From: admin Date: Thu, 21 Oct 2010 06:40:05 +0000 (+0000) Subject: This commit was generated by cvs2git to create tag 'Step0_WithoutSPLITTER'. X-Git-Tag: Step0_WithoutSPLITTER X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=497db83354642df7112db5ff43a8d0c01508d61e;p=tools%2Fmedcoupling.git This commit was generated by cvs2git to create tag 'Step0_WithoutSPLITTER'. Sprout from V6_MEDFILE3 2010-10-21 06:40:04 UTC ageay '*** empty log message ***' Delete: doc/doxygen/images/head.png doc/doxygen/static/doxygen.css doc/doxygen/static/footer.html doc/doxygen/static/header.html.in doc/salome/Makefile.am doc/salome/tui/Makefile.am doc/salome/tui/doxyfile.in doc/salome/tui/images/head.png doc/salome/tui/input/index.doc doc/salome/tui/static/doxygen.css doc/salome/tui/static/footer.html doc/salome/tui/static/header.html.in idl/Compo1Py.idl idl/MED.idl idl/MEDCouplingCorbaServant.idl idl/MEDCouplingCorbaServantTest.idl idl/MED_Gen.idl idl/Makefile.am idl/ParaMEDCouplingCorbaServant.idl idl/ParaMEDMEMComponent.idl resources/Box1.med resources/Box1Moderate.med resources/Box2.med resources/Box2Moderate.med resources/Box3.med resources/BoxEvenSmaller1.med resources/BoxHexa1.med resources/BoxHexa2.med resources/BoxModSmall1.med resources/BoxModSmall2.med resources/BoxTetra2.med resources/Case1.cnc resources/Case1.inp resources/Case1.xyz resources/ChampsDarcy.med resources/ComplexIncludedTetra.med resources/ComplexIncludingTetra.med resources/CornerTetra.med resources/Darcy3_3D_H_10x10x10.sauve resources/Darcy3_3D_H_10x10x10_2.med resources/Data.png resources/DegenEdgeXY.med resources/DegenFaceXYZ.med resources/DegenTranslatedInPlane.med resources/DividedGenTetra1.med resources/DividedGenTetra2.med resources/DividedUnitTetra.med resources/DividedUnitTetraSimpler.med resources/GenTetra1.med resources/GenTetra2.med resources/GeneralTetra.med resources/H_CastCast_EFMH_I129_COUPLEX1.med resources/H_CastCast_VF_I129_COUPLEX1.med resources/H_CastCast_VF_Se79_COUPLEX1.med resources/H_CastPorf_I129_COUPLEX1.med resources/H_CastPorf_Se79_COUPLEX1.med resources/H_PorfCast_EFMH_I129_COUPLEX1.med resources/H_PorfCast_EFMH_Se79_COUPLEX1.med resources/H_PorfPorf_I129_COUPLEX1.med resources/H_Traces_I129_COUPLEX1.med resources/H_Traces_Se79_COUPLEX1.med resources/HalfstripOnly.med resources/HalfstripOnly2.med resources/Infos.png resources/LargeInconsistentTetra.med resources/LargeUnitTetra.med resources/MEDCatalog.xml.in resources/Makefile.am resources/Mesh3D_10_2d1.med resources/Mesh3D_10_2d2.med resources/Mesh3D_11.med resources/Mistrat.med resources/Mistrat_import22.med resources/ModuleMed.png resources/MovedHexaBox1.med resources/MovedHexaBox2.med resources/NudgedDividedUnitTetra.med resources/NudgedDividedUnitTetraSimpler.med resources/NudgedSimpler.med resources/NudgedTetra.med resources/Old_ChampsDarcy.med resources/Old_H_CastCast_EFMH_I129_COUPLEX1.med resources/Old_H_CastCast_VF_I129_COUPLEX1.med resources/Old_H_CastCast_VF_Se79_COUPLEX1.med resources/Old_H_CastPorf_I129_COUPLEX1.med resources/Old_H_CastPorf_Se79_COUPLEX1.med resources/Old_H_PorfCast_EFMH_I129_COUPLEX1.med resources/Old_H_PorfCast_EFMH_Se79_COUPLEX1.med resources/Old_H_PorfPorf_I129_COUPLEX1.med resources/Old_H_PorfPorf_Se79_COUPLEX1.med resources/Old_H_Traces_I129_COUPLEX1.med resources/Old_H_Traces_Se79_COUPLEX1.med resources/Old_darcy2_Castem_EFMH.med resources/Old_darcy2_Castem_qua_EFMH.med resources/Old_darcy2_Castem_qua_VF.med resources/Old_darcy_1.1_res.med resources/Old_darcy_1.3_resCASTEM.med resources/Old_darcy_1.3_resPORFLOW.med resources/Old_darcy_1.3_resTRACES.med resources/Old_maillage_chemvalIV_cas1_40elts.med resources/Pol1.fig resources/Pol2.fig resources/Pol3.fig resources/Pol4.fig resources/SalomeApp.xml resources/SimpleHalfstripOnly.med resources/SimpleIncludedTetra.med resources/SimpleIncludingTetra.med resources/Structure.png resources/Test2D.med resources/Test2Dpoly.med resources/Test3D.med resources/Test3Dpoly.med resources/TimeStamps.med resources/TimeStamps_import22.med resources/TinyBox.med resources/TrickyTetra1.med resources/UnitTetra.med resources/UnitTetraDegenT.med resources/blow5_ascii.case resources/blow5_ascii.geo resources/blow5_ascii_cd_displacement resources/blow5_ascii_cd_thickness resources/blow5_ascii_pd_displacement resources/blow5_ascii_pd_thickness resources/boitenew.cnc resources/boitenew.inp resources/boitenew.xyz resources/carre_en_quad4.med resources/carre_en_quad4_import22.med resources/carre_en_quad4_seg2.med resources/carre_en_quad4_seg2_import22.med resources/cas_defaut_domaine_fluide.med resources/cube.cnc resources/cube.inp resources/cube.xyz resources/cube_hexa8.med resources/cube_hexa8_import22.med resources/cube_hexa8_quad4.med resources/cube_hexa8_quad4_import22.med resources/darcy2_Castem_EFMH.med resources/darcy2_Castem_qua_EFMH.med resources/darcy2_Castem_qua_VF.med resources/darcy_1.1_res.med resources/darcy_1.3_resCASTEM.med resources/darcy_1.3_resPORFLOW.med resources/darcy_1.3_resTRACES.med resources/dx200_dy1_avec_2couches.sauve resources/elle_2D_QT_10x10.sauve resources/elle_2D_QT_2x2.sauve resources/elle_2D_QT_40x40.sauve resources/elle_2D_QT_4x4.sauve resources/elle_3D_HPr_10x10x10.sauve resources/elle_3D_HPr_10x10x10_2.med resources/elle_3D_HPr_2x2x2.sauve resources/elle_3D_HPr_2x2x2_2.med resources/elle_3D_HPr_4x4x4.sauve resources/elle_3D_HPr_4x4x4_2.med resources/explore_med_file.png resources/extendedtransport53_triangles.med resources/field_selection.png resources/geomMesh21.med resources/geomMesh22.med resources/inclusion_2d.sauve resources/inclusion_2d_raf.sauve resources/mail-test1-4-1.sauve resources/mail-test1-4-2.sauve resources/mail_ktest1-3-hexa.sauve resources/mail_ktest1-3-tetra.sauve resources/mail_ktest3-1.sauve resources/mail_ktest3-2.sauve resources/mail_test1-1-qua.sauve resources/mail_test1-1-tri.sauve resources/mail_test1-2-qua.sauve resources/mail_test1-2-tri.sauve resources/maill.0.med resources/maill.00.med resources/maill.00_nofield.med resources/maill.00_nomesh.med resources/maill.00_without_seg2.med resources/maillage_5_5_5.med resources/maillage_CHEMVAL_100elts.sauve resources/maillage_CHEMVAL_40elts.sauve resources/maillage_UniSegFam.med resources/maillage_UniSegFam_import22.med resources/maillage_andra2_100elts.sauve resources/maillage_cas2_2d.sauve resources/maillage_cas4_234elts.sauve resources/maillage_chemvalIV_cas1_100elts.sauve resources/maillage_chemvalIV_cas1_40elts.med resources/maillage_chemvalIV_cas1_40elts.sauve resources/mesh.med resources/mesh_import22.med resources/mesh_selection.png resources/pointe.med resources/pointe_import22.med resources/poly3D.med resources/polyedres.med resources/polygones.med resources/recoll_bord.med resources/square1.med resources/square1_split resources/square1_split1.med resources/square1_split2.med resources/square1_split3.med resources/square2.med resources/square2_split resources/square2_split1.med resources/square2_split2.med resources/test19.med resources/test3.cnc resources/test3.inp resources/test3.xyz resources/testStructCart3D.med resources/test_2D.med resources/titi.cnc resources/titi.inp resources/titi.xyz resources/trio_2D.med resources/zzzz121b.med resources/zzzz121b_without_tr6.med src/INTERP_KERNEL/BBTree.txx src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx src/INTERP_KERNEL/Bases/InterpKernelException.cxx src/INTERP_KERNEL/Bases/InterpKernelException.hxx src/INTERP_KERNEL/Bases/InterpKernelHashFun.hxx src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx src/INTERP_KERNEL/Bases/Makefile.am src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx src/INTERP_KERNEL/BoundingBox.cxx src/INTERP_KERNEL/BoundingBox.hxx src/INTERP_KERNEL/CellModel.cxx src/INTERP_KERNEL/CellModel.hxx src/INTERP_KERNEL/ConvexIntersector.hxx src/INTERP_KERNEL/ConvexIntersector.txx src/INTERP_KERNEL/CurveIntersector.hxx src/INTERP_KERNEL/CurveIntersector.txx src/INTERP_KERNEL/CurveIntersectorP0P0.hxx src/INTERP_KERNEL/CurveIntersectorP0P0.txx src/INTERP_KERNEL/CurveIntersectorP0P1.hxx src/INTERP_KERNEL/CurveIntersectorP0P1.txx src/INTERP_KERNEL/CurveIntersectorP1P0.hxx src/INTERP_KERNEL/CurveIntersectorP1P0.txx src/INTERP_KERNEL/CurveIntersectorP1P1.hxx src/INTERP_KERNEL/CurveIntersectorP1P1.txx src/INTERP_KERNEL/DirectedBoundingBox.cxx src/INTERP_KERNEL/DirectedBoundingBox.hxx src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx src/INTERP_KERNEL/ExprEval/Makefile.am src/INTERP_KERNEL/GenMathFormulae.hxx src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.hxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx src/INTERP_KERNEL/Geometric2D/Makefile.am src/INTERP_KERNEL/Geometric2DIntersector.hxx src/INTERP_KERNEL/Geometric2DIntersector.txx src/INTERP_KERNEL/INTERPKERNELDefines.hxx src/INTERP_KERNEL/IntegralUniformIntersector.hxx src/INTERP_KERNEL/IntegralUniformIntersector.txx src/INTERP_KERNEL/InterpKernelMatrix.hxx src/INTERP_KERNEL/InterpKernelMeshQuality.cxx src/INTERP_KERNEL/InterpKernelMeshQuality.hxx src/INTERP_KERNEL/InterpKernelUtilities.hxx src/INTERP_KERNEL/Interpolation.hxx src/INTERP_KERNEL/Interpolation.txx src/INTERP_KERNEL/Interpolation1D.hxx src/INTERP_KERNEL/Interpolation1D.txx src/INTERP_KERNEL/Interpolation2D.hxx src/INTERP_KERNEL/Interpolation2D.txx src/INTERP_KERNEL/Interpolation2DCurve.hxx src/INTERP_KERNEL/Interpolation2DCurve.txx src/INTERP_KERNEL/Interpolation3D.hxx src/INTERP_KERNEL/Interpolation3D.txx src/INTERP_KERNEL/Interpolation3DSurf.hxx src/INTERP_KERNEL/Interpolation3DSurf.txx src/INTERP_KERNEL/InterpolationCC.hxx src/INTERP_KERNEL/InterpolationCC.txx src/INTERP_KERNEL/InterpolationCU.hxx src/INTERP_KERNEL/InterpolationCU.txx src/INTERP_KERNEL/InterpolationCurve.hxx src/INTERP_KERNEL/InterpolationCurve.txx src/INTERP_KERNEL/InterpolationOptions.cxx src/INTERP_KERNEL/InterpolationOptions.hxx src/INTERP_KERNEL/InterpolationPlanar.hxx src/INTERP_KERNEL/InterpolationPlanar.txx src/INTERP_KERNEL/InterpolationUtils.hxx src/INTERP_KERNEL/Intersector3D.hxx src/INTERP_KERNEL/Intersector3D.txx src/INTERP_KERNEL/Intersector3DP0P0.hxx src/INTERP_KERNEL/Intersector3DP0P0.txx src/INTERP_KERNEL/Intersector3DP0P1.hxx src/INTERP_KERNEL/Intersector3DP0P1.txx src/INTERP_KERNEL/Intersector3DP1P0.hxx src/INTERP_KERNEL/Intersector3DP1P0.txx src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx src/INTERP_KERNEL/Intersector3DP1P0Bary.txx src/INTERP_KERNEL/Intersector3DP1P1.hxx src/INTERP_KERNEL/Intersector3DP1P1.txx src/INTERP_KERNEL/IntersectorCU.hxx src/INTERP_KERNEL/IntersectorCU.txx src/INTERP_KERNEL/IntersectorCU1D.hxx src/INTERP_KERNEL/IntersectorCU1D.txx src/INTERP_KERNEL/IntersectorCU2D.hxx src/INTERP_KERNEL/IntersectorCU2D.txx src/INTERP_KERNEL/IntersectorCU3D.hxx src/INTERP_KERNEL/IntersectorCU3D.txx src/INTERP_KERNEL/Log.hxx src/INTERP_KERNEL/Makefile.am src/INTERP_KERNEL/MeshElement.hxx src/INTERP_KERNEL/MeshElement.txx src/INTERP_KERNEL/MeshRegion.hxx src/INTERP_KERNEL/MeshRegion.txx src/INTERP_KERNEL/MeshUtils.hxx src/INTERP_KERNEL/PlanarIntersector.hxx src/INTERP_KERNEL/PlanarIntersector.txx src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx src/INTERP_KERNEL/PlanarIntersectorP0P0.txx src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx src/INTERP_KERNEL/PlanarIntersectorP0P1.txx src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx src/INTERP_KERNEL/PlanarIntersectorP1P0.txx src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx src/INTERP_KERNEL/PlanarIntersectorP1P1.txx src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx src/INTERP_KERNEL/PointLocator2DIntersector.hxx src/INTERP_KERNEL/PointLocator2DIntersector.txx src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx src/INTERP_KERNEL/PointLocatorAlgos.txx src/INTERP_KERNEL/PolygonAlgorithms.hxx src/INTERP_KERNEL/PolygonAlgorithms.txx src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx src/INTERP_KERNEL/RegionNode.hxx src/INTERP_KERNEL/SplitterTetra.hxx src/INTERP_KERNEL/SplitterTetra.txx src/INTERP_KERNEL/TargetIntersector.hxx src/INTERP_KERNEL/TetraAffineTransform.cxx src/INTERP_KERNEL/TetraAffineTransform.hxx src/INTERP_KERNEL/TransformedTriangle.cxx src/INTERP_KERNEL/TransformedTriangle.hxx src/INTERP_KERNEL/TransformedTriangleInline.hxx src/INTERP_KERNEL/TransformedTriangleIntersect.cxx src/INTERP_KERNEL/TransformedTriangleMath.cxx src/INTERP_KERNEL/TranslationRotationMatrix.cxx src/INTERP_KERNEL/TranslationRotationMatrix.hxx src/INTERP_KERNEL/TriangulationIntersector.hxx src/INTERP_KERNEL/TriangulationIntersector.txx src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx src/INTERP_KERNEL/VectorUtils.hxx src/INTERP_KERNEL/VolSurfFormulae.hxx src/INTERP_KERNEL/VolSurfUser.hxx src/INTERP_KERNEL/VolSurfUser.txx src/INTERP_KERNELTest/BBTreeTest.cxx src/INTERP_KERNELTest/BBTreeTest.hxx src/INTERP_KERNELTest/BasicMainTest.hxx src/INTERP_KERNELTest/CppUnitTest.cxx src/INTERP_KERNELTest/CppUnitTest.hxx src/INTERP_KERNELTest/ExprEvalInterpTest.cxx src/INTERP_KERNELTest/ExprEvalInterpTest.hxx src/INTERP_KERNELTest/HexaTests.hxx src/INTERP_KERNELTest/InterpKernelTestExport.hxx src/INTERP_KERNELTest/Interpolation3DTest.cxx src/INTERP_KERNELTest/Interpolation3DTest.hxx src/INTERP_KERNELTest/InterpolationOptionsTest.cxx src/INTERP_KERNELTest/InterpolationOptionsTest.hxx src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx src/INTERP_KERNELTest/InterpolationTestSuite.hxx src/INTERP_KERNELTest/MEDMeshMaker.cxx src/INTERP_KERNELTest/MEDMeshMaker.hxx src/INTERP_KERNELTest/Makefile.am src/INTERP_KERNELTest/MeshTestToolkit.hxx src/INTERP_KERNELTest/MeshTestToolkit.txx src/INTERP_KERNELTest/MultiElement2DTests.hxx src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx src/INTERP_KERNELTest/MultiElementTetraTests.hxx src/INTERP_KERNELTest/PerfTest.cxx src/INTERP_KERNELTest/PointLocatorTest.cxx src/INTERP_KERNELTest/PointLocatorTest.hxx src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx src/INTERP_KERNELTest/QuadraticPlanarInterpTest3.cxx src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx src/INTERP_KERNELTest/RemapperTest.cxx src/INTERP_KERNELTest/SingleElementPlanarTests.cxx src/INTERP_KERNELTest/SingleElementPlanarTests.hxx src/INTERP_KERNELTest/SingleElementTetraTests.hxx src/INTERP_KERNELTest/TestInterpKernel.cxx src/INTERP_KERNELTest/TestInterpKernelUtils.cxx src/INTERP_KERNELTest/TestInterpKernelUtils.hxx src/INTERP_KERNELTest/TestingUtils.hxx src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx src/INTERP_KERNELTest/TransformedTriangleTest.cxx src/INTERP_KERNELTest/TransformedTriangleTest.hxx src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx src/INTERP_KERNELTest/perf_test.sh src/MED/MED_test1.py src/MED/MED_test2.py src/MED/Makefile.am src/MED/Med_Gen_Driver_i.cxx src/MED/Med_Gen_Driver_i.hxx src/MED/Med_Gen_i.cxx src/MED/Med_Gen_i.hxx src/MED/Med_Gen_test.py src/MED/testMedAlliances.py src/MED/testMedAlliances1.py src/MEDCoupling/MEDCoupling.hxx src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx src/MEDCoupling/MEDCouplingCMesh.cxx src/MEDCoupling/MEDCouplingCMesh.hxx src/MEDCoupling/MEDCouplingExtrudedMesh.cxx src/MEDCoupling/MEDCouplingExtrudedMesh.hxx src/MEDCoupling/MEDCouplingField.cxx src/MEDCoupling/MEDCouplingField.hxx src/MEDCoupling/MEDCouplingFieldDiscretization.cxx src/MEDCoupling/MEDCouplingFieldDiscretization.hxx src/MEDCoupling/MEDCouplingFieldDouble.cxx src/MEDCoupling/MEDCouplingFieldDouble.hxx src/MEDCoupling/MEDCouplingGaussLocalization.cxx src/MEDCoupling/MEDCouplingGaussLocalization.hxx src/MEDCoupling/MEDCouplingMemArray.cxx src/MEDCoupling/MEDCouplingMemArray.hxx src/MEDCoupling/MEDCouplingMemArray.txx src/MEDCoupling/MEDCouplingMesh.cxx src/MEDCoupling/MEDCouplingMesh.hxx src/MEDCoupling/MEDCouplingNatureOfField.cxx src/MEDCoupling/MEDCouplingNatureOfField.hxx src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx src/MEDCoupling/MEDCouplingPointSet.cxx src/MEDCoupling/MEDCouplingPointSet.hxx src/MEDCoupling/MEDCouplingPointSet.txx src/MEDCoupling/MEDCouplingRefCountObject.cxx src/MEDCoupling/MEDCouplingRefCountObject.hxx src/MEDCoupling/MEDCouplingRemapper.cxx src/MEDCoupling/MEDCouplingRemapper.hxx src/MEDCoupling/MEDCouplingTimeDiscretization.cxx src/MEDCoupling/MEDCouplingTimeDiscretization.hxx src/MEDCoupling/MEDCouplingTimeLabel.cxx src/MEDCoupling/MEDCouplingTimeLabel.hxx src/MEDCoupling/MEDCouplingUMesh.cxx src/MEDCoupling/MEDCouplingUMesh.hxx src/MEDCoupling/MEDCouplingUMeshDesc.cxx src/MEDCoupling/MEDCouplingUMeshDesc.hxx src/MEDCoupling/Makefile.am src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx src/MEDCoupling/Test/Makefile.am src/MEDCoupling/Test/TestMEDCoupling.cxx src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx src/MEDCouplingCorba/Client/MEDCouplingCMeshClient.cxx src/MEDCouplingCorba/Client/MEDCouplingCMeshClient.hxx src/MEDCouplingCorba/Client/MEDCouplingClient.hxx src/MEDCouplingCorba/Client/MEDCouplingExtrudedMeshClient.cxx src/MEDCouplingCorba/Client/MEDCouplingExtrudedMeshClient.hxx src/MEDCouplingCorba/Client/MEDCouplingFieldDoubleClient.cxx src/MEDCouplingCorba/Client/MEDCouplingFieldDoubleClient.hxx src/MEDCouplingCorba/Client/MEDCouplingMeshClient.cxx src/MEDCouplingCorba/Client/MEDCouplingMeshClient.hxx src/MEDCouplingCorba/Client/MEDCouplingUMeshClient.cxx src/MEDCouplingCorba/Client/MEDCouplingUMeshClient.hxx src/MEDCouplingCorba/Client/Makefile.am src/MEDCouplingCorba/MEDCouplingCMeshServant.cxx src/MEDCouplingCorba/MEDCouplingCMeshServant.hxx src/MEDCouplingCorba/MEDCouplingCorba.hxx src/MEDCouplingCorba/MEDCouplingExtrudedMeshServant.cxx src/MEDCouplingCorba/MEDCouplingExtrudedMeshServant.hxx src/MEDCouplingCorba/MEDCouplingFieldDoubleServant.cxx src/MEDCouplingCorba/MEDCouplingFieldDoubleServant.hxx src/MEDCouplingCorba/MEDCouplingFieldServant.cxx src/MEDCouplingCorba/MEDCouplingFieldServant.hxx src/MEDCouplingCorba/MEDCouplingMeshServant.cxx src/MEDCouplingCorba/MEDCouplingMeshServant.hxx src/MEDCouplingCorba/MEDCouplingPointSetServant.cxx src/MEDCouplingCorba/MEDCouplingPointSetServant.hxx src/MEDCouplingCorba/MEDCouplingRefCountServant.cxx src/MEDCouplingCorba/MEDCouplingRefCountServant.hxx src/MEDCouplingCorba/MEDCouplingUMeshServant.cxx src/MEDCouplingCorba/MEDCouplingUMeshServant.hxx src/MEDCouplingCorba/Makefile.am src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponent.cxx src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponent.hxx src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentClt.cxx src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentClt.hxx src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentServ.cxx src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentServ.hxx src/MEDCouplingCorba/Test/Makefile.am src/MEDCouplingCorba/Test/TestMEDCouplingCorbaClt.cxx src/MEDCouplingCorba/Test/TestMEDCouplingCorbaServ.cxx src/MEDCouplingCorba_Swig/Client/Makefile.am src/MEDCouplingCorba_Swig/Client/libMEDCouplingClient_Swig.i src/MEDCouplingCorba_Swig/MEDCouplingCorbaSwigTest.py src/MEDCouplingCorba_Swig/MEDCouplingCorbaSwigTestClt.py src/MEDCouplingCorba_Swig/MEDCouplingCorbaSwigTestServ.py src/MEDCouplingCorba_Swig/Makefile.am src/MEDCouplingCorba_Swig/TestMEDCouplingCorbaClt.py src/MEDCouplingCorba_Swig/TestMEDCouplingCorbaServ.py src/MEDCouplingCorba_Swig/libMEDCouplingClient_Swig.i src/MEDCouplingCorba_Swig/libMEDCouplingCorba_Swig.i src/MEDCoupling_Swig/MEDCouplingBasicsTest.py src/MEDCoupling_Swig/MEDCouplingDataForTest.py src/MEDCoupling_Swig/MEDCouplingRemapperTest.py src/MEDCoupling_Swig/MEDCouplingTypemaps.i src/MEDCoupling_Swig/Makefile.am src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i src/MEDCoupling_Swig/libMEDCoupling_Swig.i src/MEDGUI/MED_images.ts src/MEDGUI/MED_msg_en.ts src/MEDGUI/MED_msg_fr.ts src/MEDGUI/Makefile.am src/MEDGUI/MedGUI.cxx src/MEDGUI/MedGUI.h src/MEDGUI/MedGUI_Selection.cxx src/MEDGUI/MedGUI_Selection.h src/MEDLoader/MEDLoader.cxx src/MEDLoader/MEDLoader.hxx src/MEDLoader/MEDLoaderBase.cxx src/MEDLoader/MEDLoaderBase.hxx src/MEDLoader/MEDLoaderDefines.hxx src/MEDLoader/MEDLoaderTypemaps.i src/MEDLoader/Makefile.am src/MEDLoader/Swig/MEDLoaderDataForTest.py src/MEDLoader/Swig/MEDLoaderTest.py src/MEDLoader/Swig/MEDLoaderTest2.py src/MEDLoader/Swig/MEDLoaderTypemaps.i src/MEDLoader/Swig/Makefile.am src/MEDLoader/Swig/libMEDLoader_Swig.i src/MEDLoader/Test/MEDLoaderTest.cxx src/MEDLoader/Test/MEDLoaderTest.hxx src/MEDLoader/Test/Makefile.am src/MEDLoader/Test/TestMEDLoader.cxx src/MEDMEM/DataTest/Data/elle_2D_QT_2x2.sauve src/MEDMEM/DataTest/Data/elle_2D_QT_4x4.sauve src/MEDMEM/DataTest/Data/elle_3D_HPr_4x4x4.sauve src/MEDMEM/DataTest/Data/maill.0.med src/MEDMEM/DataTest/Data/mesh.med src/MEDMEM/DataTest/Data/pointe.med src/MEDMEM/DataTest/Data/zzzz121b.med src/MEDMEM/DataTest/Maillages.txt src/MEDMEM/DataTest/README src/MEDMEM/DataTest/Ref/RtestUCellModel src/MEDMEM/DataTest/Ref/RtestUGeoNameMeshEntities src/MEDMEM/DataTest/constituedump.sh src/MEDMEM/DataTest/testreadCoordinate.sh src/MEDMEM/DataTest/testreadEntete.sh src/MEDMEM/DataTest/tous.sh src/MEDMEM/Doxyfile_med_devel.in src/MEDMEM/Doxyfile_med_user.in src/MEDMEM/MEDMEM.hxx src/MEDMEM/MEDMEM_Array.hxx src/MEDMEM/MEDMEM_ArrayConvert.hxx src/MEDMEM/MEDMEM_ArrayInterface.hxx src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx src/MEDMEM/MEDMEM_CellModel.cxx src/MEDMEM/MEDMEM_CellModel.hxx src/MEDMEM/MEDMEM_ConnectZone.cxx src/MEDMEM/MEDMEM_ConnectZone.hxx src/MEDMEM/MEDMEM_Connectivity.cxx src/MEDMEM/MEDMEM_Connectivity.hxx src/MEDMEM/MEDMEM_Coordinate.cxx src/MEDMEM/MEDMEM_Coordinate.hxx src/MEDMEM/MEDMEM_DriverFactory.cxx src/MEDMEM/MEDMEM_DriverFactory.hxx src/MEDMEM/MEDMEM_DriverTools.cxx src/MEDMEM/MEDMEM_DriverTools.hxx src/MEDMEM/MEDMEM_DriversDef.cxx src/MEDMEM/MEDMEM_DriversDef.hxx src/MEDMEM/MEDMEM_EnsightFieldDriver.cxx src/MEDMEM/MEDMEM_EnsightFieldDriver.hxx src/MEDMEM/MEDMEM_EnsightMedDriver.cxx src/MEDMEM/MEDMEM_EnsightMedDriver.hxx src/MEDMEM/MEDMEM_EnsightMeshDriver.cxx src/MEDMEM/MEDMEM_EnsightMeshDriver.hxx src/MEDMEM/MEDMEM_EnsightUtils.cxx src/MEDMEM/MEDMEM_EnsightUtils.hxx src/MEDMEM/MEDMEM_Exception.cxx src/MEDMEM/MEDMEM_Exception.hxx src/MEDMEM/MEDMEM_Extractor.cxx src/MEDMEM/MEDMEM_Extractor.hxx src/MEDMEM/MEDMEM_Family.cxx src/MEDMEM/MEDMEM_Family.hxx src/MEDMEM/MEDMEM_Field.cxx src/MEDMEM/MEDMEM_Field.hxx src/MEDMEM/MEDMEM_FieldConvert.hxx src/MEDMEM/MEDMEM_FieldForward.hxx src/MEDMEM/MEDMEM_GMesh.cxx src/MEDMEM/MEDMEM_GMesh.hxx src/MEDMEM/MEDMEM_GaussLocalization.cxx src/MEDMEM/MEDMEM_GaussLocalization.hxx src/MEDMEM/MEDMEM_GenDriver.cxx src/MEDMEM/MEDMEM_GenDriver.hxx src/MEDMEM/MEDMEM_GibiMeshDriver.cxx src/MEDMEM/MEDMEM_GibiMeshDriver.hxx src/MEDMEM/MEDMEM_Grid.cxx src/MEDMEM/MEDMEM_Grid.hxx src/MEDMEM/MEDMEM_Group.cxx src/MEDMEM/MEDMEM_Group.hxx src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx src/MEDMEM/MEDMEM_Init.cxx src/MEDMEM/MEDMEM_InterlacingPolicy.hxx src/MEDMEM/MEDMEM_InterlacingTraits.hxx src/MEDMEM/MEDMEM_MEDMEMchampLire.cxx src/MEDMEM/MEDMEM_MEDMEMchampLire.hxx src/MEDMEM/MEDMEM_MEDMEMgaussEcr.cxx src/MEDMEM/MEDMEM_MEDMEMgaussEcr.hxx src/MEDMEM/MEDMEM_MEDMEMprofilEcr.cxx src/MEDMEM/MEDMEM_MEDMEMprofilEcr.hxx src/MEDMEM/MEDMEM_MedFieldDriver.hxx src/MEDMEM/MEDMEM_MedFieldDriver.txx src/MEDMEM/MEDMEM_MedFileBrowser.cxx src/MEDMEM/MEDMEM_MedFileBrowser.hxx src/MEDMEM/MEDMEM_MedMeshDriver.cxx src/MEDMEM/MEDMEM_MedMeshDriver.hxx src/MEDMEM/MEDMEM_MedVersion.cxx src/MEDMEM/MEDMEM_MedVersion.hxx src/MEDMEM/MEDMEM_Mesh.cxx src/MEDMEM/MEDMEM_Mesh.hxx src/MEDMEM/MEDMEM_Meshing.cxx src/MEDMEM/MEDMEM_Meshing.hxx src/MEDMEM/MEDMEM_ModulusArray.hxx src/MEDMEM/MEDMEM_OptionManager.hxx src/MEDMEM/MEDMEM_PointerOf.hxx src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx src/MEDMEM/MEDMEM_PorflowMeshDriver.hxx src/MEDMEM/MEDMEM_RCBase.cxx src/MEDMEM/MEDMEM_RCBase.hxx src/MEDMEM/MEDMEM_Remapper.cxx src/MEDMEM/MEDMEM_Remapper.hxx src/MEDMEM/MEDMEM_STRING.hxx src/MEDMEM/MEDMEM_SetInterlacingType.hxx src/MEDMEM/MEDMEM_SkyLineArray.cxx src/MEDMEM/MEDMEM_SkyLineArray.hxx src/MEDMEM/MEDMEM_Support.cxx src/MEDMEM/MEDMEM_Support.hxx src/MEDMEM/MEDMEM_Tags.hxx src/MEDMEM/MEDMEM_TopLevel.cxx src/MEDMEM/MEDMEM_TopLevel.hxx src/MEDMEM/MEDMEM_TypeMeshDriver.cxx src/MEDMEM/MEDMEM_TypeMeshDriver.hxx src/MEDMEM/MEDMEM_Unit.cxx src/MEDMEM/MEDMEM_Unit.hxx src/MEDMEM/MEDMEM_Utilities.hxx src/MEDMEM/MEDMEM_VtkFieldDriver.hxx src/MEDMEM/MEDMEM_VtkMedDriver.cxx src/MEDMEM/MEDMEM_VtkMedDriver.hxx src/MEDMEM/MEDMEM_VtkMeshDriver.cxx src/MEDMEM/MEDMEM_VtkMeshDriver.hxx src/MEDMEM/MEDMEM_define.hxx src/MEDMEM/MEDMEM_medimport_src.cxx src/MEDMEM/MEDMEM_medimport_src.hxx src/MEDMEM/MEDMEM_nArray.hxx src/MEDMEM/MEDNormalizedUnstructuredMesh.hxx src/MEDMEM/MEDNormalizedUnstructuredMesh.txx src/MEDMEM/Makefile.am src/MEDMEM/PointLocator.cxx src/MEDMEM/PointLocator.hxx src/MEDMEM/checkScript src/MEDMEMBinTest/Makefile.am src/MEDMEMBinTest/convertToPoly.cxx src/MEDMEMBinTest/create_grid.c src/MEDMEMBinTest/create_mesh.c src/MEDMEMBinTest/create_mesh_c2q4.c src/MEDMEMBinTest/create_mesh_c2q4s2.c src/MEDMEMBinTest/create_mesh_c2q4s2_wrong.c src/MEDMEMBinTest/create_mesh_c3h8.c src/MEDMEMBinTest/create_mesh_c3h8q4.c src/MEDMEMBinTest/create_mesh_c3h8q4_wrong.c src/MEDMEMBinTest/create_poly2D.c src/MEDMEMBinTest/create_poly3D.c src/MEDMEMBinTest/dumpInterpolation.cxx src/MEDMEMBinTest/duplicateMED.cxx src/MEDMEMBinTest/duplicateMEDMESH.cxx src/MEDMEMBinTest/ensight2med.cxx src/MEDMEMBinTest/med2_1_To_med2_2.cxx src/MEDMEMBinTest/med2ensight.cxx src/MEDMEMBinTest/med2vtk.cxx src/MEDMEMBinTest/med_test.cxx src/MEDMEMBinTest/scripts/check_convertToPoly src/MEDMEMBinTest/scripts/check_duplicateMED src/MEDMEMBinTest/scripts/check_ensight2med src/MEDMEMBinTest/scripts/check_med2_1_To_med2_2 src/MEDMEMBinTest/scripts/check_med2ensight src/MEDMEMBinTest/scripts/check_med2vtk src/MEDMEMBinTest/scripts/check_readCoordinate src/MEDMEMBinTest/scripts/check_readEntete src/MEDMEMBinTest/scripts/check_testAnalFile src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshRead src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshWrite src/MEDMEMBinTest/scripts/check_test_MEDMEM_poly3D src/MEDMEMBinTest/scripts/check_test_copie_connectivity src/MEDMEMBinTest/scripts/check_test_copie_family src/MEDMEMBinTest/scripts/check_test_copie_fieldT src/MEDMEMBinTest/scripts/check_test_copie_field_ src/MEDMEMBinTest/scripts/check_test_copie_group src/MEDMEMBinTest/scripts/check_test_copie_mesh src/MEDMEMBinTest/scripts/check_test_copie_support src/MEDMEMBinTest/scripts/check_test_gibi_driver src/MEDMEMBinTest/scripts/check_test_grid src/MEDMEMBinTest/scripts/check_test_operation_fielddouble src/MEDMEMBinTest/scripts/check_test_operation_fieldint src/MEDMEMBinTest/scripts/check_test_porflow_driver src/MEDMEMBinTest/scripts/check_test_profil_MedFieldDriver src/MEDMEMBinTest/scripts/check_test_profil_gauss_MedFieldDriver src/MEDMEMBinTest/testAG.cxx src/MEDMEMBinTest/testAnalFile.cxx src/MEDMEMBinTest/testConvertPolygon.cxx src/MEDMEMBinTest/test_GaussLocalization.cxx src/MEDMEMBinTest/test_MEDMEM_Array.cxx src/MEDMEMBinTest/test_MEDMEM_CellModel.cxx src/MEDMEMBinTest/test_MEDMEM_Meshing.cxx src/MEDMEMBinTest/test_MEDMEM_MeshingFlica.cxx src/MEDMEMBinTest/test_MEDMEM_MeshingPoly.cxx src/MEDMEMBinTest/test_MEDMEM_Meshing_poly.cxx src/MEDMEMBinTest/test_MEDMEM_ModulusArray.cxx src/MEDMEMBinTest/test_MEDMEM_PolyDriverMedMeshRead.cxx src/MEDMEMBinTest/test_MEDMEM_PolyDriverMedMeshWrite.cxx src/MEDMEMBinTest/test_MEDMEM_SkyLineArray.cxx src/MEDMEMBinTest/test_MEDMEM_nArray.cxx src/MEDMEMBinTest/test_MEDMEM_poly3D.cxx src/MEDMEMBinTest/test_affect_medarray.cxx src/MEDMEMBinTest/test_copie_connectivity.cxx src/MEDMEMBinTest/test_copie_coordinate.cxx src/MEDMEMBinTest/test_copie_family.cxx src/MEDMEMBinTest/test_copie_fieldT.cxx src/MEDMEMBinTest/test_copie_field_.cxx src/MEDMEMBinTest/test_copie_group.cxx src/MEDMEMBinTest/test_copie_medarray.cxx src/MEDMEMBinTest/test_copie_mesh.cxx src/MEDMEMBinTest/test_copie_support.cxx src/MEDMEMBinTest/test_gibi_driver.cxx src/MEDMEMBinTest/test_grid.cxx src/MEDMEMBinTest/test_operation_fielddouble.cxx src/MEDMEMBinTest/test_operation_fieldint.cxx src/MEDMEMBinTest/test_porflow_driver.cxx src/MEDMEMBinTest/test_profil_MedFieldDriver.cxx src/MEDMEMBinTest/test_profil_gauss_MedFieldDriver.cxx src/MEDMEMBinTest/test_write_groups_poly.cxx src/MEDMEMBinTest/tests/readCoordinate.cxx src/MEDMEMBinTest/tests/readEntete.cxx src/MEDMEMBinTest/tests/testUArray.cxx src/MEDMEMBinTest/tests/testUArray.cxx.ok src/MEDMEMBinTest/tests/testUCellModel.cxx src/MEDMEMBinTest/tests/testUCoordinate.cxx src/MEDMEMBinTest/tests/testUGeoNameMeshEntities.cxx src/MEDMEMBinTest/tests/testUMedException.cxx src/MEDMEMBinTest/tests/testUModulusArray.cxx src/MEDMEMBinTest/tests/testUPointerOf.cxx src/MEDMEMBinTest/tests/testUSkyLineArray.cxx src/MEDMEMBinTest/tests/testUUnit.cxx src/MEDMEMCppTest/BasicMainTest.hxx src/MEDMEMCppTest/MEDMEMCppTestExport.hxx src/MEDMEMCppTest/MEDMEMTest.cxx src/MEDMEMCppTest/MEDMEMTest.hxx src/MEDMEMCppTest/MEDMEMTest_Array.cxx src/MEDMEMCppTest/MEDMEMTest_Array_fault.cxx src/MEDMEMCppTest/MEDMEMTest_AsciiFieldDriver.cxx src/MEDMEMCppTest/MEDMEMTest_Connectivity.cxx src/MEDMEMCppTest/MEDMEMTest_Connectivity_fault.cxx src/MEDMEMCppTest/MEDMEMTest_Coordinate.cxx src/MEDMEMCppTest/MEDMEMTest_Coordinate_fault.cxx src/MEDMEMCppTest/MEDMEMTest_DesactivateFacesComputation.cxx src/MEDMEMCppTest/MEDMEMTest_DriverFactory.cxx src/MEDMEMCppTest/MEDMEMTest_Exception.cxx src/MEDMEMCppTest/MEDMEMTest_Extractor.cxx src/MEDMEMCppTest/MEDMEMTest_Family.cxx src/MEDMEMCppTest/MEDMEMTest_Family_fault.cxx src/MEDMEMCppTest/MEDMEMTest_Field.cxx src/MEDMEMCppTest/MEDMEMTest_Field_fault.cxx src/MEDMEMCppTest/MEDMEMTest_Formulae.cxx src/MEDMEMCppTest/MEDMEMTest_GaussLocalization.cxx src/MEDMEMCppTest/MEDMEMTest_GetVolumeAbs.cxx src/MEDMEMCppTest/MEDMEMTest_GibiMeshDriver.cxx src/MEDMEMCppTest/MEDMEMTest_Grid.cxx src/MEDMEMCppTest/MEDMEMTest_Grid_fault.cxx src/MEDMEMCppTest/MEDMEMTest_Group.cxx src/MEDMEMCppTest/MEDMEMTest_MedFieldDriver.cxx src/MEDMEMCppTest/MEDMEMTest_MedFileBrowser.cxx src/MEDMEMCppTest/MEDMEMTest_MedMeshDriver.cxx src/MEDMEMCppTest/MEDMEMTest_MedVersion.cxx src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing.cxx src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing_fault.cxx src/MEDMEMCppTest/MEDMEMTest_ModulusArray.cxx src/MEDMEMCppTest/MEDMEMTest_PartialDescendingConnectivity.cxx src/MEDMEMCppTest/MEDMEMTest_PointerOf.cxx src/MEDMEMCppTest/MEDMEMTest_PorflowMeshDriver.cxx src/MEDMEMCppTest/MEDMEMTest_Remapper.cxx src/MEDMEMCppTest/MEDMEMTest_SkyLineArray.cxx src/MEDMEMCppTest/MEDMEMTest_Support.cxx src/MEDMEMCppTest/MEDMEMTest_Support_fault.cxx src/MEDMEMCppTest/MEDMEMTest_TopLevel.cxx src/MEDMEMCppTest/MEDMEMTest_Unit.cxx src/MEDMEMCppTest/MEDMEMTest_Utils.cxx src/MEDMEMCppTest/MEDMEMTest_Utils.hxx src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver.cxx src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver_fault.cxx src/MEDMEMCppTest/MEDMEMTest_VtkMedDriver.cxx src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver.cxx src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver_fault.cxx src/MEDMEMCppTest/MEDMEMTest_nArray.cxx src/MEDMEMCppTest/Makefile.am src/MEDMEMCppTest/TestMEDMEM.cxx src/MEDMEMCppTest/TestOpenMED.cxx src/MEDMEMCppTest/testMEDMEM.py src/MEDMEM_I/MEDMEM_Family_i.cxx src/MEDMEM_I/MEDMEM_Family_i.hxx src/MEDMEM_I/MEDMEM_FieldTemplate_i.hxx src/MEDMEM_I/MEDMEM_Field_i.cxx src/MEDMEM_I/MEDMEM_Field_i.hxx src/MEDMEM_I/MEDMEM_GMesh_i.cxx src/MEDMEM_I/MEDMEM_GMesh_i.hxx src/MEDMEM_I/MEDMEM_Group_i.cxx src/MEDMEM_I/MEDMEM_Group_i.hxx src/MEDMEM_I/MEDMEM_I.hxx src/MEDMEM_I/MEDMEM_Med_i.cxx src/MEDMEM_I/MEDMEM_Med_i.hxx src/MEDMEM_I/MEDMEM_Mesh_i.cxx src/MEDMEM_I/MEDMEM_Mesh_i.hxx src/MEDMEM_I/MEDMEM_Support_i.cxx src/MEDMEM_I/MEDMEM_Support_i.hxx src/MEDMEM_I/MEDMEM_TraitsForFields.hxx src/MEDMEM_I/MEDMEM_convert.cxx src/MEDMEM_I/MEDMEM_convert.hxx src/MEDMEM_I/Makefile.am src/MEDMEM_I/README src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx src/MEDMEM_SWIG/Makefile.am src/MEDMEM_SWIG/avs2med src/MEDMEM_SWIG/dumpMEDMEM.py src/MEDMEM_SWIG/ensightMedEnsight_test.py src/MEDMEM_SWIG/libMEDMEM_Swig.i src/MEDMEM_SWIG/med2sauv src/MEDMEM_SWIG/medEnsightMed_test.py src/MEDMEM_SWIG/medMeshing_test.py src/MEDMEM_SWIG/medNumPy_test.py src/MEDMEM_SWIG/med_field_anal.py src/MEDMEM_SWIG/med_opfield_test.py src/MEDMEM_SWIG/med_opsupp_test.py src/MEDMEM_SWIG/med_test1.py src/MEDMEM_SWIG/med_test2.py src/MEDMEM_SWIG/med_test3.py src/MEDMEM_SWIG/med_test_grid.py src/MEDMEM_SWIG/med_test_skin.py src/MEDMEM_SWIG/medmem.py src/MEDMEM_SWIG/medutilities.py src/MEDMEM_SWIG/my_typemap.i src/MEDMEM_SWIG/sauv2med src/MEDMEM_SWIG/testDriverAscii.py src/MEDMEM_SWIG/testGaussLocalization.py src/MEDMEM_SWIG/testMedMemCxxTests.py src/MEDMEM_SWIG/testMedMemGeneral.py src/MEDMEM_SWIG/testWriteAndFam.py src/MEDMEM_SWIG/test_gibi.py src/MEDMEM_SWIG/test_porflow.py src/MEDMEM_SWIG/test_profil_MedFieldDriver.py src/MEDSPLITTER/MEDSPLITTER.hxx src/MEDSPLITTER/MEDSPLITTER_API.cxx src/MEDSPLITTER/MEDSPLITTER_API.hxx src/MEDSPLITTER/MEDSPLITTER_FaceModel.hxx src/MEDSPLITTER/MEDSPLITTER_Graph.cxx src/MEDSPLITTER/MEDSPLITTER_Graph.hxx src/MEDSPLITTER/MEDSPLITTER_MESHCollection.H src/MEDSPLITTER/MEDSPLITTER_MESHCollection.cxx src/MEDSPLITTER/MEDSPLITTER_MESHCollection.hxx src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.H src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.cxx src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.hxx src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.H src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.H src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.cxx src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.hxx src/MEDSPLITTER/MEDSPLITTER_METISGraph.cxx src/MEDSPLITTER/MEDSPLITTER_METISGraph.hxx src/MEDSPLITTER/MEDSPLITTER_ParallelTopology.cxx src/MEDSPLITTER/MEDSPLITTER_ParallelTopology.hxx src/MEDSPLITTER/MEDSPLITTER_SCOTCHGraph.cxx src/MEDSPLITTER/MEDSPLITTER_SCOTCHGraph.hxx src/MEDSPLITTER/MEDSPLITTER_SequentialTopology.cxx src/MEDSPLITTER/MEDSPLITTER_SequentialTopology.hxx src/MEDSPLITTER/MEDSPLITTER_Topology.hxx src/MEDSPLITTER/MEDSPLITTER_UserGraph.cxx src/MEDSPLITTER/MEDSPLITTER_UserGraph.hxx src/MEDSPLITTER/MEDSPLITTER_utils.hxx src/MEDSPLITTER/Makefile.am src/MEDSPLITTER/Test/MEDSPLITTERTest.cxx src/MEDSPLITTER/Test/MEDSPLITTERTest.hxx src/MEDSPLITTER/Test/MEDSPLITTERTest_MESHCollection.cxx src/MEDSPLITTER/Test/MEDSPLITTERTest_ParallelTopology.cxx src/MEDSPLITTER/Test/Makefile.am src/MEDSPLITTER/Test/TestMEDSPLITTER.cxx src/MEDSPLITTER/Test/testMEDSPLITTER.py src/MEDSPLITTER/medsplitter.cxx src/MEDSPLITTER/test_HighLevelAPI.cxx src/MEDSPLITTER_Swig/MEDSPLITTER.py src/MEDSPLITTER_Swig/Makefile.am src/MEDSPLITTER_Swig/libMEDSPLITTER_Swig.i src/MEDSPLITTER_Swig/test_MEDSPLITTER.py src/MEDWrapper/Base/MED_Algorithm.cxx src/MEDWrapper/Base/MED_Algorithm.hxx src/MEDWrapper/Base/MED_Common.hxx src/MEDWrapper/Base/MED_CoordUtils.cxx src/MEDWrapper/Base/MED_CoordUtils.hxx src/MEDWrapper/Base/MED_GaussDef.cxx src/MEDWrapper/Base/MED_GaussDef.hxx src/MEDWrapper/Base/MED_GaussUtils.cxx src/MEDWrapper/Base/MED_GaussUtils.hxx src/MEDWrapper/Base/MED_SharedPtr.hxx src/MEDWrapper/Base/MED_SliceArray.hxx src/MEDWrapper/Base/MED_Structures.cxx src/MEDWrapper/Base/MED_Structures.hxx src/MEDWrapper/Base/MED_TStructures.hxx src/MEDWrapper/Base/MED_TWrapper.hxx src/MEDWrapper/Base/MED_Utilities.cxx src/MEDWrapper/Base/MED_Utilities.hxx src/MEDWrapper/Base/MED_Vector.hxx src/MEDWrapper/Base/MED_Wrapper.cxx src/MEDWrapper/Base/MED_Wrapper.hxx src/MEDWrapper/Base/MED_WrapperBase.hxx src/MEDWrapper/Base/Makefile.am src/MEDWrapper/Factory/MED_Factory.cxx src/MEDWrapper/Factory/MED_Factory.hxx src/MEDWrapper/Factory/MED_Test.cxx src/MEDWrapper/Factory/MED_WrapperFactory.hxx src/MEDWrapper/Factory/Makefile.am src/MEDWrapper/Factory/mprint_version.cxx src/MEDWrapper/Makefile.am src/MEDWrapper/V2_1/Core/MED1cstring.cxx src/MEDWrapper/V2_1/Core/MED2cstring.cxx src/MEDWrapper/V2_1/Core/MEDGeometrieElement.cxx src/MEDWrapper/V2_1/Core/MEDattrFermer.cxx src/MEDWrapper/V2_1/Core/MEDattrNumEcrire.cxx src/MEDWrapper/V2_1/Core/MEDattrNumLire.cxx src/MEDWrapper/V2_1/Core/MEDattrOuvrir.cxx src/MEDWrapper/V2_1/Core/MEDattrStringEcrire.cxx src/MEDWrapper/V2_1/Core/MEDattrStringLire.cxx src/MEDWrapper/V2_1/Core/MEDbodyFittedEcr.cxx src/MEDWrapper/V2_1/Core/MEDbodyFittedLire.cxx src/MEDWrapper/V2_1/Core/MEDchampCr.cxx src/MEDWrapper/V2_1/Core/MEDchampEcr.cxx src/MEDWrapper/V2_1/Core/MEDchampInfo.cxx src/MEDWrapper/V2_1/Core/MEDchampLire.cxx src/MEDWrapper/V2_1/Core/MEDconnEcr.cxx src/MEDWrapper/V2_1/Core/MEDconnLire.cxx src/MEDWrapper/V2_1/Core/MEDcoordEcr.cxx src/MEDWrapper/V2_1/Core/MEDcoordLire.cxx src/MEDWrapper/V2_1/Core/MEDcstringFree.cxx src/MEDWrapper/V2_1/Core/MEDdatagroupCreer.cxx src/MEDWrapper/V2_1/Core/MEDdatagroupFermer.cxx src/MEDWrapper/V2_1/Core/MEDdatagroupOuvrir.cxx src/MEDWrapper/V2_1/Core/MEDdatasetFermer.cxx src/MEDWrapper/V2_1/Core/MEDdatasetNumEcrire.cxx src/MEDWrapper/V2_1/Core/MEDdatasetNumLire.cxx src/MEDWrapper/V2_1/Core/MEDdatasetOuvrir.cxx src/MEDWrapper/V2_1/Core/MEDdatasetStringEcrire.cxx src/MEDWrapper/V2_1/Core/MEDdatasetStringLire.cxx src/MEDWrapper/V2_1/Core/MEDdimLire.cxx src/MEDWrapper/V2_1/Core/MEDelementsEcr.cxx src/MEDWrapper/V2_1/Core/MEDelementsLire.cxx src/MEDWrapper/V2_1/Core/MEDequivCr.cxx src/MEDWrapper/V2_1/Core/MEDequivEcr.cxx src/MEDWrapper/V2_1/Core/MEDequivInfo.cxx src/MEDWrapper/V2_1/Core/MEDequivLire.cxx src/MEDWrapper/V2_1/Core/MEDfam2groA.cxx src/MEDWrapper/V2_1/Core/MEDfam2groB.cxx src/MEDWrapper/V2_1/Core/MEDfamCr.cxx src/MEDWrapper/V2_1/Core/MEDfamEcr.cxx src/MEDWrapper/V2_1/Core/MEDfamGridEcr.cxx src/MEDWrapper/V2_1/Core/MEDfamGridLire.cxx src/MEDWrapper/V2_1/Core/MEDfamInfo.cxx src/MEDWrapper/V2_1/Core/MEDfamLire.cxx src/MEDWrapper/V2_1/Core/MEDfamMaaCr.cxx src/MEDWrapper/V2_1/Core/MEDfamMaaInfo.cxx src/MEDWrapper/V2_1/Core/MEDfamMaaLire.cxx src/MEDWrapper/V2_1/Core/MEDfermer.cxx src/MEDWrapper/V2_1/Core/MEDfichDesEcr.cxx src/MEDWrapper/V2_1/Core/MEDfichEntete.cxx src/MEDWrapper/V2_1/Core/MEDfichierCreer.cxx src/MEDWrapper/V2_1/Core/MEDfichierFermer.cxx src/MEDWrapper/V2_1/Core/MEDfichierOuvrir.cxx src/MEDWrapper/V2_1/Core/MEDformatConforme.cxx src/MEDWrapper/V2_1/Core/MEDfstring.cxx src/MEDWrapper/V2_1/Core/MEDgridCr.cxx src/MEDWrapper/V2_1/Core/MEDgridEcr.cxx src/MEDWrapper/V2_1/Core/MEDgridInfo.cxx src/MEDWrapper/V2_1/Core/MEDgridLire.cxx src/MEDWrapper/V2_1/Core/MEDgro2famA.cxx src/MEDWrapper/V2_1/Core/MEDgro2famB.cxx src/MEDWrapper/V2_1/Core/MEDindiceInfo.cxx src/MEDWrapper/V2_1/Core/MEDindiceNum.cxx src/MEDWrapper/V2_1/Core/MEDlFichDes.cxx src/MEDWrapper/V2_1/Core/MEDmaaCr.cxx src/MEDWrapper/V2_1/Core/MEDmaaInfo.cxx src/MEDWrapper/V2_1/Core/MEDmodeErreurVerrouiller.cxx src/MEDWrapper/V2_1/Core/MEDnChamp.cxx src/MEDWrapper/V2_1/Core/MEDnCorres.cxx src/MEDWrapper/V2_1/Core/MEDnEntMaa.cxx src/MEDWrapper/V2_1/Core/MEDnEntites.cxx src/MEDWrapper/V2_1/Core/MEDnEquiv.cxx src/MEDWrapper/V2_1/Core/MEDnFam.cxx src/MEDWrapper/V2_1/Core/MEDnGrid.cxx src/MEDWrapper/V2_1/Core/MEDnMaa.cxx src/MEDWrapper/V2_1/Core/MEDnObjets.cxx src/MEDWrapper/V2_1/Core/MEDnPasdetemps.cxx src/MEDWrapper/V2_1/Core/MEDnProfil.cxx src/MEDWrapper/V2_1/Core/MEDnVal.cxx src/MEDWrapper/V2_1/Core/MEDnValProfil.cxx src/MEDWrapper/V2_1/Core/MEDnbnoisEcr.cxx src/MEDWrapper/V2_1/Core/MEDnbnoisLire.cxx src/MEDWrapper/V2_1/Core/MEDnbnomaEcr.cxx src/MEDWrapper/V2_1/Core/MEDnbnomaLire.cxx src/MEDWrapper/V2_1/Core/MEDnbnosoEcr.cxx src/MEDWrapper/V2_1/Core/MEDnbnosoLire.cxx src/MEDWrapper/V2_1/Core/MEDnoeudsEcr.cxx src/MEDWrapper/V2_1/Core/MEDnoeudsLire.cxx src/MEDWrapper/V2_1/Core/MEDnomDataset.cxx src/MEDWrapper/V2_1/Core/MEDnomEcr.cxx src/MEDWrapper/V2_1/Core/MEDnomEntite.cxx src/MEDWrapper/V2_1/Core/MEDnomGeometrie.cxx src/MEDWrapper/V2_1/Core/MEDnomLire.cxx src/MEDWrapper/V2_1/Core/MEDnumEcr.cxx src/MEDWrapper/V2_1/Core/MEDnumLire.cxx src/MEDWrapper/V2_1/Core/MEDobjetIdentifer.cxx src/MEDWrapper/V2_1/Core/MEDouvrir.cxx src/MEDWrapper/V2_1/Core/MEDparametresGeometrie.cxx src/MEDWrapper/V2_1/Core/MEDpasdetempsInfo.cxx src/MEDWrapper/V2_1/Core/MEDprofilEcr.cxx src/MEDWrapper/V2_1/Core/MEDprofilInfo.cxx src/MEDWrapper/V2_1/Core/MEDprofilLire.cxx src/MEDWrapper/V2_1/Core/MEDunvCr.cxx src/MEDWrapper/V2_1/Core/MEDunvLire.cxx src/MEDWrapper/V2_1/Core/MEDversionConforme.cxx src/MEDWrapper/V2_1/Core/MEDversionDonner.cxx src/MEDWrapper/V2_1/Core/MEDversionLire.cxx src/MEDWrapper/V2_1/Core/Makefile.am src/MEDWrapper/V2_1/Core/hdf5_version2api.hxx src/MEDWrapper/V2_1/Core/mdump_V2_1.cxx src/MEDWrapper/V2_1/Core/med.hxx src/MEDWrapper/V2_1/Core/med_hdfi.hxx src/MEDWrapper/V2_1/Core/med_misc.hxx src/MEDWrapper/V2_1/Core/med_outils.hxx src/MEDWrapper/V2_1/Core/med_proto.hxx src/MEDWrapper/V2_1/Core/med_utils.hxx src/MEDWrapper/V2_1/Core/test1_V2_1.cxx src/MEDWrapper/V2_1/Makefile.am src/MEDWrapper/V2_1/Wrapper/MED_V2_1_Wrapper.cxx src/MEDWrapper/V2_1/Wrapper/MED_V2_1_Wrapper.hxx src/MEDWrapper/V2_1/Wrapper/Makefile.am src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx src/MEDWrapper/V2_2/MED_V2_2_Wrapper.hxx src/MEDWrapper/V2_2/Makefile.am src/MED_SWIG/MED_shared_modules.py src/MED_SWIG/Makefile.am src/MULTIPR/MULTIPR_API.cxx src/MULTIPR/MULTIPR_API.hxx src/MULTIPR/MULTIPR_DecimationAccel.cxx src/MULTIPR/MULTIPR_DecimationAccel.hxx src/MULTIPR/MULTIPR_DecimationFilter.cxx src/MULTIPR/MULTIPR_DecimationFilter.hxx src/MULTIPR/MULTIPR_Elements.cxx src/MULTIPR/MULTIPR_Elements.hxx src/MULTIPR/MULTIPR_Exceptions.hxx src/MULTIPR/MULTIPR_Family.cxx src/MULTIPR/MULTIPR_Family.hxx src/MULTIPR/MULTIPR_Field.cxx src/MULTIPR/MULTIPR_Field.hxx src/MULTIPR/MULTIPR_GaussLoc.cxx src/MULTIPR/MULTIPR_GaussLoc.hxx src/MULTIPR/MULTIPR_Globals.hxx src/MULTIPR/MULTIPR_Mesh.cxx src/MULTIPR/MULTIPR_Mesh.hxx src/MULTIPR/MULTIPR_MeshDis.cxx src/MULTIPR/MULTIPR_MeshDis.hxx src/MULTIPR/MULTIPR_Nodes.cxx src/MULTIPR/MULTIPR_Nodes.hxx src/MULTIPR/MULTIPR_Obj.cxx src/MULTIPR/MULTIPR_Obj.hxx src/MULTIPR/MULTIPR_PointOfField.hxx src/MULTIPR/MULTIPR_Profil.cxx src/MULTIPR/MULTIPR_Profil.hxx src/MULTIPR/MULTIPR_ProgressCallback.hxx src/MULTIPR/MULTIPR_Utils.cxx src/MULTIPR/MULTIPR_Utils.hxx src/MULTIPR/Makefile.am src/MULTIPR/multipr.cxx src/Makefile.am src/MedClient/Makefile.am src/MedClient/src/CONNECTIVITYClient.cxx src/MedClient/src/CONNECTIVITYClient.hxx src/MedClient/src/COORDINATEClient.cxx src/MedClient/src/COORDINATEClient.hxx src/MedClient/src/FAMILYClient.cxx src/MedClient/src/FAMILYClient.hxx src/MedClient/src/FIELDClient.cxx src/MedClient/src/FIELDClient.hxx src/MedClient/src/FIELDDOUBLEClient.cxx src/MedClient/src/FIELDDOUBLEClient.hxx src/MedClient/src/FIELDINTClient.cxx src/MedClient/src/FIELDINTClient.hxx src/MedClient/src/GMESHClient.cxx src/MedClient/src/GMESHClient.hxx src/MedClient/src/GROUPClient.cxx src/MedClient/src/GROUPClient.hxx src/MedClient/src/MEDClient.hxx src/MedClient/src/MESHClient.cxx src/MedClient/src/MESHClient.hxx src/MedClient/src/Makefile.am src/MedClient/src/MakefileForTest src/MedClient/src/MemorySpy.cxx src/MedClient/src/MemorySpy.hxx src/MedClient/src/README_medclient_test src/MedClient/src/SUPPORTClient.cxx src/MedClient/src/SUPPORTClient.hxx src/MedClient/src/TESTMEDCLIENT_Gen.idl src/MedClient/src/TESTMEDCLIENT_Gen_i.cxx src/MedClient/src/TESTMEDCLIENT_Gen_i.hxx src/MedClient/src/UtilClient.hxx src/MedClient/src/create_mesh_c2q4.c src/MedClient/src/create_mesh_c2t3.c src/MedClient/src/create_mesh_c3h8.c src/MedClient/src/create_mesh_c3t4.c src/MedClient/src/libMEDClient.i src/MedClient/src/medClient_test.py src/MedClient/src/testMeshAlliances.py src/MedClient/src/test_medclient.py src/MedClient/test/Makefile.am src/MedClient/test/environ/Makefile.am src/MedClient/test/environ/csh/Makefile.am src/MedClient/test/environ/csh/init1.in src/MedClient/test/environ/csh/init2.in src/MedClient/test/environ/csh/init3.in src/MedClient/test/environ/csh/runContainer.in src/MedClient/test/environ/csh/runEnvironTests.in src/MedClient/test/environ/csh/stopContainer.in src/MedClient/test/environ/runContainer.in src/MedClient/test/environ/runEnvironTests.in src/MedClient/test/environ/runTestMedCorba.in src/MedClient/test/environ/stopContainer.in src/MedClient/test/resources/carre_en_quad4_seg2.med src/MedClient/test/resources/maill.0.med src/MedClient/test/resources/pointe.med src/MedClient/test/resources/test_hydro_darcy1a_out.med src/MedClient/test/test1/Compo1.py src/MedClient/test/test1/Compo1Py.idl src/MedClient/test/test1/Compo1Py.py src/MedClient/test/test1/Makefile.am src/MedClient/test/test1/TestMedCorba1.py src/MedClient/test/test1/TestMedCorba2.py src/MedClient/test/test1/TestMedCorba3.py src/MedClient/test/test1/TestMedCorba4.py src/MedClient/test/test1/TestMedCorba5.py src/MedClient/test/test1/resources/CatalogModuleTest.xml src/MedClient/test/test1/resources/Compo1PyCatalog.xml src/MedClient/test/test2/Compo2.cxx src/MedClient/test/test2/Compo2.hxx src/MedClient/test/test2/Makefile.am src/MedClient/test/test2/TestMedCorba6.py src/MedClient/test/test2/TestMedCorba7.py src/MedClient/test/test2/TestMedCorba8.py src/MedClient/test/test2/libCompo2.i src/MedCorba_Swig/Makefile.am src/MedCorba_Swig/batchmode_medcorba_test.py src/MedCorba_Swig/batchmode_medcorba_test1.py src/MedCorba_Swig/libMedCorba_Swig.i src/MedCorba_Swig/medcorba_test.py src/ParaMEDCouplingCorba/Makefile.am src/ParaMEDCouplingCorba/ParaMEDCouplingFieldDoubleServant.cxx src/ParaMEDCouplingCorba/ParaMEDCouplingFieldDoubleServant.hxx src/ParaMEDCouplingCorba/ParaMEDCouplingUMeshServant.cxx src/ParaMEDCouplingCorba/ParaMEDCouplingUMeshServant.hxx src/ParaMEDLoader/Makefile.am src/ParaMEDLoader/ParaMEDLoader.cxx src/ParaMEDLoader/ParaMEDLoader.hxx src/ParaMEDMEM/BASICS_JR src/ParaMEDMEM/BlockTopology.cxx src/ParaMEDMEM/BlockTopology.hxx src/ParaMEDMEM/CommInterface.cxx src/ParaMEDMEM/CommInterface.hxx src/ParaMEDMEM/ComponentTopology.cxx src/ParaMEDMEM/ComponentTopology.hxx src/ParaMEDMEM/DEC.cxx src/ParaMEDMEM/DEC.hxx src/ParaMEDMEM/DECOptions.hxx src/ParaMEDMEM/ElementLocator.cxx src/ParaMEDMEM/ElementLocator.hxx src/ParaMEDMEM/ExplicitCoincidentDEC.cxx src/ParaMEDMEM/ExplicitCoincidentDEC.hxx src/ParaMEDMEM/ExplicitMapping.hxx src/ParaMEDMEM/ExplicitTopology.cxx src/ParaMEDMEM/ExplicitTopology.hxx src/ParaMEDMEM/ICoCoField.cxx src/ParaMEDMEM/ICoCoField.hxx src/ParaMEDMEM/ICoCoMEDField.cxx src/ParaMEDMEM/ICoCoMEDField.hxx src/ParaMEDMEM/ICoCoTrioField.cxx src/ParaMEDMEM/ICoCoTrioField.hxx src/ParaMEDMEM/InterpKernelDEC.cxx src/ParaMEDMEM/InterpKernelDEC.hxx src/ParaMEDMEM/InterpolationMatrix.cxx src/ParaMEDMEM/InterpolationMatrix.hxx src/ParaMEDMEM/LinearTimeInterpolator.cxx src/ParaMEDMEM/LinearTimeInterpolator.hxx src/ParaMEDMEM/MPIAccess.cxx src/ParaMEDMEM/MPIAccess.hxx src/ParaMEDMEM/MPIAccessDEC.cxx src/ParaMEDMEM/MPIAccessDEC.hxx src/ParaMEDMEM/MPIProcessorGroup.cxx src/ParaMEDMEM/MPIProcessorGroup.hxx src/ParaMEDMEM/Makefile.am src/ParaMEDMEM/MxN_Mapping.cxx src/ParaMEDMEM/MxN_Mapping.hxx src/ParaMEDMEM/NonCoincidentDEC.cxx src/ParaMEDMEM/NonCoincidentDEC.hxx src/ParaMEDMEM/ParaFIELD.cxx src/ParaMEDMEM/ParaFIELD.hxx src/ParaMEDMEM/ParaGRID.cxx src/ParaMEDMEM/ParaGRID.hxx src/ParaMEDMEM/ParaMESH.cxx src/ParaMEDMEM/ParaMESH.hxx src/ParaMEDMEM/ProcessorGroup.cxx src/ParaMEDMEM/ProcessorGroup.hxx src/ParaMEDMEM/README_JR src/ParaMEDMEM/StructuredCoincidentDEC.cxx src/ParaMEDMEM/StructuredCoincidentDEC.hxx src/ParaMEDMEM/TODO_JR src/ParaMEDMEM/TimeInterpolator.cxx src/ParaMEDMEM/TimeInterpolator.hxx src/ParaMEDMEM/Topology.cxx src/ParaMEDMEM/Topology.hxx src/ParaMEDMEMComponent/MPIMEDCouplingFieldDoubleServant.cxx src/ParaMEDMEMComponent/MPIMEDCouplingFieldDoubleServant.hxx src/ParaMEDMEMComponent/Makefile.am src/ParaMEDMEMComponent/ParaMEDMEMComponent_i.cxx src/ParaMEDMEMComponent/ParaMEDMEMComponent_i.hxx src/ParaMEDMEMTest/MPI2Connector.cxx src/ParaMEDMEMTest/MPI2Connector.hxx src/ParaMEDMEMTest/MPIAccessDECTest.cxx src/ParaMEDMEMTest/MPIAccessDECTest.hxx src/ParaMEDMEMTest/MPIAccessTest.cxx src/ParaMEDMEMTest/MPIAccessTest.hxx src/ParaMEDMEMTest/MPIMainTest.hxx src/ParaMEDMEMTest/Makefile.am src/ParaMEDMEMTest/ParaMEDMEMTest.cxx src/ParaMEDMEMTest/ParaMEDMEMTest.hxx src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_BlockTopology.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_ICocoTrio.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_MPIProcessorGroup.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx src/ParaMEDMEMTest/TestMPIAccess.cxx src/ParaMEDMEMTest/TestMPIAccessDEC.cxx src/ParaMEDMEMTest/TestParaMEDMEM.cxx src/ParaMEDMEMTest/test_AllToAllDEC.cxx src/ParaMEDMEMTest/test_AllToAllTimeDEC.cxx src/ParaMEDMEMTest/test_AllToAllvDEC.cxx src/ParaMEDMEMTest/test_AllToAllvTimeDEC.cxx src/ParaMEDMEMTest/test_AllToAllvTimeDoubleDEC.cxx src/ParaMEDMEMTest/test_MPI_Access_Cancel.cxx src/ParaMEDMEMTest/test_MPI_Access_Cyclic_ISend_IRecv.cxx src/ParaMEDMEMTest/test_MPI_Access_Cyclic_Send_Recv.cxx src/ParaMEDMEMTest/test_MPI_Access_IProbe.cxx src/ParaMEDMEMTest/test_MPI_Access_ISendRecv.cxx src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv.cxx src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_BottleNeck.cxx src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length.cxx src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length_1.cxx src/ParaMEDMEMTest/test_MPI_Access_Probe.cxx src/ParaMEDMEMTest/test_MPI_Access_SendRecv.cxx src/ParaMEDMEMTest/test_MPI_Access_Send_Recv.cxx src/ParaMEDMEMTest/test_MPI_Access_Send_Recv_Length.cxx src/ParaMEDMEMTest/test_MPI_Access_Time.cxx src/ParaMEDMEMTest/test_MPI_Access_Time_0.cxx src/ParaMEDMEMTest/test_perf.cxx src/ParaMEDMEM_Swig/Makefile.am src/ParaMEDMEM_Swig/ParaMEDMEM.py src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.i src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.typemap src/ParaMEDMEM_Swig/test_InterpKernelDEC.py src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py src/ParaMEDMEM_Swig/test_StructuredCoincodentDEC.py src/RENUMBER/Makefile.am src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx src/RENUMBER/RENUMBER_METISRenumbering.cxx src/RENUMBER/RENUMBER_METISRenumbering.hxx src/RENUMBER/RENUMBER_Renumbering.cxx src/RENUMBER/RENUMBER_Renumbering.hxx src/RENUMBER/RenumberingFactory.cxx src/RENUMBER/RenumberingFactory.hxx src/RENUMBER/renumbering.cxx src/RENUMBER/testRenumbering.py --- diff --git a/doc/doxygen/images/head.png b/doc/doxygen/images/head.png deleted file mode 100755 index 307d9ef9a..000000000 Binary files a/doc/doxygen/images/head.png and /dev/null differ diff --git a/doc/doxygen/static/doxygen.css b/doc/doxygen/static/doxygen.css deleted file mode 100644 index d8991647e..000000000 --- a/doc/doxygen/static/doxygen.css +++ /dev/null @@ -1,468 +0,0 @@ -body { - font-family: Arial, Helvetica, sans-serif; - background-color: #ffffff; -} - -h1 { - text-align: center; - text-decoration: none; - border: none; - line-height: 25px; - text-align: center; -// text-transform:uppercase; - background: #D9f4fd; - font-size: 12pt; - font-weight: bold; - border: 1px solid #CCCCCC; - -moz-border-radius: 8px; - -moz-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); -} - -h2 { - font-size: 12pt; - font-weight: bold; -} - -table { - font-size: 10pt; -} - -CAPTION { - font-weight: bold -} - -/* Link in the top navbar */ -A.qindex {} - -A.qindexRef {} - -/* Link to any cross-referenced Doxygen element inside a code section - (ex: header) -*/ -A.code { - text-decoration: none; - font-weight: normal; - color: #4444ee -} - -A.codeRef { - font-weight: normal; - color: #4444ee -} - -A:hover { - text-decoration: none; - background-color: lightblue; -} - -div.contents { - font-family: Arial, Helvetica, sans-serif; - font-size: 10pt; -} - -div.navpath { - font-size: 11pt; - border: 0 none; - text-align: left; -} - -div.version { - background-color:#ffffde; - border:1px solid #cccccc; - font-family: Arial, Helvetica, sans-serif; - font-size: 9pt; - text-align: center; - width:100px; - -moz-border-radius: 8px; -// -moz-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); -} - -div.header { - background: url("head.png"); - background-color: #175783; - border: 1px solid; - height: 80px; - background-repeat: no-repeat; - margin-bottom: 10px; -} - -div.tabs { - text-align: justify; - margin-left : 2px; - margin-right : 2px; - margin-top : 2px; - margin-bottom : 2px - font-weight: bold; - color: #FFFFFF; -} - -div.footer { - background-color: #D9f4fd; - border: 1px solid #AAAAAA; - font-family: Arial, Helvetica, sans-serif; - font-size: 11px; - padding: 10px; - margin-top: 15px; -} - -DL.el { - margin-left: -1cm -} - -/* A code fragment (ex: header) */ -div.fragment { - border: none; -} - -/* In the alpha list (coumpound index), style of an alphabetical index letter */ -DIV.ah { - background-color: #CCCCCC; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px -} - -/* Method name (+ type) */ -TD.md { - background-color: lightblue; - font-weight: bold; -} - -/* Method parameter (some of them) */ -TD.mdname1 { - background-color: lightblue; - font-weight: bold; color: #602020; -} - -/* Method parameter (some of them) */ -TD.mdname { - background-color: lightblue; - font-weight: bold; - color: #602020; - width: 600px; -} - -/* Separator between methods group (usually empty, seems not supported by IE) */ -DIV.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold -} - -DIV.groupText { - margin-left: 16px; - font-style: italic; - font-size: smaller -} - -/*div.div-page { - background-color: #FFFFFF; - margin-left: 1em; - margin-right: 1em; - margin-top: 1em; - margin-bottom: 0.1em; - - padding-left: 1em; - padding-right: 1em; - padding-top: 0.5em; - padding-bottom: 0.5em; - - border: 2px solid #0D299A; - border-width: 2px; - border-color: #0D299A; -}*/ - -div.tabs { - text-align: justify; - margin-left : 2px; - margin-right : 2px; - margin-top : 2px; - margin-bottom : 2px - font-weight: bold; - color: #FFFFFF; -} - -DIV.div-footer { - margin-left: 1em; - margin-right: 1em; - margin-bottom: 0.2em; - text-align: right; - font-size: 9pt; -} - -/* In File List, Coumpound List, etc, 1st column of the index */ -TD.indexkey { - background-color: #CCCCCC; - font-weight: bold; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} - -/* In File List, Coumpound List, etc, 2nd column of the index */ -TD.indexvalue { - background-color: #CCCCCC; - font-style: italic; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} - -span.keyword { color: #008000 } -span.keywordtype { color: #604020 } -span.keywordflow { color: #e08000 } -span.comment { color: #800000 } -span.preprocessor { color: #806020 } -span.stringliteral { color: #002080 } -span.charliteral { color: #008080 } - -/* @group Code Colorization */ - -.fragment { - font-family: monospace, fixed; - font-size: 10pt; -} - -pre.fragment { - width: 95%; - border: 1px solid #CCCCCC; - -moz-border-radius: 8px; - -moz-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); - background-color:#EEF3F5; - padding: 4px 6px; - margin: 4px 1px 4px 1px; -} - -/* Top Navigation style */ - -div.navigation { - margin-bottom: 70px; -} - -/* Left navigation panel style */ - -body.ftvtree { - background-color: #D9f4fd; - margin: 10px; -} - -div.directory { - margin: 0; -} - -div.directory.p { - margin: 0; -} - -h3.swap { - font-size: 10pt; - margin-bottom: 0; -} - -/* Link to any cross-referenced Doxygen element */ -a.el { - text-decoration: none; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - font-size: 9pt; - color: #551a8b; -} - -a.el:hover { - background-color: transparent; -} - -a.elRef { - font-weight: normal; -} - - -#MSearchBox { - -moz-border-radius:8px 8px 8px 8px; - background-color:white; - border:1px solid #84B0C7; - margin:0; - padding:0; - white-space:nowrap; -} - -div.directory img { - vertical-align:-30%; -} - -div.directory p { - white-space:nowrap; - margin: 0; -} - -div.directory-alt div { - display: none; - margin: 0px; -} - - -div.directory div { - display: none; - margin: 0px; -} - -div.version { - background-color:#ffffde; - border:1px solid #cccccc; - font-family: Arial, Helvetica, sans-serif; - font-size: 9pt; - text-align: center; - width:100px; - -moz-border-radius: 8px; -// -moz-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); -} - -/* In File List, Coumpound List, etc, 1st column of the index */ -TD.indexkey { - background-color: #DDDDEE; - font-weight: bold; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} - -/* In File List, Coumpound List, etc, 2nd column of the index */ -TD.indexvalue { - background-color: #EEEEFF; - font-style: italic; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} - - -/* @group Member Descriptions */ - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #ccc; -} - -.memItemLeft, .memTemplItemLeft { - white-space: nowrap; -} - -.memTemplParams { - color: #606060; - white-space: nowrap; -} - -/* @end */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; - margin-left: 3px; -} - -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.memitem { - padding: 0; - margin-bottom: 10px; -} - -.memname { - white-space: nowrap; - font-weight: bold; -} - -.memproto, .memdoc { - border: 1px solid #84b0c7; -} - -.memproto { - padding: 0; - background-color: #d5e1e8; - font-weight: bold; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - -} - - - -.memdoc { - padding: 2px 5px; - background-color: #eef3f5; - border-top-width: 0; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -/* @end */ - diff --git a/doc/doxygen/static/footer.html b/doc/doxygen/static/footer.html deleted file mode 100755 index fdfb138ca..000000000 --- a/doc/doxygen/static/footer.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/doc/doxygen/static/header.html.in b/doc/doxygen/static/header.html.in deleted file mode 100755 index bcf8c48ea..000000000 --- a/doc/doxygen/static/header.html.in +++ /dev/null @@ -1,10 +0,0 @@ - - - - - $title - - - -
-
Version: @VERSION@
\ No newline at end of file diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am deleted file mode 100644 index a9a137c35..000000000 --- a/doc/salome/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE -# -# 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 -# - -# -* Makefile *- -# Author : Patrick GOLDBRONN (CEA) -# Date : 30/11/2001 -# $Header$ -# -SUBDIRS = tui -SUBDIRSTUI = tui - -dev_docs: - @@SETX@; for d in $(SUBDIRSTUI); do \ - (cd $$d && $(MAKE) $@) || exit 1; \ - done; \ No newline at end of file diff --git a/doc/salome/tui/Makefile.am b/doc/salome/tui/Makefile.am deleted file mode 100644 index 2b0b611e5..000000000 --- a/doc/salome/tui/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE -# -# 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -EXTRA_DIST += images input static/doxygen.css static/footer.html - -tuidocdir = $(docdir)/tui/MED -tuidoc_DATA = images/head.png - -dev_docs: doxyfile - echo "Running doxygen in directory: "`pwd`; \ - $(DOXYGEN) $<; - -clean-local: - -rm -fr MED doxygen.bak - -install-data-local: - if test -d MED; then \ - $(INSTALL) -d $(DESTDIR)$(docdir)/tui ; \ - cp -rp MED $(DESTDIR)$(docdir)/tui ; \ - fi; - -uninstall-local: - rm -rf $(DESTDIR)$(docdir)/tui/MED \ No newline at end of file diff --git a/doc/salome/tui/doxyfile.in b/doc/salome/tui/doxyfile.in deleted file mode 100755 index d023562bd..000000000 --- a/doc/salome/tui/doxyfile.in +++ /dev/null @@ -1,264 +0,0 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# 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 -# -# Doxyfile 1.4.6 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME MED Module Developer" -PROJECT_NUMBER = -OUTPUT_DIRECTORY = MED -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = @top_srcdir@ @top_builddir@ -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = YES -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = NO -DISTRIBUTE_GROUP_DOC = NO -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 5 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = YES -OPTIMIZE_OUTPUT_JAVA = YES -BUILTIN_STL_SUPPORT = @DOXYGEN_SUPPORT_STL@ -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -HIDE_UNDOC_MEMBERS = YES -HIDE_UNDOC_CLASSES = YES -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = YES -CASE_SENSE_NAMES = YES -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = NO -SORT_BRIEF_DOCS = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 25 -SHOW_USED_FILES = NO -SHOW_DIRECTORIES = NO -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = @top_srcdir@/src \ - @top_srcdir@/bin \ - @top_srcdir@/idl \ - @top_builddir@/bin \ - @srcdir@/input -FILE_PATTERNS = *.idl *.h *.hh *.hxx *.c *.cc *.cxx *.ixx *.jxx @DOXYGEN_PYTHON_EXTENSION@ *.doc -RECURSIVE = YES -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = YES -IMAGE_PATH = @srcdir@/images -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = YES -USE_HTAGS = NO -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 3 -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = . -HTML_FILE_EXTENSION = .html -HTML_HEADER = @builddir@/static/header.html -HTML_FOOTER = @srcdir@/static/footer.html -HTML_STYLESHEET = @srcdir@/static/doxygen.css -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = YES -TOC_EXPAND = YES -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = NO - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = NO -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = NO -GROUP_GRAPHS = NO -UML_LOOK = NO -TEMPLATE_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = NO -CALL_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = jpg -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1200 -MAX_DOT_GRAPH_DEPTH = 0 -DOT_TRANSPARENT = NO -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = NO -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/doc/salome/tui/images/head.png b/doc/salome/tui/images/head.png deleted file mode 100755 index 307d9ef9a..000000000 Binary files a/doc/salome/tui/images/head.png and /dev/null differ diff --git a/doc/salome/tui/input/index.doc b/doc/salome/tui/input/index.doc deleted file mode 100644 index 50c09d9e0..000000000 --- a/doc/salome/tui/input/index.doc +++ /dev/null @@ -1,13 +0,0 @@ -/*! \mainpage - -To browse the \b SALOME Med module Developer Documentation, follow the links below or use navigation menu at the top of the page: - - -\note Documentation of 3D - part of intersection matrix calculation more or less complete - -*/ \ No newline at end of file diff --git a/doc/salome/tui/static/doxygen.css b/doc/salome/tui/static/doxygen.css deleted file mode 100755 index ad299dd32..000000000 --- a/doc/salome/tui/static/doxygen.css +++ /dev/null @@ -1,443 +0,0 @@ -body { - font-family: Arial, Helvetica, sans-serif; - background-color: #ffffff; -} - -h1 { - text-align: center; - text-decoration: none; - border: none; - line-height: 25px; - text-align: center; -// text-transform:uppercase; - background: #D9f4fd; - font-size: 12pt; - font-weight: bold; - border: 1px solid #CCCCCC; - margin-top: 50px; - -moz-border-radius: 8px; - -moz-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); -} - -h2 { - font-size: 12pt; - font-weight: bold; -} - -table { - font-size: 10pt; - padding-left: 20px; -} - -CAPTION { - font-weight: bold -} - -/* Link in the top navbar */ -A.qindex {} - -A.qindexRef {} - -/* Link to any cross-referenced Doxygen element inside a code section - (ex: header) -*/ -A.code { - text-decoration: none; - font-weight: normal; - color: #4444ee -} - -A.codeRef { - font-weight: normal; - color: #4444ee -} - -A:hover { - text-decoration: none; - background-color: lightblue; -} - -div.contents { - font-family: Arial, Helvetica, sans-serif; - font-size: 10pt; - padding: 20px; -} - -div.navpath { - font-size: 11pt; -} - -div.header { - background: url("head.png"); - background-color: #175783; - border: 1px solid; - height: 80px; - background-repeat: no-repeat; - margin-bottom:20px; -} - -div.tabs { - text-align: justify; - margin-left : 2px; - margin-right : 2px; - margin-top : 2px; - margin-bottom : 2px - font-weight: bold; - color: #FFFFFF; -} - -div.footer { - background-color: #D9f4fd; - border: 1px solid #AAAAAA; - font-family: Arial, Helvetica, sans-serif; - font-size: 11px; - padding: 10px; -} - -div.div-footer { - background-color: #D9f4fd; - border: 1px solid #AAAAAA; - font-family: Arial, Helvetica, sans-serif; - font-size: 11px; - padding: 10px; - text-align: center; -} - -DL.el { - margin-left: -1cm -} - -/* A code fragment (ex: header) */ -div.fragment { - border: none; -} - -/* In the alpha list (coumpound index), style of an alphabetical index letter */ -DIV.ah { - background-color: #CCCCCC; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px -} - -/* Method name (+ type) */ -TD.md { - background-color: lightblue; - font-weight: bold; -} - -/* Method parameter (some of them) */ -TD.mdname1 { - background-color: lightblue; - font-weight: bold; color: #602020; -} - -/* Method parameter (some of them) */ -TD.mdname { - background-color: lightblue; - font-weight: bold; - color: #602020; - width: 600px; -} - -/* Separator between methods group (usually empty, seems not supported by IE) */ -DIV.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold -} - -DIV.groupText { - margin-left: 16px; - font-style: italic; - font-size: smaller -} - -/*div.div-page { - background-color: #FFFFFF; - margin-left: 1em; - margin-right: 1em; - margin-top: 1em; - margin-bottom: 0.1em; - - padding-left: 1em; - padding-right: 1em; - padding-top: 0.5em; - padding-bottom: 0.5em; - - border: 2px solid #0D299A; - border-width: 2px; - border-color: #0D299A; -}*/ - -div.tabs { - text-align: justify; - margin-left : 2px; - margin-right : 2px; - margin-top : 2px; - margin-bottom : 2px - font-weight: bold; - color: #FFFFFF; -} - -/* In File List, Coumpound List, etc, 1st column of the index */ -TD.indexkey { - background-color: #DDDDEE; - font-weight: bold; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} - -/* In File List, Coumpound List, etc, 2nd column of the index */ -TD.indexvalue { - background-color: #EEEEFF; - font-style: italic; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} - -span.keyword { color: #008000 } -span.keywordtype { color: #604020 } -span.keywordflow { color: #e08000 } -span.comment { color: #800000 } -span.preprocessor { color: #806020 } -span.stringliteral { color: #002080 } -span.charliteral { color: #008080 } - -/* @group Code Colorization */ - -.fragment { - font-family: monospace, fixed; - font-size: 10pt; -} - -pre.fragment { - width: 95%; - border: 1px solid #CCCCCC; - -moz-border-radius: 8px; - -moz-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); - background-color:#EEF3F5; - padding: 4px 6px; - margin: 20px; -} - -/* Top Navigation style */ - -div.navigation { - margin-bottom:20px; -} - -/* Left navigation panel style */ - -body.ftvtree { - background-color: #D9f4fd; - margin: 10px; -} - -div.directory { - margin: 0; -} - -div.directory.p { - margin: 0; -} - -h3.swap { - font-size: 10pt; - margin-bottom: 0; -} - -/* Link to any cross-referenced Doxygen element */ -a.el { - text-decoration: none; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - font-size: 10pt; - color: #551a8b; -} - -a.el:hover { - background-color: transparent; - color: #551acc; -} - -a { -// text-decoration: none; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - font-size: 10pt; - color: #551a8b; -} - -a:hover { - background-color: transparent; - color: #551acc; -} - -a.elRef { - font-weight: normal; -} - - -#MSearchBox { - -moz-border-radius:8px 8px 8px 8px; - background-color:white; - border:1px solid #84B0C7; - margin:0; - padding:0; - white-space:nowrap; -} - -div.directory img { - vertical-align:-30%; -} - -div.directory p { - white-space:nowrap; - margin: 0; -} - -div.directory-alt div { - display: none; - margin: 0px; -} - - -div.directory div { - display: none; - margin: 0px; -} - -div.version { - background-color:#ffffde; - border:1px solid #cccccc; - font-family: Arial, Helvetica, sans-serif; - font-size: 9pt; - text-align: center; - width:100px; - -moz-border-radius: 8px; - // -moz-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); -} - - -/* @group Member Descriptions */ - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #ccc; -} - -.memItemLeft, .memTemplItemLeft { - white-space: nowrap; -} - -.memTemplParams { - color: #606060; - white-space: nowrap; -} - -/* @end */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; - margin-left: 3px; -} - -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.memitem { - padding: 0; - margin-bottom: 10px; -} - -.memname { - white-space: nowrap; - font-weight: bold; -} - -.memproto, .memdoc { - border: 1px solid #84b0c7; -} - -.memproto { - padding: 0; - background-color: #d5e1e8; - font-weight: bold; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - -} - - - -.memdoc { - padding: 2px 5px; - background-color: #eef3f5; - border-top-width: 0; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -/* @end */ diff --git a/doc/salome/tui/static/footer.html b/doc/salome/tui/static/footer.html deleted file mode 100755 index 53f5a62fe..000000000 --- a/doc/salome/tui/static/footer.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - diff --git a/doc/salome/tui/static/header.html.in b/doc/salome/tui/static/header.html.in deleted file mode 100755 index 791a37c53..000000000 --- a/doc/salome/tui/static/header.html.in +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - $title - - - - -
-
Version: @VERSION@
- - diff --git a/resources/Box1.med b/resources/Box1.med deleted file mode 100644 index 329a2860e..000000000 Binary files a/resources/Box1.med and /dev/null differ diff --git a/resources/Box1Moderate.med b/resources/Box1Moderate.med deleted file mode 100644 index 3fef76cd2..000000000 Binary files a/resources/Box1Moderate.med and /dev/null differ diff --git a/resources/Box2.med b/resources/Box2.med deleted file mode 100644 index adc472503..000000000 Binary files a/resources/Box2.med and /dev/null differ diff --git a/resources/Box2Moderate.med b/resources/Box2Moderate.med deleted file mode 100644 index 9aaa9ffb3..000000000 Binary files a/resources/Box2Moderate.med and /dev/null differ diff --git a/resources/Box3.med b/resources/Box3.med deleted file mode 100644 index 9686dfb48..000000000 Binary files a/resources/Box3.med and /dev/null differ diff --git a/resources/BoxEvenSmaller1.med b/resources/BoxEvenSmaller1.med deleted file mode 100644 index e789adaec..000000000 Binary files a/resources/BoxEvenSmaller1.med and /dev/null differ diff --git a/resources/BoxHexa1.med b/resources/BoxHexa1.med deleted file mode 100644 index 016f1186d..000000000 Binary files a/resources/BoxHexa1.med and /dev/null differ diff --git a/resources/BoxHexa2.med b/resources/BoxHexa2.med deleted file mode 100644 index 9653f1ff2..000000000 Binary files a/resources/BoxHexa2.med and /dev/null differ diff --git a/resources/BoxModSmall1.med b/resources/BoxModSmall1.med deleted file mode 100644 index a2d1575da..000000000 Binary files a/resources/BoxModSmall1.med and /dev/null differ diff --git a/resources/BoxModSmall2.med b/resources/BoxModSmall2.med deleted file mode 100644 index bfad92a81..000000000 Binary files a/resources/BoxModSmall2.med and /dev/null differ diff --git a/resources/BoxTetra2.med b/resources/BoxTetra2.med deleted file mode 100644 index 44807eb2a..000000000 Binary files a/resources/BoxTetra2.med and /dev/null differ diff --git a/resources/ComplexIncludedTetra.med b/resources/ComplexIncludedTetra.med deleted file mode 100644 index 93b4e74cf..000000000 Binary files a/resources/ComplexIncludedTetra.med and /dev/null differ diff --git a/resources/ComplexIncludingTetra.med b/resources/ComplexIncludingTetra.med deleted file mode 100644 index c900d2ad7..000000000 Binary files a/resources/ComplexIncludingTetra.med and /dev/null differ diff --git a/resources/CornerTetra.med b/resources/CornerTetra.med deleted file mode 100644 index d1a6a675a..000000000 Binary files a/resources/CornerTetra.med and /dev/null differ diff --git a/resources/DegenEdgeXY.med b/resources/DegenEdgeXY.med deleted file mode 100644 index 425238535..000000000 Binary files a/resources/DegenEdgeXY.med and /dev/null differ diff --git a/resources/DegenFaceXYZ.med b/resources/DegenFaceXYZ.med deleted file mode 100644 index e48d9b76f..000000000 Binary files a/resources/DegenFaceXYZ.med and /dev/null differ diff --git a/resources/DegenTranslatedInPlane.med b/resources/DegenTranslatedInPlane.med deleted file mode 100644 index 8fa088b3f..000000000 Binary files a/resources/DegenTranslatedInPlane.med and /dev/null differ diff --git a/resources/DividedGenTetra1.med b/resources/DividedGenTetra1.med deleted file mode 100644 index 564cad0c9..000000000 Binary files a/resources/DividedGenTetra1.med and /dev/null differ diff --git a/resources/DividedGenTetra2.med b/resources/DividedGenTetra2.med deleted file mode 100644 index fcfee02c8..000000000 Binary files a/resources/DividedGenTetra2.med and /dev/null differ diff --git a/resources/DividedUnitTetra.med b/resources/DividedUnitTetra.med deleted file mode 100644 index f2feced90..000000000 Binary files a/resources/DividedUnitTetra.med and /dev/null differ diff --git a/resources/DividedUnitTetraSimpler.med b/resources/DividedUnitTetraSimpler.med deleted file mode 100644 index 5dfbeb1f5..000000000 Binary files a/resources/DividedUnitTetraSimpler.med and /dev/null differ diff --git a/resources/GenTetra1.med b/resources/GenTetra1.med deleted file mode 100644 index 4683d902d..000000000 Binary files a/resources/GenTetra1.med and /dev/null differ diff --git a/resources/GenTetra2.med b/resources/GenTetra2.med deleted file mode 100644 index 6b88cd2a2..000000000 Binary files a/resources/GenTetra2.med and /dev/null differ diff --git a/resources/GeneralTetra.med b/resources/GeneralTetra.med deleted file mode 100644 index 38d0747a3..000000000 Binary files a/resources/GeneralTetra.med and /dev/null differ diff --git a/resources/HalfstripOnly.med b/resources/HalfstripOnly.med deleted file mode 100644 index 87dfa507d..000000000 Binary files a/resources/HalfstripOnly.med and /dev/null differ diff --git a/resources/HalfstripOnly2.med b/resources/HalfstripOnly2.med deleted file mode 100644 index 36f51836a..000000000 Binary files a/resources/HalfstripOnly2.med and /dev/null differ diff --git a/resources/LargeUnitTetra.med b/resources/LargeUnitTetra.med deleted file mode 100644 index e910d3faa..000000000 Binary files a/resources/LargeUnitTetra.med and /dev/null differ diff --git a/resources/Mesh3D_11.med b/resources/Mesh3D_11.med deleted file mode 100644 index 5088b55b3..000000000 Binary files a/resources/Mesh3D_11.med and /dev/null differ diff --git a/resources/MovedHexaBox1.med b/resources/MovedHexaBox1.med deleted file mode 100644 index 82e5dcf06..000000000 Binary files a/resources/MovedHexaBox1.med and /dev/null differ diff --git a/resources/MovedHexaBox2.med b/resources/MovedHexaBox2.med deleted file mode 100644 index 8e4244f4c..000000000 Binary files a/resources/MovedHexaBox2.med and /dev/null differ diff --git a/resources/NudgedDividedUnitTetra.med b/resources/NudgedDividedUnitTetra.med deleted file mode 100644 index c19006836..000000000 Binary files a/resources/NudgedDividedUnitTetra.med and /dev/null differ diff --git a/resources/NudgedDividedUnitTetraSimpler.med b/resources/NudgedDividedUnitTetraSimpler.med deleted file mode 100644 index d71c6e680..000000000 Binary files a/resources/NudgedDividedUnitTetraSimpler.med and /dev/null differ diff --git a/resources/NudgedSimpler.med b/resources/NudgedSimpler.med deleted file mode 100644 index 8c04f9711..000000000 Binary files a/resources/NudgedSimpler.med and /dev/null differ diff --git a/resources/NudgedTetra.med b/resources/NudgedTetra.med deleted file mode 100644 index 4ad4cb66e..000000000 Binary files a/resources/NudgedTetra.med and /dev/null differ diff --git a/resources/Pol1.fig b/resources/Pol1.fig deleted file mode 100644 index cee7eb792..000000000 --- a/resources/Pol1.fig +++ /dev/null @@ -1,15 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5-alpha5 -Landscape -Center -Metric -Letter -100.00 -Single --2 -1200 2 -5 1 0 1 0 7 50 -1 -1 0.000 0 1 0 0 2700.000 4800.000 3600 6000 4200 4800 3600 3600 -5 1 0 1 0 7 50 -1 -1 0.000 0 1 0 0 5400.000 1200.000 3600 3600 5400 4200 7200 3600 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 5100.000 6300.000 7200 3600 7800 4200 8400 5400 -5 1 0 1 0 7 50 -1 -1 0.000 0 1 0 0 8400.000 6000.000 8400 5400 7800 6000 8400 6600 -5 1 0 1 0 7 50 -1 -1 0.000 0 1 0 0 9128.571 9642.857 8400 6600 6600 7800 6000 9600 -5 1 0 1 0 7 50 -1 -1 0.000 0 1 0 0 2820.000 9120.000 6000 9600 5400 7200 3600 6000 diff --git a/resources/Pol2.fig b/resources/Pol2.fig deleted file mode 100644 index 4778e6735..000000000 --- a/resources/Pol2.fig +++ /dev/null @@ -1,13 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5-alpha5 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 13000.000 7200.000 6600 9000 6600 5400 8400 2400 -5 1 0 1 0 7 50 -1 -1 0.000 0 1 0 0 10500.000 -900.000 8400 2400 10800 3000 12600 2400 -5 1 0 1 0 7 50 -1 -1 0.000 0 1 0 0 16242.857 6471.429 12600 2400 10800 6000 11400 9000 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 9000.000 13500.000 6600 9000 9000 8400 11400 9000 diff --git a/resources/Pol3.fig b/resources/Pol3.fig deleted file mode 100644 index 4bad14493..000000000 --- a/resources/Pol3.fig +++ /dev/null @@ -1,11 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5-alpha5 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 -3000 7200 6600 3600 diff --git a/resources/Pol4.fig b/resources/Pol4.fig deleted file mode 100644 index 1c6cd7924..000000000 --- a/resources/Pol4.fig +++ /dev/null @@ -1,10 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5-alpha5 -Landscape -Center -Inches -Letter -100.00 -Single --2 -1200 2 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 4800.000 4837.500 4200 7200 4800 2400 5400 7200 diff --git a/resources/SimpleHalfstripOnly.med b/resources/SimpleHalfstripOnly.med deleted file mode 100644 index b7a6dd719..000000000 Binary files a/resources/SimpleHalfstripOnly.med and /dev/null differ diff --git a/resources/SimpleIncludedTetra.med b/resources/SimpleIncludedTetra.med deleted file mode 100644 index 127d890d4..000000000 Binary files a/resources/SimpleIncludedTetra.med and /dev/null differ diff --git a/resources/SimpleIncludingTetra.med b/resources/SimpleIncludingTetra.med deleted file mode 100644 index e72ef0879..000000000 Binary files a/resources/SimpleIncludingTetra.med and /dev/null differ diff --git a/resources/Test2D.med b/resources/Test2D.med deleted file mode 100644 index 8f651af39..000000000 Binary files a/resources/Test2D.med and /dev/null differ diff --git a/resources/Test2Dpoly.med b/resources/Test2Dpoly.med deleted file mode 100644 index 7d56fed90..000000000 Binary files a/resources/Test2Dpoly.med and /dev/null differ diff --git a/resources/Test3D.med b/resources/Test3D.med deleted file mode 100644 index 48eccd7a6..000000000 Binary files a/resources/Test3D.med and /dev/null differ diff --git a/resources/Test3Dpoly.med b/resources/Test3Dpoly.med deleted file mode 100644 index 621709411..000000000 Binary files a/resources/Test3Dpoly.med and /dev/null differ diff --git a/resources/TinyBox.med b/resources/TinyBox.med deleted file mode 100644 index 3f76ecd80..000000000 Binary files a/resources/TinyBox.med and /dev/null differ diff --git a/resources/TrickyTetra1.med b/resources/TrickyTetra1.med deleted file mode 100644 index 32b45916a..000000000 Binary files a/resources/TrickyTetra1.med and /dev/null differ diff --git a/resources/UnitTetra.med b/resources/UnitTetra.med deleted file mode 100644 index a5f4a1ce4..000000000 Binary files a/resources/UnitTetra.med and /dev/null differ diff --git a/resources/UnitTetraDegenT.med b/resources/UnitTetraDegenT.med deleted file mode 100644 index 42c660c60..000000000 Binary files a/resources/UnitTetraDegenT.med and /dev/null differ diff --git a/resources/pointe.med b/resources/pointe.med deleted file mode 100644 index 99ea55289..000000000 Binary files a/resources/pointe.med and /dev/null differ diff --git a/resources/poly3D.med b/resources/poly3D.med deleted file mode 100644 index 5a42c3ff9..000000000 Binary files a/resources/poly3D.med and /dev/null differ diff --git a/resources/polygones.med b/resources/polygones.med deleted file mode 100644 index a1c404d0a..000000000 Binary files a/resources/polygones.med and /dev/null differ diff --git a/resources/square1.med b/resources/square1.med deleted file mode 100644 index 3fd7c4111..000000000 Binary files a/resources/square1.med and /dev/null differ diff --git a/resources/square1_split b/resources/square1_split deleted file mode 100644 index c6a1bce25..000000000 --- a/resources/square1_split +++ /dev/null @@ -1,6 +0,0 @@ -#MED Fichier V 2.3 -# -3 -Mesh_2 1 Mesh_2_1 localhost /home/vb144235/resources/square1_split1.med -Mesh_2 2 Mesh_2_2 localhost /home/vb144235/resources/square1_split2.med -Mesh_2 3 Mesh_2_3 localhost /home/vb144235/resources/square1_split3.med diff --git a/resources/square2.med b/resources/square2.med deleted file mode 100644 index 9b9d0a40e..000000000 Binary files a/resources/square2.med and /dev/null differ diff --git a/resources/square2_split b/resources/square2_split deleted file mode 100644 index bad1d1a8f..000000000 --- a/resources/square2_split +++ /dev/null @@ -1,5 +0,0 @@ -#MED Fichier V 2.3 -# -2 -Mesh_3 1 Mesh_3_1 localhost /home/vb144235/resources/square2_split1.med -Mesh_3 2 Mesh_3_2 localhost /home/vb144235/resources/square2_split2.med diff --git a/src/INTERP_KERNEL/BBTree.txx b/src/INTERP_KERNEL/BBTree.txx deleted file mode 100644 index b24255fd7..000000000 --- a/src/INTERP_KERNEL/BBTree.txx +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (C) 2007-2010 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 __BBTREE_TXX__ -#define __BBTREE_TXX__ - -#include -#include - -#include -#include -#include - -template -class BBTree -{ - -private: - BBTree* _left; - BBTree* _right; - int _level; - double _max_left; - double _min_right; - const double *_bb; - typename std::vector _elems; - bool _terminal; - ConnType _nbelems; - double _epsilon; - - static const int MIN_NB_ELEMS=15; - static const int MAX_LEVEL=20; -public: - - /*! - Constructor of the bounding box tree - \param bbs pointer to the [xmin1 xmax1 ymin1 ymax1 xmin2 xmax2 ...] array containing the bounding boxes that are to be indexed. - \param elems array to the indices of the elements contained in the BBTree - \param level level in the BBTree recursive structure - \param nbelems nb of elements in the BBTree - \param epsilon precision to which points are decided to be coincident - - Parameters \a elems and \a level are used only by BBTree itself for creating trees recursively. A typical use is therefore : - \code - int nbelems=... - double* bbs= new double[2*2*nbelems]; - // filling bbs ... - ... - BBTree<2> tree = new BBTree<2>(elems,0,0,nbelems,1e-12); - \endcode - */ - - BBTree(const double* bbs, ConnType* elems, int level, ConnType nbelems, double epsilon=1E-12): - _left(0), _right(0), _level(level), _bb(bbs), _terminal(false),_nbelems(nbelems),_epsilon(epsilon) - { - if (nbelems < MIN_NB_ELEMS || level> MAX_LEVEL) - { - _terminal=true; - - } - double* nodes=new double [nbelems]; - _elems.resize(nbelems); - for (ConnType i=0; i(nodes, nodes+nbelems/2, nodes+nbelems); - double median = *(nodes+nbelems/2); - delete[] nodes; - // std:: cout << *median < new_elems_left; - std::vector new_elems_right; - - new_elems_left.reserve(nbelems/2+1); - new_elems_right.reserve(nbelems/2+1); - double max_left = -std::numeric_limits::max(); - double min_right= std::numeric_limits::max(); - for (int i=0; imedian) - { - new_elems_right.push_back(elem); - if (minmax_left) max_left = max; - } - - - } - _max_left=max_left+std::abs(_epsilon); - _min_right=min_right-std::abs(_epsilon); - ConnType *tmp; - tmp=0; - if(!new_elems_left.empty()) - tmp=&(new_elems_left[0]); - _left=new BBTree(bbs, tmp, level+1, new_elems_left.size(),_epsilon); - tmp=0; - if(!new_elems_right.empty()) - tmp=&(new_elems_right[0]); - _right=new BBTree(bbs, tmp, level+1, new_elems_right.size(),_epsilon); - - } - - - - ~BBTree() - { - if (_left!=0) delete _left; - if (_right!=0) delete _right; - - } - - - /*! returns in \a elems the list of elements potentially intersecting the bounding box pointed to by \a bb - - \param bb pointer to query bounding box - \param elems list of elements (given in 0-indexing that is to say in \b C \b mode) intersecting the bounding box - */ - - void getIntersectingElems(const double* bb, std::vector& elems) const - { - // terminal node : return list of elements intersecting bb - if (_terminal) - { - for (int i=0; i<_nbelems; i++) - { - const double* const bb_ptr=_bb+_elems[i]*2*dim; - bool intersects = true; - for (int idim=0; idim-_epsilon|| bb_ptr[idim*2+1]-bb[idim*2]<_epsilon) - intersects=false; - } - if (intersects) - { - elems.push_back(_elems[i]); - } - } - return; - } - - //non terminal node - double min = bb[(_level%dim)*2]; - double max = bb[(_level%dim)*2+1]; - if (max < _min_right) - { - _left->getIntersectingElems(bb, elems); - return; - } - if (min> _max_left) - { - _right->getIntersectingElems(bb,elems); - return; - } - _left->getIntersectingElems(bb,elems); - _right->getIntersectingElems(bb,elems); - } - - - /*! returns in \a elems the list of elements potentially containing the point pointed to by \a xx - \param xx pointer to query point coords - \param elems list of elements (given in 0-indexing) intersecting the bounding box - */ - - void getElementsAroundPoint(const double* xx, std::vector& elems) const - { - // terminal node : return list of elements intersecting bb - if (_terminal) - { - for (ConnType i=0; i<_nbelems; i++) - { - const double* const bb_ptr=_bb+_elems[i]*2*dim; - bool intersects = true; - for (int idim=0; idim_epsilon|| bb_ptr[idim*2+1]-xx[idim]<-_epsilon) - intersects=false; - } - if (intersects) - { - elems.push_back(_elems[i]); - } - } - return; - } - - //non terminal node - if (xx[_level%dim] < _min_right) - { - _left->getElementsAroundPoint(xx, elems); - return; - } - if (xx[_level%dim]> _max_left) - { - _right->getElementsAroundPoint(xx,elems); - return; - } - _left->getElementsAroundPoint(xx,elems); - _right->getElementsAroundPoint(xx,elems); - } - - - - int size() - { - if (_terminal) return _nbelems; - return _left->size()+_right->size(); - } -}; -#endif diff --git a/src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx b/src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx deleted file mode 100644 index 68977cc3a..000000000 --- a/src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELBASESDEFINES_HXX__ -#define __INTERPKERNELBASESDEFINES_HXX__ - -//export symbols -// #ifdef WIN32 -// # if defined INTERPKERNELBASES_EXPORTS || defined interpkernelbases_EXPORTS -// # define INTERPKERNELBASES_EXPORT __declspec(dllexport) -// # else -// # define INTERPKERNELBASES_EXPORT __declspec(dllimport) -// # endif -// #else -// # define INTERPKERNELBASES_EXPORT -// #endif - -#define INTERPKERNELBASES_EXPORT - -#endif diff --git a/src/INTERP_KERNEL/Bases/InterpKernelException.cxx b/src/INTERP_KERNEL/Bases/InterpKernelException.cxx deleted file mode 100644 index e73efc12f..000000000 --- a/src/INTERP_KERNEL/Bases/InterpKernelException.cxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelException.hxx" - -#include - -INTERP_KERNEL::Exception::Exception(const char *what):_reason(what) -{ - std::cerr << "AN INTERP_KERNEL::EXCEPTION HAS BEEN THROWN : " << what << "**********" << std::endl; -} - -INTERP_KERNEL::Exception::Exception(const char *what, const char *file, int line):_reason(what) -{ -} - -INTERP_KERNEL::Exception::~Exception() throw () -{ -} - -const char *INTERP_KERNEL::Exception::what() const throw() -{ - return _reason.c_str(); -} diff --git a/src/INTERP_KERNEL/Bases/InterpKernelException.hxx b/src/INTERP_KERNEL/Bases/InterpKernelException.hxx deleted file mode 100644 index 187dcdeda..000000000 --- a/src/INTERP_KERNEL/Bases/InterpKernelException.hxx +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELEXCEPTION_HXX__ -#define __INTERPKERNELEXCEPTION_HXX__ - -#include "INTERPKERNELBASESDefines.hxx" - -#include -#include - -namespace INTERP_KERNEL -{ - class INTERPKERNELBASES_EXPORT Exception : std::exception - { - public: - Exception(const char *what); - Exception(const char *what, const char *file, int line); - ~Exception() throw (); - const char *what() const throw(); - protected: - std::string _reason; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Bases/InterpKernelHashFun.hxx b/src/INTERP_KERNEL/Bases/InterpKernelHashFun.hxx deleted file mode 100644 index 0fd4102a9..000000000 --- a/src/INTERP_KERNEL/Bases/InterpKernelHashFun.hxx +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// 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 General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -/* - * Copyright (c) 1996-1998 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ -#ifndef __INTERPKERNELHASHFUN_HXX__ -#define __INTERPKERNELHASHFUN_HXX__ - -#include - -namespace INTERP_KERNEL -{ - template - struct hash { }; - - inline std::size_t __stl_hash_string(const char* __s) - { - unsigned long __h = 0; - for ( ; *__s; ++__s) - __h = 5 * __h + *__s; - return std::size_t(__h); - } - - template<> - struct hash - { - std::size_t operator()(const char* __s) const - { return __stl_hash_string(__s); } - }; - - template<> - struct hash - { - std::size_t operator()(const char* __s) const - { return __stl_hash_string(__s); } - }; - - template<> - struct hash - { - std::size_t operator()(char __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(unsigned char __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(unsigned char __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(short __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(unsigned short __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(int __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(unsigned int __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(long __x) const { return __x; } - }; - - template<> - struct hash - { - std::size_t operator()(unsigned long __x) const { return __x; } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx b/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx deleted file mode 100644 index b4cc8cfbe..000000000 --- a/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx +++ /dev/null @@ -1,403 +0,0 @@ -// Copyright (C) 2001, 2002, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// 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 General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -/* - * Copyright (c) 1996 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ -#ifndef __INTERPKERNELHASHMAP__ -#define __INTERPKERNELHASHMAP__ - -#include "InterpKernelStlExt.hxx" -#include "InterpKernelHashTable.hxx" - -namespace INTERP_KERNEL -{ - template, - class _EqualKey = std::equal_to<_Key>, class _Alloc = std::allocator<_Tp> > - class HashMap - { - private: - typedef hashtable,_Key, _HashFn, - STLEXT::Select1st >, - _EqualKey, _Alloc> _Ht; - - _Ht _M_ht; - - public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - - key_equal key_eq() const { return _M_ht.key_eq(); } - - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - - HashMap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - - explicit HashMap(size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - - HashMap(size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - - HashMap(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {} - - template - HashMap(_InputIterator __f, _InputIterator __l) : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - - template - HashMap(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - - template - HashMap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - - template - HashMap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - - size_type size() const { return _M_ht.size(); } - - size_type max_size() const { return _M_ht.max_size(); } - - bool empty() const { return _M_ht.empty(); } - - void swap(HashMap& __hs) { _M_ht.swap(__hs._M_ht); } - - template - friend bool operator== (const HashMap<_K1, _T1, _HF, _EqK, _Al>&, - const HashMap<_K1, _T1, _HF, _EqK, _Al>&); - - iterator begin() { return _M_ht.begin(); } - - iterator end() { return _M_ht.end(); } - - const_iterator begin() const { return _M_ht.begin(); } - - const_iterator end() const { return _M_ht.end(); } - - std::pair insert(const value_type& __obj) { return _M_ht.insert_unique(__obj); } - - template - void insert(_InputIterator __f, _InputIterator __l) { _M_ht.insert_unique(__f, __l); } - - std::pair - insert_noresize(const value_type& __obj) { return _M_ht.insert_unique_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - - const_iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - _Tp& operator[](const key_type& __key) { return _M_ht.find_or_insert(value_type(__key, _Tp())).second; } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - std::pair equal_range(const key_type& __key) { return _M_ht.equal_range(__key); } - - std::pair equal_range(const key_type& __key) const { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) { return _M_ht.erase(__key); } - - void erase(iterator __it) { _M_ht.erase(__it); } - - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - - void clear() { _M_ht.clear(); } - - void resize(size_type __hint) { _M_ht.resize(__hint); } - - size_type bucket_count() const { return _M_ht.bucket_count(); } - - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - - size_type elems_in_bucket(size_type __n) const { return _M_ht.elems_in_bucket(__n); } - }; - - template - inline bool operator==(const HashMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, - const HashMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) - { return __hm1._M_ht == __hm2._M_ht; } - - template - inline bool operator!=(const HashMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, - const HashMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) - { return !(__hm1 == __hm2); } - - template - inline void swap(HashMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, - HashMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) - { __hm1.swap(__hm2); } - - template, - class _EqualKey = std::equal_to<_Key>, - class _Alloc = std::allocator<_Tp> > - class hash_multimap - { - private: - typedef hashtable, _Key, _HashFn, - STLEXT::Select1st >, _EqualKey, _Alloc> - _Ht; - _Ht _M_ht; - public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - - key_equal key_eq() const { return _M_ht.key_eq(); } - - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - - hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) { } - - explicit hash_multimap(size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - - hash_multimap(size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - - hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {} - - template - hash_multimap(_InputIterator __f, _InputIterator __l) : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - - size_type size() const { return _M_ht.size(); } - - size_type max_size() const { return _M_ht.max_size(); } - - bool empty() const { return _M_ht.empty(); } - - void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); } - - template - friend bool operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, - const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); - - iterator begin() { return _M_ht.begin(); } - - iterator end() { return _M_ht.end(); } - - const_iterator begin() const { return _M_ht.begin(); } - - const_iterator end() const { return _M_ht.end(); } - - iterator insert(const value_type& __obj) { return _M_ht.insert_equal(__obj); } - - template - void insert(_InputIterator __f, _InputIterator __l) { _M_ht.insert_equal(__f,__l); } - - iterator insert_noresize(const value_type& __obj) { return _M_ht.insert_equal_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - - const_iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - std::pair equal_range(const key_type& __key) { return _M_ht.equal_range(__key); } - - std::pair equal_range(const key_type& __key) const { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) { return _M_ht.erase(__key); } - - void erase(iterator __it) { _M_ht.erase(__it); } - - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - - void clear() { _M_ht.clear(); } - - void resize(size_type __hint) { _M_ht.resize(__hint); } - - size_type bucket_count() const { return _M_ht.bucket_count(); } - - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - - size_type elems_in_bucket(size_type __n) const { return _M_ht.elems_in_bucket(__n); } - }; - - template - inline bool operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, - const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) - { return __hm1._M_ht == __hm2._M_ht; } - - template - inline bool operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, - const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) - { return !(__hm1 == __hm2); } - - template - inline void swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, - hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) - { __hm1.swap(__hm2); } - -} - -namespace std -{ - // Specialization of insert_iterator so that it will work for HashMap - // and hash_multimap. - template - class insert_iterator > - { - protected: - typedef INTERP_KERNEL::HashMap<_Key, _Tp, _HashFn, _EqKey, _Alloc> - _Container; - _Container* container; - public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - - insert_iterator(_Container& __x, typename _Container::iterator) : container(&__x) {} - - insert_iterator<_Container>& operator=(const typename _Container::value_type& __value__) - { - container->insert(__value__); - return *this; - } - - insert_iterator<_Container>& operator*() { return *this; } - - insert_iterator<_Container>& operator++() { return *this; } - - insert_iterator<_Container>& operator++(int) { return *this; } - }; - - template - class insert_iterator > - { - protected: - typedef INTERP_KERNEL::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> - _Container; - _Container* container; - typename _Container::iterator iter; - - public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - - insert_iterator(_Container& __x, typename _Container::iterator) : container(&__x) {} - - insert_iterator<_Container>& operator=(const typename _Container::value_type& __value__) - { - container->insert(__value__); - return *this; - } - - insert_iterator<_Container>& operator*() { return *this; } - - insert_iterator<_Container>& operator++() { return *this; } - - insert_iterator<_Container>& operator++(int) { return *this; } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx b/src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx deleted file mode 100644 index 472891549..000000000 --- a/src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx +++ /dev/null @@ -1,995 +0,0 @@ -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -// Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// 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 General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -/* - * Copyright (c) 1996,1997 - * Silicon Graphics Computer Systems, Inc. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * - * Copyright (c) 1994 - * Hewlett-Packard Company - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Hewlett-Packard Company makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ -#ifndef __INTERPKERNELHASHTABLE_HXX__ -#define __INTERPKERNELHASHTABLE_HXX__ - -#include "InterpKernelStlExt.hxx" -#include "InterpKernelHashFun.hxx" - -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - template - struct _Hashtable_node - { - _Hashtable_node* _M_next; - _Val _M_val; - }; - - template > - class hashtable; - - template - struct _Hashtable_iterator; - - template - struct _Hashtable_const_iterator; - - template - struct _Hashtable_iterator - { - typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - typedef std::forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef std::ptrdiff_t difference_type; - typedef std::size_t size_type; - typedef _Val& reference; - typedef _Val* pointer; - - _Node* _M_cur; - _Hashtable* _M_ht; - - _Hashtable_iterator(_Node* __n, _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) { } - - _Hashtable_iterator() { } - - reference - operator*() const - { return _M_cur->_M_val; } - - pointer - operator->() const - { return &(operator*()); } - - iterator& - operator++(); - - iterator - operator++(int); - - bool - operator==(const iterator& __it) const - { return _M_cur == __it._M_cur; } - - bool - operator!=(const iterator& __it) const - { return _M_cur != __it._M_cur; } - }; - - template - struct _Hashtable_const_iterator - { - typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val,_Key,_HashFcn, - _ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef std::forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef std::ptrdiff_t difference_type; - typedef std::size_t size_type; - typedef const _Val& reference; - typedef const _Val* pointer; - - const _Node* _M_cur; - const _Hashtable* _M_ht; - - _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) { } - - _Hashtable_const_iterator() { } - - _Hashtable_const_iterator(const iterator& __it) - : _M_cur(__it._M_cur), _M_ht(__it._M_ht) { } - - reference operator*() const { return _M_cur->_M_val; } - - pointer operator->() const { return &(operator*()); } - - const_iterator& operator++(); - - const_iterator operator++(int); - - bool operator==(const const_iterator& __it) const { return _M_cur == __it._M_cur; } - - bool operator!=(const const_iterator& __it) const { return _M_cur != __it._M_cur; } - }; - - // Note: assumes long is at least 32 bits. - enum { _S_num_primes = 28 }; - - static const unsigned long __stl_prime_list[_S_num_primes] = - { - 53ul, 97ul, 193ul, 389ul, 769ul, - 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, - 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, - 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, - 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, - 1610612741ul, 3221225473ul, 4294967291ul - }; - - inline unsigned long - __stl_next_prime(unsigned long __n) - { - const unsigned long* __first = __stl_prime_list; - const unsigned long* __last = __stl_prime_list + (int)_S_num_primes; - const unsigned long* pos = std::lower_bound(__first, __last, __n); - return pos == __last ? *(__last - 1) : *pos; - } - - // Forward declaration of operator==. - template - class hashtable; - - template - bool operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, - const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2); - - // Hashtables handle allocators a bit differently than other - // containers do. If we're using standard-conforming allocators, then - // a hashtable unconditionally has a member variable to hold its - // allocator, even if it so happens that all instances of the - // allocator type are identical. This is because, for hashtables, - // this extra storage is negligible. Additionally, a base class - // wouldn't serve any other purposes; it wouldn't, for example, - // simplify the exception-handling code. - template - class hashtable - { - public: - typedef _Key key_type; - typedef _Val value_type; - typedef _HashFcn hasher; - typedef _EqualKey key_equal; - - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - - hasher hash_funct() const { return _M_hash; } - - key_equal key_eq() const { return _M_equals; } - - private: - typedef _Hashtable_node<_Val> _Node; - - public: - typedef typename _Alloc::template rebind::other allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } - - private: - typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc; - typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc; - typedef std::vector<_Node*, _Nodeptr_Alloc> _Vector_type; - - _Node_Alloc _M_node_allocator; - - _Node *_M_get_node() { return _M_node_allocator.allocate(1); } - - void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); } - - private: - hasher _M_hash; - key_equal _M_equals; - _ExtractKey _M_get_key; - _Vector_type _M_buckets; - size_type _M_num_elements; - - public: - typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, - _EqualKey, _Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, - _EqualKey, _Alloc> - const_iterator; - - friend struct - _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; - - friend struct - _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, - _EqualKey, _Alloc>; - - public: - hashtable(size_type __n, const _HashFcn& __hf, - const _EqualKey& __eql, const _ExtractKey& __ext, - const allocator_type& __a = allocator_type()) - : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), - _M_get_key(__ext), _M_buckets(__a), _M_num_elements(0) - { _M_initialize_buckets(__n); } - - hashtable(size_type __n, const _HashFcn& __hf, - const _EqualKey& __eql, - const allocator_type& __a = allocator_type()) - : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), - _M_get_key(_ExtractKey()), _M_buckets(__a), _M_num_elements(0) - { _M_initialize_buckets(__n); } - - hashtable(const hashtable& __ht) - : _M_node_allocator(__ht.get_allocator()), _M_hash(__ht._M_hash), - _M_equals(__ht._M_equals), _M_get_key(__ht._M_get_key), - _M_buckets(__ht.get_allocator()), _M_num_elements(0) - { _M_copy_from(__ht); } - - hashtable& operator= (const hashtable& __ht) - { - if (&__ht != this) - { - clear(); - _M_hash = __ht._M_hash; - _M_equals = __ht._M_equals; - _M_get_key = __ht._M_get_key; - _M_copy_from(__ht); - } - return *this; - } - - ~hashtable() - { clear(); } - - size_type size() const { return _M_num_elements; } - - size_type max_size() const { return size_type(-1); } - - bool empty() const { return size() == 0; } - - void swap(hashtable& __ht) - { - std::swap(_M_hash, __ht._M_hash); - std::swap(_M_equals, __ht._M_equals); - std::swap(_M_get_key, __ht._M_get_key); - _M_buckets.swap(__ht._M_buckets); - std::swap(_M_num_elements, __ht._M_num_elements); - } - - iterator begin() - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return iterator(_M_buckets[__n], this); - return end(); - } - - iterator end() { return iterator(0, this); } - - const_iterator begin() const - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return const_iterator(_M_buckets[__n], this); - return end(); - } - - const_iterator end() const { return const_iterator(0, this); } - - template - friend bool operator==(const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&, - const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&); - - public: - size_type bucket_count() const { return _M_buckets.size(); } - - size_type max_bucket_count() const { return __stl_prime_list[(int)_S_num_primes - 1]; } - - size_type elems_in_bucket(size_type __bucket) const - { - size_type __result = 0; - for (_Node* __n = _M_buckets[__bucket]; __n; __n = __n->_M_next) - __result += 1; - return __result; - } - - std::pair insert_unique(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_unique_noresize(__obj); - } - - iterator insert_equal(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_equal_noresize(__obj); - } - - std::pair insert_unique_noresize(const value_type& __obj); - - iterator insert_equal_noresize(const value_type& __obj); - - template - void insert_unique(_InputIterator __f, _InputIterator __l) - { insert_unique(__f, __l, __iterator_category(__f)); } - - template - void insert_equal(_InputIterator __f, _InputIterator __l) - { insert_equal(__f, __l, __iterator_category(__f)); } - - template - void insert_unique(_InputIterator __f, _InputIterator __l, - std::input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_unique(*__f); - } - - template - void insert_equal(_InputIterator __f, _InputIterator __l, - std::input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_equal(*__f); - } - - template - void insert_unique(_ForwardIterator __f, _ForwardIterator __l, - std::forward_iterator_tag) - { - size_type __n = std::distance(__f, __l); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } - - template - void - insert_equal(_ForwardIterator __f, _ForwardIterator __l, - std::forward_iterator_tag) - { - size_type __n = std::distance(__f, __l); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } - - reference find_or_insert(const value_type& __obj); - - iterator find(const key_type& __key) - { - size_type __n = _M_bkt_num_key(__key); - _Node* __first; - for (__first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - { } - return iterator(__first, this); - } - - const_iterator find(const key_type& __key) const - { - size_type __n = _M_bkt_num_key(__key); - const _Node* __first; - for (__first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - { } - return const_iterator(__first, this); - } - - size_type count(const key_type& __key) const - { - const size_type __n = _M_bkt_num_key(__key); - size_type __result = 0; - for (const _Node* __cur = _M_buckets[__n]; __cur; - __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), __key)) - ++__result; - return __result; - } - - std::pair equal_range(const key_type& __key); - - std::pair equal_range(const key_type& __key) const; - - size_type erase(const key_type& __key); - - void erase(const iterator& __it); - - void erase(iterator __first, iterator __last); - - void erase(const const_iterator& __it); - - void erase(const_iterator __first, const_iterator __last); - - void resize(size_type __num_elements_hint); - - void clear(); - - private: - size_type _M_next_size(size_type __n) const { return __stl_next_prime(__n); } - - void _M_initialize_buckets(size_type __n) - { - const size_type __n_buckets = _M_next_size(__n); - _M_buckets.reserve(__n_buckets); - _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); - _M_num_elements = 0; - } - - size_type _M_bkt_num_key(const key_type& __key) const - { return _M_bkt_num_key(__key, _M_buckets.size()); } - - size_type _M_bkt_num(const value_type& __obj) const - { return _M_bkt_num_key(_M_get_key(__obj)); } - - size_type _M_bkt_num_key(const key_type& __key, std::size_t __n) const - { return _M_hash(__key) % __n; } - - size_type _M_bkt_num(const value_type& __obj, std::size_t __n) const - { return _M_bkt_num_key(_M_get_key(__obj), __n); } - - _Node* _M_new_node(const value_type& __obj) - { - _Node* __n = _M_get_node(); - __n->_M_next = 0; - try - { - this->get_allocator().construct(&__n->_M_val, __obj); - return __n; - } - catch(...) - { - _M_put_node(__n); - throw; - } - } - - void _M_delete_node(_Node* __n) - { - this->get_allocator().destroy(&__n->_M_val); - _M_put_node(__n); - } - - void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); - - void _M_erase_bucket(const size_type __n, _Node* __last); - - void _M_copy_from(const hashtable& __ht); - }; - - template - _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& - _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: - operator++() - { - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) - { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; - } - - template - inline _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> - _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: - operator++(int) - { - iterator __tmp = *this; - ++*this; - return __tmp; - } - - template - _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& - _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: - operator++() - { - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) - { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; - } - - template - inline _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> - _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: - operator++(int) - { - const_iterator __tmp = *this; - ++*this; - return __tmp; - } - - template - bool operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, - const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) - { - typedef typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_Node _Node; - - if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) - return false; - - for (std::size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n) - { - _Node* __cur1 = __ht1._M_buckets[__n]; - _Node* __cur2 = __ht2._M_buckets[__n]; - // Check same length of lists - for (; __cur1 && __cur2; - __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) - { } - if (__cur1 || __cur2) - return false; - // Now check one's elements are in the other - for (__cur1 = __ht1._M_buckets[__n] ; __cur1; - __cur1 = __cur1->_M_next) - { - bool _found__cur1 = false; - for (__cur2 = __ht2._M_buckets[__n]; - __cur2; __cur2 = __cur2->_M_next) - { - if (__cur1->_M_val == __cur2->_M_val) - { - _found__cur1 = true; - break; - } - } - if (!_found__cur1) - return false; - } - } - return true; - } - - template - inline bool operator!=(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, - const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) - { return !(__ht1 == __ht2); } - - template - inline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, - hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) - { __ht1.swap(__ht2); } - - template - std::pair::iterator, bool> - hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: - insert_unique_noresize(const value_type& __obj) - { - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return std::pair(iterator(__cur, this), false); - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return std::pair(iterator(__tmp, this), true); - } - - template - typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator - hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: - insert_equal_noresize(const value_type& __obj) - { - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - { - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __cur->_M_next; - __cur->_M_next = __tmp; - ++_M_num_elements; - return iterator(__tmp, this); - } - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return iterator(__tmp, this); - } - - template - typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::reference - hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: - find_or_insert(const value_type& __obj) - { - resize(_M_num_elements + 1); - - size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return __cur->_M_val; - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return __tmp->_M_val; - } - - template - std::pair::iterator, - typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator> - hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::equal_range(const key_type& __key) - { - typedef std::pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (_Node* __first = _M_buckets[__n]; __first; - __first = __first->_M_next) - if (_M_equals(_M_get_key(__first->_M_val), __key)) - { - for (_Node* __cur = __first->_M_next; __cur; - __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(iterator(__first, this), iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(iterator(__first, this), - iterator(_M_buckets[__m], this)); - return _Pii(iterator(__first, this), end()); - } - return _Pii(end(), end()); - } - - template - std::pair::const_iterator, - typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator> - hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::equal_range(const key_type& __key) const - { - typedef std::pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (const _Node* __first = _M_buckets[__n]; __first; - __first = __first->_M_next) - { - if (_M_equals(_M_get_key(__first->_M_val), __key)) - { - for (const _Node* __cur = __first->_M_next; __cur; - __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(const_iterator(__first, this), - const_iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(const_iterator(__first, this), - const_iterator(_M_buckets[__m], this)); - return _Pii(const_iterator(__first, this), end()); - } - } - return _Pii(end(), end()); - } - - template - typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::size_type - hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(const key_type& __key) - { - const size_type __n = _M_bkt_num_key(__key); - _Node* __first = _M_buckets[__n]; - size_type __erased = 0; - - if (__first) - { - _Node* __cur = __first; - _Node* __next = __cur->_M_next; - while (__next) - { - if (_M_equals(_M_get_key(__next->_M_val), __key)) - { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - ++__erased; - --_M_num_elements; - } - else - { - __cur = __next; - __next = __cur->_M_next; - } - } - if (_M_equals(_M_get_key(__first->_M_val), __key)) - { - _M_buckets[__n] = __first->_M_next; - _M_delete_node(__first); - ++__erased; - --_M_num_elements; - } - } - return __erased; - } - - template - void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(const iterator& __it) - { - _Node* __p = __it._M_cur; - if (__p) - { - const size_type __n = _M_bkt_num(__p->_M_val); - _Node* __cur = _M_buckets[__n]; - if (__cur == __p) - { - _M_buckets[__n] = __cur->_M_next; - _M_delete_node(__cur); - --_M_num_elements; - } - else - { - _Node* __next = __cur->_M_next; - while (__next) - { - if (__next == __p) - { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - --_M_num_elements; - break; - } - else - { - __cur = __next; - __next = __cur->_M_next; - } - } - } - } - } - - template - void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(iterator __first, iterator __last) - { - size_type __f_bucket = __first._M_cur ? _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size(); - - size_type __l_bucket = __last._M_cur ? _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size(); - - if (__first._M_cur == __last._M_cur) - return; - else if (__f_bucket == __l_bucket) - _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); - else - { - _M_erase_bucket(__f_bucket, __first._M_cur, 0); - for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) - _M_erase_bucket(__n, 0); - if (__l_bucket != _M_buckets.size()) - _M_erase_bucket(__l_bucket, __last._M_cur); - } - } - - template - inline void - hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: - erase(const_iterator __first, const_iterator __last) - { - erase(iterator(const_cast<_Node*>(__first._M_cur), - const_cast(__first._M_ht)), - iterator(const_cast<_Node*>(__last._M_cur), - const_cast(__last._M_ht))); - } - - template - inline void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(const const_iterator& __it) - { erase(iterator(const_cast<_Node*>(__it._M_cur), const_cast(__it._M_ht))); } - - template - void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::resize(size_type __num_elements_hint) - { - const size_type __old_n = _M_buckets.size(); - if (__num_elements_hint > __old_n) - { - const size_type __n = _M_next_size(__num_elements_hint); - if (__n > __old_n) - { - _Vector_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator()); - try - { - for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) - { - _Node* __first = _M_buckets[__bucket]; - while (__first) - { - size_type __new_bucket = _M_bkt_num(__first->_M_val,__n); - _M_buckets[__bucket] = __first->_M_next; - __first->_M_next = __tmp[__new_bucket]; - __tmp[__new_bucket] = __first; - __first = _M_buckets[__bucket]; - } - } - _M_buckets.swap(__tmp); - } - catch(...) - { - for (size_type __bucket = 0; __bucket < __tmp.size();++__bucket) - { - while (__tmp[__bucket]) - { - _Node* __next = __tmp[__bucket]->_M_next; - _M_delete_node(__tmp[__bucket]); - __tmp[__bucket] = __next; - } - } - throw; - } - } - } - } - - template - void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) - { - _Node* __cur = _M_buckets[__n]; - if (__cur == __first) - _M_erase_bucket(__n, __last); - else - { - _Node* __next; - for (__next = __cur->_M_next; - __next != __first; - __cur = __next, __next = __cur->_M_next) - ; - while (__next != __last) - { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - --_M_num_elements; - } - } - } - - template - void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_erase_bucket(const size_type __n, _Node* __last) - { - _Node* __cur = _M_buckets[__n]; - while (__cur != __last) - { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; - _M_buckets[__n] = __cur; - --_M_num_elements; - } - } - - template - void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::clear() - { - for (size_type __i = 0; __i < _M_buckets.size(); ++__i) - { - _Node* __cur = _M_buckets[__i]; - while (__cur != 0) - { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; - } - _M_buckets[__i] = 0; - } - _M_num_elements = 0; - } - - template - void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from(const hashtable& __ht) - { - _M_buckets.clear(); - _M_buckets.reserve(__ht._M_buckets.size()); - _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); - try - { - for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { - const _Node* __cur = __ht._M_buckets[__i]; - if (__cur) - { - _Node* __local_copy = _M_new_node(__cur->_M_val); - _M_buckets[__i] = __local_copy; - for (_Node* __next = __cur->_M_next; - __next; - __cur = __next, __next = __cur->_M_next) - { - __local_copy->_M_next = _M_new_node(__next->_M_val); - __local_copy = __local_copy->_M_next; - } - } - } - _M_num_elements = __ht._M_num_elements; - } - catch(...) - { - clear(); - throw; - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx b/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx deleted file mode 100644 index 36b40df94..000000000 --- a/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELSTLEXT_HXX__ -#define __INTERPKERNELSTLEXT_HXX__ - -#include - -namespace INTERP_KERNEL -{ - namespace STLEXT - { - template - struct Select1st : public std::unary_function<_Pair, typename _Pair::first_type> - { - typename _Pair::first_type& operator()(_Pair& __x) const { return __x.first; } - const typename _Pair::first_type&operator()(const _Pair& __x) const { return __x.first; } - }; - - template - inline void Construct(_T1* __p, const _T2& __value__) { ::new(static_cast(__p)) _T1(__value__); } - - template inline void Destroy(_Tp* __pointer) { __pointer->~_Tp(); } - } -} - -#endif diff --git a/src/INTERP_KERNEL/Bases/Makefile.am b/src/INTERP_KERNEL/Bases/Makefile.am deleted file mode 100755 index fc89569bc..000000000 --- a/src/INTERP_KERNEL/Bases/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2007-2010 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 : Makefile.am -# Author : Vincent BERGEAUD (CEA/DEN/DANS/DM2S/SFME/LGLS) -# Module : MED -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -noinst_LTLIBRARIES = libinterpkernelbases.la - -salomeinclude_HEADERS = \ -INTERPKERNELBASESDefines.hxx \ -InterpKernelException.hxx \ -NormalizedUnstructuredMesh.hxx \ -InterpKernelStlExt.hxx \ -InterpKernelHashMap.hxx \ -InterpKernelHashTable.hxx \ -InterpKernelHashFun.hxx - -# Libraries targets - -dist_libinterpkernelbases_la_SOURCES = \ -InterpKernelException.cxx diff --git a/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx b/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx deleted file mode 100644 index 5d2350cae..000000000 --- a/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2007-2010 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 __NORMALIZEDUNSTRUCTUREDMESH_HXX__ -#define __NORMALIZEDUNSTRUCTUREDMESH_HXX__ - -namespace INTERP_KERNEL -{ - typedef enum - { - ALL_C_MODE , - ALL_FORTRAN_MODE - } NumberingPolicy; - - - typedef enum - { - NORM_POINT0 = 0, - NORM_SEG2 = 1, - NORM_SEG3 = 2, - NORM_TRI3 = 3, - NORM_QUAD4 = 4, - NORM_POLYGON = 5, - NORM_TRI6 = 6, - NORM_QUAD8 = 8, - // - NORM_TETRA4 = 14, - NORM_PYRA5 = 15, - NORM_PENTA6 = 16, - NORM_HEXA8 = 18, - NORM_TETRA10 = 20, - NORM_PYRA13 = 23, - NORM_PENTA15 = 25, - NORM_HEXA20 = 30, - NORM_POLYHED = 31, - NORM_ERROR = 40 - } NormalizedCellType; - - class GenericMesh - {}; -} - -#endif diff --git a/src/INTERP_KERNEL/BoundingBox.cxx b/src/INTERP_KERNEL/BoundingBox.cxx deleted file mode 100644 index 4179448b4..000000000 --- a/src/INTERP_KERNEL/BoundingBox.cxx +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (C) 2007-2010 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 "BoundingBox.hxx" - -#include -#include -#include - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating box from an array of the points corresponding - * to the vertices of the element. - * Each point is represented by an array of three doubles. - * - * @param pts array of points - * @param numPts number of vertices - * - */ - BoundingBox::BoundingBox(const double** pts, const unsigned numPts) - :_coords(new double[6]) - { - assert(numPts > 1); - - // initialize with first two points - const double* pt1 = pts[0]; - const double* pt2 = pts[1]; - - for(BoxCoord c = XMIN ; c <= ZMIN ; c = BoxCoord(c + 1)) - { - _coords[c] = std::min(pt1[c], pt2[c]); - _coords[c + 3] = std::max(pt1[c], pt2[c]); - } - - for(unsigned i = 2 ; i < numPts ; ++i) - { - updateWithPoint(pts[i]); - } - - assert(isValid()); - } - - /** - * Constructor creating box from union of two boxes, resulting in a box that encloses both of them - * - * @param box1 the first box - * @param box2 the second box - */ - BoundingBox::BoundingBox(const BoundingBox& box1, const BoundingBox& box2) - : _coords(new double[6]) - { - assert(_coords != 0); - - for(BoxCoord c = XMIN ; c <= ZMIN ; c = BoxCoord(c + 1)) - { - _coords[c] = std::min(box1._coords[c], box2._coords[c]); - _coords[c + 3] = std::max(box1._coords[c + 3], box2._coords[c + 3]); - } - - assert(isValid()); - } - - /** - * Destructor - * - */ - BoundingBox::~BoundingBox() - { - delete[] _coords; - } - - /** - * Determines if the intersection with a given box is empty - * - * @param box BoundingBox with which intersection is tested - * @return true if intersection between boxes is empty, false if not - */ - bool BoundingBox::isDisjointWith(const BoundingBox& box) const - { - for(BoxCoord c = XMIN ; c <= ZMIN ; c = BoxCoord(c + 1)) - { - const double otherMinCoord = box.getCoordinate(c); - const double otherMaxCoord = box.getCoordinate(BoxCoord(c + 3)); - - // boxes are disjoint if there exists a direction in which the - // minimum coordinate of one is greater than the maximum coordinate of the other - - // more stable version ? - // const double tol = 1.0e-2*_coords[c]; - // if(_coords[c] > otherMaxCoord + tol - // || _coords[c + 3] < otherMinCoord - tol) - - - if(_coords[c] > otherMaxCoord - || _coords[c + 3] < otherMinCoord) - - { - return true; - } - - } - return false; - } - - - - /** - * Updates the bounding box to include a given point - * - * @param pt point to be included - * - */ - void BoundingBox::updateWithPoint(const double* pt) - { - for(BoxCoord c = XMIN ; c <= ZMIN ; c = BoxCoord(c + 1)) - { - const double ptVal = pt[c]; - - // update min and max coordinates - _coords[c] = std::min(_coords[c], ptVal); - _coords[c + 3] = std::max(_coords[c + 3], ptVal); - - } - } - - /** - * Checks if the box is valid, which it is if its minimum coordinates are - * smaller than its maximum coordinates in all directions. - * - * @return true if the box is valid, false if not - */ - bool BoundingBox::isValid() const - { - bool valid = true; - for(BoxCoord c = XMIN ; c < ZMIN ; c = BoxCoord(c + 1)) - { - if(_coords[c] > _coords[c + 3]) - { - std::cout << "+++ Error in BoundingBox |: coordinate " << c << " is invalid : " - <<_coords[c] << " > " << _coords[c+3] << std::endl; - valid = false; - } - } - return valid; - } - -} diff --git a/src/INTERP_KERNEL/BoundingBox.hxx b/src/INTERP_KERNEL/BoundingBox.hxx deleted file mode 100644 index d95cfd818..000000000 --- a/src/INTERP_KERNEL/BoundingBox.hxx +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2007-2010 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 __BOUNDINGBOX_HXX__ -#define __BOUNDINGBOX_HXX__ - -#include "INTERPKERNELDefines.hxx" -#include - -namespace INTERP_KERNEL -{ - - /** - * \brief Class representing the bounding box of a number of points. - * - */ - class INTERPKERNEL_EXPORT BoundingBox - { - public: - - /// Enumeration representing the six coordinates that define the bounding box - enum BoxCoord { XMIN = 0, YMIN = 1, ZMIN = 2, XMAX = 3, YMAX = 4, ZMAX = 5 }; - - BoundingBox(const double** pts, const unsigned numPts); - - BoundingBox(const BoundingBox& box1, const BoundingBox& box2); - - ~BoundingBox(); - - bool isDisjointWith(const BoundingBox& box) const; - - inline void setCoordinate(const BoxCoord coord, double value); - - inline double getCoordinate(const BoxCoord coord) const; - - void updateWithPoint(const double* pt); - - inline void dumpCoords() const; - - private: - - bool isValid() const; - - /// disallow copying - BoundingBox(const BoundingBox& box); - - /// disallow assignment - BoundingBox& operator=(const BoundingBox& box); - - /// Vector containing the coordinates of the box - /// interlaced in the order XMIN, YMIN, ZMIN, XMAX, YMAX, ZMAX - double* _coords; - - }; - - /** - * Sets a coordinate of the box to a given value. - * - * @param coord coordinate to set - * @param value new value for coordinate - * - */ - inline void BoundingBox::setCoordinate(const BoxCoord coord, double value) - { - _coords[coord] = value; - } - - /** - * Gets a coordinate of the box - * - * @param coord coordinate to get - * @return value of coordinate - * - */ - inline double BoundingBox::getCoordinate(const BoxCoord coord) const - { - return _coords[coord]; - } - - /** - * Prints the coordinates of the box to std::cout - * - */ - inline void BoundingBox::dumpCoords() const - { - std::cout << "[xmin, xmax] = [" << _coords[XMIN] << ", " << _coords[XMAX] << "]" << " | "; - std::cout << "[ymin, ymax] = [" << _coords[YMIN] << ", " << _coords[YMAX] << "]" << " | "; - std::cout << "[zmin, zmax] = [" << _coords[ZMIN] << ", " << _coords[ZMAX] << "]"; - std::cout << std::endl; - } - -} - -#endif diff --git a/src/INTERP_KERNEL/CellModel.cxx b/src/INTERP_KERNEL/CellModel.cxx deleted file mode 100644 index 88bc7a820..000000000 --- a/src/INTERP_KERNEL/CellModel.cxx +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright (C) 2007-2010 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 "CellModel.hxx" - -#include "InterpKernelException.hxx" - -#include -#include -#include - -namespace INTERP_KERNEL -{ - const char *CellModel::CELL_TYPES_REPR[]={"NORM_POINT0", "NORM_SEG2", "NORM_SEG3", "NORM_TRI3", "NORM_QUAD4",// 0->4 - "NORM_POLYGON", "NORM_TRI6", "" , "NORM_QUAD8", "",//5->9 - "", "", "", "", "NORM_TETRA4",//10->14 - "NORM_PYRA5", "NORM_PENTA6", "", "NORM_HEXA8", "",//15->19 - "NORM_TETRA10", "", "", "NORM_PYRA13", "",//20->24 - "NORM_PENTA15", "", "", "", "",//25->29 - "NORM_HEXA20", "NORM_POLYHED", "", "", "",//30->34 - "", "", "", "", "",//35->39 - "NORM_ERROR"}; - - std::map CellModel::_map_of_unique_instance; - - const CellModel& CellModel::getCellModel(NormalizedCellType type) - { - if(_map_of_unique_instance.empty()) - buildUniqueInstance(); - const std::map::iterator iter=_map_of_unique_instance.find(type); - if(iter==_map_of_unique_instance.end()) - { - std::ostringstream stream; stream << "no cellmodel for normalized type " << type; - throw Exception(stream.str().c_str()); - } - return (*iter).second; - } - - const char *CellModel::getRepr() const - { - return CELL_TYPES_REPR[(int)_type]; - } - - /*! - * This method is compatible with all types including dynamic one. - */ - bool CellModel::isCompatibleWith(NormalizedCellType type) const - { - if(_type==type) - return true; - const CellModel& other=getCellModel(type); - if(_dim!=other.getDimension()) - return false; - bool b1=isQuadratic(); - bool b2=other.isQuadratic(); - if((b1 && !b2) || (!b1 && b2)) - return false; - b1=isDynamic(); - b2=other.isDynamic(); - return b1 || b2; - } - - void CellModel::buildUniqueInstance() - { - _map_of_unique_instance.insert(std::make_pair(NORM_POINT0,CellModel(NORM_POINT0))); - _map_of_unique_instance.insert(std::make_pair(NORM_SEG2,CellModel(NORM_SEG2))); - _map_of_unique_instance.insert(std::make_pair(NORM_SEG3,CellModel(NORM_SEG3))); - _map_of_unique_instance.insert(std::make_pair(NORM_TRI3,CellModel(NORM_TRI3))); - _map_of_unique_instance.insert(std::make_pair(NORM_QUAD4,CellModel(NORM_QUAD4))); - _map_of_unique_instance.insert(std::make_pair(NORM_TRI6,CellModel(NORM_TRI6))); - _map_of_unique_instance.insert(std::make_pair(NORM_QUAD8,CellModel(NORM_QUAD8))); - _map_of_unique_instance.insert(std::make_pair(NORM_TETRA4,CellModel(NORM_TETRA4))); - _map_of_unique_instance.insert(std::make_pair(NORM_HEXA8,CellModel(NORM_HEXA8))); - _map_of_unique_instance.insert(std::make_pair(NORM_PYRA5,CellModel(NORM_PYRA5))); - _map_of_unique_instance.insert(std::make_pair(NORM_PENTA6,CellModel(NORM_PENTA6))); - _map_of_unique_instance.insert(std::make_pair(NORM_TETRA10,CellModel(NORM_TETRA10))); - _map_of_unique_instance.insert(std::make_pair(NORM_PYRA13,CellModel(NORM_PYRA13))); - _map_of_unique_instance.insert(std::make_pair(NORM_PENTA15,CellModel(NORM_PENTA15))); - _map_of_unique_instance.insert(std::make_pair(NORM_HEXA20,CellModel(NORM_HEXA20))); - _map_of_unique_instance.insert(std::make_pair(NORM_POLYGON,CellModel(NORM_POLYGON))); - _map_of_unique_instance.insert(std::make_pair(NORM_POLYHED,CellModel(NORM_POLYHED))); - } - - CellModel::CellModel(NormalizedCellType type):_type(type) - { - _quadratic=false; - _dyn=false; - _extruded_type=NORM_ERROR; - _linear_type=NORM_ERROR; - _quadratic_type=NORM_ERROR; - switch(type) - { - case NORM_POINT0: - { - _nb_of_pts=0; _nb_of_sons=0; _dim=0; _extruded_type=NORM_SEG2; - } - break; - case NORM_SEG2: - { - _nb_of_pts=2; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; - } - break; - case NORM_SEG3: - { - _nb_of_pts=3; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD8; _linear_type=NORM_SEG2; - } - break; - case NORM_TETRA4: - { - _nb_of_pts=4; _nb_of_sons=4; _dim=3; _quadratic_type=NORM_TETRA10; - _sons_type[0]=NORM_TRI3; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_TRI3; _sons_type[3]=NORM_TRI3; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _nb_of_sons_con[0]=3; - _sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _nb_of_sons_con[1]=3; - _sons_con[2][0]=1; _sons_con[2][1]=3; _sons_con[2][2]=2; _nb_of_sons_con[2]=3; - _sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _nb_of_sons_con[3]=3; - } - break; - case NORM_HEXA8: - { - _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; - _sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_QUAD4; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4; - _sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _nb_of_sons_con[1]=4; - _sons_con[2][0]=0; _sons_con[2][1]=4; _sons_con[2][2]=5; _sons_con[2][3]=1; _nb_of_sons_con[2]=4; - _sons_con[3][0]=1; _sons_con[3][1]=5; _sons_con[3][2]=6; _sons_con[3][3]=2; _nb_of_sons_con[3]=4; - _sons_con[4][0]=2; _sons_con[4][1]=6; _sons_con[4][2]=7; _sons_con[4][3]=3; _nb_of_sons_con[4]=4; - _sons_con[5][0]=3; _sons_con[5][1]=7; _sons_con[5][2]=4; _sons_con[5][3]=0; _nb_of_sons_con[5]=4; - } - break; - case NORM_QUAD4: - { - _nb_of_pts=4; _nb_of_sons=4; _dim=2; _quadratic_type=NORM_QUAD8; - _sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2; _sons_type[3]=NORM_SEG2; - _sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2; - _sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2; - _sons_con[2][0]=2; _sons_con[2][1]=3; _nb_of_sons_con[2]=2; - _sons_con[3][0]=3; _sons_con[3][1]=0; _nb_of_sons_con[3]=2; _extruded_type=NORM_HEXA8; - } - break; - case NORM_TRI3: - { - _nb_of_pts=3; _nb_of_sons=3; _dim=2; _quadratic_type=NORM_TRI6; - _sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2; - _sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2; - _sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2; - _sons_con[2][0]=2; _sons_con[2][1]=0; _nb_of_sons_con[2]=2; _extruded_type=NORM_PENTA6; - } - break; - case NORM_TRI6: - { - _nb_of_pts=6; _nb_of_sons=3; _dim=2; _linear_type=NORM_TRI3; - _sons_type[0]=NORM_SEG3; _sons_type[1]=NORM_SEG3; _sons_type[2]=NORM_SEG3; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=3; _nb_of_sons_con[0]=3; - _sons_con[1][0]=1; _sons_con[1][1]=2; _sons_con[1][2]=4; _nb_of_sons_con[1]=3; - _sons_con[2][0]=2; _sons_con[2][1]=0; _sons_con[2][2]=5; _nb_of_sons_con[2]=3; _quadratic=true; _extruded_type=NORM_PENTA15; - } - break; - case NORM_QUAD8: - { - _nb_of_pts=8; _nb_of_sons=4; _dim=2; _linear_type=NORM_QUAD4; - _sons_type[0]=NORM_SEG3; _sons_type[1]=NORM_SEG3; _sons_type[2]=NORM_SEG3; _sons_type[3]=NORM_SEG3; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=4; _nb_of_sons_con[0]=3; - _sons_con[1][0]=1; _sons_con[1][1]=2; _sons_con[1][2]=5; _nb_of_sons_con[1]=3; - _sons_con[2][0]=2; _sons_con[2][1]=3; _sons_con[2][2]=6; _nb_of_sons_con[2]=3; - _sons_con[3][0]=3; _sons_con[3][1]=0; _sons_con[3][2]=7; _nb_of_sons_con[3]=3; _quadratic=true; _extruded_type=NORM_HEXA20; - } - break; - case NORM_PYRA5: - { - _nb_of_pts=5; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PYRA13; - _sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_TRI3; _sons_type[3]=NORM_TRI3; _sons_type[4]=NORM_TRI3; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4; - _sons_con[1][0]=0; _sons_con[1][1]=4; _sons_con[1][2]=1; _nb_of_sons_con[1]=3; - _sons_con[2][0]=1; _sons_con[2][1]=4; _sons_con[2][2]=2; _nb_of_sons_con[2]=3; - _sons_con[3][0]=2; _sons_con[3][1]=4; _sons_con[3][2]=3; _nb_of_sons_con[3]=3; - _sons_con[4][0]=3; _sons_con[4][1]=4; _sons_con[4][2]=0; _nb_of_sons_con[4]=3; - } - break; - case NORM_PENTA6: - { - _nb_of_pts=6; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PENTA15; - _sons_type[0]=NORM_TRI3; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _nb_of_sons_con[0]=3; - _sons_con[1][0]=3; _sons_con[1][1]=5; _sons_con[1][2]=4; _nb_of_sons_con[1]=3; - _sons_con[2][0]=0; _sons_con[2][1]=3; _sons_con[2][2]=4; _sons_con[2][3]=1; _nb_of_sons_con[2]=4; - _sons_con[3][0]=1; _sons_con[3][1]=4; _sons_con[3][2]=5; _sons_con[3][3]=2; _nb_of_sons_con[3]=4; - _sons_con[4][0]=2; _sons_con[4][1]=5; _sons_con[4][2]=3; _sons_con[4][3]=0; _nb_of_sons_con[4]=4; - } - break; - case NORM_TETRA10: - { - _nb_of_pts=10; _nb_of_sons=4; _dim=3; _linear_type=NORM_TETRA4; - _sons_type[0]=NORM_TRI6; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_TRI6; _sons_type[3]=NORM_TRI6; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=4; _sons_con[0][4]=5; _sons_con[0][5]=6; _nb_of_sons_con[0]=6; - _sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _sons_con[1][3]=7; _sons_con[1][4]=8; _sons_con[1][5]=4; _nb_of_sons_con[1]=6; - _sons_con[2][0]=1; _sons_con[2][1]=3; _sons_con[2][2]=2; _sons_con[2][3]=8; _sons_con[2][4]=9; _sons_con[2][5]=5; _nb_of_sons_con[2]=6; - _sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _sons_con[3][3]=9; _sons_con[3][4]=7; _sons_con[3][5]=6; _nb_of_sons_con[3]=6; _quadratic=true; - } - break; - case NORM_PYRA13: - { - _nb_of_pts=13; _nb_of_sons=5; _dim=3; _linear_type=NORM_PYRA5; - _sons_type[0]=NORM_QUAD8; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_TRI6; _sons_type[3]=NORM_TRI6; _sons_type[4]=NORM_TRI6; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=5; _sons_con[0][5]=6; _sons_con[0][6]=7; _sons_con[0][7]=8; _nb_of_sons_con[0]=8; - _sons_con[1][0]=0; _sons_con[1][1]=4; _sons_con[1][2]=1; _sons_con[1][3]=9; _sons_con[1][4]=10; _sons_con[1][5]=5; _nb_of_sons_con[1]=6; - _sons_con[2][0]=1; _sons_con[2][1]=4; _sons_con[2][2]=2; _sons_con[2][3]=10; _sons_con[2][4]=11; _sons_con[2][5]=6; _nb_of_sons_con[2]=6; - _sons_con[3][0]=2; _sons_con[3][1]=4; _sons_con[3][2]=3; _sons_con[3][3]=11; _sons_con[3][4]=12; _sons_con[3][5]=7; _nb_of_sons_con[3]=6; - _sons_con[4][0]=3; _sons_con[4][1]=4; _sons_con[4][2]=0; _sons_con[4][3]=12; _sons_con[4][4]=9; _sons_con[4][5]=8; _nb_of_sons_con[4]=6; _quadratic=true; - } - break; - case NORM_PENTA15: - { - _nb_of_pts=15; _nb_of_sons=5; _dim=3; _linear_type=NORM_PENTA6; - _sons_type[0]=NORM_TRI6; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_QUAD8; _sons_type[3]=NORM_QUAD8; _sons_type[4]=NORM_QUAD8; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=6; _sons_con[0][4]=7; _sons_con[0][5]=8; _nb_of_sons_con[0]=6; - _sons_con[1][0]=3; _sons_con[1][1]=5; _sons_con[1][2]=4; _sons_con[1][3]=11; _sons_con[1][4]=10; _sons_con[1][5]=9; _nb_of_sons_con[1]=6; - _sons_con[2][0]=0; _sons_con[2][1]=3; _sons_con[2][2]=4; _sons_con[2][3]=1; _sons_con[2][4]=12; _sons_con[2][5]=9; _sons_con[2][6]=13; _sons_con[2][7]=6; _nb_of_sons_con[2]=8; - _sons_con[3][0]=1; _sons_con[3][1]=4; _sons_con[3][2]=5; _sons_con[3][3]=2; _sons_con[3][4]=13; _sons_con[3][5]=10; _sons_con[3][6]=14; _sons_con[3][7]=7; _nb_of_sons_con[3]=8; - _sons_con[4][0]=2; _sons_con[4][1]=4; _sons_con[4][2]=5; _sons_con[4][3]=0; _sons_con[4][4]=14; _sons_con[4][5]=11; _sons_con[4][6]=12; _sons_con[4][7]=8; _nb_of_sons_con[4]=8; _quadratic=true; - } - break; - case NORM_HEXA20: - { - _nb_of_pts=20; _nb_of_sons=6; _dim=3; _linear_type=NORM_HEXA8; - _sons_type[0]=NORM_QUAD8; _sons_type[1]=NORM_QUAD8; _sons_type[2]=NORM_QUAD8; _sons_type[3]=NORM_QUAD8; _sons_type[4]=NORM_QUAD8; _sons_type[5]=NORM_QUAD8; - _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=8; _sons_con[0][5]=9; _sons_con[0][6]=10; _sons_con[0][7]=11; _nb_of_sons_con[0]=8; - _sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _sons_con[1][4]=15; _sons_con[1][5]=14; _sons_con[1][6]=13; _sons_con[1][7]=12; _nb_of_sons_con[1]=8; - _sons_con[2][0]=0; _sons_con[2][1]=4; _sons_con[2][2]=5; _sons_con[2][3]=1; _sons_con[2][4]=16; _sons_con[2][5]=12; _sons_con[2][6]=17; _sons_con[2][7]=8; _nb_of_sons_con[2]=8; - _sons_con[3][0]=1; _sons_con[3][1]=5; _sons_con[3][3]=6; _sons_con[3][3]=2; _sons_con[3][4]=17; _sons_con[3][5]=13; _sons_con[3][6]=18; _sons_con[3][7]=9;_nb_of_sons_con[3]=8; - _sons_con[4][0]=2; _sons_con[4][1]=6; _sons_con[4][3]=7; _sons_con[4][3]=3; _sons_con[4][4]=18; _sons_con[4][5]=14; _sons_con[4][6]=19; _sons_con[4][7]=10; _nb_of_sons_con[4]=8; - _sons_con[5][0]=3; _sons_con[5][1]=7; _sons_con[5][3]=4; _sons_con[5][3]=0; _sons_con[5][4]=19; _sons_con[5][5]=15; _sons_con[5][6]=16; _sons_con[5][7]=11; _nb_of_sons_con[5]=8; _quadratic=true; - } - break; - case NORM_POLYGON: - { - _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _extruded_type=NORM_POLYHED; - } - break; - case NORM_POLYHED: - { - _nb_of_pts=0; _nb_of_sons=0; _dim=3; _dyn=true; - } - break; - case NORM_ERROR: - { - _nb_of_pts=std::numeric_limits::max(); _nb_of_sons=std::numeric_limits::max(); _dim=std::numeric_limits::max(); - } - break; - } - } - - /*! - * Equivalent to getNumberOfSons except that this method deals with dynamic type. - */ - unsigned CellModel::getNumberOfSons2(const int *conn, int lgth) const - { - if(!isDynamic()) - return getNumberOfSons(); - if(_dim==2)//polygon - return lgth; - else - return std::count(conn,conn+lgth,-1)+1; - } - - /*! - * Equivalent to getSonType except that this method deals with dynamic type. - */ - NormalizedCellType CellModel::getSonType2(unsigned sonId) const - { - if(!isDynamic()) - return getSonType(sonId); - if(_dim==2)//polygon - return NORM_SEG2; - //polyedron - return NORM_POLYGON; - } - - /*! - * \b WARNING this method do not manage correctly types that return true at the call of isDynamic. Use fillSonCellNodalConnectivity2 instead. - */ - unsigned CellModel::fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const - { - unsigned nbOfTurnLoop=_nb_of_sons_con[sonId]; - const unsigned *sonConn=_sons_con[sonId]; - for(unsigned i=0;i - -namespace INTERP_KERNEL -{ - /*! - * This class descibes all static elements (different from polygons and polyhedron) 3D, 2D and 1D. - */ - class CellModel - { - public: - static const unsigned MAX_NB_OF_SONS=6; - static const unsigned MAX_NB_OF_NODES_PER_ELEM=30; - private: - CellModel(NormalizedCellType type); - static void buildUniqueInstance(); - public: - INTERPKERNEL_EXPORT static const CellModel& getCellModel(NormalizedCellType type); - INTERPKERNEL_EXPORT const char *getRepr() const; - INTERPKERNEL_EXPORT bool isDynamic() const { return _dyn; } - INTERPKERNEL_EXPORT bool isQuadratic() const { return _quadratic; } - INTERPKERNEL_EXPORT unsigned getDimension() const { return _dim; } - INTERPKERNEL_EXPORT bool isCompatibleWith(NormalizedCellType type) const; - //! sonId is in C format. - INTERPKERNEL_EXPORT const unsigned *getNodesConstituentTheSon(unsigned sonId) const { return _sons_con[sonId]; } - INTERPKERNEL_EXPORT unsigned getNumberOfNodes() const { return _nb_of_pts; } - INTERPKERNEL_EXPORT unsigned getNumberOfSons() const { return _nb_of_sons; } - INTERPKERNEL_EXPORT unsigned getNumberOfSons2(const int *conn, int lgth) const; - INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nb_of_sons_con[sonId]; } - INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const; - INTERPKERNEL_EXPORT NormalizedCellType getExtrudedType() const { return _extruded_type; } - INTERPKERNEL_EXPORT NormalizedCellType getLinearType() const { return _linear_type; } - INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType() const { return _quadratic_type; } - INTERPKERNEL_EXPORT NormalizedCellType getSonType(unsigned sonId) const { return _sons_type[sonId]; } - INTERPKERNEL_EXPORT NormalizedCellType getSonType2(unsigned sonId) const; - INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const; - INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const; - private: - bool _dyn; - bool _quadratic; - unsigned _dim; - unsigned _nb_of_pts; - unsigned _nb_of_sons; - NormalizedCellType _type; - NormalizedCellType _extruded_type; - NormalizedCellType _linear_type; - NormalizedCellType _quadratic_type; - unsigned _sons_con[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM]; - unsigned _nb_of_sons_con[MAX_NB_OF_SONS]; - NormalizedCellType _sons_type[MAX_NB_OF_SONS]; - static std::map _map_of_unique_instance; - static const char *CELL_TYPES_REPR[]; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/ConvexIntersector.hxx b/src/INTERP_KERNEL/ConvexIntersector.hxx deleted file mode 100644 index 6657205ce..000000000 --- a/src/INTERP_KERNEL/ConvexIntersector.hxx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2007-2010 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 __CONVEXINTERSECTOR_HXX__ -#define __CONVEXINTERSECTOR_HXX__ - -#include "PlanarIntersectorP0P0.hxx" -#include "PlanarIntersectorP0P1.hxx" -#include "PlanarIntersectorP1P0.hxx" -#include "PlanarIntersectorP1P1.hxx" -#include "PlanarIntersectorP1P0Bary.hxx" - -namespace INTERP_KERNEL -{ - template class InterpType > - class ConvexIntersector : public InterpType > - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - ConvexIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, double medianPlane, - bool doRotate, int orientation, int printLevel); - double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS); - double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad); - double intersectGeometryGeneral(const std::vector& targetCoords, const std::vector& sourceCoords); - double intersectGeoBary(const std::vector& targetCell, bool targetCellQuadratic, const double *sourceCell, std::vector& res); - private : - double _epsilon; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/ConvexIntersector.txx b/src/INTERP_KERNEL/ConvexIntersector.txx deleted file mode 100644 index 45f6f4403..000000000 --- a/src/INTERP_KERNEL/ConvexIntersector.txx +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (C) 2007-2010 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 __CONVEXINTERSECTOR_TXX__ -#define __CONVEXINTERSECTOR_TXX__ - -#include "ConvexIntersector.hxx" -#include "PlanarIntersectorP0P0.txx" -#include "PlanarIntersectorP0P1.txx" -#include "PlanarIntersectorP1P0.txx" -#include "PlanarIntersectorP1P1.txx" -#include "PlanarIntersectorP1P0Bary.txx" - -#include "PolygonAlgorithms.txx" - -#include - -#define CONVINTERSECTOR_TEMPLATE template class InterpType> -#define CONVEX_INTERSECTOR_ ConvexIntersector - -namespace INTERP_KERNEL -{ - CONVINTERSECTOR_TEMPLATE - CONVEX_INTERSECTOR_::ConvexIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, - double medianPlane, bool doRotate , int oriantation, int printLevel) - :InterpType(meshT,meshS,dimCaracteristic, precision, md3DSurf, medianPlane, doRotate, oriantation, printLevel), - _epsilon(precision*dimCaracteristic) - { - if(PlanarIntersector::_print_level >= 1) - { - std::cout << " - intersection type = convex " << std::endl; - if(SPACEDIM==3){ - if(PlanarIntersector::_do_rotate) std::cout << " _do_rotate = true" << std::endl; - else std::cout << " _do_rotate = false" << std::endl; - } - } - } - - CONVINTERSECTOR_TEMPLATE - double CONVEX_INTERSECTOR_::intersectGeometry(ConnType icellT, ConnType icellS, - ConnType nbNodesT, ConnType nbNodesS) - { - double result = 0; - int orientation = 1; - - /*** Obtain the coordinates of T and S ***/ - std::vector CoordsT; - std::vector CoordsS; - PlanarIntersector::getRealCoordinates(icellT,icellS,nbNodesT,nbNodesS,CoordsT,CoordsS,orientation); - /*** Compute the intersection area ***/ - INTERP_KERNEL::PolygonAlgorithms P(_epsilon, PlanarIntersector::_precision); - std::deque inter = P.intersectConvexPolygons(&CoordsT[0], &CoordsS[0], - CoordsT.size()/SPACEDIM, CoordsS.size()/SPACEDIM); - double area[SPACEDIM]; - int nb_inter =((int)inter.size())/SPACEDIM; - for(int i = 1; i(&inter[0],&inter[SPACEDIM*i],&inter[SPACEDIM*(i+1)],area); - result +=0.5*norm(area); - } - - //DEBUG prints - if(PlanarIntersector::_print_level >= 3) - { - std::cout << std::endl << "Number of nodes of the intersection = "<< nb_inter << std::endl; - for(int i=0; i< nb_inter; i++) - {for (int idim=0; idim - class CurveIntersector : public TargetIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - CurveIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double adjustmentEpsAbs, double medianLine, int printLevel); - virtual ~CurveIntersector(); - void createBoundingBoxes(const MyMeshType& mesh, std::vector& bbox); - void adjustBoundingBoxes(std::vector& bbox, double adjustmentEpsAbs); - static void getElemBB(double* bb, const MyMeshType& mesh, ConnType iP, ConnType nb_nodes); - - protected : - bool getRealTargetCoordinates(ConnType icellT, std::vector& coordsT); - bool getRealSourceCoordinates(ConnType icellS, std::vector& coordsS); - double intersectSegments(double *Coords_T, double *Coords_S); - - struct TDualSegment - { - std::vector _coords; - int _nodeId; // in mesh mode - }; - static void getDualSegments(ConnType icell, - const MyMeshType& mesh, - std::vector& segments); - - protected: - const ConnType *_connectT; - const ConnType *_connectS; - const double *_coordsT; - const double *_coordsS; - const ConnType *_connIndexT; - const ConnType *_connIndexS; - const MyMeshType& _meshT; - const MyMeshType& _meshS; - double _tolerance; - double _precision; - double _median_line; - int _print_level; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersector.txx b/src/INTERP_KERNEL/CurveIntersector.txx deleted file mode 100644 index 7fb2be48f..000000000 --- a/src/INTERP_KERNEL/CurveIntersector.txx +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright (C) 2007-2010 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 __CURVEINTERSECTOR_TXX__ -#define __CURVEINTERSECTOR_TXX__ - -#include "CurveIntersector.hxx" -#include "InterpolationUtils.hxx" - -#include - -namespace INTERP_KERNEL -{ - template - CurveIntersector - ::CurveIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, double medianLine, int printLevel): - _meshT(meshT), - _meshS(meshS), - _tolerance(tolerance), - _precision(precision), - _median_line(medianLine), - _print_level(printLevel) - { - if ( SPACEDIM != 1 && SPACEDIM != 2 ) - throw Exception("CurveIntersector(): space dimension of mesh must be 1 or 2"); - if ( MESHDIM != 1 ) - throw Exception("CurveIntersector(): mesh dimension must be 1"); - - _connectT = meshT.getConnectivityPtr(); - _connectS = meshS.getConnectivityPtr(); - _connIndexT = meshT.getConnectivityIndexPtr(); - _connIndexS = meshS.getConnectivityIndexPtr(); - _coordsT = meshT.getCoordinatesPtr(); - _coordsS = meshS.getCoordinatesPtr(); - } - - template - CurveIntersector::~CurveIntersector() - { - } - - //================================================================================ - /*! - \brief creates the bounding boxes for all the cells of mesh \a mesh - - \param mesh structure pointing to the mesh - \param bbox vector containing the bounding boxes - */ - //================================================================================ - - template - void CurveIntersector::createBoundingBoxes (const MyMeshType& mesh, - std::vector& bbox) - { - long nbelems = mesh.getNumberOfElements(); - bbox.resize(2*SPACEDIM* nbelems); - const double* coords = mesh.getCoordinatesPtr(); - const ConnType* conn = mesh.getConnectivityPtr(); - const ConnType* conn_index = mesh.getConnectivityIndexPtr(); - int ibox=0; - for(long icell=0; icell::max(); - bbox[2*SPACEDIM*ibox+2*idim+1] = -std::numeric_limits::max(); - } - //updating the bounding box with each node of the element - for (int j=0; j - ::coo2C(conn[OTT::conn2C(conn_index[icell]+j)]); - for(int idim=0; idim x ) ? bbox[ibox*2*SPACEDIM + 2*idim+1] : x; - } - } - ibox++; - } - } - - //================================================================================ - /*! - Computes the bouding box of a given element. iP in numPol mode. - */ - //================================================================================ - - template - void CurveIntersector::getElemBB (double* bb, - const MyMeshType& mesh, - ConnType iP, - ConnType nb_nodes) - { - const double* coords = mesh.getCoordinatesPtr(); - const ConnType* conn_index = mesh.getConnectivityIndexPtr(); - const ConnType* conn = mesh.getConnectivityPtr(); - //initializing bounding box limits - for(int idim=0; idim::max(); - bb[2*idim+1] = -std::numeric_limits::max(); - } - - for (ConnType i=0; i::coo2C(conn[OTT::conn2C(conn_index[OTT::ind2C(iP)]+i)])); - for(int idim=0; idimbb[2*idim+1]) ? x : bb[2*idim+1]; - } - } - } - - //================================================================================ - /*! Readjusts a set of bounding boxes so that they are extended - in all dimensions for avoiding missing interesting intersections - - \param bbox vector containing the bounding boxes - */ - //================================================================================ - - template - void CurveIntersector::adjustBoundingBoxes (std::vector& bbox, - double adjustmentEpsAbs) - { - long size = bbox.size()/(2*SPACEDIM); - for (int i=0; i - bool CurveIntersector::getRealTargetCoordinates - (ConnType icellT, std::vector& coordsT) - { - int nbNodesT = _connIndexT[OTT::ind2C(icellT)+1] - - _connIndexT[OTT::ind2C(icellT)]; - coordsT.resize(SPACEDIM*nbNodesT); - for (ConnType iT=0; iT::coo2C(_connectT[OTT::conn2C(_connIndexT[OTT::ind2C(icellT)]+iT)])+idim]; - } - } - if ( nbNodesT > 2 ) - { - for(int idim=0; idim - bool CurveIntersector::getRealSourceCoordinates - (ConnType icellS, std::vector& coordsS) - { - int nbNodesS = _connIndexS[OTT::ind2C(icellS)+1] - - _connIndexS[OTT::ind2C(icellS)]; - coordsS.resize(SPACEDIM*nbNodesS); - for(ConnType iS=0; iS::coo2C(_connectS[OTT::conn2C(_connIndexS[OTT::ind2C(icellS)]+iS)])+idim]; - } - } - if ( nbNodesS > 2 ) - { - for(int idim=0; idim - void CurveIntersector::getDualSegments(ConnType icell, - const MyMeshType& mesh, - std::vector& segments) - { - // get coordinates of cell nodes - int nbNodes; - std::vector ncoords; - std::vector nodeIds; - { - const ConnType *connect = mesh.getConnectivityPtr(); - const ConnType *connIndex = mesh.getConnectivityIndexPtr(); - const double *coords = mesh.getCoordinatesPtr(); - - nbNodes = connIndex[icell+1] - connIndex[icell]; - - ncoords.resize(SPACEDIM*nbNodes); - nodeIds.resize(nbNodes); - - for(int i=0; i::conn2C(connIndex[OTT::ind2C(icell)]+i)]; - ncoords[SPACEDIM*i+idim] = coords[SPACEDIM*OTT::coo2C(nodeIds[i])+idim]; - } - if ( nbNodes > 2 ) // quadratic segment, put medium node in the middle - { - for(int idim=0; idim - double CurveIntersector::intersectSegments(double *Coords_T, - double *Coords_S) - { - double xt0 = Coords_T[0], xt1 = Coords_T[1]; - double xs0 = Coords_S[0], xs1 = Coords_S[1]; - if ( SPACEDIM == 2 ) - { - // Pass 2D->1D - - enum { X=0, Y }; - - // check if two segments overlap in 2D within tolerance - - double* t0 = Coords_T; - double* t1 = Coords_T + 2; - double t01[2] = { t1[X]-t0[X], t1[Y]-t0[Y] }; // tgt segment direction - double tSize = sqrt( t01[X]*t01[X] + t01[Y]*t01[Y] ); // tgt segment size - if ( tSize < _precision ) return 0; // degenerated segment - t01[X] /= tSize, t01[Y] /= tSize; // normalize t01 - - double* s0 = Coords_S; - double* s1 = Coords_S + 2; - double t0s0[2] = { s0[X]-t0[X], s0[Y]-t0[Y] }; - double t0s1[2] = { s1[X]-t0[X], s1[Y]-t0[Y] }; - double nt01_x_t0s0 = t0s0[X] * t01[Y] - t0s0[Y] * t01[X]; // t0s0 dot norm of t01 - double nt01_x_t0s1 = t0s1[X] * t01[Y] - t0s1[Y] * t01[X]; // t0s1 dot norm of t01 - double dist_ts0 = fabs( nt01_x_t0s0 ); // dist from tgt seg to s0 - double dist_ts1 = fabs( nt01_x_t0s1 ); // dist from tgt seg to s1 - bool s0_out_of_tol = ( dist_ts0 > _tolerance ); - bool s1_out_of_tol = ( dist_ts1 > _tolerance ); - if ( nt01_x_t0s0 * nt01_x_t0s1 > 0 && ( s0_out_of_tol || s1_out_of_tol )) - return 0; // tgt segment is to far from src segment - - double S0[2] = { s0[X], s0[Y] }; - double S1[2] = { s1[X], s1[Y] }; - if ( s0_out_of_tol ) // put s0 within tolerance - { - double t = _tolerance * nt01_x_t0s0 / dist_ts0; // signed tolerance - double r = ( nt01_x_t0s0 - t ) / ( nt01_x_t0s0 - nt01_x_t0s1 ); - S0[X] = s0[X] * ( 1.-r ) + s1[X] * r; - S0[Y] = s0[Y] * ( 1.-r ) + s1[Y] * r; - } - if ( s1_out_of_tol ) // put s1 within tolerance - { - double t = _tolerance * nt01_x_t0s1 / dist_ts1; // signed tolerance - double r = ( nt01_x_t0s1 - t ) / ( nt01_x_t0s1 - nt01_x_t0s0 ); - S1[X] = s1[X] * ( 1.-r ) + s0[X] * r; - S1[Y] = s1[Y] * ( 1.-r ) + s0[Y] * r; - } - - // project tgt and src segments to median line - - double s01[2] = { S1[X]-S0[X], S1[Y]-S0[Y] }; // src segment direction - double sSize = sqrt( s01[X]*s01[X] + s01[Y]*s01[Y] ); // src segment size - if ( sSize < _precision ) return 0; // degenerated segment - s01[X] /= sSize, s01[Y] /= sSize; // normalize s01 - - // make t01 and s01 codirected - double t01_x_s01 = t01[X] * s01[X] + t01[Y] * s01[Y]; // t01 dot s01 - if ( t01_x_s01 < 0 ) - s01[X] = -s01[X], s01[Y] = -s01[Y]; - - double medianDir[2] = { - t01[X] * ( 1.-_median_line) + s01[X] * _median_line, - t01[Y] * ( 1.-_median_line) + s01[Y] * _median_line - }; - double medianSize = sqrt( medianDir[X]*medianDir[X] + medianDir[Y]*medianDir[Y] ); - if ( medianSize < std::numeric_limits::min() ) - return 0; // strange... - medianDir[X] /= medianSize, medianDir[Y] /= medianSize; - - xt0 = t0[X] * medianDir[X] + t0[Y] * medianDir[Y]; - xt1 = t1[X] * medianDir[X] + t1[Y] * medianDir[Y]; - xs0 = S0[X] * medianDir[X] + S0[Y] * medianDir[Y]; - xs1 = S1[X] * medianDir[X] + S1[Y] * medianDir[Y]; - - } // if ( SPACEDIM == 2 ) - - if ( xt0 > xt1 ) std::swap( xt0, xt1 ); - if ( xs0 > xs1 ) std::swap( xs0, xs1 ); - - double x0 = std::max( xt0, xs0 ); - double x1 = std::min( xt1, xs1 ); - return ( x0 < x1 ) ? ( x1 - x0 ) : 0.; - } - -} - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx b/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx deleted file mode 100644 index 3ce6f6ff5..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2010 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 __CURVEINTERSECTORP0P0_HXX__ -#define __CURVEINTERSECTORP0P0_HXX__ - -#include "CurveIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class CurveIntersectorP0P0 : public CurveIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - - CurveIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, - double medianLine, int printLevel); - public: - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - void intersectCells(ConnType icellT, - const std::vector& icellsS, MyMatrix& res); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P0.txx b/src/INTERP_KERNEL/CurveIntersectorP0P0.txx deleted file mode 100644 index a72c1ecca..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP0P0.txx +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2007-2010 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 __CURVEINTERSECTORP0P0_TXX__ -#define __CURVEINTERSECTORP0P0_TXX__ - -#include "CurveIntersectorP0P0.hxx" -#include "CurveIntersector.txx" - -#define BASE_INTERSECTOR CurveIntersector - -namespace INTERP_KERNEL -{ - template - CurveIntersectorP0P0 - ::CurveIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, - double medianLine, int printLevel): - BASE_INTERSECTOR(meshT, meshS, precision, tolerance, medianLine, printLevel) - { - } - - template - int CurveIntersectorP0P0 - ::getNumberOfRowsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshT.getNumberOfElements(); - } - - template - int CurveIntersectorP0P0 - ::getNumberOfColsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshS.getNumberOfElements(); - } - - template - void CurveIntersectorP0P0 - ::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - typename MyMatrix::value_type& resRow = res[icellT]; - std::vector coordsT; - int t, nbSegT = 1 + BASE_INTERSECTOR::getRealTargetCoordinates(icellT,coordsT); - for ( t = 0; t < nbSegT; ++t ) - for(typename std::vector::const_iterator - iter=icellsS.begin(); iter!=icellsS.end(); iter++) - { - int iS = *iter; - std::vector coordsS; - int s, nbSegS = 1 + BASE_INTERSECTOR::getRealSourceCoordinates(iS,coordsS); - for ( s = 0; s < nbSegS; ++s ) - { - double surf = BASE_INTERSECTOR::intersectSegments(&coordsT[0] + t*SPACEDIM, - &coordsS[0] + s*SPACEDIM); - if(surf!=0.) - resRow.insert(std::make_pair(OTT::indFC(iS),surf)); - } - } - } -} -#undef BASE_INTERSECTOR - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx b/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx deleted file mode 100644 index 7d4b0cd0b..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2010 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 __CURVEINTERSECTORP0P1_HXX__ -#define __CURVEINTERSECTORP0P1_HXX__ - -#include "CurveIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class CurveIntersectorP0P1 : public CurveIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - - CurveIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, - double medianLine, int printLevel); - public: - void intersectCells(ConnType icellT, - const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P1.txx b/src/INTERP_KERNEL/CurveIntersectorP0P1.txx deleted file mode 100644 index 1947a9f5b..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP0P1.txx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2007-2010 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 __CurveIntersectorP0P1_TXX__ -#define __CurveIntersectorP0P1_TXX__ - -#include "CurveIntersectorP0P1.hxx" -#include "CurveIntersector.txx" - -#define BASE_INTERSECTOR CurveIntersector - -namespace INTERP_KERNEL -{ - template - CurveIntersectorP0P1 - ::CurveIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, - double medianLine, int printLevel): - BASE_INTERSECTOR(meshT, meshS, precision, tolerance, medianLine, printLevel) - { - } - - template - int CurveIntersectorP0P1 - ::getNumberOfRowsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshT.getNumberOfNodes(); - } - - template - int CurveIntersectorP0P1 - ::getNumberOfColsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshS.getNumberOfElements(); - } - - //================================================================================ - /*! - * \brief Project from segments to nodes - */ - //================================================================================ - - template - void CurveIntersectorP0P1 - ::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - std::vector segmentsT; - BASE_INTERSECTOR::getDualSegments( icellT, BASE_INTERSECTOR::_meshT, segmentsT); - for ( int t = 0; t < (int)segmentsT.size(); ++t ) - { - typename MyMatrix::value_type& resRow = res[ OTT::ind2C( segmentsT[t]._nodeId )]; - for(typename std::vector::const_iterator - iter=icellsS.begin(); iter!=icellsS.end(); iter++) - { - int iS = *iter; - std::vector coordsS; - int s, nbSegS = 1 + BASE_INTERSECTOR::getRealSourceCoordinates(iS,coordsS); - for ( s = 0; s < nbSegS; ++s ) - { - double surf = BASE_INTERSECTOR::intersectSegments(&segmentsT[t]._coords[0], - &coordsS[0] + s*SPACEDIM); - if(surf!=0.) - { - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(iS)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(iS),surf)); - else - { - surf+=(*iterRes).second; - resRow.erase(OTT::indFC(iS)); - resRow.insert(std::make_pair(OTT::indFC(iS),surf)); - } - } - } - } - } - } -} -#undef BASE_INTERSECTOR - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx b/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx deleted file mode 100644 index 914c28429..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __CURVEINTERSECTORP1P0_HXX__ -#define __CURVEINTERSECTORP1P0_HXX__ - -#include "CurveIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class CurveIntersectorP1P0 : public CurveIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - - CurveIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, double medianLine, int printLevel); - public: - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P0.txx b/src/INTERP_KERNEL/CurveIntersectorP1P0.txx deleted file mode 100644 index f4e136dd3..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP1P0.txx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2007-2010 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 __CurveIntersectorP1P0_TXX__ -#define __CurveIntersectorP1P0_TXX__ - -#include "CurveIntersectorP1P0.hxx" -#include "CurveIntersector.txx" - -#define BASE_INTERSECTOR CurveIntersector - -namespace INTERP_KERNEL -{ - template - CurveIntersectorP1P0 - ::CurveIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, - double medianLine, int printLevel): - BASE_INTERSECTOR (meshT, meshS, precision, tolerance, medianLine, printLevel) - { - } - - template - int CurveIntersectorP1P0 - ::getNumberOfRowsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshT.getNumberOfElements(); - } - - template - int CurveIntersectorP1P0 - ::getNumberOfColsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshS.getNumberOfNodes(); - } - - //================================================================================ - /*! - * \brief Project from source nodes to target segments - */ - //================================================================================ - - template - void CurveIntersectorP1P0 - ::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - typename MyMatrix::value_type& resRow = res[ icellT ]; - std::vector segmentsS; - std::vector coordsT; - int t, nbSegT = 1 + BASE_INTERSECTOR::getRealTargetCoordinates(icellT,coordsT); - for ( t = 0; t < nbSegT; ++t ) - for(typename std::vector::const_iterator - iter=icellsS.begin(); iter!=icellsS.end(); iter++) - { - int iS = *iter; - BASE_INTERSECTOR::getDualSegments( OTT::ind2C(iS), - BASE_INTERSECTOR::_meshS, segmentsS); - for ( int s = 0; s < (int)segmentsS.size(); ++s ) - { - double surf = BASE_INTERSECTOR::intersectSegments(&segmentsS[s]._coords[0], - &coordsT[0] + t*SPACEDIM); - if(surf!=0.) - { - int nS = segmentsS[s]._nodeId; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(nS); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(nS,surf)); - else - { - surf+=(*iterRes).second; - resRow.erase(nS); - resRow.insert(std::make_pair(nS,surf)); - } - } - } - } - } -} -#undef BASE_INTERSECTOR - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx b/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx deleted file mode 100644 index 1df986724..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2010 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 __CURVEINTERSECTORP1P1_HXX__ -#define __CURVEINTERSECTORP1P1_HXX__ - -#include "CurveIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class CurveIntersectorP1P1 : public CurveIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - - CurveIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, - double medianLine, int printLevel); - public: - void intersectCells(ConnType icellT, - const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1.txx b/src/INTERP_KERNEL/CurveIntersectorP1P1.txx deleted file mode 100644 index 7be7429bb..000000000 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1.txx +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007-2010 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 __CurveIntersectorP1P1_TXX__ -#define __CurveIntersectorP1P1_TXX__ - -#include "CurveIntersectorP1P1.hxx" -#include "CurveIntersector.txx" - -#define BASE_INTERSECTOR CurveIntersector - -namespace INTERP_KERNEL -{ - template - CurveIntersectorP1P1 - ::CurveIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, - double precision, double tolerance, - double medianLine, int printLevel): - BASE_INTERSECTOR (meshT, meshS, precision, tolerance, medianLine, printLevel) - { - } - - template - int CurveIntersectorP1P1 - ::getNumberOfRowsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshT.getNumberOfNodes(); - } - - template - int CurveIntersectorP1P1 - ::getNumberOfColsOfResMatrix() const - { - return BASE_INTERSECTOR::_meshS.getNumberOfNodes(); - } - - template - void CurveIntersectorP1P1 - ::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - std::vector segmentsT, segmentsS; - BASE_INTERSECTOR::getDualSegments( icellT, BASE_INTERSECTOR::_meshT, segmentsT); - for ( int t = 0; t < (int)segmentsT.size(); ++t ) - { - typename MyMatrix::value_type& resRow = res[ OTT::ind2C( segmentsT[t]._nodeId )]; - for(typename std::vector::const_iterator - iter=icellsS.begin(); iter!=icellsS.end(); iter++) - { - int iS = *iter; - BASE_INTERSECTOR::getDualSegments( OTT::ind2C(iS), - BASE_INTERSECTOR::_meshS, segmentsS); - for ( int s = 0; s < (int)segmentsS.size(); ++s ) - { - double surf = BASE_INTERSECTOR::intersectSegments(&segmentsT[t]._coords[0], - &segmentsS[s]._coords[0]); - if(surf!=0.) - { - int nS = segmentsS[s]._nodeId; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(nS); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(nS,surf)); - else - { - surf+=(*iterRes).second; - resRow.erase(nS); - resRow.insert(std::make_pair(nS,surf)); - } - } - } - } - } - } -} -#undef BASE_INTERSECTOR - -#endif diff --git a/src/INTERP_KERNEL/DirectedBoundingBox.cxx b/src/INTERP_KERNEL/DirectedBoundingBox.cxx deleted file mode 100644 index b59f78db6..000000000 --- a/src/INTERP_KERNEL/DirectedBoundingBox.cxx +++ /dev/null @@ -1,753 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : DirectedBoundingBox.cxx -// Created : Mon Apr 12 14:41:22 2010 -// Author : Edward AGAPOV (eap) - -#include "DirectedBoundingBox.hxx" - -#include "InterpolationUtils.hxx" - -#define __TENSOR(i,j) tensor[(i)*_dim+(j)] -#define __AXIS(i) (&_axes[(i)*_dim]) -#define __MIN(i) _minmax[i*2] -#define __MAX(i) _minmax[i*2+1] -#define __MYID (long(this)%10000) -#define __DMP(msg) \ - // cout << msg << endl - -using namespace std; - -namespace -{ - //================================================================================ - /*! - * \brief Add point coordinates to inertia tensor in 3D space - */ - //================================================================================ - - inline void addPointToInertiaTensor3D(const double* coord, - const double* gc, - vector& tensor) - { - // we fill the upper triangle of tensor only - const int _dim = 3; - double x = coord[0] - gc[0], y = coord[1] - gc[1], z = coord[2] - gc[2]; - __TENSOR(0,0) += y*y + z*z; - __TENSOR(1,1) += x*x + z*z; - __TENSOR(2,2) += x*x + y*y; - __TENSOR(0,1) -= x*y; - __TENSOR(0,2) -= x*z; - __TENSOR(1,2) -= y*z; - } - //================================================================================ - /*! - * \brief Add point coordinates to inertia tensor in 2D space - */ - //================================================================================ - - inline void addPointToInertiaTensor2D(const double* coord, - const double* gc, - vector& tensor) - { - // we fill the upper triangle of tensor only - const int _dim = 2; - double x = coord[0] - gc[0], y = coord[1] - gc[1]; - __TENSOR(0,0) += y*y; - __TENSOR(1,1) += x*x; - __TENSOR(0,1) -= x*y; - } - - //================================================================================ - /*! - * \brief Find eigenvectors of tensor using Jacobi's method - */ - //================================================================================ - - bool JacobiEigenvectorsSearch( const int _dim, vector& tensor, vector& _axes) - { - if ( _dim == 3 ) - __DMP( "Tensor : {" - << "{ "<<__TENSOR(0,0) << ", "<<__TENSOR(0,1) << ", "<<__TENSOR(0,2) << "} " - << "{ "<<__TENSOR(1,0) << ", "<<__TENSOR(1,1) << ", "<<__TENSOR(1,2) << "} " - << "{ "<<__TENSOR(2,0) << ", "<<__TENSOR(2,1) << ", "<<__TENSOR(2,2) << "}} "); - else - __DMP( "Tensor : {" - << "{ "<<__TENSOR(0,0) << ", "<<__TENSOR(0,1) << "} " - << "{ "<<__TENSOR(1,0) << ", "<<__TENSOR(1,1) << "}} "); - - const int maxRot = 5*_dim*_dim; // limit on number of rotations - const double tol = 1e-9; - - // set _axes to identity - int i,j; - for ( i = 0; i < _dim; ++i ) - for ( j = 0; j < _dim; ++j ) - __AXIS(i)[j] = ( i==j ? 1. : 0 ); - - bool solved = false; - for ( int iRot = 0; iRot < maxRot; ++ iRot ) - { - // find max off-diagonal element of the tensor - int k = 0, l = 0; - double max = 0.; - for ( i = 0; i < _dim-1; ++i ) - for ( j = i+1; j < _dim; ++j ) - if ( fabs( __TENSOR(i,j)) > max ) - max = fabs( __TENSOR(i,j) ), k = i, l = j; - solved = ( max < tol ); - if ( solved ) - break; - - // Rotate to make __TENSOR(k,l) == 0 - - double diff = __TENSOR(l,l) - __TENSOR(k,k); - double t; // tangent of rotation angle - if ( fabs(__TENSOR(k,l)) < abs(diff)*1.0e-36) - { - t = __TENSOR(k,l)/diff; - } - else - { - double phi = diff/(2.0*__TENSOR(k,l)); - t = 1.0/(abs(phi) + sqrt(phi*phi + 1.0)); - if ( phi < 0.0) t = -t; - } - double c = 1.0/sqrt(t*t + 1.0); // cosine of rotation angle - double s = t*c; // sine of rotation angle - double tau = s/(1.0 + c); - __TENSOR(k,k) -= t*__TENSOR(k,l); - __TENSOR(l,l) += t*__TENSOR(k,l); - __TENSOR(k,l) = 0.0; - -#define __ROTATE(T,r1,c1,r2,c2) \ -{ \ -int i1 = r1*_dim+c1, i2 = r2*_dim+c2; \ -double t1 = T[i1], t2 = T[i2]; \ -T[i1] -= s * ( t2 + tau * t1);\ -T[i2] += s * ( t1 - tau * t2);\ -} - for ( i = 0; i < k; ++i ) // Case of i < k - __ROTATE(tensor, i,k,i,l); - - for ( i = k+1; i < l; ++i ) // Case of k < i < l - __ROTATE(tensor, k,i,i,l); - - for ( i = l + 1; i < _dim; ++i ) // Case of i > l - __ROTATE(tensor, k,i,l,i); - - for ( i = 0; i < _dim; ++i ) // Update transformation matrix - __ROTATE(_axes, i,k,i,l); - } - - __DMP( "Solved = " << solved ); - if ( _dim == 3 ) { - __DMP( " Eigen " << __TENSOR(0,0)<<", "<<__TENSOR(1,1)<<", "<<__TENSOR(2,2) ); - for ( int i=0; i <3; ++i ) - __DMP( i << ": " << __AXIS(i)[0] << ", " << __AXIS(i)[1] << ", " << __AXIS(i)[2] ); - } - else { - __DMP( " Eigen " << __TENSOR(0,0) << ", " << __TENSOR(1,1) ); - for ( int i=0; i <2; ++i ) - __DMP( i << ": " << __AXIS(i)[0] << ", " << __AXIS(i)[1] ); - } - - return solved; - } - - //================================================================================ - /*! - * \brief Return true if two minmaxes do not intersect - */ - //================================================================================ - - inline bool isMinMaxOut(const double* minmax1, - const double* minmax2, - int dim) - { - for ( int i = 0; i < dim; ++i ) - { - if ( minmax1[i*2] > minmax2[i*2+1] || - minmax1[i*2+1] < minmax2[i*2] ) - return true; - } - return false; - } - -} // noname namespace - -namespace INTERP_KERNEL -{ - - //================================================================================ - /*! - * \brief Creates empty box intended to further initalization via setData() - */ - //================================================================================ - - DirectedBoundingBox::DirectedBoundingBox():_dim(0) - { - } - - //================================================================================ - /*! - * \brief Creates bounding box of a mesh - * \param pts - coordinates of points in full interlace - * \param numPts - number of points in the mesh - * \param dim - space dimension - */ - //================================================================================ - - DirectedBoundingBox::DirectedBoundingBox(const double* pts, - const unsigned numPts, - const unsigned dim) - : _dim(dim), _axes(dim*dim), _minmax(2*dim) - { - // init box extremities - for ( unsigned i = 0; i < _dim; ++i ) - _minmax[1+i*2] = -numeric_limits::max(), - _minmax[i*2] = numeric_limits::max(); - - if ( numPts < 1 ) return; - - __DMP( "DirectedBoundingBox " << __MYID ); - - const double* coord = pts; - const double* coordEnd = coord + numPts * dim; - - // compute gravity center of points - double gc[3] = {0,0,0}; - if ( dim > 1 ) - { - for ( coord = pts; coord < coordEnd; ) - for ( int i = 0; i < (int)dim; ++i ) - gc[i] += *coord++; - for ( int j = 0; j < (int)dim; ++j ) - gc[j] /= numPts; - - } - - // compute axes and box extremities - vector tensor( dim * dim, 0.); - switch ( dim ) - { - case 3: - for ( coord = pts; coord < coordEnd; coord += dim ) - addPointToInertiaTensor3D( coord, gc, tensor ); - - //computeAxes3D(tensor); - JacobiEigenvectorsSearch(_dim, tensor, _axes); - - for ( coord = pts; coord < coordEnd; coord += dim ) - addPointToBox( coord ); - - break; - - case 2: - for ( coord = pts; coord < coordEnd; coord += dim ) - addPointToInertiaTensor2D( coord, gc, tensor ); - - //computeAxes2D(tensor); - JacobiEigenvectorsSearch(_dim, tensor, _axes); - - for ( coord = pts; coord < coordEnd; coord += dim ) - addPointToBox( coord ); - - break; - - default: - for ( coord = pts; coord < coordEnd; coord += dim ) - { - if ( *coord < _minmax[0] ) _minmax[0] = *coord; - if ( *coord > _minmax[1] ) _minmax[1] = *coord; - } - } - } - - //================================================================================ - /*! - * \brief Creates bounding box of an element - * \param pts - coordinates of points of element - * \param numPts - number of points in the element - * \param dim - space dimension - */ - //================================================================================ - - DirectedBoundingBox::DirectedBoundingBox(const double** pts, - const unsigned numPts, - const unsigned dim) - : _dim(dim), _axes(dim*dim), _minmax(2*dim) - { - // init box extremities - for ( unsigned i = 0; i < _dim; ++i ) - _minmax[1+i*2] = -numeric_limits::max(), - _minmax[i*2] = numeric_limits::max(); - - if ( numPts < 1 ) return; - - __DMP( "DirectedBoundingBox " << __MYID ); - - // compute gravity center of points - double gc[3] = {0,0,0}; - if ( dim > 1 ) - { - for ( unsigned i = 0; i < numPts; ++i ) - for ( int j = 0; j < (int)dim; ++j ) - gc[j] += pts[i][j]; - for ( int j = 0; j < (int)dim; ++j ) - gc[j] /= numPts; - } - - // compute axes and box extremities - vector tensor( dim * dim, 0.); - switch ( dim ) - { - case 3: - for ( unsigned i = 0; i < numPts; ++i ) - addPointToInertiaTensor3D( pts[i], gc, tensor ); - - //computeAxes3D(tensor); - JacobiEigenvectorsSearch(_dim, tensor, _axes); - - for ( unsigned i = 0; i < numPts; ++i ) - addPointToBox( pts[i] ); - - break; - case 2: - for ( unsigned i = 0; i < numPts; ++i ) - addPointToInertiaTensor2D( pts[i], gc, tensor ); - - //computeAxes2D(tensor); - JacobiEigenvectorsSearch(_dim, tensor, _axes); - - for ( unsigned i = 0; i < numPts; ++i ) - addPointToBox( pts[i] ); - - break; - default: - for ( unsigned i = 0; i < numPts; ++i ) - { - if ( pts[i][0] < _minmax[0] ) _minmax[0] = pts[i][0]; - if ( pts[i][0] > _minmax[1] ) _minmax[1] = pts[i][0]; - } - _axes[0] = 1.0; - } - } - - //================================================================================ - /*! - * \brief Compute eigenvectors of inertia tensor - */ - //================================================================================ - - // void DirectedBoundingBox::computeAxes3D(const std::vector& tensor) -// { -// // compute principal moments of inertia which are eigenvalues of the tensor -// double eig[3]; -// { -// // coefficients of polynomial equation det(tensor-eig*I) = 0 -// double a = -1; -// double b = __TENSOR(0,0)+__TENSOR(1,1)+__TENSOR(2,2); -// double c = -// __TENSOR(0,1)*__TENSOR(0,1) + -// __TENSOR(0,2)*__TENSOR(0,2) + -// __TENSOR(1,2)*__TENSOR(1,2) - -// __TENSOR(0,0)*__TENSOR(1,1) - -// __TENSOR(0,0)*__TENSOR(2,2) - -// __TENSOR(1,1)*__TENSOR(2,2); -// double d = -// __TENSOR(0,0)*__TENSOR(1,1)*__TENSOR(2,2) - -// __TENSOR(0,0)*__TENSOR(1,2)*__TENSOR(1,2) - -// __TENSOR(1,1)*__TENSOR(0,2)*__TENSOR(0,2) - -// __TENSOR(2,2)*__TENSOR(0,1)*__TENSOR(0,1) + -// __TENSOR(0,1)*__TENSOR(0,2)*__TENSOR(1,2)*2; - -// // find eigenvalues which are roots of characteristic polynomial -// double x = (3*c/a - b*b/(a*a))/3; -// double y = (2*b*b*b/(a*a*a) - 9*b*c/(a*a) + 27*d/a)/27; -// double z = y*y/4 + x*x*x/27; - -// double i = sqrt(y*y/4 - z) + 1e-300; -// double j = -pow(i,1/3.); -// double y2 = -y/(2*i); -// if ( y2 > 1.0) y2 = 1.; else if ( y2 < -1.0) y2 = -1.; -// double k = acos(y2); -// double m = cos(k/3); -// double n = sqrt(3)*sin(k/3); -// double p = -b/(3*a); - -// eig[0] = -2*j*m + p; -// eig[1] = j *(m + n) + p; -// eig[2] = j *(m - n) + p; -// } -// // compute eigenvector of the tensor at each eigenvalue -// // by solving system [tensor-eig*I]*[axis] = 0 -// bool ok = true; -// __DMP( "Tensor : {" -// << "{ "<<__TENSOR(0,0) << ", "<<__TENSOR(0,1) << ", "<<__TENSOR(0,2) << "} " -// << "{ "<<__TENSOR(1,0) << ", "<<__TENSOR(1,1) << ", "<<__TENSOR(1,2) << "} " -// << "{ "<<__TENSOR(2,0) << ", "<<__TENSOR(2,1) << ", "<<__TENSOR(2,2) << "}} "); -// for ( int i = 0; i < 3 && ok; ++i ) // loop on 3 eigenvalues -// { -// // [tensor-eig*I] -// double T[3][3]= -// {{ __TENSOR(0,0)-eig[i],__TENSOR(0,1), __TENSOR(0,2), }, -// { __TENSOR(0,1), __TENSOR(1,1)-eig[i],__TENSOR(1,2), }, -// { __TENSOR(0,2), __TENSOR(1,2), __TENSOR(2,2)-eig[i]}}; -// // The determinant of T is zero, so that the equations are not linearly independent. -// // Therefore, we assign an arbitrary value (1.) to i-th component of eigenvector -// // and use two of the equations to compute the other two components -// double M[2][3], sol[2]; -// for ( int j = 0, c = 0; j < 3; ++j ) -// if ( i == j ) -// M[0][2] = -T[0][j], M[1][2] = -T[1][j]; -// else -// M[0][c] = T[0][j], M[1][c] = T[1][j], c++; - -// ok = solveSystemOfEquations<2>( M, sol ); - -// double* eigenVec = __AXIS(i); -// for ( int j = 0, c = 0; j < 3; ++j ) -// eigenVec[j] = ( i == j ) ? 1. : sol[c++]; - -// // normilize -// double size = sqrt(eigenVec[0]*eigenVec[0] + -// eigenVec[1]*eigenVec[1] + -// eigenVec[2]*eigenVec[2] ); -// if ((ok = (size > numeric_limits::min() ))) -// { -// eigenVec[0] /= size; -// eigenVec[1] /= size; -// eigenVec[2] /= size; -// } -// } -// if ( !ok ) -// { -// __DMP( " solve3EquationSystem() - KO " ); -// _axes = vector( _dim*_dim, 0); -// __AXIS(0)[0] = __AXIS(1)[1] = __AXIS(2)[2] = 1.; -// } -// __DMP( " Eigen " << eig[0] << ", " << eig[1] << ", " << eig[2] ); -// for ( int i=0; i <3; ++i ) -// __DMP( i << ": " << __AXIS(i)[0] << ", " << __AXIS(i)[1] << ", " << __AXIS(i)[2] ); - -// double* a0 = __AXIS(0), *a1 = __AXIS(1); -// double cross[3] = { a0[1]*a1[2]-a1[1]*a0[2], -// a0[2]*a1[0]-a1[2]*a0[0], -// a0[0]*a1[1]-a1[0]*a0[1] }; -// __DMP( " Cross a1^a2 " << cross[0] << ", " << cross[1] << ", " << cross[2] ); -// } - - //================================================================================ - /*! - * \brief Compute eigenvectors of inertia tensor - */ - //================================================================================ - - // void DirectedBoundingBox::computeAxes2D(const std::vector& tensor) -// { -// // compute principal moments of inertia which are eigenvalues of the tensor -// // by solving square equation det(tensor-eig*I) -// double X = (__TENSOR(0,0)+__TENSOR(1,1))/2; -// double Y = sqrt(4*__TENSOR(0,1)*__TENSOR(0,1) + -// (__TENSOR(0,0)-__TENSOR(1,1)) * (__TENSOR(0,0)-__TENSOR(1,1)))/2; -// double eig[2] = -// { -// X + Y, -// X - Y -// }; -// // compute eigenvector of the tensor at each eigenvalue -// // by solving system [tensor-eig*I]*[axis] = 0 -// bool ok = true; -// for ( int i = 0; i < 2 && ok; ++i ) -// { -// // [tensor-eig*I] -// double T[2][2]= -// {{ __TENSOR(0,0)-eig[i],__TENSOR(0,1) }, -// { __TENSOR(0,1), __TENSOR(1,1)-eig[i] }}; - -// // The determinant of T is zero, so that the equations are not linearly independent. -// // Therefore, we assign an arbitrary value (1.) to i-th component of eigenvector -// // and use one equation to compute the other component -// double* eigenVec = __AXIS(i); -// eigenVec[i] = 1.; -// int j = 1-i; -// if ((ok = ( fabs( T[j][j] ) > numeric_limits::min() ))) -// eigenVec[j] = -T[j][i] / T[j][j]; -// } -// if ( !ok ) -// { -// _axes = vector( _dim*_dim, 0); -// __AXIS(0)[0] = __AXIS(1)[1] = 1.; -// } -// } - - //================================================================================ - /*! - * \brief Convert point coordinates into local coordinate system of the box - */ - //================================================================================ - - void DirectedBoundingBox::toLocalCS(const double* p, double* pLoc) const - { - switch ( _dim ) - { - case 3: - pLoc[0] = dotprod<3>( p, __AXIS(0)); - pLoc[1] = dotprod<3>( p, __AXIS(1)); - pLoc[2] = dotprod<3>( p, __AXIS(2)); - break; - case 2: - pLoc[0] = dotprod<2>( p, __AXIS(0)); - pLoc[1] = dotprod<2>( p, __AXIS(1)); - break; - default: - pLoc[0] = p[0]; - } - } - - //================================================================================ - /*! - * \brief Convert point coordinates from local coordinate system of the box to global CS - */ - //================================================================================ - - void DirectedBoundingBox::fromLocalCS(const double* p, double* pGlob) const - { - switch ( _dim ) - { - case 3: - pGlob[0] = p[0] * __AXIS(0)[0] + p[1] * __AXIS(1)[0] + p[2] * __AXIS(2)[0]; - pGlob[1] = p[0] * __AXIS(0)[1] + p[1] * __AXIS(1)[1] + p[2] * __AXIS(2)[1]; - pGlob[2] = p[0] * __AXIS(0)[2] + p[1] * __AXIS(1)[2] + p[2] * __AXIS(2)[2]; - break; - case 2: - pGlob[0] = p[0] * __AXIS(0)[0] + p[1] * __AXIS(1)[0]; - pGlob[1] = p[0] * __AXIS(0)[1] + p[1] * __AXIS(1)[1]; - break; - default: - pGlob[0] = p[0]; - } - } - - //================================================================================ - /*! - * \brief Enlarge box size by given value - */ - //================================================================================ - - void DirectedBoundingBox::enlarge(const double tol) - { - for ( unsigned i = 0; i < _dim; ++i ) - __MIN(i) -= tol, __MAX(i) += tol; - } - - //================================================================================ - /*! - * \brief Return coordinates of corners of bounding box - */ - //================================================================================ - - void DirectedBoundingBox::getCorners(std::vector& corners, - const double* minmax) const - { - int iC, nbCorners = 1; - for ( int i=0;i<(int)_dim;++i ) nbCorners *= 2; - corners.resize( nbCorners * _dim ); - // each coordinate is filled with either min or max, nbSwap is number of corners - // after which min and max swap - int nbSwap = nbCorners/2; - for ( unsigned i = 0; i < _dim; ++i ) - { - iC = 0; - while ( iC < nbCorners ) - { - for (int j = 0; j < nbSwap; ++j, ++iC ) corners[iC*_dim+i] = minmax[i*2]; - for (int j = 0; j < nbSwap; ++j, ++iC ) corners[iC*_dim+i] = minmax[i*2+1]; - } - nbSwap /= 2; - } - } - - //================================================================================ - /*! - * \brief Test if this box intersects with the other - * \retval bool - true if there is no intersection - */ - //================================================================================ - - bool DirectedBoundingBox::isDisjointWith(const DirectedBoundingBox& box) const - { - if ( _dim < 1 || box._dim < 1 ) return false; // empty box includes all - if ( _dim == 1 ) - return isMinMaxOut( &box._minmax[0], &this->_minmax[0], _dim ); - - // boxes are disjoined if their minmaxes in local CS of either of boxes do not intersect - for ( int isThisCS = 0; isThisCS < 2; ++isThisCS ) - { - const DirectedBoundingBox* axisBox = isThisCS ? this : &box; - const DirectedBoundingBox* cornerBox = isThisCS ? &box : this; - - // find minmax of cornerBox in the CS of axisBox - - DirectedBoundingBox mmBox((double*)0,0,_dim); //!< empty box with CS == axisBox->_axes - mmBox._axes = axisBox->_axes; - - vector corners; - getCorners( corners, &cornerBox->_minmax[0] ); - - double globCorner[3]; - for ( int iC = 0, nC = corners.size()/_dim; iC < nC; ++iC) - { - cornerBox->fromLocalCS( &corners[iC*_dim], globCorner ); - mmBox.addPointToBox( globCorner ); - } - if ( isMinMaxOut( &mmBox._minmax[0], &axisBox->_minmax[0], _dim )) - return true; - } - return false; - } - - //================================================================================ - /*! - * \brief Test if this box intersects with an non-directed box - * \retval bool - true if there is no intersection - */ - //================================================================================ - - bool DirectedBoundingBox::isDisjointWith(const double* box) const - { - if ( _dim < 1 ) return false; // empty box includes all - if ( _dim == 1 ) - return isMinMaxOut( &_minmax[0], box, _dim ); - - // boxes are disjoined if their minmaxes in local CS of either of boxes do not intersect - - // compare minmaxes in locals CS of this directed box - { - vector cornersOther; - getCorners( cornersOther, box ); - DirectedBoundingBox mmBox((double*)0,0,_dim); //!< empty box with CS == this->_axes - mmBox._axes = this->_axes; - for ( int iC = 0, nC = cornersOther.size()/_dim; iC < nC; ++iC) - mmBox.addPointToBox( &cornersOther[iC*_dim] ); - - if ( isMinMaxOut( &mmBox._minmax[0], &this->_minmax[0], _dim )) - return true; - } - - // compare minmaxes in global CS - { - vector cornersThis; - getCorners( cornersThis, &_minmax[0] ); - DirectedBoundingBox mmBox((double*)0,0,_dim); //!< initailized _minmax - double globCorner[3]; - for ( int iC = 0, nC = cornersThis.size()/_dim; iC < nC; ++iC) - { - fromLocalCS( &cornersThis[iC*_dim], globCorner ); - for ( int i = 0; i < (int)_dim; ++i ) - { - if ( globCorner[i] < mmBox._minmax[i*2] ) mmBox._minmax[i*2] = globCorner[i]; - if ( globCorner[i] > mmBox._minmax[i*2+1] ) mmBox._minmax[i*2+1] = globCorner[i]; - } - } - if ( isMinMaxOut( &mmBox._minmax[0], box, _dim )) - return true; - } - return false; - } - - //================================================================================ - /*! - * \brief Return true if given point is out of this box - */ - //================================================================================ - - bool DirectedBoundingBox::isOut(const double* point) const - { - if ( _dim < 1 ) return false; // empty box includes all - - double pLoc[3]; - toLocalCS( point, pLoc ); - bool out = isLocalOut( pLoc ); -#ifdef _DEBUG_ - switch (_dim) - { - case 3: - __DMP(__MYID<<": "< DirectedBoundingBox::getData() const - { - vector data(1, _dim); - if ( _dim > 0 ) - { - data.insert( data.end(), &_axes[0], &_axes[0] + _axes.size()); - data.insert( data.end(), &_minmax[0], &_minmax[0] + _minmax.size()); - } - if ( data.size() < (unsigned)dataSize( _dim )) - data.resize( dataSize( _dim ), 0 ); - return data; - } - - //================================================================================ - /*! - * \brief Initializes self with data retrieved via getData() - */ - //================================================================================ - - void DirectedBoundingBox::setData(const double* data) - { - _dim = unsigned( *data++ ); - if ( _dim > 0 ) - { - _axes.assign( data, data+_dim*_dim ); data += _dim*_dim; - _minmax.assign( data, data+2*_dim ); - } - else - { - _axes.clear(); - _minmax.clear(); - } - } - - //================================================================================ - /*! - * \brief Return size of internal data returned by getData() depending on space dim - */ - //================================================================================ - - int DirectedBoundingBox::dataSize(int dim) - { - return 1 + dim*dim + 2*dim; // : _dim + _axes + _minmax - } -} diff --git a/src/INTERP_KERNEL/DirectedBoundingBox.hxx b/src/INTERP_KERNEL/DirectedBoundingBox.hxx deleted file mode 100644 index 344f65909..000000000 --- a/src/INTERP_KERNEL/DirectedBoundingBox.hxx +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 __DIRECTEDBOUNDINGBOX_HXX__ -#define __DIRECTEDBOUNDINGBOX_HXX__ - -#include "INTERPKERNELDefines.hxx" - -#include - -namespace INTERP_KERNEL -{ - - /** - * \brief Class representing the bounding box of a number of points - * with box axes parallel to principal axes of inertia of points - */ - class INTERPKERNEL_EXPORT DirectedBoundingBox - { - public: - - DirectedBoundingBox(); - - DirectedBoundingBox(const double* pts, const unsigned numPts, const unsigned dim); - - DirectedBoundingBox(const double** pts, const unsigned numPts, const unsigned dim); - - //~DirectedBoundingBox(); - - void enlarge(const double tol); - - bool isDisjointWith(const DirectedBoundingBox& box) const; - - bool isDisjointWith(const double* box) const; - - bool isOut(const double* point) const; - - - // return internal data - std::vector getData() const; - - // initialize with data returned by getData() - void setData(const double* data); - - // return size of internal data - static int dataSize(int dim); - - private: - - //void computeAxes3D(const std::vector& tensor); - - //void computeAxes2D(const std::vector& tensor); - - inline void addPointToBox(const double* coord); - - void toLocalCS(const double* p, double* pLoc) const; - - void fromLocalCS(const double* p, double* pGlob) const; - - inline bool isLocalOut(const double* pLoc) const; - - void getCorners(std::vector& corners, const double* minmax) const; - - unsigned _dim; - - std::vector _axes; //!< principal axes of inertia in full interlace - std::vector _minmax; //!< pairs of min an max coordinates along the axes - - }; - - //================================================================================ - /*! - * \brief Test point in local CS against box extremities - * - */ - //================================================================================ - - inline bool DirectedBoundingBox::isLocalOut(const double* pLoc) const - { - for ( int i = 0; i < (int)_dim; ++i ) - if ( pLoc[i] < _minmax[i*2] || pLoc[i] > _minmax[i*2+1] ) - return true; - return false; - } - - //================================================================================ - /*! - * \brief Update box extremities - */ - //================================================================================ - - inline void DirectedBoundingBox::addPointToBox(const double* coord) - { - for ( int i = 0; i < (int)_dim; ++i ) - { - double c = 0; - for ( int j = 0; j < (int)_dim; ++j ) c += coord[j]*_axes[i*_dim+j]; - if ( c < _minmax[i*2] ) _minmax[i*2] = c; - if ( c > _minmax[i*2+1] ) _minmax[i*2+1] = c; - } - } -} -#endif diff --git a/src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx b/src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx deleted file mode 100644 index 8dbfa17f8..000000000 --- a/src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELEXPREVALDEFINES_HXX__ -#define __INTERPKERNELEXPREVALDEFINES_HXX__ - -//export symbols -// #ifdef WIN32 -// # if defined INTERPKERNELEXPREVAL_EXPORTS || defined interpkernelexpreval_EXPORTS -// # define INTERPKERNELEXPREVAL_EXPORT __declspec(dllexport) -// # else -// # define INTERPKERNELEXPREVAL_EXPORT __declspec(dllimport) -// # endif -// #else -// # define INTERPKERNELEXPREVAL_EXPORT -// #endif - -#define INTERPKERNELEXPREVAL_EXPORT - -#ifdef WNT -#pragma warning( disable : 4290 ) // See http://msdn.microsoft.com/en-us/library/sa28fef8%28VS.80%29.aspx -#endif - - -#endif diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx deleted file mode 100644 index ee7116fd2..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelAsmX86.hxx" - -#include -#include -#include - -const char *INTERP_KERNEL::AsmX86::OPS[NB_OF_OPS]={"mov","push","pop","fld","faddp","fsubp","fmulp","fdivp","fcos","fsin","fabs","fchs","fsqrt","sub","add","ret","leave","movsd","fst"}; - -std::vector INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - std::vector ret; - for(std::vector::const_iterator iter=asmb.begin();iter!=asmb.end();iter++) - convertOneInstructionInML(*iter,ret); - return ret; -} - -char *INTERP_KERNEL::AsmX86::convertMachineLangageInBasic(const std::vector& ml, int& lgth) const -{ - lgth=ml.size(); - char *ret=new char[lgth]; - std::copy(ml.begin(),ml.end(),ret); - return ret; -} - -void INTERP_KERNEL::AsmX86::convertOneInstructionInML(const std::string& inst, std::vector& ml) const throw(INTERP_KERNEL::Exception) -{ - std::string::size_type pos=inst.find_first_of(' '); - std::string op; - std::string param; - if(pos!=std::string::npos) - { - op=inst.substr(0,pos); - param=inst.substr(pos+1); - } - else - op=inst; - int id=0; - for(const char **it=OPS;it!=OPS+NB_OF_OPS;it++,id++) - { - std::string tmp(*it); - if(op==tmp) - break; - } - switch(id) - { - case 0: - convertMov(param,ml); - break; - case 1: - convertPush(param,ml); - break; - case 2: - convertPop(param,ml); - break; - case 3: - convertFld(param,ml); - break; - case 4: - convertFaddp(param,ml); - break; - case 5: - convertFsubp(param,ml); - break; - case 6: - convertFmulp(param,ml); - break; - case 7: - convertFdivp(param,ml); - break; - case 8: - convertFcos(param,ml); - break; - case 9: - convertFsin(param,ml); - break; - case 10: - convertFabs(param,ml); - break; - case 11: - convertFchs(param,ml); - break; - case 12: - convertFsqrt(param,ml); - break; - case 13: - convertSub(param,ml); - break; - case 14: - convertAdd(param,ml); - break; - case 15: - convertRet(param,ml); - break; - case 16: - convertLeave(param,ml); - break; - case 17: - convertMovsd(param,ml); - break; - case 18: - convertFst(param,ml); - break; - default: - { - std::ostringstream oss; oss << "Unrecognized op : " << op << " in assembly line : " << inst; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } -} - -#include - -void INTERP_KERNEL::AsmX86::convertMov(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ASM1[]="ebp,esp"; - const char ML1[2]={0x89,0xe5}; - if(inst==ASM1) - { - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - return ; - } - const char ASM2[]="rbp,rsp"; - const char ML2[3]={0x48,0x89,0xe5}; - if(inst==ASM2) - { - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - return ; - } - std::string::size_type pos=inst.find_first_of(' '); - if(pos==std::string::npos) - { - std::ostringstream oss; oss << "not recognized instruction mov : " << inst; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - std::string inst2=inst.substr(pos+1); - pos=inst2.find_first_of(','); - if(pos==std::string::npos) - { - std::ostringstream oss; oss << "not recognized instruction mov : " << inst; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - std::string inst3=inst2.substr(0,pos); - std::string inst4=inst2.substr(pos+1); - convertMovToEsp(inst3,inst4,ml); -} - -void INTERP_KERNEL::AsmX86::convertMovToEsp(const std::string& inst1, const std::string& inst2, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - if(inst1[0]!='[' || inst1[inst1.length()-1]!=']') - throw INTERP_KERNEL::Exception("not recognized convertMovToEsp exp !"); - std::string inst1bis=inst1.substr(1,inst1.length()-2); - const char ASM1[]="esp"; - const char ML1[3]={0xc7,0x04,0x24}; - if(inst1bis==ASM1) - {//mov dword [esp],0x3ff3c0ca - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - appendAddress(inst2,4,ml); - return ; - } - if(inst1bis.substr(0,3)==ASM1) - { - if(inst1bis[3]=='+') - {//mov dword [esp+4],0x3ff3c0ca - const char ML2[3]={0xc7,0x44,0x24}; - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - std::string::size_type pos=inst1bis.find_first_of(']'); - std::string inst1_1=inst1bis.substr(4,pos-4-1); - appendAddress(inst1_1,1,ml); - appendAddress(inst2,4,ml); - return; - } - else - throw INTERP_KERNEL::Exception("Not recognized exp : mov [esp@..],..."); - } - const char ASM3[]="rsp"; - const char ML3[3]={0xc7,0x04,0x24}; - if(inst1bis==ASM3) - {//mov dword [rsp],0x3ff3c0ca - ml.insert(ml.end(),ML3,ML3+sizeof(ML3)); - appendAddress(inst2,4,ml); - return ; - } - if(inst1bis.substr(0,3)==ASM3) - { - if(inst1bis[3]=='+') - {//mov dword [rsp+4],0x3ff3c0ca - const char ML2[3]={0xc7,0x44,0x24}; - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - std::string::size_type pos=inst1bis.find_first_of(']'); - std::string inst1_1=inst1bis.substr(4,pos-4-1); - appendAddress(inst1_1,1,ml); - appendAddress(inst2,4,ml); - return; - } - else - throw INTERP_KERNEL::Exception("Not recognized exp : mov [esp@..],..."); - } - throw INTERP_KERNEL::Exception("Not recognized exp : mov"); -} - -void INTERP_KERNEL::AsmX86::convertPush(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - std::string::size_type pos=inst.find_first_of(' '); - std::string inst2=inst.substr(pos+1); - const char ASM1[]="ebp"; - const char ML1[1]={0x55}; - if(inst2==ASM1) - {//push ebp - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - return ; - } - const char ASM2[]="ebx"; - const char ML2[1]={0x53}; - if(inst2==ASM2) - {//push ebx - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - return ; - } - const char ASM3[]="rbp"; - const char ML3[1]={0x55}; - if(inst2==ASM3) - {//push rbp - ml.insert(ml.end(),ML3,ML3+sizeof(ML3)); - return ; - } - throw INTERP_KERNEL::Exception("Unrecognized push instruction"); -} - -void INTERP_KERNEL::AsmX86::convertPop(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - std::string::size_type pos=inst.find_first_of(' '); - std::string inst2=inst.substr(pos+1); - const char ASM1[]="ebp"; - const char ML1[1]={0x5d}; - if(inst2==ASM1) - {//push ebp - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - return ; - } - const char ASM2[]="ebx"; - const char ML2[1]={0x5b}; - if(inst2==ASM2) - {//push ebx - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - return ; - } - throw INTERP_KERNEL::Exception("Unrecognized pop instruction"); -} - -void INTERP_KERNEL::AsmX86::convertFld(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - std::string::size_type pos=inst.find_first_of(' '); - std::string params=inst.substr(pos+1); - std::string params2=params.substr(1,params.length()-2); - if(params2.substr(0,3)=="esp") - { - const char ML1[3]={0xdd,0x04,0x24}; - if(params2.length()==3) - {//fld qword [esp] - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - return ; - } - pos=params2.find_first_of('+'); - if(pos!=std::string::npos) - {//fld qword [esp+@] - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - std::string params3=params2.substr(pos+1); - appendAddress(params3,1,ml); - return ; - } - throw INTERP_KERNEL::Exception("Unrecognized fld esp..."); - } - if(params2.substr(0,3)=="ebp") - { - const char ML2[2]={0xdd,0x45}; - if(params2.length()==3) - {//fld qword [ebp] - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - ml.push_back(0); - return ; - } - pos=params2.find_first_of('+'); - if(pos!=std::string::npos) - {//fld qword [esp+@] - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - std::string params3=params2.substr(pos+1); - appendAddress(params3,1,ml); - return ; - } - throw INTERP_KERNEL::Exception("Unrecognized fld ebp..."); - } - if(params2.substr(0,3)=="rsp") - { - const char ML2[3]={0xdd,0x04,0x24}; - ml.insert(ml.end(),ML2,ML2+sizeof(ML2));// to improve ! no fully managed ! - return ; - } - throw INTERP_KERNEL::Exception("Unrecognized fld instruction"); -} - -void INTERP_KERNEL::AsmX86::convertFaddp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML1[2]={0xde,0xc1}; - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); -} - -void INTERP_KERNEL::AsmX86::convertFsubp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML1[2]={0xde,0xe9}; - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); -} - -void INTERP_KERNEL::AsmX86::convertFmulp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML1[2]={0xde,0xc9}; - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); -} - -void INTERP_KERNEL::AsmX86::convertFdivp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML1[2]={0xde,0xf9}; - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); -} - -void INTERP_KERNEL::AsmX86::convertFcos(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML[2]={0xd9,0xff}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); -} - -void INTERP_KERNEL::AsmX86::convertFsin(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML[2]={0xd9,0xfe}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); -} - -void INTERP_KERNEL::AsmX86::convertFabs(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML[2]={0xd9,0xe1}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); -} - -void INTERP_KERNEL::AsmX86::convertFchs(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML[2]={0xd9,0xe0}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); -} - -void INTERP_KERNEL::AsmX86::convertFsqrt(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML[2]={0xd9,0xfa}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); -} - -void INTERP_KERNEL::AsmX86::convertSub(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - if(inst.substr(0,4)=="esp,") - { - const char ML[2]={0x81,0xec}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); - std::string inst2=inst.substr(4); - appendAddress(inst2,4,ml); - return; - } - if(inst.substr(0,4)=="rsp,") - { - const char ML[4]={0x48,0x83,0xec,0x08}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); // to improve 8 statically put (last of element of ML) !!!! - return; - } - throw INTERP_KERNEL::Exception("Not recognized sub instruction."); -} - -void INTERP_KERNEL::AsmX86::convertAdd(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - if(inst.substr(0,4)=="esp,") - { - const char ML[2]={0x81,0xc4}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); - std::string inst2=inst.substr(4); - appendAddress(inst2,4,ml); - return; - } - if(inst.substr(0,4)=="rsp,") - { - const char ML[4]={0x48,0x83,0xc4,0x08}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); // to improve 8 statically put (last of element of ML) !!!! - return; - } - throw INTERP_KERNEL::Exception("Not recognized add instruction."); -} - -void INTERP_KERNEL::AsmX86::convertRet(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML[1]={0xc3}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); -} - -void INTERP_KERNEL::AsmX86::convertLeave(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ML[1]={0xc9}; - ml.insert(ml.end(),ML,ML+sizeof(ML)); -} - -void INTERP_KERNEL::AsmX86::convertMovsd(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ASM1[]="[rsp],xmm0"; - const char ML1[5]={0xf2,0x0f,0x11,0x04,0x24}; - if(inst==ASM1) - { - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - return ; - } - const char ASM2[]="xmm0,[rsp]"; - const char ML2[5]={0xf2,0x0f,0x10,0x04,0x24}; - if(inst==ASM2) - { - ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); - return ; - } - std::ostringstream oss; oss << "not recognized instruction movsd : " << inst; - throw INTERP_KERNEL::Exception(oss.str().c_str()); -} - -void INTERP_KERNEL::AsmX86::convertFst(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - const char ASM1[]="qword [rsp]"; - const char ML1[3]={0xdd,0x14,0x24}; - if(inst==ASM1) - { - ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); - return ; - } - std::ostringstream oss; oss << "not recognized instruction fst : " << inst; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - //tony -} - - -void INTERP_KERNEL::AsmX86::appendAddress(const std::string& addr, int nbOfByte, std::vector& ml) throw(INTERP_KERNEL::Exception) -{ - int i,j; - char v; - std::istringstream iss(addr); - if(addr.length()>2) - { - if(addr[0]=='0' && addr[1]=='x') - iss >> std::hex; - } - iss >> i; - for(int k=0;k>=8; - } -} diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx deleted file mode 100644 index 11b8733e5..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELASMX86_HXX__ -#define __INTERPKERNELASMX86_HXX__ - -#include "INTERPKERNELEXPREVALDefines.hxx" -#include "InterpKernelException.hxx" - -#include -#include - -namespace INTERP_KERNEL -{ - class AsmX86 - { - public: - std::vector convertIntoMachineLangage(const std::vector& asmb) const throw(INTERP_KERNEL::Exception); - char *convertMachineLangageInBasic(const std::vector& ml, int& lgth) const; - private: - void convertOneInstructionInML(const std::string& inst, std::vector& ml) const throw(INTERP_KERNEL::Exception); - private: - static void convertMov(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertPush(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertPop(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFld(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFaddp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFsubp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFmulp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFdivp(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFcos(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFsin(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFabs(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFchs(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFsqrt(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertSub(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertAdd(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertRet(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertLeave(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertMovsd(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void convertFst(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception); - // - static void convertMovToEsp(const std::string& inst1, const std::string& inst2, std::vector& ml) throw(INTERP_KERNEL::Exception); - static void appendAddress(const std::string& addr, int nbOfByte, std::vector& ml) throw(INTERP_KERNEL::Exception); - private: - static const int NB_OF_OPS=19; - static const char *OPS[NB_OF_OPS]; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx deleted file mode 100644 index 585fac2f8..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx +++ /dev/null @@ -1,869 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelExprParser.hxx" -#include "InterpKernelValue.hxx" -#include "InterpKernelAsmX86.hxx" - -#include -#include -#include -#include -#include -#include - -#ifdef _POSIX_MAPPED_FILES -#include -#else -#ifdef WNT -#include -#endif -#endif - -using namespace INTERP_KERNEL; - -const char LeafExprVar::END_OF_RECOGNIZED_VAR[]="Vec"; - -const char ExprParser::WHITE_SPACES[]=" \n"; - -const char ExprParser::EXPR_PARSE_ERR_MSG[]="Invalid expression detected : "; - -LeafExpr *LeafExpr::buildInstanceFrom(const std::string& expr) throw(INTERP_KERNEL::Exception) -{ - std::istringstream stream; - stream.str(expr); - double val; - stream >> val; - if(!stream.fail()) - if(stream.eof()) - return new LeafExprVal(val); - else - { - std::ostringstream errMsg; - char MSGTYP6[]="Error following expression is not consedered as a double value : "; - errMsg << MSGTYP6 << expr; - throw INTERP_KERNEL::Exception(errMsg.str().c_str()); - } - else - return new LeafExprVar(expr); -} - -LeafExpr::~LeafExpr() -{ -} - -LeafExprVal::LeafExprVal(double value):_value(value) -{ -} - -LeafExprVal::~LeafExprVal() -{ -} - -void LeafExprVal::fillValue(Value *val) const throw(INTERP_KERNEL::Exception) -{ - val->setDouble(_value); -} - -LeafExprVar::LeafExprVar(const std::string& var):_fast_pos(-1),_var_name(var) -{ -} - -void LeafExprVar::fillValue(Value *val) const throw(INTERP_KERNEL::Exception) -{ - val->setVarname(_fast_pos,_var_name); -} - -void LeafExprVar::prepareExprEvaluation(const std::vector& vars) const throw(INTERP_KERNEL::Exception) -{ - std::vector::const_iterator iter=std::find(vars.begin(),vars.end(),_var_name); - if(iter==vars.end()) - { - if(!isRecognizedKeyVar(_var_name,_fast_pos)) - { - std::ostringstream oss; oss << "Var : " << _var_name << " not in : "; - std::copy(vars.begin(),vars.end(),std::ostream_iterator(oss,", ")); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - return; - } - _fast_pos=iter-vars.begin(); -} - -void LeafExprVar::prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception) -{ - if(!isRecognizedKeyVar(_var_name,_fast_pos)) - _fast_pos=-2; -} - -bool LeafExprVar::isRecognizedKeyVar(const std::string& var, int& pos) -{ - if(var.length()!=sizeof(END_OF_RECOGNIZED_VAR)) - return false; - std::string end=var.substr(1); - if(end!=END_OF_RECOGNIZED_VAR) - return false; - char first=var[0]; - if(first<'I' || first>'Z') - return false; - pos=-7-(first-'I'); - return true; -} - -LeafExprVar::~LeafExprVar() -{ -} - -ExprParser::ExprParser(const char *expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false),_expr(expr) -{ -} - -//! For \b NOT null terminated strings coming from FORTRAN. -ExprParser::ExprParser(const char *expr, int lgth, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false) -{ - _expr=buildStringFromFortran(expr,lgth); -} - -ExprParser::~ExprParser() -{ - delete _leaf; - releaseFunctions(); -} - -std::size_t ExprParser::findCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket) -{ - int level=0; - for(std::size_t iter=posOfCloseBracket-1;iter>=0;iter--) - if(expr[iter]==')') - level++; - else if(expr[iter]=='(') - { - if(level==0) - return iter; - else - level--; - } - return std::string::npos; -} - -std::string ExprParser::buildStringFromFortran(const char *expr, int lgth) -{ - std::string ret(expr,lgth); - std::string whiteSpaces(WHITE_SPACES); - std::size_t found=ret.find_last_not_of(whiteSpaces); - if (found!=std::string::npos) - ret.erase(found+1); - else - ret.clear();//ret is all whitespace - return ret; -} - -std::string ExprParser::deleteWhiteSpaces(const std::string& expr) -{ - std::string ret(expr); - std::string whiteSpaces(WHITE_SPACES); - std::size_t where1=0,where2=0; - while(where2!=std::string::npos && where1!=std::string::npos) - { - where1=ret.find_first_of(whiteSpaces.c_str(),where1,whiteSpaces.length()); - if(where1!=std::string::npos) - { - where2=ret.find_first_not_of(whiteSpaces,where1); - if(where2!=std::string::npos) - ret.erase(ret.begin()+where1,ret.begin()+where2); - else - ret.erase(ret.begin()+where1,ret.end()); - } - } - return ret; -} - -void ExprParser::parse() throw(INTERP_KERNEL::Exception) -{ - _is_parsed=true; - _is_parsing_ok=false; - _sub_expr.clear(); - releaseFunctions(); - if(!_expr.empty()) - { - checkBracketsParity(); - if(!simplify()) - parseDeeper(); - } - _is_parsing_ok=true; -} - -double ExprParser::evaluate() const throw(INTERP_KERNEL::Exception) -{ - Value *gen=new ValueDouble; - ValueDouble *res=(ValueDouble *)evaluateLowLev(gen); - delete gen; - double ret=res->getData(); - delete res; - return ret; -} - -DecompositionInUnitBase ExprParser::evaluateUnit() const throw(INTERP_KERNEL::Exception) -{ - Value *gen=new ValueUnit; - ValueUnit *res=0; - try - { - res=(ValueUnit *)evaluateLowLev(gen); - } - catch(INTERP_KERNEL::Exception& e) - { - delete gen; - throw e; - } - delete gen; - DecompositionInUnitBase ret=res->getData(); - delete res; - return ret; -} - -void ExprParser::evaluateExpr(int szOfOutParam, const double *inParam, double *outParam) const throw(INTERP_KERNEL::Exception) -{ - Value *gen=new ValueDoubleExpr(szOfOutParam,inParam); - ValueDoubleExpr *res=0; - try - { - res=(ValueDoubleExpr *)evaluateLowLev(gen); - } - catch(INTERP_KERNEL::Exception& e) - { - delete gen; - throw e; - } - delete gen; - std::copy(res->getData(),res->getData()+szOfOutParam,outParam); - delete res; -} - -void ExprParser::prepareExprEvaluation(const std::vector& vars) const throw(INTERP_KERNEL::Exception) -{ - if(_leaf) - { - LeafExprVar *leafC=dynamic_cast(_leaf); - if(leafC) - leafC->prepareExprEvaluation(vars); - } - else - for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).prepareExprEvaluation(vars); -} - -void ExprParser::prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception) -{ - std::set trueVars; - getTrueSetOfVars(trueVars); - if(trueVars.size()>1) - { - std::ostringstream oss; oss << "For this type of evaluation only one not keyword variable authorized : "; - oss << "having " << trueVars.size() << " : "; - std::copy(trueVars.begin(),trueVars.end(),std::ostream_iterator(oss," ")); oss << " !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - prepareExprEvaluationVecLowLev(); -} - -void ExprParser::prepareExprEvaluationVecLowLev() const throw(INTERP_KERNEL::Exception) -{ - if(_leaf) - { - LeafExprVar *leafC=dynamic_cast(_leaf); - if(leafC) - leafC->prepareExprEvaluationVec(); - } - else - for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).prepareExprEvaluationVecLowLev(); -} - -Value *ExprParser::evaluateLowLev(Value *valGen) const throw(INTERP_KERNEL::Exception) -{ - if(!_is_parsing_ok) - throw INTERP_KERNEL::Exception("Parsing fails ! Invalid expression !"); - if(_sub_expr.empty() && !_leaf) - throw INTERP_KERNEL::Exception("Empty expression !"); - std::vector stackOfVal; - try - { - if(_leaf) - { - Value *ret=valGen->newInstance(); - try - { - _leaf->fillValue(ret); - } - catch(INTERP_KERNEL::Exception& e) - { - delete ret; - throw e; - } - stackOfVal.resize(1); - stackOfVal[0]=ret; - } - else - { - stackOfVal.resize(_sub_expr.size()); - std::vector::reverse_iterator iter2=stackOfVal.rbegin(); - for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++,iter2++) - *iter2=(*iter).evaluateLowLev(valGen); - } - std::list::const_iterator iter3; - for(iter3=_func_btw_sub_expr.begin();iter3!=_func_btw_sub_expr.end();iter3++) - (*iter3)->operate(stackOfVal); - } - catch(INTERP_KERNEL::Exception& e) - { - for(std::vector::iterator iter4=stackOfVal.begin();iter4!=stackOfVal.end();iter4++) - delete *iter4; - throw e; - } - return stackOfVal.back(); -} - -void ExprParser::getSetOfVars(std::set& vars) const -{ - if(_leaf) - { - LeafExprVar *leafC=dynamic_cast(_leaf); - if(leafC) - vars.insert(leafC->getVar()); - } - else - for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).getSetOfVars(vars); -} - -void ExprParser::getTrueSetOfVars(std::set& trueVars) const -{ - std::set vars; - getSetOfVars(vars); - trueVars.clear(); - for(std::set::const_iterator iter=vars.begin();iter!=vars.end();iter++) - { - int tmp; - if(!LeafExprVar::isRecognizedKeyVar(*iter,tmp)) - trueVars.insert(*iter); - } -} - -void ExprParser::parseDeeper() throw(INTERP_KERNEL::Exception) -{ - for(std::list::iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - if(!(*iter).simplify()) - (*iter).parseDeeper(); -} - -/*! - * This method has the responsability to see if this->_expr can be seen as a unary function of something. - * Something defined as the contain of highest level barckets. - * Typically '(3*x+2)' and 'cos(4*l+p*n)' will be intercepted by this method whereas '3*x+2' not...etc.. - */ -void ExprParser::parseUnaryFunc() throw(INTERP_KERNEL::Exception) -{ - if(_expr[_expr.length()-1]!=')') - return ; - //at this level of code _expr - std::size_t pos1=_expr.find_first_of('('); - std::size_t pos4=findCorrespondingOpenBracket(_expr,_expr.length()-1); - if(pos4!=pos1) - return ; - std::string funcName=_expr.substr(0,pos1); - std::size_t pos2=funcName.find_first_of("+-*/^",0,5); - std::size_t pos3=funcName.find_first_not_of("+-*/^",0,5); - if(pos2!=std::string::npos && pos3!=std::string::npos) - return ;//Bracket group is not alone, can't conclude not recursively. - std::string newExp2=_expr.substr(pos1+1,_expr.length()-pos1-2); - int nbOfParamsInFunc=std::count(newExp2.begin(),newExp2.end(),',')+1; - if(pos3!=std::string::npos) - _func_btw_sub_expr.push_back(FunctionsFactory::buildFuncFromString(funcName.c_str(),nbOfParamsInFunc)); - else - { - int lgth=funcName.length(); - char tmp[2]; tmp[1]='\0'; - for(int i=0;i_expr is interpretable without any recursion. - * \return true if no recursion needed, false if this->_expr is too complex to be interpreted at this level. - * \throw exception if this->_expr is simple enough to try to interprate this and this expression contains an error. - */ -bool ExprParser::tryToInterpALeaf() throw(INTERP_KERNEL::Exception) -{ - std::size_t pos=_expr.find_first_not_of("+-",0,2); - std::string minimizedExpr=_expr.substr(pos); - std::size_t pos2=minimizedExpr.find_first_of("+-*/^()",0,7); - if(pos2!=std::string::npos) - return false; - delete _leaf; - _leaf=LeafExpr::buildInstanceFrom(minimizedExpr); - int nbOfNegs=0; - for(std::size_t i=0;i::iterator iter=_func_btw_sub_expr.begin();iter!=_func_btw_sub_expr.end();iter++) - delete *iter; - _func_btw_sub_expr.clear(); -} - -/*! - * This method parse this->_expr at the current level. - * This method first try to see if this->_expr is a leaf, if not it try a unary function of something (see INTERP_KERNEL::ExprParser::parseUnaryFunc method) - * If true is returned, no deeper parsing needed, if false is returned for a full parsing of this->_expr INTERP_KERNEL::ExprParser::parseDeeper call needed. - */ -bool ExprParser::simplify() throw(INTERP_KERNEL::Exception) -{ - if(tryToInterpALeaf()) - return true; - parseUnaryFunc(); - if(!_is_parsing_ok) - { - parseForAddMin(); - if(!_is_parsing_ok) - { - parseForMulDiv(); - if(!_is_parsing_ok) - parseForPow(); - } - } - if(!_is_parsing_ok) - { - std::ostringstream errMsg; - char MSGTYP3[]="Error in interpreting : "; - errMsg << EXPR_PARSE_ERR_MSG << MSGTYP3 << _expr; - locateError(errMsg,_expr,0); - throw INTERP_KERNEL::Exception(errMsg.str().c_str()); - } - return false; -} - -void ExprParser::checkBracketsParity() const throw(INTERP_KERNEL::Exception) -{ - std::string::const_iterator iter; - int curLevel=0; - for(iter=_expr.begin();iter!=_expr.end();iter++) - { - if(*iter=='(') - curLevel++; - else if(*iter==')') - { - if(curLevel==0) - { - std::ostringstream errMsg; - char MSGTYP1[]="Error in brackets : closing brackets ')' before openning '('"; - errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1; - locateError(errMsg,_expr,iter-_expr.begin()); - throw INTERP_KERNEL::Exception(errMsg.str().c_str()); - } - curLevel--; - } - } - if(curLevel!=0) - { - std::ostringstream errMsg; - char MSGTYP2[]="Error in brackets : not finally closed expr."; - errMsg << EXPR_PARSE_ERR_MSG << MSGTYP2; - throw INTERP_KERNEL::Exception(errMsg.str().c_str()); - } -} - -void ExprParser::locateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr) -{ - stringToDisp << "Position is " << posOfErr << " of string : \"" << srcOfErr << "\"" << std::endl; -} - -char *ExprParser::compileX86() const -{ - std::vector ass; - //need in stack - ass.push_back("push ebp"); - ass.push_back("mov ebp,esp"); - compileX86LowLev(ass); - ass.push_back("pop ebp"); - ass.push_back("ret"); - std::cout << std::endl; - for(std::vector::const_iterator iter=ass.begin();iter!=ass.end();iter++) - std::cout << " " << *iter << std::endl; - AsmX86 asmb; - std::vector output=asmb.convertIntoMachineLangage(ass); - for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) - std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; - std::cout << std::endl; - int lgth; - char *lm=asmb.convertMachineLangageInBasic(output,lgth); - char *ret=0; -#ifdef _POSIX_MAPPED_FILES - ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); -#else -#ifdef WNT - HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); - ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); -#endif -#endif - if(ret) - std::copy(lm,lm+lgth,ret); - delete [] lm; - return ret; -} - -char *ExprParser::compileX86_64() const -{ - std::vector ass; - //need in stack - ass.push_back("push rbp"); - ass.push_back("mov rbp,rsp"); - compileX86_64LowLev(ass); - ass.push_back("sub rsp,8"); - ass.push_back("fst qword [rsp]"); - ass.push_back("movsd xmm0,[rsp]"); - ass.push_back("add rsp,8"); - ass.push_back("leave"); - ass.push_back("ret"); - std::cout << std::endl; - for(std::vector::const_iterator iter=ass.begin();iter!=ass.end();iter++) - std::cout << " " << *iter << std::endl; - AsmX86 asmb; - std::vector output=asmb.convertIntoMachineLangage(ass); - for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) - std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; - std::cout << std::endl; - int lgth; - char *lm=asmb.convertMachineLangageInBasic(output,lgth); - char *ret=0; -#ifdef _POSIX_MAPPED_FILES - ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); -#else -#ifdef WNT - HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); - ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); -#endif -#endif - if(ret) - std::copy(lm,lm+lgth,ret); - delete [] lm; - return ret; -} - -void ExprParser::compileX86LowLev(std::vector& ass) const -{ - if(_leaf) - _leaf->compileX86(ass); - else - { - for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).compileX86LowLev(ass); - for(std::list::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) - (*iter2)->operateX86(ass); - } -} - -void ExprParser::compileX86_64LowLev(std::vector& ass) const -{ - if(_leaf) - _leaf->compileX86_64(ass); - else - { - for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).compileX86_64LowLev(ass); - for(std::list::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) - (*iter2)->operateX86(ass); - } -} - -void LeafExprVal::compileX86(std::vector& ass) const -{ - ass.push_back("sub esp,8"); - int *b=(int *)&_value,*c=(int *)&_value; - c++; - std::ostringstream oss; - oss << std::hex; - oss << "mov dword [esp+4],0x" << *c; - ass.push_back(oss.str()); - oss.str(""); - oss << "mov dword [esp],0x" << *b; - ass.push_back(oss.str()); - ass.push_back("fld qword [esp]"); - ass.push_back("add esp,8"); -} - -void LeafExprVal::compileX86_64(std::vector& ass) const -{ - ass.push_back("sub rsp,8"); - int *b=(int *)&_value,*c=(int *)&_value; - c++; - std::ostringstream oss; - oss << std::hex; - oss << "mov dword [rsp+4],0x" << *c; - ass.push_back(oss.str()); - oss.str(""); - oss << "mov dword [rsp],0x" << *b; - ass.push_back(oss.str()); - ass.push_back("fld qword [rsp]"); - ass.push_back("add rsp,8"); -} - -void LeafExprVar::compileX86(std::vector& ass) const -{ - ass.push_back("fld qword [ebp+8]"); -} - -void LeafExprVar::compileX86_64(std::vector& ass) const -{ - ass.push_back("sub rsp,8"); - ass.push_back("movsd [rsp],xmm0"); - ass.push_back("fld qword [rsp]"); - ass.push_back("add rsp,8"); -} - -int ExprParser::getStackSizeToPlayX86(const ExprParser *asker) const -{ - if(asker) - { - int sz=_father->getStackSizeToPlayX86(this); - int i=0; - for(std::list::const_reverse_iterator iter=_sub_expr.rbegin();iter!=_sub_expr.rend();iter++,i++) - { - const ExprParser& obj=(*iter); - const ExprParser *pt=&obj; - if(pt==asker) - return sz-i; - } - throw INTERP_KERNEL::Exception("error getStackSizeToPlayX86 an object ExprParser called as father, whereas it is not one !"); - } - else - { - if(!_father) - return MAX_X86_FP_ST; - return _father->getStackSizeToPlayX86(this); - } -} diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx deleted file mode 100644 index 7ff8babb5..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELEXPRPARSER_HXX__ -#define __INTERPKERNELEXPRPARSER_HXX__ - -#include "INTERPKERNELEXPREVALDefines.hxx" -#include "InterpKernelUnit.hxx" -#include "InterpKernelException.hxx" -#include "InterpKernelFunction.hxx" - -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - class ValueDouble; - - class INTERPKERNELEXPREVAL_EXPORT LeafExpr - { - public: - virtual ~LeafExpr(); - virtual void fillValue(Value *val) const throw(INTERP_KERNEL::Exception) = 0; - virtual void compileX86(std::vector& ass) const = 0; - virtual void compileX86_64(std::vector& ass) const = 0; - static LeafExpr *buildInstanceFrom(const std::string& expr) throw(INTERP_KERNEL::Exception); - }; - - class INTERPKERNELEXPREVAL_EXPORT LeafExprVal : public LeafExpr - { - public: - LeafExprVal(double value); - ~LeafExprVal(); - void compileX86(std::vector& ass) const; - void compileX86_64(std::vector& ass) const; - void fillValue(Value *val) const throw(INTERP_KERNEL::Exception); - private: - double _value; - }; - - class INTERPKERNELEXPREVAL_EXPORT LeafExprVar : public LeafExpr - { - public: - LeafExprVar(const std::string& var); - ~LeafExprVar(); - void compileX86(std::vector& ass) const; - void compileX86_64(std::vector& ass) const; - void fillValue(Value *val) const throw(INTERP_KERNEL::Exception); - std::string getVar() const { return _var_name; } - void prepareExprEvaluation(const std::vector& vars) const throw(INTERP_KERNEL::Exception); - void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception); - static bool isRecognizedKeyVar(const std::string& var, int& pos); - public: - static const char END_OF_RECOGNIZED_VAR[]; - private: - mutable int _fast_pos; - std::string _var_name; - }; - - class INTERPKERNELEXPREVAL_EXPORT ExprParser - { - public: - ExprParser(const char *expr, ExprParser *father=0); - ExprParser(const char *expr, int lgth, ExprParser *father=0); - ~ExprParser(); - void parse() throw(INTERP_KERNEL::Exception); - bool isParsingSuccessfull() const { return _is_parsing_ok; } - double evaluate() const throw(INTERP_KERNEL::Exception); - DecompositionInUnitBase evaluateUnit() const throw(INTERP_KERNEL::Exception); - void prepareExprEvaluation(const std::vector& vars) const throw(INTERP_KERNEL::Exception); - void evaluateExpr(int szOfOutParam, const double *inParam, double *outParam) const throw(INTERP_KERNEL::Exception); - void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception); - void getSetOfVars(std::set& vars) const; - void getTrueSetOfVars(std::set& vars) const; - // - char *compileX86() const; - char *compileX86_64() const; - void compileX86LowLev(std::vector& ass) const; - void compileX86_64LowLev(std::vector& ass) const; - int getStackSizeToPlayX86(const ExprParser *asker) const; - // - static std::string buildStringFromFortran(const char *expr, int lgth); - static std::string deleteWhiteSpaces(const std::string& expr); - private: - Value *evaluateLowLev(Value *valGen) const throw(INTERP_KERNEL::Exception); - private: - void prepareExprEvaluationVecLowLev() const throw(INTERP_KERNEL::Exception); - bool tryToInterpALeaf() throw(INTERP_KERNEL::Exception); - void parseUnaryFunc() throw(INTERP_KERNEL::Exception); - void parseForAddMin() throw(INTERP_KERNEL::Exception); - void parseForMulDiv() throw(INTERP_KERNEL::Exception); - void parseForPow() throw(INTERP_KERNEL::Exception); - void parseDeeper() throw(INTERP_KERNEL::Exception); - bool simplify() throw(INTERP_KERNEL::Exception); - void releaseFunctions(); - void checkBracketsParity() const throw(INTERP_KERNEL::Exception); - static std::size_t findCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket); - static void locateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr); - private: - ExprParser *_father; - bool _is_parsed; - LeafExpr *_leaf; - bool _is_parsing_ok; - std::string _expr; - std::list _sub_expr; - std::list _func_btw_sub_expr; - private: - static const int MAX_X86_FP_ST=8; - static const char WHITE_SPACES[]; - static const char EXPR_PARSE_ERR_MSG[]; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx deleted file mode 100644 index dd16329f6..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx +++ /dev/null @@ -1,651 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelFunction.hxx" -#include "InterpKernelValue.hxx" - -#include - -using namespace INTERP_KERNEL; - -const char IdentityFunction::REPR[]="Id"; - -const char PositiveFunction::REPR[]="+"; - -const char NegateFunction::REPR[]="-"; - -const char CosFunction::REPR[]="cos"; - -const char SinFunction::REPR[]="sin"; - -const char TanFunction::REPR[]="tan"; - -const char SqrtFunction::REPR[]="sqrt"; - -const char AbsFunction::REPR[]="abs"; - -const char PlusFunction::REPR[]="+"; - -const char MinusFunction::REPR[]="-"; - -const char MultFunction::REPR[]="*"; - -const char DivFunction::REPR[]="/"; - -const char PowFunction::REPR[]="^"; - -const char ExpFunction::REPR[]="exp"; - -const char LnFunction::REPR[]="ln"; - -const char MaxFunction::REPR[]="max"; - -const char MinFunction::REPR[]="min"; - -Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams) throw(INTERP_KERNEL::Exception) -{ - switch(nbOfParams) - { - case 1: - return buildUnaryFuncFromString(type); - case 2: - return buildBinaryFuncFromString(type); - default: - throw INTERP_KERNEL::Exception("Invalid number of params detected : limited to 2 !"); - } -} - -Function *FunctionsFactory::buildUnaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception) -{ - std::string tmp(type); - if(tmp.empty()) - return new IdentityFunction; - if(tmp==CosFunction::REPR) - return new CosFunction; - if(tmp==SinFunction::REPR) - return new SinFunction; - if(tmp==TanFunction::REPR) - return new TanFunction; - if(tmp==SqrtFunction::REPR) - return new SqrtFunction; - if(tmp==AbsFunction::REPR) - return new AbsFunction; - if(tmp==PositiveFunction::REPR) - return new PositiveFunction; - if(tmp==NegateFunction::REPR) - return new NegateFunction; - if(tmp==ExpFunction::REPR) - return new ExpFunction; - if(tmp==LnFunction::REPR) - return new LnFunction; - // - std::string msg("Invalid unary function detected : \""); - msg+=type; msg+="\""; - throw INTERP_KERNEL::Exception(msg.c_str()); -} - -Function *FunctionsFactory::buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception) -{ - std::string tmp(type); - if(tmp==PositiveFunction::REPR) - return new PlusFunction; - if(tmp==NegateFunction::REPR) - return new MinusFunction; - if(tmp==MultFunction::REPR) - return new MultFunction; - if(tmp==DivFunction::REPR) - return new DivFunction; - if(tmp==PowFunction::REPR) - return new PowFunction; - if(tmp==MaxFunction::REPR) - return new MaxFunction; - if(tmp==MinFunction::REPR) - return new MinFunction; - std::string msg("Invalid binary function detected : \""); - msg+=type; msg+="\""; - throw INTERP_KERNEL::Exception(msg.c_str()); -} - -Function *FunctionsFactory::buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception) -{ - char tmp[2]; tmp[0]=type; tmp[1]='\0'; - return buildBinaryFuncFromString(tmp); -} - -Function::~Function() -{ -} - -IdentityFunction::~IdentityFunction() -{ -} - -void IdentityFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ -} - -void IdentityFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ -} - -const char *IdentityFunction::getRepr() const -{ - return REPR; -} - -bool IdentityFunction::isACall() const -{ - return false; -} - -PositiveFunction::~PositiveFunction() -{ -} - -int UnaryFunction::getNbInputParams() const -{ - return 1; -} - -void PositiveFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ -} - -void PositiveFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ -} - -const char *PositiveFunction::getRepr() const -{ - return REPR; -} - -bool PositiveFunction::isACall() const -{ - return false; -} - -NegateFunction::~NegateFunction() -{ -} - -void NegateFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->negate(); -} - -void NegateFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fchs"); -} - -const char *NegateFunction::getRepr() const -{ - return REPR; -} - -bool NegateFunction::isACall() const -{ - return false; -} - -CosFunction::~CosFunction() -{ -} - -void CosFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->cos(); -} - -void CosFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fcos"); -} - -const char *CosFunction::getRepr() const -{ - return REPR; -} - -bool CosFunction::isACall() const -{ - return true; -} - -SinFunction::~SinFunction() -{ -} - -void SinFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->sin(); -} - -void SinFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fsin"); -} - -const char *SinFunction::getRepr() const -{ - return REPR; -} - -bool SinFunction::isACall() const -{ - return true; -} - -TanFunction::~TanFunction() -{ -} - -void TanFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->tan(); -} - -void TanFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); -} - -const char *TanFunction::getRepr() const -{ - return REPR; -} - -bool TanFunction::isACall() const -{ - return true; -} - -SqrtFunction::~SqrtFunction() -{ -} - -void SqrtFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->sqrt(); -} - -void SqrtFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fsqrt"); -} - -const char *SqrtFunction::getRepr() const -{ - return REPR; -} - -bool SqrtFunction::isACall() const -{ - return true; -} - -AbsFunction::~AbsFunction() -{ -} - -void AbsFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->abs(); -} - -void AbsFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fabs"); -} - -const char *AbsFunction::getRepr() const -{ - return REPR; -} - -bool AbsFunction::isACall() const -{ - return false; -} - -void ExpFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->exp(); -} - -void ExpFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); -} - -const char *ExpFunction::getRepr() const -{ - return REPR; -} - -bool ExpFunction::isACall() const -{ - return true; -} - -LnFunction::~LnFunction() -{ -} - -void LnFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val=stack.back(); - val->ln(); -} - -void LnFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); -} - -const char *LnFunction::getRepr() const -{ - return REPR; -} - -bool LnFunction::isACall() const -{ - return true; -} - -int BinaryFunction::getNbInputParams() const -{ - return 2; -} - -PlusFunction::~PlusFunction() -{ -} - -void PlusFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val1=stack.back(); - stack.pop_back(); - Value *& val2=stack.back(); - Value *val3; - try - { - val3=val1->plus(val2); - } - catch(INTERP_KERNEL::Exception& e) - { - delete val1; - throw e; - } - delete val1; - delete val2; - val2=val3; -} - -void PlusFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("faddp st1"); -} - -const char *PlusFunction::getRepr() const -{ - return REPR; -} - -bool PlusFunction::isACall() const -{ - return false; -} - -MinusFunction::~MinusFunction() -{ -} - -void MinusFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val1=stack.back(); - stack.pop_back(); - Value *& val2=stack.back(); - Value *val3; - try - { - val3=val1->minus(val2); - } - catch(INTERP_KERNEL::Exception& e) - { - delete val1; - throw e; - } - delete val1; - delete val2; - val2=val3; -} - -void MinusFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fsubp st1"); -} - -const char *MinusFunction::getRepr() const -{ - return REPR; -} - -bool MinusFunction::isACall() const -{ - return false; -} - -MultFunction::~MultFunction() -{ -} - -void MultFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val1=stack.back(); - stack.pop_back(); - Value *& val2=stack.back(); - Value *val3=val1->mult(val2); - delete val1; - delete val2; - val2=val3; -} - -void MultFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fmulp st1"); -} - -const char *MultFunction::getRepr() const -{ - return REPR; -} - -bool MultFunction::isACall() const -{ - return false; -} - -DivFunction::~DivFunction() -{ -} - -void DivFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val1=stack.back(); - stack.pop_back(); - Value *& val2=stack.back(); - Value *val3; - try - { - val3=val1->div(val2); - } - catch(INTERP_KERNEL::Exception& e) - { - delete val1; - throw e; - } - delete val1; - delete val2; - val2=val3; -} - -void DivFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - asmb.push_back("fdivp st1"); -} - -const char *DivFunction::getRepr() const -{ - return REPR; -} - -bool DivFunction::isACall() const -{ - return false; -} - -PowFunction::~PowFunction() -{ -} - -void PowFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val1=stack.back(); - stack.pop_back(); - Value *& val2=stack.back(); - Value *val3; - try - { - val3=val1->pow(val2); - } - catch(INTERP_KERNEL::Exception& e) - { - delete val1; - throw e; - } - delete val1; - delete val2; - val2=val3; -} - -void PowFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); -} - -const char *PowFunction::getRepr() const -{ - return REPR; -} - -bool PowFunction::isACall() const -{ - return true; -} - -ExpFunction::~ExpFunction() -{ -} - -MaxFunction::~MaxFunction() -{ -} - -void MaxFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val1=stack.back(); - stack.pop_back(); - Value *& val2=stack.back(); - Value *val3; - try - { - val3=val1->max(val2); - } - catch(INTERP_KERNEL::Exception& e) - { - delete val1; - throw e; - } - delete val1; - delete val2; - val2=val3; -} - -void MaxFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); -} - -const char *MaxFunction::getRepr() const -{ - return REPR; -} - -bool MaxFunction::isACall() const -{ - return false; -} - -MinFunction::~MinFunction() -{ -} - -void MinFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) -{ - Value *val1=stack.back(); - stack.pop_back(); - Value *& val2=stack.back(); - Value *val3; - try - { - val3=val1->min(val2); - } - catch(INTERP_KERNEL::Exception& e) - { - delete val1; - throw e; - } - delete val1; - delete val2; - val2=val3; -} - -void MinFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); -} - -const char *MinFunction::getRepr() const -{ - return REPR; -} - -bool MinFunction::isACall() const -{ - return false; -} diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx deleted file mode 100644 index 160e15ba9..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELFUNCTION_HXX__ -#define __INTERPKERNELFUNCTION_HXX__ - -#include "INTERPKERNELEXPREVALDefines.hxx" -#include "InterpKernelException.hxx" - -#include - -namespace INTERP_KERNEL -{ - class Value; - class Function; - - class INTERPKERNELEXPREVAL_EXPORT FunctionsFactory - { - public: - static Function *buildFuncFromString(const char *type, int nbOfParams) throw(INTERP_KERNEL::Exception); - static Function *buildUnaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception); - //static Function *buildUnaryFuncFromString(char type) throw(INTERP_KERNEL::Exception); - static Function *buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception); - static Function *buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception); - }; - - class INTERPKERNELEXPREVAL_EXPORT Function - { - public: - virtual ~Function(); - virtual int getNbInputParams() const = 0; - virtual void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) = 0; - virtual void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) = 0; - virtual const char *getRepr() const = 0; - virtual bool isACall() const = 0; - }; - - class INTERPKERNELEXPREVAL_EXPORT UnaryFunction : public Function - { - public: - int getNbInputParams() const; - }; - - class INTERPKERNELEXPREVAL_EXPORT IdentityFunction : public UnaryFunction - { - public: - ~IdentityFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT PositiveFunction : public UnaryFunction - { - public: - ~PositiveFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT NegateFunction : public UnaryFunction - { - public: - ~NegateFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT CosFunction : public UnaryFunction - { - public: - ~CosFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT SinFunction : public UnaryFunction - { - public: - ~SinFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT TanFunction : public UnaryFunction - { - public: - ~TanFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT SqrtFunction : public UnaryFunction - { - public: - ~SqrtFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT AbsFunction : public UnaryFunction - { - public: - ~AbsFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT ExpFunction : public UnaryFunction - { - public: - ~ExpFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT LnFunction : public UnaryFunction - { - public: - ~LnFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT BinaryFunction : public Function - { - public: - int getNbInputParams() const; - }; - - class PlusFunction : public BinaryFunction - { - public: - ~PlusFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT MinusFunction : public BinaryFunction - { - public: - ~MinusFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT MultFunction : public BinaryFunction - { - public: - ~MultFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT DivFunction : public BinaryFunction - { - public: - ~DivFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT PowFunction : public BinaryFunction - { - public: - ~PowFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT MaxFunction : public BinaryFunction - { - public: - ~MaxFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; - - class INTERPKERNELEXPREVAL_EXPORT MinFunction : public BinaryFunction - { - public: - ~MinFunction(); - void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); - void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); - const char *getRepr() const; - bool isACall() const; - public: - static const char REPR[]; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx deleted file mode 100644 index 6eacf7221..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelUnit.hxx" -#include "InterpKernelExprParser.hxx" - -#include -#include -#include -#include - -using namespace INTERP_KERNEL; - -UnitDataBase UnitDataBase::_uniqueMapForExpr; - -static const char InterpKernelMuAscii[2]={-0x4B,0x0}; - -static const char InterpKernelMuUnicode[3]={-0x3E,-0x4B,0x0}; - -const char *UnitDataBase::PREF_POW10[NB_OF_PREF_POW10]={"y","z","a","f","p","n",InterpKernelMuAscii,InterpKernelMuUnicode,"u","m","c","d", - "da","h","k","M","G","T","P","E","Z","Y"}; - -const double UnitDataBase::POW10[NB_OF_PREF_POW10]={1e-24,1e-21,1e-18,1e-15,1e-12,1e-9,1e-6,1e-6,1e-6,1e-3,1e-2,1e-1, - 1e1,1e2,1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24}; - -static const char InterpKernelDegreeCAscii[3]={-0x50,0x43,0x0}; - -static const char InterpKernelDegreeCUnicode[4]={-0x3E,-0x50,0x43,0x0}; - -static const char InterpKernelDegreeCUnicodeWin[3]={-0x08,0x43,0x0}; - -const char *UnitDataBase::UNITS_RECOGN[NB_OF_UNITS_RECOGN]={"g","m","s","A","K", - "W","J","Hz","V","h","min","t","N","dyn", - "eV","Pa","atm","bar",InterpKernelDegreeCAscii,"C","ohm","F","S", - "T","H","P","St",InterpKernelDegreeCUnicode,InterpKernelDegreeCUnicodeWin}; - -const short UnitDataBase::PROJ_IN_BASE[NB_OF_UNITS_RECOGN][SIZE_OF_UNIT_BASE]= - { - {1,0,0,0,0},//g - {0,1,0,0,0},//m - {0,0,1,0,0},//s - {0,0,0,1,0},//A - {0,0,0,0,1},//K - {1,2,-3,0,0},//W - {1,2,-2,0,0},//J - {0,0,-1,0,0},//Hz - {1,2,-3,-1,0},//V - {0,0,1,0,0},//h - {0,0,1,0,0},//min - {1,0,0,0,0},//t - {1,1,-2,0,0},//N - {1,1,-2,0,0},//dyn - {1,2,-2,0,0},//eV - {1,-1,-2,0,0},//Pa - {1,-1,-2,0,0},//atm - {1,-1,-2,0,0},//bar - {0,0,0,0,1},//degree C - {0,0,1,1,0},//C - {1,2,-3,-2,0},//ohm - {-1,-2,4,2,0},//F - {-1,-2,3,2,0},//S - {1,0,-2,-1,0},//T - {1,2,-2,-2,0},//H - {1,-1,-1,0,0},//P - {0,2,-1,0,0},//St - {0,0,0,0,1},//degree C - {0,0,0,0,1}//degree C - }; - -const double UnitDataBase::MUL_COEFF[NB_OF_UNITS_RECOGN]= - { 1.,1.,1.,1.,1., - 1000.,1000.,1.,1000.,3600.,3600.,1e6,1000.,1e-2, - 1.60217733e-16,1000.,1.01325e8,1e8,1.,1.,1000.,1e-3, - 1000.,1000.,100.,1.,1.,1.,1.}; - -const double UnitDataBase::ADD_COEFF[NB_OF_UNITS_RECOGN]= - { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 273.15, 0., 0., 0., 0., 0., 0., 0., 0., 273.15 ,273.15}; - -UnitDataBase::UnitDataBase() -{ - for(int i=0;i::const_iterator iter=_units_semantic.find(work); - if(iter!=_units_semantic.end()) - { - ret=(*iter).second; - std::map::const_iterator iter2=_units_add.find(work); - addFact=(*iter2).second; - std::map::const_iterator iter3=_units_mul.find(work); - mFact=(*iter3).second; - work2=unit.substr(0,i); - } - } - if(!ret) - { - std::ostringstream os; - os << "Unit : " << unit << " not recognized !"; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - if(!work2.empty()) - { - std::map::const_iterator iter4=_prefix_pow_10.find(work2); - if(iter4==_prefix_pow_10.end()) - { - std::ostringstream os; - os << "Unit : " << unit << " not fully recognized : \"" << work << "\" detected as core unit and \""; - os << work2 << "\" not recognized prefix !"; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - addFact=0.; - mFact*=(*iter4).second; - } - return ret; -} - -DecompositionInUnitBase::DecompositionInUnitBase():_add_to_base(0.),_mult_fact_to_base(1.) -{ - _value[0]=0; - _value[1]=0; - _value[2]=0; - _value[3]=0; - _value[4]=0; -} - -void DecompositionInUnitBase::setInfo(const short *vals, double addFact, double mFact) -{ - _add_to_base=addFact; - _mult_fact_to_base=mFact; - _value[0]=vals[0]; - _value[1]=vals[1]; - _value[2]=vals[2]; - _value[3]=vals[3]; - _value[4]=vals[4]; -} - -bool DecompositionInUnitBase::operator==(const DecompositionInUnitBase& other) const -{ - return _value[0]==other._value[0] && _value[1]==other._value[1] && _value[2]==other._value[2] && _value[3]==other._value[3] && _value[4]==other._value[4]; -} - -void DecompositionInUnitBase::getTranslationParams(const DecompositionInUnitBase& other, double& mul, double& add) const -{ - if((*this)==other) - { - mul=_mult_fact_to_base/other._mult_fact_to_base; - add=_add_to_base/other._mult_fact_to_base-other._add_to_base; - } - else - { - mul=std::numeric_limits::max(); - add=std::numeric_limits::max(); - } -} - -bool DecompositionInUnitBase::isEqual(short mass, short lgth, short time, short intensity, short temp, double add, double mult) -{ - bool ret1=mass==_value[0]; - bool ret2=lgth==_value[1]; - bool ret3=time==_value[2]; - bool ret4=intensity==_value[3]; - bool ret5=temp==_value[4]; - bool ret6=areDoubleEquals(add,_add_to_base); - bool ret7=areDoubleEquals(mult,_mult_fact_to_base); - return ret1 && ret2 && ret3 && ret4 && ret5 && ret6 && ret7; -} - -void DecompositionInUnitBase::negate() -{ - _mult_fact_to_base=-_mult_fact_to_base; -} - -bool DecompositionInUnitBase::isAdimensional() const -{ - return _value[0]==0 && _value[1]==0 && _value[2]==0 && _value[3]==0 && _value[4]==0; -} - -bool DecompositionInUnitBase::isUnitary() const -{ - return areDoubleEquals(_add_to_base,0.) && areDoubleEquals(_mult_fact_to_base,1.); -} - -void DecompositionInUnitBase::tryToConvertInUnit(double val) throw(INTERP_KERNEL::Exception) -{ - int valI=(int)val; - if((val-(double)valI)!=0.) - { - std::ostringstream os; - os << "Double value " << val << " can't be considered as integer. Not admitable for units !"; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - _value[0]=0; - _value[1]=0; - _value[2]=0; - _value[3]=0; - _value[4]=0; - _add_to_base=0; - _mult_fact_to_base=valI; -} - -DecompositionInUnitBase &DecompositionInUnitBase::operator*(const DecompositionInUnitBase& other) -{ - _value[0]+=other._value[0]; _value[1]+=other._value[1]; _value[2]+=other._value[2]; _value[3]+=other._value[3]; _value[4]+=other._value[4]; - _mult_fact_to_base*=other._mult_fact_to_base; - _add_to_base=0.; - return *this; -} - -DecompositionInUnitBase &DecompositionInUnitBase::operator/(const DecompositionInUnitBase& other) -{ - _value[0]-=other._value[0]; _value[1]-=other._value[1]; _value[2]-=other._value[2]; _value[3]-=other._value[3]; _value[4]-=other._value[4]; - _mult_fact_to_base/=other._mult_fact_to_base; - _add_to_base=0.; - return *this; -} - -DecompositionInUnitBase &DecompositionInUnitBase::operator^(const DecompositionInUnitBase& other) throw(INTERP_KERNEL::Exception) -{ - if(!other.isAdimensional()) - throw INTERP_KERNEL::Exception("Trying to execute operator ^ with a second member not adimensionnal"); - int exp=couldItBeConsideredAsInt(other._mult_fact_to_base); - _value[0]*=exp; _value[1]*=exp; _value[2]*=exp; _value[3]*=exp; _value[4]*=exp; - _mult_fact_to_base=powInt(_mult_fact_to_base,exp); - _add_to_base=0.; - return *this; -} - -void DecompositionInUnitBase::dealWithAddFactor(const DecompositionInUnitBase& other) -{ - if(!areDoubleEquals(_add_to_base,0.)) - if(other.isAdimensional()) - if(areDoubleEquals(other._mult_fact_to_base,1.)) - return ; - if(!other.areDoubleEquals(_add_to_base,0.)) - if(isAdimensional()) - if(areDoubleEquals(_mult_fact_to_base,1.)) - return ; - _add_to_base=0.; -} - -double DecompositionInUnitBase::powInt(double val, int exp) -{ - double work=1.; - if(exp==0) - return 1.; - if(exp>0) - for(int i=0;i::max(); -} - -std::string Unit::getCoarseRepr() const -{ - return _coarse_repr; -} diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx deleted file mode 100644 index 1c5b50ee8..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELUNIT_HXX__ -#define __INTERPKERNELUNIT_HXX__ - -#include "INTERPKERNELEXPREVALDefines.hxx" -#include "InterpKernelException.hxx" - -#include -#include - -namespace INTERP_KERNEL -{ - class INTERPKERNELEXPREVAL_EXPORT UnitDataBase - { - public: - UnitDataBase(); - const short *getInfoForUnit(const std::string& unit, - double& addFact, double& mFact) const throw(INTERP_KERNEL::Exception); - static UnitDataBase _uniqueMapForExpr; - static const int SIZE_OF_UNIT_BASE=5; - private: - std::map _prefix_pow_10; - std::map _units_semantic; - std::map _units_mul; - std::map _units_add; - private: - static const int NB_OF_PREF_POW10=22; - static const char *PREF_POW10[NB_OF_PREF_POW10]; - static const double POW10[NB_OF_PREF_POW10]; - static const int NB_OF_UNITS_RECOGN=29; - static const char *UNITS_RECOGN[NB_OF_UNITS_RECOGN]; - static const short PROJ_IN_BASE[NB_OF_UNITS_RECOGN][SIZE_OF_UNIT_BASE]; - static const double MUL_COEFF[NB_OF_UNITS_RECOGN]; - static const double ADD_COEFF[NB_OF_UNITS_RECOGN]; - }; - - class INTERPKERNELEXPREVAL_EXPORT DecompositionInUnitBase - { - public: - DecompositionInUnitBase(); - void setInfo(const short *vals, double addFact, double mFact); - short operator[](int i) const { return _value[i]; } - bool operator==(const DecompositionInUnitBase& other) const; - void getTranslationParams(const DecompositionInUnitBase& other, double& mul, double& add) const; - bool isEqual(short mass, short lgth, short time, short intensity, short temp, - double add, double mult); - bool isUnitary() const; - //! \b WARNING no test is done on the fact that unit is adimensionnal. - void negate(); - bool isAdimensional() const; - void tryToConvertInUnit(double val) throw(INTERP_KERNEL::Exception); - DecompositionInUnitBase &operator*(const DecompositionInUnitBase& other); - DecompositionInUnitBase &operator/(const DecompositionInUnitBase& other); - DecompositionInUnitBase &operator^(const DecompositionInUnitBase& other) throw(INTERP_KERNEL::Exception); - private: - void dealWithAddFactor(const DecompositionInUnitBase& other); - static int couldItBeConsideredAsInt(double val) throw(INTERP_KERNEL::Exception); - static bool areDoubleEquals(double a, double b); - static double powInt(double val, int exp); - private: - short _value[UnitDataBase::SIZE_OF_UNIT_BASE]; - double _add_to_base; - double _mult_fact_to_base; - }; - - /*! - * This class deals with units. - * This class has two main responsabilities : - * - interprete units by giving simply their representation in string type. - * - performing operations on these units. - * - * All the possible units are represented with a unique tuple with 5 elements - * representing the unique decomposition of a unit in the following base. - * - * dimension 0 stands for mass in g (\b NOT kg to simplify parsing). - * dimension 1 stands for length in m. - * dimension 2 stands for time in s. - * dimension 3 stands for elec intensity A. - * dimension 4 stands for temperature in K. - */ - class INTERPKERNELEXPREVAL_EXPORT Unit - { - public: - Unit(const char *reprC, bool tryToInterp=true); - Unit(const char *reprFortran, int sizeOfRepr, bool tryToInterp=true); - void tryToInterprate() const; - bool isInterpretationOK() const; - bool isCompatibleWith(const Unit& other) const; - double convert(const Unit& target, double sourceVal) const; - std::string getCoarseRepr() const; - private: - std::string _coarse_repr; - mutable bool _is_interpreted; - mutable bool _is_interpretation_ok; - mutable DecompositionInUnitBase _decomp_in_base; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx deleted file mode 100644 index 5e3bcfe19..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx +++ /dev/null @@ -1,425 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelValue.hxx" -#include "InterpKernelFunction.hxx" - -#include -#include -#include - -using namespace INTERP_KERNEL; - -ValueDouble::ValueDouble():_data(std::numeric_limits::max()) -{ -} - -Value *ValueDouble::newInstance() const -{ - return new ValueDouble; -} - -ValueDouble::ValueDouble(double val):_data(val) -{ -} - -void ValueDouble::setDouble(double val) throw(INTERP_KERNEL::Exception) -{ - _data=val; -} - -void ValueDouble::setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception) -{ - std::string msg("Error var : "); msg+=var; msg+=" not numeric : use another expression evaluator !"; - throw INTERP_KERNEL::Exception(msg.c_str()); -} - -void ValueDouble::positive() throw(INTERP_KERNEL::Exception) -{ -} - -void ValueDouble::negate() throw(INTERP_KERNEL::Exception) -{ - _data=-_data; -} - -void ValueDouble::sqrt() throw(INTERP_KERNEL::Exception) -{ - _data=std::sqrt(_data); -} - -void ValueDouble::cos() throw(INTERP_KERNEL::Exception) -{ - _data=std::cos(_data); -} - -void ValueDouble::sin() throw(INTERP_KERNEL::Exception) -{ - _data=std::sin(_data); -} - -void ValueDouble::tan() throw(INTERP_KERNEL::Exception) -{ - _data=std::tan(_data); -} - -void ValueDouble::abs() throw(INTERP_KERNEL::Exception) -{ - if(_data<0.) - _data=-_data; -} - -void ValueDouble::exp() throw(INTERP_KERNEL::Exception) -{ - _data=std::exp(_data); -} - -void ValueDouble:: ln() throw(INTERP_KERNEL::Exception) -{ - _data=std::log(_data); -} - -Value *ValueDouble::plus(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=checkSameType(other); - return new ValueDouble(_data+valC->_data); -} - -Value *ValueDouble::minus(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=checkSameType(other); - return new ValueDouble(_data-valC->_data); -} - -Value *ValueDouble::mult(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=checkSameType(other); - return new ValueDouble(_data*valC->_data); -} - -Value *ValueDouble::div(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=checkSameType(other); - return new ValueDouble(_data/valC->_data); -} - -Value *ValueDouble::pow(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=checkSameType(other); - return new ValueDouble(std::pow(_data,valC->_data)); -} - -Value *ValueDouble::max(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=checkSameType(other); - return new ValueDouble(std::max(_data,valC->_data)); -} - -Value *ValueDouble::min(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=checkSameType(other); - return new ValueDouble(std::min(_data,valC->_data)); -} - -const ValueDouble *ValueDouble::checkSameType(const Value *val) throw(INTERP_KERNEL::Exception) -{ - const ValueDouble *valC=dynamic_cast(val); - if(!valC) - throw INTERP_KERNEL::Exception("Trying to operate on non homogeneous Values (double with other type) !"); - return valC; -} - -ValueUnit::ValueUnit() -{ -} - -Value *ValueUnit::newInstance() const -{ - return new ValueUnit; -} - -ValueUnit::ValueUnit(const DecompositionInUnitBase& unit):_data(unit) -{ -} - -void ValueUnit::setDouble(double val) throw(INTERP_KERNEL::Exception) -{ - _data.tryToConvertInUnit(val); -} - -void ValueUnit::setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception) -{ - double add,mult; - const short *projInBase=UnitDataBase::_uniqueMapForExpr.getInfoForUnit(var,add,mult); - _data.setInfo(projInBase,add,mult); -} - -void ValueUnit::positive() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(PositiveFunction::REPR); -} - -void ValueUnit::negate() throw(INTERP_KERNEL::Exception) -{ - _data.negate(); -} - -void ValueUnit::sqrt() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(SqrtFunction::REPR); -} - -void ValueUnit::cos() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(CosFunction::REPR); -} - -void ValueUnit::sin() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(SinFunction::REPR); -} - -void ValueUnit::tan() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(TanFunction::REPR); -} - -void ValueUnit::abs() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(AbsFunction::REPR); -} - -void ValueUnit::exp() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(ExpFunction::REPR); -} - -void ValueUnit::ln() throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(LnFunction::REPR); -} - -Value *ValueUnit::plus(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(PlusFunction::REPR); - return 0; -} - -Value *ValueUnit::minus(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(MinusFunction::REPR); - return 0; -} - -Value *ValueUnit::mult(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueUnit *valC=checkSameType(other); - DecompositionInUnitBase tmp=_data; - tmp*valC->getData(); - return new ValueUnit(tmp); -} - -Value *ValueUnit::div(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueUnit *valC=checkSameType(other); - DecompositionInUnitBase tmp=_data; - tmp/valC->getData(); - return new ValueUnit(tmp); -} - -Value *ValueUnit::pow(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueUnit *valC=checkSameType(other); - DecompositionInUnitBase tmp=_data; - tmp^valC->getData(); - return new ValueUnit(tmp); -} - -Value *ValueUnit::max(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(MaxFunction::REPR); - return 0; -} - -Value *ValueUnit::min(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - unsupportedOp(MinFunction::REPR); - return 0; -} - -const ValueUnit *ValueUnit::checkSameType(const Value *val) throw(INTERP_KERNEL::Exception) -{ - const ValueUnit *valC=dynamic_cast(val); - if(!valC) - throw INTERP_KERNEL::Exception("Trying to operate on non homogeneous Values (Units with other type) !"); - return valC; -} - -void ValueUnit::unsupportedOp(const char *type) throw(INTERP_KERNEL::Exception) -{ - const char msg[]="Unsupported operation for units :"; - std::string msgStr(msg); - msgStr+=type; - throw INTERP_KERNEL::Exception(msgStr.c_str()); -} - -ValueDoubleExpr::ValueDoubleExpr(int szDestData, const double *srcData):_sz_dest_data(szDestData),_dest_data(new double[_sz_dest_data]),_src_data(srcData) -{ -} - -ValueDoubleExpr::~ValueDoubleExpr() -{ - delete [] _dest_data; -} - -Value *ValueDoubleExpr::newInstance() const -{ - return new ValueDoubleExpr(_sz_dest_data,_src_data); -} - -void ValueDoubleExpr::setDouble(double val) throw(INTERP_KERNEL::Exception) -{ - std::fill(_dest_data,_dest_data+_sz_dest_data,val); -} - -void ValueDoubleExpr::setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception) -{ - if(fastPos==-2) - std::copy(_src_data,_src_data+_sz_dest_data,_dest_data); - else if(fastPos>-2) - std::fill(_dest_data,_dest_data+_sz_dest_data,_src_data[fastPos]); - else - { - std::fill(_dest_data,_dest_data+_sz_dest_data,0.); - _dest_data[-7-fastPos]=1.; - } -} - -void ValueDoubleExpr::positive() throw(INTERP_KERNEL::Exception) -{ -} - -void ValueDoubleExpr::negate() throw(INTERP_KERNEL::Exception) -{ - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::negate()); -} - -void ValueDoubleExpr::sqrt() throw(INTERP_KERNEL::Exception) -{ - double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less(),0.)); - if(it!=_dest_data+_sz_dest_data) - throw INTERP_KERNEL::Exception("Trying to apply sqrt on < 0. value !"); - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::sqrt)); -} - -void ValueDoubleExpr::cos() throw(INTERP_KERNEL::Exception) -{ - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::cos)); -} - -void ValueDoubleExpr::sin() throw(INTERP_KERNEL::Exception) -{ - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::sin)); -} - -void ValueDoubleExpr::tan() throw(INTERP_KERNEL::Exception) -{ - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::tan)); -} - -void ValueDoubleExpr::abs() throw(INTERP_KERNEL::Exception) -{ - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(fabs)); -} - -void ValueDoubleExpr::exp() throw(INTERP_KERNEL::Exception) -{ - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::exp)); -} - -void ValueDoubleExpr::ln() throw(INTERP_KERNEL::Exception) -{ - double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less_equal(),0.)); - if(it!=_dest_data+_sz_dest_data) - throw INTERP_KERNEL::Exception("Trying to apply sqrt on < 0. value !"); - std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::log)); -} - -Value *ValueDoubleExpr::plus(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); - std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::plus()); - return ret; -} - -Value *ValueDoubleExpr::minus(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); - std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::minus()); - return ret; -} - -Value *ValueDoubleExpr::mult(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); - std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::multiplies()); - return ret; -} - -Value *ValueDoubleExpr::div(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDoubleExpr *otherC=static_cast(other); - double *it=std::find(otherC->getData(),otherC->getData()+_sz_dest_data,0.); - if(it!=otherC->getData()+_sz_dest_data) - throw INTERP_KERNEL::Exception("Trying to operate division by 0. !"); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); - std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::divides()); - return ret; -} - -Value *ValueDoubleExpr::pow(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDoubleExpr *otherC=static_cast(other); - double p=otherC->getData()[0]; - double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less(),0.)); - if(it!=_dest_data+_sz_dest_data) - throw INTERP_KERNEL::Exception("Trying to operate pow(a,b) with a<0. !"); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); - std::transform(_dest_data,_dest_data+_sz_dest_data,ret->getData(),std::bind2nd(std::ptr_fun(std::pow),p)); - return ret; -} - -Value *ValueDoubleExpr::max(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); - std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::ptr_fun(std::max)); - return ret; -} - -Value *ValueDoubleExpr::min(const Value *other) const throw(INTERP_KERNEL::Exception) -{ - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); - std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::ptr_fun(std::min)); - return ret; -} diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx deleted file mode 100644 index 95ac2e66b..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELVALUE_HXX__ -#define __INTERPKERNELVALUE_HXX__ - -#include "INTERPKERNELEXPREVALDefines.hxx" -#include "InterpKernelException.hxx" -#include "InterpKernelUnit.hxx" - -namespace INTERP_KERNEL -{ - class INTERPKERNELEXPREVAL_EXPORT Value - { - public: - virtual Value *newInstance() const = 0; - virtual ~Value() { } - virtual void setDouble(double val) throw(INTERP_KERNEL::Exception) = 0; - virtual void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception) = 0; - //unary - virtual void positive() throw(INTERP_KERNEL::Exception) = 0; - virtual void negate() throw(INTERP_KERNEL::Exception) = 0; - virtual void sqrt() throw(INTERP_KERNEL::Exception) = 0; - virtual void cos() throw(INTERP_KERNEL::Exception) = 0; - virtual void sin() throw(INTERP_KERNEL::Exception) = 0; - virtual void tan() throw(INTERP_KERNEL::Exception) = 0; - virtual void abs() throw(INTERP_KERNEL::Exception) = 0; - virtual void exp() throw(INTERP_KERNEL::Exception) = 0; - virtual void ln() throw(INTERP_KERNEL::Exception) = 0; - //binary - virtual Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual Value *div(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual Value *max(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual Value *min(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; - }; - - class INTERPKERNELEXPREVAL_EXPORT ValueDouble : public Value - { - public: - ValueDouble(); - Value *newInstance() const; - void setDouble(double val) throw(INTERP_KERNEL::Exception); - void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception); - // - double getData() const { return _data; } - void positive() throw(INTERP_KERNEL::Exception); - void negate() throw(INTERP_KERNEL::Exception); - void sqrt() throw(INTERP_KERNEL::Exception); - void cos() throw(INTERP_KERNEL::Exception); - void sin() throw(INTERP_KERNEL::Exception); - void tan() throw(INTERP_KERNEL::Exception); - void abs() throw(INTERP_KERNEL::Exception); - void exp() throw(INTERP_KERNEL::Exception); - void ln() throw(INTERP_KERNEL::Exception); - // - Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *div(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *max(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *min(const Value *other) const throw(INTERP_KERNEL::Exception); - private: - ValueDouble(double val); - static const ValueDouble *checkSameType(const Value *val) throw(INTERP_KERNEL::Exception); - private: - double _data; - }; - - class INTERPKERNELEXPREVAL_EXPORT ValueUnit : public Value - { - public: - ValueUnit(); - Value *newInstance() const; - void setDouble(double val) throw(INTERP_KERNEL::Exception); - void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception); - // - DecompositionInUnitBase getData() const { return _data; } - void positive() throw(INTERP_KERNEL::Exception); - void negate() throw(INTERP_KERNEL::Exception); - void sqrt() throw(INTERP_KERNEL::Exception); - void cos() throw(INTERP_KERNEL::Exception); - void sin() throw(INTERP_KERNEL::Exception); - void tan() throw(INTERP_KERNEL::Exception); - void abs() throw(INTERP_KERNEL::Exception); - void exp() throw(INTERP_KERNEL::Exception); - void ln() throw(INTERP_KERNEL::Exception); - // - Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *div(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *max(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *min(const Value *other) const throw(INTERP_KERNEL::Exception); - private: - ValueUnit(const DecompositionInUnitBase& unit); - static void unsupportedOp(const char *type) throw(INTERP_KERNEL::Exception); - static const ValueUnit *checkSameType(const Value *val) throw(INTERP_KERNEL::Exception); - private: - DecompositionInUnitBase _data; - }; - - class INTERPKERNELEXPREVAL_EXPORT ValueDoubleExpr : public Value - { - public: - ValueDoubleExpr(int szDestData, const double *srcData); - ~ValueDoubleExpr(); - double *getData() const { return _dest_data; } - Value *newInstance() const; - void setDouble(double val) throw(INTERP_KERNEL::Exception); - void setVarname(int fastPos, const std::string& var) throw(INTERP_KERNEL::Exception); - // - void positive() throw(INTERP_KERNEL::Exception); - void negate() throw(INTERP_KERNEL::Exception); - void sqrt() throw(INTERP_KERNEL::Exception); - void cos() throw(INTERP_KERNEL::Exception); - void sin() throw(INTERP_KERNEL::Exception); - void tan() throw(INTERP_KERNEL::Exception); - void abs() throw(INTERP_KERNEL::Exception); - void exp() throw(INTERP_KERNEL::Exception); - void ln() throw(INTERP_KERNEL::Exception); - // - Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *mult(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *div(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *max(const Value *other) const throw(INTERP_KERNEL::Exception); - Value *min(const Value *other) const throw(INTERP_KERNEL::Exception); - private: - int _sz_dest_data; - double *_dest_data; - const double *_src_data; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/ExprEval/Makefile.am b/src/INTERP_KERNEL/ExprEval/Makefile.am deleted file mode 100644 index 28f5e9124..000000000 --- a/src/INTERP_KERNEL/ExprEval/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (C) 2007-2010 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 : Makefile.am -# Author : Anthony GEAY (CEA/DEN/DANS/DM2S/SFME/LGLS) -# Module : MED -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -noinst_LTLIBRARIES = libinterpkernelexpreval.la - -salomeinclude_HEADERS = \ -INTERPKERNELEXPREVALDefines.hxx \ -InterpKernelExprParser.hxx \ -InterpKernelFunction.hxx \ -InterpKernelUnit.hxx \ -InterpKernelValue.hxx \ -InterpKernelAsmX86.hxx - -EXTRA_DIST += \ -INTERPKERNELEXPREVALDefines.hxx \ -InterpKernelExprParser.hxx \ -InterpKernelFunction.hxx \ -InterpKernelUnit.hxx \ -InterpKernelValue.hxx - -dist_libinterpkernelexpreval_la_SOURCES = \ - InterpKernelExprParser.cxx \ - InterpKernelFunction.cxx \ - InterpKernelUnit.cxx \ - InterpKernelValue.cxx \ - InterpKernelAsmX86.cxx - -libinterpkernelexpreval_la_CPPFLAGS=-I$(srcdir)/../Bases - -libinterpkernelexpreval_la_LDFLAGS= - -AM_CPPFLAGS += $(libinterpkernelexpreval_la_CPPFLAGS) - -LDADD= $(libinterpkernelexpreval_la_LDFLAGS) diff --git a/src/INTERP_KERNEL/GenMathFormulae.hxx b/src/INTERP_KERNEL/GenMathFormulae.hxx deleted file mode 100644 index 42ce4f43f..000000000 --- a/src/INTERP_KERNEL/GenMathFormulae.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2007-2010 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 __GENMATHFORMULAE_HXX__ -#define __GENMATHFORMULAE_HXX__ - -#include "InterpKernelException.hxx" - -#include - -namespace INTERP_KERNEL -{ - /*! - * This method computes eigenvalues of a 3x3 symetric matrix stored with 6 values in 'matrix'. The convension chosen for 'matrix' is described here: - * matrix[0]=m_xx, matrix[1]=m_yy, matrix[2]=m_zz, - * matrix[3]=m_xy, matrix[4]=m_yz, matrix[5]=m_xz - * This method returns the 3 eigenvalues in 'eigenVals'. - */ - void computeEigenValues6(const double *matrix, double *eigenVals) - { - double tr=(matrix[0]+matrix[1]+matrix[2])/3.; - double K[6]={matrix[0]-tr,matrix[1]-tr,matrix[2]-tr,matrix[3],matrix[4],matrix[5]}; - double q=(K[0]*K[1]*K[2]+2.*K[4]*K[5]*K[3]-K[0]*K[4]*K[4]-K[2]*K[3]*K[3]-K[1]*K[5]*K[5])/2.; - double p=K[0]*K[0]+K[1]*K[1]+K[2]*K[2]+2*(K[3]*K[3]+K[4]*K[4]+K[5]*K[5]); - p/=6.; - double sqp=sqrt(p); - double tmp=p*sqp; - double phi; - if(fabs(q)<=fabs(tmp)) - phi=1./3.*acos(q/tmp); - else - phi=0.; - if(phi<0.) - phi+=M_PI/3.; - eigenVals[0]=tr+2.*sqp*cos(phi); - eigenVals[1]=tr-sqp*(cos(phi)+sqrt(3.)*sin(phi)); - eigenVals[2]=tr-sqp*(cos(phi)-sqrt(3.)*sin(phi)); - } - - /*! - * This method computes one eigenvector of a 3x3 symetric matrix stored with 6 values in 'matrix'. The convension chosen for 'matrix' is described here: - * matrix[0]=m_xx, matrix[1]=m_yy, matrix[2]=m_zz, - * matrix[3]=m_xy, matrix[4]=m_yz, matrix[5]=m_xz - * This method returns the eigenvector of the corresponding eigenvalue in 'eigenVal'. The returned eigenValue is normalized. - */ - void computeEigenVectorForEigenValue6(const double *matrix, double eigenVal, double eps, double *eigenVector) throw(INTERP_KERNEL::Exception) - { - //if(fabs(eigenVal)>eps) - { - const double m9[9]={matrix[0]-eigenVal,matrix[3],matrix[5],matrix[3],matrix[1]-eigenVal,matrix[4],matrix[5],matrix[4],matrix[2]-eigenVal}; - for(int i=0;i<3;i++) - { - double w[9]={m9[0+3*i],m9[1+3*i],m9[2+3*i],m9[0+(3*(i+1))%6],m9[1+(3*(i+1))%6],m9[2+(3*(i+1))%6],1.,1.,1.}; - double det=w[0]*w[4]*w[8]+w[1]*w[5]*w[6]+w[2]*w[3]*w[7]-w[0]*w[5]*w[7]-w[1]*w[3]*w[8]-w[2]*w[4]*w[6]; - if(fabs(det)>eps) - { - eigenVector[0]=(w[1]*w[5]-w[4]*w[2])/det; - eigenVector[1]=(w[2]*w[3]-w[0]*w[5])/det; - eigenVector[2]=(w[0]*w[4]-w[1]*w[3])/det; - double norm=sqrt(eigenVector[0]*eigenVector[0]+eigenVector[1]*eigenVector[1]+eigenVector[2]*eigenVector[2]); - eigenVector[0]/=norm; - eigenVector[1]/=norm; - eigenVector[2]/=norm; - return; - } - } - } - //else - { - eigenVector[0]=0.; - eigenVector[1]=0.; - eigenVector[2]=0.; - return; - } - //throw INTERP_KERNEL::Exception("computeEigenVector : Do not succed in finding eigen vector !"); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx b/src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx deleted file mode 100644 index 2909cb9d8..000000000 --- a/src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEOMETRIC2DDEFINES_HXX__ -#define __INTERPKERNELGEOMETRIC2DDEFINES_HXX__ - -//export symbols -// #ifdef WIN32 -// # if defined INTERPKERNELGEOMETRIC2D_EXPORTS || defined InterpGeometric2DAlg_EXPORTS -// # define INTERPKERNELGEOMETRIC2D_EXPORT __declspec(dllexport) -// # else -// # define INTERPKERNELGEOMETRIC2D_EXPORT __declspec(dllimport) -// # endif -// #else -// # define INTERPKERNELGEOMETRIC2D_EXPORT -// #endif - -#define INTERPKERNELGEOMETRIC2D_EXPORT - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx deleted file mode 100644 index c92bf3014..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DAbstractEdge.hxx" -#include "InterpKernelGeo2DComposedEdge.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" - -using namespace INTERP_KERNEL; - -IteratorOnComposedEdge::IteratorOnComposedEdge():_list_handle(0) -{ -} - -IteratorOnComposedEdge::IteratorOnComposedEdge(ComposedEdge *compEdges):_list_handle(compEdges->getListBehind()) -{ - first(); -} - -void IteratorOnComposedEdge::operator=(const IteratorOnComposedEdge& other) -{ - _deep_it=other._deep_it; - _list_handle=other._list_handle; -} - -void IteratorOnComposedEdge::last() -{ - _deep_it=_list_handle->end(); - _deep_it--; -} - -void IteratorOnComposedEdge::nextLoop() -{ - _deep_it++; - if(_deep_it==_list_handle->end()) - first(); -} - -void IteratorOnComposedEdge::previousLoop() -{ - if(_deep_it!=_list_handle->begin()) - _deep_it--; - else - last(); -} - -bool IteratorOnComposedEdge::goToNextInOn(bool direction, int& i, int nbMax) -{ - TypeOfEdgeLocInPolygon loc=current()->getLoc(); - if(direction) - { - while(loc==FULL_OUT_1 && igetLoc(); - } - if(i==nbMax) - return false; - return true; - } - else - { - while(loc==FULL_OUT_1 && igetLoc(); - } - if(i==nbMax) - return false; - while(loc!=FULL_OUT_1 && igetLoc(); - } - nextLoop(); i--; - return true; - } -} - -void IteratorOnComposedEdge::assignMySelfToAllElems(ComposedEdge *elems) -{ - std::list *myList=elems->getListBehind(); - for(std::list::iterator iter=myList->begin();iter!=myList->end();iter++) - (*iter)->getIterator()=(*this); -} - -void IteratorOnComposedEdge::insertElemEdges(ComposedEdge *elems, bool changeMySelf) -{ - std::list *myListToInsert=elems->getListBehind(); - std::list::iterator iter=myListToInsert->begin(); - *_deep_it=*iter; - _deep_it++; - iter++; - int sizeOfMyList=myListToInsert->size(); - _list_handle->insert(_deep_it,iter,myListToInsert->end()); - if(!changeMySelf) - { - for(int i=0;i -#include -#include - -namespace INTERP_KERNEL -{ - class Edge; - class Node; - class Bounds; - - class ComposedEdge; - class ElementaryEdge; - - /*! - * Asumption is done with this iterator that we iterate on a container containing more than one edge. - */ - class INTERPKERNELGEOMETRIC2D_EXPORT IteratorOnComposedEdge - { - friend class ComposedEdge; - friend class ElementaryEdge; - friend class QuadraticPolygon; - public: - IteratorOnComposedEdge(); - IteratorOnComposedEdge(ComposedEdge *compEdges); - bool isValid() const { return _list_handle!=0; } - void operator=(const IteratorOnComposedEdge& other); - void first() { _deep_it=_list_handle->begin(); } - void next() { _deep_it++; } - void last(); - void nextLoop(); - void previousLoop(); - bool finished() const { return _deep_it==_list_handle->end(); } - bool goToNextInOn(bool direction, int& i, int nbMax); - ElementaryEdge *current() { return *_deep_it; } - void assignMySelfToAllElems(ComposedEdge *elems); - void insertElemEdges(ComposedEdge *elems, bool changeMySelf); - private: - std::list::iterator _deep_it; - std::list* _list_handle; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx deleted file mode 100644 index 7b0187162..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DBounds.hxx" -#include "InterpKernelException.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DNode.hxx" - -using namespace INTERP_KERNEL; - -const double& Bounds::operator[](int i) const -{ - switch(i) - { - case 0: - return _x_min; - case 1: - return _x_max; - case 2: - return _y_min; - case 3: - return _y_max; - } - throw Exception("internal error occurs !"); -} - -double &Bounds::operator[](int i) -{ - switch(i) - { - case 0: - return _x_min; - case 1: - return _x_max; - case 2: - return _y_min; - case 3: - return _y_max; - } - throw Exception("internal error occurs !"); -} - -double Bounds::getDiagonal() const -{ - double a=_x_max-_x_min; - double b=_y_max-_y_min; - return sqrt(a*a+b*b); -} - -/*! - * See Node::applySimilarity to see signification of params. - */ -void Bounds::applySimilarity(double xBary, double yBary, double dimChar) -{ - _x_min=(_x_min-xBary)/dimChar; - _x_max=(_x_max-xBary)/dimChar; - _y_min=(_y_min-yBary)/dimChar; - _y_max=(_y_max-yBary)/dimChar; -} - -void Bounds::getBarycenter(double& xBary, double& yBary) const -{ - xBary=(_x_min+_x_max)/2.; - yBary=(_y_max+_y_min)/2.; -} - -void Bounds::prepareForAggregation() -{ - _x_min=1e200; _x_max=-1e200; _y_min=1e200; _y_max=-1e200; -} - -/*! - * Given an arc defined by 'center', 'radius' and 'intrcptArcDelta' in radian, returns (by outputs intrcptArcAngle0 and intrcptArcDelta) - * the intercepted angle of 'this' from 'center' point of view. - * If diagonal of 'this' is the same order of 2*radius, intrcptArcAngle0 and intrcptArcDelta remains unchanged. - * @param center IN parameter. - * @param radius IN parameter. - * @param intrcptArcAngle0 OUT parameter. - * @param intrcptArcDelta IN/OUT parameter. - */ -void Bounds::getInterceptedArc(const double *center, double radius, double& intrcptArcAngle0, double& intrcptArcDelta) const -{ - double diag=getDiagonal(); - if(diag<2.*radius) - { - double v1[2],v2[2],w1[2],w2[2]; - v1[0]=_x_min-center[0]; v1[1]=_y_max-center[1]; v2[0]=_x_max-center[0]; v2[1]=_y_min-center[1]; - w1[0]=v1[0]; w1[1]=_y_min-center[1]; w2[0]=v2[0]; w2[1]=_y_max-center[1]; - double delta1=EdgeArcCircle::safeAsin(v1[0]*v2[1]-v1[1]*v2[0]); - double delta2=EdgeArcCircle::safeAsin(w1[0]*w2[1]-w1[1]*w2[0]); - double tmp; - if(fabs(delta1)>fabs(delta2)) - { - intrcptArcDelta=delta1; - intrcptArcAngle0=EdgeArcCircle::getAbsoluteAngle(v1,tmp); - } - else - { - intrcptArcDelta=delta2; - intrcptArcAngle0=EdgeArcCircle::getAbsoluteAngle(w1,tmp); - } - } -} - -double Bounds::fitXForXFigD(double val, int res) const -{ - double delta=std::max(_x_max-_x_min,_y_max-_y_min)/2.; - double ret=val-(_x_max+_x_min)/2.+delta; - delta=11.1375*res/(2.*delta); - return ret*delta; -} - -double Bounds::fitYForXFigD(double val, int res) const -{ - double delta=std::max(_x_max-_x_min,_y_max-_y_min)/2.; - double ret=val-(_y_max+_y_min)/2.+delta; - delta=11.1375*res/(2.*delta); - return ret*delta; -} - -Bounds *Bounds::nearlyAmIIntersectingWith(const Bounds& other) const -{ - if( (other._x_min > _x_max+QUADRATIC_PLANAR::_precision) || (other._x_max < _x_min-QUADRATIC_PLANAR::_precision) || (other._y_min > _y_max+QUADRATIC_PLANAR::_precision) - || (other._y_max < _y_min-QUADRATIC_PLANAR::_precision) ) - return 0; - if( (other._x_min >= _x_max ) || (other._x_max <= _x_min) || (other._y_min >= _y_max) || (other._y_max <= _y_min) ) - return new Bounds(std::max(_x_min-QUADRATIC_PLANAR::_precision,other._x_min), - std::min(_x_max+QUADRATIC_PLANAR::_precision,other._x_max), - std::max(_y_min-QUADRATIC_PLANAR::_precision,other._y_min), - std::min(_y_max+QUADRATIC_PLANAR::_precision,other._y_max));//In approx cases. - else - return new Bounds(std::max(_x_min,other._x_min),std::min(_x_max,other._x_max),std::max(_y_min,other._y_min),std::min(_y_max,other._y_max)); -} - -Bounds *Bounds::amIIntersectingWith(const Bounds& other) const -{ - if( (other._x_min > _x_max) || (other._x_max < _x_min) || (other._y_min > _y_max) || (other._y_max < _y_min) ) - return 0; - return new Bounds(std::max(_x_min,other._x_min),std::min(_x_max,other._x_max),std::max(_y_min,other._y_min),std::min(_y_max,other._y_max)); -} - -Position Bounds::where(double x, double y) const -{ - if((x>=_x_min && x<=_x_max) && (y>=_y_min && y<=_y_max)) - return IN; - else - return OUT; -} - -Position Bounds::nearlyWhere(double x, double y) const -{ - bool thinX=Node::areDoubleEquals(_x_min,_x_max); - bool thinY=Node::areDoubleEquals(_y_min,_y_max); - if(!thinX) - { - if((Node::areDoubleEquals(x,_x_min) || Node::areDoubleEquals(x,_x_max)) && ((y<_y_max+QUADRATIC_PLANAR::_precision) && (y>_y_min-QUADRATIC_PLANAR::_precision))) - return ON_BOUNDARY_POS; - } - else - if(!Node::areDoubleEquals(_x_min,x) && !Node::areDoubleEquals(_x_max,x)) - return OUT; - if(!thinY) - { - if((Node::areDoubleEquals(y,_y_min) || Node::areDoubleEquals(y,_y_max)) && ((x<_x_max+QUADRATIC_PLANAR::_precision) && (x>_x_min-QUADRATIC_PLANAR::_precision))) - return ON_BOUNDARY_POS; - } - else - if(!Node::areDoubleEquals(_y_min,y) && !Node::areDoubleEquals(_y_max,y)) - return OUT; - if(thinX && thinY) - return ON_BOUNDARY_POS; - if((x>=_x_min && x<=_x_max) && (y>=_y_min && y<=_y_max)) - return IN; - else - return OUT; -} - -void Bounds::aggregate(const Bounds& other) -{ - _x_min=std::min(_x_min,other._x_min); _x_max=std::max(_x_max,other._x_max); - _y_min=std::min(_y_min,other._y_min); _y_max=std::max(_y_max,other._y_max); -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx deleted file mode 100644 index 4df244ba9..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DBOUNDS_HXX__ -#define __INTERPKERNELGEO2DBOUNDS_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" - -#include - -namespace INTERP_KERNEL -{ - /*! - * Relative LOC - */ - typedef enum - { - IN = 0, - OUT = 1, - ON_BOUNDARY_POS = 2, - ON_BOUNDARY_NEG = 3 - } Position; - - class INTERPKERNELGEOMETRIC2D_EXPORT Bounds - { - public: - Bounds():_x_min(0.),_x_max(0.),_y_min(0.),_y_max(0.) { } - double &operator[](int i); - const double& operator[](int i) const; - double getDiagonal() const; - void getBarycenter(double& xBary, double& yBary) const; - void applySimilarity(double xBary, double yBary, double dimChar); - Bounds& operator=(const Bounds& other) { _x_min=other._x_min; _x_max=other._x_max; _y_min=other._y_min; _y_max=other._y_max; return *this; } - Bounds(double xMin, double xMax, double yMin, double yMax):_x_min(xMin),_x_max(xMax),_y_min(yMin),_y_max(yMax) { } - void setValues(double xMin, double xMax, double yMin, double yMax) { _x_min=xMin; _x_max=xMax; _y_min=yMin; _y_max=yMax; } - void prepareForAggregation(); - void getInterceptedArc(const double *center, double radius, double& intrcptArcAngle0, double& intrcptArcDelta) const; - int fitXForXFig(double val, int res) const { return (int)fitXForXFigD(val,res); } - int fitYForXFig(double val, int res) const { return (int)fitYForXFigD(val,res); } - double fitXForXFigD(double val, int res) const; - double fitYForXFigD(double val, int res) const; - Bounds *nearlyAmIIntersectingWith(const Bounds& other) const; - Bounds *amIIntersectingWith(const Bounds& other) const; - //! No approximations. - Position where(double x, double y) const; - //! Idem where method but with approximations. - Position nearlyWhere(double x, double y) const; - void aggregate(const Bounds& other); - double getCaracteristicDim() const { return std::max(_x_max-_x_min,_y_max-_y_min); } - protected: - double _x_min; - double _x_max; - double _y_min; - double _y_max; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx deleted file mode 100644 index 6e13f3055..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ /dev/null @@ -1,459 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DComposedEdge.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" -#include "InterpKernelGeo2DEdgeInfLin.hxx" -#include "InterpKernelException.hxx" - -#include -#include -#include -#include - -using namespace INTERP_KERNEL; - -ComposedEdge::ComposedEdge(const ComposedEdge& other) -{ - for(std::list::const_iterator iter=other._sub_edges.begin();iter!=other._sub_edges.end();iter++) - _sub_edges.push_back((*iter)->clone()); -} - -ComposedEdge::~ComposedEdge() -{ - clearAll(_sub_edges.begin()); -} - -void ComposedEdge::setValueAt(int i, Edge *e, bool direction) -{ - std::list::iterator it=_sub_edges.begin(); - for(int j=0;jgetPtr()==_b1->getPtr();} - - ElementaryEdge *_b1; -}; - -double ComposedEdge::getCommonLengthWith(const ComposedEdge& other) const -{ - double ret=0.; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - { - if(find_if(other._sub_edges.begin(),other._sub_edges.end(),AbsEdgeCmp(*iter))!=other._sub_edges.end()) - { - const ElementaryEdge *tmp=static_cast(*iter); - ret+=tmp->getCurveLength(); - } - } - return ret; -} - -void ComposedEdge::clear() -{ - clearAll(_sub_edges.begin()); - _sub_edges.clear(); -} - -void ComposedEdge::pushBack(Edge *edge, bool direction) -{ - _sub_edges.push_back(new ElementaryEdge(edge,direction)); -} - -void ComposedEdge::pushBack(ElementaryEdge *elem) -{ - _sub_edges.push_back(elem); -} - -void ComposedEdge::pushBack(ComposedEdge *elem) -{ - std::list *elemsOfElem=elem->getListBehind(); - _sub_edges.insert(_sub_edges.end(),elemsOfElem->begin(),elemsOfElem->end()); -} - -ElementaryEdge *ComposedEdge::operator[](int i) const -{ - std::list::const_iterator iter=_sub_edges.begin(); - for(int ii=0;ii::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->reverse(); -} - -void ComposedEdge::initLocations() const -{ - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->initLocations(); -} - -ComposedEdge *ComposedEdge::clone() const -{ - return new ComposedEdge(*this); -} - -bool ComposedEdge::isNodeIn(Node *n) const -{ - bool ret=false; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end() && !ret;iter++) - ret=(*iter)->isNodeIn(n); - return ret; -} - -/*! - * This method computes the area of 'this'. - * By definition : - * \f[ - * Area=\int_{Polygon} dS - * \f] - * Thanks to Green's theorem we have. - * \f[ - * \int_{Polygon} x \cdot dS=\sum_{0 \leq i < nb of edges} -\int_{Edge_{i}}ydx=\sum_{0 \leq i < nb of edges} AreaOfZone_{Edge_{i}} - * \f] - * Where \f$ AreaOfZone_{i} \f$ is computed virtually by INTERP_KERNEL::Edge::getAreaOfZone with following formula : - * \f[ - * AreaOfZone_{i}=\int_{Edge_{i}} -ydx - * \f] - */ -double ComposedEdge::getArea() const -{ - double ret=0.; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - ret+=(*iter)->getAreaOfZone(); - return ret; -} - -double ComposedEdge::getPerimeter() const -{ - double ret=0.; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - ret+=(*iter)->getCurveLength(); - return ret; -} - -double ComposedEdge::getHydraulicDiameter() const -{ - return 4*fabs(getArea())/getPerimeter(); -} - -/*! - * This method computes barycenter of 'this' by returning xG in bary[0] and yG in bary[1]. - * By definition : - * \f[ - * Area \cdot x_{G}=\int_{Polygon} x \cdot dS - * \f] - * \f[ - * Area \cdot y_{G}=\int_{Polygon} y \cdot dS - * \f] - * Thanks to Green's theorem we have. - * \f[ - * \int_{Polygon} x \cdot dS=\sum_{0 \leq i < nb of edges} -\int_{Edge_{i}}yxdx - * \f] - * \f[ - * \int_{Polygon} y \cdot dS=\sum_{0 \leq i < nb of edges} -\int_{Edge_{i}}\frac{y^{2}}{2}dx - * \f] - * Area is computed using the same principle than described in INTERP_KERNEL::ComposedEdge::getArea method. - * \f$ -\int_{Edge_{i}}yxdx \f$ and \f$ -\int_{Edge_{i}}\frac{y^{2}}{2}dx \f$ are computed virtually with INTERP_KERNEL::Edge::getBarycenterOfZone. - */ -void ComposedEdge::getBarycenter(double *bary) const -{ - bary[0]=0.; - bary[1]=0.; - double area=0.; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - { - (*iter)->getBarycenterOfZone(bary); - area+=(*iter)->getAreaOfZone(); - } - bary[0]/=area; - bary[1]/=area; -} - -/*! - * Idem ComposedEdge::getBarycenter except that the special case where _sub_edges==1 is dealt here. - */ -void ComposedEdge::getBarycenterGeneral(double *bary) const -{ - if(_sub_edges.empty()) - throw INTERP_KERNEL::Exception("ComposedEdge::getBarycenterGeneral called on an empty polygon !"); - if(_sub_edges.size()>2) - return getBarycenter(bary); - double w; - _sub_edges.back()->getBarycenter(bary,w); -} - -double ComposedEdge::normalize(ComposedEdge *other, double& xBary, double& yBary) -{ - Bounds b; - b.prepareForAggregation(); - fillBounds(b); - other->fillBounds(b); - double dimChar=b.getCaracteristicDim(); - b.getBarycenter(xBary,yBary); - applyGlobalSimilarity(xBary,yBary,dimChar); - other->applyGlobalSimilarity(xBary,yBary,dimChar); - return dimChar; -} - -void ComposedEdge::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const -{ - stream.precision(10); - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->dumpInXfigFile(stream,resolution,box); -} - -Node *ComposedEdge::getEndNode() const -{ - return _sub_edges.back()->getEndNode(); -} - -Node *ComposedEdge::getStartNode() const -{ - return _sub_edges.front()->getStartNode(); -} - -bool ComposedEdge::changeEndNodeWith(Node *node) const -{ - return _sub_edges.back()->changeEndNodeWith(node); -} - -bool ComposedEdge::changeStartNodeWith(Node *node) const -{ - return _sub_edges.front()->changeStartNodeWith(node); -} - -void ComposedEdge::fillBounds(Bounds& output) const -{ - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->fillBounds(output); -} - -/*! - * \b WARNING : applies similarity \b ONLY on edges without any change on Nodes. To perform a global similarity call applyGlobalSimilarity. - */ -void ComposedEdge::applySimilarity(double xBary, double yBary, double dimChar) -{ - for(std::list::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->applySimilarity(xBary,yBary,dimChar); -} - -/*! - * Perform Similarity transformation on all elements of this Nodes and Edges. - */ -void ComposedEdge::applyGlobalSimilarity(double xBary, double yBary, double dimChar) -{ - std::set allNodes; - getAllNodes(allNodes); - for(std::set::iterator iter=allNodes.begin();iter!=allNodes.end();iter++) - (*iter)->applySimilarity(xBary,yBary,dimChar); - for(std::list::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->applySimilarity(xBary,yBary,dimChar); -} - -/*! - * This method append to param 'partConsidered' the part of length of subedges IN or ON. - * @param partConsidered INOUT param. - */ -void ComposedEdge::dispatchPerimeter(double& partConsidered) const -{ - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - { - TypeOfEdgeLocInPolygon loc=(*iter)->getLoc(); - if(loc==FULL_IN_1 || loc==FULL_ON_1) - partConsidered+=(*iter)->getCurveLength(); - } -} - -/*! - * Idem dispatchPerimeterExcl except that when a subedge is declared as ON this subedge is counted in commonPart. - */ -void ComposedEdge::dispatchPerimeterExcl(double& partConsidered, double& commonPart) const -{ - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - { - TypeOfEdgeLocInPolygon loc=(*iter)->getLoc(); - if(loc==FULL_IN_1) - partConsidered+=(*iter)->getCurveLength(); - if(loc==FULL_ON_1) - commonPart+=(*iter)->getCurveLength(); - } -} - -void ComposedEdge::getAllNodes(std::set& output) const -{ - std::list::const_iterator iter=_sub_edges.begin(); - for(;iter!=_sub_edges.end();iter++) - (*iter)->getAllNodes(output); -} - -void ComposedEdge::getBarycenter(double *bary, double& weigh) const -{ - weigh=0.; bary[0]=0.; bary[1]=0.; - double tmp1,tmp2[2]; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - { - (*iter)->getBarycenter(tmp2,tmp1); - weigh+=tmp1; - bary[0]+=tmp1*tmp2[0]; - bary[1]+=tmp1*tmp2[1]; - } - bary[0]/=weigh; - bary[1]/=weigh; -} - -bool ComposedEdge::isInOrOut(Node *nodeToTest) const -{ - Bounds b; b.prepareForAggregation(); - fillBounds(b); - if(b.nearlyWhere((*nodeToTest)[0],(*nodeToTest)[1])==OUT) - return false; - // searching for e1 - std::set nodes; - getAllNodes(nodes); - std::set radialDistributionOfNodes; - std::set::const_iterator iter; - for(iter=nodes.begin();iter!=nodes.end();iter++) - radialDistributionOfNodes.insert(nodeToTest->getSlope(*(*iter))); - std::vector radialDistrib(radialDistributionOfNodes.begin(),radialDistributionOfNodes.end()); - radialDistributionOfNodes.clear(); - std::vector radialDistrib2(radialDistrib.size()); - copy(radialDistrib.begin()+1,radialDistrib.end(),radialDistrib2.begin()); - radialDistrib2.back()=M_PI+radialDistrib.front(); - std::vector radialDistrib3(radialDistrib.size()); - std::transform(radialDistrib2.begin(),radialDistrib2.end(),radialDistrib.begin(),radialDistrib3.begin(),std::minus()); - std::vector::iterator iter3=max_element(radialDistrib3.begin(),radialDistrib3.end()); - int i=iter3-radialDistrib3.begin(); - // ok for e1 - Let's go. - EdgeInfLin *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.); - double ref=e1->getCharactValue(*nodeToTest); - std::set< IntersectElement > inOutSwitch; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - { - ElementaryEdge *val=(*iter); - if(val) - { - Edge *e=val->getPtr(); - std::auto_ptr intersc(Edge::buildIntersectorWith(e1,e)); - bool obviousNoIntersection,areOverlapped; - intersc->areOverlappedOrOnlyColinears(0,obviousNoIntersection,areOverlapped); - if(obviousNoIntersection) - { - continue; - } - if(!areOverlapped) - { - std::list< IntersectElement > listOfIntesc=intersc->getIntersectionsCharacteristicVal(); - for(std::list< IntersectElement >::iterator iter2=listOfIntesc.begin();iter2!=listOfIntesc.end();iter2++) - if((*iter2).isIncludedByBoth()) - inOutSwitch.insert(*iter2); - } - //if overlapped we can forget - } - else - throw Exception("Invalid use of ComposedEdge::isInOrOut : only one level supported !"); - } - e1->decrRef(); - bool ret=false; - for(std::set< IntersectElement >::iterator iter=inOutSwitch.begin();iter!=inOutSwitch.end();iter++) - { - if((*iter).getVal1()getLoc()==ON_1) - ret=!ret; - } - else - break; - } - return ret; -} - -/*bool ComposedEdge::isInOrOut(Node *aNodeOn, Node *nodeToTest) const -{ - - EdgeInfLin *e1=new EdgeInfLin(aNodeOn,nodeToTest); - double ref=e1->getCharactValue(*nodeToTest); - set< IntersectElement > inOutSwitch; - for(vector::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - { - ElementaryEdge *val=dynamic_cast(*iter); - if(val) - { - Edge *e=val->getPtr(); - auto_ptr intersc(Edge::buildIntersectorWith(e1,e)); - bool obviousNoIntersection,areOverlapped; - intersc->areOverlappedOrOnlyColinears(0,obviousNoIntersection,areOverlapped); - if(obviousNoIntersection) - { - continue; - } - if(!areOverlapped) - { - list< IntersectElement > listOfIntesc=intersc->getIntersectionsCharacteristicVal(); - for(list< IntersectElement >::iterator iter2=listOfIntesc.begin();iter2!=listOfIntesc.end();iter2++) - if((*iter2).isIncludedByBoth()) - inOutSwitch.insert(*iter2); - } - //if overlapped we can forget - } - else - throw Exception("Invalid use of ComposedEdge::isInOrOut : only one level supported !"); - } - e1->decrRef(); - bool ret=false; - for(set< IntersectElement >::iterator iter=inOutSwitch.begin();iter!=inOutSwitch.end();iter++) - { - if((*iter).getVal1()getLoc()==ON_1) - ret=!ret; - } - else - break; - } - return ret; -}*/ - -bool ComposedEdge::getDirection() const -{ - throw Exception("ComposedEdge::getDirection : no sense"); -} - -bool ComposedEdge::intresincEqCoarse(const Edge *other) const -{ - if(_sub_edges.size()!=1) - return false; - return _sub_edges.front()->intresincEqCoarse(other); -} - -void ComposedEdge::clearAll(std::list::iterator startToDel) -{ - for(std::list::iterator iter=startToDel;iter!=_sub_edges.end();iter++) - delete (*iter); -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx deleted file mode 100644 index 772585e84..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__ -#define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" - -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - class Node; - class Edge; - class Bounds; - class ElementaryEdge; - class IteratorOnComposedEdge; - - class INTERPKERNELGEOMETRIC2D_EXPORT ComposedEdge - { - friend class IteratorOnComposedEdge; - public: - ComposedEdge() { } - ComposedEdge(const ComposedEdge& other); - ComposedEdge(int size):_sub_edges(size) { } - static void Delete(ComposedEdge *pt) { delete pt; } - static void SoftDelete(ComposedEdge *pt) { pt->_sub_edges.clear(); delete pt; } - void reverse(); - int recursiveSize() const { return _sub_edges.size(); } - void initLocations() const; - ComposedEdge *clone() const; - bool isNodeIn(Node *n) const; - double getArea() const; - double getPerimeter() const; - double getHydraulicDiameter() const; - void getBarycenter(double *bary) const; - void getBarycenterGeneral(double *bary) const; - double normalize(ComposedEdge *other, double& xBary, double& yBary); - void fillBounds(Bounds& output) const; - void applySimilarity(double xBary, double yBary, double dimChar); - void applyGlobalSimilarity(double xBary, double yBary, double dimChar); - void dispatchPerimeter(double& partConsidered) const; - void dispatchPerimeterExcl(double& partConsidered, double& commonPart) const; - double dispatchPerimeterAdv(const ComposedEdge& father, std::vector& result) const; - void getAllNodes(std::set& output) const; - void getBarycenter(double *bary, double& weigh) const; - bool completed() const { return getEndNode()==getStartNode(); } - void setValueAt(int i, Edge *e, bool direction=true); - double getCommonLengthWith(const ComposedEdge& other) const; - void clear(); - bool empty() const { return _sub_edges.empty(); } - ElementaryEdge *front() const { return _sub_edges.front(); } - ElementaryEdge *back() const { return _sub_edges.back(); } - void resize(int i) { _sub_edges.resize(i); } - void pushBack(Edge *edge, bool direction=true); - void pushBack(ElementaryEdge *elem); - void pushBack(ComposedEdge *elem); - int size() const { return _sub_edges.size(); } - ElementaryEdge *operator[](int i) const; - Node *getEndNode() const; - Node *getStartNode() const; - bool changeEndNodeWith(Node *node) const; - bool changeStartNodeWith(Node *node) const; - void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const; - bool isInOrOut(Node *nodeToTest) const; - bool getDirection() const; - bool intresincEqCoarse(const Edge *other) const; - private: - std::list* getListBehind() { return &_sub_edges; } - protected: - ~ComposedEdge(); - private: - void clearAll(std::list::iterator startToDel); - protected: - std::list _sub_edges; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx deleted file mode 100644 index 16c5fdd93..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx +++ /dev/null @@ -1,846 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DEdge.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" -#include "InterpKernelGeo2DEdgeInfLin.hxx" -//#include "EdgeParabol.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelException.hxx" - -#include - -using namespace INTERP_KERNEL; - -MergePoints::MergePoints():_ass1Start1(0),_ass1End1(0),_ass1Start2(0),_ass1End2(0), - _ass2Start1(0),_ass2End1(0),_ass2Start2(0),_ass2End2(0) -{ -} - -void MergePoints::start1Replaced() -{ - unsigned nbOfAsso=getNumberOfAssociations(); - if(nbOfAsso==0) - _ass1Start1=1; - else - _ass2Start1=1; -} - -void MergePoints::end1Replaced() -{ - unsigned nbOfAsso=getNumberOfAssociations(); - if(nbOfAsso==0) - _ass1End1=1; - else - _ass2End1=1; -} - -void MergePoints::start1OnStart2() -{ - unsigned nbOfAsso=getNumberOfAssociations(); - if(nbOfAsso==0) - { - _ass1Start1=1; - _ass1Start2=1; - } - else - { - _ass2Start1=1; - _ass2Start2=1; - } -} - -void MergePoints::start1OnEnd2() -{ - unsigned nbOfAsso=getNumberOfAssociations(); - if(nbOfAsso==0) - { - _ass1Start1=1; - _ass1End2=1; - } - else - { - _ass2Start1=1; - _ass2End2=1; - } -} - -void MergePoints::end1OnStart2() -{ - unsigned nbOfAsso=getNumberOfAssociations(); - if(nbOfAsso==0) - { - _ass1End1=1; - _ass1Start2=1; - } - else - { - _ass2End1=1; - _ass2Start2=1; - } -} - -void MergePoints::end1OnEnd2() -{ - unsigned nbOfAsso=getNumberOfAssociations(); - if(nbOfAsso==0) - { - _ass1End1=1; - _ass1End2=1; - } - else - { - _ass2End1=1; - _ass2End2=1; - } -} - -bool MergePoints::isStart1(unsigned rk) const -{ - if(rk==0) - return _ass1Start1; - else - return _ass2Start1; -} - -bool MergePoints::isEnd1(unsigned rk) const -{ - if(rk==0) - return _ass1End1; - else - return _ass2End1; -} - -bool MergePoints::isStart2(unsigned rk) const -{ - if(rk==0) - return _ass1Start2; - else - return _ass2Start2; -} - -bool MergePoints::isEnd2(unsigned rk) const -{ - if(rk==0) - return _ass1End2; - else - return _ass2End2; -} - -void MergePoints::clear() -{ - _ass1Start1=0;_ass1End1=0;_ass1Start2=0;_ass1End2=0; - _ass2Start1=0;_ass2End1=0;_ass2Start2=0;_ass2End2=0; -} - -unsigned MergePoints::getNumberOfAssociations() const -{ - unsigned ret=0; - unsigned subTot=_ass1Start1+_ass1End1+_ass1Start2+_ass1End2; - if(subTot!=0) - ret++; - subTot=_ass2Start1+_ass2End1+_ass2Start2+_ass2End2; - if(subTot!=0) - ret++; - return ret; -} - -IntersectElement::IntersectElement(double val1, double val2, bool start1, bool end1, bool start2, bool end2, Node *node - , const Edge& e1, const Edge& e2, bool keepOrder):_1S(keepOrder?start1:start2), - _1E(keepOrder?end1:end2), - _2S(keepOrder?start2:start1), - _2E(keepOrder?end2:end1), - _chararct_val_for_e1(keepOrder?val1:val2), - _chararct_val_for_e2(keepOrder?val2:val1), - _node(node),_loc_of_node(node->getLoc()),_e1(keepOrder?e1:e2), - _e2(keepOrder?e2:e1) -{ -} - -IntersectElement::IntersectElement(const IntersectElement& other):_1S(other._1S),_1E(other._1E),_2S(other._2S),_2E(other._2E), - _chararct_val_for_e1(other._chararct_val_for_e1), - _chararct_val_for_e2(other._chararct_val_for_e2),_node(other._node), - _loc_of_node(other._loc_of_node),_e1(other._e1), _e2(other._e2) -{ - if(_node) - _node->incrRef(); -} - -IntersectElement& IntersectElement::operator=(const IntersectElement& other) -{ - _1S=other._1S;_1E=other._1E; _2S=other._2S; _2E=other._2E; - _chararct_val_for_e1=other._chararct_val_for_e1; - _chararct_val_for_e2=other._chararct_val_for_e2; - setNode(other._node); - return *this; -} - -bool IntersectElement::operator<(const IntersectElement& other) const -{ - return _e1.isLower(_chararct_val_for_e1,other._chararct_val_for_e1); -} - -IntersectElement::~IntersectElement() -{ - if(_node) - _node->decrRef(); -} - -/*! - * Returns 0 or 1. - */ -bool IntersectElement::isOnMergedExtremity() const -{ - if( (_1S && _2S) || (_1S && _2E) || (_1E && _2S) || (_1E && _2E) ) - return true; - return false; -} - -/*! - * To call if isOnMergedExtremity returned true. - */ -void IntersectElement::performMerging(MergePoints& commonNode) const -{ - if(_1S && _2S) - { - if(_e1.changeStartNodeWith(_e2.getStartNode())) - { - _e2.getStartNode()->declareOnLim(); - commonNode.start1OnStart2(); - } - } - else if(_1S && _2E) - { - if(_e1.changeStartNodeWith(_e2.getEndNode())) - { - _e2.getEndNode()->declareOnLim(); - commonNode.start1OnEnd2(); - } - } - else if(_1E && _2S) - { - if(_e1.changeEndNodeWith(_e2.getStartNode())) - { - _e2.getStartNode()->declareOnLim(); - commonNode.end1OnStart2(); - } - } - else if(_1E && _2E) - { - if(_e1.changeEndNodeWith(_e2.getEndNode())) - { - _e2.getEndNode()->declareOnLim(); - commonNode.end1OnEnd2(); - } - } -} - -/*! - * This methode is const because 'node' is supposed to be equal geomitrically to _node. - */ -void IntersectElement::setNode(Node *node) const -{ - if(node!=_node) - { - if(_node) - ((Node *)_node)->decrRef(); - ((IntersectElement *)(this))->_node=node; - if(_node) - _node->incrRef(); - } -} - -bool IntersectElement::isLowerOnOther(const IntersectElement& other) const -{ - return _e2.isLower(_chararct_val_for_e2,other._chararct_val_for_e2); -} - -unsigned IntersectElement::isOnExtrForAnEdgeAndInForOtherEdge() const -{ - if(( _1S && !(_2S || _2E) ) || ( _1E && !(_2S || _2E) )) - { - if(_1S && !(_2S || _2E)) - setNode(_e1.getStartNode()); - else - setNode(_e1.getEndNode()); - if(_e2.isIn(_chararct_val_for_e2)) - return LIMIT_ON; - return LIMIT_ALONE; - } - if(( _2S && !(_1S || _1E) ) || ( _2E && !(_1S || _1E))) - { - if(_2S && !(_1S || _1E)) - setNode(_e2.getStartNode()); - else - setNode(_e2.getEndNode()); - if(_e1.isIn(_chararct_val_for_e1)) - return LIMIT_ON; - return LIMIT_ALONE; - } - return NO_LIMIT; -} - -bool IntersectElement::isIncludedByBoth() const -{ - return _e1.isIn(_chararct_val_for_e1) && _e2.isIn(_chararct_val_for_e2); -} - -bool EdgeIntersector::intersect(const Bounds *whereToFind, std::vector& newNodes, bool& order, MergePoints& commonNode) -{ - std::list< IntersectElement > listOfIntesc=getIntersectionsCharacteristicVal(); - std::list< IntersectElement >::iterator iter; - for(iter=listOfIntesc.begin();iter!=listOfIntesc.end();) - { - if((*iter).isOnMergedExtremity()) - { - (*iter).performMerging(commonNode); - iter=listOfIntesc.erase(iter); - continue; - } - unsigned tmp=(*iter).isOnExtrForAnEdgeAndInForOtherEdge(); - if(tmp==IntersectElement::LIMIT_ALONE) - { - iter=listOfIntesc.erase(iter); - continue; - } - else if(tmp==IntersectElement::LIMIT_ON) - { - (*iter).attachLoc(); - iter++; - continue; - } - if(!(*iter).isIncludedByBoth()) - { - iter=listOfIntesc.erase(iter); - continue; - } - (*iter).attachLoc(); - iter++; - } - if(listOfIntesc.size()==0) - return false; - if(listOfIntesc.size()==1) - { - order=true;//useless - newNodes.push_back(listOfIntesc.front().getNodeAndReleaseIt()); - } - else - { - std::vector vecOfIntesc(listOfIntesc.begin(),listOfIntesc.end()); - listOfIntesc.clear(); - sort(vecOfIntesc.begin(),vecOfIntesc.end()); - for(std::vector::iterator iterV=vecOfIntesc.begin();iterV!=vecOfIntesc.end();iterV++) - newNodes.push_back((*iterV).getNodeAndReleaseIt()); - order=vecOfIntesc.front().isLowerOnOther(vecOfIntesc.back()); - } - return true; -} - -/*! - * Locates 'node' regarding edge this->_e1. If node is located close to (with distant lt epsilon) start or end point of _e1, - * 'node' takes its place. In this case 'obvious' is set to true and 'commonNode' stores information of merge point and finally 'where' is set. - * Furthermore 'node' is declared as ON LIMIT to indicate in locating process that an absolute location computation will have to be done. - * If 'node' is not close to start or end point of _e1, 'obvious' is set to false and 'commonNode' and 'where' are let unchanged. - */ -void EdgeIntersector::obviousCaseForCurvAbscisse(Node *node, TypeOfLocInEdge& where, MergePoints& commonNode, bool& obvious) const -{ - obvious=true; - if(node->isEqual(*_e1.getStartNode())) - { - where=START; - if(_e1.changeStartNodeWith(node)) - { - commonNode.start1Replaced(); - node->declareOnLim(); - } - return ; - } - if(node->isEqual(*_e1.getEndNode())) - { - where=END; - if(_e1.changeEndNodeWith(node)) - { - commonNode.end1Replaced(); - node->declareOnLim(); - } - return ; - } - obvious=false; -} - -Edge::Edge(double sX, double sY, double eX, double eY):_cnt(1),_loc(FULL_UNKNOWN),_start(new Node(sX,sY)),_end(new Node(eX,eY)) -{ -} - -Edge::~Edge() -{ - _start->decrRef(); - if(_end) - _end->decrRef(); -} - -bool Edge::decrRef() -{ - bool ret=(--_cnt==0); - if(ret) - delete this; - return ret; -} - -void Edge::declareOn() const -{ - if(_loc==FULL_UNKNOWN) - { - _loc=FULL_ON_1; - _start->declareOn(); - _end->declareOn(); - } -} - -void Edge::declareIn() const -{ - if(_loc==FULL_UNKNOWN) - { - _loc=FULL_IN_1; - _start->declareIn(); - _end->declareIn(); - } -} - -void Edge::declareOut() const -{ - if(_loc==FULL_UNKNOWN) - { - _loc=FULL_OUT_1; - _start->declareOut(); - _end->declareOut(); - } -} - -void Edge::fillXfigStreamForLoc(std::ostream& stream) const -{ - switch(_loc) - { - case FULL_IN_1: - stream << '2';//Green - break; - case FULL_OUT_1: - stream << '1';//Bleue - break; - case FULL_ON_1: - stream << '4';//Red - break; - default: - stream << '0'; - } -} - -bool Edge::changeStartNodeWith(Node *otherStartNode) const -{ - if(_start==otherStartNode) - return true; - if(_start->isEqual(*otherStartNode)) - { - (((Edge *)this)->_start)->decrRef();//un-const cast Ok thanks to 2 lines above. - (((Edge *)this)->_start)=otherStartNode; - _start->incrRef(); - return true; - } - return false; -} - -bool Edge::changeStartNodeWithAndKeepTrack(Node *otherStartNode, std::vector& track) const -{ - if(_start==otherStartNode) - return true; - if(_start->isEqualAndKeepTrack(*otherStartNode,track)) - { - (((Edge *)this)->_start)->decrRef();//un-const cast Ok thanks to 2 lines above. - (((Edge *)this)->_start)=otherStartNode; - otherStartNode->incrRef(); - return true; - } - return false; -} - -bool Edge::changeEndNodeWith(Node *otherEndNode) const -{ - if(_end==otherEndNode) - return true; - if(_end->isEqual(*otherEndNode)) - { - (((Edge *)this)->_end)->decrRef(); - (((Edge *)this)->_end)=otherEndNode; - _end->incrRef(); - return true; - } - return false; -} - -bool Edge::changeEndNodeWithAndKeepTrack(Node *otherEndNode, std::vector& track) const -{ - if(_end==otherEndNode) - return true; - if(_end->isEqualAndKeepTrack(*otherEndNode,track)) - { - (((Edge *)this)->_end)->decrRef(); - (((Edge *)this)->_end)=otherEndNode; - otherEndNode->incrRef(); - return true; - } - return false; -} - -/*! - * Precondition : 'start' and 'end' are lying on the same curve than 'this'. - * Add in vec the sub edge lying on this. - * If 'start' is equal (by pointer) to '_end' and 'end' is equal to '_end' too nothing is added. - * If 'start' is equal (by pointer) to '_start' and 'end' is equal to '_start' too nothing is added. - * If 'start' is equal (by pointer) to '_start' and 'end' is equal to '_end' this is added in vec. - */ -void Edge::addSubEdgeInVector(Node *start, Node *end, ComposedEdge& vec) const -{ - if((start==_start && end==_start) || (start==_end && end==_end)) - return ; - if(start==_start && end==_end) - { - incrRef(); - vec.pushBack((Edge *)this); - return ; - } - vec.pushBack(buildEdgeLyingOnMe(start,end,true)); -} - -/*! - * Retrieves a vector 'vectOutput' that is normal to 'this'. 'vectOutput' is normalized. - */ -void Edge::getNormalVector(double *vectOutput) const -{ - std::copy((const double *)(*_end),(const double *)(*_end)+2,vectOutput); - std::transform(vectOutput,vectOutput+2,(const double *)(*_start),vectOutput,std::minus()); - double norm=1./Node::norm(vectOutput); - std::transform(vectOutput,vectOutput+2,vectOutput,bind2nd(std::multiplies(),norm)); - double tmp=vectOutput[0]; - vectOutput[0]=vectOutput[1]; - vectOutput[1]=-tmp; -} - -Edge *Edge::buildEdgeFrom(Node *start, Node *end) -{ - return new EdgeLin(start,end); -} - -Edge *Edge::buildFromXfigLine(std::istream& str) -{ - unsigned char type; - str >> type; - if(type=='2') - return new EdgeLin(str); - else if(type=='5') - return new EdgeArcCircle(str); - else - { - std::cerr << "Unknown line found..."; - return 0; - } -} - -/*! - * \param other The Edge with which we are going to intersect. - * \param commonNode Output. The common nodes found during operation of intersecting. - * \param outVal1 Output filled in case true is returned. It specifies the new or not new edges by which 'this' is replaced after intersecting op. - * \param outVal2 Output filled in case true is returned. It specifies the new or not new edges by which 'other' is replaced after intersecting op. - * return true if the intersection between this. - */ -bool Edge::intersectWith(const Edge *other, MergePoints& commonNode, - ComposedEdge& outVal1, ComposedEdge& outVal2) const -{ - bool ret=true; - Bounds *merge=_bounds.nearlyAmIIntersectingWith(other->getBounds()); - if(!merge) - return false; - delete merge; - merge=0; - EdgeIntersector *intersector=buildIntersectorWith(this,other); - ret=intersect(this,other,intersector,merge,commonNode,outVal1,outVal2); - delete intersector; - return ret; -} - -bool Edge::intersectOverlapped(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, MergePoints& commonNode, - ComposedEdge& outValForF1, ComposedEdge& outValForF2) -{ - bool rev=intersector->haveTheySameDirection(); - Node *f2Start=f2->getNode(rev?START:END); - Node *f2End=f2->getNode(rev?END:START); - TypeOfLocInEdge place1, place2; - intersector->getPlacements(f2Start,f2End,place1,place2,commonNode); - int codeForIntersectionCase=combineCodes(place1,place2); - return splitOverlappedEdges(f1,f2,f2Start,f2End,rev,codeForIntersectionCase,outValForF1,outValForF2); -} - -/*! - * Perform 1D linear interpolation. Warning distrib1 and distrib2 are expected to be in ascending mode. - */ -void Edge::interpolate1DLin(const std::vector& distrib1, const std::vector& distrib2, std::map >& result) -{ - int nbOfV1=distrib1.size()-1; - int nbOfV2=distrib2.size()-1; - Node *n1=new Node(0.,0.); Node *n3=new Node(0.,0.); - Node *n2=new Node(0.,0.); Node *n4=new Node(0.,0.); - MergePoints commonNode; - for(int i=0;i::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal(),distrib1[i])); - if(iter!=distrib2.end()) - { - for(int j=(iter-1)-distrib2.begin();jsetNewCoords(distrib1[i],0.); n2->setNewCoords(distrib1[i+1],0.); - n3->setNewCoords(distrib2[j],0.); n4->setNewCoords(distrib2[j+1],0.); - ComposedEdge *f1=new ComposedEdge; - ComposedEdge *f2=new ComposedEdge; - SegSegIntersector inters(*e1,*e2); - bool b1,b2; - inters.areOverlappedOrOnlyColinears(0,b1,b2); - if(intersectOverlapped(e1,e2,&inters,commonNode,*f1,*f2)) - { - result[i][j]=f1->getCommonLengthWith(*f2)/e1->getCurveLength(); - } - ComposedEdge::Delete(f1); ComposedEdge::Delete(f2); - e1->decrRef(); e2->decrRef(); - } - } - } - } - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); -} - -EdgeIntersector *Edge::buildIntersectorWith(const Edge *e1, const Edge *e2) -{ - EdgeIntersector *ret=0; - const EdgeLin *tmp1=0; - const EdgeArcCircle *tmp2=0; - unsigned char type1=e1->getTypeOfFunc(); - e1->dynCastFunction(tmp1,tmp2); - unsigned char type2=e2->getTypeOfFunc(); - e2->dynCastFunction(tmp1,tmp2); - type1|=type2; - switch(type1) - { - case 1:// Intersection seg/seg - ret=new SegSegIntersector((const EdgeLin &)(*e1),(const EdgeLin &)(*e2)); - break; - case 5:// Intersection seg/arc of circle - ret=new ArcCSegIntersector(*tmp2,*tmp1,tmp2==e1); - break; - case 4:// Intersection arc/arc of circle - ret=new ArcCArcCIntersector((const EdgeArcCircle &)(*e1),(const EdgeArcCircle &)(*e2)); - break; - default: - //Should never happen - throw Exception("A non managed association of edge has been detected. Go work for intersection computation implementation."); - } - return ret; -} - -/*! - * See Node::applySimilarity to see signification of params. - */ -void Edge::applySimilarity(double xBary, double yBary, double dimChar) -{ - _bounds.applySimilarity(xBary,yBary,dimChar); -} - -bool Edge::intersect(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, const Bounds *whereToFind, MergePoints& commonNode, - ComposedEdge& outValForF1, ComposedEdge& outValForF2) -{ - bool obviousNoIntersection; - bool areOverlapped; - intersector->areOverlappedOrOnlyColinears(whereToFind,obviousNoIntersection,areOverlapped); - if(areOverlapped) - return intersectOverlapped(f1,f2,intersector,commonNode,outValForF1,outValForF2); - if(obviousNoIntersection) - return false; - std::vector newNodes; - bool order; - if(intersector->intersect(whereToFind,newNodes,order,commonNode)) - { - if(newNodes.empty()) - throw Exception("Internal error occured - error in intersector implementation!");// This case should never happen - std::vector::iterator iter=newNodes.begin(); - std::vector::reverse_iterator iterR=newNodes.rbegin(); - f1->addSubEdgeInVector(f1->getStartNode(),*iter,outValForF1); - f2->addSubEdgeInVector(f2->getStartNode(),order?*iter:*iterR,outValForF2); - for(std::vector::iterator iter=newNodes.begin();iter!=newNodes.end();iter++,iterR++) - { - if((iter+1)==newNodes.end()) - { - f1->addSubEdgeInVector(*iter,f1->getEndNode(),outValForF1); - (*iter)->decrRef(); - f2->addSubEdgeInVector(order?*iter:*iterR,f2->getEndNode(),outValForF2); - } - else - { - f1->addSubEdgeInVector(*iter,*(iter+1),outValForF1); - (*iter)->decrRef(); - f2->addSubEdgeInVector(order?*iter:*iterR,order?*(iter+1):*(iterR+1),outValForF2); - } - } - return true; - } - else//no intersection inside whereToFind - return false; -} - -int Edge::combineCodes(TypeOfLocInEdge code1, TypeOfLocInEdge code2) -{ - int ret=(int)code1; - ret*=OFFSET_FOR_TYPEOFLOCINEDGE; - ret+=(int)code2; - return ret; -} - -/*! - * This method splits e1 and e2 into pieces as much sharable as possible. The precondition to the call of this method - * is that e1 and e2 have been declared as overlapped by corresponding intersector built from e1 and e2 type. - * - * @param nS start node of e2 with the SAME DIRECTION as e1. The pointer nS should be equal to start node of e2 or to its end node. - * @param nE end node of e2 with the SAME DIRECTION as e1. The pointer nE should be equal to start node of e2 or to its end node. - * @param direction is param that specifies if e2 and e1 have same directions (true) or opposed (false). - * @param code is the code returned by method Edge::combineCodes. - */ -bool Edge::splitOverlappedEdges(const Edge *e1, const Edge *e2, Node *nS, Node *nE, bool direction, int code, - ComposedEdge& outVal1, ComposedEdge& outVal2) -{ - Edge *tmp; - switch(code) - { - case OUT_BEFORE*OFFSET_FOR_TYPEOFLOCINEDGE+START: // OUT_BEFORE - START - case OUT_BEFORE*OFFSET_FOR_TYPEOFLOCINEDGE+OUT_BEFORE: // OUT_BEFORE - OUT_BEFORE - case OUT_AFTER*OFFSET_FOR_TYPEOFLOCINEDGE+OUT_AFTER: // OUT_AFTER - OUT_AFTER - case END*OFFSET_FOR_TYPEOFLOCINEDGE+OUT_AFTER: // END - OUT_AFTER - case END*OFFSET_FOR_TYPEOFLOCINEDGE+START: // END - START - return false; - case INSIDE*OFFSET_FOR_TYPEOFLOCINEDGE+OUT_AFTER: // INSIDE - OUT_AFTER - outVal1.pushBack(e1->buildEdgeLyingOnMe(e1->getStartNode(),nS,true)); - tmp=e1->buildEdgeLyingOnMe(nS,e1->getEndNode()); tmp->incrRef(); - outVal1.pushBack(tmp); - outVal2.resize(2); - outVal2.setValueAt(direction?0:1,tmp,direction); tmp->declareOn(); - outVal2.setValueAt(direction?1:0,e1->buildEdgeLyingOnMe(e1->getEndNode(),nE,direction)); - return true; - case INSIDE*OFFSET_FOR_TYPEOFLOCINEDGE+INSIDE: // INSIDE - INSIDE - { - if(!e2->isIn(e2->getCharactValue(*(e1->getStartNode())))) - { - e2->incrRef(); e2->incrRef(); - outVal1.resize(3); - outVal1.setValueAt(0,e1->buildEdgeLyingOnMe(e1->getStartNode(),nS)); - outVal1.setValueAt(1,(Edge*)e2,direction); - outVal1.setValueAt(2,e1->buildEdgeLyingOnMe(nE,e1->getEndNode())); - outVal2.pushBack((Edge*)e2); e2->declareOn(); - return true; - } - else - { - outVal1.resize(3); - outVal2.resize(3); - tmp=e1->buildEdgeLyingOnMe(e1->getStartNode(),nE); tmp->incrRef(); tmp->declareOn(); - outVal1.setValueAt(0,tmp,true); outVal2.setValueAt(direction?2:0,tmp,direction); - outVal1.setValueAt(1,e1->buildEdgeLyingOnMe(nE,nS)); - tmp=e1->buildEdgeLyingOnMe(nS,e1->getEndNode()); tmp->incrRef(); tmp->declareOn(); - outVal1.setValueAt(2,tmp,true); outVal2.setValueAt(direction?0:2,tmp,direction); - tmp=e1->buildEdgeLyingOnMe(e1->getEndNode(),e1->getStartNode()); - outVal2.setValueAt(1,tmp,direction); - return true; - } - } - case OUT_BEFORE*OFFSET_FOR_TYPEOFLOCINEDGE+INSIDE: // OUT_BEFORE - INSIDE - tmp=e1->buildEdgeLyingOnMe(e1->getStartNode(),nE); tmp->incrRef(); - outVal1.pushBack(tmp); - outVal1.pushBack(e1->buildEdgeLyingOnMe(nE,e1->getEndNode())); - outVal2.resize(2); - outVal2.setValueAt(direction?0:1,e1->buildEdgeLyingOnMe(nS,e1->getStartNode(),direction)); - outVal2.setValueAt(direction?1:0,tmp,direction); tmp->declareOn(); - return true; - case OUT_BEFORE*OFFSET_FOR_TYPEOFLOCINEDGE+OUT_AFTER: // OUT_BEFORE - OUT_AFTER - e1->incrRef(); e1->incrRef(); - outVal1.pushBack((Edge*)e1); - outVal2.resize(3); - outVal2.setValueAt(direction?0:2,e1->buildEdgeLyingOnMe(nS,e1->getStartNode(),direction)); - outVal2.setValueAt(1,(Edge*)e1,direction); e1->declareOn(); - outVal2.setValueAt(direction?2:0,e1->buildEdgeLyingOnMe(e1->getEndNode(),nE,direction)); - return true; - case START*OFFSET_FOR_TYPEOFLOCINEDGE+END: // START - END - e1->incrRef(); e1->incrRef(); - outVal1.pushBack((Edge*)e1); - outVal2.pushBack((Edge*)e1,direction); e1->declareOn(); - return true; - case START*OFFSET_FOR_TYPEOFLOCINEDGE+OUT_AFTER: // START - OUT_AFTER - e1->incrRef(); e1->incrRef(); - outVal1.pushBack((Edge*)e1); - outVal2.resize(2); - outVal2.setValueAt(direction?0:1,(Edge*)e1,direction); e1->declareOn(); - outVal2.setValueAt(direction?1:0,e1->buildEdgeLyingOnMe(e1->getEndNode(),nE,direction)); - return true; - case INSIDE*OFFSET_FOR_TYPEOFLOCINEDGE+END: // INSIDE - END - e2->incrRef(); e2->incrRef(); - outVal1.pushBack(e1->buildEdgeLyingOnMe(e1->getStartNode(),nS,true)); - outVal1.pushBack((Edge*)e2,direction); - outVal2.pushBack((Edge*)e2); e2->declareOn(); - return true; - case OUT_BEFORE*OFFSET_FOR_TYPEOFLOCINEDGE+END: // OUT_BEFORE - END - e1->incrRef(); e1->incrRef(); - outVal1.pushBack((Edge*)e1); - outVal2.resize(2); - outVal2.setValueAt(direction?0:1,e1->buildEdgeLyingOnMe(nS,e1->getStartNode(),direction)); - outVal2.setValueAt(direction?1:0,(Edge*)e1,direction); e1->declareOn(); - return true; - case START*OFFSET_FOR_TYPEOFLOCINEDGE+INSIDE: // START - INSIDE - e2->incrRef(); e2->incrRef(); - outVal1.pushBack((Edge*)e2,direction); - outVal1.pushBack(e1->buildEdgeLyingOnMe(nE,e1->getEndNode())); - outVal2.pushBack((Edge*)e2); e2->declareOn(); - return true; - case INSIDE*OFFSET_FOR_TYPEOFLOCINEDGE+START: // INSIDE - START - outVal1.resize(2); - outVal2.resize(2); - tmp=e1->buildEdgeLyingOnMe(nS,e1->getEndNode()); tmp->incrRef(); tmp->declareOn(); - outVal1.setValueAt(0,e1->buildEdgeLyingOnMe(e1->getStartNode(),nS)); - outVal1.setValueAt(1,tmp); - outVal2.setValueAt(direction?0:1,tmp,direction); - outVal2.setValueAt(direction?1:0,e1->buildEdgeLyingOnMe(e1->getEndNode(),nE,direction)); - return true; - case END*OFFSET_FOR_TYPEOFLOCINEDGE+INSIDE: // END - INSIDE - outVal1.resize(2); - outVal2.resize(2); - tmp=e1->buildEdgeLyingOnMe(e1->getStartNode(),nE); tmp->incrRef(); tmp->declareOn(); - outVal1.setValueAt(0,tmp); - outVal1.setValueAt(1,e1->buildEdgeLyingOnMe(nE,e1->getEndNode())); - outVal2.setValueAt(direction?0:1,e1->buildEdgeLyingOnMe(e1->getEndNode(),e1->getStartNode(),direction)); - outVal2.setValueAt(direction?1:0,tmp,direction); - return true; - default: - throw Exception("Unexpected situation of overlapping edges : internal error occurs ! "); - } -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx deleted file mode 100644 index a02ca807a..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DEDGE_HXX__ -#define __INTERPKERNELGEO2DEDGE_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" -#include "InterpKernelGeo2DComposedEdge.hxx" -#include "InterpKernelException.hxx" -#include "InterpKernelGeo2DBounds.hxx" -#include "InterpKernelGeo2DNode.hxx" - -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - typedef enum - { - SEG = 1, - ARC_CIRCLE = 4, - ARC_PARABOL = 8 - } TypeOfFunction; - - typedef enum - { - CIRCLE = 0 , - PARABOL = 1 - } TypeOfMod4QuadEdge; - - typedef enum - { - START = 5, - END = 1, - INSIDE = 2, - OUT_BEFORE = 3, - OUT_AFTER = 4 - } TypeOfLocInEdge; //see Edge::OFFSET_FOR_TYPEOFLOCINEDGE - - typedef enum - { - FULL_IN_1 = 1, - FULL_ON_1 = 4, - FULL_OUT_1 = 2, - FULL_UNKNOWN = 3 - } TypeOfEdgeLocInPolygon; - - class INTERPKERNELGEOMETRIC2D_EXPORT MergePoints - { - public: - MergePoints(); - - //methods called during intersection edge-edge - void start1Replaced(); - void end1Replaced(); - void start1OnStart2(); - void start1OnEnd2(); - void end1OnStart2(); - void end1OnEnd2(); - //methods to be called during aggregation - bool isStart1(unsigned rk) const; - bool isEnd1(unsigned rk) const; - bool isStart2(unsigned rk) const; - bool isEnd2(unsigned rk) const; - void clear(); - unsigned getNumberOfAssociations() const; - private: - unsigned _ass1Start1 : 1; - unsigned _ass1End1 : 1; - unsigned _ass1Start2 : 1; - unsigned _ass1End2 : 1; - unsigned _ass2Start1 : 1; - unsigned _ass2End1 : 1; - unsigned _ass2Start2 : 1; - unsigned _ass2End2 : 1; - }; - - /*! - * This class is in charge to store an intersection point as result of \b non oververlapping edge intersection. - * This class manages the cases when intersect element is one of the extrimities of edge1 and/or edge2. - */ - class INTERPKERNELGEOMETRIC2D_EXPORT IntersectElement - { - public: - IntersectElement(double val1, double val2, bool start1, bool end1, bool start2, bool end2, Node *node, const Edge& e1, const Edge& e2, bool keepOrder); - IntersectElement(const IntersectElement& other); - //! The sort operator is done on the edge 1 \b not edge 2. - bool operator<(const IntersectElement& other) const; - IntersectElement& operator=(const IntersectElement& other); - double getVal1() const { return _chararct_val_for_e1; } - double getVal2() const { return _chararct_val_for_e2; } - //! idem operator< method except that the orientation is done on edge 2 \b not edge 1. - bool isLowerOnOther(const IntersectElement& other) const; - unsigned isOnExtrForAnEdgeAndInForOtherEdge() const; - void attachLoc() { _node->setLoc(_loc_of_node); } - bool isOnMergedExtremity() const; - bool isIncludedByBoth() const; - void setNode(Node *node) const; - void performMerging(MergePoints& commonNode) const; - Node *getNodeOnly() const { return _node; } - Node *getNodeAndReleaseIt() { Node *tmp=_node; _node=0; return tmp; } - ~IntersectElement(); - private: - bool _1S; - bool _1E; - bool _2S; - bool _2E; - double _chararct_val_for_e1; - double _chararct_val_for_e2; - Node *_node; - TypeOfLocInPolygon _loc_of_node; - const Edge& _e1; - const Edge& _e2; - public: - static const unsigned LIMIT_ALONE = 22; - static const unsigned LIMIT_ON = 73; - static const unsigned NO_LIMIT = 19; - }; - - /*! - * This abstract interface specifies all the methods to be overloaded of all possibilities edge-intersection. - */ - class INTERPKERNELGEOMETRIC2D_EXPORT EdgeIntersector - { - protected: - //! All non symetric methods are relative to 'e1'. - EdgeIntersector(const Edge& e1, const Edge& e2):_e1(e1),_e2(e2) { } - public: - virtual ~EdgeIntersector() { } - virtual bool keepOrder() const = 0; - //!to call only if 'areOverlapped' have been set to true when areOverlappedOrOnlyColinears was called - virtual bool haveTheySameDirection() const = 0; - //!to call only if 'areOverlapped' have been set to true when areOverlappedOrOnlyColinears was called - virtual void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const = 0; - //! When true is returned, newNodes should contains at least 1 element. All merging nodes betw _e1 and _e2 extremities must be done. - bool intersect(const Bounds *whereToFind, std::vector& newNodes, bool& order, MergePoints& commonNode); - //! Should be called only once per association. - virtual void areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped) = 0; - //! The size of returned vector is equal to number of potential intersections point. The values are so that their are interpretable by virtual Edge::isIn method. - virtual std::list< IntersectElement > getIntersectionsCharacteristicVal() const = 0; - protected: - void obviousCaseForCurvAbscisse(Node *node, TypeOfLocInEdge& where, MergePoints& commonNode, bool& obvious) const; - protected: - const Edge& _e1; - const Edge& _e2; - }; - - class INTERPKERNELGEOMETRIC2D_EXPORT SameTypeEdgeIntersector : public EdgeIntersector - { - protected: - SameTypeEdgeIntersector(const Edge& e1, const Edge& e2):EdgeIntersector(e1,e2) { } - bool keepOrder() const { return true; } - }; - - class INTERPKERNELGEOMETRIC2D_EXPORT CrossTypeEdgeIntersector : public EdgeIntersector - { - protected: - CrossTypeEdgeIntersector(const Edge& e1, const Edge& e2, bool reverse):EdgeIntersector(e1,e2),_reverse(reverse) { } - bool keepOrder() const { return _reverse; } - bool haveTheySameDirection() const { throw Exception("Cross type intersector is not supposed to deal with overlapped in cross type."); } - const Edge *myE1() { if(_reverse) return &_e1; else return &_e2; } - const Edge *myE2() { if(_reverse) return &_e2; else return &_e1; } - protected: - //! boolean to inform intersector that unsymetrics treatments reverse of e1 and e2 should be done. - bool _reverse; - }; - - class EdgeLin; - class EdgeInfLin; - class EdgeArcCircle; - - /*! - * Deal with an oriented edge of a polygon. - * An Edge is definied with a start node a end node and an equation of 1D curve. - * All other attributes are mutable because they don't impact these 3 invariant attributes. - * To be exact start and end node can change (adress) but their location remain - * the same (at precision). - */ - class INTERPKERNELGEOMETRIC2D_EXPORT Edge - { - public: - Edge(Node *start, Node *end, bool direction=true):_cnt(1),_loc(FULL_UNKNOWN) { if(direction) { _start=start; _end=end; } else { _start=end; _end=start; } _start->incrRef(); _end->incrRef(); } - Edge(double sX, double sY, double eX, double eY); - TypeOfEdgeLocInPolygon getLoc() const { return _loc; } - void incrRef() const { _cnt++; } - bool decrRef(); - void initLocs() const { _loc=FULL_UNKNOWN; _start->initLocs(); _end->initLocs(); } - void declareOn() const; - void declareIn() const; - void declareOut() const; - const Bounds& getBounds() const { return _bounds; } - void fillXfigStreamForLoc(std::ostream& stream) const; - Node *getNode(TypeOfLocInEdge where) const { if(where==START) return _start; else if(where==END) return _end; else return 0; } - Node *getStartNode() const { return _start; } - Node *getEndNode() const { return _end; } - void setEndNodeWithoutChange(Node *newEnd); - void setStartNodeWithoutChange(Node *newStart); - bool changeStartNodeWith(Node *otherStartNode) const; - bool changeStartNodeWithAndKeepTrack(Node *otherStartNode, std::vector& track) const; - bool changeEndNodeWith(Node *otherEndNode) const; - bool changeEndNodeWithAndKeepTrack(Node *otherEndNode, std::vector& track) const; - void addSubEdgeInVector(Node *start, Node *end, ComposedEdge& vec) const; - void getNormalVector(double *vectOutput) const; - static EdgeIntersector *buildIntersectorWith(const Edge *e1, const Edge *e2); - static Edge *buildFromXfigLine(std::istream& str); - static Edge *buildEdgeFrom(Node *start, Node *end); - template - static Edge *buildEdgeFrom(Node *start, Node *middle, Node *end); - virtual void update(Node *m) = 0; - //! returns area between this and axe Ox delimited along Ox by _start and _end. - virtual double getAreaOfZone() const = 0; - //! apply a similiraty transformation on 'this' - virtual void applySimilarity(double xBary, double yBary, double dimChar); - //! return the length of arc. Value is always > 0. ! - virtual double getCurveLength() const = 0; - virtual void getBarycenter(double *bary) const = 0; - virtual void getBarycenterOfZone(double *bary) const = 0; - //! Retrieves a point that is owning to this, well placed for IN/OUT detection of this. Typically midlle of this is returned. - virtual Node *buildRepresentantOfMySelf() const = 0; - //! Given a magnitude specified by sub-type returns if in or not. See getCharactValue method. - virtual bool isIn(double characterVal) const = 0; - //! With the same magnitude as defined in 'isIn' method perform a compararison. Precondition : val1 and val2 are different and exactly INSIDE this. - virtual bool isLower(double val1, double val2) const = 0; - //! node is expected to lay on 'this'. It returns a characteristic magnitude usable by isIn method. - virtual double getCharactValue(const Node& node) const = 0; - //! retrieves the distance to this : The min distance from pt and any point of this. - virtual double getDistanceToPoint(const double *pt) const = 0; - //! return if node with coords 'coordOfNode' is on this (with precision). - virtual bool isNodeLyingOn(const double *coordOfNode) const = 0; - virtual TypeOfFunction getTypeOfFunc() const = 0; - virtual void dynCastFunction(const EdgeLin * &seg, - const EdgeArcCircle * &arcSeg) const = 0; - bool intersectWith(const Edge *other, MergePoints& commonNode, - ComposedEdge& outVal1, ComposedEdge& outVal2) const; - static bool intersectOverlapped(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, MergePoints& commonNode, - ComposedEdge& outValForF1, ComposedEdge& outValForF2); - static void interpolate1DLin(const std::vector& distrib1, const std::vector& distrib2, - std::map >& result); - virtual void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const = 0; - protected: - Edge():_cnt(1),_loc(FULL_UNKNOWN),_start(0),_end(0) { } - virtual ~Edge(); - static int combineCodes(TypeOfLocInEdge code1, TypeOfLocInEdge code2); - static bool intersect(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, const Bounds *whereToFind, MergePoints& commonNode, - ComposedEdge& outValForF1, ComposedEdge& outValForF2); - //! The code 'code' is built by method combineCodes - static bool splitOverlappedEdges(const Edge *e1, const Edge *e2, Node *nS, Node *nE, bool direction, int code, - ComposedEdge& outVal1, ComposedEdge& outVal2); - virtual Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const = 0; - protected: - mutable unsigned char _cnt; - mutable TypeOfEdgeLocInPolygon _loc; - Bounds _bounds; - Node *_start; - Node *_end; - protected: - //In relation with max possible value of TypeOfLocInEdge. - static const int OFFSET_FOR_TYPEOFLOCINEDGE = 8; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx deleted file mode 100644 index 68387e094..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DEDGE_TXX__ -#define __INTERPKERNELGEO2DEDGE_TXX__ - -#include "InterpKernelGeo2DEdgeArcCircle.hxx" - -template -INTERP_KERNEL::Edge *INTERP_KERNEL::Edge::buildEdgeFrom(Node *start, Node *middle, Node *end) -{ - return new INTERP_KERNEL::EdgeArcCircle(start,middle,end); -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx deleted file mode 100644 index f427aaace..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx +++ /dev/null @@ -1,695 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" -#include "InterpKernelException.hxx" -#include "InterpKernelGeo2DNode.hxx" - -#include -#include - -using namespace INTERP_KERNEL; - -ArcCArcCIntersector::ArcCArcCIntersector(const EdgeArcCircle& e1, const EdgeArcCircle& e2):SameTypeEdgeIntersector(e1,e2),_dist(0.) -{ -} - -bool ArcCArcCIntersector::haveTheySameDirection() const -{ - return (getE1().getAngle()>0. && getE2().getAngle()>0.) || (getE1().getAngle()<0. && getE2().getAngle()<0.); -} - -/*! - * Precondition 'start' and 'end' are on the same curve than this. - */ -void ArcCArcCIntersector::getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const -{ - bool obvious1,obvious2; - obviousCaseForCurvAbscisse(start,whereStart,commonNode,obvious1); - obviousCaseForCurvAbscisse(end,whereEnd,commonNode,obvious2); - if(obvious1 && obvious2) - return ; - double angleInRadStart=getAngle(start); - double angleInRadEnd=getAngle(end); - if(obvious1 || obvious2) - { - if(obvious1) - { - if(EdgeArcCircle::isIn2Pi(getE1().getAngle0(),getE1().getAngle(),angleInRadEnd)) - whereEnd=INSIDE; - else - whereEnd=OUT_AFTER; - return ; - } - else - { - if(EdgeArcCircle::isIn2Pi(getE1().getAngle0(),getE1().getAngle(),angleInRadStart)) - whereStart=INSIDE; - else - whereStart=OUT_BEFORE; - return ; - } - } - if(EdgeArcCircle::isIn2Pi(getE1().getAngle0(),getE1().getAngle(),angleInRadStart)) - { - whereStart=INSIDE; - if(EdgeArcCircle::isIn2Pi(getE1().getAngle0(),getE1().getAngle(),angleInRadEnd)) - whereEnd=INSIDE; - else - whereEnd=OUT_AFTER; - } - else - {//we are out in start. - if(EdgeArcCircle::isIn2Pi(getE1().getAngle0(),getE1().getAngle(),angleInRadEnd)) - { - whereStart=OUT_BEFORE; - whereEnd=INSIDE; - } - else - { - if(EdgeArcCircle::isIn2Pi(getE2().getAngle0(),getE2().getAngle(),getE1().getAngle0())) - {//_e2 contains stictly _e1 - whereStart=OUT_BEFORE; - whereEnd=OUT_AFTER; - } - else - {//_e2 is outside from _e1 - whereStart=OUT_BEFORE; - whereEnd=OUT_BEFORE; - } - } - } -} - -/*! - * Return angle between ]-Pi;Pi[ - */ -double ArcCArcCIntersector::getAngle(Node *node) const -{ - return EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(((*node)[0]-getE1().getCenter()[0])/getE1().getRadius(),((*node)[1]-getE1().getCenter()[1])/getE1().getRadius()); -} - -bool ArcCArcCIntersector::areArcsOverlapped(const EdgeArcCircle& a1, const EdgeArcCircle& a2) -{ - double centerL[2],radiusL,angle0L,angleL; - double centerB[2],radiusB; - double lgth1=fabs(a1.getAngle()*a1.getRadius()); - double lgth2=fabs(a2.getAngle()*a2.getRadius()); - if(lgth1getInterceptedArc(centerL,radiusL,angle0L,angleL); - delete merge; - // - tmp=sqrt(tmp); - if(Node::areDoubleEqualsWP(tmp,0.,1/(10*std::max(radiusL,radiusB)))) - { - if(Node::areDoubleEquals(radiusL,radiusB)) - return true; - else - return false; - } - double phi=EdgeArcCircle::getAbsoluteAngleOfNormalizedVect((centerL[0]-centerB[0])/tmp,(centerL[1]-centerB[1])/tmp); - double cst2=2*radiusL*tmp/(radiusB*radiusB); - double cmpContainer[4]; - int sizeOfCmpContainer=2; - cmpContainer[0]=cst+cst2*cos(phi-angle0L); - cmpContainer[1]=cst+cst2*cos(phi-angle0L+angleL); - double a=EdgeArcCircle::normalizeAngle(phi-angle0L); - if(EdgeArcCircle::isIn2Pi(angle0L,angleL,a)) - cmpContainer[sizeOfCmpContainer++]=cst+cst2; - a=EdgeArcCircle::normalizeAngle(phi-angle0L+M_PI); - if(EdgeArcCircle::isIn2Pi(angle0L,angleL,a)) - cmpContainer[sizeOfCmpContainer++]=cst-cst2; - a=*std::max_element(cmpContainer,cmpContainer+sizeOfCmpContainer); - return Node::areDoubleEqualsWP(a,1.,2.); -} - -void ArcCArcCIntersector::areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped) -{ - _dist=Node::distanceBtw2Pt(getE1().getCenter(),getE2().getCenter()); - double radius1=getE1().getRadius(); double radius2=getE2().getRadius(); - if(_dist>radius1+radius2+QUADRATIC_PLANAR::_precision || _dist+std::min(radius1,radius2)+QUADRATIC_PLANAR::_precision ArcCArcCIntersector::getIntersectionsCharacteristicVal() const -{ - std::list< IntersectElement > ret; - const double *center1=getE1().getCenter(); - const double *center2=getE2().getCenter(); - double radius1=getE1().getRadius(); double radius2=getE2().getRadius(); - double d1_1=(_dist*_dist-radius2*radius2+radius1*radius1)/(2.*_dist); - double u[2];//u is normalized vector from center1 to center2. - u[0]=(center2[0]-center1[0])/_dist; u[1]=(center2[1]-center1[1])/_dist; - double d1_1y=EdgeArcCircle::safeSqrt(radius1*radius1-d1_1*d1_1); - double angleE1=EdgeArcCircle::normalizeAngle(getE1().getAngle0()+getE1().getAngle()); - double angleE2=EdgeArcCircle::normalizeAngle(getE2().getAngle0()+getE2().getAngle()); - if(!Node::areDoubleEquals(d1_1y,0)) - { - //2 intersections - double v1[2],v2[2]; - v1[0]=u[0]*d1_1-u[1]*d1_1y; v1[1]=u[1]*d1_1+u[0]*d1_1y; - v2[0]=u[0]*d1_1+u[1]*d1_1y; v2[1]=u[1]*d1_1-u[0]*d1_1y; - Node *node1=new Node(center1[0]+v1[0],center1[1]+v1[1]); node1->declareOn(); - Node *node2=new Node(center1[0]+v2[0],center1[1]+v2[1]); node2->declareOn(); - double angle1_1=EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(v1[0]/radius1,v1[1]/radius1); - double angle2_1=EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(v2[0]/radius1,v2[1]/radius1); - double v3[2],v4[2]; - v3[0]=center1[0]-center2[0]+v1[0]; v3[1]=center1[1]-center2[1]+v1[1]; - v4[0]=center1[0]-center2[0]+v2[0]; v4[1]=center1[1]-center2[1]+v2[1]; - double angle1_2=EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(v3[0]/radius2,v3[1]/radius2); - double angle2_2=EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(v4[0]/radius2,v4[1]/radius2); - // - bool e1_1S=Node::areDoubleEqualsWP(angle1_1,getE1().getAngle0(),radius1); - bool e1_1E=Node::areDoubleEqualsWP(angle1_1,angleE1,radius1); - bool e1_2S=Node::areDoubleEqualsWP(angle1_2,getE2().getAngle0(),radius1); - bool e1_2E=Node::areDoubleEqualsWP(angle1_2,angleE2,radius1); - // - bool e2_1S=Node::areDoubleEqualsWP(angle2_1,getE1().getAngle0(),radius2); - bool e2_1E=Node::areDoubleEqualsWP(angle2_1,angleE1,radius2); - bool e2_2S=Node::areDoubleEqualsWP(angle2_2,getE2().getAngle0(),radius2); - bool e2_2E=Node::areDoubleEqualsWP(angle2_2,angleE2,radius2); - ret.push_back(IntersectElement(angle1_1,angle1_2,e1_1S,e1_1E,e1_2S,e1_2E,node1,_e1,_e2,keepOrder())); - ret.push_back(IntersectElement(angle2_1,angle2_2,e2_1S,e2_1E,e2_2S,e2_2E,node2,_e1,_e2,keepOrder())); - } - else - { - //tangent intersection - double v1[2],v2[2]; - v1[0]=d1_1*u[0]; v1[1]=d1_1*u[1]; - v2[0]=center1[0]-center2[0]+v1[0]; v2[1]=center1[1]-center2[1]+v1[1]; - double angle0_1=EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(v1[0]/radius1,v1[1]/radius1); - double angle0_2=EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(v2[0]/radius2,v2[1]/radius2); - bool e0_1S=Node::areDoubleEqualsWP(angle0_1,getE1().getAngle0(),radius1); - bool e0_1E=Node::areDoubleEqualsWP(angle0_1,angleE1,radius1); - bool e0_2S=Node::areDoubleEqualsWP(angle0_2,getE2().getAngle0(),radius2); - bool e0_2E=Node::areDoubleEqualsWP(angle0_2,angleE2,radius2); - Node *node=new Node(center1[0]+d1_1*u[0],center1[1]+d1_1*u[1]); node->declareOnTangent(); - ret.push_back(IntersectElement(angle0_1,angle0_2,e0_1S,e0_1E,e0_2S,e0_2E,node,_e1,_e2,keepOrder())); - } - return ret; -} -/*double angle0_2; - double signDeltaAngle2; - double d1_2; - if(u[1]<0.) - angle0_1=-angle0_1; - if(d1_1>=0.) - { - if(_dist>radius1) - { - angle0_2=angle0_1+M_PI; - signDeltaAngle2=-1.; - } - else - { - angle0_2=angle0_1; - signDeltaAngle2=1.; - } - } - else - { - angle0_1+=M_PI; - angle0_2=angle0_1; - signDeltaAngle2=1.; - } - angle0_1=normalizeAngle(angle0_1); - angle0_2=normalizeAngle(angle0_2); - double angleE1=normalizeAngle(getE1().getAngle0()+getE1().getAngle()); - double angleE2=normalizeAngle(getE2().getAngle0()+getE2().getAngle()); - if(!(Node::areDoubleEquals(d1_1,radius1) || Node::areDoubleEquals(d1_1,-radius1)) ) - { - //2 intersections - double deltaAngle1=EdgeArcCircle::safeAcos(fabs(d1_1)/radius1); //owns to 0;Pi/2 by construction - double deltaAngle2=EdgeArcCircle::safeAcos(fabs(d1_2)/radius2); //owns to 0;Pi/2 by construction - double angle1_1=normalizeAngle(angle0_1+deltaAngle1);// Intersection 1 seen for _e1 - double angle2_1=normalizeAngle(angle0_1-deltaAngle1);// Intersection 2 seen for _e1 - double angle1_2=normalizeAngle(angle0_2+signDeltaAngle2*deltaAngle2);// Intersection 1 seen for _e2 - double angle2_2=normalizeAngle(angle0_2-signDeltaAngle2*deltaAngle2);// Intersection 2 seen for _e2 - // - bool e1_1S=Node::areDoubleEqualsWP(angle1_1,getE1().getAngle0(),radius1); - bool e1_1E=Node::areDoubleEqualsWP(angle1_1,angleE1,radius1); - bool e1_2S=Node::areDoubleEqualsWP(angle1_2,getE2().getAngle0(),radius1); - bool e1_2E=Node::areDoubleEqualsWP(angle1_2,angleE2,radius1); - // - bool e2_1S=Node::areDoubleEqualsWP(angle2_1,getE1().getAngle0(),radius2); - bool e2_1E=Node::areDoubleEqualsWP(angle2_1,angleE1,radius2); - bool e2_2S=Node::areDoubleEqualsWP(angle2_2,getE2().getAngle0(),radius2); - bool e2_2E=Node::areDoubleEqualsWP(angle2_2,angleE2,radius2); - Node *node1=new Node(center1[0]+radius1*cos(angle1_1),center1[0]+radius1*sin(angle1_1)); node1->declareOn(); - Node *node2=new Node(center1[0]+radius1*cos(angle2_1),center1[0]+radius1*sin(angle2_1)); node2->declareOn(); - ret.push_back(IntersectElement(angle1_1,angle1_2,e1_1S,e1_1E,e1_2S,e1_2E,node1,_e1,_e2,keepOrder())); - ret.push_back(IntersectElement(angle2_1,angle2_2,e2_1S,e2_1E,e2_2S,e2_2E,node2,_e1,_e2,keepOrder())); - } - else - //tangent intersection - { - bool e0_1S=Node::areDoubleEqualsWP(angle0_1,getE1().getAngle0(),radius1); - bool e0_1E=Node::areDoubleEqualsWP(angle0_1,angleE1,radius1); - bool e0_2S=Node::areDoubleEqualsWP(angle0_2,getE2().getAngle0(),radius2); - bool e0_2E=Node::areDoubleEqualsWP(angle0_2,angleE2,radius2); - Node *node=new Node(center1[0]+radius1*cos(angle0_1),center1[0]+radius1*sin(angle0_1)); node->declareOnTangent(); - ret.push_back(IntersectElement(angle0_1,angle0_2,e0_1S,e0_1E,e0_2S,e0_2E,node,_e1,_e2,keepOrder())); - } - return ret;*/ - -ArcCSegIntersector::ArcCSegIntersector(const EdgeArcCircle& e1, const EdgeLin& e2, bool reverse):CrossTypeEdgeIntersector(e1,e2,reverse) -{ -} - -void ArcCSegIntersector::areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped) -{ - areOverlapped=false;//No overlapping by contruction - const double *center=getE1().getCenter(); - _dx=(*(_e2.getEndNode()))[0]-(*(_e2.getStartNode()))[0]; - _dy=(*(_e2.getEndNode()))[1]-(*(_e2.getStartNode()))[1]; - _drSq=_dx*_dx+_dy*_dy; - _cross= - ((*(_e2.getStartNode()))[0]-center[0])*((*(_e2.getEndNode()))[1]-center[1])- - ((*(_e2.getStartNode()))[1]-center[1])*((*(_e2.getEndNode()))[0]-center[0]); - _determinant=getE1().getRadius()*getE1().getRadius()/_drSq-_cross*_cross/(_drSq*_drSq); - if(_determinant>-2*QUADRATIC_PLANAR::_precision)//QUADRATIC_PLANAR::_precision*QUADRATIC_PLANAR::_precision*_drSq*_drSq/(2.*_dx*_dx)) - obviousNoIntersection=false; - else - obviousNoIntersection=true; -} - -void ArcCSegIntersector::getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const -{ - throw Exception("Internal error. Should never been called : no overlapping possible between arc of circle and a segment."); -} - -std::list< IntersectElement > ArcCSegIntersector::getIntersectionsCharacteristicVal() const -{ - std::list< IntersectElement > ret; - const double *center=getE1().getCenter(); - if(!(fabs(_determinant)<(2.*QUADRATIC_PLANAR::_precision)))//QUADRATIC_PLANAR::_precision*QUADRATIC_PLANAR::_precision*_drSq*_drSq/(2.*_dx*_dx)) - { - double determinant=EdgeArcCircle::safeSqrt(_determinant); - double x1=(_cross*_dy/_drSq+Node::sign(_dy)*_dx*determinant)+center[0]; - double y1=(-_cross*_dx/_drSq+fabs(_dy)*determinant)+center[1]; - Node *intersect1=new Node(x1,y1); intersect1->declareOn(); - bool i1_1S=_e1.getStartNode()->isEqual(*intersect1); - bool i1_1E=_e1.getEndNode()->isEqual(*intersect1); - bool i1_2S=_e2.getStartNode()->isEqual(*intersect1); - bool i1_2E=_e2.getEndNode()->isEqual(*intersect1); - ret.push_back(IntersectElement(getE1().getCharactValue(*intersect1),getE2().getCharactValue(*intersect1),i1_1S,i1_1E,i1_2S,i1_2E,intersect1,_e1,_e2,keepOrder())); - // - double x2=(_cross*_dy/_drSq-Node::sign(_dy)*_dx*determinant)+center[0]; - double y2=(-_cross*_dx/_drSq-fabs(_dy)*determinant)+center[1]; - Node *intersect2=new Node(x2,y2); intersect2->declareOn(); - bool i2_1S=_e1.getStartNode()->isEqual(*intersect2); - bool i2_1E=_e1.getEndNode()->isEqual(*intersect2); - bool i2_2S=_e2.getStartNode()->isEqual(*intersect2); - bool i2_2E=_e2.getEndNode()->isEqual(*intersect2); - ret.push_back(IntersectElement(getE1().getCharactValue(*intersect2),getE2().getCharactValue(*intersect2),i2_1S,i2_1E,i2_2S,i2_2E,intersect2,_e1,_e2,keepOrder())); - } - else//tangent intersection - { - double x=(_cross*_dy)/_drSq+center[0]; - double y=(-_cross*_dx)/_drSq+center[1]; - Node *intersect=new Node(x,y); intersect->declareOnTangent(); - bool i_1S=_e1.getStartNode()->isEqual(*intersect); - bool i_1E=_e1.getEndNode()->isEqual(*intersect); - bool i_2S=_e2.getStartNode()->isEqual(*intersect); - bool i_2E=_e2.getEndNode()->isEqual(*intersect); - ret.push_back(IntersectElement(_e1.getCharactValue(*intersect),_e2.getCharactValue(*intersect),i_1S,i_1E,i_2S,i_2E,intersect,_e1,_e2,keepOrder())); - } - return ret; -} - -EdgeArcCircle::EdgeArcCircle(std::istream& lineInXfig) -{ - const unsigned NB_OF_SKIP_FIELDS=15; - std::string tmpS; - for(unsigned i=0;i> tmpS; - _start=new Node(lineInXfig); - Node *middle=new Node(lineInXfig); - _end=new Node(lineInXfig); - getArcOfCirclePassingThru(*_start,*middle,*_end,_center,_radius,_angle,_angle0); - middle->decrRef(); - updateBounds(); -} - -EdgeArcCircle::EdgeArcCircle(Node *start, Node *middle, Node *end, bool direction):Edge(start,end, direction) -{ - getArcOfCirclePassingThru(*_start,*middle,*_end,_center,_radius,_angle,_angle0); - updateBounds(); -} - -EdgeArcCircle::EdgeArcCircle(double sX, double sY, double mX, double mY, double eX, double eY):Edge(sX,sY,eX,eY) -{ - double middle[2]; middle[0]=mX; middle[1]=mY; - getArcOfCirclePassingThru(*_start,middle,*_end,_center,_radius,_angle,_angle0); - updateBounds(); -} - -/*! - * @param angle0 in ]-Pi;Pi[ - * @param deltaAngle in ]-2.*Pi;2.*Pi[ - */ -EdgeArcCircle::EdgeArcCircle(Node *start, Node *end, const double *center, double radius, double angle0, double deltaAngle, bool direction):Edge(start,end,direction),_angle(deltaAngle), - _angle0(angle0),_radius(radius) -{ - _center[0]=center[0]; - _center[1]=center[1]; - updateBounds(); -} - -void EdgeArcCircle::changeMiddle(Node *newMiddle) -{ - getArcOfCirclePassingThru(*_start,*newMiddle,*_end,_center,_radius,_angle,_angle0); - updateBounds(); -} - -Edge *EdgeArcCircle::buildEdgeLyingOnMe(Node *start, Node *end, bool direction) const -{ - double sx=((*start)[0]-_center[0])/_radius; - double sy=((*start)[1]-_center[1])/_radius; - double ex=((*end)[0]-_center[0])/_radius; - double ey=((*end)[1]-_center[1])/_radius; - double angle0=getAbsoluteAngleOfNormalizedVect(direction?sx:ex,direction?sy:ey); - double deltaAngle=getAbsoluteAngleOfNormalizedVect(sx*ex+sy*ey,sx*ey-sy*ex); - if(deltaAngle>0. && _angle<0.) - deltaAngle-=2.*M_PI; - else if(deltaAngle<0. && _angle>0.) - deltaAngle+=2.*M_PI; - deltaAngle=direction?deltaAngle:-deltaAngle; - return new EdgeArcCircle(start,end,_center,_radius,angle0,deltaAngle,direction); -} - -void EdgeArcCircle::applySimilarity(double xBary, double yBary, double dimChar) -{ - Edge::applySimilarity(xBary,yBary,dimChar); - _radius/=dimChar; - _center[0]=(_center[0]-xBary)/dimChar; - _center[1]=(_center[1]-yBary)/dimChar; -} - -/*! - * Given an \b NON normalized vector 'vect', returns its norm 'normVect' and its - * angle in ]-Pi,Pi] relative to Ox axe. - */ -double EdgeArcCircle::getAbsoluteAngle(const double *vect, double& normVect) -{ - normVect=Node::norm(vect); - return getAbsoluteAngleOfNormalizedVect(vect[0]/normVect,vect[1]/normVect); -} - -/*! - * Given a \b normalized vector defined by (ux,uy) returns its angle in ]-Pi;Pi]. - * So before using this method ux*ux+uy*uy should as much as possible close to 1. - * This methods is quite time consuming in order to keep as much as possible precision. - * It is NOT ALWAYS possible to do that only in one call of acos. Sometimes call to asin is necessary - * due to imperfection of acos near 0. and Pi (cos x ~ 1-x*x/2.) - */ -double EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(double ux, double uy) -{ - //When arc is lower than 0.707 Using Asin - if(fabs(ux)<0.707) - { - double ret=safeAcos(ux); - if(uy>0.) - return ret; - ret=-ret; - return ret; - } - else - { - double ret=safeAsin(uy); - if(ux>0.) - return ret; - if(ret>0.) - return M_PI-ret; - else - return -M_PI-ret; - } -} - -void EdgeArcCircle::getArcOfCirclePassingThru(const double *start, const double *middle, const double *end, - double *center, double& radius, double& angleInRad, double& angleInRad0) -{ - double delta=(middle[0]-start[0])*(end[1]-middle[1])-(end[0]-middle[0])*(middle[1]-start[1]); - double b1=(middle[1]*middle[1]+middle[0]*middle[0]-start[0]*start[0]-start[1]*start[1])/2; - double b2=(end[1]*end[1]+end[0]*end[0]-middle[0]*middle[0]-middle[1]*middle[1])/2; - center[0]=((end[1]-middle[1])*b1+(start[1]-middle[1])*b2)/delta; - center[1]=((middle[0]-end[0])*b1+(middle[0]-start[0])*b2)/delta; - radius=safeSqrt((start[0]-center[0])*(start[0]-center[0])+(start[1]-center[1])*(start[1]-center[1])); - angleInRad0=getAbsoluteAngleOfNormalizedVect((start[0]-center[0])/radius,(start[1]-center[1])/radius); - double angleInRadM=getAbsoluteAngleOfNormalizedVect((middle[0]-center[0])/radius,(middle[1]-center[1])/radius); - angleInRad=getAbsoluteAngleOfNormalizedVect(((start[0]-center[0])*(end[0]-center[0])+(start[1]-center[1])*(end[1]-center[1]))/(radius*radius), - ((start[0]-center[0])*(end[1]-center[1])-(start[1]-center[1])*(end[0]-center[0]))/(radius*radius)); - if(isAngleNotIn(angleInRad0,angleInRad,angleInRadM)) - angleInRad=angleInRad<0?2*M_PI+angleInRad:angleInRad-2*M_PI; -} - -void EdgeArcCircle::dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const -{ - stream << "5 1 0 1 "; - fillXfigStreamForLoc(stream); - stream << " 7 50 -1 -1 0.000 0 "; - if( (direction && _angle>=0) || (!direction && _angle<0)) - stream << '0';//'0' - else - stream << '1';//'1' - stream << " 0 0 "; - stream << box.fitXForXFigD(_center[0],resolution) << " " << box.fitYForXFigD(_center[1],resolution) << " "; - direction?_start->dumpInXfigFile(stream,resolution,box):_end->dumpInXfigFile(stream,resolution,box); - Node *middle=buildRepresentantOfMySelf(); - middle->dumpInXfigFile(stream,resolution,box); - middle->decrRef(); - direction?_end->dumpInXfigFile(stream,resolution,box):_start->dumpInXfigFile(stream,resolution,box); - stream << std::endl; -} - -void EdgeArcCircle::update(Node *m) -{ - getArcOfCirclePassingThru(*_start,*m,*_end,_center,_radius,_angle,_angle0); - updateBounds(); -} - -/*! - * This methods computes : - * \f[ - * \int_{Current Edge} -ydx - * \f] - */ -double EdgeArcCircle::getAreaOfZone() const -{ - return -_radius*_radius*(sin(_angle)-_angle)/2.+((*_start)[0]-(*_end)[0])*((*_start)[1]+(*_end)[1])/2.; -} - -double EdgeArcCircle::getCurveLength() const -{ - return fabs(_angle*_radius); -} - -void EdgeArcCircle::getBarycenter(double *bary) const -{ - bary[0]=_center[0]+_radius*cos(_angle0+_angle/2.); - bary[1]=_center[1]+_radius*sin(_angle0+_angle/2.); -} - -/*! - * \f[ - * bary[0]=\int_{Current Edge} -yxdx - * \f] - * \f[ - * bary[1]=\int_{Current Edge} -\frac{y^{2}}{2}dx - * \f] - * To compute these 2 expressions in this class we have : - * \f[ - * x=x_{0}+Radius \cdot cos(\theta) - * \f] - * \f[ - * y=y_{0}+Radius \cdot sin(\theta) - * \f] - * \f[ - * dx=-Radius \cdot sin(\theta) \cdot d\theta - * \f] - */ -void EdgeArcCircle::getBarycenterOfZone(double *bary) const -{ - double x0=_center[0]; - double y0=_center[1]; - double angle1=_angle0+_angle; - double tmp1=sin(angle1); - double tmp0=sin(_angle0); - double tmp2=_radius*_radius*_radius; - double tmp3=cos(angle1); - double tmp4=cos(_angle0); - bary[0]=_radius*x0*y0*(tmp4-tmp3)+_radius*_radius*(y0*(cos(2*_angle0)-cos(2*angle1))/4.+ - x0*(_angle/2.+(sin(2.*_angle0)-sin(2.*angle1))/4.)) - +tmp2*(tmp1*tmp1*tmp1-tmp0*tmp0*tmp0)/3.; - bary[1]=y0*y0*_radius*(tmp4-tmp3)/2.+_radius*_radius*y0*(_angle/2.+(sin(2.*_angle0)-sin(2.*angle1))/4.) - +tmp2*(tmp4-tmp3+(tmp3*tmp3*tmp3-tmp4*tmp4*tmp4)/3.)/2.; -} - -/*! - * Characteristic value used is angle in ]_Pi;Pi[ from axe 0x. - */ -bool EdgeArcCircle::isIn(double characterVal) const -{ - return isIn2Pi(_angle0,_angle,characterVal); -} - -Node *EdgeArcCircle::buildRepresentantOfMySelf() const -{ - return new Node(_center[0]+_radius*cos(_angle0+_angle/2.),_center[1]+_radius*sin(_angle0+_angle/2.)); -} - -/*! - * Characteristic value used is angle in ]_Pi;Pi[ from axe 0x. - * 'val1' and 'val2' have been detected previously as owning to this. - */ -bool EdgeArcCircle::isLower(double val1, double val2) const -{ - double myDelta1=val1-_angle0; - double myDelta2=val2-_angle0; - if(_angle>0.) - { - myDelta1=myDelta1>-(_radius*QUADRATIC_PLANAR::_precision)?myDelta1:myDelta1+2.*M_PI;//in some cases val1 or val2 are so close to angle0 that myDelta is close to 0. but negative. - myDelta2=myDelta2>-(_radius*QUADRATIC_PLANAR::_precision)?myDelta2:myDelta2+2.*M_PI; - return myDelta10.) - { - myDelta=myDelta>=0.?myDelta:myDelta+2.*M_PI; - return myDelta>0. && myDeltadelta; - } -} - -/*! - * Given the arc 'a' defined by 'start' angle and a 'delta' [-Pi;Pi] states for the angle 'angleIn' [-Pi;Pi] if it owns or not 'a'. - */ -bool EdgeArcCircle::isAngleNotIn(double start, double delta, double angleIn) -{ - double tmp=start; - if(tmp<0.) - tmp+=2*M_PI; - double tmp2=angleIn; - if(tmp2<0.) - tmp2+=2*M_PI; - if(tmp+delta>=2.*M_PI) - return (tmp2tmp+delta-2*M_PI); - else if(tmp+delta>=0.) - return (tmp2std::max(tmp,tmp+delta)); - else - return (tmp2>tmp) && (tmp2<(tmp+delta+2.*M_PI)); -} - -void EdgeArcCircle::updateBounds() -{ - _bounds.setValues(std::min((*_start)[0],(*_end)[0]),std::max((*_start)[0],(*_end)[0]),std::min((*_start)[1],(*_end)[1]),std::max((*_start)[1],(*_end)[1])); - if(isIn2Pi(_angle0,_angle,M_PI/2)) - _bounds[3]=_center[1]+_radius; - if(isIn2Pi(_angle0,_angle,-M_PI/2)) - _bounds[2]=_center[1]-_radius; - if(isIn2Pi(_angle0,_angle,0.)) - _bounds[1]=_center[0]+_radius; - if(isIn2Pi(_angle0,_angle,M_PI)) - _bounds[0]=_center[0]-_radius; -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx deleted file mode 100644 index d3a2fefcd..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__ -#define __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" -#include "InterpKernelGeo2DEdge.hxx" - -namespace INTERP_KERNEL -{ - class INTERPKERNELGEOMETRIC2D_EXPORT ArcCArcCIntersector : public SameTypeEdgeIntersector - { - public: - ArcCArcCIntersector(const EdgeArcCircle& e1, const EdgeArcCircle& e2); - bool haveTheySameDirection() const; - void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const; - void areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped); - std::list< IntersectElement > getIntersectionsCharacteristicVal() const; - private: - //! return angle in ]-Pi;Pi[ - 'node' must be on curve of '_e1' - double getAngle(Node *node) const; - static bool areArcsOverlapped(const EdgeArcCircle& a1, const EdgeArcCircle& a2); - private: - const EdgeArcCircle& getE1() const { return (const EdgeArcCircle&)_e1; } - const EdgeArcCircle& getE2() const { return (const EdgeArcCircle&)_e2; } - private: - double _dist; - }; - - class INTERPKERNELGEOMETRIC2D_EXPORT ArcCSegIntersector : public CrossTypeEdgeIntersector - { - public: - ArcCSegIntersector(const EdgeArcCircle& e1, const EdgeLin& e2, bool reverse=true); - //virtual overloading - void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const; - void areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped); - std::list< IntersectElement > getIntersectionsCharacteristicVal() const; - private: - const EdgeArcCircle& getE1() const { return (const EdgeArcCircle&)_e1; } - const EdgeLin& getE2() const { return (const EdgeLin&)_e2; } - private: - double _dx; - double _dy; - double _drSq; - double _cross; - double _determinant; - }; - - class INTERPKERNELGEOMETRIC2D_EXPORT EdgeArcCircle : public Edge - { - public: - EdgeArcCircle(std::istream& lineInXfig); - EdgeArcCircle(Node *start, Node *middle, Node *end, bool direction = true); - EdgeArcCircle(double sX, double sY, double mX, double mY, double eX, double eY); - EdgeArcCircle(Node *start, Node *end, const double *center, double radius, double angle0, double deltaAngle, bool direction=true); - //! for tests - void changeMiddle(Node *newMiddle); - void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const; - void update(Node *m); - double getAreaOfZone() const; - double getCurveLength() const; - void getBarycenter(double *bary) const; - void getBarycenterOfZone(double *bary) const; - bool isIn(double characterVal) const; - Node *buildRepresentantOfMySelf() const; - bool isLower(double val1, double val2) const; - double getCharactValue(const Node& node) const; - double getDistanceToPoint(const double *pt) const; - bool isNodeLyingOn(const double *coordOfNode) const; - TypeOfFunction getTypeOfFunc() const { return ARC_CIRCLE; } - void dynCastFunction(const EdgeLin * &seg, - const EdgeArcCircle * &arcSeg) const { arcSeg=this; } - const double *getCenter() const { return _center; } - void getCenter(double *center) const { center[0]=_center[0]; center[1]=_center[1]; } - bool doIHaveSameDirectionAs(const Edge& other) const { return false; } - void applySimilarity(double xBary, double yBary, double dimChar); - double getAngle0() const { return _angle0; } - double getRadius() const { return _radius; } - double getAngle() const { return _angle; } - static double getAbsoluteAngle(const double *vect, double& normVect); - static double getAbsoluteAngleOfNormalizedVect(double ux, double uy); - static void getArcOfCirclePassingThru(const double *start, const double *middle, const double *end, - double *center, double& radius, double& angleInRad, double& angleInRad0); - //! To avoid in aggressive optimizations nan. - static double safeSqrt(double val) { double ret=std::max(val,0.); return sqrt(ret); } - static double safeAcos(double cosAngle) { double ret=std::min(cosAngle,1.); ret=std::max(ret,-1.); return acos(ret); } - static double safeAsin(double sinAngle) { double ret=std::min(sinAngle,1.); ret=std::max(ret,-1.); return asin(ret); } - //! @param start and @param angleIn in ]-Pi;Pi] and @param delta in ]-2*Pi,2*Pi[ - static bool isIn2Pi(double start, double delta, double angleIn); - //! 'delta' 'start' in ]-Pi;Pi[ - static bool isAngleNotIn(double start, double delta, double angleIn); - //! for an angle 'angle' in ]-3*Pi;3*Pi[ returns angle in ]-Pi;Pi[ - static double normalizeAngle(double angle) { if(angle>M_PI) return angle-2.*M_PI; if(angle<-M_PI) return angle+2.*M_PI; return angle; } - protected: - void updateBounds(); - Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const; - protected: - //!Value between -2Pi and 2Pi - double _angle; - //!Value between -Pi and Pi - double _angle0; - double _radius; - double _center[2]; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx deleted file mode 100644 index 9298af554..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DEdgeInfLin.hxx" - -using namespace INTERP_KERNEL; - -EdgeInfLin::EdgeInfLin(Node *pointPassingThrough, double slope) -{ - _start=pointPassingThrough; - _start->incrRef(); - _end=new Node((*_start)[0]+cos(slope),(*_start)[1]+sin(slope)); -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx deleted file mode 100644 index 157386825..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DEDGEINFLIN_HXX__ -#define __INTERPKERNELGEO2DEDGEINFLIN_HXX__ - -#include "InterpKernelGeo2DEdgeLin.hxx" - -namespace INTERP_KERNEL -{ - class EdgeInfLin : public EdgeLin - { - public: - EdgeInfLin(Node *start, Node *end):EdgeLin(start,end,true) { } - EdgeInfLin(Node *pointPassingThrough, double slope); - bool isIn(double characterVal) const { return true; } - void dynCastFunction(const EdgeLin * &seg, - const EdgeArcCircle * &arcSeg) const { seg=this; } - void dumpInXfigFile(std::ostream& stream) const { } - private: - ~EdgeInfLin() { } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx deleted file mode 100644 index fa7de64f8..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DEdgeLin.hxx" -#include "InterpKernelGeo2DNode.hxx" -#include "InterpKernelException.hxx" - -using namespace INTERP_KERNEL; - -namespace INTERP_KERNEL -{ - extern const unsigned MAX_SIZE_OF_LINE_XFIG_FILE=1024; -} - -SegSegIntersector::SegSegIntersector(const EdgeLin& e1, const EdgeLin& e2):SameTypeEdgeIntersector(e1,e2) -{ - _matrix[0]=(*(e2.getStartNode()))[0]-(*(e2.getEndNode()))[0]; - _matrix[1]=(*(e1.getEndNode()))[0]-(*(e1.getStartNode()))[0]; - _matrix[2]=(*(e2.getStartNode()))[1]-(*(e2.getEndNode()))[1]; - _matrix[3]=(*(e1.getEndNode()))[1]-(*(e1.getStartNode()))[1]; - _col[0]=_matrix[3]*(*(e1.getStartNode()))[0]-_matrix[1]*(*(e1.getStartNode()))[1]; - _col[1]=-_matrix[2]*(*(e2.getStartNode()))[0]+_matrix[0]*(*(e2.getStartNode()))[1]; - //Little trick to avoid problems if 'e1' and 'e2' are colinears and along Ox or Oy axes. - if(fabs(_matrix[3])>fabs(_matrix[1])) - _ind=0; - else - _ind=1; -} - -/*! - * Must be called when 'this' and 'other' have been detected to be at least colinear. Typically they are overlapped. - * Must be called after call of areOverlappedOrOnlyColinears. - */ -bool SegSegIntersector::haveTheySameDirection() const -{ - return (_matrix[3]*_matrix[1]+_matrix[2]*_matrix[0])>0.; - //return (_matrix[_ind?1:0]>0. && _matrix[_ind?3:2]>0.) || (_matrix[_ind?1:0]<0. && _matrix[_ind?3:2]<0.); -} - -/*! - * Precondition start and end must be so that there predecessor was in the same direction than 'e1' - */ -void SegSegIntersector::getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const -{ - getCurveAbscisse(start,whereStart,commonNode); - getCurveAbscisse(end,whereEnd,commonNode); -} - -void SegSegIntersector::getCurveAbscisse(Node *node, TypeOfLocInEdge& where, MergePoints& commonNode) const -{ - bool obvious; - obviousCaseForCurvAbscisse(node,where,commonNode,obvious); - if(obvious) - return ; - double ret=((*node)[!_ind]-(*_e1.getStartNode())[!_ind])/((*_e1.getEndNode())[!_ind]-(*_e1.getStartNode())[!_ind]); - if(ret>0. && ret <1.) - where=INSIDE; - else if(ret<0.) - where=OUT_BEFORE; - else - where=OUT_AFTER; -} - -/*! - * areColinears method should be called before with a returned colinearity equal to false to avoid bad news. - */ -std::list< IntersectElement > SegSegIntersector::getIntersectionsCharacteristicVal() const -{ - std::list< IntersectElement > ret; - double x=_matrix[0]*_col[0]+_matrix[1]*_col[1]; - double y=_matrix[2]*_col[0]+_matrix[3]*_col[1]; - //Only one intersect point possible - Node *node=new Node(x,y); - node->declareOn(); - bool i_1S=_e1.getStartNode()->isEqual(*node); - bool i_1E=_e1.getEndNode()->isEqual(*node); - bool i_2S=_e2.getStartNode()->isEqual(*node); - bool i_2E=_e2.getEndNode()->isEqual(*node); - ret.push_back(IntersectElement(_e1.getCharactValue(*node), - _e2.getCharactValue(*node), - i_1S,i_1E,i_2S,i_2E,node,_e1,_e2,keepOrder())); - return ret; -} - -/*! - * retrieves if segs are colinears. - * WARNING !!! Contrary to areOverlappedOrOnlyColinears method, this method use an - * another precision to detect colinearity ! - */ -bool SegSegIntersector::areColinears() const -{ - double determinant=_matrix[0]*_matrix[3]-_matrix[1]*_matrix[2]; - return fabs(determinant)2.*QUADRATIC_PLANAR::_precision)//2*_precision due to max of offset on _start and _end - { - colinearity=false; areOverlapped=false; - _matrix[0]/=determinant; _matrix[1]/=determinant; _matrix[2]/=determinant; _matrix[3]/=determinant; - } - else - { - colinearity=true; - //retrieving initial matrix - double tmp=_matrix[0]; _matrix[0]=_matrix[3]; _matrix[3]=tmp; - _matrix[1]=-_matrix[1]; _matrix[2]=-_matrix[2]; - // - double deno=sqrt(_matrix[0]*_matrix[0]+_matrix[1]*_matrix[1]); - double x=(*(_e1.getStartNode()))[0]-(*(_e2.getStartNode()))[0]; - double y=(*(_e1.getStartNode()))[1]-(*(_e2.getStartNode()))[1]; - areOverlapped=fabs((_matrix[1]*y+_matrix[0]*x)/deno)0. && characterVal<1.; -} - -Node *EdgeLin::buildRepresentantOfMySelf() const -{ - return new Node(((*(_start))[0]+(*(_end))[0])/2.,((*(_start))[1]+(*(_end))[1])/2.); -} - -double EdgeLin::getCharactValue(const Node& node) const -{ - return getCharactValueEng(node); -} - -double EdgeLin::getDistanceToPoint(const double *pt) const -{ - double loc=getCharactValueEng(pt); - if(loc>0. && loc<1.) - { - double tmp[2]; - tmp[0]=(*_start)[0]*(1-loc)+loc*(*_end)[0]; - tmp[1]=(*_start)[1]*(1-loc)+loc*(*_end)[1]; - return Node::distanceBtw2Pt(pt,tmp); - } - else - { - double dist1=Node::distanceBtw2Pt(*_start,pt); - double dist2=Node::distanceBtw2Pt(*_end,pt); - return std::min(dist1,dist2); - } -} - -bool EdgeLin::isNodeLyingOn(const double *coordOfNode) const -{ - double dBase=sqrt(_start->distanceWithSq(*_end)); - double d1=Node::distanceBtw2Pt(*_start,coordOfNode); - d1+=Node::distanceBtw2Pt(*_end,coordOfNode); - return Node::areDoubleEquals(dBase,d1); -} - -void EdgeLin::dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const -{ - stream << "2 1 0 1 "; - fillXfigStreamForLoc(stream); - stream << " 7 50 -1 -1 0.000 0 0 -1 0 0 2" << std::endl; - direction?_start->dumpInXfigFile(stream,resolution,box):_end->dumpInXfigFile(stream,resolution,box); - direction?_end->dumpInXfigFile(stream,resolution,box):_start->dumpInXfigFile(stream,resolution,box); - stream << std::endl; -} - -void EdgeLin::update(Node *m) -{ - updateBounds(); -} - -double EdgeLin::getNormSq() const -{ - return _start->distanceWithSq(*_end); -} - -/*! - * This methods computes : - * \f[ - * \int_{Current Edge} -ydx - * \f] - */ -double EdgeLin::getAreaOfZone() const -{ - return ((*_start)[0]-(*_end)[0])*((*_start)[1]+(*_end)[1])/2.; -} - -void EdgeLin::getBarycenter(double *bary) const -{ - bary[0]=((*_start)[0]+(*_end)[0])/2.; - bary[1]=((*_start)[1]+(*_end)[1])/2.; -} - -/*! - * \f[ - * bary[0]=\int_{Current Edge} -yxdx - * \f] - * \f[ - * bary[1]=\int_{Current Edge} -\frac{y^{2}}{2}dx - * \f] - * To compute these 2 expressions in this class we have : - * \f[ - * y=y_{1}+\frac{y_{2}-y_{1}}{x_{2}-x_{1}}(x-x_{1}) - * \f] - */ -void EdgeLin::getBarycenterOfZone(double *bary) const -{ - double x1=(*_start)[0]; - double y1=(*_start)[1]; - double x2=(*_end)[0]; - double y2=(*_end)[1]; - bary[0]=(x1-x2)*(y1*(2.*x1+x2)+y2*(2.*x2+x1))/6.; - //bary[0]+=(y1-y2)*(x2*x2/3.-(x1*x2+x1*x1)/6.)+y1*(x1*x1-x2*x2)/2.; - //bary[0]+=(y1-y2)*((x2*x2+x1*x2+x1*x1)/3.-(x2+x1)*x1/2.)+y1*(x1*x1-x2*x2)/2.; - bary[1]=(x1-x2)*(y1*(y1+y2)+y2*y2)/6.; -} - -double EdgeLin::getCurveLength() const -{ - double x=(*_start)[0]-(*_end)[0]; - double y=(*_start)[1]-(*_end)[1]; - return sqrt(x*x+y*y); -} - -Edge *EdgeLin::buildEdgeLyingOnMe(Node *start, Node *end, bool direction) const -{ - return new EdgeLin(start,end,direction); -} - -/*! - * No precision should be introduced here. Just think as if precision was perfect. - */ -void EdgeLin::updateBounds() -{ - _bounds.setValues(std::min((*_start)[0],(*_end)[0]),std::max((*_start)[0],(*_end)[0]),std::min((*_start)[1],(*_end)[1]),std::max((*_start)[1],(*_end)[1])); -} - -double EdgeLin::getCharactValueEng(const double *node) const -{ - double car1_1x=node[0]-(*(_start))[0]; double car1_2x=(*(_end))[0]-(*(_start))[0]; - double car1_1y=node[1]-(*(_start))[1]; double car1_2y=(*(_end))[1]-(*(_start))[1]; - return (car1_1x*car1_2x+car1_1y*car1_2y)/(car1_2x*car1_2x+car1_2y*car1_2y); -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx deleted file mode 100644 index 8221eb5ed..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DEDGELIN_HXX__ -#define __INTERPKERNELGEO2DEDGELIN_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" -#include "InterpKernelGeo2DEdge.hxx" - -namespace INTERP_KERNEL -{ - class SegSegIntersector : SameTypeEdgeIntersector - { - friend class Edge; - public: - SegSegIntersector(const EdgeLin& e1, const EdgeLin& e2); - bool areColinears() const; - bool haveTheySameDirection() const; - void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const; - void areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped); - std::list< IntersectElement > getIntersectionsCharacteristicVal() const; - private: - void getCurveAbscisse(Node *node, TypeOfLocInEdge& where, MergePoints& commonNode) const; - private: - //! index on which all single index op will be performed. Filled in case colinearity is equal to true. - int _ind; - double _col[2]; - double _matrix[4];//SPACEDIM*SPACEDIM - }; - - class INTERPKERNELGEOMETRIC2D_EXPORT EdgeLin : public Edge - { - friend class SegSegIntersector; - public: - EdgeLin(std::istream& lineInXfig); - EdgeLin(Node *start, Node *end, bool direction=true); - EdgeLin(double sX, double sY, double eX, double eY); - ~EdgeLin(); - TypeOfFunction getTypeOfFunc() const { return SEG; } - void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const; - void update(Node *m); - double getNormSq() const; - double getAreaOfZone() const; - double getCurveLength() const; - void getBarycenter(double *bary) const; - void getBarycenterOfZone(double *bary) const; - bool isIn(double characterVal) const; - Node *buildRepresentantOfMySelf() const; - double getCharactValue(const Node& node) const; - double getDistanceToPoint(const double *pt) const; - bool isNodeLyingOn(const double *coordOfNode) const; - bool isLower(double val1, double val2) const { return val1incrRef(); -} - -ElementaryEdge::~ElementaryEdge() -{ - if(_ptr) - _ptr->decrRef(); -} - -bool ElementaryEdge::isNodeIn(Node *n) const -{ - return _ptr->getStartNode()==n || _ptr->getEndNode()==n; -} - -/*! - * \b WARNING contrary to INTERP_KERNEL::Edge::getBarycenterOfZone method called, - * this one is cumulative. - */ -void ElementaryEdge::getBarycenterOfZone(double *bary) const -{ - double tmp[2]; - _ptr->getBarycenterOfZone(tmp); - if(_direction) - { - bary[0]+=tmp[0]; - bary[1]+=tmp[1]; - } - else - { - bary[0]-=tmp[0]; - bary[1]-=tmp[1]; - } -} - -void ElementaryEdge::fillBounds(Bounds& output) const -{ - output.aggregate(_ptr->getBounds()); -} - -void ElementaryEdge::getAllNodes(std::set& output) const -{ - output.insert(_ptr->getStartNode()); - output.insert(_ptr->getEndNode()); -} - -void ElementaryEdge::getBarycenter(double *bary, double& weigh) const -{ - _ptr->getBarycenter(bary); - weigh=_ptr->getCurveLength(); -} - -ElementaryEdge *ElementaryEdge::clone() const -{ - return new ElementaryEdge(*this); -} - -void ElementaryEdge::initLocations() const -{ - _ptr->initLocs(); -} - -/*! - * WARNING use this method if and only if this is so that it is completely in/out/on of @param pol. - */ -TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelf(const ComposedEdge& pol, TypeOfEdgeLocInPolygon precEdgeLoc) const -{ - if(getLoc()!=FULL_UNKNOWN) - return getLoc(); - //obvious cases - if(precEdgeLoc==FULL_IN_1) - { - if(getStartNode()->getLoc()==ON_1) - { - declareOut(); - return getLoc(); - } - else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1) - { - declareIn(); - return getLoc(); - } - } - if(precEdgeLoc==FULL_OUT_1) - { - if(getStartNode()->getLoc()==ON_1) - { - declareIn(); - return getLoc(); - } - else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1) - { - declareOut(); - return getLoc(); - } - } - if(getStartNode()->getLoc()==IN_1 || getEndNode()->getLoc()==IN_1) - { - declareIn(); - return getLoc(); - } - if(getStartNode()->getLoc()==OUT_1 || getEndNode()->getLoc()==OUT_1) - { - declareOut(); - return getLoc(); - } - //a seek is requested - return locateFullyMySelfAbsolute(pol); -} - -TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelfAbsolute(const ComposedEdge& pol) const -{ - Node *node=_ptr->buildRepresentantOfMySelf(); - if(pol.isInOrOut(node)) - declareIn(); - else - declareOut(); - node->decrRef(); - return getLoc(); -} - -Node *ElementaryEdge::getEndNode() const -{ - if(_direction) - return _ptr->getEndNode(); - else return _ptr->getStartNode(); -} - -Node *ElementaryEdge::getStartNode() const -{ - if(_direction) - return _ptr->getStartNode(); - else - return _ptr->getEndNode(); -} - -bool ElementaryEdge::changeEndNodeWith(Node *node) const -{ - if(_direction) - return _ptr->changeEndNodeWith(node); - else - return _ptr->changeStartNodeWith(node); -} - -bool ElementaryEdge::changeStartNodeWith(Node *node) const -{ - if(_direction) - return _ptr->changeStartNodeWith(node); - else - return _ptr->changeEndNodeWith(node); -} - -void ElementaryEdge::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const -{ - _ptr->dumpInXfigFile(stream,_direction,resolution,box); -} - -bool ElementaryEdge::intresicEqual(const ElementaryEdge *other) const -{ - return _ptr==other->_ptr; -} - -bool ElementaryEdge::intresicEqualDirSensitive(const ElementaryEdge *other) const -{ - return ( _direction==other->_direction ) && (_ptr==other->_ptr); -} - -bool ElementaryEdge::intresincEqCoarse(const Edge *other) const -{ - return _ptr==other; -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx deleted file mode 100644 index 11168621a..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DELEMENTARYEDGE_HXX__ -#define __INTERPKERNELGEO2DELEMENTARYEDGE_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" -#include "InterpKernelException.hxx" -#include "InterpKernelGeo2DAbstractEdge.hxx" -#include "InterpKernelGeo2DEdge.hxx" - -namespace INTERP_KERNEL -{ - class INTERPKERNELGEOMETRIC2D_EXPORT ElementaryEdge - { - public: - ElementaryEdge(Edge *ptr, bool direction):_direction(direction),_ptr(ptr) { } - ElementaryEdge(const ElementaryEdge& other); - ~ElementaryEdge(); - bool isThereStartPoint() const { return _iterator.isValid(); } - IteratorOnComposedEdge& getIterator() { return _iterator; } - bool completed() const { return false; } - void declareOn() const { _ptr->declareOn(); } - void declareIn() const { _ptr->declareIn(); } - void declareOut() const { _ptr->declareOut(); } - TypeOfEdgeLocInPolygon getLoc() const { return _ptr->getLoc(); } - Edge *getPtr() const { return _ptr; } - void reverse() { _direction=(!_direction); } - bool isNodeIn(Node *n) const; - double getAreaOfZone() const { double ret=_ptr->getAreaOfZone(); return _direction?ret:-ret; } - void getBarycenterOfZone(double *bary) const; - void fillBounds(Bounds& output) const; - void applySimilarity(double xBary, double yBary, double dimChar) { _ptr->applySimilarity(xBary,yBary,dimChar); } - void getAllNodes(std::set& output) const; - void getBarycenter(double *bary, double& weigh) const; - ElementaryEdge *clone() const; - void initLocations() const; - int size() const; - TypeOfEdgeLocInPolygon locateFullyMySelfAbsolute(const ComposedEdge& pol) const; - TypeOfEdgeLocInPolygon locateFullyMySelf(const ComposedEdge& pol, TypeOfEdgeLocInPolygon precEdgeLoc) const; - Node *getEndNode() const; - Node *getStartNode() const; - double getCurveLength() const { return _ptr->getCurveLength(); } - bool changeEndNodeWith(Node *node) const; - bool changeStartNodeWith(Node *node) const; - bool intresicEqual(const ElementaryEdge *other) const; - bool intresicEqualDirSensitive(const ElementaryEdge *other) const; - void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const; - bool getDirection() const { return _direction; } - bool intresincEqCoarse(const Edge *other) const; - private: - bool _direction; - Edge *_ptr; - IteratorOnComposedEdge _iterator; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx deleted file mode 100644 index d95825f74..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DNode.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" - -using namespace INTERP_KERNEL; - -Node::Node(double x, double y):_cnt(1),_loc(UNKNOWN) -{ - _coords[0]=x; _coords[1]=y; -} - -Node::Node(const double *coords):_cnt(1),_loc(UNKNOWN) -{ - _coords[0]=coords[0]; - _coords[1]=coords[1]; -} - -Node::Node(std::istream& stream):_cnt(1),_loc(UNKNOWN) -{ - int tmp; - stream >> tmp; - _coords[0]=((double) tmp)/1e4; - stream >> tmp; - _coords[1]=((double) tmp)/1e4; -} - -Node::~Node() -{ -} - -bool Node::decrRef() -{ - bool ret=(--_cnt==0); - if(ret) - delete this; - return ret; -} - -bool Node::isEqual(const Node& other) const -{ - const unsigned SPACEDIM=2; - bool ret=true; - for(unsigned i=0;i& track) const -{ - bool ret=isEqual(other); - if(ret) - track.push_back((Node *)&other); - return ret; -} - -void Node::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const -{ - stream << box.fitXForXFig(_coords[0],resolution) << " " << box.fitYForXFig(_coords[1],resolution) << " "; -} - -double Node::distanceWithSq(const Node& other) const -{ - return (_coords[0]-other._coords[0])*(_coords[0]-other._coords[0])+(_coords[1]-other._coords[1])*(_coords[1]-other._coords[1]); -} - -/*! - * WARNING different from 'computeAngle' method ! The returned value are not in the same interval ! - * Here in -Pi/2; Pi/2. Typically this method returns the same value by exchanging pt1 and pt2. - * Use in process of detection of a point in or not in polygon. - */ -double Node::computeSlope(const double *pt1, const double *pt2) -{ - double x=pt2[0]-pt1[0]; - double y=pt2[1]-pt1[1]; - double norm=sqrt(x*x+y*y); - double ret=EdgeArcCircle::safeAcos(fabs(x)/norm); - if( (x>=0. && y>=0.) || (x<0. && y<0.) ) - return ret; - else - return M_PI-ret; -} - -/*! - * WARNING different from 'computeSlope' method. Here angle in -Pi;Pi is returned. - * This method is anti-symetric. - */ -double Node::computeAngle(const double *pt1, const double *pt2) -{ - double x=pt2[0]-pt1[0]; - double y=pt2[1]-pt1[1]; - double norm=sqrt(x*x+y*y); - return EdgeArcCircle::getAbsoluteAngleOfNormalizedVect(x/norm,y/norm); -} - -/*! - * apply a Similarity transformation on this. - * @param xBary is the opposite of the X translation to do. - * @param yBary is the opposite of the Y translation to do. - * @param dimChar is the reduction factor. - */ -void Node::applySimilarity(double xBary, double yBary, double dimChar) -{ - _coords[0]=(_coords[0]-xBary)/dimChar; - _coords[1]=(_coords[1]-yBary)/dimChar; -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx deleted file mode 100644 index e58d62061..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DNODE_HXX__ -#define __INTERPKERNELGEO2DNODE_HXX__ - -#include "InterpKernelGeo2DPrecision.hxx" -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" - -#include -#include -#include - -namespace INTERP_KERNEL -{ - typedef enum - { - IN_1 = 7, - ON_1 = 8, - ON_LIM_1 = 12, - ON_TANG_1 = 9, - OUT_1 = 10, - UNKNOWN = 11 - } TypeOfLocInPolygon; - - class Bounds; - - /*! - * As nodes can be shared between edges it is dealed with ref counting. - */ - class INTERPKERNELGEOMETRIC2D_EXPORT Node - { - public: - Node(double x, double y); - Node(const double *coords); - Node(std::istream& stream); - void incrRef() const { _cnt++; } - bool decrRef(); - void initLocs() const { _loc=UNKNOWN; } - void setLoc(TypeOfLocInPolygon loc) const { _loc=loc; } - TypeOfLocInPolygon getLoc() const { return _loc; } - void declareIn() const { if(_loc==UNKNOWN) _loc=IN_1; } - void declareOn() const { if(_loc==UNKNOWN) _loc=ON_1; } - void declareOnLim() const { if(_loc==UNKNOWN || _loc==ON_1) _loc=ON_LIM_1; } - void declareOut() { if(_loc==UNKNOWN) _loc=OUT_1; } - void declareOnTangent() { _loc=ON_TANG_1; } - operator const double*() const { return _coords; } - bool isEqual(const Node& other) const; - //returns an angle in -Pi/2;Pi/2. - double getSlope(const Node& other) const; - bool isEqualAndKeepTrack(const Node& other, std::vector& track) const; - void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const; - double distanceWithSq(const Node& other) const; - double operator[](int i) const { return _coords[i]; } - //! use with caution - void setNewCoords(double x, double y) { _coords[0]=x; _coords[1]=y; } - //returns an angle in -Pi/2;Pi/2. - static double computeSlope(const double *pt1, const double *pt2); - //returns an angle in -Pi;Pi - static double computeAngle(const double *pt1, const double *pt2); - void applySimilarity(double xBary, double yBary, double dimChar); - static double dot(const double *vect1, const double *vect2) { return vect1[0]*vect2[0]+vect1[1]*vect2[1]; } - static double sign(double val) { if(val>=0) return 1.; else return -1.; } - static double norm(const double *vect) { return sqrt(vect[0]*vect[0]+vect[1]*vect[1]); } - static bool areDoubleEquals(double a, double b) { return fabs(a-b) < QUADRATIC_PLANAR::_precision; } - //! idem areDoubleEquals except that precision of comparison is modified. - static bool areDoubleEqualsWP(double a, double b, double k) { return fabs(a-b) < k*QUADRATIC_PLANAR::_precision; } - static double distanceBtw2Pt(const double *a, const double *b) { return sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])); } - static double distanceBtw2PtSq(const double *a, const double *b) { return (a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]); } - protected: - ~Node(); - protected: - mutable unsigned char _cnt; - mutable TypeOfLocInPolygon _loc; - double _coords[2]; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.cxx deleted file mode 100644 index cba6e5881..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.cxx +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DPrecision.hxx" - -double INTERP_KERNEL::QUADRATIC_PLANAR::_precision=1e-14; - -double INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=1e-14; - -void INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(double precision) -{ - INTERP_KERNEL::QUADRATIC_PLANAR::_precision=precision; -} - -void INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(double precision) -{ - INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=precision; -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.hxx deleted file mode 100644 index 371a85e22..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DPrecision.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DPRECISION_HXX__ -#define __INTERPKERNELGEO2DPRECISION_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" - -namespace INTERP_KERNEL -{ - class INTERPKERNELGEOMETRIC2D_EXPORT QUADRATIC_PLANAR - { - public: - static double _precision; - static double _arc_detection_precision; - static void setPrecision(double precision); - static void setArcDetectionPrecision(double precision); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx deleted file mode 100644 index ef38d42ce..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ /dev/null @@ -1,637 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DAbstractEdge.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" -#include "InterpKernelGeo2DBounds.hxx" -#include "InterpKernelGeo2DEdge.txx" - -#include -#include -#include -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_KERNEL -{ - const unsigned MAX_SIZE_OF_LINE_XFIG_FILE=1024; -} - -QuadraticPolygon::QuadraticPolygon(const char *file) -{ - char currentLine[MAX_SIZE_OF_LINE_XFIG_FILE]; - std::ifstream stream(file); - stream.exceptions(std::ios_base::eofbit); - try - { - do - stream.getline(currentLine,MAX_SIZE_OF_LINE_XFIG_FILE); - while(strcmp(currentLine,"1200 2")!=0); - do - { - Edge *newEdge=Edge::buildFromXfigLine(stream); - if(!empty()) - newEdge->changeStartNodeWith(back()->getEndNode()); - pushBack(newEdge); - } - while(1); - } - catch(std::ifstream::failure&) - { - } - front()->changeStartNodeWith(back()->getEndNode()); -} - -QuadraticPolygon::~QuadraticPolygon() -{ -} - -QuadraticPolygon *QuadraticPolygon::buildLinearPolygon(std::vector& nodes) -{ - QuadraticPolygon *ret=new QuadraticPolygon; - int size=nodes.size(); - for(int i=0;ipushBack(new EdgeLin(nodes[i],nodes[(i+1)%size])); - nodes[i]->decrRef(); - } - return ret; -} - -QuadraticPolygon *QuadraticPolygon::buildArcCirclePolygon(std::vector& nodes) -{ - QuadraticPolygon *ret=new QuadraticPolygon; - int size=nodes.size(); - for(int i=0;ipushBack(new EdgeLin(nodes[i],nodes[(i+1)%(size/2)])); - else - ret->pushBack(new EdgeArcCircle(nodes[i],nodes[i+size/2],nodes[(i+1)%(size/2)])); - nodes[i]->decrRef(); nodes[i+size/2]->decrRef(); - } - return ret; -} - -void QuadraticPolygon::buildDbgFile(const std::vector& nodes, const char *fileName) -{ - std::ofstream file(fileName); - file << std::setprecision(16); - file << " double coords[]=" << std::endl << " { "; - for(std::vector::const_iterator iter=nodes.begin();iter!=nodes.end();iter++) - { - if(iter!=nodes.begin()) - file << "," << std::endl << " "; - file << (*(*iter))[0] << ", " << (*(*iter))[1]; - } - file << "};" << std::endl; -} - -void QuadraticPolygon::closeMe() const -{ - if(!front()->changeStartNodeWith(back()->getEndNode())) - throw(Exception("big error: not closed polygon...")); -} - -void QuadraticPolygon::circularPermute() -{ - if(_sub_edges.size()>1) - { - ElementaryEdge *first=_sub_edges.front(); - _sub_edges.pop_front(); - _sub_edges.push_back(first); - } -} - -bool QuadraticPolygon::isButterfly() const -{ - for(std::list::const_iterator it=_sub_edges.begin();it!=_sub_edges.end();it++) - { - Edge *e1=(*it)->getPtr(); - std::list::const_iterator it2=it; - it2++; - for(;it2!=_sub_edges.end();it2++) - { - MergePoints commonNode; - ComposedEdge *outVal1=new ComposedEdge; - ComposedEdge *outVal2=new ComposedEdge; - Edge *e2=(*it2)->getPtr(); - if(e1->intersectWith(e2,commonNode,*outVal1,*outVal2)) - { - Delete(outVal1); - Delete(outVal2); - return true; - } - Delete(outVal1); - Delete(outVal2); - } - } - return false; -} - -void QuadraticPolygon::dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const -{ - std::ofstream file(fileName); - const int resolution=1200; - Bounds box; - box.prepareForAggregation(); - fillBounds(box); - other.fillBounds(box); - dumpInXfigFile(file,resolution,box); - other.ComposedEdge::dumpInXfigFile(file,resolution,box); -} - -void QuadraticPolygon::dumpInXfigFile(const char *fileName) const -{ - std::ofstream file(fileName); - const int resolution=1200; - Bounds box; - box.prepareForAggregation(); - fillBounds(box); - dumpInXfigFile(file,resolution,box); -} - -void QuadraticPolygon::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const -{ - stream << "#FIG 3.2 Produced by xfig version 3.2.5-alpha5" << std::endl; - stream << "Landscape" << std::endl; - stream << "Center" << std::endl; - stream << "Metric" << std::endl; - stream << "Letter" << std::endl; - stream << "100.00" << std::endl; - stream << "Single" << std::endl; - stream << "-2" << std::endl; - stream << resolution << " 2" << std::endl; - ComposedEdge::dumpInXfigFile(stream,resolution,box); -} - -/*! - * Warning contrary to intersectWith method this method is \b NOT const. 'this' and 'other' are modified after call of this method. - */ -double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other) -{ - double ret=0.,xBaryBB,yBaryBB; - double fact=normalize(&other,xBaryBB,yBaryBB); - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) - { - ret+=fabs((*iter)->getArea()); - delete *iter; - } - return ret*fact*fact; -} - -/*! - * Warning contrary to intersectWith method this method is \b NOT const. 'this' and 'other' are modified after call of this method. - */ -double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other, double* barycenter) -{ - double ret=0.,bary[2],area,xBaryBB,yBaryBB; - barycenter[0] = barycenter[1] = 0.; - double fact=normalize(&other,xBaryBB,yBaryBB); - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) - { - area=fabs((*iter)->getArea()); - (*iter)->getBarycenter(bary); - delete *iter; - ret+=area; - barycenter[0] += bary[0]*area; - barycenter[1] += bary[1]*area; - } - if ( ret > std::numeric_limits::min() ) - { - barycenter[0]=barycenter[0]/ret*fact+xBaryBB; - barycenter[1]=barycenter[1]/ret*fact+yBaryBB; - - } - return ret*fact*fact; -} - -/*! - * \b WARNING this method is const and other is const too. \b BUT location of Edges in 'this' and 'other' are nevertheless modified. - * This is possible because loc attribute in Edge class is mutable. - * This implies that if 'this' or/and 'other' are reused for intersect* method initLocations has to be called on each of this/them. - */ -double QuadraticPolygon::intersectWith(const QuadraticPolygon& other) const -{ - double ret=0.; - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) - { - ret+=fabs((*iter)->getArea()); - delete *iter; - } - return ret; -} - -/*! - * \b WARNING this method is const and other is const too. \b BUT location of Edges in 'this' and 'other' are nevertheless modified. - * This is possible because loc attribute in Edge class is mutable. - * This implies that if 'this' or/and 'other' are reused for intersect* method initLocations has to be called on each of this/them. - */ -double QuadraticPolygon::intersectWith(const QuadraticPolygon& other, double* barycenter) const -{ - double ret=0., bary[2]; - barycenter[0] = barycenter[1] = 0.; - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) - { - double area = fabs((*iter)->getArea()); - (*iter)->getBarycenter(bary); - delete *iter; - ret+=area; - barycenter[0] += bary[0]*area; - barycenter[1] += bary[1]*area; - } - if ( ret > std::numeric_limits::min() ) - { - barycenter[0] /= ret; - barycenter[1] /= ret; - } - return ret; -} - -/*! - * \b WARNING this method is const and other is const too. \b BUT location of Edges in 'this' and 'other' are nevertheless modified. - * This is possible because loc attribute in Edge class is mutable. - * This implies that if 'this' or/and 'other' are reused for intersect* method initLocations has to be called on each of this/them. - */ -void QuadraticPolygon::intersectForPerimeter(const QuadraticPolygon& other, double& perimeterThisPart, double& perimeterOtherPart, double& perimeterCommonPart) const -{ - perimeterThisPart=0.; perimeterOtherPart=0.; perimeterCommonPart=0.; - QuadraticPolygon cpyOfThis(*this); - QuadraticPolygon cpyOfOther(other); int nbOfSplits=0; - splitPolygonsEachOther(cpyOfThis,cpyOfOther,nbOfSplits); - performLocatingOperation(cpyOfOther); - other.performLocatingOperation(cpyOfThis); - cpyOfThis.dispatchPerimeterExcl(perimeterThisPart,perimeterCommonPart); - cpyOfOther.dispatchPerimeterExcl(perimeterOtherPart,perimeterCommonPart); - perimeterCommonPart/=2.; -} - -/*! - * \b WARNING this method is const and other is const too. \b BUT location of Edges in 'this' and 'other' are nevertheless modified. - * This is possible because loc attribute in Edge class is mutable. - * This implies that if 'this' or/and 'other' are reused for intersect* method initLocations has to be called on each of this/them. - * - * polThis.size()==this->size() and polOther.size()==other.size(). - * For each ElementaryEdge of 'this', the corresponding contribution in resulting polygon is in 'polThis'. - * For each ElementaryEdge of 'other', the corresponding contribution in resulting polygon is in 'polOther'. - * As consequence common part are counted twice (in polThis \b and in polOther). - */ -void QuadraticPolygon::intersectForPerimeterAdvanced(const QuadraticPolygon& other, std::vector< double >& polThis, std::vector< double >& polOther) const -{ - polThis.resize(size()); - polOther.resize(other.size()); - IteratorOnComposedEdge it1((QuadraticPolygon *)this); - int edgeId=0; - for(it1.first();!it1.finished();it1.next(),edgeId++) - { - ElementaryEdge* curE1=it1.current(); - QuadraticPolygon cpyOfOther(other); - QuadraticPolygon tmp; - tmp.pushBack(curE1->clone()); - int tmp2; - splitPolygonsEachOther(tmp,cpyOfOther,tmp2); - other.performLocatingOperation(tmp); - tmp.dispatchPerimeter(polThis[edgeId]); - } - // - IteratorOnComposedEdge it2((QuadraticPolygon *)&other); - edgeId=0; - for(it2.first();!it2.finished();it2.next(),edgeId++) - { - ElementaryEdge* curE2=it2.current(); - QuadraticPolygon cpyOfThis(*this); - QuadraticPolygon tmp; - tmp.pushBack(curE2->clone()); - int tmp2; - splitPolygonsEachOther(tmp,cpyOfThis,tmp2); - performLocatingOperation(tmp); - tmp.dispatchPerimeter(polOther[edgeId]); - } -} - - -/*! - * numberOfCreatedPointsPerEdge is resized to the number of edges of 'this'. - * This method returns in ordered maner the number of newly created points per edge. - * This method performs a split process between 'this' and 'other' that gives the result PThis. - * Then for each edges of 'this' this method counts how many edges in Pthis have the same id. - */ -void QuadraticPolygon::intersectForPoint(const QuadraticPolygon& other, std::vector< int >& numberOfCreatedPointsPerEdge) const -{ - numberOfCreatedPointsPerEdge.resize(size()); - IteratorOnComposedEdge it1((QuadraticPolygon *)this); - int edgeId=0; - for(it1.first();!it1.finished();it1.next(),edgeId++) - { - ElementaryEdge* curE1=it1.current(); - QuadraticPolygon cpyOfOther(other); - QuadraticPolygon tmp; - tmp.pushBack(curE1->clone()); - int tmp2; - splitPolygonsEachOther(tmp,cpyOfOther,tmp2); - numberOfCreatedPointsPerEdge[edgeId]=tmp.recursiveSize()-1; - } -} - -/*! - * \b WARNING this method is const and other is const too. \b BUT location of Edges in 'this' and 'other' are nevertheless modified. - * This is possible because loc attribute in Edge class is mutable. - * This implies that if 'this' or/and 'other' are reused for intersect* method initLocations has to be called on each of this/them. - */ -std::vector QuadraticPolygon::intersectMySelfWith(const QuadraticPolygon& other) const -{ - QuadraticPolygon cpyOfThis(*this); - QuadraticPolygon cpyOfOther(other); int nbOfSplits=0; - splitPolygonsEachOther(cpyOfThis,cpyOfOther,nbOfSplits); - //At this point cpyOfThis and cpyOfOther have been splited at maximum edge so that in/out can been done. - performLocatingOperation(cpyOfOther); - return other.buildIntersectionPolygons(cpyOfThis,cpyOfOther); -} - -/*! - * This method is typically the first step of boolean operations between pol1 and pol2. - * This method perform the minimal splitting so that at the end each edges constituting pol1 are fully either IN or OUT or ON. - * @param pol1 IN/OUT param that is equal to 'this' when called. - */ -void QuadraticPolygon::splitPolygonsEachOther(QuadraticPolygon& pol1, QuadraticPolygon& pol2, int& nbOfSplits) -{ - IteratorOnComposedEdge it1(&pol1),it2(&pol2); - MergePoints merge; - ComposedEdge *c1=new ComposedEdge; - ComposedEdge *c2=new ComposedEdge; - for(it2.first();!it2.finished();it2.next()) - { - ElementaryEdge* curE2=it2.current(); - if(!curE2->isThereStartPoint()) - it1.first(); - else - it1=curE2->getIterator(); - for(;!it1.finished();) - { - - ElementaryEdge* curE1=it1.current(); - merge.clear(); nbOfSplits++; - if(curE1->getPtr()->intersectWith(curE2->getPtr(),merge,*c1,*c2)) - { - if(!curE1->getDirection()) c1->reverse(); - if(!curE2->getDirection()) c2->reverse(); - updateNeighbours(merge,it1,it2,c1,c2); - //Substitution of simple edge by sub-edges. - delete curE1; // <-- destroying simple edge coming from pol1 - delete curE2; // <-- destroying simple edge coming from pol2 - it1.insertElemEdges(c1,true);// <-- 2nd param is true to go next. - it2.insertElemEdges(c2,false);// <-- 2nd param is false to avoid to go next. - curE2=it2.current(); - // - it1.assignMySelfToAllElems(c2);//To avoid that others - SoftDelete(c1); - SoftDelete(c2); - c1=new ComposedEdge; - c2=new ComposedEdge; - } - else - { - updateNeighbours(merge,it1,it2,curE1,curE2); - it1.next(); - } - } - } - Delete(c1); - Delete(c2); -} - -void QuadraticPolygon::performLocatingOperation(QuadraticPolygon& pol2) const -{ - IteratorOnComposedEdge it(&pol2); - TypeOfEdgeLocInPolygon loc=FULL_ON_1; - for(it.first();!it.finished();it.next()) - { - ElementaryEdge *cur=it.current(); - loc=cur->locateFullyMySelf(*this,loc); - } -} - -/*! - * Given 2 polygons 'pol1' and 'pol2' (localized) the resulting polygons are returned. - * - * this : pol2 simplified. - * @param pol1 pol1 split. - * @param pol2 pol2 split. - */ -std::vector QuadraticPolygon::buildIntersectionPolygons(const QuadraticPolygon& pol1, const QuadraticPolygon& pol2) const -{ - std::vector ret; - std::list pol2Zip=pol2.zipConsecutiveInSegments(); - if(!pol2Zip.empty()) - closePolygons(pol2Zip,pol1,ret); - else - {//borders of pol2 do not cross pol1,and pol2 borders are outside of pol1. That is to say, either pol2 and pol1 - //do not overlap or pol1 is fully inside pol2. So in the first case no intersection, in the other case - //the intersection is pol1. - ElementaryEdge *e1FromPol1=pol1[0]; - TypeOfEdgeLocInPolygon loc=FULL_ON_1; - loc=e1FromPol1->locateFullyMySelf(*this,loc); - if(loc==FULL_IN_1) - ret.push_back(new QuadraticPolygon(pol1)); - } - return ret; -} - -/*! - * Returns parts of potentially non closed-polygons. Each returned polygons are not mergeable. - * this : pol2 split and locallized. - */ -std::list QuadraticPolygon::zipConsecutiveInSegments() const -{ - std::list ret; - IteratorOnComposedEdge it((ComposedEdge *)this); - int nbOfTurns=recursiveSize(); - int i=0; - if(!it.goToNextInOn(false,i,nbOfTurns)) - return ret; - i=0; - // - while(igetLoc(); - while(loc!=FULL_OUT_1 && iclone(); - tmp1->pushBack(tmp3); - it.nextLoop(); i++; - loc=it.current()->getLoc(); - } - if(tmp1->empty()) - { - delete tmp1; - continue; - } - ret.push_back(tmp1); - it.goToNextInOn(true,i,nbOfTurns); - } - return ret; -} - -/*! - * 'this' should be considered as pol2Simplified. - * @param pol2zip is a list of set of edges (openned polygon) coming from split polygon 2. - * @param pol1 is split pol1. - * @param results the resulting \b CLOSED polygons. - */ -void QuadraticPolygon::closePolygons(std::list& pol2Zip, const QuadraticPolygon& pol1, - std::vector& results) const -{ - bool directionKnownInPol1=false; - bool directionInPol1; - for(std::list::iterator iter=pol2Zip.begin();iter!=pol2Zip.end();) - { - if((*iter)->completed()) - { - results.push_back(*iter); - directionKnownInPol1=false; - iter=pol2Zip.erase(iter); - continue; - } - if(!directionKnownInPol1) - { - if(!(*iter)->amIAChanceToBeCompletedBy(pol1,*this,directionInPol1)) - { delete *iter; iter=pol2Zip.erase(iter); continue; } - else - directionKnownInPol1=true; - } - std::list::iterator iter2=iter; iter2++; - std::list::iterator iter3=(*iter)->fillAsMuchAsPossibleWith(pol1,iter2,pol2Zip.end(),directionInPol1); - if(iter3!=pol2Zip.end()) - { - (*iter)->pushBack(*iter3); - SoftDelete(*iter3); - pol2Zip.erase(iter3); - } - } -} - -/*! - * 'this' is expected to be set of edges (not closed) of pol2 split. - */ -bool QuadraticPolygon::amIAChanceToBeCompletedBy(const QuadraticPolygon& pol1Splitted,const QuadraticPolygon& pol2NotSplitted, bool& direction) -{ - IteratorOnComposedEdge it((QuadraticPolygon *)&pol1Splitted); - bool found=false; - Node *n=getEndNode(); - ElementaryEdge *cur=it.current(); - for(it.first();!it.finished() && !found;) - { - cur=it.current(); - found=(cur->getStartNode()==n); - if(!found) - it.next(); - } - if(!found) - throw Exception("Internal error : polygons uncompatible each others. Should never happend"); - //Ok we found correspondance between this and pol1. Searching for right direction to close polygon. - ElementaryEdge *e=_sub_edges.back(); - if(e->getLoc()==FULL_ON_1) - { - if(e->getPtr()==cur->getPtr()) - { - direction=false; - it.previousLoop(); - cur=it.current(); - Node *repr=cur->getPtr()->buildRepresentantOfMySelf(); - bool ret=pol2NotSplitted.isInOrOut(repr); - repr->decrRef(); - return ret; - } - else - { - direction=true; - Node *repr=cur->getPtr()->buildRepresentantOfMySelf(); - bool ret=pol2NotSplitted.isInOrOut(repr); - repr->decrRef(); - return ret; - } - } - else - direction=cur->locateFullyMySelfAbsolute(pol2NotSplitted)==FULL_IN_1; - return true; -} - -/*! - * This method fills as much as possible 'this' (part of pol2 split) with edges of 'pol1Splitted'. - */ -std::list::iterator QuadraticPolygon::fillAsMuchAsPossibleWith(const QuadraticPolygon& pol1Splitted, - std::list::iterator iStart, - std::list::iterator iEnd, - bool direction) -{ - IteratorOnComposedEdge it((QuadraticPolygon *)&pol1Splitted); - bool found=false; - Node *n=getEndNode(); - ElementaryEdge *cur; - for(it.first();!it.finished() && !found;) - { - cur=it.current(); - found=(cur->getStartNode()==n); - if(!found) - it.next(); - } - if(!direction) - it.previousLoop(); - Node *nodeToTest; - std::list::iterator ret; - do - { - cur=it.current(); - ElementaryEdge *tmp=cur->clone(); - if(!direction) - tmp->reverse(); - pushBack(tmp); - nodeToTest=tmp->getEndNode(); - direction?it.nextLoop():it.previousLoop(); - ret=checkInList(nodeToTest,iStart,iEnd); - if(completed()) - return iEnd; - } - while(ret==iEnd); - return ret; -} - -std::list::iterator QuadraticPolygon::checkInList(Node *n, std::list::iterator iStart, - std::list::iterator iEnd) -{ - for(std::list::iterator iter=iStart;iter!=iEnd;iter++) - if((*iter)->isNodeIn(n)) - return iter; - return iEnd; -} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx deleted file mode 100644 index 52f985b91..000000000 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELGEO2DQUADRATICPOLYGON_HXX__ -#define __INTERPKERNELGEO2DQUADRATICPOLYGON_HXX__ - -#include "INTERPKERNELGEOMETRIC2DDefines.hxx" - -#include "InterpKernelGeo2DComposedEdge.hxx" -#include "InterpKernelGeo2DAbstractEdge.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" - -#include -#include - -namespace INTERP_KERNEL -{ - class Edge; - class MergePoints; - - class INTERPKERNELGEOMETRIC2D_EXPORT QuadraticPolygon : public ComposedEdge - { - public: - QuadraticPolygon() { } - QuadraticPolygon(const QuadraticPolygon& other):ComposedEdge(other) { } - QuadraticPolygon(const char *fileName); - static QuadraticPolygon *buildLinearPolygon(std::vector& nodes); - static QuadraticPolygon *buildArcCirclePolygon(std::vector& nodes); - static void buildDbgFile(const std::vector& nodes, const char *fileName); - ~QuadraticPolygon(); - void closeMe() const; - void circularPermute(); - bool isButterfly() const; - void dumpInXfigFile(const char *fileName) const; - void dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const; - //! Before intersecting as intersectWith a normalization is done. - double intersectWithAbs(QuadraticPolygon& other); - //! Before intersecting as intersectWith a normalization is done. - double intersectWithAbs(QuadraticPolygon& other, double* barycenter); - double intersectWith(const QuadraticPolygon& other) const; - double intersectWith(const QuadraticPolygon& other, double* barycenter) const; - std::vector intersectMySelfWith(const QuadraticPolygon& other) const; - void intersectForPerimeter(const QuadraticPolygon& other, double& perimeterThisPart, double& perimeterOtherPart, double& perimeterCommonPart) const; - void intersectForPerimeterAdvanced(const QuadraticPolygon& other, std::vector< double >& polThis, std::vector< double >& polOther) const; - void intersectForPoint(const QuadraticPolygon& other, std::vector< int >& numberOfCreatedPointsPerEdge) const; - public://Only public for tests reasons - void performLocatingOperation(QuadraticPolygon& pol2) const; - static void splitPolygonsEachOther(QuadraticPolygon& pol1, QuadraticPolygon& pol2, int& nbOfSplits); - std::vector buildIntersectionPolygons(const QuadraticPolygon& pol1, const QuadraticPolygon& pol2) const; - bool amIAChanceToBeCompletedBy(const QuadraticPolygon& pol1Splitted, const QuadraticPolygon& pol2NotSplitted, bool& direction); - protected: - std::list zipConsecutiveInSegments() const; - void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const; - void closePolygons(std::list& pol2Zip, const QuadraticPolygon& pol1, std::vector& results) const; - template - static void updateNeighbours(const MergePoints& merger, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2, - const EDGES *e1, const EDGES *e2); - std::list::iterator fillAsMuchAsPossibleWith(const QuadraticPolygon& pol1Splitted, - std::list::iterator iStart, - std::list::iterator iEnd, - bool direction); - static std::list::iterator checkInList(Node *n, std::list::iterator iStart, - std::list::iterator iEnd); - }; -} - -namespace INTERP_KERNEL -{ - template - void QuadraticPolygon::updateNeighbours(const MergePoints& merger, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2, - const EDGES *e1, const EDGES *e2) - { - it1.previousLoop(); it2.previousLoop(); - ElementaryEdge *curE1=it1.current(); ElementaryEdge *curE2=it2.current(); - curE1->changeEndNodeWith(e1->getStartNode()); curE2->changeEndNodeWith(e2->getStartNode()); - it1.nextLoop(); it1.nextLoop(); it2.nextLoop(); it2.nextLoop(); - curE1->changeStartNodeWith(e1->getEndNode()); curE2->changeStartNodeWith(e2->getEndNode()); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2D/Makefile.am b/src/INTERP_KERNEL/Geometric2D/Makefile.am deleted file mode 100644 index c0b3fb645..000000000 --- a/src/INTERP_KERNEL/Geometric2D/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (C) 2007-2010 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 : Makefile.am -# Author : Anthony GEAY (CEA/DEN/DANS/DM2S/SFME/LGLS) -# Module : MED -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -noinst_LTLIBRARIES = libInterpGeometric2DAlg.la - -dist_libInterpGeometric2DAlg_la_SOURCES = \ -InterpKernelGeo2DAbstractEdge.cxx \ -InterpKernelGeo2DBounds.cxx \ -InterpKernelGeo2DPrecision.cxx \ -InterpKernelGeo2DComposedEdge.cxx \ -InterpKernelGeo2DEdgeArcCircle.cxx \ -InterpKernelGeo2DEdge.cxx \ -InterpKernelGeo2DEdgeInfLin.cxx \ -InterpKernelGeo2DEdgeLin.cxx \ -InterpKernelGeo2DElementaryEdge.cxx \ -InterpKernelGeo2DNode.cxx \ -InterpKernelGeo2DQuadraticPolygon.cxx - -salomeinclude_HEADERS = \ -INTERPKERNELGEOMETRIC2DDefines.hxx \ -InterpKernelGeo2DAbstractEdge.hxx \ -InterpKernelGeo2DBounds.hxx \ -InterpKernelGeo2DPrecision.hxx \ -InterpKernelGeo2DComposedEdge.hxx \ -InterpKernelGeo2DEdgeArcCircle.hxx \ -InterpKernelGeo2DEdge.hxx \ -InterpKernelGeo2DEdgeInfLin.hxx \ -InterpKernelGeo2DEdgeLin.hxx \ -InterpKernelGeo2DElementaryEdge.hxx \ -InterpKernelGeo2DNode.hxx \ -InterpKernelGeo2DQuadraticPolygon.hxx \ -InterpKernelGeo2DEdge.txx - -libInterpGeometric2DAlg_la_CPPFLAGS = -I$(srcdir)/../Bases diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.hxx b/src/INTERP_KERNEL/Geometric2DIntersector.hxx deleted file mode 100644 index 188266570..000000000 --- a/src/INTERP_KERNEL/Geometric2DIntersector.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2007-2010 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 __GEOMETRIC2DINTERSECTOR_HXX__ -#define __GEOMETRIC2DINTERSECTOR_HXX__ - -#include "PlanarIntersectorP0P0.hxx" -#include "PlanarIntersectorP0P1.hxx" -#include "PlanarIntersectorP1P0.hxx" -#include "PlanarIntersectorP1P1.hxx" -#include "PlanarIntersectorP1P0Bary.hxx" - -namespace INTERP_KERNEL -{ - class QuadraticPolygon; - - template class InterpType> - class Geometric2DIntersector : public InterpType > - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation); - double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS); - double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad); - double intersectGeometryGeneral(const std::vector& targetCoords, const std::vector& sourceCoords); - double intersectGeoBary(const std::vector& targetCell, bool targetCellQuadratic, const double *sourceCell, std::vector& res); - private: - QuadraticPolygon *buildPolygonFrom(const std::vector& coords, NormalizedCellType type); - QuadraticPolygon *buildPolygonAFrom(ConnType cell, int nbOfPoints, NormalizedCellType type); - QuadraticPolygon *buildPolygonBFrom(ConnType cell, int nbOfPoints, NormalizedCellType type); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.txx b/src/INTERP_KERNEL/Geometric2DIntersector.txx deleted file mode 100644 index ef03918c2..000000000 --- a/src/INTERP_KERNEL/Geometric2DIntersector.txx +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (C) 2007-2010 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 __GEOMETRIC2DINTERSECTOR_TXX__ -#define __GEOMETRIC2DINTERSECTOR_TXX__ - -#include "Geometric2DIntersector.hxx" -#include "PlanarIntersectorP0P0.txx" -#include "PlanarIntersectorP0P1.txx" -#include "PlanarIntersectorP1P0.txx" -#include "PlanarIntersectorP1P1.txx" -#include "PlanarIntersectorP1P0Bary.txx" -#include "CellModel.hxx" - -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" -#include "InterpKernelGeo2DNode.hxx" - -#define GEO2D_INTERSECTOR Geometric2DIntersector -#define INTERSECTOR_TEMPLATE template class InterpType> - -namespace INTERP_KERNEL -{ - INTERSECTOR_TEMPLATE - GEO2D_INTERSECTOR::Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double md3DSurf, double medianPlane, - double precision, int orientation): - InterpType(meshT,meshS,dimCaracteristic, precision, md3DSurf, medianPlane, true, orientation, 0) - { - QUADRATIC_PLANAR::_precision=precision; - } - - INTERSECTOR_TEMPLATE - double GEO2D_INTERSECTOR::intersectGeometry(ConnType icellT, ConnType icellS, - ConnType nbNodesT, ConnType nbNodesS) - { - int orientation = 1; - std::vector CoordsT; - std::vector CoordsS; - PlanarIntersector::getRealCoordinates(icellT,icellS,nbNodesT,nbNodesS,CoordsT,CoordsS,orientation); - NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(icellT); - NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(icellS); - QuadraticPolygon *p1=buildPolygonFrom(CoordsT,tT); - QuadraticPolygon *p2=buildPolygonFrom(CoordsS,tS); - double ret=p1->intersectWithAbs(*p2); - delete p1; delete p2; - return ret; - } - - INTERSECTOR_TEMPLATE - double GEO2D_INTERSECTOR::intersectGeometryWithQuadrangle(const double * quadrangle, - const std::vector& sourceCoords, - bool isSourceQuad) - { - std::vector nodes(4); - nodes[0]=new Node(quadrangle[0],quadrangle[1]); - nodes[1]=new Node(quadrangle[SPACEDIM],quadrangle[SPACEDIM+1]); - nodes[2]=new Node(quadrangle[2*SPACEDIM],quadrangle[2*SPACEDIM+1]); - nodes[3]=new Node(quadrangle[3*SPACEDIM],quadrangle[3*SPACEDIM+1]); - int nbOfSourceNodes=sourceCoords.size()/SPACEDIM; - std::vector nodes2(nbOfSourceNodes); - for(int i=0;iintersectWithAbs(*p2); - delete p1; delete p2; - return ret; - } - - INTERSECTOR_TEMPLATE - double GEO2D_INTERSECTOR::intersectGeometryGeneral(const std::vector& targetCoords, - const std::vector& sourceCoords) - { - int nbOfTargetNodes=targetCoords.size()/SPACEDIM; - std::vector nodes(nbOfTargetNodes); - for(int i=0;i nodes2(nbOfSourceNodes); - for(int i=0;iintersectWithAbs(*p2); - delete p1; delete p2; - return ret; - } - - //================================================================================ - /*! - * \brief Intersect a triangle and a polygon for P1P0 barycentric algorithm - * \param targetCell - list of coordinates of target polygon in full interlace - * \param targetCellQuadratic - specifies if target polygon is quadratic or not - * \param sourceTria - list of coordinates of source triangle - * \param res - coefficients a,b and c associated to nodes of sourceTria - */ - //================================================================================ - - INTERSECTOR_TEMPLATE - double GEO2D_INTERSECTOR::intersectGeoBary(const std::vector& targetCell, - bool targetCellQuadratic, - const double * sourceTria, - std::vector& res) - { - std::vector nodes(3); - nodes[0]=new Node(sourceTria[0*SPACEDIM],sourceTria[0*SPACEDIM+1]); - nodes[1]=new Node(sourceTria[1*SPACEDIM],sourceTria[1*SPACEDIM+1]); - nodes[2]=new Node(sourceTria[2*SPACEDIM],sourceTria[2*SPACEDIM+1]); - int nbOfTargetNodes=targetCell.size()/SPACEDIM; - std::vector nodes2(nbOfTargetNodes); - for(int i=0;iintersectWithAbs(*p2,barycenter); - delete p1; delete p2; - if ( ret > std::numeric_limits::min() ) - { - std::vector sourceCell(3); - sourceCell[0] = &sourceTria[0]; - sourceCell[1] = &sourceTria[SPACEDIM]; - sourceCell[2] = &sourceTria[SPACEDIM*2]; - res.resize(3); - barycentric_coords( sourceCell, barycenter, &res[0]); - res[0] *= ret; - res[1] *= ret; - res[2] *= ret; - } - else - { - ret = 0; - } - return ret; - } - - INTERSECTOR_TEMPLATE - QuadraticPolygon *GEO2D_INTERSECTOR::buildPolygonFrom(const std::vector& coords, NormalizedCellType type) - { - int nbNodes=coords.size()/SPACEDIM; - std::vector nodes(nbNodes); - for(int i=0;i::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[OTT::ind2C(cell)]); - std::vector nodes(nbOfPoints); - for(int i=0;i::_coordsT+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(CellModel::getCellModel(type).isQuadratic()) - return QuadraticPolygon::buildLinearPolygon(nodes); - else - return QuadraticPolygon::buildArcCirclePolygon(nodes); - } - - INTERSECTOR_TEMPLATE - QuadraticPolygon *GEO2D_INTERSECTOR::buildPolygonBFrom(ConnType cell, int nbOfPoints, NormalizedCellType type) - { - const ConnType *startOfCellNodeConn=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[OTT::ind2C(cell)]); - std::vector nodes(nbOfPoints); - for(int i=0;i::_coordsS+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(type!=NORM_TRI6 && type!=NORM_QUAD8) - return QuadraticPolygon::buildLinearPolygon(nodes); - else - return QuadraticPolygon::buildArcCirclePolygon(nodes); - } -} - -#endif diff --git a/src/INTERP_KERNEL/INTERPKERNELDefines.hxx b/src/INTERP_KERNEL/INTERPKERNELDefines.hxx deleted file mode 100644 index 825b15783..000000000 --- a/src/INTERP_KERNEL/INTERPKERNELDefines.hxx +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELDEFINES_HXX__ -#define __INTERPKERNELDEFINES_HXX__ - -//export symbols -#ifdef WIN32 -# if defined INTERPKERNEL_EXPORTS || defined interpkernel_EXPORTS -# define INTERPKERNEL_EXPORT __declspec(dllexport) -# else -# define INTERPKERNEL_EXPORT __declspec(dllimport) -# endif -#else -# define INTERPKERNEL_EXPORT -#endif - -#endif diff --git a/src/INTERP_KERNEL/IntegralUniformIntersector.hxx b/src/INTERP_KERNEL/IntegralUniformIntersector.hxx deleted file mode 100644 index e7fe7e9f2..000000000 --- a/src/INTERP_KERNEL/IntegralUniformIntersector.hxx +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTEGRALUNIFORMINTERSECTOR_HXX__ -#define __INTEGRALUNIFORMINTERSECTOR_HXX__ - -#include "TargetIntersector.hxx" - -#include - -namespace INTERP_KERNEL -{ - template - class IntegralUniformIntersector : public TargetIntersector - { - public: - typedef typename MyMeshType::MyConnType ConnType; - public: - IntegralUniformIntersector(const MyMeshType& mesh, bool isAbs); - double performNormalization(double val) const { if(_is_abs) return fabs(val); else return val; } - void setFromTo(bool val) { _from_to=val; } - void putValueIn(ConnType i, double val, MyMatrix& res) const; - protected: - const MyMeshType& _mesh; - //! if false means fromIntegralUniform if true means toIntegralUniform - bool _from_to; - bool _is_abs; - }; - - template - class IntegralUniformIntersectorP0 : public IntegralUniformIntersector - { - public: - typedef typename MyMeshType::MyConnType ConnType; - public: - IntegralUniformIntersectorP0(const MyMeshType& mesh, bool isAbs); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - }; - - template - class IntegralUniformIntersectorP1 : public IntegralUniformIntersector - { - public: - typedef typename MyMeshType::MyConnType ConnType; - public: - IntegralUniformIntersectorP1(const MyMeshType& mesh, bool isAbs); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/IntegralUniformIntersector.txx b/src/INTERP_KERNEL/IntegralUniformIntersector.txx deleted file mode 100644 index 334d9e0b0..000000000 --- a/src/INTERP_KERNEL/IntegralUniformIntersector.txx +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTEGRALUNIFORMINTERSECTOR_TXX__ -#define __INTEGRALUNIFORMINTERSECTOR_TXX__ - -#include "IntegralUniformIntersector.hxx" -#include "VolSurfUser.txx" - -namespace INTERP_KERNEL -{ - template - IntegralUniformIntersector::IntegralUniformIntersector(const MyMeshType& mesh, bool isAbs):_mesh(mesh),_from_to(false),_is_abs(isAbs) - { - } - - template - void IntegralUniformIntersector::putValueIn(ConnType iInCMode, double val1, MyMatrix& res) const - { - static const NumberingPolicy numPol=MyMeshType::My_numPol; - double val=performNormalization(val1); - if(_from_to) - { - typename MyMatrix::value_type& resRow=res[0]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(iInCMode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(iInCMode),val)); - else - { - double val2=(*iterRes).second+val; - resRow.erase(OTT::indFC(iInCMode)); - resRow.insert(std::make_pair(OTT::indFC(iInCMode),val2)); - } - } - else - { - typename MyMatrix::value_type& resRow=res[iInCMode]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(0)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(0),val)); - else - { - double val2=(*iterRes).second+val; - resRow.erase(OTT::indFC(0)); - resRow.insert(std::make_pair(OTT::indFC(0),val2)); - } - } - } - - template - IntegralUniformIntersectorP0::IntegralUniformIntersectorP0(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector(mesh,isAbs) - { - } - - template - int IntegralUniformIntersectorP0::getNumberOfRowsOfResMatrix() const - { - if(IntegralUniformIntersector::_from_to) - return 1; - else - return IntegralUniformIntersector::_mesh.getNumberOfElements(); - } - - template - int IntegralUniformIntersectorP0::getNumberOfColsOfResMatrix() const - { - if(IntegralUniformIntersector::_from_to) - return IntegralUniformIntersector::_mesh.getNumberOfElements(); - else - return 1; - } - - template - void IntegralUniformIntersectorP0::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - static const NumberingPolicy numPol=MyMeshType::My_numPol; - res.resize(getNumberOfRowsOfResMatrix()); - unsigned long nbelem=IntegralUniformIntersector::_mesh.getNumberOfElements(); - const ConnType *connIndx=IntegralUniformIntersector::_mesh.getConnectivityIndexPtr(); - const ConnType *conn=IntegralUniformIntersector::_mesh.getConnectivityPtr(); - const double *coords=IntegralUniformIntersector::_mesh.getCoordinatesPtr(); - for(unsigned long i=0;i::_mesh.getTypeOfElement(OTT::indFC(i)); - double val=computeVolSurfOfCell(t,conn+OTT::ind2C(connIndx[i]),connIndx[i+1]-connIndx[i],coords); - IntegralUniformIntersector::putValueIn(i,val,res); - } - } - - template - IntegralUniformIntersectorP1::IntegralUniformIntersectorP1(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector(mesh,isAbs) - { - } - - template - int IntegralUniformIntersectorP1::getNumberOfRowsOfResMatrix() const - { - if(IntegralUniformIntersector::_from_to) - return 1; - else - return IntegralUniformIntersector::_mesh.getNumberOfNodes(); - } - - template - int IntegralUniformIntersectorP1::getNumberOfColsOfResMatrix() const - { - if(IntegralUniformIntersector::_from_to) - return IntegralUniformIntersector::_mesh.getNumberOfNodes(); - else - return 1; - } - - template - void IntegralUniformIntersectorP1::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - static const NumberingPolicy numPol=MyMeshType::My_numPol; - res.resize(getNumberOfRowsOfResMatrix()); - unsigned long nbelem=IntegralUniformIntersector::_mesh.getNumberOfElements(); - const ConnType *connIndx=IntegralUniformIntersector::_mesh.getConnectivityIndexPtr(); - const ConnType *conn=IntegralUniformIntersector::_mesh.getConnectivityPtr(); - const double *coords=IntegralUniformIntersector::_mesh.getCoordinatesPtr(); - for(unsigned long i=0;i::_mesh.getTypeOfElement(OTT::indFC(i)); - int lgth=connIndx[i+1]-connIndx[i]; - const ConnType *locConn=conn+OTT::ind2C(connIndx[i]); - double val=computeVolSurfOfCell(t,locConn,lgth,coords); - if(t==NORM_TRI3) - val/=3.; - else if(t==NORM_TETRA4) - val/=4.; - else - throw INTERP_KERNEL::Exception("Invalid cell type detected : must be TRI3 or TETRA4 ! "); - for(int j=0;j::putValueIn(OTT::coo2C(locConn[j]),val,res); - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/InterpKernelMatrix.hxx b/src/INTERP_KERNEL/InterpKernelMatrix.hxx deleted file mode 100755 index b8110641b..000000000 --- a/src/INTERP_KERNEL/InterpKernelMatrix.hxx +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELMATRIX_HXX_ -#define __INTERPKERNELMATRIX_HXX__ - -#include "InterpolationUtils.hxx" - -#include -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - template - class Matrix; - - template - std::ostream& operator<<(std::ostream& in, const Matrix& m); - template - std::istream& operator>>(std::istream& in, Matrix& m); - - template - class Matrix - { - - class KeyComparator - { - public: - KeyComparator(int val):_val(val) { } - bool operator()(const typename std::pair& val) { return val.first==_val; } - protected: - int _val; - }; - - class Row : public std::vector< typename std::pair > - { - public: - Row():std::vector< typename std::pair >(){}; - Row (const Row& row) - { - this->resize(row.size()); - for (int i=0; isize(); i++) - (*this)[i]=row[i]; - } - Row& operator= (const Row& row) - { - this->resize(row.size()); - for (int i=0; isize(); i++) - (*this)[i]=row[i]; - return *this; - } - typename std::vector< std::pair >::const_iterator find(int elem) const - { - return std::find_if(std::vector< typename std::pair >::begin(),std::vector< typename std::pair >::end(),KeyComparator(elem)); - } - - void erase(int elem) { std::vector< typename std::pair >::erase(std::find_if(std::vector< typename std::pair >::begin(),std::vector< typename std::pair >::end(),KeyComparator(elem))); } - - void insert(const std::pair& myPair) { push_back(myPair); } - }; - - private: - unsigned int _nb_rows; - T* _coeffs; - unsigned int* _cols; - std::vector _ncols_offset; - std::vector< Row > _auxiliary_matrix; - friend std::ostream& operator<<<>(std::ostream& in, const Matrix& m); - friend std::istream& operator>><>(std::istream& in, Matrix& m); - bool _is_configured; - public: - typedef Row value_type; - public: - Matrix():_coeffs(0), _cols(0), _nb_rows(0), _is_configured(false) - { } - Matrix(int nbrows):_coeffs(0), _cols(0), _is_configured(false) - { _nb_rows=nbrows; } - Matrix(std::vector > & matrix) : - _coeffs(0), _cols(0), _is_configured(false) - { - _nb_rows=matrix.size(); - _auxiliary_matrix.resize(_nb_rows); - for (int i=0; i<_nb_rows; i++) - { - typename std::map::iterator it; - for (it=matrix[i].begin(); it != matrix[i].end(); it++) - _auxiliary_matrix[i].push_back(*it);//MN: pq push_back plutot que simple affectation? - } - } - /*!Copy constructor - */ - Matrix(const Matrix & m) - { - _is_configured=m._is_configured; - _nb_rows=m._nb_rows; - _auxiliary_matrix=m._auxiliary_matrix; - _ncols_offset=m._ncols_offset; - if (_is_configured) - { - int size=_ncols_offset[_nb_rows]; - _coeffs = new double[size]; - _cols = new unsigned int[size]; - memcpy(_coeffs, m._coeffs, size*sizeof(double)); - memcpy(_cols, m._cols, size*sizeof(int)); - } - } - - ~Matrix() - { - delete[] _coeffs; - delete[] _cols; - } - - Matrix& operator=(const Matrix& m) - { - _is_configured=m._is_configured; - _nb_rows=m._nb_rows; - _auxiliary_matrix=m._auxiliary_matrix; - _ncols_offset=m._ncols_offset; - if (_is_configured) - { - int size=_ncols_offset[_nb_rows]; - _coeffs = new double[size]; - _cols = new unsigned int[size]; - memcpy(_coeffs, m._coeffs, size*sizeof(double)); - memcpy(_cols, m._cols, size*sizeof(int)); - } - return this; - } - - /*! declares a method that specifies the number of rows */ - void resize(unsigned int nbrows) - { - _nb_rows=nbrows; - _auxiliary_matrix.resize(nbrows); - } - - /*! sets (i,j) coefficient to \a value */ - void setIJ(int irow, int icol, T value) - { - if (_is_configured) - throw Exception("filling a configured matrix"); - if (_auxiliary_matrix.empty()) - _auxiliary_matrix.resize(_nb_rows); - - for (unsigned int i=0; i< _auxiliary_matrix[OTT::ind2C(irow)].size(); i++) - if (_auxiliary_matrix[OTT::ind2C(irow)][i].first == icol) - { - _auxiliary_matrix[OTT::ind2C(irow)][i].second = value; - return; - } - _auxiliary_matrix[OTT::ind2C(irow)].push_back(std::make_pair(icol, value)); - } - - /*! - Matrix multiplies vector \a input and stores the result in - vector \a output. - The vector pointed by \a input must be dimensioned - to the number of columns while the vector pointed by output must be - dimensioned to the number of rows. - */ - void multiply(const T* const input, T* const output) - { - if (!_is_configured) - configure(); - - for (int i=0; i< _nb_rows; i++) - { - output[i]=0.; - for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) - { - int icol = _cols[j]; - output[i]+=input[icol]*_coeffs[j]; - } - } - } - - /*! - Matrix multiplies vector \a input and stores the result in - vector \a output. - input and output are supposed to represent the same field - discretised on two different on meshes. - nb_comp is the number of components of the fields input and output - The vector pointed by \a input must be dimensioned - to the number of columns times nb_comp while the vector pointed by output must be - dimensioned to the number of rows times nb_comp. - */ - void multiply(const T* const input, T* const output, int nb_comp) - { - if (!_is_configured) - configure(); - - for (int i=0; i< _nb_rows; i++) - { - for(int comp = 0; comp < nb_comp; comp++) - output[i*nb_comp+comp]=0.; - for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) - { - int icol = _cols[j]; - for(int comp = 0; comp < nb_comp; comp++) - output[i*nb_comp+comp]+=input[icol*nb_comp+comp]*_coeffs[j]; - } - } - } - /*! - Transpose-multiplies vector \a input and stores the result in - vector \a output. - nb_cols is the number of columns of the matrix, (it is not an attribute of the class) - The vector pointed by \a input must be dimensioned - to the number of lines _nb_rows while the vector pointed by output must be - dimensioned to the number of columns nb_cols. - */ - void transposeMultiply(const T* const input, T* const output, int nb_cols) - { - if (!_is_configured) - configure(); - - for (int icol=0; icol< nb_cols; icol++) - output[icol]=0.; - for (int i=0; i< _nb_rows; i++) - { - for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) - { - int icol = _cols[j]; - output[icol]+=input[i]*_coeffs[j]; - } - } - } - /*! - Transpose-multiplies vector \a input and stores the result in - vector \a output. - input and output are supposed to represent the same field - discretised on two different on meshes. - nb_comp is the number of components of the fields input and output - nb_cols is the number of columns of the matrix, (it is not an attribute of the class) - The vector pointed by \a input must be dimensioned - to _nb_rows*nb_comp while the vector pointed by output must be - dimensioned to nb_cols*nb_comp. - */ - void transposeMultiply(const T* const input, T* const output, int nb_cols, int nb_comp) - { - if (!_is_configured) - configure(); - - for (int icol=0; icol< nb_cols; icol++) - for(int comp = 0; comp < nb_comp; comp++) - output[icol*nb_comp+comp]=0.; - - for (int i=0; i< _nb_rows; i++) - { - for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) - { - int icol = _cols[j]; - for(int comp = 0; comp < nb_comp; comp++) - output[icol*nb_comp+comp]+=input[i*nb_comp+comp]*_coeffs[j]; - } - } - } - /* - Sums the coefficients of each column of the matrix - nb_cols is the number of columns of the matrix, (it is not an attribute of the class) - The vector output must be dimensioned to nb_cols - */ - void colSum(std::vector< T >& output, int nb_cols) - { - if (!_is_configured) - configure(); - for (int icol=0; icol< nb_cols; icol++) - output[icol]=0.; - for (int i=0; i< _nb_rows; i++) - { - for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) - { - int icol = _cols[j]; - output[icol]+=_coeffs[j]; - } - } - } - - /* - Sums the coefficients of each row of the matrix - The vector output must be dimensioned to _nb_rows - */ - void rowSum(std::vector< T >& output) - { - if (!_is_configured) - configure(); - for (int i=0; i< _nb_rows; i++) - { - output[i]=0; - for (unsigned int j=_ncols_offset[i]; j< _ncols_offset[i+1]; j++) - output[i]+=_coeffs[j]; - } - } - - /*! This operation freezes the profile of the matrix - and puts it under a CSR form so that it becomes - efficient both in terms of memory occupation and - in terms of multiplication */ - - void configure() - { - _ncols_offset.resize(_nb_rows+1); - _ncols_offset[0]=0; - for (unsigned int i=0; i<_nb_rows; i++) - _ncols_offset[i+1]=_ncols_offset[i]+_auxiliary_matrix[i].size(); - int nbcoeffs= _ncols_offset[_nb_rows]; - _cols=new unsigned int[nbcoeffs]; - _coeffs=new T[nbcoeffs]; - unsigned int* cols_ptr=_cols; - T* coeffs_ptr=_coeffs; - for (unsigned int i=0; i<_nb_rows; i++) - { - for (unsigned int j=0; j<_auxiliary_matrix[i].size(); j++) - { - *cols_ptr++ = OTT::ind2C(_auxiliary_matrix[i][j].first); - *coeffs_ptr++ = _auxiliary_matrix[i][j].second; - } - } - _auxiliary_matrix.clear(); - _is_configured=true; - } - - /*! - * 0 <= irow < n - */ - Row &operator [] (unsigned int irow) - { - return _auxiliary_matrix[irow]; - } - - int getNbRows() - { - return _nb_rows; - } - - }; - - /*! output to an ascii file - only nonzero elements are written - - the first line contains the indexing (0 or 1) - - the second line contains the number of rows. - - for each row, a line contains: - - the number of nonzero coeffs - - and for each coeff : icol, value - - for instance, matrix - | 1.0 0.0 0.5 | - | 0.0 1.0 0.0 | - | 0.2 0.0 1.0 | - will be displayed in 0-indexing as - 0 - 3 - 2 0 1.0 2 0.5 - 1 1 1.0 - 2 0 0.2 2 1.0 - */ - - template - std::ostream& operator<<(std::ostream& out, const Matrix& m) - { - if (m._is_configured) - { - out << OTT::indFC(0) <::indFC(m._cols[j]) <<"\t"<::indFC(0) <<"\n"; - out << m._nb_rows <<"\n"; - for (unsigned int i=0; i - std::istream& operator>>(std::istream& in, Matrix& m) - { - int index_base_test; - in >> index_base_test; - if (index_base_test!=OTT::indFC(0)) - { - std::cerr << "file index is "<> m._nb_rows; - m._auxiliary_matrix.resize(m._nb_rows); - for (unsigned int i=0; i> ncols; - m._auxiliary_matrix[i].resize(ncols); - double value; - unsigned int col; - for (unsigned int j=0; j>col; - in>>value; - m._auxiliary_matrix[i].push_back(std::make_pair(col, value)); - } - } - return in; - } -} - -#endif diff --git a/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx b/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx deleted file mode 100644 index bf465ae3a..000000000 --- a/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpKernelMeshQuality.hxx" - -#include -#include -#include -#include - -double INTERP_KERNEL::quadSkew(const double *coo) -{ - double pa0[3]={ - coo[3]+coo[6]-coo[0]-coo[9], - coo[4]+coo[7]-coo[1]-coo[10], - coo[5]+coo[8]-coo[2]-coo[11] - }; - double pa1[3]={ - coo[6]+coo[9]-coo[0]-coo[3], - coo[7]+coo[10]-coo[1]-coo[4], - coo[8]+coo[11]-coo[2]-coo[5], - }; - double l0=sqrt(pa0[0]*pa0[0]+pa0[1]*pa0[1]+pa0[2]*pa0[2]); - double l1=sqrt(pa1[0]*pa1[0]+pa1[1]*pa1[1]+pa1[2]*pa1[2]); - if(l0<1.e-15) - return 0.; - if(l1<1.e-15) - return 0.; - pa0[0]/=l0; pa0[1]/=l0; pa0[2]/=l0; - pa1[0]/=l1; pa1[1]/=l1; pa1[2]/=l1; - return pa0[0]*pa1[0]+pa0[1]*pa1[1]+pa0[2]*pa1[2]; -} - -double INTERP_KERNEL::quadEdgeRatio(const double *coo) -{ - double a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); - double b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); - double c2=(coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8]); - double d2=(coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11]); - double mab=a2Mcd?Mab:Mcd; - if(m2>1.e-15) - return sqrt(M2/m2); - else - return std::numeric_limits::max(); -} - -double INTERP_KERNEL::quadAspectRatio(const double *coo) -{ - double a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); - double b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); - double c=sqrt((coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8])); - double d=sqrt((coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11])); - double ma=a>b?a:b; - double mb=c>d?c:d; - double hm=ma>mb?ma:mb; - double ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), - (coo[5]-coo[2])*(coo[6]-coo[3])-(coo[3]-coo[0])*(coo[8]-coo[5]), - (coo[3]-coo[0])*(coo[7]-coo[4])-(coo[4]-coo[1])*(coo[6]-coo[3])}; - double cd[3]={(coo[10]-coo[7])*(coo[2]-coo[11])-(coo[1]-coo[10])*(coo[11]-coo[8]), - (coo[11]-coo[8])*(coo[0]-coo[9])-(coo[9]-coo[6])*(coo[2]-coo[11]), - (coo[9]-coo[6])*(coo[1]-coo[10])-(coo[10]-coo[7])*(coo[0]-coo[9])}; - double e=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2])+sqrt(cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]); - if(d>1e-15) - return 0.5*(a+b+c+d)*hm/e; - else - return std::numeric_limits::max(); -} - -double INTERP_KERNEL::quadWarp(const double *coo) -{ - double e0[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; - double e1[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; - double e2[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; - double e3[3]={coo[0]-coo[9],coo[1]-coo[10],coo[2]-coo[11]}; - - double n0[3]={e3[1]*e0[2]-e3[2]*e0[1],e3[2]*e0[0]-e3[0]*e0[2],e3[0]*e0[1]-e3[1]*e0[0]}; - double n1[3]={e0[1]*e1[2]-e0[2]*e1[1],e0[2]*e1[0]-e0[0]*e1[2],e0[0]*e1[1]-e0[1]*e1[0]}; - double n2[3]={e1[1]*e2[2]-e1[2]*e2[1],e1[2]*e2[0]-e1[0]*e2[2],e1[0]*e2[1]-e1[1]*e2[0]}; - double n3[3]={e2[1]*e3[2]-e2[2]*e3[1],e2[2]*e3[0]-e2[0]*e3[2],e2[0]*e3[1]-e2[1]*e3[0]}; - - double l0=sqrt(n0[0]*n0[0]+n0[1]*n0[1]+n0[2]*n0[2]); - double l1=sqrt(n1[0]*n1[0]+n1[1]*n1[1]+n1[2]*n1[2]); - double l2=sqrt(n2[0]*n2[0]+n2[1]*n2[1]+n2[2]*n2[2]); - double l3=sqrt(n3[0]*n3[0]+n3[1]*n3[1]+n3[2]*n3[2]); - - if(l0<1.e-15 || l1<1.e-15 || l2<1.e-15 || l3<1e-15) - return std::numeric_limits::min(); - - double warp=std::min(n0[0]/l0*n2[0]/l2+n0[1]/l0*n2[1]/l2+n0[2]/l0*n2[2]/l2,n1[0]/l1*n3[0]/l3+n1[1]/l1*n3[1]/l3+n1[2]/l1*n3[2]/l3); - return warp*warp*warp; -} - -double INTERP_KERNEL::triEdgeRatio(const double *coo) -{ - double a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); - double b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); - double c2=(coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8]); - double mab=a2mab?mab:c2; - double M2=c2>Mab?c2:Mab; - if(m2>1.e-15) - return sqrt(M2/m2); - else - return std::numeric_limits::max(); -} - -double INTERP_KERNEL::triAspectRatio(const double *coo) -{ - double a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); - double b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); - double c=sqrt((coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8])); - - double hm=a>b?a:b; - hm=hm>c?hm:c; - - double ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), - (coo[5]-coo[2])*(coo[6]-coo[3])-(coo[3]-coo[0])*(coo[8]-coo[5]), - (coo[3]-coo[0])*(coo[7]-coo[4])-(coo[4]-coo[1])*(coo[6]-coo[3])}; - double d=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]); - static const double normalizeCoeff=sqrt(3.)/6.; - if(d>1.e-15) - return normalizeCoeff*hm*(a+b+c)/d; - else - return std::numeric_limits::max(); -} - -double INTERP_KERNEL::tetraEdgeRatio(const double *coo) -{ - double a[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; - double b[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; - double c[3]={coo[0]-coo[6],coo[1]-coo[7],coo[2]-coo[8]}; - double d[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; - double e[3]={coo[9]-coo[3],coo[10]-coo[4],coo[11]-coo[5]}; - double f[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; - - double l2[6]= - {a[0]*a[0]+a[1]*a[1]+a[2]*a[2], - b[0]*b[0]+b[1]*b[1]+b[2]*b[2], - c[0]*c[0]+c[1]*c[1]+c[2]*c[2], - d[0]*d[0]+d[1]*d[1]+d[2]*d[2], - e[0]*e[0]+e[1]*e[1]+e[2]*e[2], - f[0]*f[0]+f[1]*f[1]+f[2]*f[2]}; - - double M2=*std::max_element(l2,l2+6); - double m2=*std::min_element(l2,l2+6); - if(m2>1e-15) - return sqrt(M2/m2); - else - return std::numeric_limits::max(); -} - -double INTERP_KERNEL::tetraAspectRatio(const double *coo) -{ - static const double normalizeCoeff=sqrt(6.)/12.; - double ab[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; - double ac[3]={coo[6]-coo[0],coo[7]-coo[1],coo[8]-coo[2]}; - double ad[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; - double detTet=(ab[0]*(ac[1]*ad[2]-ac[2]*ad[1]))+(ab[1]*(ac[2]*ad[0]-ac[0]*ad[2]))+(ab[2]*(ac[0]*ad[1]-ac[1]*ad[2])); - //if(detTet<1.e-15) - // return std::numeric_limits::max(); - double bc[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; - double bd[3]={coo[9]-coo[3],coo[10]-coo[4],coo[11]-coo[5]}; - double cd[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; - - double ab2=ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]; - double bc2=bc[0]*bc[0]+bc[1]*bc[1]+bc[2]*bc[2]; - double ac2=ac[0]*ac[0]+ac[1]*ac[1]+ac[2]*ac[2]; - double ad2=ad[0]*ad[0]+ad[1]*ad[1]+ad[2]*ad[2]; - double bd2=bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]; - double cd2=cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]; - - double A=ab2>bc2?ab2:bc2; - double B=ac2>ad2?ac2:ad2; - double C=bd2>cd2?bd2:cd2; - double D=A>B?A:B; - double hm=D>C?sqrt(D):sqrt(C); - - bd[0]=ab[1]*bc[2]-ab[2]*bc[1]; bd[1]=ab[2]*bc[0]-ab[0]*bc[2]; bd[2]=ab[0]*bc[1]-ab[1]*bc[0]; - A=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); - bd[0]=ab[1]*ad[2]-ab[2]*ad[1]; bd[1]=ab[2]*ad[0]-ab[0]*ad[2]; bd[2]=ab[0]*ad[1]-ab[1]*ad[0]; - B=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); - bd[0]=ac[1]*ad[2]-ac[2]*ad[1]; bd[1]=ac[2]*ad[0]-ac[0]*ad[2]; bd[2]=ac[0]*ad[1]-ac[1]*ad[0]; - C=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); - bd[0]=bc[1]*cd[2]-bc[2]*cd[1]; bd[1]=bc[2]*cd[0]-bc[0]*cd[2]; bd[2]=bc[0]*cd[1]-bc[1]*cd[0]; - D=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); - return normalizeCoeff*hm*(A+B+C+D)/fabs(detTet); -} diff --git a/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx b/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx deleted file mode 100644 index 2f11bb4d1..000000000 --- a/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELMESHQUALITY_HXX_ -#define __INTERPKERNELMESHQUALITY_HXX__ - -#include "INTERPKERNELDefines.hxx" - -namespace INTERP_KERNEL -{ - INTERPKERNEL_EXPORT double quadSkew(const double *coo); - INTERPKERNEL_EXPORT double quadEdgeRatio(const double *coo); - INTERPKERNEL_EXPORT double quadAspectRatio(const double *coo); - INTERPKERNEL_EXPORT double quadWarp(const double *coo); - INTERPKERNEL_EXPORT double triEdgeRatio(const double *coo); - INTERPKERNEL_EXPORT double triAspectRatio(const double *coo); - INTERPKERNEL_EXPORT double tetraEdgeRatio(const double *coo); - INTERPKERNEL_EXPORT double tetraAspectRatio(const double *coo); -} - -#endif diff --git a/src/INTERP_KERNEL/InterpKernelUtilities.hxx b/src/INTERP_KERNEL/InterpKernelUtilities.hxx deleted file mode 100644 index c317cf64e..000000000 --- a/src/INTERP_KERNEL/InterpKernelUtilities.hxx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELUTILITIES_HXX__ -#define __INTERPKERNELUTILITIES_HXX__ - -//! DON'T INCLUDE THIS FILE IN .h NOR IN .hxx FILES !!!!!!!!! -#ifdef _DEBUG_ -# define MESSAGE(chain) {HERE ; cerr << chain << endl ;} -#else -# define MESSAGE(chain) -#endif - -#ifdef _DEBUG_ -# define HERE {cout< (message) , __FILE__ , __LINE__ - -#endif diff --git a/src/INTERP_KERNEL/Interpolation.hxx b/src/INTERP_KERNEL/Interpolation.hxx deleted file mode 100644 index d5bc563f9..000000000 --- a/src/INTERP_KERNEL/Interpolation.hxx +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION_HXX__ -#define __INTERPOLATION_HXX__ - -#include "INTERPKERNELDefines.hxx" -#include "InterpolationOptions.hxx" -#include "InterpKernelException.hxx" - -#include - -namespace INTERP_KERNEL -{ - template - class Interpolation : public InterpolationOptions - { - public: - Interpolation() { } - Interpolation(const InterpolationOptions& io) :InterpolationOptions(io){} - //interpolation of two triangular meshes. - template - int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result) - { return asLeaf().interpolateMeshes(meshS,meshT,result); } - template - int fromIntegralUniform(const MyMeshType& meshT, MatrixType& result, const char *method) { return fromToIntegralUniform(false,meshT,result,method); } - template - int toIntegralUniform(const MyMeshType& meshS, MatrixType& result, const char *method) { return fromToIntegralUniform(true,meshS,result,method); } - static void checkAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth) throw(INTERP_KERNEL::Exception); - protected: - template - int fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const char *method); - protected: - TrueMainInterpolator& asLeaf() { return static_cast(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation.txx b/src/INTERP_KERNEL/Interpolation.txx deleted file mode 100644 index 6e59eb88c..000000000 --- a/src/INTERP_KERNEL/Interpolation.txx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION_TXX__ -#define __INTERPOLATION_TXX__ - -#include "Interpolation.hxx" -#include "IntegralUniformIntersector.hxx" -#include "IntegralUniformIntersector.txx" - -namespace INTERP_KERNEL -{ - template - template - int Interpolation::fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const char *method) - { - typedef typename MyMeshType::MyConnType ConnType; - std::string methodCPP(method); - int ret=-1; - if(methodCPP=="P0") - { - IntegralUniformIntersectorP0 intersector(mesh,InterpolationOptions::getMeasureAbsStatus()); - intersector.setFromTo(fromTo); - std::vector tmp; - intersector.intersectCells(0,tmp,result); - ret=intersector.getNumberOfColsOfResMatrix(); - } - else if(methodCPP=="P1") - { - IntegralUniformIntersectorP1 intersector(mesh,InterpolationOptions::getMeasureAbsStatus()); - intersector.setFromTo(fromTo); - std::vector tmp; - intersector.intersectCells(0,tmp,result); - ret=intersector.getNumberOfColsOfResMatrix(); - } - else - throw INTERP_KERNEL::Exception("Invalid method specified in fromIntegralUniform : must be in { \"P0\", \"P1\"}"); - return ret; - } - - template - void Interpolation::checkAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth) throw(INTERP_KERNEL::Exception) - { - const int NB_OF_METH_MANAGED=4; - const char *METH_MANAGED[NB_OF_METH_MANAGED]={"P0P0","P0P1","P1P0","P1P1"}; - std::string methodC(method); - bool found=false; - for(int i=0;i - { - public: - Interpolation1D() { } - Interpolation1D(const InterpolationOptions& io):InterpolationCurve(io) {} - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation1D.txx b/src/INTERP_KERNEL/Interpolation1D.txx deleted file mode 100644 index 05e57f29a..000000000 --- a/src/INTERP_KERNEL/Interpolation1D.txx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION1D_TXX__ -#define __INTERPOLATION1D_TXX__ - -#include "Interpolation1D.hxx" - -#include "InterpolationCurve.txx" - -#endif diff --git a/src/INTERP_KERNEL/Interpolation2D.hxx b/src/INTERP_KERNEL/Interpolation2D.hxx deleted file mode 100755 index 05508345d..000000000 --- a/src/INTERP_KERNEL/Interpolation2D.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION2D_HXX__ -#define __INTERPOLATION2D_HXX__ - -#include "InterpolationPlanar.hxx" - -namespace INTERP_KERNEL -{ - class Interpolation2D : public InterpolationPlanar - { - public: - Interpolation2D() { } - Interpolation2D(const InterpolationOptions& io):InterpolationPlanar(io) { } - public: - bool doRotate() const { return false; } - double medianPlane() const { return 0.; } - template - void performAdjustmentOfBB(PlanarIntersector* intersector, std::vector& bbox) const { } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation2D.txx b/src/INTERP_KERNEL/Interpolation2D.txx deleted file mode 100644 index 7d12de41d..000000000 --- a/src/INTERP_KERNEL/Interpolation2D.txx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION2D_TXX__ -#define __INTERPOLATION2D_TXX__ - -#include "Interpolation2D.hxx" - -#include "InterpolationPlanar.txx" - -#endif diff --git a/src/INTERP_KERNEL/Interpolation2DCurve.hxx b/src/INTERP_KERNEL/Interpolation2DCurve.hxx deleted file mode 100644 index 72a36b6f4..000000000 --- a/src/INTERP_KERNEL/Interpolation2DCurve.hxx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION2DCURVE_HXX__ -#define __INTERPOLATION2DCURVE_HXX__ - -#include "InterpolationCurve.hxx" -#include "InterpolationOptions.hxx" - -namespace INTERP_KERNEL -{ - class Interpolation2DCurve : public InterpolationCurve - { - public: - Interpolation2DCurve(); - Interpolation2DCurve(const InterpolationOptions& io); - // geometric precision, intersection tolerance, coice of the median line, - void setOptions(double precision, double tolerance, double medianLine); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation2DCurve.txx b/src/INTERP_KERNEL/Interpolation2DCurve.txx deleted file mode 100644 index 0aafe3f91..000000000 --- a/src/INTERP_KERNEL/Interpolation2DCurve.txx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION2DCURVE_TXX__ -#define __INTERPOLATION2DCURVE_TXX__ - -#include "Interpolation2DCurve.hxx" -#include "InterpolationCurve.txx" - -namespace INTERP_KERNEL -{ - Interpolation2DCurve::Interpolation2DCurve() - { - // to have non-zero default thickness of target element - InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() ); - } - - Interpolation2DCurve::Interpolation2DCurve - (const InterpolationOptions& io):InterpolationCurve(io) - { - // to have non-zero default thickness of target element - InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() ); - } - - /** - * \brief Function used to set the options for the intersection calculation - * \details The following options can be modified: - * -# Precision: Level of precision of the computations. - * - Values: positive real number. - * - Default: 1.0E-12. - * -# Tolerance: Thickness of target element. - * - Values: positive real number. - * - Default: 1.0E-12. - * -# Median line: Position of the median line where both segments will be projected. - * - Values: real number between 0.0 and 1.0. - * - Default: 0.5 - */ - void Interpolation2DCurve::setOptions (double precision, - double tolerance, - double medianLine) - { - InterpolationOptions::setPrecision(precision); - InterpolationOptions::setBoundingBoxAdjustmentAbs(tolerance); - InterpolationOptions::setMedianPlane(medianLine); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation3D.hxx b/src/INTERP_KERNEL/Interpolation3D.hxx deleted file mode 100644 index e054c53f8..000000000 --- a/src/INTERP_KERNEL/Interpolation3D.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION3D_HXX__ -#define __INTERPOLATION3D_HXX__ - -#include "Interpolation.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpolationOptions.hxx" - -namespace INTERP_KERNEL -{ - class Interpolation3D : public Interpolation - { - public: - Interpolation3D(); - Interpolation3D(const InterpolationOptions& io); - template - int interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const char *method); - private: - SplittingPolicy _splitting_policy; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx deleted file mode 100644 index e01aef93a..000000000 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ /dev/null @@ -1,385 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION3D_TXX__ -#define __INTERPOLATION3D_TXX__ - -#include "Interpolation3D.hxx" -#include "Interpolation.txx" -#include "MeshElement.txx" -#include "TransformedTriangle.hxx" -#include "PolyhedronIntersectorP0P0.txx" -#include "PointLocator3DIntersectorP0P0.txx" -#include "PolyhedronIntersectorP0P1.txx" -#include "PointLocator3DIntersectorP0P1.txx" -#include "PolyhedronIntersectorP1P0.txx" -#include "PolyhedronIntersectorP1P0Bary.txx" -#include "PointLocator3DIntersectorP1P0.txx" -#include "PolyhedronIntersectorP1P1.txx" -#include "PointLocator3DIntersectorP1P1.txx" -#include "Log.hxx" -/// If defined, use recursion to traverse the binary search tree, else use the BBTree class -//#define USE_RECURSIVE_BBOX_FILTER - -#ifdef USE_RECURSIVE_BBOX_FILTER -#include "MeshRegion.txx" -#include "RegionNode.hxx" -#include - -#else // use BBTree class - -#include "BBTree.txx" - -#endif - -namespace INTERP_KERNEL -{ - /** - * \defgroup interpolation3D Interpolation3D - * \class Interpolation3D - * \brief Class used to calculate the volumes of intersection between the elements of two 3D meshes. - * - */ - /** - * Default constructor - * - */ - Interpolation3D::Interpolation3D() - { - } - Interpolation3D::Interpolation3D(const InterpolationOptions& io):Interpolation(io) - { - } - - /** - * Calculates the matrix of volumes of intersection between the elements of srcMesh and the elements of targetMesh. - * The calculation is done in two steps. First a filtering process reduces the number of pairs of elements for which the - * calculation must be carried out by eliminating pairs that do not intersect based on their bounding boxes. Then, the - * volume of intersection is calculated by an object of type Intersector3D for the remaining pairs, and entered into the - * intersection matrix. - * - * The matrix is partially sparse : it is a vector of maps of integer - double pairs. - * It can also be an INTERP_KERNEL::Matrix object. - * The length of the vector is equal to the number of target elements - for each target element there is a map, regardless - * of whether the element intersects any source elements or not. But in the maps there are only entries for those source elements - * which have a non-zero intersection volume with the target element. The vector has indices running from - * 0 to (nb target elements - 1), meaning that the map for target element i is stored at index i - 1. In the maps, however, - * the indexing is more natural : the intersection volume of the target element i with source element j is found at matrix[i-1][j]. - * - - * @param srcMesh 3-dimensional source mesh - * @param targetMesh 3-dimesional target mesh, containing only tetraedra - * @param result matrix in which the result is stored - * - */ - template - int Interpolation3D::interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const char *method) - { - typedef typename MyMeshType::MyConnType ConnType; - // create MeshElement objects corresponding to each element of the two meshes - const unsigned long numSrcElems = srcMesh.getNumberOfElements(); - const unsigned long numTargetElems = targetMesh.getNumberOfElements(); - - LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements "); - - std::vector*> srcElems(numSrcElems); - std::vector*> targetElems(numTargetElems); - - std::map*, int> indices; - - for(unsigned long i = 0 ; i < numSrcElems ; ++i) - srcElems[i] = new MeshElement(i, srcMesh); - - for(unsigned long i = 0 ; i < numTargetElems ; ++i) - targetElems[i] = new MeshElement(i, targetMesh); - - Intersector3D* intersector=0; - std::string methC = InterpolationOptions::filterInterpolationMethod(method); - if(methC=="P0P0") - { - switch(InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new PolyhedronIntersectorP0P0(targetMesh, srcMesh, getSplittingPolicy()); - break; - case PointLocator: - intersector=new PointLocator3DIntersectorP0P0(targetMesh, srcMesh, getPrecision()); - break; - default: - throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P0P0 interp specified : must be Triangle or PointLocator."); - } - } - else if(methC=="P0P1") - { - switch(InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new PolyhedronIntersectorP0P1(targetMesh, srcMesh, getSplittingPolicy()); - break; - case PointLocator: - intersector=new PointLocator3DIntersectorP0P1(targetMesh, srcMesh, getPrecision()); - break; - default: - throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P0P1 interp specified : must be Triangle or PointLocator."); - } - } - else if(methC=="P1P0") - { - switch(InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new PolyhedronIntersectorP1P0(targetMesh, srcMesh, getSplittingPolicy()); - break; - case PointLocator: - intersector=new PointLocator3DIntersectorP1P0(targetMesh, srcMesh, getPrecision()); - break; - default: - throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P0 interp specified : must be Triangle or PointLocator."); - } - } - else if(methC=="P1P0Bary") - { - if(InterpolationOptions::getIntersectionType()==Triangulation) - intersector=new PolyhedronIntersectorP1P0Bary(targetMesh, srcMesh, getSplittingPolicy()); - else - throw INTERP_KERNEL::Exception("Invalid 3D intersection type specified : must be Triangle."); - } - else if(methC=="P1P1") - { - switch(InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new PolyhedronIntersectorP1P1(targetMesh, srcMesh, getSplittingPolicy()); - break; - case PointLocator: - intersector=new PointLocator3DIntersectorP1P1(targetMesh, srcMesh, getPrecision()); - break; - default: - throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle or PointLocator."); - } - } - else - throw Exception("Invalid method choosed must be in \"P0P0\", \"P0P1\", \"P1P0\" or \"P1P1\"."); - // create empty maps for all source elements - result.resize(intersector->getNumberOfRowsOfResMatrix()); - -#ifdef USE_RECURSIVE_BBOX_FILTER - - /* - * Performs a depth-first search over srcMesh, using bounding boxes to recursively eliminate the elements of targetMesh - * which cannot intersect smaller and smaller regions of srcMesh. At each level, each region is divided in two, forming - * a binary search tree with leaves consisting of only one element of the source mesh together with the elements of the - * target mesh that can intersect it. The recursion is implemented with a stack of RegionNodes, each one containing a - * source region and a target region. Each region has an associated bounding box and a vector of pointers to the elements - * that belong to it. Each MeshElement contains a bounding box and the global number of the corresponding element in the mesh. - */ - - // create initial RegionNode and fill up its source region with all the source mesh elements and - // its target region with all the target mesh elements whose bounding box - // intersects that of the source region - - RegionNode* firstNode = new RegionNode(); - - MeshRegion& srcRegion = firstNode->getSrcRegion(); - - for(unsigned long i = 0 ; i < numSrcElems ; ++i) - { - srcRegion.addElement(srcElems[i], srcMesh); - } - - MeshRegion& targetRegion = firstNode->getTargetRegion(); - - for(unsigned long i = 0 ; i < numTargetElems ; ++i) - { - if(!srcRegion.isDisjointWithElementBoundingBox( *(targetElems[i]) )) - { - targetRegion.addElement(targetElems[i], targetMesh); - } - } - - // Using a stack, descend recursively, creating at each step two new RegionNodes having as source region the left and - // right part of the source region of the current node (created using MeshRegion::split()) and as target region all the - // elements of the target mesh whose bounding box intersects the corresponding part - // Continue until the source region contains only one element, at which point the intersection volumes are - // calculated with all the remaining target mesh elements and stored in the matrix if they are non-zero. - - std::stack< RegionNode* > nodes; - nodes.push(firstNode); - - while(!nodes.empty()) - { - RegionNode* currNode = nodes.top(); - nodes.pop(); - LOG(4, "Popping node "); - - if(currNode->getTargetRegion().getNumberOfElements() == 1) - { - // calculate volumes - LOG(4, " - One element"); - - MeshElement* targetElement = *(currNode->getTargetRegion().getBeginElements()); - std::vector intersectElems; - for(typename std::vector< MeshElement* >::const_iterator iter = currNode->getSrcRegion().getBeginElements();iter != currNode->getSrcRegion().getEndElements();++iter) - intersectElems.push_back((*iter)->getIndex()); - intersector->intersectCells(targetElement->getIndex(),intersectElems,result); - } - else // recursion - { - - LOG(4, " - Recursion"); - - RegionNode* leftNode = new RegionNode(); - RegionNode* rightNode = new RegionNode(); - - // split current source region - //} decide on axis - static BoundingBox::BoxCoord axis = BoundingBox::XMAX; - - currNode->getTargetRegion().split(leftNode->getTargetRegion(), rightNode->getTargetRegion(), axis, targetMesh); - - LOG(5, "After split, left target region has " << leftNode->getTargetRegion().getNumberOfElements() - << " elements and right target region has " << rightNode->getTargetRegion().getNumberOfElements() - << " elements"); - - // ugly hack to avoid problem with enum which does not start at 0 - // I guess I ought to implement ++ for it instead ... - // Anyway, it basically chooses the next axis, cyclically - axis = (axis != BoundingBox::ZMAX) ? static_cast(axis + 1) : BoundingBox::XMAX; - - // add source elements of current node that overlap the target regions of the new nodes - LOG(5, " -- Adding source elements"); - int numLeftElements = 0; - int numRightElements = 0; - for(typename std::vector*>::const_iterator iter = currNode->getSrcRegion().getBeginElements() ; - iter != currNode->getSrcRegion().getEndElements() ; ++iter) - { - LOG(6, " --- New target node"); - - if(!leftNode->getTargetRegion().isDisjointWithElementBoundingBox(**iter)) - { - leftNode->getSrcRegion().addElement(*iter, srcMesh); - ++numLeftElements; - } - - if(!rightNode->getTargetRegion().isDisjointWithElementBoundingBox(**iter)) - { - rightNode->getSrcRegion().addElement(*iter, srcMesh); - ++numRightElements; - } - - } - - LOG(5, "Left src region has " << numLeftElements << " elements and right src region has " - << numRightElements << " elements"); - - // push new nodes on stack - if(numLeftElements != 0) - { - nodes.push(leftNode); - } - else - { - delete leftNode; - } - - if(numRightElements != 0) - { - nodes.push(rightNode); - } - else - { - delete rightNode; - } - } - - // all nodes are deleted here - delete currNode; - - LOG(4, "Next iteration. Nodes left : " << nodes.size()); - } - -#else // Use BBTree - - // create BBTree structure - // - get bounding boxes - double* bboxes = new double[6 * numSrcElems]; - int* srcElemIdx = new int[numSrcElems]; - for(unsigned long i = 0; i < numSrcElems ; ++i) - { - // get source bboxes in right order - const BoundingBox* box = srcElems[i]->getBoundingBox(); - bboxes[6*i+0] = box->getCoordinate(BoundingBox::XMIN); - bboxes[6*i+1] = box->getCoordinate(BoundingBox::XMAX); - bboxes[6*i+2] = box->getCoordinate(BoundingBox::YMIN); - bboxes[6*i+3] = box->getCoordinate(BoundingBox::YMAX); - bboxes[6*i+4] = box->getCoordinate(BoundingBox::ZMIN); - bboxes[6*i+5] = box->getCoordinate(BoundingBox::ZMAX); - - // source indices have to begin with zero for BBox, I think - srcElemIdx[i] = srcElems[i]->getIndex(); - } - - BBTree<3,ConnType> tree(bboxes, srcElemIdx, 0, numSrcElems); - - // for each target element, get source elements with which to calculate intersection - // - calculate intersection by calling intersectCells - for(unsigned long i = 0; i < numTargetElems; ++i) - { - const BoundingBox* box = targetElems[i]->getBoundingBox(); - const int targetIdx = targetElems[i]->getIndex(); - - // get target bbox in right order - double targetBox[6]; - targetBox[0] = box->getCoordinate(BoundingBox::XMIN); - targetBox[1] = box->getCoordinate(BoundingBox::XMAX); - targetBox[2] = box->getCoordinate(BoundingBox::YMIN); - targetBox[3] = box->getCoordinate(BoundingBox::YMAX); - targetBox[4] = box->getCoordinate(BoundingBox::ZMIN); - targetBox[5] = box->getCoordinate(BoundingBox::ZMAX); - - std::vector intersectElems; - - tree.getIntersectingElems(targetBox, intersectElems); - - if ( !intersectElems.empty() ) - intersector->intersectCells(targetIdx,intersectElems,result); - } - - delete [] bboxes; - delete [] srcElemIdx; - -#endif - // free allocated memory - int ret=intersector->getNumberOfColsOfResMatrix(); - - delete intersector; - - for(unsigned long i = 0 ; i < numSrcElems ; ++i) - { - delete srcElems[i]; - } - for(unsigned long i = 0 ; i < numTargetElems ; ++i) - { - delete targetElems[i]; - } - return ret; - - } -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.hxx b/src/INTERP_KERNEL/Interpolation3DSurf.hxx deleted file mode 100644 index b319e81bc..000000000 --- a/src/INTERP_KERNEL/Interpolation3DSurf.hxx +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION3DSURF_HXX__ -#define __INTERPOLATION3DSURF_HXX__ - -#include "InterpolationPlanar.hxx" -#include "InterpolationOptions.hxx" - -namespace INTERP_KERNEL -{ - class Interpolation3DSurf : public InterpolationPlanar - { - public: - Interpolation3DSurf(); - Interpolation3DSurf(const InterpolationOptions& io); - void setOptions(double precision, int printLevel, double medianPlane, - IntersectionType intersectionType, bool doRotate, int orientation=0); - public: - template - void performAdjustmentOfBB(PlanarIntersector* intersector, std::vector& bbox) const - { intersector->adjustBoundingBoxes(bbox,InterpolationPlanar::getBoundingBoxAdjustment(),InterpolationPlanar::getBoundingBoxAdjustmentAbs()); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.txx b/src/INTERP_KERNEL/Interpolation3DSurf.txx deleted file mode 100644 index 440a95c25..000000000 --- a/src/INTERP_KERNEL/Interpolation3DSurf.txx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATION3DSURF_TXX__ -#define __INTERPOLATION3DSURF_TXX__ - -#include "Interpolation3DSurf.hxx" -#include "InterpolationPlanar.txx" - -namespace INTERP_KERNEL -{ - Interpolation3DSurf::Interpolation3DSurf() - { - } - - Interpolation3DSurf::Interpolation3DSurf(const InterpolationOptions& io):InterpolationPlanar(io) - { - } - - - /** - \brief Function used to set the options for the intersection calculation - \details The following options can be modified: - -# Intersection_type: the type of algorithm to be used in the computation of the cell-cell intersections. - - Values: Triangle, Convex. - - Default: Triangle. - -# MedianPlane: Position of the median plane where both cells will be projected - - Values: between 0 and 1. - - Default: 0.5. - -# DoRotate: rotate the coordinate system such that the target cell is in the Oxy plane. - - Values: true (necessarilly if Intersection_type=Triangle), false. - - Default: true (as default Intersection_type=Triangle) - -# Precision: Level of precision of the computations is precision times the characteristic size of the mesh. - - Values: positive real number. - - Default: 1.0E-12. - -# PrintLevel: Level of verboseness during the computations. - - Values: interger between 0 and 3. - - Default: 0. - */ - void Interpolation3DSurf::setOptions(double precision, int printLevel, double medianPlane, - IntersectionType intersectionType, bool doRotate, int orientation) - { - InterpolationPlanar::setOptions(precision,printLevel,intersectionType, orientation); - InterpolationPlanar::setDoRotate(doRotate); - InterpolationPlanar::setMedianPlane(medianPlane); - } -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationCC.hxx b/src/INTERP_KERNEL/InterpolationCC.hxx deleted file mode 100644 index 738bdb0c5..000000000 --- a/src/INTERP_KERNEL/InterpolationCC.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : InterpolationCC.hxx -// Created : Fri Aug 14 11:33:17 2009 -// Author : Edward AGAPOV (eap) -// -#ifndef __InterpolationCC_HXX__ -#define __InterpolationCC_HXX__ - -#include "Interpolation.hxx" - -namespace INTERP_KERNEL -{ - /*! - * \brief Interpolator of cartesian/cartesian meshes - */ - class InterpolationCC : public Interpolation - { -// static const int SPACEDIM=MyMeshType::MY_SPACEDIM; -// static const int MESHDIM=MyMeshType::MY_MESHDIM; -// typedef typename MyMeshType::MyConnType ConnType; -// static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - InterpolationCC(); - //InterpolationCC(const InterpolationOptions& io); - template - int interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const char *method); - - private: - }; -} - - -#endif diff --git a/src/INTERP_KERNEL/InterpolationCC.txx b/src/INTERP_KERNEL/InterpolationCC.txx deleted file mode 100644 index 9b08c68f6..000000000 --- a/src/INTERP_KERNEL/InterpolationCC.txx +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : InterpolationCC.txx -// Created : Fri Aug 14 11:39:27 2009 -// Author : Edward AGAPOV (eap) -// - -#include "InterpolationCC.hxx" -#include "InterpolationUtils.hxx" - -// convert index "From Mesh Index" -#define _FMI(i) OTT::ind2C((i)) -// convert index "To Mesh Index" -#define _TMI(i) OTT::indFC((i)) - -namespace INTERP_KERNEL -{ - //================================================================================ - /*! - * \brief Constructor does nothing - */ - //================================================================================ - InterpolationCC::InterpolationCC() - { - } - - //================================================================================ - /*! - * \brief An 1D intersection result - */ - //================================================================================ - - struct Interference - { - int _src_index; // source cell index along an axis - int _tgt_index; // target cell index along an axis - double _length; // interference length - Interference(int is = -1, int it = -1, double l = 0):_src_index(is),_tgt_index(it),_length(l){} - }; - - //================================================================================ - /*! - * \brief Fills the matrix by precomputed cell interferences along axes - * \param inter_of_axis - cell/cell interferences along each axis - * \param result - matrix to fill in - * \param src_nb_cells[] - nb of cells along each of axes in the source mesh - * \param tgt_nb_cells[] - nb of cells along each of axes in the target mesh - * \param src_i_cell - source cell number accumulated by previous axes - * \param tgt_i_cell - target cell number accumulated by previous axes - * \param src_prev_area - factor by which this axis icreases cell number - * \param tgt_prev_area - factor by which this axis icreases cell number - * \param axis - the axis to treat - * \param prev_value - intersection size computed by previous axes - */ - //================================================================================ - - template - void fillMatrix(const std::list< Interference > inter_of_axis[dim], - MatrixType& result, - const int src_nb_cells[dim], - const int tgt_nb_cells[dim], - const int src_i_cell = 0, - const int tgt_i_cell = 0, - const int src_prev_area = 1, - const int tgt_prev_area = 1, - const int axis = 0, - const double prev_value = 1.0) - { - typedef std::list < Interference >::const_iterator TIntIterator; - - if ( axis + 1 == dim ) - { - for ( TIntIterator i = inter_of_axis[axis].begin(); i != inter_of_axis[axis].end(); ++i ) - { - double value = i->_length * prev_value; - int src_i = i->_src_index * src_prev_area + src_i_cell; - int tgt_i = i->_tgt_index * tgt_prev_area + tgt_i_cell; - - result[ tgt_i ].insert( std::make_pair( _TMI( src_i ), value )); - } - } - else - { - int src_prev_area_next = src_prev_area * src_nb_cells[ axis ]; - int tgt_prev_area_next = tgt_prev_area * tgt_nb_cells[ axis ]; - - for ( TIntIterator i = inter_of_axis[axis].begin(); i != inter_of_axis[axis].end(); ++i ) - { - double value = i->_length * prev_value; - int src_i = i->_src_index * src_prev_area + src_i_cell; - int tgt_i = i->_tgt_index * tgt_prev_area + tgt_i_cell; - - // call for the next axis - fillMatrix(inter_of_axis, result, - src_nb_cells, tgt_nb_cells, src_i, tgt_i, - src_prev_area_next, tgt_prev_area_next, - axis+1, value ); - } - } - } - - //================================================================================ - /*! - * \brief Calculates the matrix of volumes of intersection between the elements of - * src_mesh and the elements of targetMesh - * \param src_mesh - source mesh - * \param tgt_mesh - target mesh - * \param result - matrix in which the result is stored - * \param method - interpolation method, not used as only "P0P0" is implemented so far - * - * The matrix is partially sparse : it is a vector of maps of integer - double pairs. - * It can also be an INTERP_KERNEL::Matrix object. - * The length of the vector is equal to the number of target elements - for each target - * element there is a map, regardless of whether the element intersects any source - * elements or not. But in the maps there are only entries for those source elements - * which have a non-zero intersection volume with the target element. The vector has - * indices running from 0 to (nb target elements - 1), meaning that the map for target - * element i is stored at index i - 1. In the maps, however, the indexing is more natural: - * the intersection volume of the target element i with source element j is found at matrix[i-1][j] - */ - //================================================================================ - - template - int InterpolationCC::interpolateMeshes(const MyMeshType& src_mesh, - const MyMeshType& tgt_mesh, - MatrixType& result, - const char * method) - { - if ( std::string("P0P0") != method ) - throw Exception("Only P0P0 method is implemented so far"); - - // create empty maps for all target elements - result.resize( tgt_mesh.getNumberOfElements() ); - - const int ret = src_mesh.getNumberOfElements(); - - const double eps = getPrecision(); - const int dim = MyMeshType::MY_MESHDIM; - //const NumberingPolicy numPol = MyMeshType::My_numPol; - - const double* src_coords[ dim ]; - const double* tgt_coords[ dim ]; - int src_nb_cells[ dim ]; - int tgt_nb_cells[ dim ]; - for ( int j = 0; j < dim; ++j ) - { - src_coords[ j ] = src_mesh.getCoordsAlongAxis( _TMI( j )); - tgt_coords[ j ] = tgt_mesh.getCoordsAlongAxis( _TMI( j )); - src_nb_cells[ j ] = src_mesh.nbCellsAlongAxis( _TMI( j )); - tgt_nb_cells[ j ] = tgt_mesh.nbCellsAlongAxis( _TMI( j )); - } - - // ============================================ - // Calculate cell interferences along the axes - // ============================================ - - std::list < Interference > interferences[ dim ]; - - for ( int j = 0; j < dim; ++j ) // loop on axes of castesian space - { - std::list < Interference >& axis_interferences = interferences[j]; - - int it = 0, is = 0; - double x1t, x2t, x1s, x2s; // left and right ordinates of target and source cells - - // look for the first interference - // -------------------------------- - bool intersection = false; - while ( !intersection && it < tgt_nb_cells[j] && is < src_nb_cells[j] ) - { - x1s = src_coords[ j ][ is ]; - x2t = tgt_coords[ j ][ it+1 ]; - if ( x2t < x1s+eps ) - { - it++; // source lays on the right of target - continue; - } - x1t = tgt_coords[ j ][ it ]; - x2s = src_coords[ j ][ is+1 ]; - if ( x2s < x1t+eps ) - { - is++; // source lays on the left of target - continue; - } - intersection = true; - } - if ( !intersection ) return ret; // no intersections - - // get all interferences - // ---------------------- - while ( intersection ) - { - x1s = src_coords[ j ][ is ]; - x1t = tgt_coords[ j ][ it ]; - x2t = tgt_coords[ j ][ it+1 ]; - x2s = src_coords[ j ][ is+1 ]; - - double x1 = std::max( x1s ,x1t ); - double x2 = std::min( x2s ,x2t ); - axis_interferences.push_back( Interference( is, it, x2 - x1 )); - - // to the next target and/or source cell - double diff2 = x2s - x2t; - if ( diff2 > -eps ) - intersection = ( ++it < tgt_nb_cells[j] ); - if ( diff2 < eps ) - intersection = ( ++is < src_nb_cells[j] && intersection); - } - } - - // ================ - // Fill the matrix - // ================ - - switch ( dim ) - { - case 3: - fillMatrix( interferences, result, src_nb_cells,tgt_nb_cells ); - break; - - case 2: - fillMatrix( interferences, result, src_nb_cells,tgt_nb_cells ); - break; - - case 1: - fillMatrix( interferences, result, src_nb_cells,tgt_nb_cells ); - break; - } - - return ret; - } -} diff --git a/src/INTERP_KERNEL/InterpolationCU.hxx b/src/INTERP_KERNEL/InterpolationCU.hxx deleted file mode 100644 index ea73b3667..000000000 --- a/src/INTERP_KERNEL/InterpolationCU.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : InterpolationCU.hxx -// Created : Mon Dec 14 16:52:53 2009 -// Author : Edward AGAPOV (eap) -// -#ifndef __InterpolationCU_HXX__ -#define __InterpolationCU_HXX__ - -#include "Interpolation.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - class InterpolationCU : public Interpolation< InterpolationCU > - { - public: - InterpolationCU(); - InterpolationCU(const InterpolationOptions & io); - - template - int interpolateMeshes(const MyCMeshType& meshS, const MyUMeshType& meshT, MatrixType& result, const char *method); - - template - int interpolateMeshesRev(const MyUMeshType& meshS, const MyCMeshType& meshT, MatrixType& result, const char *method); - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationCU.txx b/src/INTERP_KERNEL/InterpolationCU.txx deleted file mode 100644 index 18d09ef97..000000000 --- a/src/INTERP_KERNEL/InterpolationCU.txx +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : InterpolationCU.txx -// Created : Mon Dec 14 17:30:25 2009 -// Author : Edward AGAPOV (eap) - -#ifndef __InterpolationCU_TXX__ -#define __InterpolationCU_TXX__ - -#include "InterpolationCU.hxx" - -#include "Interpolation.txx" -#include "IntersectorCU1D.txx" -#include "IntersectorCU2D.txx" -#include "IntersectorCU3D.txx" - -#include - -// // convert index "From Mesh Index" -#define _FMIU(i) OTT::ind2C((i)) -#define _FMIC(i) OTT::ind2C((i)) -// convert index "To Mesh Index" -#define _TMIU(i) OTT::indFC((i)) -#define _TMIC(i) OTT::indFC((i)) -// convert coord "From Mesh Coord" -#define _FMCOO(i) OTT::coo2C((i)) -// convert connectivity "From Mesh Connectivity" -#define _FMCON(i) OTT::conn2C((i)) - -namespace INTERP_KERNEL -{ - /** - * \defgroup InterpolationCU InterpolationCU - * \class InterpolationCU - * \brief Class used to calculate the volumes of intersection between the elements of a cartesian and an unstructured meshes. - * - */ - //================================================================================ - /** - * Default constructor - * - */ - //================================================================================ - - InterpolationCU::InterpolationCU() - { - } - - InterpolationCU::InterpolationCU(const InterpolationOptions & io) - :Interpolation(io) - { - } - - //================================================================================ - /** - * Calculates the matrix of volumes of intersection between the elements of srcMesh and the elements of targetMesh. - * The calculation is done in two steps. First a filtering process reduces the number of pairs of elements for which the - * calculation must be carried out by eliminating pairs that do not intersect based on their bounding boxes. Then, the - * volume of intersection is calculated for the remaining pairs, and entered into the - * intersection matrix. - * - * The matrix is partially sparse : it is a vector of maps of integer - double pairs. - * It can also be an INTERP_KERNEL::Matrix object. - * The length of the vector is equal to the number of target elements - for each target element there is a map, regardless - * of whether the element intersects any source elements or not. But in the maps there are only entries for those source elements - * which have a non-zero intersection volume with the target element. The vector has indices running from - * 0 to (nb target elements - 1), meaning that the map for target element i is stored at index i - 1. In the maps, however, - * the indexing is more natural : the intersection volume of the target element i with source element j is found at matrix[i-1][j]. - * - - * @param srcMesh cartesian source mesh - * @param targetMesh unstructured target mesh - * @param result matrix in which the result is stored - * @param method interpolation method - */ - //================================================================================ - - template - int InterpolationCU::interpolateMeshes(const MyCMeshType& src_mesh, - const MyUMeshType& tgt_mesh, - MatrixType& result, - const char * method) - { - typedef typename MyUMeshType::MyConnType ConnType; - typedef typename MyCMeshType::MyConnType CConnType; - - if ( std::string("P0P0") != method ) - throw Exception("Only P0P0 method is implemented so far"); - if ( MyCMeshType::MY_SPACEDIM != MyUMeshType::MY_SPACEDIM || - MyCMeshType::MY_SPACEDIM != MyUMeshType::MY_MESHDIM ) - throw Exception("InterpolationCU::interpolateMeshes(): dimension of meshes must be same"); - - const double eps = getPrecision(); - const int dim = MyCMeshType::MY_SPACEDIM; - - TargetIntersector* intersector = 0; - switch( dim ) - { - case 1: intersector = new IntersectorCU1D( src_mesh, tgt_mesh ); break; - case 2: intersector = new IntersectorCU2D( src_mesh, tgt_mesh ); break; - case 3: intersector = new IntersectorCU3D( src_mesh, tgt_mesh, getSplittingPolicy() ); break; - } - // create empty maps for all target elements - result.resize( intersector->getNumberOfRowsOfResMatrix() ); - const int ret = intersector->getNumberOfColsOfResMatrix(); - - const double* src_coords[ dim ]; - int src_nb_coords[ dim ]; - std::map< double, int> src_coord_to_index[ dim ]; - for ( int j = 0; j < dim; ++j ) - { - src_coords [j] = src_mesh.getCoordsAlongAxis( _TMIC( j )); - src_nb_coords[j] = src_mesh.nbCellsAlongAxis ( _TMIC( j )) + 1; - for (int i = 0; i < src_nb_coords[j]; ++i ) - src_coord_to_index[j].insert( std::make_pair( src_coords[j][i], i )); - } - - const unsigned long tgtu_nb_cells = tgt_mesh.getNumberOfElements(); - - IntersectorCU bbHelper(src_mesh, tgt_mesh); - double bb[2*dim]; - - // loop on unstructured tgt cells - - for(unsigned int iT=0; iT src_coords[j][0] + eps; - if ( !doItersect ) - continue; // no intersection - - // find structured src cells intersecting iT cell - std::vector< std::vector< CConnType > > structIndices(1); - std::map< double, int>::iterator coo_ind; - for ( int j = 0; j < dim; ++j ) - { - coo_ind = src_coord_to_index[j].lower_bound( bb[2*j+1] - eps ); - if ( coo_ind == src_coord_to_index[j].end() ) - --coo_ind; - int max_i = coo_ind->second; - - coo_ind = src_coord_to_index[j].upper_bound( bb[2*j ] + eps ); - if ( coo_ind != src_coord_to_index[j].begin() ) - --coo_ind; - int min_i = coo_ind->second; - - std::vector< std::vector< CConnType > > newStructIndices; - for ( unsigned int iInd = 0; iInd < structIndices.size(); ++iInd ) - { - for ( int i = min_i; i < max_i; ++i ) - { - std::vector< CConnType > index = structIndices[iInd]; - index.push_back( i ); - newStructIndices.push_back( index ); - } - } - structIndices.swap( newStructIndices ); - } - - // perform intersection - - for ( unsigned int iInd = 0; iInd < structIndices.size(); ++iInd ) - intersector->intersectCells( iT, structIndices[iInd], result ); - } - delete intersector; - return ret; - } - - //================================================================================ - /** - * Calculates the matrix of volumes of intersection between the elements of srcMesh and the elements of targetMesh. - * The calculation is done in two steps. First a filtering process reduces the number of pairs of elements for which the - * calculation must be carried out by eliminating pairs that do not intersect based on their bounding boxes. Then, the - * volume of intersection is calculated for the remaining pairs, and entered into the - * intersection matrix. - * - * The matrix is partially sparse : it is a vector of maps of integer - double pairs. - * It can also be an INTERP_KERNEL::Matrix object. - * The length of the vector is equal to the number of target elements - for each target element there is a map, regardless - * of whether the element intersects any source elements or not. But in the maps there are only entries for those source elements - * which have a non-zero intersection volume with the target element. The vector has indices running from - * 0 to (nb target elements - 1), meaning that the map for target element i is stored at index i - 1. In the maps, however, - * the indexing is more natural : the intersection volume of the target element i with source element j is found at matrix[i-1][j]. - * - - * @param srcMesh 2-dimesional unstructured target mesh - * @param targetMesh 2-dimensional cartesian source mesh - * @param result matrix in which the result is stored - * @param method interpolation method - */ - //================================================================================ - - template - int InterpolationCU::interpolateMeshesRev(const MyUMeshType& meshS, const MyCMeshType& meshT, MatrixType& result, const char *method) - { - MatrixType revResult; - int sizeT = interpolateMeshes( meshT, meshS, revResult, method ); - int sizeS = revResult.size(); - result.resize( sizeT ); - - for ( int iS = 0; iS < sizeS; ++iS ) - { - typename MatrixType::value_type & row = revResult[iS]; - typename MatrixType::value_type::iterator iT_surf = row.begin(); - for ( ; iT_surf != row.end(); ++iT_surf ) - result[ iT_surf->first ][ iS ] = iT_surf->second; - } - return sizeS; - } - -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationCurve.hxx b/src/INTERP_KERNEL/InterpolationCurve.hxx deleted file mode 100644 index 0c3f11ad3..000000000 --- a/src/INTERP_KERNEL/InterpolationCurve.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATIONCURVE_HXX__ -#define __INTERPOLATIONCURVE_HXX__ - -#include "Interpolation.hxx" -#include "InterpolationOptions.hxx" - -namespace INTERP_KERNEL -{ - template - class InterpolationCurve : public Interpolation< InterpolationCurve > - { - public: - InterpolationCurve(); - InterpolationCurve(const InterpolationOptions & io); - - // Main function to interpolate - template - int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, - MatrixType& result, const char *method); - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationCurve.txx b/src/INTERP_KERNEL/InterpolationCurve.txx deleted file mode 100644 index e4b908322..000000000 --- a/src/INTERP_KERNEL/InterpolationCurve.txx +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATIONCURVE_TXX__ -#define __INTERPOLATIONCURVE_TXX__ - -#include "InterpolationCurve.hxx" -#include "InterpolationOptions.hxx" -#include "CurveIntersectorP0P0.txx" -#include "CurveIntersectorP1P0.txx" -#include "CurveIntersectorP0P1.txx" -#include "CurveIntersectorP1P1.txx" -#include "BBTree.txx" - -#include - -namespace INTERP_KERNEL -{ - /** - * \defgroup interpolationCurve InterpolationCurve - * - * \class InterpolationCurve - * \brief Class used to compute the coefficients of the interpolation matrix between - * two local meshes in two dimensions. - */ - template - InterpolationCurve::InterpolationCurve() - { - } - - template - InterpolationCurve::InterpolationCurve (const InterpolationOptions& io) - :Interpolation< InterpolationCurve >(io) - { - } - - /** \brief Main function to interpolate 1D meshes. - \details The algorithm proceeds in two steps: first a filtering process reduces the number of pairs of elements for which the - * calculation must be carried out by eliminating pairs that do not intersect based on their bounding boxes. Then, the - * volume of intersection is calculated by an object of type IntersectorPlanar for the remaining pairs, and entered into the - * intersection matrix. - * - * The matrix is partially sparse : it is a vector of maps of integer - double pairs. - * The length of the vector is equal to the number of target elements - for each target element there is a map, regardless - * of whether the element intersects any source elements or not. But in the maps there are only entries for those source elements - * which have a non-zero intersection volume with the target element. The vector has indices running from - * 0 to (#target elements - 1), meaning that the map for target element i is stored at index i - 1. In the maps, however, - * the indexing is more natural : the intersection volume of the target element i with source element j is found at matrix[i-1][j]. - * - - * @param myMeshS Planar source mesh - * @Param myMeshT Planar target mesh - * @return vector containing for each element i of the source mesh, a map giving for each element j - * of the target mesh which i intersects, the area of the intersection - * - */ - template - template - int InterpolationCurve::interpolateMeshes (const MyMeshType& myMeshS, - const MyMeshType& myMeshT, - MatrixType& result, - const char * method) - { - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol = MyMeshType::My_numPol; - - long global_start = clock(); - int counter=0; - - long nbMailleS = myMeshS.getNumberOfElements(); - long nbMailleT = myMeshT.getNumberOfElements(); - - CurveIntersector* intersector=0; - std::string meth(method); - if(meth=="P0P0") - { - intersector = new CurveIntersectorP0P0 - (myMeshT, myMeshS, - InterpolationOptions::getPrecision(), - InterpolationOptions::getBoundingBoxAdjustmentAbs(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrintLevel()); - } - else if(meth=="P0P1") - { - intersector = new CurveIntersectorP0P1 - (myMeshT, myMeshS, - InterpolationOptions::getPrecision(), - InterpolationOptions::getBoundingBoxAdjustmentAbs(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrintLevel()); - } - else if(meth=="P1P0") - { - intersector = new CurveIntersectorP1P0 - (myMeshT, myMeshS, - InterpolationOptions::getPrecision(), - InterpolationOptions::getBoundingBoxAdjustmentAbs(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrintLevel()); - } - else if(meth=="P1P1") - { - intersector = new CurveIntersectorP1P1 - (myMeshT, myMeshS, - InterpolationOptions::getPrecision(), - InterpolationOptions::getBoundingBoxAdjustmentAbs(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrintLevel()); - } - else - throw INTERP_KERNEL::Exception("Invalid method specified ! Must be in : \"P0P0\" \"P0P1\" \"P1P0\" or \"P1P1\""); - /****************************************************************/ - /* Create a search tree based on the bounding boxes */ - /* Instanciate the intersector and initialise the result vector */ - /****************************************************************/ - - long start_filtering=clock(); - - std::vector bbox; - intersector->createBoundingBoxes(myMeshS,bbox); // create the bounding boxes - intersector->adjustBoundingBoxes(bbox, InterpolationOptions::getBoundingBoxAdjustmentAbs()); - BBTree my_tree(&bbox[0], 0, 0, nbMailleS);//creating the search structure - - long end_filtering = clock(); - - result.resize(intersector->getNumberOfRowsOfResMatrix());//on initialise. - - /****************************************************/ - /* Loop on the target cells - core of the algorithm */ - /****************************************************/ - long start_intersection = clock(); - const ConnType *connIndxT = myMeshT.getConnectivityIndexPtr(); - for(int iT=0; iT intersecting_elems; - double bb[2*SPACEDIM]; - intersector->getElemBB(bb,myMeshT,OTT::indFC(iT),nb_nodesT); - my_tree.getIntersectingElems(bb, intersecting_elems); - intersector->intersectCells(iT,intersecting_elems,result); - counter += intersecting_elems.size(); - } - int ret = intersector->getNumberOfColsOfResMatrix(); - delete intersector; - - if (InterpolationOptions::getPrintLevel() >= 1) - { - long end_intersection=clock(); - std::cout << "Filtering time= " << end_filtering-start_filtering << std::endl; - std::cout << "Intersection time= " << end_intersection-start_intersection << std::endl; - long global_end =clock(); - std::cout << "Number of computed intersections = " << counter << std::endl; - std::cout << "Global time= " << global_end - global_start << std::endl; - } - return ret; - } -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationOptions.cxx b/src/INTERP_KERNEL/InterpolationOptions.cxx deleted file mode 100644 index 6069bf22d..000000000 --- a/src/INTERP_KERNEL/InterpolationOptions.cxx +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpolationOptions.hxx" - -const double INTERP_KERNEL::InterpolationOptions::DFT_MEDIAN_PLANE=0.5; - -const double INTERP_KERNEL::InterpolationOptions::DFT_SURF3D_ADJ_EPS=1.e-4; - -const double INTERP_KERNEL::InterpolationOptions::DFT_MAX_DIST_3DSURF_INTERSECT=-1.; - -const char INTERP_KERNEL::InterpolationOptions::PRECISION_STR[]="Precision"; - -const char INTERP_KERNEL::InterpolationOptions::MEDIANE_PLANE_STR[]="MedianPlane"; - -const char INTERP_KERNEL::InterpolationOptions::BOUNDING_BOX_ADJ_STR[]="BoundingBoxAdjustment"; - -const char INTERP_KERNEL::InterpolationOptions::BOUNDING_BOX_ADJ_ABS_STR[]="BoundingBoxAdjustmentAbs"; - -const char INTERP_KERNEL::InterpolationOptions::MAX_DISTANCE_3DSURF_INSECT_STR[]="MaxDistance3DSurfIntersect"; - -const char INTERP_KERNEL::InterpolationOptions::PRINT_LEV_STR[]="PrintLevel"; - -const char INTERP_KERNEL::InterpolationOptions::DO_ROTATE_STR[]="DoRotate"; - -const char INTERP_KERNEL::InterpolationOptions::ORIENTATION_STR[]="Orientation"; - -const char INTERP_KERNEL::InterpolationOptions::MEASURE_ABS_STR[]="MeasureAbs"; - -const char INTERP_KERNEL::InterpolationOptions::INTERSEC_TYPE_STR[]="IntersectionType"; - -const char INTERP_KERNEL::InterpolationOptions::SPLITTING_POLICY_STR[]="SplittingPolicy"; - -const char INTERP_KERNEL::InterpolationOptions::TRIANGULATION_INTERSECT2D_STR[]="Triangulation"; - -const char INTERP_KERNEL::InterpolationOptions::CONVEX_INTERSECT2D_STR[]="Convex"; - -const char INTERP_KERNEL::InterpolationOptions::GEOMETRIC_INTERSECT2D_STR[]="Geometric2D"; - -const char INTERP_KERNEL::InterpolationOptions::POINTLOCATOR_INTERSECT_STR[]="PointLocator"; - -const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_5_STR[]="PLANAR_FACE_5"; - -const char INTERP_KERNEL::InterpolationOptions::PLANAR_SPLIT_FACE_6_STR[]="PLANAR_FACE_6"; - -const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_24_STR[]="GENERAL_24"; - -const char INTERP_KERNEL::InterpolationOptions::GENERAL_SPLIT_48_STR[]="GENERAL_48"; - -bool INTERP_KERNEL::InterpolationOptions::setOptionDouble(const std::string& key, double value) -{ - if(key==PRECISION_STR) - { - setPrecision(value); - return true; - } - else if(key==MEDIANE_PLANE_STR) - { - setMedianPlane(value); - return true; - } - else if(key==BOUNDING_BOX_ADJ_STR) - { - setBoundingBoxAdjustment(value); - return true; - } - else if(key==BOUNDING_BOX_ADJ_ABS_STR) - { - setBoundingBoxAdjustmentAbs(value); - return true; - } - else if(key==MAX_DISTANCE_3DSURF_INSECT_STR) - { - setMaxDistance3DSurfIntersect(value); - return true; - } - else - return false; -} - -bool INTERP_KERNEL::InterpolationOptions::setOptionInt(const std::string& key, int value) -{ - if(key==PRINT_LEV_STR) - { - setPrintLevel(value); - return true; - } - else if(key==DO_ROTATE_STR) - { - setDoRotate(value != 0); - return true; - } - else if(key==ORIENTATION_STR) - { - setOrientation(value); - return true; - } - else if(key==MEASURE_ABS_STR) - { - bool valBool=(value!=0); - setMeasureAbsStatus(valBool); - return true; - } - else - return false; -} - -bool INTERP_KERNEL::InterpolationOptions::setOptionString(const std::string& key, const std::string& value) -{ - if(key==INTERSEC_TYPE_STR) - { - if(value==TRIANGULATION_INTERSECT2D_STR) - { - setIntersectionType(INTERP_KERNEL::Triangulation); - return true; - } - else if(value==CONVEX_INTERSECT2D_STR) - { - setIntersectionType(INTERP_KERNEL::Convex); - return true; - } - else if(value==GEOMETRIC_INTERSECT2D_STR) - { - setIntersectionType(INTERP_KERNEL::Geometric2D); - return true; - } - else if(value==POINTLOCATOR_INTERSECT_STR) - { - setIntersectionType(INTERP_KERNEL::PointLocator); - return true; - } - } - else if(key==SPLITTING_POLICY_STR) - { - if(value==PLANAR_SPLIT_FACE_5_STR) - { - setSplittingPolicy(INTERP_KERNEL::PLANAR_FACE_5); - return true; - } - else if(value==PLANAR_SPLIT_FACE_6_STR) - { - setSplittingPolicy(INTERP_KERNEL::PLANAR_FACE_6); - return true; - } - else if(value==GENERAL_SPLIT_24_STR) - { - setSplittingPolicy(INTERP_KERNEL::GENERAL_24); - return true; - } - else if(value==GENERAL_SPLIT_48_STR) - { - setSplittingPolicy(INTERP_KERNEL::GENERAL_48); - return true; - } - else - return false; - } - return false; -} - -std::string INTERP_KERNEL::InterpolationOptions::filterInterpolationMethod(const std::string& meth) const -{ - if ( _P1P0_bary_method && meth == "P1P0" ) - return "P1P0Bary"; - return meth; -} - -bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_level, - std::string intersection_type, - double precision, - double median_plane, - bool do_rotate, - double bounding_box_adjustment, - double bounding_box_adjustment_abs, - double max_distance_for_3Dsurf_intersect, - long orientation, - bool measure_abs, - std::string splitting_policy, - bool P1P0_bary_method ) -{ - _print_level=print_level; - _precision=precision; - _median_plane=median_plane; - _do_rotate=do_rotate; - _bounding_box_adjustment=bounding_box_adjustment; - _bounding_box_adjustment_abs=bounding_box_adjustment_abs; - _max_distance_for_3Dsurf_intersect=max_distance_for_3Dsurf_intersect; - _orientation=orientation; - _measure_abs=measure_abs; - _P1P0_bary_method=P1P0_bary_method; - return(setOptionString(INTERSEC_TYPE_STR,intersection_type) && setOptionString(SPLITTING_POLICY_STR,splitting_policy)); -} - diff --git a/src/INTERP_KERNEL/InterpolationOptions.hxx b/src/INTERP_KERNEL/InterpolationOptions.hxx deleted file mode 100644 index 667e320b6..000000000 --- a/src/INTERP_KERNEL/InterpolationOptions.hxx +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATIONOPTIONS_HXX__ -#define __INTERPOLATIONOPTIONS_HXX__ - -#include "INTERPKERNELDefines.hxx" - -#include - -namespace INTERP_KERNEL -{ - typedef enum { Triangulation, Convex, Geometric2D, PointLocator } IntersectionType; - /// Type describing the different ways in which the hexahedron can be split into tetrahedra. - /// The PLANAR_* policies persume that each face is to be considered planar, while the general - /// policies make no such hypothesis. The integer at the end gives the number of tetrahedra - /// that result from the split. - typedef enum { PLANAR_FACE_5 = 5, PLANAR_FACE_6 = 6, GENERAL_24 = 24, GENERAL_48 = 48 } SplittingPolicy; - - class INTERPKERNEL_EXPORT InterpolationOptions - { - private: - int _print_level ; - IntersectionType _intersection_type; - double _precision; - double _median_plane ; - bool _do_rotate ; - //! this measure is relative to the caracteristic dimension - double _bounding_box_adjustment ; - //! this measure is absolute \b not relative to the cell size - double _bounding_box_adjustment_abs ; - double _max_distance_for_3Dsurf_intersect; - int _orientation ; - bool _measure_abs; - SplittingPolicy _splitting_policy ; - bool _P1P0_bary_method; // issue 0020440 - - public: - InterpolationOptions() { init(); } - int getPrintLevel() const { return _print_level; } - void setPrintLevel(int pl) { _print_level=pl; } - - IntersectionType getIntersectionType() const { return _intersection_type; } - void setIntersectionType(IntersectionType it) { _intersection_type=it; } - - double getPrecision() const { return _precision; } - void setPrecision(double p) { _precision=p; } - - double getMedianPlane() const { return _median_plane; } - void setMedianPlane(double mp) { _median_plane=mp; } - - bool getDoRotate() const { return _do_rotate; } - void setDoRotate( bool dr) { _do_rotate = dr; } - - double getBoundingBoxAdjustment() const { return _bounding_box_adjustment; } - void setBoundingBoxAdjustment(double bba) { _bounding_box_adjustment=bba; } - - double getBoundingBoxAdjustmentAbs() const { return _bounding_box_adjustment_abs; } - void setBoundingBoxAdjustmentAbs(double bba) { _bounding_box_adjustment_abs=bba; } - - double getMaxDistance3DSurfIntersect() const { return _max_distance_for_3Dsurf_intersect; } - void setMaxDistance3DSurfIntersect(double bba) { _max_distance_for_3Dsurf_intersect=bba; } - - int getOrientation() const { return _orientation; } - void setOrientation(int o) { _orientation=o; } - - bool getMeasureAbsStatus() const { return _measure_abs; } - void setMeasureAbsStatus(bool newStatus) { _measure_abs=newStatus; } - - SplittingPolicy getSplittingPolicy() const { return _splitting_policy; } - void setSplittingPolicy(SplittingPolicy sp) { _splitting_policy=sp; } - - void setP1P0BaryMethod(bool isP1P0) { _P1P0_bary_method=isP1P0; } - bool getP1P0BaryMethod() const { return _P1P0_bary_method; } - - std::string filterInterpolationMethod(const std::string& meth) const; - - void init() - { - _print_level=0; - _intersection_type=Triangulation; - _precision=1e-12; - _median_plane=DFT_MEDIAN_PLANE; - _do_rotate=true; - _bounding_box_adjustment=DFT_SURF3D_ADJ_EPS; - _bounding_box_adjustment_abs=0.; - _max_distance_for_3Dsurf_intersect=DFT_MAX_DIST_3DSURF_INTERSECT; - _orientation=0; - _measure_abs=true; - _splitting_policy=GENERAL_48; - _P1P0_bary_method=false; - } - bool setInterpolationOptions(long print_level, - std::string intersection_type, - double precision, - double median_plane, - bool do_rotate, - double bounding_box_adjustment, - double bounding_box_adjustment_abs, - double max_distance_for_3Dsurf_intersect, - long orientation, - bool measure_abs, - std::string splitting_policy, - bool P1P0_bary_method ); - void copyOptions(const InterpolationOptions & other) { *this = other; } - bool setOptionDouble(const std::string& key, double value); - bool setOptionInt(const std::string& key, int value); - bool setOptionString(const std::string& key, const std::string& value); - private: - static const double DFT_MEDIAN_PLANE; - static const double DFT_SURF3D_ADJ_EPS; - static const double DFT_MAX_DIST_3DSURF_INTERSECT; - public: - static const char PRECISION_STR[]; - static const char MEDIANE_PLANE_STR[]; - static const char BOUNDING_BOX_ADJ_STR[]; - static const char BOUNDING_BOX_ADJ_ABS_STR[]; - static const char MAX_DISTANCE_3DSURF_INSECT_STR[]; - static const char PRINT_LEV_STR[]; - static const char DO_ROTATE_STR[]; - static const char ORIENTATION_STR[]; - static const char MEASURE_ABS_STR[]; - static const char INTERSEC_TYPE_STR[]; - static const char SPLITTING_POLICY_STR[]; - static const char TRIANGULATION_INTERSECT2D_STR[]; - static const char CONVEX_INTERSECT2D_STR[]; - static const char GEOMETRIC_INTERSECT2D_STR[]; - static const char POINTLOCATOR_INTERSECT_STR[]; - static const char PLANAR_SPLIT_FACE_5_STR[]; - static const char PLANAR_SPLIT_FACE_6_STR[]; - static const char GENERAL_SPLIT_24_STR[]; - static const char GENERAL_SPLIT_48_STR[]; - }; - -} -#endif diff --git a/src/INTERP_KERNEL/InterpolationPlanar.hxx b/src/INTERP_KERNEL/InterpolationPlanar.hxx deleted file mode 100755 index 2e54eabe4..000000000 --- a/src/INTERP_KERNEL/InterpolationPlanar.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATIONPLANAR_HXX__ -#define __INTERPOLATIONPLANAR_HXX__ - -#include "Interpolation.hxx" -#include "PlanarIntersector.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpolationOptions.hxx" - -namespace INTERP_KERNEL -{ - template - class InterpolationPlanar : public Interpolation< InterpolationPlanar > - { - private: - double _dim_caracteristic; - public: - InterpolationPlanar(); - InterpolationPlanar(const InterpolationOptions & io); - - // geometric precision, debug print level, coice of the median plane, intersection etc ... - void setOptions(double precision, int printLevel, - IntersectionType intersectionType, int orientation=0); - - // Main function to interpolate triangular and quadratic meshes - template - int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result, const char *method); - public: - bool doRotate() const { return asLeafInterpPlanar().doRotate(); } - double medianPlane() const { return asLeafInterpPlanar().medianPlane(); } - template - void performAdjustmentOfBB(PlanarIntersector* intersector, std::vector& bbox) const - { return asLeafInterpPlanar().performAdjustmentOfBB(intersector,bbox); } - protected: - RealPlanar& asLeafInterpPlanar() { return static_cast(*this); } - const RealPlanar& asLeafInterpPlanar() const { return static_cast< const RealPlanar& >(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationPlanar.txx b/src/INTERP_KERNEL/InterpolationPlanar.txx deleted file mode 100644 index b41ec15a7..000000000 --- a/src/INTERP_KERNEL/InterpolationPlanar.txx +++ /dev/null @@ -1,392 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATIONPLANAR_TXX__ -#define __INTERPOLATIONPLANAR_TXX__ - -#include "InterpolationPlanar.hxx" -#include "Interpolation.txx" -#include "InterpolationOptions.hxx" -#include "PlanarIntersector.hxx" -#include "PlanarIntersector.txx" -#include "TriangulationIntersector.hxx" -#include "TriangulationIntersector.txx" -#include "ConvexIntersector.hxx" -#include "ConvexIntersector.txx" -#include "Geometric2DIntersector.hxx" -#include "Geometric2DIntersector.txx" -#include "PointLocator2DIntersector.hxx" -#include "PointLocator2DIntersector.txx" -#include "PlanarIntersectorP0P1PL.hxx" -#include "PlanarIntersectorP0P1PL.txx" -#include "PlanarIntersectorP1P0PL.hxx" -#include "PlanarIntersectorP1P0PL.txx" -#include "PlanarIntersectorP1P1PL.hxx" -#include "PlanarIntersectorP1P1PL.txx" -#include "VectorUtils.hxx" -#include "BBTree.txx" - -#include -#include - -namespace INTERP_KERNEL -{ - /** - * \defgroup interpolationPlanar InterpolationPlanar - * - * \class InterpolationPlanar - * \brief Class used to compute the coefficients of the interpolation matrix between - * two local meshes in two dimensions. Meshes can contain mixed triangular and quadrangular elements. - */ - template - InterpolationPlanar::InterpolationPlanar():_dim_caracteristic(1) - - { - } - - template - InterpolationPlanar::InterpolationPlanar(const InterpolationOptions& io):Interpolation< InterpolationPlanar >(io),_dim_caracteristic(1) - - { - } - - /** - * \brief Function used to set the options for the intersection calculation - * \details The following options can be modified: - * -# Intersection_type: the type of algorithm to be used in the computation of the cell-cell intersections. - * - Values: Triangle, Convex. - * - Default: Triangle. - * -# Precision: Level of precision of the computations is precision times the characteristic size of the mesh. - * - Values: positive real number. - * - Default: 1.0E-12. - * -# PrintLevel: Level of verboseness during the computations. - * - Values: interger between 0 and 3. - * - Default: 0. - */ - template - void InterpolationPlanar::setOptions(double precision, int printLevel, IntersectionType intersectionType, int orientation) - { - InterpolationOptions::setPrecision(precision); - InterpolationOptions::setPrintLevel(printLevel); - InterpolationOptions::setIntersectionType(intersectionType); - InterpolationOptions::setOrientation(orientation); - } - - - /** \brief Main function to interpolate triangular or quadrangular meshes. - \details The algorithm proceeds in two steps: first a filtering process reduces the number of pairs of elements for which the - * calculation must be carried out by eliminating pairs that do not intersect based on their bounding boxes. Then, the - * volume of intersection is calculated by an object of type IntersectorPlanar for the remaining pairs, and entered into the - * intersection matrix. - * - * The matrix is partially sparse : it is a vector of maps of integer - double pairs. - * The length of the vector is equal to the number of target elements - for each target element there is a map, regardless - * of whether the element intersects any source elements or not. But in the maps there are only entries for those source elements - * which have a non-zero intersection volume with the target element. The vector has indices running from - * 0 to (#target elements - 1), meaning that the map for target element i is stored at index i - 1. In the maps, however, - * the indexing is more natural : the intersection volume of the target element i with source element j is found at matrix[i-1][j]. - * - - * @param myMeshS Planar source mesh - * @Param myMeshT Planar target mesh - * @return vector containing for each element i of the source mesh, a map giving for each element j - * of the target mesh which i intersects, the area of the intersection - * - */ - template - template - int InterpolationPlanar::interpolateMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, MatrixType& result, const char *method) - { - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - - long global_start =clock(); - int counter=0; - /***********************************************************/ - /* Check both meshes are made of triangles and quadrangles */ - /***********************************************************/ - - long nbMailleS=myMeshS.getNumberOfElements(); - long nbMailleT=myMeshT.getNumberOfElements(); - - /**************************************************/ - /* Search the characteristic size of the meshes */ - /**************************************************/ - - double BoxS[2*SPACEDIM]; myMeshS.getBoundingBox(BoxS); - double BoxT[2*SPACEDIM]; myMeshT.getBoundingBox(BoxT); - double diagonalS,dimCaracteristicS=std::numeric_limits::max(); - if(nbMailleS!=0) - { - diagonalS=getDistanceBtw2Pts(BoxS+SPACEDIM,BoxS); - dimCaracteristicS=diagonalS/nbMailleS; - } - double diagonalT,dimCaracteristicT=std::numeric_limits::max(); - if(nbMailleT!=0) - { - diagonalT=getDistanceBtw2Pts(BoxT+SPACEDIM,BoxT); - dimCaracteristicT=diagonalT/nbMailleT; - } - - _dim_caracteristic=std::min(dimCaracteristicS, dimCaracteristicT); - if (InterpolationOptions::getPrintLevel()>=1) - { - std::cout << " - Characteristic size of the source mesh : " << dimCaracteristicS << std::endl; - std::cout << " - Characteristic size of the target mesh: " << dimCaracteristicT << std::endl; - std::cout << "InterpolationPlanar::computation of the intersections" << std::endl; - } - - PlanarIntersector* intersector=0; - std::string meth = InterpolationOptions::filterInterpolationMethod(method); - if(meth=="P0P0") - { - switch (InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new TriangulationIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Convex: - intersector=new ConvexIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getDoRotate(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Geometric2D: - intersector=new Geometric2DIntersector(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - case PointLocator: - intersector=new PointLocator2DIntersector(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - } - } - else if(meth=="P0P1") - { - switch (InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new TriangulationIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Convex: - intersector=new ConvexIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getDoRotate(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Geometric2D: - intersector=new Geometric2DIntersector(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - case PointLocator: - intersector=new PlanarIntersectorP0P1PL(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - } - } - else if(meth=="P1P0") - { - switch (InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new TriangulationIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Convex: - intersector=new ConvexIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getDoRotate(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Geometric2D: - intersector=new Geometric2DIntersector(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - case PointLocator: - intersector=new PlanarIntersectorP1P0PL(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - } - } - else if(meth=="P1P0Bary") - { - switch (InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new TriangulationIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Convex: - intersector=new ConvexIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getDoRotate(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Geometric2D: - intersector=new Geometric2DIntersector(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - case PointLocator: - throw INTERP_KERNEL::Exception("Invalid intersector (PointLocator) for P1P0Bary !"); - break; - } - } - else if(meth=="P1P1") - { - switch (InterpolationOptions::getIntersectionType()) - { - case Triangulation: - intersector=new TriangulationIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Convex: - intersector=new ConvexIntersector(myMeshT,myMeshS,_dim_caracteristic, - InterpolationOptions::getPrecision(), - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getDoRotate(), - InterpolationOptions::getOrientation(), - InterpolationOptions::getPrintLevel()); - break; - case Geometric2D: - intersector=new Geometric2DIntersector(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - case PointLocator: - intersector=new PlanarIntersectorP1P1PL(myMeshT, myMeshS, _dim_caracteristic, - InterpolationOptions::getMaxDistance3DSurfIntersect(), - InterpolationOptions::getMedianPlane(), - InterpolationOptions::getPrecision(), - InterpolationOptions::getOrientation()); - break; - } - } - else - throw INTERP_KERNEL::Exception("Invalid method specified or intersection type ! Must be in : \"P0P0\" \"P0P1\" \"P1P0\" or \"P1P1\""); - /****************************************************************/ - /* Create a search tree based on the bounding boxes */ - /* Instanciate the intersector and initialise the result vector */ - /****************************************************************/ - - long start_filtering=clock(); - - std::vector bbox; - intersector->createBoundingBoxes(myMeshS,bbox); // create the bounding boxes - performAdjustmentOfBB(intersector,bbox); - const double *bboxPtr=0; - if(nbMailleS>0) - bboxPtr=&bbox[0]; - BBTree my_tree(bboxPtr, 0, 0,nbMailleS);//creating the search structure - - long end_filtering=clock(); - - result.resize(intersector->getNumberOfRowsOfResMatrix());//on initialise. - - /****************************************************/ - /* Loop on the target cells - core of the algorithm */ - /****************************************************/ - long start_intersection=clock(); - long nbelem_type=myMeshT.getNumberOfElements(); - const ConnType *connIndxT=myMeshT.getConnectivityIndexPtr(); - for(int iT=0; iT intersecting_elems; - double bb[2*SPACEDIM]; - intersector->getElemBB(bb,myMeshT,OTT::indFC(iT),nb_nodesT); - my_tree.getIntersectingElems(bb, intersecting_elems); - intersector->intersectCells(iT,intersecting_elems,result); - counter+=intersecting_elems.size(); - intersecting_elems.clear(); - } - int ret=intersector->getNumberOfColsOfResMatrix(); - delete intersector; - - if (InterpolationOptions::getPrintLevel() >=1) - { - long end_intersection=clock(); - std::cout << "Filtering time= " << end_filtering-start_filtering << std::endl; - std::cout << "Intersection time= " << end_intersection-start_intersection << std::endl; - long global_end =clock(); - std::cout << "Number of computed intersections = " << counter << std::endl; - std::cout << "Global time= " << global_end - global_start << std::endl; - } - return ret; - } -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationUtils.hxx b/src/INTERP_KERNEL/InterpolationUtils.hxx deleted file mode 100644 index e96f3fc1b..000000000 --- a/src/INTERP_KERNEL/InterpolationUtils.hxx +++ /dev/null @@ -1,923 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPOLATIONUTILS_HXX__ -#define __INTERPOLATIONUTILS_HXX__ - -#include "INTERPKERNELDefines.hxx" -#include "InterpKernelException.hxx" - -#include "NormalizedUnstructuredMesh.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - template - class OTT//OffsetToolTrait - { - }; - - template - class OTT - { - public: - static ConnType indFC(ConnType i) { return i; } - static ConnType ind2C(ConnType i) { return i; } - static ConnType conn2C(ConnType i) { return i; } - static ConnType coo2C(ConnType i) { return i; } - }; - - template - class OTT - { - public: - static ConnType indFC(ConnType i) { return i+1; } - static ConnType ind2C(ConnType i) { return i-1; } - static ConnType conn2C(ConnType i) { return i-1; } - static ConnType coo2C(ConnType i) { return i-1; } - }; - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* calcul la surface d'un triangle */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - - inline double Surf_Tri(const double* P_1,const double* P_2,const double* P_3) - { - double A=(P_3[1]-P_1[1])*(P_2[0]-P_1[0])-(P_2[1]-P_1[1])*(P_3[0]-P_1[0]); - double Surface = 0.5*fabs(A); - return Surface; - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* fonction qui calcul le déterminant */ - /* de deux vecteur(cf doc CGAL). */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - - //fonction qui calcul le déterminant des vecteurs: P3P1 et P3P2 - //(cf doc CGAL). - - inline double mon_determinant(const double* P_1, - const double* P_2, - const double* P_3) - { - double mon_det=(P_1[0]-P_3[0])*(P_2[1]-P_3[1])-(P_2[0]-P_3[0])*(P_1[1]-P_3[1]); - return mon_det; - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - //calcul la norme du vecteur P1P2 - - inline double norme_vecteur(const double* P_1,const double* P_2) - { - double X=P_1[0]-P_2[0]; - double Y=P_1[1]-P_2[1]; - double norme=sqrt(X*X+Y*Y); - return norme; - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* calcul le cos et le sin de l'angle P1P2,P1P3 */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - - inline std::vector calcul_cos_et_sin(const double* P_1, - const double* P_2, - const double* P_3) - { - - std::vector Vect; - double P1_P2=norme_vecteur(P_1,P_2); - double P2_P3=norme_vecteur(P_2,P_3); - double P3_P1=norme_vecteur(P_3,P_1); - - double N=P1_P2*P1_P2+P3_P1*P3_P1-P2_P3*P2_P3; - double D=2.0*P1_P2*P3_P1; - double COS=N/D; - if (COS>1.0) COS=1.0; - if (COS<-1.0) COS=-1.0; - Vect.push_back(COS); - double V=mon_determinant(P_2,P_3,P_1); - double D_1=P1_P2*P3_P1; - double SIN=V/D_1; - if (SIN>1.0) SIN=1.0; - if (SIN<-1.0) SIN=-1.0; - Vect.push_back(SIN); - - return Vect; - - } - - /*! - * This method builds a quadrangle built with the first point of 'triIn' the barycenter of two edges starting or ending with - * the first point of 'triIn' and the barycenter of 'triIn'. - * - * @param triIn is a 6 doubles array in full interlace mode, that represents a triangle. - * @param quadOut is a 8 doubles array filled after the following call. - */ - template - inline void fillDualCellOfTri(const double *triIn, double *quadOut) - { - //1st point - std::copy(triIn,triIn+SPACEDIM,quadOut); - double tmp[SPACEDIM]; - std::transform(triIn,triIn+SPACEDIM,triIn+SPACEDIM,tmp,std::plus()); - //2nd point - std::transform(tmp,tmp+SPACEDIM,quadOut+SPACEDIM,std::bind2nd(std::multiplies(),0.5)); - std::transform(tmp,tmp+SPACEDIM,triIn+2*SPACEDIM,tmp,std::plus()); - //3rd point - std::transform(tmp,tmp+SPACEDIM,quadOut+2*SPACEDIM,std::bind2nd(std::multiplies(),1/3.)); - //4th point - std::transform(triIn,triIn+SPACEDIM,triIn+2*SPACEDIM,tmp,std::plus()); - std::transform(tmp,tmp+SPACEDIM,quadOut+3*SPACEDIM,std::bind2nd(std::multiplies(),0.5)); - } - - /*! - * This method builds a potentially non-convex polygon cell built with the first point of 'triIn' the barycenter of two edges starting or ending with - * the first point of 'triIn' and the barycenter of 'triIn'. - * - * @param triIn is a 6 doubles array in full interlace mode, that represents a triangle. - * @param quadOut is a 8 doubles array filled after the following call. - */ - template - inline void fillDualCellOfPolyg(const double *polygIn, int nPtsPolygonIn, double *polygOut) - { - //1st point - std::copy(polygIn,polygIn+SPACEDIM,polygOut); - std::transform(polygIn,polygIn+SPACEDIM,polygIn+SPACEDIM,polygOut+SPACEDIM,std::plus()); - //2nd point - std::transform(polygOut+SPACEDIM,polygOut+2*SPACEDIM,polygOut+SPACEDIM,std::bind2nd(std::multiplies(),0.5)); - double tmp[SPACEDIM]; - // - for(int i=0;i()); - std::transform(tmp,tmp+SPACEDIM,polygOut+(2*i+3)*SPACEDIM,std::bind2nd(std::multiplies(),0.5)); - std::transform(polygIn+(i+1)*SPACEDIM,polygIn+(i+2)*SPACEDIM,tmp,tmp,std::plus()); - std::transform(tmp,tmp+SPACEDIM,polygOut+(2*i+2)*SPACEDIM,std::bind2nd(std::multiplies(),1./3.)); - } - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* calcul les coordonnées du barycentre d'un polygone */ - /* le vecteur en entrée est constitué des coordonnées */ - /* des sommets du polygone */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - - inline std::vector bary_poly(const std::vector& V) - { - std::vector Bary; - long taille=V.size(); - double x=0; - double y=0; - - for(long i=0;i - bool solveSystemOfEquations(double M[nbRow][nbRow+1], double* sol) - { - const int nbCol=nbRow+1; - - // make upper triangular matrix (forward elimination) - - int iR[nbRow];// = { 0, 1, 2 }; - for ( int i = 0; i < (int) nbRow; ++i ) iR[i] = i; - - for ( int i = 0; i < (int)(nbRow-1); ++i ) // nullify nbRow-1 rows - { - // swap rows to have max value of i-th column in i-th row - double max = std::fabs( M[ iR[i] ][i] ); - for ( int r = i+1; r < (int)nbRow; ++r ) { - double m = std::fabs( M[ iR[r] ][i] ); - if ( m > max ) { - max = m; - std::swap( iR[r], iR[i] ); - } - } - if ( max < std::numeric_limits::min() ) { - //sol[0]=1; sol[1]=sol[2]=sol[3]=0; - return false; // no solution - } - // make 0 below M[i][i] (actually we do not modify i-th column) - double* tUpRow = M[ iR[i] ]; - for ( int r = i+1; r < (int)nbRow; ++r ) { - double* mRow = M[ iR[r] ]; - double coef = mRow[ i ] / tUpRow[ i ]; - for ( int c = i+1; c < nbCol; ++c ) - mRow[ c ] -= tUpRow[ c ] * coef; - } - } - double* mRow = M[ iR[nbRow-1] ]; - if ( std::fabs( mRow[ nbRow-1 ] ) < std::numeric_limits::min() ) { - //sol[0]=1; sol[1]=sol[2]=sol[3]=0; - return false; // no solution - } - mRow[ nbRow ] /= mRow[ nbRow-1 ]; - - // calculate solution (back substitution) - - sol[ nbRow-1 ] = mRow[ nbRow ]; - - for ( int i = nbRow-2; i+1; --i ) - { - mRow = M[ iR[i] ]; - sol[ i ] = mRow[ nbRow ]; - for ( int j = nbRow-1; j > i; --j ) - sol[ i ] -= sol[j]*mRow[ j ]; - sol[ i ] /= mRow[ i ]; - } - - return true; - } - - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* Calculate barycentric coordinates of a 2D point p */ - /* with respect to the triangle verices. */ - /* triaCoords are in full interlace */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - - template - inline void barycentric_coords(const double* triaCoords, const double* p, double* bc) - { - // matrix 2x2 - double - T11 = triaCoords[0]-triaCoords[2*SPACEDIM], T12 = triaCoords[SPACEDIM]-triaCoords[2*SPACEDIM], - T21 = triaCoords[1]-triaCoords[2*SPACEDIM+1], T22 = triaCoords[SPACEDIM+1]-triaCoords[2*SPACEDIM+1]; - // matrix determinant - double Tdet = T11*T22 - T12*T21; - if ( fabs( Tdet ) < std::numeric_limits::min() ) { - bc[0]=1; bc[1]=0; bc[2]=0; - return; - } - // matrix inverse - double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11; - // vector - double r11 = p[0]-triaCoords[2*SPACEDIM], r12 = p[1]-triaCoords[2*SPACEDIM+1]; - // barycentric coordinates: mutiply matrix by vector - bc[0] = (t11 * r11 + t12 * r12)/Tdet; - bc[1] = (t21 * r11 + t22 * r12)/Tdet; - bc[2] = 1. - bc[0] - bc[1]; - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* Calculate barycentric coordinates of a point p */ - /* with respect to triangle or tetra verices. */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - - inline void barycentric_coords(const std::vector& n, const double* p, double* bc) - { - enum { _X, _Y, _Z }; - if ( n.size() == 3 ) // TRIA3 - { - // matrix 2x2 - double - T11 = n[0][_X]-n[2][_X], T12 = n[1][_X]-n[2][_X], - T21 = n[0][_Y]-n[2][_Y], T22 = n[1][_Y]-n[2][_Y]; - // matrix determinant - double Tdet = T11*T22 - T12*T21; - if ( std::fabs( Tdet ) < std::numeric_limits::min() ) { - bc[0]=1; bc[1]=bc[2]=0; // no solution - return; - } - // matrix inverse - double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11; - // vector - double r11 = p[_X]-n[2][_X], r12 = p[_Y]-n[2][_Y]; - // barycentric coordinates: mutiply matrix by vector - bc[0] = (t11 * r11 + t12 * r12)/Tdet; - bc[1] = (t21 * r11 + t22 * r12)/Tdet; - bc[2] = 1. - bc[0] - bc[1]; - } - else // TETRA4 - { - // Find bc by solving system of 3 equations using Gaussian elimination algorithm - // bc1*( x1 - x4 ) + bc2*( x2 - x4 ) + bc3*( x3 - x4 ) = px - x4 - // bc1*( y1 - y4 ) + bc2*( y2 - y4 ) + bc3*( y3 - y4 ) = px - y4 - // bc1*( z1 - z4 ) + bc2*( z2 - z4 ) + bc3*( z3 - z4 ) = px - z4 - - double T[3][4]= - {{ n[0][_X]-n[3][_X], n[1][_X]-n[3][_X], n[2][_X]-n[3][_X], p[_X]-n[3][_X] }, - { n[0][_Y]-n[3][_Y], n[1][_Y]-n[3][_Y], n[2][_Y]-n[3][_Y], p[_Y]-n[3][_Y] }, - { n[0][_Z]-n[3][_Z], n[1][_Z]-n[3][_Z], n[2][_Z]-n[3][_Z], p[_Z]-n[3][_Z] }}; - - if ( !solveSystemOfEquations<3>( T, bc )) - bc[0]=1., bc[1] = bc[2] = bc[3] = 0; - else - bc[ 3 ] = 1. - bc[0] - bc[1] - bc[2]; - } - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* calcul la surface d'un polygone. */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - - inline double Surf_Poly(const std::vector& Poly) - { - - double Surface=0; - for(unsigned long i=0; i<(Poly.size())/2-2; i++) - { - double Surf=Surf_Tri( &Poly[0],&Poly[2*(i+1)],&Poly[2*(i+2)] ); - Surface=Surface + Surf ; - } - return Surface ; - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* fonction qui teste si un point est dans une maille */ - /* point: P_0 */ - /* P_1, P_2, P_3 sommet des mailles */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - - inline bool point_dans_triangle(const double* P_0,const double* P_1, - const double* P_2,const double* P_3, - double eps) - { - - bool A=false; - double det_1=mon_determinant(P_1,P_3,P_0); - double det_2=mon_determinant(P_3,P_2,P_0); - double det_3=mon_determinant(P_2,P_1,P_0); - if( (det_1>=-eps && det_2>=-eps && det_3>=-eps) || (det_1<=eps && det_2<=eps && det_3<=eps) ) - { - A=true; - } - - return A; - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /*fonction pour vérifier qu'un point n'a pas déja été considérer dans */ - /* le vecteur et le rajouter au vecteur sinon. */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - - inline void verif_point_dans_vect(const double* P, std::vector& V, double absolute_precision ) - { - long taille=V.size(); - bool isPresent=false; - for(long i=0;i& V, double dim_caracteristic, double precision) - { - - double absolute_precision = precision*dim_caracteristic; - bool A_1=INTERP_KERNEL::point_dans_triangle(P_1,P_4,P_5,P_6,absolute_precision); - if(A_1) - verif_point_dans_vect(P_1,V,absolute_precision); - bool A_2=INTERP_KERNEL::point_dans_triangle(P_2,P_4,P_5,P_6,absolute_precision); - if(A_2) - verif_point_dans_vect(P_2,V,absolute_precision); - bool A_3=INTERP_KERNEL::point_dans_triangle(P_3,P_4,P_5,P_6,absolute_precision); - if(A_3) - verif_point_dans_vect(P_3,V,absolute_precision); - } - - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* calcul de l'intersection de deux segments: segments P1P2 avec P3P4 */ - /* . Si l'intersection est non nulle et si celle-ci n'est */ - /* n'est pas déjà contenue dans Vect on la rajoute à Vect */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - - inline void inters_de_segment(const double * P_1,const double * P_2, - const double * P_3,const double * P_4, - std::vector& Vect, - double dim_caracteristic, double precision) - { - // calcul du déterminant de P_1P_2 et P_3P_4. - double det=(P_2[0]-P_1[0])*(P_4[1]-P_3[1])-(P_4[0]-P_3[0])*(P_2[1]-P_1[1]); - - double absolute_precision = dim_caracteristic*precision; - if(fabs(det)>absolute_precision) - { - double k_1=-((P_3[1]-P_4[1])*(P_3[0]-P_1[0])+(P_4[0]-P_3[0])*(P_3[1]-P_1[1]))/det; - - if (k_1 >= -absolute_precision && k_1 <= 1+absolute_precision) - //if( k_1 >= -precision && k_1 <= 1+precision) - { - double k_2= ((P_1[1]-P_2[1])*(P_1[0]-P_3[0])+(P_2[0]-P_1[0])*(P_1[1]-P_3[1]))/det; - - if (k_2 >= -absolute_precision && k_2 <= 1+absolute_precision) - //if( k_2 >= -precision && k_2 <= 1+precision) - { - double P_0[2]; - P_0[0]=P_1[0]+k_1*(P_2[0]-P_1[0]); - P_0[1]=P_1[1]+k_1*(P_2[1]-P_1[1]); - verif_point_dans_vect(P_0,Vect,absolute_precision); - } - } - } - } - - - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* calcul l'intersection de deux triangles */ - /* P_1, P_2, P_3: sommets du premier triangle */ - /* P_4, P_5, P_6: sommets du deuxième triangle */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - - inline void intersec_de_triangle(const double* P_1,const double* P_2, const double* P_3, - const double* P_4,const double* P_5,const double* P_6, - std::vector& Vect, double dim_caracteristic, double precision) - { - inters_de_segment(P_1,P_2,P_4,P_5,Vect, dim_caracteristic, precision); - inters_de_segment(P_1,P_2,P_5,P_6,Vect, dim_caracteristic, precision); - inters_de_segment(P_1,P_2,P_6,P_4,Vect, dim_caracteristic, precision); - inters_de_segment(P_2,P_3,P_4,P_5,Vect, dim_caracteristic, precision); - inters_de_segment(P_2,P_3,P_5,P_6,Vect, dim_caracteristic, precision); - inters_de_segment(P_2,P_3,P_6,P_4,Vect, dim_caracteristic, precision); - inters_de_segment(P_3,P_1,P_4,P_5,Vect, dim_caracteristic, precision); - inters_de_segment(P_3,P_1,P_5,P_6,Vect, dim_caracteristic, precision); - inters_de_segment(P_3,P_1,P_6,P_4,Vect, dim_caracteristic, precision); - rajou_sommet_triangl(P_1,P_2,P_3,P_4,P_5,P_6,Vect, dim_caracteristic, precision); - rajou_sommet_triangl(P_4,P_5,P_6,P_1,P_2,P_3,Vect, dim_caracteristic, precision); - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* fonction pour vérifier qu'un n°de maille n'a pas déja été considérer */ - /* dans le vecteur et le rajouter au vecteur sinon. */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - - inline void verif_maill_dans_vect(int Num, std::vector& V) - { - long taille=V.size(); - int A=0; - for(long i=0;itheta1, std::pair theta2) - { - double norm1 = sqrt(theta1.first*theta1.first +theta1.second*theta1.second); - double norm2 = sqrt(theta2.first*theta2.first +theta2.second*theta2.second); - - double epsilon = 1.e-12; - - if( norm1 < epsilon || norm2 < epsilon ) - std::cout << "Warning InterpolationUtils.hxx: AngleLess : Vector with zero norm, cannot define the angle !!!! " << std::endl; - - return theta1.second*(norm2 + theta2.first) < theta2.second*(norm1 + theta1.first); - - } - }; - - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* fonction pour reconstituer un polygone convexe à partir */ - /* d'un nuage de point. */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - - inline std::vector reconstruct_polygon(const std::vector& V) - { - - int taille=V.size(); - - //VB : why 6 ? - - if(taille<=6) - {return V;} - else - { - double *COS=new double[taille/2]; - double *SIN=new double[taille/2]; - //double *angle=new double[taille/2]; - std::vector Bary=bary_poly(V); - COS[0]=1.0; - SIN[0]=0.0; - //angle[0]=0.0; - for(int i=0; i Trigo=calcul_cos_et_sin(&Bary[0],&V[0],&V[2*(i+1)]); - COS[i+1]=Trigo[0]; - SIN[i+1]=Trigo[1]; - //if(SIN[i+1]>=0) - // {angle[i+1]=atan2(SIN[i+1],COS[i+1]);} - // else - // {angle[i+1]=-atan2(SIN[i+1],COS[i+1]);} - } - - //ensuite on ordonne les angles. - std::vector Pt_ordonne; - Pt_ordonne.reserve(taille); - // std::multimap Ordre; - std::multimap,int, AngleLess> CosSin; - for(int i=0;i::iterator mi; - std::multimap,int, AngleLess>::iterator micossin; - // for(mi=Ordre.begin();mi!=Ordre.end();mi++) - // { - // int j=(*mi).second; - // Pt_ordonne.push_back(V[2*j]); - // Pt_ordonne.push_back(V[2*j+1]); - // } - for(micossin=CosSin.begin();micossin!=CosSin.end();micossin++) - { - int j=(*micossin).second; - Pt_ordonne.push_back(V[2*j]); - Pt_ordonne.push_back(V[2*j+1]); - } - delete [] COS; - delete [] SIN; - // delete [] angle; - return Pt_ordonne; - } - } - - template - inline void getElemBB(double* bb, const double *coordsOfMesh, int iP, int nb_nodes) - { - bb[0]=std::numeric_limits::max(); - bb[1]=-std::numeric_limits::max(); - bb[2]=std::numeric_limits::max(); - bb[3]=-std::numeric_limits::max(); - bb[4]=std::numeric_limits::max(); - bb[5]=-std::numeric_limits::max(); - - for (int i=0; ibb[1])?x:bb[1]; - bb[2]=(ybb[3])?y:bb[3]; - bb[4]=(zbb[5])?z:bb[5]; - } - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* Computes the dot product of a and b */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - template - inline double dotprod( const double * a, const double * b) - { - double result=0; - for(int idim = 0; idim < dim ; idim++) result += a[idim]*b[idim]; - return result; - } - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* Computes the norm of vector v */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - template - inline double norm(const double * v) - { - double result =0; - for(int idim =0; idim - inline double distance2( const double * a, const double * b) - { - double result =0; - for(int idim =0; idim - inline double distance2( T * a, int inda, T * b, int indb) - { - double result =0; - for(int idim =0; idim inline void crossprod( const double * A, const double * B, const double * C, double * V); - - template<> inline - void crossprod<2>( const double * A, const double * B, const double * C, double * V) - { - double AB[2]; - double AC[2]; - for(int idim =0; idim<2; idim++) AB[idim] = B[idim]-A[idim];//B-A - for(int idim =0; idim<2; idim++) AC[idim] = C[idim]-A[idim];//C-A; - - V[0]=determinant(AB,AC); - V[1]=0; - } - template<> inline - void crossprod<3>( const double * A, const double * B, const double * C, double * V) - { - double AB[3]; - double AC[3]; - for(int idim =0; idim<3; idim++) AB[idim] = B[idim]-A[idim];//B-A - for(int idim =0; idim<3; idim++) AC[idim] = C[idim]-A[idim];//C-A; - - V[0]=AB[1]*AC[2]-AB[2]*AC[1]; - V[1]=-AB[0]*AC[2]+AB[2]*AC[0]; - V[2]=AB[0]*AC[1]-AB[1]*AC[0]; - } - template<> inline - void crossprod<1>( const double * A, const double * B, const double * C, double * V) - { - // just to be able to compile - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* Checks wether point A is inside the quadrangle BCDE */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - - template inline double check_inside(const double* A,const double* B,const double* C,const double* D, - const double* E,double* ABC, double* ADE) - { - crossprod(A,B,C,ABC); - crossprod(A,D,E,ADE); - return dotprod(ABC,ADE); - } - - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* Computes the geometric angle (in [0,Pi]) between two non zero vectors AB and AC */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - template inline double angle(const double * A, const double * B, const double * C, double * n) - { - double AB[dim]; - double AC[dim]; - double orthAB[dim]; - - for(int idim =0; idim(AB); - for(int idim =0; idim(AC); - double AB_dot_AC=dotprod(AB,AC); - for(int idim =0; idim(orthAB); - - return 2*atan2(numer,denom); - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* Tells whether the frame constituted of vectors AB, AC and n is direct */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - template inline double direct_frame(const double * A, const double * B, const double * C, double * n); - template<> inline - double direct_frame<2>(const double * A, const double * B, const double * C, double * n) - { - double AB[2]; - double AC[2]; - for(int idim =0; idim<2; idim++) AB[idim] = B[idim]-A[idim];//B-A; - for(int idim =0; idim<2; idim++) AC[idim] = C[idim]-A[idim];//C-A; - - return determinant(AB,AC)*n[0]; - } - template<> inline - double direct_frame<3>(const double * A, const double * B, const double * C, double * n) - { - double AB[3]; - double AC[3]; - for(int idim =0; idim<3; idim++) AB[idim] = B[idim]-A[idim];//B-A; - for(int idim =0; idim<3; idim++) AC[idim] = C[idim]-A[idim];//C-A; - - return determinant(AB,AC,n)>0; - } - - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* calcul l'intersection de deux polygones COPLANAIRES */ - /* en dimension DIM (2 ou 3). Si DIM=3 l'algorithme ne considère*/ - /* que les deux premières coordonnées de chaque point */ - /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - template inline void intersec_de_polygone(const double * Coords_A, const double * Coords_B, - int nb_NodesA, int nb_NodesB, - std::vector& inter, - double dim_caracteristic, double precision) - { - for(int i_A = 1; i_A3) inter=INTERP_KERNEL::reconstruct_polygon(inter); - } - - /*_ _ _ _ _ _ _ _ _ - *_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - * fonctions qui calcule l'aire d'un polygone en dimension 2 ou 3 - *_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - template inline double polygon_area(std::vector& inter) - { - double result=0.; - double area[DIM]; - - for(int i = 1; i<(int)inter.size()/DIM-1; i++) - { - INTERP_KERNEL::crossprod(&inter[0],&inter[DIM*i],&inter[DIM*(i+1)],area); - result +=0.5*norm(area); - } - return result; - } - - template inline double polygon_area(std::deque& inter) - { - double result=0.; - double area[DIM]; - - for(int i = 1; i<(int)inter.size()/DIM-1; i++) - { - INTERP_KERNEL::crossprod(&inter[0],&inter[DIM*i],&inter[DIM*(i+1)],area); - result +=0.5*norm(area); - } - return result; - } - - /*! Computes the triple product (XA^XB).XC (in 3D)*/ - inline double triple_product(const double* A, const double*B, const double*C, const double*X) - { - double XA[3]; - XA[0]=A[0]-X[0]; - XA[1]=A[1]-X[1]; - XA[2]=A[2]-X[2]; - double XB[3]; - XB[0]=B[0]-X[0]; - XB[1]=B[1]-X[1]; - XB[2]=B[2]-X[2]; - double XC[3]; - XC[0]=C[0]-X[0]; - XC[1]=C[1]-X[1]; - XC[2]=C[2]-X[2]; - - return - (XA[1]*XB[2]-XA[2]*XB[1])*XC[0]+ - (XA[2]*XB[0]-XA[0]*XB[2])*XC[1]+ - (XA[0]*XB[1]-XA[1]*XB[0])*XC[2]; - } - - /*! Subroutine of checkEqualPolygins that tests if two list of nodes (not necessarily distincts) describe the same polygon, assuming they share a comon point.*/ - /*! Indexes istart1 and istart2 designate two points P1 in L1 and P2 in L2 that have identical coordinates. Generally called with istart1=0.*/ - /*! Integer sign ( 1 or -1) indicate the direction used in going all over L2. */ - template - bool checkEqualPolygonsOneDirection(T * L1, T * L2, int size1, int size2, int istart1, int istart2, double epsilon, int sign) - { - int i1 = istart1; - int i2 = istart2; - int i1next = ( i1 + 1 ) % size1; - int i2next = ( i2 + sign +size2) % size2; - - while(true) - { - while( i1next!=istart1 && distance2(L1,i1*dim, L1,i1next*dim) < epsilon ) i1next = ( i1next + 1 ) % size1; - while( i2next!=istart2 && distance2(L2,i2*dim, L2,i2next*dim) < epsilon ) i2next = ( i2next + sign +size2 ) % size2; - - if(i1next == istart1) - { - if(i2next == istart2) - return true; - else return false; - } - else - if(i2next == istart2) - return false; - else - { - if(distance2(L1,i1next*dim, L2,i2next*dim) > epsilon ) - return false; - else - { - i1 = i1next; - i2 = i2next; - i1next = ( i1 + 1 ) % size1; - i2next = ( i2 + sign + size2 ) % size2; - } - } - } - } - - /*! Tests if two list of nodes (not necessarily distincts) describe the same polygon.*/ - /*! Existence of multiple points in the list is considered.*/ - template - bool checkEqualPolygons(T * L1, T * L2, double epsilon) - { - if(L1==NULL || L2==NULL) - { - std::cout << "Warning InterpolationUtils.hxx:checkEqualPolygonsPointer: Null pointer " << std::endl; - throw(Exception("big error: not closed polygon...")); - } - - int size1 = (*L1).size()/dim; - int size2 = (*L2).size()/dim; - int istart1 = 0; - int istart2 = 0; - - while( istart2 < size2 && distance2(L1,istart1*dim, L2,istart2*dim) > epsilon ) istart2++; - - if(istart2 == size2) - { - return (size1 == 0) && (size2 == 0); - } - else - return checkEqualPolygonsOneDirection( L1, L2, size1, size2, istart1, istart2, epsilon, 1) - || checkEqualPolygonsOneDirection( L1, L2, size1, size2, istart1, istart2, epsilon, -1); - - } -} - - -#endif diff --git a/src/INTERP_KERNEL/Intersector3D.hxx b/src/INTERP_KERNEL/Intersector3D.hxx deleted file mode 100644 index 9be0b67df..000000000 --- a/src/INTERP_KERNEL/Intersector3D.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3D_HXX__ -#define __INTERSECTOR3D_HXX__ - -#include "TargetIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class Intersector3D : public TargetIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - Intersector3D(const MyMeshType& targetMesh, const MyMeshType& srcMesh); - void getRealTargetCoordinates(ConnType icellT, std::vector& coordsT) const; - void getRealSourceCoordinates(ConnType icellT, std::vector& coordsT) const; - const ConnType *getStartConnOfTargetCell(ConnType icellT) const; - const ConnType *getStartConnOfSourceCell(ConnType icellS) const; - void getConnOfSourceCell(ConnType icellS, typename std::vector& res) const; - protected: - const MyMeshType& _target_mesh; - const MyMeshType& _src_mesh; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3D.txx b/src/INTERP_KERNEL/Intersector3D.txx deleted file mode 100644 index 10199d178..000000000 --- a/src/INTERP_KERNEL/Intersector3D.txx +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3D_TXX__ -#define __INTERSECTOR3D_TXX__ - -#include "Intersector3D.hxx" - -#include - -namespace INTERP_KERNEL -{ - template - Intersector3D::Intersector3D(const MyMeshType& targetMesh, const MyMeshType& srcMesh):_target_mesh(targetMesh),_src_mesh(srcMesh) - { - } - - /*! - * @param icellT in format of MyMeshType. - */ - template - void Intersector3D::getRealTargetCoordinates(ConnType icellT, std::vector& coordsT) const - { - int nbNodesT=_target_mesh.getNumberOfNodesOfElement(icellT); - coordsT.resize(SPACEDIM*nbNodesT); - std::vector::iterator iter=coordsT.begin(); - for (ConnType iT=0; iT - void Intersector3D::getRealSourceCoordinates(ConnType icellS, std::vector& coordsS) const - { - int nbNodesS=_src_mesh.getNumberOfNodesOfElement(icellS); - coordsS.resize(SPACEDIM*nbNodesS); - std::vector::iterator iter=coordsS.begin(); - for (ConnType iS=0; iS - const typename MyMeshType::MyConnType *Intersector3D::getStartConnOfTargetCell(ConnType icellT) const - { - const ConnType *myConectT=_target_mesh.getConnectivityPtr(); - const ConnType *myConIndexT=_target_mesh.getConnectivityIndexPtr(); - return myConectT+OTT::conn2C(myConIndexT[icellT]); - } - - /*! - * @param icellT in C format. - * @return is in format of MyMeshType - */ - template - const typename MyMeshType::MyConnType *Intersector3D::getStartConnOfSourceCell(ConnType icellS) const - { - const ConnType *myConectS=_src_mesh.getConnectivityPtr(); - const ConnType *myConIndexS=_src_mesh.getConnectivityIndexPtr(); - return myConectS+OTT::conn2C(myConIndexS[icellS]); - } - - /*! - * @param icellS in format of MyMeshType. - * @param res ; out param in format of MyMeshType. - */ - template - void Intersector3D::getConnOfSourceCell(ConnType icellS, typename std::vector& res) const - { - const ConnType *myConectS=_src_mesh.getConnectivityPtr(); - const ConnType *myConIndexS=_src_mesh.getConnectivityIndexPtr(); - ConnType start=myConIndexS[OTT::ind2C(icellS)]; - ConnType end=myConIndexS[OTT::ind2C(icellS)+1]; - int nbNodesS=end-start; - res.resize(nbNodesS); - std::copy(myConectS+OTT::conn2C(start),myConectS+OTT::conn2C(end),res.begin()); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP0P0.hxx b/src/INTERP_KERNEL/Intersector3DP0P0.hxx deleted file mode 100644 index c685f321b..000000000 --- a/src/INTERP_KERNEL/Intersector3DP0P0.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3DP0P0_HXX__ -#define __INTERSECTOR3DP0P0_HXX__ - -#include "Intersector3D.hxx" - -namespace INTERP_KERNEL -{ - template - class Intersector3DP0P0 : public Intersector3D - { - public: - Intersector3DP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP0P0.txx b/src/INTERP_KERNEL/Intersector3DP0P0.txx deleted file mode 100644 index 396cbafe8..000000000 --- a/src/INTERP_KERNEL/Intersector3DP0P0.txx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3DP0P0_TXX__ -#define __INTERSECTOR3DP0P0_TXX__ - -#include "Intersector3DP0P0.hxx" -#include "Intersector3D.txx" - -namespace INTERP_KERNEL -{ - template - Intersector3DP0P0::Intersector3DP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh):Intersector3D(targetMesh,srcMesh) - { - } - - template - int Intersector3DP0P0::getNumberOfRowsOfResMatrix() const - { - return Intersector3D::_target_mesh.getNumberOfElements(); - } - - template - int Intersector3DP0P0::getNumberOfColsOfResMatrix() const - { - return Intersector3D::_src_mesh.getNumberOfElements(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP0P1.hxx b/src/INTERP_KERNEL/Intersector3DP0P1.hxx deleted file mode 100644 index 82138b69f..000000000 --- a/src/INTERP_KERNEL/Intersector3DP0P1.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3DP0P1_HXX__ -#define __INTERSECTOR3DP0P1_HXX__ - -#include "Intersector3D.hxx" - -namespace INTERP_KERNEL -{ - template - class Intersector3DP0P1 : public Intersector3D - { - public: - Intersector3DP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP0P1.txx b/src/INTERP_KERNEL/Intersector3DP0P1.txx deleted file mode 100644 index 0b8a07c8d..000000000 --- a/src/INTERP_KERNEL/Intersector3DP0P1.txx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3DP0P1_TXX__ -#define __INTERSECTOR3DP0P1_TXX__ - -#include "Intersector3DP0P1.hxx" -#include "Intersector3D.txx" - -namespace INTERP_KERNEL -{ - template - Intersector3DP0P1::Intersector3DP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh):Intersector3D(targetMesh,srcMesh) - { - } - - template - int Intersector3DP0P1::getNumberOfRowsOfResMatrix() const - { - return Intersector3D::_target_mesh.getNumberOfNodes(); - } - - template - int Intersector3DP0P1::getNumberOfColsOfResMatrix() const - { - return Intersector3D::_src_mesh.getNumberOfElements(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP1P0.hxx b/src/INTERP_KERNEL/Intersector3DP1P0.hxx deleted file mode 100644 index aa5489ee8..000000000 --- a/src/INTERP_KERNEL/Intersector3DP1P0.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3DP1P0_HXX__ -#define __INTERSECTOR3DP1P0_HXX__ - -#include "Intersector3D.hxx" - -namespace INTERP_KERNEL -{ - template - class Intersector3DP1P0 : public Intersector3D - { - public: - Intersector3DP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP1P0.txx b/src/INTERP_KERNEL/Intersector3DP1P0.txx deleted file mode 100644 index b7492711d..000000000 --- a/src/INTERP_KERNEL/Intersector3DP1P0.txx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERSECTOR3DP1P0_TXX__ -#define __INTERSECTOR3DP1P0_TXX__ - -#include "Intersector3DP1P0.hxx" -#include "Intersector3D.txx" - -namespace INTERP_KERNEL -{ - template - Intersector3DP1P0::Intersector3DP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh):Intersector3D(targetMesh,srcMesh) - { - } - - template - int Intersector3DP1P0::getNumberOfRowsOfResMatrix() const - { - return Intersector3D::_target_mesh.getNumberOfElements(); - } - - template - int Intersector3DP1P0::getNumberOfColsOfResMatrix() const - { - return Intersector3D::_src_mesh.getNumberOfNodes(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx b/src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx deleted file mode 100644 index b47ba5ccd..000000000 --- a/src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2010 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 __Intersector3DP1P0Bary_HXX__ -#define __Intersector3DP1P0Bary_HXX__ - -#include "Intersector3D.hxx" - -namespace INTERP_KERNEL -{ - template - class Intersector3DP1P0Bary : public Intersector3D - { - public: - Intersector3DP1P0Bary(const MyMeshType& targetMesh, const MyMeshType& srcMesh); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP1P0Bary.txx b/src/INTERP_KERNEL/Intersector3DP1P0Bary.txx deleted file mode 100644 index f0883fe3c..000000000 --- a/src/INTERP_KERNEL/Intersector3DP1P0Bary.txx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __Intersector3DP1P0Bary_TXX__ -#define __Intersector3DP1P0Bary_TXX__ - -#include "Intersector3DP1P0Bary.hxx" -#include "Intersector3D.txx" - -namespace INTERP_KERNEL -{ - template - Intersector3DP1P0Bary::Intersector3DP1P0Bary(const MyMeshType& targetMesh, const MyMeshType& srcMesh):Intersector3D(targetMesh,srcMesh) - { - } - - template - int Intersector3DP1P0Bary::getNumberOfRowsOfResMatrix() const - { - return Intersector3D::_target_mesh.getNumberOfElements(); - } - - template - int Intersector3DP1P0Bary::getNumberOfColsOfResMatrix() const - { - return Intersector3D::_src_mesh.getNumberOfNodes(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP1P1.hxx b/src/INTERP_KERNEL/Intersector3DP1P1.hxx deleted file mode 100644 index a6961b7f2..000000000 --- a/src/INTERP_KERNEL/Intersector3DP1P1.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2010 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 __Intersector3DP1P1_HXX__ -#define __Intersector3DP1P1_HXX__ - -#include "Intersector3D.hxx" - -namespace INTERP_KERNEL -{ - template - class Intersector3DP1P1 : public Intersector3D - { - public: - Intersector3DP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/Intersector3DP1P1.txx b/src/INTERP_KERNEL/Intersector3DP1P1.txx deleted file mode 100644 index c41a1d0d4..000000000 --- a/src/INTERP_KERNEL/Intersector3DP1P1.txx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __Intersector3DP1P1_TXX__ -#define __Intersector3DP1P1_TXX__ - -#include "Intersector3DP1P1.hxx" -#include "Intersector3D.txx" - -namespace INTERP_KERNEL -{ - template - Intersector3DP1P1::Intersector3DP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh):Intersector3D(targetMesh,srcMesh) - { - } - - template - int Intersector3DP1P1::getNumberOfRowsOfResMatrix() const - { - return Intersector3D::_target_mesh.getNumberOfNodes(); - } - - template - int Intersector3DP1P1::getNumberOfColsOfResMatrix() const - { - return Intersector3D::_src_mesh.getNumberOfNodes(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU.hxx b/src/INTERP_KERNEL/IntersectorCU.hxx deleted file mode 100644 index 75c5d405e..000000000 --- a/src/INTERP_KERNEL/IntersectorCU.hxx +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU.hxx -// Created : Thu Dec 17 12:30:17 2009 -// Author : Edward AGAPOV (eap) -// - -#ifndef __IntersectorCU_HXX__ -#define __IntersectorCU_HXX__ - -#include "TargetIntersector.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - template class _StabIntersector; - - template > - class IntersectorCU : public TargetIntersector - { - public: - static const int SPACEDIM=MyCMeshType::MY_SPACEDIM; - static const int MESHDIM=MyCMeshType::MY_MESHDIM; - typedef typename MyUMeshType::MyConnType UConnType; - typedef typename MyCMeshType::MyConnType CConnType; - public: - //! \addtogroup InterpKerGrpIntCU @{ - IntersectorCU(const MyCMeshType& meshS, const MyUMeshType& meshT); - //! @} - virtual ~IntersectorCU(); - void getUElemBB(double* bb, UConnType iP); - void getUCoordinates(UConnType icell, std::vector& coords); - - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - void intersectCells(CConnType icellU, const std::vector& icellC, MyMatrix& res); - double intersectGeometry(CConnType icellT, const std::vector& icellC) { return asLeaf().intersectGeometry(icellT,icellC); } - protected: - ConcreteIntersector& asLeaf() { return static_cast(*this); } - - protected: - const UConnType *_connectU; - const UConnType *_connIndexU; - const double * _coordsU; - const MyUMeshType& _meshU; - - const double * _coordsC[SPACEDIM]; - int _nbCellsC[SPACEDIM]; - const MyCMeshType& _meshC; - }; - - // class to enable usage of IntersectorCU not for intersection but for access to data it encapsulates - template - class _StabIntersector: public IntersectorCU > - { - public: - _StabIntersector(const MyCMeshType& meshS, const MyUMeshType& meshT) : IntersectorCU >(meshS, meshT) {} - double intersectGeometry(typename MyUMeshType::MyConnType icellT, const std::vector& icellC) { throw Exception("You must provide an intersector as the 4-th template argument of IntersectorCU"); return 0; } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU.txx b/src/INTERP_KERNEL/IntersectorCU.txx deleted file mode 100644 index f9a3155a4..000000000 --- a/src/INTERP_KERNEL/IntersectorCU.txx +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU.txx -// Created : Thu Dec 17 12:30:17 2009 -// Author : Edward AGAPOV (eap) -// -#ifndef __IntersectorCU_TXX__ -#define __IntersectorCU_TXX__ - -#include "IntersectorCU.hxx" - -// convert index "From Mesh Index" -#define _FMIU(i) OTT::ind2C((i)) -#define _FMIC(i) OTT::ind2C((i)) -// convert index "To Mesh Index" -#define _TMIU(i) OTT::indFC((i)) -#define _TMIC(i) OTT::indFC((i)) -// convert coord "From Mesh Coord" -#define _FMCOO(i) OTT::coo2C((i)) -// convert connectivity "From Mesh Connectivity" -#define _FMCON(i) OTT::conn2C((i)) - - -#define _CU_TEMPLATE \ -template -#define _INTERSECTOR_CU_ \ -IntersectorCU - -namespace INTERP_KERNEL -{ - //================================================================================ - /*! - * \brief Constructor - */ - //================================================================================ - - _CU_TEMPLATE - _INTERSECTOR_CU_::IntersectorCU(const MyCMeshType& meshS, const MyUMeshType& meshT): - _meshU(meshT), _meshC(meshS) - { - _connectU =meshT.getConnectivityPtr(); - _connIndexU=meshT.getConnectivityIndexPtr(); - _coordsU =meshT.getCoordinatesPtr(); - - for ( int j = 0; j < SPACEDIM; ++j ) - { - _coordsC [ j ] = _meshC.getCoordsAlongAxis( _TMIC( j )); - _nbCellsC[ j ] = _meshC.nbCellsAlongAxis ( _TMIC( j )); - } - } - - //================================================================================ - /*! - * \brief Destructor - */ - //================================================================================ - - _CU_TEMPLATE - _INTERSECTOR_CU_::~IntersectorCU() - { - } - - //================================================================================ - /*! - * \brief Return bounding box of an unstructured element - */ - //================================================================================ - - _CU_TEMPLATE - void _INTERSECTOR_CU_::getUElemBB(double* bb, UConnType icell) - { - //initializing bounding box limits - for(int idim=0; idim::max(); - bb[2*idim+1] = -std::numeric_limits::max(); - } - - UConnType nb_nodes = _connIndexU[icell+1] - _connIndexU[icell]; - for (UConnType i=0; i::coo2C(conn[OTT::conn2C(conn_index[OTT::ind2C(iP)]+i)])); - const double* coord_node=_coordsU+SPACEDIM*(_FMCOO( _connectU[_FMCON (_connIndexU[_FMIU(icell)]+i)])); - for(int idim=0; idimbb[2*idim+1])?x:bb[2*idim+1]; - } - } - } - - //================================================================================ - /*! - * \brief Return coordinates of nodes of an unstructured element - */ - //================================================================================ - - _CU_TEMPLATE - void _INTERSECTOR_CU_::getUCoordinates(UConnType icell, std::vector& coords) - { - UConnType nb_nodes = _connIndexU[icell+1] - _connIndexU[icell]; - coords.resize( SPACEDIM * nb_nodes ); - for (UConnType i=0; i& icellC, - MyMatrix& res) - { - double v = intersectGeometry(icellU, icellC); - - CConnType iC = icellC[0], area = _nbCellsC[0]; - for ( int j = 1; j < SPACEDIM; ++j ) - { - iC += icellC[j] * area; - area *= _nbCellsC[j]; - } - res[ icellU ][ iC ] = v; - } -} - -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU1D.hxx b/src/INTERP_KERNEL/IntersectorCU1D.hxx deleted file mode 100644 index 0da006bcb..000000000 --- a/src/INTERP_KERNEL/IntersectorCU1D.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU1D.hxx -// Created : Thu Dec 17 14:10:00 2009 -// Author : Edward AGAPOV (eap) -// -#ifndef __IntersectorCU1D_HXX__ -#define __IntersectorCU1D_HXX__ - -#include "IntersectorCU.hxx" - -namespace INTERP_KERNEL -{ - template - class IntersectorCU1D : public IntersectorCU > - { - public: - typedef typename MyUMeshType::MyConnType UConnType; - typedef typename MyCMeshType::MyConnType CConnType; - public: - IntersectorCU1D(const MyCMeshType& meshS, const MyUMeshType& meshT); - ~IntersectorCU1D(); - double intersectGeometry(UConnType icellT, const std::vector& icellC); - - private: - }; -} - - -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU1D.txx b/src/INTERP_KERNEL/IntersectorCU1D.txx deleted file mode 100644 index 1eff67400..000000000 --- a/src/INTERP_KERNEL/IntersectorCU1D.txx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU1D.txx -// Created : Thu Dec 17 14:17:49 2009 -// Author : Edward AGAPOV (eap) - -#ifndef __IntersectorCU1D_TXX__ -#define __IntersectorCU1D_TXX__ - -#include "IntersectorCU1D.hxx" -#include "IntersectorCU.txx" - -#define IntersectorCU1D_TEMPLATE template -#define INTERSECTOR_CU1D IntersectorCU1D -#define _INTER_CU IntersectorCU > - -namespace INTERP_KERNEL -{ - //================================================================================ - /*! - * \brief intersector of the unstructured mesh and the cartesian mesh in 1D - */ - //================================================================================ - - IntersectorCU1D_TEMPLATE - INTERSECTOR_CU1D::IntersectorCU1D(const MyCMeshType& meshS, - const MyUMeshType& meshT): - _INTER_CU( meshS, meshT ) - { - if ( MyCMeshType::MY_SPACEDIM != 1 || MyCMeshType::MY_MESHDIM != 1 || - MyUMeshType::MY_SPACEDIM != 1 || MyUMeshType::MY_MESHDIM != 1 ) - throw Exception("IntersectorCU1D(): Invalid mesh dimension, it must be 1"); - } - - //================================================================================ - /*! - * \brief destructor - */ - //================================================================================ - - IntersectorCU1D_TEMPLATE - INTERSECTOR_CU1D::~IntersectorCU1D() - { - } - - //================================================================================ - /*! - * \brief Calculate length of intersection of an unstructured cell and a cartesian one. - * The cartesian cell is given by its [i,j,k] indices - */ - //================================================================================ - - IntersectorCU1D_TEMPLATE - double INTERSECTOR_CU1D::intersectGeometry(UConnType icellT, - const std::vector& icellS) - { - std::vector coordsU; - _INTER_CU::getUCoordinates(icellT, coordsU); - - const double* coordsC = & _INTER_CU::_coordsC[0][ _FMIC(icellS[0]) ]; - - double res = std::min( coordsU[1], coordsC[1] ) - std::max( coordsU[0], coordsC[0] ); - return res; - } -} -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU2D.hxx b/src/INTERP_KERNEL/IntersectorCU2D.hxx deleted file mode 100644 index b6f335c2a..000000000 --- a/src/INTERP_KERNEL/IntersectorCU2D.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU2D.hxx -// Created : Thu Dec 17 14:10:00 2009 -// Author : Edward AGAPOV (eap) -// -#ifndef __IntersectorCU2D_HXX__ -#define __IntersectorCU2D_HXX__ - -#include "IntersectorCU.hxx" - -namespace INTERP_KERNEL -{ - template - class IntersectorCU2D : public IntersectorCU > - { - public: - typedef typename MyUMeshType::MyConnType UConnType; - typedef typename MyCMeshType::MyConnType CConnType; - public: - IntersectorCU2D(const MyCMeshType& meshS, const MyUMeshType& meshT); - double intersectGeometry(UConnType icellT, const std::vector& icellC); - - private: - TriangulationIntersector _intersector; - }; -} - - -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU2D.txx b/src/INTERP_KERNEL/IntersectorCU2D.txx deleted file mode 100644 index e6174d823..000000000 --- a/src/INTERP_KERNEL/IntersectorCU2D.txx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU2D.txx -// Created : Thu Dec 17 14:17:49 2009 -// Author : Edward AGAPOV (eap) - -#ifndef __IntersectorCU2D_TXX__ -#define __IntersectorCU2D_TXX__ - -#include "IntersectorCU2D.hxx" -#include "IntersectorCU.txx" - -#define IntersectorCU2D_TEMPLATE template -#define INTERSECTOR_CU2D IntersectorCU2D -#define INTER_CU IntersectorCU > - - -namespace INTERP_KERNEL -{ - IntersectorCU2D_TEMPLATE - INTERSECTOR_CU2D::IntersectorCU2D(const MyCMeshType& meshS, - const MyUMeshType& meshT): - IntersectorCU >( meshS, meshT ), - _intersector(meshT, meshT, 0,0,0,0,0,0 ) - { - if ( MyCMeshType::MY_SPACEDIM != 2 || MyCMeshType::MY_MESHDIM != 2 || - MyUMeshType::MY_SPACEDIM != 2 || MyUMeshType::MY_MESHDIM != 2 ) - throw Exception("IntersectorCU2D(): Invalid mesh dimension, it must be 2"); - } - - - //================================================================================ - /*! - * \brief Calculate area of intersection of an unstructured cell and a cartesian one. - * The cartesian cell is given by its [i,j] indices - */ - //================================================================================ - - IntersectorCU2D_TEMPLATE - double INTERSECTOR_CU2D::intersectGeometry(UConnType icellT, - const std::vector& icellS) - { - std::vector uCoords; - getUCoordinates( icellT, uCoords ); - - NormalizedCellType tT = INTER_CU::_meshU.getTypeOfElement( _TMIU(icellT)); - bool is_tgt_quad = CellModel::getCellModel(tT).isQuadratic(); - - double quad[8] = { INTER_CU::_coordsC[0][icellS[0]], INTER_CU::_coordsC[1][icellS[1]], - INTER_CU::_coordsC[0][icellS[0]+1], INTER_CU::_coordsC[1][icellS[1]], - INTER_CU::_coordsC[0][icellS[0]+1], INTER_CU::_coordsC[1][icellS[1]+1], - INTER_CU::_coordsC[0][icellS[0]], INTER_CU::_coordsC[1][icellS[1]+1] }; - - double surf = _intersector.intersectGeometryWithQuadrangle( quad, - uCoords, - is_tgt_quad); - return surf; - } -} -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU3D.hxx b/src/INTERP_KERNEL/IntersectorCU3D.hxx deleted file mode 100644 index c74565220..000000000 --- a/src/INTERP_KERNEL/IntersectorCU3D.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU3D.hxx -// Created : Thu Dec 17 14:10:00 2009 -// Author : Edward AGAPOV (eap) -// -#ifndef __IntersectorCU3D_HXX__ -#define __IntersectorCU3D_HXX__ - -#include "IntersectorCU.hxx" -#include "SplitterTetra.hxx" - -namespace INTERP_KERNEL -{ - class _Cartesian3D2UnstructHexMesh; - - template - class IntersectorCU3D : public IntersectorCU > - { - public: - typedef typename MyUMeshType::MyConnType UConnType; - typedef typename MyCMeshType::MyConnType CConnType; - public: - IntersectorCU3D(const MyCMeshType& meshS, const MyUMeshType& meshT, SplittingPolicy splitting_policy); - ~IntersectorCU3D(); - double intersectGeometry(UConnType icellT, const std::vector& icellC); - - private: - - typedef SplitterTetra2 TSplitter; - typedef SplitterTetra <_Cartesian3D2UnstructHexMesh > TTetra; - _Cartesian3D2UnstructHexMesh* _uHexMesh; - TSplitter* _split; - }; -} - - -#endif diff --git a/src/INTERP_KERNEL/IntersectorCU3D.txx b/src/INTERP_KERNEL/IntersectorCU3D.txx deleted file mode 100644 index 6a94f91a9..000000000 --- a/src/INTERP_KERNEL/IntersectorCU3D.txx +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2009-2010 OPEN CASCADE -// -// 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 : IntersectorCU3D.txx -// Created : Thu Dec 17 14:17:49 2009 -// Author : Edward AGAPOV (eap) - -#ifndef __IntersectorCU3D_TXX__ -#define __IntersectorCU3D_TXX__ - -#include "IntersectorCU3D.hxx" -#include "IntersectorCU.txx" -#include "SplitterTetra.txx" - -#define IntersectorCU3D_TEMPLATE template -#define INTERSECTOR_CU3D IntersectorCU3D -#define _INTERSECTOR_CU IntersectorCU > - -namespace INTERP_KERNEL -{ - //================================================================================ - /*! - * \brief Unstructured hexahedral mesh derived from cartesian 3D mesh. - * Mesh contains one HEXA8 element - */ - //================================================================================ - - class _Cartesian3D2UnstructHexMesh : public INTERP_KERNEL::GenericMesh - { - public: - static const int MY_SPACEDIM=3; - static const int MY_MESHDIM=3; - typedef int MyConnType; - static const NumberingPolicy My_numPol=ALL_C_MODE; - - _Cartesian3D2UnstructHexMesh(const double * coords[3]): _coordsC(coords) {} - void setHexa(int I, int J, int K) // indices in C mode - { - double* pCoord = _coordsU; - for ( int k = K; k < K+2; ++k ) - for ( int j = J; j < J+2; ++j ) - for ( int i = I; i < I+2; ++i ) - { - *pCoord++ = _coordsC[0][i]; - *pCoord++ = _coordsC[1][j]; - *pCoord++ = _coordsC[2][k]; - } - } - const int *getConnectivityPtr() const - { - static int conn[] = { 1,0,2,3,5,4,6,7 }; - return conn; - } - const int *getConnectivityIndexPtr() const - { - static int conInd[] = { 0,8 }; - return conInd; - } - void getBoundingBox(double *boundingBox) const - { - boundingBox[BoundingBox::XMIN] = _coordsU[0]; - boundingBox[BoundingBox::XMAX] = _coordsU[0+1*MY_SPACEDIM]; - boundingBox[BoundingBox::YMIN] = _coordsU[1]; - boundingBox[BoundingBox::YMAX] = _coordsU[1+2*MY_SPACEDIM]; - boundingBox[BoundingBox::ZMIN] = _coordsU[2]; - boundingBox[BoundingBox::ZMAX] = _coordsU[2+4*MY_SPACEDIM]; - } - NormalizedCellType getTypeOfElement(int eltId) const { return NORM_HEXA8; } - unsigned char getNumberOfNodesOfElement(int eltId) const { return 8; } - unsigned long getNumberOfElements() const { return 1; } - unsigned long getNumberOfNodes() const { return 8; } - const double *getCoordinatesPtr() const { return _coordsU; } - void releaseTempArrays() {} - private: - const double** _coordsC; - double _coordsU[3*8]; - }; - - //================================================================================ - /*! - * \brief intersector of the unstructured mesh and the cartesian mesh in 3D - */ - //================================================================================ - - IntersectorCU3D_TEMPLATE - INTERSECTOR_CU3D::IntersectorCU3D(const MyCMeshType& meshS, - const MyUMeshType& meshT, - SplittingPolicy splitting_policy): - _INTERSECTOR_CU( meshS, meshT ) - { - if ( MyCMeshType::MY_SPACEDIM != 3 || MyCMeshType::MY_MESHDIM != 3 || - MyUMeshType::MY_SPACEDIM != 3 || MyUMeshType::MY_MESHDIM != 3 ) - throw Exception("IntersectorCU3D(): Invalid mesh dimension, it must be 3"); - - _uHexMesh = new _Cartesian3D2UnstructHexMesh( _INTERSECTOR_CU::_coordsC ); - _split = new TSplitter( meshT, *_uHexMesh, splitting_policy ); - } - - //================================================================================ - /*! - * \brief destructor - */ - //================================================================================ - - IntersectorCU3D_TEMPLATE - INTERSECTOR_CU3D::~IntersectorCU3D() - { - delete _uHexMesh; _uHexMesh=0; - delete _split; _split=0; - } - - //================================================================================ - /*! - * \brief Calculate volume of intersection of an unstructured cell and a cartesian one. - * The cartesian cell is given by its [i,j,k] indices - */ - //================================================================================ - - IntersectorCU3D_TEMPLATE - double INTERSECTOR_CU3D::intersectGeometry(UConnType icellT, - const std::vector& icellS) - { - // split an unstructured cell into tetra - std::vector< TTetra* > tetra; - UConnType nb_nodes = - _INTERSECTOR_CU::_connIndexU[icellT+1] - _INTERSECTOR_CU::_connIndexU[icellT]; - _split->releaseArrays(); - _split->splitTargetCell( icellT, nb_nodes, tetra); - - // intersect a cartesian 3d cell with tetra - _uHexMesh->setHexa( _FMIC(icellS[0]),_FMIC(icellS[1]),_FMIC(icellS[2])); // set cell at i,j,k - double res = 0; - for ( unsigned int t = 0; t < tetra.size(); ++t ) - { - res += tetra[t]->intersectSourceCell( 0 ); - delete tetra[t]; - } - return res; - } -} -#endif diff --git a/src/INTERP_KERNEL/Log.hxx b/src/INTERP_KERNEL/Log.hxx deleted file mode 100644 index b086c743e..000000000 --- a/src/INTERP_KERNEL/Log.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2010 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 _LOG_H_ -#define _LOG_H_ - -/** - * \file Log.hxx - * \brief Simple pre-processor logging utility. - * - * Replaces LOG( lvl, x ) with "if(lvl <= LOG_LEVEL) std::cout << x << std::endl" when logging is active - * (LOG_LEVEL > 0 is defined). x is the level at which the message should be logged - if it is smaller or equal to - * LOG_LEVEL (which can be defined at compile-time for each file by passing option -DLOG_LEVEL=x to gcc) - * than the message is logged. - * - * - * - */ - -/// define LOG_LEVEL here if it is not already defined -#ifndef LOG_LEVEL -#define LOG_LEVEL 0 -#endif - -#if LOG_LEVEL > 0 - -#include - -/// write message msg to std::cout if x <= LOG_LEVEL -#define LOG(x, msg) if(x <= LOG_LEVEL) std::cout << msg << std::endl; -#define LOG3( x , msg1 , msg2 ) if(x <= LOG_LEVEL) std::cout << msg1, msg2 << std::endl; - -#else - -#define LOG( x , msg ) -#define LOG3( x , msg1 , msg2 ) - -#endif - - - - - - - - - - - -#endif diff --git a/src/INTERP_KERNEL/Makefile.am b/src/INTERP_KERNEL/Makefile.am deleted file mode 100644 index e3dfc56cb..000000000 --- a/src/INTERP_KERNEL/Makefile.am +++ /dev/null @@ -1,202 +0,0 @@ -# Copyright (C) 2007-2010 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 -# - -# MED files in memory -# File : Makefile.am -# Author : Vincent BERGEAUD (CEA/DEN/DANS/DM2S/SFME/LGLS) -# Module : MED -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -SUBDIRS = Bases Geometric2D ExprEval . - -DIST_SUBDIRS = Bases Geometric2D ExprEval - -lib_LTLIBRARIES = libinterpkernel.la - - -salomeinclude_HEADERS = \ -BBTree.txx \ -BoundingBox.hxx \ -CellModel.hxx \ -ConvexIntersector.hxx \ -ConvexIntersector.txx \ -Geometric2DIntersector.hxx \ -Geometric2DIntersector.txx \ -PointLocator2DIntersector.hxx \ -PointLocator2DIntersector.txx \ -INTERPKERNELDefines.hxx \ -InterpKernelMatrix.hxx \ -InterpKernelMeshQuality.hxx \ -Interpolation.hxx \ -Interpolation.txx \ -Interpolation2D.hxx \ -Interpolation2D.txx \ -Interpolation3D.hxx \ -Interpolation3D.txx \ -Interpolation3DSurf.hxx \ -Interpolation3DSurf.txx \ -InterpolationOptions.hxx \ -InterpolationPlanar.hxx \ -InterpolationPlanar.txx \ -InterpolationCC.hxx \ -InterpolationCC.txx \ -InterpolationCU.hxx \ -InterpolationCU.txx \ -InterpolationUtils.hxx \ -IntersectorCU.hxx \ -IntersectorCU.txx \ -IntersectorCU1D.hxx \ -IntersectorCU1D.txx \ -IntersectorCU2D.hxx \ -IntersectorCU2D.txx \ -IntersectorCU3D.hxx \ -IntersectorCU3D.txx \ -Intersector3D.hxx \ -Intersector3D.txx \ -Intersector3DP0P0.hxx \ -Intersector3DP0P0.txx \ -Intersector3DP0P1.hxx \ -Intersector3DP0P1.txx \ -Intersector3DP1P0.hxx \ -Intersector3DP1P0.txx \ -Intersector3DP1P0Bary.hxx \ -Intersector3DP1P0Bary.txx \ -Intersector3DP1P1.hxx \ -Intersector3DP1P1.txx \ -Log.hxx \ -MeshElement.hxx \ -MeshElement.txx \ -MeshRegion.hxx \ -MeshRegion.txx \ -MeshUtils.hxx \ -PointLocatorAlgos.txx \ -PlanarIntersector.hxx \ -PlanarIntersector.txx \ -PlanarIntersectorP0P0.hxx \ -PlanarIntersectorP0P0.txx \ -PlanarIntersectorP0P1.hxx \ -PlanarIntersectorP0P1.txx \ -PlanarIntersectorP1P0.hxx \ -PlanarIntersectorP1P0.txx \ -PlanarIntersectorP1P0Bary.hxx \ -PlanarIntersectorP1P0Bary.txx \ -PlanarIntersectorP0P1PL.hxx \ -PlanarIntersectorP0P1PL.txx \ -PlanarIntersectorP1P0PL.hxx \ -PlanarIntersectorP1P0PL.txx \ -PlanarIntersectorP1P1PL.hxx \ -PlanarIntersectorP1P1PL.txx \ -PlanarIntersectorP1P1.hxx \ -PlanarIntersectorP1P1.txx \ -PolygonAlgorithms.hxx \ -PolygonAlgorithms.txx \ -PolyhedronIntersectorP0P0.hxx \ -PolyhedronIntersectorP0P0.txx \ -PointLocator3DIntersectorP0P0.hxx \ -PointLocator3DIntersectorP0P0.txx \ -PolyhedronIntersectorP0P1.hxx \ -PolyhedronIntersectorP0P1.txx \ -PointLocator3DIntersectorP0P1.hxx \ -PointLocator3DIntersectorP0P1.txx \ -PolyhedronIntersectorP1P0.hxx \ -PolyhedronIntersectorP1P0.txx \ -PointLocator3DIntersectorP1P0.hxx \ -PointLocator3DIntersectorP1P0.txx \ -PolyhedronIntersectorP1P0Bary.hxx \ -PolyhedronIntersectorP1P0Bary.txx \ -PolyhedronIntersectorP1P1.hxx \ -PolyhedronIntersectorP1P1.txx \ -PointLocator3DIntersectorP1P1.hxx \ -PointLocator3DIntersectorP1P1.txx \ -RegionNode.hxx \ -SplitterTetra.hxx \ -SplitterTetra.txx \ -TargetIntersector.hxx \ -TetraAffineTransform.hxx \ -TransformedTriangle.hxx \ -TransformedTriangleInline.hxx \ -TranslationRotationMatrix.hxx \ -TriangulationIntersector.hxx \ -TriangulationIntersector.txx \ -IntegralUniformIntersector.hxx \ -IntegralUniformIntersector.txx \ -UnitTetraIntersectionBary.hxx \ -VTKNormalizedUnstructuredMesh.hxx \ -VTKNormalizedUnstructuredMesh.txx \ -VectorUtils.hxx \ -VolSurfFormulae.hxx \ -GenMathFormulae.hxx \ -VolSurfUser.hxx \ -VolSurfUser.txx \ -CurveIntersector.hxx \ -CurveIntersector.txx \ -CurveIntersectorP0P0.hxx \ -CurveIntersectorP0P0.txx \ -CurveIntersectorP0P1.hxx \ -CurveIntersectorP0P1.txx \ -CurveIntersectorP1P0.hxx \ -CurveIntersectorP1P0.txx \ -CurveIntersectorP1P1.hxx \ -CurveIntersectorP1P1.txx \ -Interpolation1D.hxx \ -Interpolation1D.txx \ -Interpolation2DCurve.hxx \ -Interpolation2DCurve.txx \ -InterpolationCurve.hxx \ -InterpolationCurve.txx \ -DirectedBoundingBox.hxx - - -EXTRA_DIST += \ -InterpKernelUtilities.hxx \ -Intersector3DP0P0.hxx \ -Intersector3DP0P0.txx \ -PlanarIntersectorP0P1.hxx \ -PlanarIntersectorP0P1.txx \ -PlanarIntersectorP1P0.hxx \ -PlanarIntersectorP1P0.txx \ -VolSurfFormulae.hxx \ -VolSurfUser.hxx \ -VolSurfUser.txx - -# Libraries targets - -dist_libinterpkernel_la_SOURCES = \ - TransformedTriangle.cxx \ - TransformedTriangleIntersect.cxx \ - TransformedTriangleMath.cxx \ - BoundingBox.cxx \ - TranslationRotationMatrix.cxx \ - TetraAffineTransform.cxx \ - CellModel.cxx \ - UnitTetraIntersectionBary.cxx \ - InterpolationOptions.cxx \ - DirectedBoundingBox.cxx \ - InterpKernelMeshQuality.cxx - -libinterpkernel_la_CPPFLAGS=-I$(srcdir)/Geometric2D -I$(srcdir)/Bases - -libinterpkernel_la_LDFLAGS= - -# the geom2D library is included in the interpkernel one -libinterpkernel_la_LIBADD= ./Geometric2D/libInterpGeometric2DAlg.la Bases/libinterpkernelbases.la ExprEval/libinterpkernelexpreval.la - -AM_CPPFLAGS += $(libinterpkernel_la_CPPFLAGS) -LDADD= $(libinterpkernel_la_LDFLAGS) diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx deleted file mode 100644 index 76d2f3e23..000000000 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2007-2010 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 __MESHELEMENT_HXX__ -#define __MESHELEMENT_HXX__ - -#include "BoundingBox.hxx" - -namespace INTERP_KERNEL -{ - - /** - * \brief Class representing a single element of a mesh together with its bounding box. - * It gives access to the element's global number, type and bounding box and allows - * easy bounding box intersection tests between MeshElements and collections of MeshElement (MeshRegions) - */ - template - class MeshElement - { - - public: - template - MeshElement(const ConnType index, const MyMeshType& mesh); - - ~MeshElement(); - - ConnType getIndex() const { return _index; } - - unsigned char getNumberOfNodes() const { return _number; } - - const BoundingBox* getBoundingBox() const { return _box; } - - private: - /// disallow copying - MeshElement(const MeshElement& elem); - - /// disallow assignment - MeshElement& operator=(const MeshElement& elem); - - /// global number of the element - const ConnType _index; - - const unsigned char _number; - - /// bounding box of the element - does not change after having been initialised - BoundingBox* _box; - }; - - /** - * \brief Class defining an order for MeshElements based on their bounding boxes. - * The order defined between two elements is that between a given coordinate of - * their bounding boxes. For instance, if the order is based on YMIN, an element whose boxes - * has a smaller YMIN is sorted before one with a larger YMIN. - * - */ - class ElementBBoxOrder - { - public : - - ElementBBoxOrder(BoundingBox::BoxCoord coord); - template - bool operator()(MeshElement* elem1, MeshElement* elem2); - - private : - /// BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering - BoundingBox::BoxCoord _coord; - }; - -} - -#endif diff --git a/src/INTERP_KERNEL/MeshElement.txx b/src/INTERP_KERNEL/MeshElement.txx deleted file mode 100644 index ed9bc6536..000000000 --- a/src/INTERP_KERNEL/MeshElement.txx +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2007-2010 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 __MESHELEMENT_TXX__ -#define __MESHELEMENT_TXX__ - -#include "MeshElement.hxx" - -#include "TetraAffineTransform.hxx" -#include "TransformedTriangle.hxx" -#include "MeshUtils.hxx" -#include "BoundingBox.hxx" -#include - -namespace INTERP_KERNEL -{ - - /** - * Constructor - * - * @param index global number of element in the mesh in C mode. - * @param mesh mesh that the element belongs to - */ - template - template - MeshElement::MeshElement(const ConnType index, const MyMeshType& mesh) - : _index(index), _number(mesh.getNumberOfNodesOfElement(OTT::indFC(index))), _box(0) - { - const double**vertices = new const double*[_number]; - - for(unsigned char i = 0 ; i < _number ; ++i) - vertices[i] = getCoordsOfNode(i , OTT::indFC(index), mesh); - - // create bounding box - _box = new BoundingBox(vertices,_number); - delete [] vertices; - } - - /** - * Destructor - * - */ - template - MeshElement::~MeshElement() - { - delete _box; - } - - - - ///////////////////////////////////////////////////////////////////// - /// ElementBBoxOrder ///////////// - ///////////////////////////////////////////////////////////////////// - /** - * Constructor - * - * @param coord BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering - */ - ElementBBoxOrder::ElementBBoxOrder(BoundingBox::BoxCoord coord) - : _coord(coord) - { - } - - /** - * Comparison operator based on the bounding boxes of the elements - * - * @return true if the coordinate _coord of the bounding box of elem1 is - * strictly smaller than that of the bounding box of elem2 - */ - template - bool ElementBBoxOrder::operator()( MeshElement* elem1, MeshElement* elem2) - { - const BoundingBox* box1 = elem1->getBoundingBox(); - const BoundingBox* box2 = elem2->getBoundingBox(); - - assert(elem1 != 0); - assert(elem2 != 0); - assert(box1 != 0); - assert(box2 != 0); - - const double coord1 = box1->getCoordinate(_coord); - const double coord2 = box2->getCoordinate(_coord); - - return coord1 < coord2; - } - -} - -#endif diff --git a/src/INTERP_KERNEL/MeshRegion.hxx b/src/INTERP_KERNEL/MeshRegion.hxx deleted file mode 100644 index 4ab573e4a..000000000 --- a/src/INTERP_KERNEL/MeshRegion.hxx +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2007-2010 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 __MESHREGION_HXX__ -#define __MESHREGION_HXX__ - -#include "MeshElement.hxx" -#include "BoundingBox.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -#include - -namespace INTERP_KERNEL -{ - /** - * \brief Class representing a set of elements in a mesh together with their bounding box. - * It permits to split itself in two, which is used in the depth-first search filtering process. - * - */ - template - class MeshRegion - { - public: - - MeshRegion(); - - ~MeshRegion(); - - template - void addElement(MeshElement* const element, const MyMeshType& mesh); - - template - void split(MeshRegion& region1, MeshRegion& region2, BoundingBox::BoxCoord coord, const MyMeshType& mesh); - - bool isDisjointWithElementBoundingBox(const MeshElement& elem) const; - /** - * Accessor to beginning of elements vector - * - * @return constant iterator pointing at the beginning of the vector or elements - */ - typename std::vector< MeshElement* >::const_iterator getBeginElements() const { return _elements.begin(); } - - /** - * Accessor to end of elements vector - * - * @return constant iterator pointing at the end of the vector or elements - */ - typename std::vector< MeshElement* >::const_iterator getEndElements() const { return _elements.end(); } - - /** - * Gives information on how many elements are contained in the region. - * - * @return the number of elements contained in the region - */ - unsigned getNumberOfElements() const { return _elements.size(); } - - private: - - /// disallow copying - MeshRegion(const MeshRegion& m); - - /// disallow assignment - MeshRegion& operator=(const MeshRegion& m); - - /// Vector of pointers to contained MeshElements. - /// NB : these pointers are not owned by the region object, and are thus - /// neither allocated or liberated in this class. The elements must therefore be allocated and liberated outside the class. - std::vector< MeshElement* > _elements; - - /// BoundingBox containing all the nodes of all the elements in the region. - BoundingBox* _box; - - }; - -} - -#endif diff --git a/src/INTERP_KERNEL/MeshRegion.txx b/src/INTERP_KERNEL/MeshRegion.txx deleted file mode 100644 index a47c3017c..000000000 --- a/src/INTERP_KERNEL/MeshRegion.txx +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (C) 2007-2010 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 __MESHREGION_TXX__ -#define __MESHREGION_TXX__ - -#include "MeshRegion.hxx" - -#include "MeshElement.txx" -#include "MeshUtils.hxx" - -namespace INTERP_KERNEL -{ - - /** - * Default constructor - * - */ - template - MeshRegion::MeshRegion():_box(0) - { - } - - /** - * Destructor - * - */ - template - MeshRegion::~MeshRegion() - { - delete _box; - } - - /** - * Adds an element to the region, updating the bounding box. If the bounding box does not yet - * exist, it is created here. This creation is delayed to make it possible to have empty MeshRegions - * - * @param element pointer to element to add to region - * @param mesh mesh to which element belongs - * - */ - template - template - void MeshRegion::addElement(MeshElement* const element, const MyMeshType& mesh) - { - _elements.push_back(element); - - const unsigned char numNodes = element->getNumberOfNodes(); - const ConnType elemIdx = element->getIndex(); - - if(_box == 0) - { - const double** pts = new const double*[numNodes]; - - // get coordinates of the nodes of the element - for(unsigned char i = 0 ; i < numNodes ; ++i) - { - pts[i] = getCoordsOfNode(i, OTT::indFC(elemIdx), mesh); - } - - _box = new BoundingBox(pts, numNodes); - delete [] pts; - - } else { - - for(unsigned char i = 0 ; i < numNodes ; ++i) - { - const double* pt = getCoordsOfNode(i, OTT::indFC(elemIdx), mesh); - _box->updateWithPoint(pt); - } - } - } - - /** - * Splits the region in two along the given axis, copying the elements with bounding boxes whose maximum - * coordinate along the axis are smaller than the middle of the bounding box of this region in region1. The - * rest of the elements are copied to region2. - * - * @param region1 region in which to store one half of this region - * @param region2 region in which to store the other of this region - * @param coord coordinate of BoundingBox to use when splitting the region - * @param mesh mesh to which region belongs - * - */ - template - template - void MeshRegion::split(MeshRegion& region1, MeshRegion& region2, BoundingBox::BoxCoord coord, const MyMeshType& mesh) - { - // create ordering - ElementBBoxOrder cmp(coord); - - // sort elements by their bounding boxes - std::sort(_elements.begin(), _elements.end(), cmp); - - // put the first half of the elements in region1 and the - // rest in region2 - typename std::vector< MeshElement *>::const_iterator iter = _elements.begin(); - int elemCount = 0; - - while(elemCount < static_cast(_elements.size() / 2)) - { - region1.addElement(*iter, mesh); - ++iter; - ++elemCount; - } - - while(iter != _elements.end()) - { - region2.addElement(*iter, mesh); - ++iter; - } - } - - /** - * Determines if a given element can intersect the elements of this region by - * testing whether the bounding box of the region intersects the bounding box of the element. - * Note that the test is only true in one direction : if the bounding boxes are disjoint, the - * element cannot intersect any of the elements in the region, but if they are not disjoint, the - * element may or may not do so. - * - * @param elem Element with which to test for disjoint-ness - * @return true if the bounding box of the element is disjoint with the bounding box of the region, false otherwise - */ - template - bool MeshRegion::isDisjointWithElementBoundingBox(const MeshElement& elem) const - { - const BoundingBox* elemBox = elem.getBoundingBox(); - - assert(_box != 0); - assert(elemBox != 0); - - return _box->isDisjointWith(*elemBox); - } - - -} - -#endif diff --git a/src/INTERP_KERNEL/MeshUtils.hxx b/src/INTERP_KERNEL/MeshUtils.hxx deleted file mode 100644 index d55b5d5de..000000000 --- a/src/INTERP_KERNEL/MeshUtils.hxx +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2007-2010 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 __MESHUTILS_HXX__ -#define __MESHUTILS_HXX__ - -#include "InterpolationUtils.hxx" - -namespace INTERP_KERNEL -{ - /** - * Returns the global number of the node of an element. - * - * @param node the node for which the global number is sought (ALWAYS in C mode) - * @param element an element of the mesh (in numPol policy) - * @param mesh a mesh - * @return the node's global number so that (its coordinates in the coordinates array are at [SPACEDIM*globalNumber, SPACEDIM*globalNumber + SPACEDIM] - */ - template - inline typename MyMeshType::MyConnType getGlobalNumberOfNode(typename MyMeshType::MyConnType node, typename MyMeshType::MyConnType element, const MyMeshType& mesh) - { - typedef typename MyMeshType::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshType::My_numPol; - const ConnType elemIdx=OTT::conn2C(mesh.getConnectivityIndexPtr()[OTT::ind2C(element)]); - if(mesh.getTypeOfElement(element)!=INTERP_KERNEL::NORM_POLYHED) - return OTT::coo2C(mesh.getConnectivityPtr()[elemIdx + node]); - else - { - const ConnType *startNodalConnOfElem=mesh.getConnectivityPtr()+elemIdx; - ConnType ptr=0,ret=0; - while(startNodalConnOfElem[ret]==-1 || ptr!=node) - { - ret++; - if(startNodalConnOfElem[ret]!=-1) - ptr++; - } - return OTT::coo2C(startNodalConnOfElem[ret]); - } - } - - /** - * Returns the coordinates of a node of an element - * - * @param node the node for which the coordinates are sought. In C mode. - * @param element an element of the mesh. In mesh policy. - * @param mesh a mesh - * @return pointer to an array of 3 doubles containing the coordinates of the node - */ - template - inline const double* getCoordsOfNode(typename MyMeshType::MyConnType node, typename MyMeshType::MyConnType element, const MyMeshType& mesh) - { - typedef typename MyMeshType::MyConnType ConnType; - const ConnType connIdx = getGlobalNumberOfNode(node, element, mesh); - const double *ret=mesh.getCoordinatesPtr()+MyMeshType::MY_SPACEDIM*connIdx; - return ret; - } - - /** - * Returns the coordinates of a node of an element - * - * @param node the node for which the coordinates are sought. In C mode. - * @param element an element of the mesh. In mesh policy. - * @param mesh a mesh - * @param nodeId globale nodeId in whole mesh point of view in C mode. - * @return pointer to an array of 3 doubles containing the coordinates of the node - */ - template - inline const double* getCoordsOfNode2(typename MyMeshType::MyConnType node, typename MyMeshType::MyConnType element, const MyMeshType& mesh, typename MyMeshType::MyConnType& nodeId) - { - typedef typename MyMeshType::MyConnType ConnType; - nodeId= getGlobalNumberOfNode(node, element, mesh); - return mesh.getCoordinatesPtr()+MyMeshType::MY_SPACEDIM*nodeId; - } - - /** - * Returns the barycentric coordinates of a point within a triangle or tetrahedron - * - * @param point the point for which the barycentric coordinates are sought - * @param element an element of the mesh - * @param mesh a mesh - * @param barycentricCoords an array of 3 doubles containing the coordinates of the node - */ - template - inline void getBarycentricCoordinates(const double* point, - typename MyMeshType::MyConnType element, - const MyMeshType& mesh, - double* barycentricCoords) - { - std::vector nodes( NB_NODES ); - for ( int node = 0; node < NB_NODES; ++node ) - { - nodes[ node ] = getCoordsOfNode( node, element, mesh ); - } - barycentric_coords( nodes, point, barycentricCoords ); - } - -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersector.hxx b/src/INTERP_KERNEL/PlanarIntersector.hxx deleted file mode 100644 index 62c970f87..000000000 --- a/src/INTERP_KERNEL/PlanarIntersector.hxx +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTOR_HXX__ -#define __PLANARINTERSECTOR_HXX__ - -#include "TargetIntersector.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - class TranslationRotationMatrix; - - template - class PlanarIntersector : public TargetIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - //! \addtogroup InterpKerGrpIntPlan @{ - PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); - //! @} - virtual ~PlanarIntersector(); - void createBoundingBoxes(const MyMeshType& mesh, std::vector& bbox); - void adjustBoundingBoxes(std::vector& bbox, double surf3DAdjustmentEps, double surf3DAdjustmentEpsAbs); - inline void getElemBB(double* bb, const MyMeshType& mesh, ConnType iP, ConnType nb_nodes); - static int projection(double *Coords_A, double *Coords_B, - int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double median_plane, bool do_rotate); - protected : - int projectionThis(double *Coords_A, double *Coords_B, int nb_NodesA, int nb_NodesB); - void getRealTargetCoordinates(ConnType icellT, std::vector& coordsT); - void getRealSourceCoordinates(ConnType icellS, std::vector& coordsS); - void getRealTargetCoordinatesPermute(ConnType icellT, int offset, std::vector& coordsT); - void getRealSourceCoordinatesPermute(ConnType icellS, int offset, std::vector& coordsS); - void getRealCoordinates(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS, std::vector& coordsT, std::vector& coordsS, int& orientation); - double getValueRegardingOption(double val) const; - static void rotate3DTriangle( double* PP1, double*PP2, double*PP3, - TranslationRotationMatrix& rotation_matrix); - protected: - const ConnType *_connectT; - const ConnType *_connectS; - const double *_coordsT; - const double *_coordsS; - const ConnType *_connIndexT; - const ConnType *_connIndexS; - const MyMeshType& _meshT; - const MyMeshType& _meshS; - double _dim_caracteristic; - double _max_distance_3Dsurf_intersect; - double _precision; - double _median_plane; - bool _do_rotate; - int _orientation; - int _print_level; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersector.txx b/src/INTERP_KERNEL/PlanarIntersector.txx deleted file mode 100644 index b7d381397..000000000 --- a/src/INTERP_KERNEL/PlanarIntersector.txx +++ /dev/null @@ -1,437 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTOR_TXX__ -#define __PLANARINTERSECTOR_TXX__ - -#include "PlanarIntersector.hxx" -#include "InterpolationUtils.hxx" -#include "TranslationRotationMatrix.hxx" - -#include -#include - -namespace INTERP_KERNEL -{ - template - PlanarIntersector::PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel): - _meshT(meshT),_meshS(meshS), - _dim_caracteristic(dimCaracteristic),_max_distance_3Dsurf_intersect(md3DSurf),_precision(precision),_median_plane(medianPlane), - _do_rotate(doRotate),_orientation(orientation),_print_level(printLevel) - { - _connectT=meshT.getConnectivityPtr(); - _connectS=meshS.getConnectivityPtr(); - _connIndexT=meshT.getConnectivityIndexPtr(); - _connIndexS=meshS.getConnectivityIndexPtr(); - _coordsT=meshT.getCoordinatesPtr(); - _coordsS=meshS.getCoordinatesPtr(); - } - - template - PlanarIntersector::~PlanarIntersector() - { - } - - /*! - \brief creates the bounding boxes for all the cells of mesh \a mesh - - The method accepts mixed meshes (containing triangles and quadrangles). - The vector returned is of dimension 6*nb_elems with bounding boxes stored as xmin1, xmax1, ymin1, ymax1, zmin1, zmax1, xmin2, xmax2, ymin2,... - The returned pointer must be deleted by the calling code. - - \param mesh structure pointing to the mesh - \param bbox vector containing the bounding boxes - */ - template - void PlanarIntersector::createBoundingBoxes(const MyMeshType& mesh, std::vector& bbox) - { - /* We build the segment tree for locating possible matching intersections*/ - long nbelems = mesh.getNumberOfElements(); - bbox.resize(2*SPACEDIM* nbelems); - const double* coords = mesh.getCoordinatesPtr(); - const ConnType* conn = mesh.getConnectivityPtr(); - const ConnType* conn_index = mesh.getConnectivityIndexPtr(); - int ibox=0; - for(long icell=0; icell::max(); - bbox[2*SPACEDIM*ibox+2*idim+1] = -std::numeric_limits::max(); - } - //updating the bounding box with each node of the element - for (int j=0; j::coo2C(conn[OTT::conn2C(conn_index[icell]+j)]); - for(int idim=0; idimx)?bbox[ibox*2*SPACEDIM + 2*idim+1]:x; - } - } - ibox++; - } - } - - /*! - Computes the bouding box of a given element. iP in numPol mode. - */ - template - void PlanarIntersector::getElemBB(double* bb, const MyMeshType& mesh, ConnType iP, ConnType nb_nodes) - { - const double* coords = mesh.getCoordinatesPtr(); - const ConnType* conn_index = mesh.getConnectivityIndexPtr(); - const ConnType* conn = mesh.getConnectivityPtr(); - //initializing bounding box limits - for(int idim=0; idim::max(); - bb[2*idim+1] = -std::numeric_limits::max(); - } - - for (ConnType i=0; i::coo2C(conn[OTT::conn2C(conn_index[OTT::ind2C(iP)]+i)])); - for(int idim=0; idimbb[2*idim+1])?x:bb[2*idim+1]; - } - } - } - - /*! Readjusts a set of bounding boxes so that they are extended - in all dimensions for avoiding missing interesting intersections - - \param bbox vector containing the bounding boxes - */ - template - void PlanarIntersector::adjustBoundingBoxes(std::vector& bbox, double surf3DAdjustmentEps, double surf3DAdjustmentEpsAbs) - { - /* We build the segment tree for locating possible matching intersections*/ - - long size = bbox.size()/(2*SPACEDIM); - for (int i=0; i::max(); - for(int idim=0; idim - void PlanarIntersector::getRealTargetCoordinates(ConnType icellT, std::vector& coordsT) - { - int nbNodesT=_connIndexT[OTT::ind2C(icellT)+1]-_connIndexT[OTT::ind2C(icellT)]; - coordsT.resize(SPACEDIM*nbNodesT); - for (ConnType iT=0; iT::coo2C(_connectT[OTT::conn2C(_connIndexT[OTT::ind2C(icellT)]+iT)])+idim]; - } - - /*! - * @param icellS id in source mesh in format of MyMeshType. - * @param coordsS output val that stores coordinates of the source cell automatically resized to the right length. - */ - template - void PlanarIntersector::getRealSourceCoordinates(ConnType icellS, std::vector& coordsS) - { - int nbNodesS=_connIndexS[OTT::ind2C(icellS)+1]-_connIndexS[OTT::ind2C(icellS)]; - coordsS.resize(SPACEDIM*nbNodesS); - for (ConnType iS=0; iS::coo2C(_connectS[OTT::conn2C(_connIndexS[OTT::ind2C(icellS)]+iS)])+idim]; - } - - /*! - * @param icellT id in target mesh in format of MyMeshType. - * @param offset is a value in C format that indicates the number of circular permutation. - * @param coordsT output val that stores coordinates of the target cell automatically resized to the right length. - */ - template - void PlanarIntersector::getRealTargetCoordinatesPermute(ConnType icellT, int offset, std::vector& coordsT) - { - int nbNodesT=_connIndexT[OTT::ind2C(icellT)+1]-_connIndexT[OTT::ind2C(icellT)]; - coordsT.resize(SPACEDIM*nbNodesT); - for (ConnType iTTmp=0; iTTmp::coo2C(_connectT[OTT::conn2C(_connIndexT[OTT::ind2C(icellT)]+iT)])+idim]; - } - } - - /*! - * @param icellS id in source mesh in format of MyMeshType. - * @param offset is a value in C format that indicates the number of circular permutation. - * @param coordsS output val that stores coordinates of the source cell automatically resized to the right length. - */ - template - void PlanarIntersector::getRealSourceCoordinatesPermute(ConnType icellS, int offset, std::vector& coordsS) - { - int nbNodesS=_connIndexS[OTT::ind2C(icellS)+1]-_connIndexS[OTT::ind2C(icellS)]; - coordsS.resize(SPACEDIM*nbNodesS); - for (ConnType iSTmp=0; iSTmp::coo2C(_connectS[OTT::conn2C(_connIndexS[OTT::ind2C(icellS)]+iS)])+idim]; - } - } - - /*! - * @param icellT id in target mesh in format of MyMeshType. - * @param icellS id in source mesh in format of MyMeshType. - * @param nbNodesT nb of nodes of the target cell. - * @param nbNodesS nb of nodes of the source cell. - * @param coordsT output val that stores coordinates of the target cell automatically resized to the right length. - * @param coordsS output val that stores coordinates of the source cell automatically resized to the right length. - * @param orientation is an output value too, only set if SPACEDIM==3. - */ - template - void PlanarIntersector::getRealCoordinates(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS, std::vector& coordsT, std::vector& coordsS, int& orientation) - { - coordsT.resize(SPACEDIM*nbNodesT); - coordsS.resize(SPACEDIM*nbNodesS); - for (int idim=0; idim::coo2C(_connectT[OTT::conn2C(_connIndexT[OTT::ind2C(icellT)]+iT)])+idim]; - for (ConnType iS=0; iS::coo2C(_connectS[OTT::conn2C(_connIndexS[OTT::ind2C(icellS)]+iS)])+idim]; - } - - //project cells T and S on the median plane and rotate the median plane - if(SPACEDIM==3) - orientation = projectionThis(&coordsT[0], &coordsS[0], nbNodesT, nbNodesS); - - //DEBUG PRINTS - if(_print_level >= 3) - { - std::cout << std::endl << "Cell coordinates (possibly after projection)" << std::endl; - std::cout << std::endl << "icellT= " << icellT << ", nb nodes T= " << nbNodesT << std::endl; - for(int iT =0; iT< nbNodesT; iT++) - {for (int idim=0; idim - double PlanarIntersector::getValueRegardingOption(double val) const - { - if(_orientation==0) - return val; - if(_orientation==2) - return fabs(val); - if (( val > 0.0 && _orientation==1) || ( val < 0.0 && _orientation==-1 )) - return _orientation*val; - return 0.; - } - - template - int PlanarIntersector::projectionThis(double *Coords_A, double *Coords_B, int nb_NodesA, int nb_NodesB) - { - return projection(Coords_A,Coords_B,nb_NodesA,nb_NodesB,_dim_caracteristic*_precision,_max_distance_3Dsurf_intersect,_median_plane,_do_rotate); - } - - template - int PlanarIntersector::projection(double *Coords_A, double *Coords_B, - int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double median_plane, bool do_rotate) - { - double normal_A[3]={0,0,0}; - double normal_B[3]={0,0,0}; - double linear_comb[3]; - double proj; - bool same_orientation; - - //Find the normal to cells A and B - int i_A1=1; - while(i_A1(Coords_A,&Coords_A[SPACEDIM*i_A1])< epsilon) i_A1++; - int i_A2=i_A1+1; - crossprod(Coords_A, &Coords_A[SPACEDIM*i_A1], &Coords_A[SPACEDIM*i_A2],normal_A); - double normA = sqrt(dotprod(normal_A,normal_A)); - while(i_A2(Coords_A, &Coords_A[SPACEDIM*i_A1], &Coords_A[SPACEDIM*i_A2],normal_A); - i_A2++; - normA = sqrt(dotprod(normal_A,normal_A)); - - } - int i_B1=1; - while(i_B1(Coords_B,Coords_B+SPACEDIM*i_B1)< epsilon) i_B1++; - int i_B2=i_B1+1; - crossprod(Coords_B, Coords_B+SPACEDIM*i_B1, Coords_B+SPACEDIM*i_B2,normal_B); - double normB = sqrt(dotprod(normal_B,normal_B)); - while(i_B2(Coords_B, Coords_B+SPACEDIM*i_B1, Coords_B+SPACEDIM*i_B2,normal_B); - i_B2++; - normB = sqrt(dotprod(normal_B,normal_B)); - } - - //fabien option - if(md3DSurf>0.) - { - double coords_GA[3]; - for (int i=0;i<3;i++) - { - coords_GA[i]=0.; - for (int j=0;jmd3DSurf) - return 0; - } - if(i_A2(normal_A,normal_B)>=0; - - if(!same_orientation) - for(int idim =0; idim< SPACEDIM; idim++) normal_A[idim] *=-1; - - double normB= sqrt(dotprod(normal_B,normal_B)); - - for(int idim =0; idim< SPACEDIM; idim++) - linear_comb[idim] = median_plane*normal_A[idim]/normA + (1-median_plane)*normal_B[idim]/normB; - double norm= sqrt(dotprod(linear_comb,linear_comb)); - - //Necessarily: norm>epsilon, no need to check - for(int idim =0; idim< SPACEDIM; idim++) linear_comb[idim]/=norm; - - //Project the nodes of A and B on the median plane - for(int i_A=0; i_A(&Coords_A[SPACEDIM*i_A],linear_comb); - for(int idim =0; idim< SPACEDIM; idim++) - Coords_A[SPACEDIM*i_A+idim] -= proj*linear_comb[idim]; - } - for(int i_B=0; i_B(Coords_B+SPACEDIM*i_B,linear_comb); - for(int idim =0; idim< SPACEDIM; idim++) - Coords_B[SPACEDIM*i_B+idim] -= proj*linear_comb[idim]; - } - - //Buid the matrix sending A into the Oxy plane and apply it to A and B - if(do_rotate) - { - TranslationRotationMatrix rotation; - //rotate3DTriangle(Coords_A, &Coords_A[SPACEDIM*i_A1], &Coords_A[SPACEDIM*i_A2], rotation); - rotate3DTriangle(Coords_B, Coords_B+SPACEDIM*i_B1, Coords_B+SPACEDIM*i_B2, rotation); - for (int i=0; i(Coords_A,&Coords_A[i_A1])= " << distance2(Coords_A,&Coords_A[i_A1]) << std::endl; - std::cout << "abs(normal_A) = " << fabs(normal_A[0]) << " ; " <(&Coords_B[0],&Coords_B[i_B1])= " << distance2(Coords_B,Coords_B+i_B1) << std::endl; - std::cout << "normal_B = " << normal_B[0] << " ; " << normal_B[1] << " ; " << normal_B[2] << std::endl; - - return 1; - } - } - - template - void PlanarIntersector::rotate3DTriangle(double* PP1, double*PP2, double*PP3, - TranslationRotationMatrix& rotation_matrix) - { - //initializes - rotation_matrix.translate(PP1); - - double P2w[3]; - double P3w[3]; - P2w[0]=PP2[0]; P2w[1]=PP2[1];P2w[2]=PP2[2]; - P3w[0]=PP3[0]; P3w[1]=PP3[1];P3w[2]=PP3[2]; - - // translating to set P1 at the origin - for (int i=0; i<3; i++) - { - P2w[i]-=PP1[i]; - P3w[i]-=PP1[i]; - } - - // rotating to set P2 on the Oxy plane - TranslationRotationMatrix A; - A.rotate_x(P2w); - A.rotate_vector(P3w); - rotation_matrix.multiply(A); - - //rotating to set P2 on the Ox axis - TranslationRotationMatrix B; - B.rotate_z(P2w); - B.rotate_vector(P3w); - rotation_matrix.multiply(B); - - //rotating to set P3 on the Oxy plane - TranslationRotationMatrix C; - C.rotate_x(P3w); - rotation_matrix.multiply(C); - } -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx deleted file mode 100644 index bbb03d530..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP0P0_HXX__ -#define __PLANARINTERSECTORP0P0_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP0P0 : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - protected: - PlanarIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); - public: - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - /*! - * Contrary to intersectCells method here icellS and icellT are \b not in \b C mode but in mode of MyMeshType. - */ - double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS) { return asLeaf().intersectGeometry(icellT,icellS,nbNodesT,nbNodesS); } - protected: - ConcreteP0P0Intersector& asLeaf() { return static_cast(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P0.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P0.txx deleted file mode 100644 index 50a144976..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P0.txx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP0P0_TXX__ -#define __PLANARINTERSECTORP0P0_TXX__ - -#include "PlanarIntersectorP0P0.hxx" - -namespace INTERP_KERNEL -{ - template - PlanarIntersectorP0P0::PlanarIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, double medianPlane, - bool doRotate, int orientation, int printLevel): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel) - { - } - - template - int PlanarIntersectorP0P0::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfElements(); - } - - template - int PlanarIntersectorP0P0::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfElements(); - } - - template - void PlanarIntersectorP0P0::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - int nbNodesT=PlanarIntersector::_connIndexT[icellT+1]-PlanarIntersector::_connIndexT[icellT]; - typename MyMatrix::value_type& resRow=res[icellT]; - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - int iS=*iter; - int nbNodesS=PlanarIntersector::_connIndexS[iS+1]-PlanarIntersector::_connIndexS[iS]; - double surf=intersectGeometry(OTT::indFC(icellT),OTT::indFC(iS),nbNodesT,nbNodesS); - surf=PlanarIntersector::getValueRegardingOption(surf); - if(surf!=0.) - resRow.insert(std::make_pair(OTT::indFC(iS),surf)); - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx deleted file mode 100644 index f19ea4c2d..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP0P1_HXX__ -#define __PLANARINTERSECTORP0P1_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP0P1 : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - protected: - PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); - public: - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - /*! - * Contrary to intersectCells method here icellS and icellT are \b not in \b C mode but in mode of MyMeshType. - */ - double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad) { return asLeaf().intersectGeometryWithQuadrangle(quadrangle,sourceCoords,isSourceQuad); } - protected: - ConcreteP0P1Intersector& asLeaf() { return static_cast(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P1.txx deleted file mode 100644 index 4f87fbaa7..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1.txx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP0P1_TXX__ -#define __PLANARINTERSECTORP0P1_TXX__ - -#include "PlanarIntersectorP0P1.hxx" -#include "InterpolationUtils.hxx" -#include "CellModel.hxx" - -namespace INTERP_KERNEL -{ - template - PlanarIntersectorP0P1::PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, double medianPlane, - bool doRotate, int orientation, int printLevel): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel) - { - } - - template - int PlanarIntersectorP0P1::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfNodes(); - } - - template - int PlanarIntersectorP0P1::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfElements(); - } - - /*! - * This methods split on the fly, into triangles in order to compute dual mesh of target cell (with icellT id in target mesh in C mode). - */ - template - void PlanarIntersectorP0P1::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - int nbNodesT=PlanarIntersector::_connIndexT[icellT+1]-PlanarIntersector::_connIndexT[icellT]; - double triangle[9]; - double quadrangle[12]; - std::vector sourceCellCoords; - int orientation=1; - const ConnType *startOfCellNodeConn=PlanarIntersector::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[icellT]); - for(int nodeIdT=0;nodeIdT::coo2C(startOfCellNodeConn[nodeIdT]); - std::copy(PlanarIntersector::_coordsT+curNodeTInCmode*SPACEDIM, - PlanarIntersector::_coordsT+curNodeTInCmode*SPACEDIM+SPACEDIM,triangle); - typename MyMatrix::value_type& resRow=res[curNodeTInCmode]; - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - int iS=*iter; - PlanarIntersector::getRealSourceCoordinates(OTT::indFC(iS),sourceCellCoords); - for(int subTriT=1;subTriT<=nbNodesT-2;subTriT++) - { - std::copy(PlanarIntersector::_coordsT+OTT::coo2C(startOfCellNodeConn[(nodeIdT+subTriT)%nbNodesT])*SPACEDIM, - PlanarIntersector::_coordsT+OTT::coo2C(startOfCellNodeConn[(nodeIdT+subTriT)%nbNodesT])*SPACEDIM+SPACEDIM, - triangle+SPACEDIM); - std::copy(PlanarIntersector::_coordsT+OTT::coo2C(startOfCellNodeConn[(nodeIdT+subTriT+1)%nbNodesT])*SPACEDIM, - PlanarIntersector::_coordsT+OTT::coo2C(startOfCellNodeConn[(nodeIdT+subTriT+1)%nbNodesT])*SPACEDIM+SPACEDIM, - triangle+2*SPACEDIM); - fillDualCellOfTri(triangle,quadrangle); - std::vector sourceCellCoordsTmp(sourceCellCoords); - if(SPACEDIM==3) - orientation=PlanarIntersector::projectionThis(&sourceCellCoordsTmp[0],quadrangle,sourceCellCoords.size()/SPACEDIM,4); - NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(OTT::indFC(iS)); - double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,sourceCellCoordsTmp,CellModel::getCellModel(tS).isQuadratic()); - surf=PlanarIntersector::getValueRegardingOption(surf); - if(surf!=0.) - { - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(iS)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(iS),surf)); - else - { - double val=(*iterRes).second+surf; - resRow.erase(OTT::indFC(iS)); - resRow.insert(std::make_pair(OTT::indFC(iS),val)); - } - } - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx deleted file mode 100644 index 8426e7e6e..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP0P1PL_HXX__ -#define __PLANARINTERSECTORP0P1PL_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP0P1PL : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PlanarIntersectorP0P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation); - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx deleted file mode 100644 index 29dba1bb9..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP0P1PL_TXX__ -#define __PLANARINTERSECTORP0P1PL_TXX__ - -#include "PlanarIntersectorP0P1PL.hxx" -#include "PlanarIntersector.txx" -#include "CellModel.hxx" - -#include "PointLocatorAlgos.txx" - -namespace INTERP_KERNEL -{ - template - PlanarIntersectorP0P1PL::PlanarIntersectorP0P1PL(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double md3DSurf, - double medianPlane, double precision, int orientation): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,true,orientation,0) - { - } - - template - void PlanarIntersectorP0P1PL::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - std::vector< std::vector > coordsOfSources(icellsS.size()); - int ii=0; - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++,ii++) - PlanarIntersector::getRealSourceCoordinates(OTT::indFC(*iter),coordsOfSources[ii]); - const ConnType *startOfCellNodeConnT=PlanarIntersector::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[icellT]); - std::vector coordsTarget; - PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),coordsTarget); - int nbNodesT=coordsTarget.size()/SPACEDIM; - ii=0; - for(typename std::vector::const_iterator iter2=icellsS.begin();iter2!=icellsS.end();iter2++,ii++) - { - std::vector tmpSource(coordsOfSources[ii]); - std::vector tmpTarget(coordsTarget); - if(SPACEDIM==3) - PlanarIntersector::projectionThis(&tmpSource[0],&tmpTarget[0],tmpSource.size()/SPACEDIM,nbNodesT); - for(int nodeIdT=0;nodeIdT::isElementContainsPointAlg2D(&tmpTarget[0]+nodeIdT*SPACEDIM,&tmpSource[0],tmpSource.size()/SPACEDIM,PlanarIntersector::_precision)) - { - ConnType curNodeTInCmode=OTT::coo2C(startOfCellNodeConnT[nodeIdT]); - typename MyMatrix::value_type& resRow=res[curNodeTInCmode]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(*iter2)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(*iter2),1.)); - } - } - } - } - - template - int PlanarIntersectorP0P1PL::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfNodes(); - } - - template - int PlanarIntersectorP0P1PL::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfElements(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx deleted file mode 100644 index 02fe06137..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P0_HXX__ -#define __PLANARINTERSECTORP1P0_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP1P0 : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - protected: - PlanarIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); - public: - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - /*! - * Contrary to intersectCells method here icellS and icellT are \b not in \b C mode but in mode of MyMeshType. - */ - double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad) { return asLeaf().intersectGeometryWithQuadrangle(quadrangle,sourceCoords,isSourceQuad); } - protected: - ConcreteP1P0Intersector& asLeaf() { return static_cast(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx deleted file mode 100644 index 3bc961fa6..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P0_TXX__ -#define __PLANARINTERSECTORP1P0_TXX__ - -#include "PlanarIntersectorP1P0.hxx" -#include "InterpolationUtils.hxx" - -namespace INTERP_KERNEL -{ - template - PlanarIntersectorP1P0::PlanarIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, double medianPlane, - bool doRotate, int orientation, int printLevel): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel) - { - } - - template - int PlanarIntersectorP1P0::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfElements(); - } - - template - int PlanarIntersectorP1P0::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfNodes(); - } - - /*! - * This methods split on the fly, into triangles in order to compute dual mesh of target cell (with icellT id in target mesh in C mode). - */ - template - void PlanarIntersectorP1P0::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - double triangle[9]; - double quadrangle[12]; - std::vector targetCellCoords; - int orientation=1; - PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),targetCellCoords); - NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(OTT::indFC(icellT)); - bool isTargetQuad=CellModel::getCellModel(tT).isQuadratic(); - typename MyMatrix::value_type& resRow=res[icellT]; - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - int iS=*iter; - int nbNodesS=PlanarIntersector::_connIndexS[iS+1]-PlanarIntersector::_connIndexS[iS]; - const ConnType *startOfCellNodeConn=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[iS]); - for(int nodeIdS=0;nodeIdS::coo2C(startOfCellNodeConn[nodeIdS]); - std::copy(PlanarIntersector::_coordsS+curNodeSInCmode*SPACEDIM, - PlanarIntersector::_coordsS+curNodeSInCmode*SPACEDIM+SPACEDIM,triangle); - for(int subTriS=1;subTriS<=nbNodesS-2;subTriS++) - { - std::copy(PlanarIntersector::_coordsS+OTT::coo2C(startOfCellNodeConn[(nodeIdS+subTriS)%nbNodesS])*SPACEDIM, - PlanarIntersector::_coordsS+OTT::coo2C(startOfCellNodeConn[(nodeIdS+subTriS)%nbNodesS])*SPACEDIM+SPACEDIM, - triangle+SPACEDIM); - std::copy(PlanarIntersector::_coordsS+OTT::coo2C(startOfCellNodeConn[(nodeIdS+subTriS+1)%nbNodesS])*SPACEDIM, - PlanarIntersector::_coordsS+OTT::coo2C(startOfCellNodeConn[(nodeIdS+subTriS+1)%nbNodesS])*SPACEDIM+SPACEDIM, - triangle+2*SPACEDIM); - fillDualCellOfTri(triangle,quadrangle); - std::vector targetCellCoordsTmp(targetCellCoords); - if(SPACEDIM==3) - orientation=PlanarIntersector::projectionThis(&targetCellCoordsTmp[0],quadrangle,targetCellCoords.size()/SPACEDIM,4); - double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,targetCellCoordsTmp,isTargetQuad); - surf=PlanarIntersector::getValueRegardingOption(surf); - if(surf!=0.) - { - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),surf)); - else - { - double val=(*iterRes).second+surf; - resRow.erase(OTT::indFC(curNodeSInCmode)); - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); - } - } - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx deleted file mode 100644 index d58cffc9c..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2007-2010 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 __PlanarIntersectorP1P0Bary_HXX__ -#define __PlanarIntersectorP1P0Bary_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP1P0Bary : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - protected: - PlanarIntersectorP1P0Bary(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); - public: - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - /*! - * Contrary to intersectCells method here icellS and icellT are \b not in \b C mode but in mode of MyMeshType. - */ - double intersectGeoBary(const std::vector& targetCell, - bool targetCellQuadratic, - const double * sourceTria, - std::vector& res) - { return asLeaf().intersectGeoBary(targetCell,targetCellQuadratic,sourceTria,res); } - protected: - ConcreteP1P0Intersector& asLeaf() { return static_cast(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx deleted file mode 100644 index dd59b8c42..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2007-2010 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 __PlanarIntersectorP1P0Bary_TXX__ -#define __PlanarIntersectorP1P0Bary_TXX__ - -#include "PlanarIntersectorP1P0Bary.hxx" -#include "InterpolationUtils.hxx" - -#define PLAN_INTERSECTOR PlanarIntersectorP1P0Bary -#define PLAN_INTER_TEMPLATE template - -namespace INTERP_KERNEL -{ - PLAN_INTER_TEMPLATE - PLAN_INTERSECTOR::PlanarIntersectorP1P0Bary(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, - double md3DSurf, double medianPlane, - bool doRotate, int orientation, int printLevel): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf, - medianPlane,doRotate,orientation,printLevel) - { - // SPEC: - // "Limitation. For the P1P0 barycentric improvement only triangle source cells in 2D and - // tetrahedrons in 3D will be supported by interpolators. If a non - // triangle/tetrahedron source cell is detected an INTERP_KERNEL::Exception should be thrown." - - // Check types of source elements here rather than in intersectCells() since a wrong type can be - // found late after a long time of calculation. - - const unsigned long numSrcElems = meshS.getNumberOfElements(); - for(unsigned long i = 0 ; i < numSrcElems ; ++i) - if ( meshS.getTypeOfElement( OTT::indFC( i )) != NORM_TRI3 ) - throw INTERP_KERNEL::Exception("P1P0 barycentric algorithm works only with triangular source meshes"); - } - - PLAN_INTER_TEMPLATE - int PLAN_INTERSECTOR::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfElements(); - } - - PLAN_INTER_TEMPLATE - int PLAN_INTERSECTOR::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfNodes(); - } - - /*! - * This method computes a value per each node of each source triangle for target. - */ - PLAN_INTER_TEMPLATE - void PLAN_INTERSECTOR::intersectCells(ConnType icellT, - const std::vector& icellsS, - MyMatrix& res) - { - int orientation=1; - std::vector srcTriaCoords, tgtCellCoords, tgtCellCoordsTmp, nodeCeffs; - - // target cell data - PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),tgtCellCoords); - std::vector * tgtCoords = & tgtCellCoords; - int tgtNbNodes = tgtCellCoords.size()/SPACEDIM; - NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(OTT::indFC(icellT)); - bool isTargetQuad=CellModel::getCellModel(tT).isQuadratic(); - - typename MyMatrix::value_type& resRow=res[icellT]; - - // treat each source triangle - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - int iS=*iter; - PlanarIntersector::getRealSourceCoordinates(OTT::indFC(iS),srcTriaCoords); - const ConnType *startOfCellNodeConn=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[iS]); - if(SPACEDIM==3) - { - tgtCellCoordsTmp = tgtCellCoords; - tgtCoords = & tgtCellCoordsTmp; - orientation=PlanarIntersector::projectionThis(&tgtCellCoordsTmp[0], &srcTriaCoords[0], - tgtNbNodes, 3); - } - //double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,targetCellCoordsTmp,isTargetQuad); - double surf=orientation*intersectGeoBary( *tgtCoords, isTargetQuad, &srcTriaCoords[0], nodeCeffs ); - surf=PlanarIntersector::getValueRegardingOption(surf); - if(surf!=0.) - { - for(int nodeIdS=0;nodeIdS<3;nodeIdS++) - { - ConnType curNodeS=startOfCellNodeConn[nodeIdS]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(curNodeS); - if(iterRes!=resRow.end()) - { - nodeCeffs[nodeIdS] += iterRes->second; - resRow.erase( curNodeS ); - } - resRow.insert(std::make_pair(curNodeS,nodeCeffs[nodeIdS])); - } - } - } - } -} -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx deleted file mode 100644 index 31fda104a..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P0PL_HXX__ -#define __PLANARINTERSECTORP1P0PL_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP1P0PL : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PlanarIntersectorP1P0PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation); - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx deleted file mode 100644 index 4973f93d1..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P0PL_TXX__ -#define __PLANARINTERSECTORP1P0PL_TXX__ - -#include "PlanarIntersectorP1P0PL.hxx" -#include "PlanarIntersector.txx" -#include "CellModel.hxx" - -#include "PointLocatorAlgos.txx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "MeshUtils.hxx" - -namespace INTERP_KERNEL -{ - template - PlanarIntersectorP1P0PL::PlanarIntersectorP1P0PL(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double md3DSurf, - double medianPlane, double precision, int orientation): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,true,orientation,0) - { - } - - template - void PlanarIntersectorP1P0PL::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - std::vector CoordsT; - typename MyMatrix::value_type& resRow=res[icellT]; - PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),CoordsT); - double baryT[SPACEDIM]; - double baryTTmp[SPACEDIM]; - calculateBarycenterDyn2(&CoordsT[0],CoordsT.size()/SPACEDIM,baryT); - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(OTT::indFC(*iter)); - if(tS!=NORM_TRI3) - throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==2. Only TRI3 supported !"); - std::vector CoordsS; - PlanarIntersector::getRealSourceCoordinates(OTT::indFC(*iter),CoordsS); - if(SPACEDIM==2) - { - std::copy(baryT,baryT+SPACEDIM,baryTTmp); - } - else - { - double littleTargetCell[9]; - std::copy(baryT,baryT+3,littleTargetCell); - std::copy(CoordsT.begin(),CoordsT.begin()+3,littleTargetCell+3); - std::copy(CoordsT.begin()+3,CoordsT.begin()+6,littleTargetCell+6); - PlanarIntersector::projectionThis(&CoordsS[0],littleTargetCell,3,3); - std::copy(littleTargetCell,littleTargetCell+3,baryTTmp); - } - if(PointLocatorAlgos::isElementContainsPointAlg2D(baryTTmp,&CoordsS[0],3,PlanarIntersector::_precision)) - { - double resLoc[3]; - barycentric_coords(&CoordsS[0],baryTTmp,resLoc); - const ConnType *startOfCellNodeConnS=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[*iter]); - for(int nodeIdS=0;nodeIdS<3;nodeIdS++) - { - if(fabs(resLoc[nodeIdS])>PlanarIntersector::_precision) - { - ConnType curNodeSInCmode=OTT::coo2C(startOfCellNodeConnS[nodeIdS]); - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),resLoc[nodeIdS])); - else - { - double val=(*iterRes).second+resLoc[nodeIdS]; - resRow.erase(OTT::indFC(curNodeSInCmode)); - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); - } - } - } - } - } - } - - template - int PlanarIntersectorP1P0PL::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfElements(); - } - - template - int PlanarIntersectorP1P0PL::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfNodes(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx deleted file mode 100644 index 4278bb39a..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P1_HXX__ -#define __PLANARINTERSECTORP1P1_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP1P1 : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - protected: - PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); - public: - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - - double intersectGeometryGeneral(const std::vector& targetCoords, const std::vector& sourceCoords) { return asLeaf().intersectGeometryGeneral(targetCoords,sourceCoords); } - protected: - ConcreteP1P1Intersector& asLeaf() { return static_cast(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx deleted file mode 100644 index dcd85a694..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P1_TXX__ -#define __PLANARINTERSECTORP1P1_TXX__ - -#include "PlanarIntersectorP1P1.hxx" -#include "InterpolationUtils.hxx" -#include "CellModel.hxx" - -namespace INTERP_KERNEL -{ - template - PlanarIntersectorP1P1::PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, double medianPlane, - bool doRotate, int orientation, int printLevel): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel) - { - } - - template - int PlanarIntersectorP1P1::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfNodes(); - } - - template - int PlanarIntersectorP1P1::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfNodes(); - } - - /*! - * This methods split on the fly, into triangles in order to compute dual mesh of target cell (with icellT id in target mesh in C mode). - */ - template - void PlanarIntersectorP1P1::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - int nbNodesT=PlanarIntersector::_connIndexT[icellT+1]-PlanarIntersector::_connIndexT[icellT]; - int orientation=1; - const ConnType *startOfCellNodeConn=PlanarIntersector::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[icellT]); - std::vector polygT; - PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),polygT); - for(int nodeIdT=0;nodeIdT::coo2C(startOfCellNodeConn[nodeIdT]); - PlanarIntersector::getRealTargetCoordinatesPermute(OTT::indFC(icellT),nodeIdT,polygT); - std::vector polygDualT(SPACEDIM*2*(nbNodesT-1)); - fillDualCellOfPolyg(&polygT[0],polygT.size()/SPACEDIM,&polygDualT[0]); - typename MyMatrix::value_type& resRow=res[curNodeTInCmode]; - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - int iS=*iter; - int nbNodesS=PlanarIntersector::_connIndexS[iS+1]-PlanarIntersector::_connIndexS[iS]; - const ConnType *startOfCellNodeConnS=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[iS]); - for(int nodeIdS=0;nodeIdS::coo2C(startOfCellNodeConnS[nodeIdS]); - std::vector polygS; - PlanarIntersector::getRealSourceCoordinatesPermute(OTT::indFC(iS),nodeIdS,polygS); - std::vector polygDualS(SPACEDIM*2*(nbNodesS-1)); - fillDualCellOfPolyg(&polygS[0],polygS.size()/SPACEDIM,&polygDualS[0]); - std::vector polygDualTTmp(polygDualT); - if(SPACEDIM==3) - orientation=PlanarIntersector::projectionThis(&polygDualS[0],&polygDualTTmp[0],polygDualS.size()/SPACEDIM,polygDualT.size()/SPACEDIM); - double surf=orientation*intersectGeometryGeneral(polygDualTTmp,polygDualS); - surf=PlanarIntersector::getValueRegardingOption(surf); - if(surf!=0.) - { - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),surf)); - else - { - double val=(*iterRes).second+surf; - resRow.erase(OTT::indFC(curNodeSInCmode)); - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); - } - } - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx deleted file mode 100644 index a93b16bfa..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P1PL_HXX__ -#define __PLANARINTERSECTORP1P1PL_HXX__ - -#include "PlanarIntersector.hxx" - -namespace INTERP_KERNEL -{ - template - class PlanarIntersectorP1P1PL : public PlanarIntersector - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PlanarIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation); - void intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx deleted file mode 100644 index 76eaaab10..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2007-2010 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 __PLANARINTERSECTORP1P1PL_TXX__ -#define __PLANARINTERSECTORP1P1PL_TXX__ - -#include "PlanarIntersectorP1P1PL.hxx" -#include "PlanarIntersector.txx" -#include "CellModel.hxx" - -#include "PointLocatorAlgos.txx" -#include "MeshUtils.hxx" - -namespace INTERP_KERNEL -{ - template - PlanarIntersectorP1P1PL::PlanarIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double md3DSurf, - double medianPlane, double precision, int orientation): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,true,orientation,0) - { - } - - template - void PlanarIntersectorP1P1PL::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - std::vector CoordsT; - PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),CoordsT); - int nbOfNodesT=CoordsT.size()/SPACEDIM; - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(OTT::indFC(*iter)); - if(tS!=NORM_TRI3) - throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==2. Only TRI3 supported !"); - std::vector CoordsS; - PlanarIntersector::getRealSourceCoordinates(OTT::indFC(*iter),CoordsS); - std::vector CoordsTTmp(CoordsT); - if(SPACEDIM==3) - PlanarIntersector::projectionThis(&CoordsS[0],&CoordsTTmp[0],CoordsS.size()/SPACEDIM,nbOfNodesT); - const ConnType *startOfCellNodeConnT=PlanarIntersector::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[icellT]); - for(int nodeIdT=0;nodeIdT::ind2C(startOfCellNodeConnT[nodeIdT])]; - if( PointLocatorAlgos::isElementContainsPointAlg2D(&CoordsTTmp[nodeIdT*SPACEDIM],&CoordsS[0],3,PlanarIntersector::_precision) ) - { - double resLoc[3]; - barycentric_coords(&CoordsS[0],&CoordsTTmp[nodeIdT*SPACEDIM],resLoc); - const ConnType *startOfCellNodeConnS=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[*iter]); - for(int nodeIdS=0;nodeIdS<3;nodeIdS++) - { - if(fabs(resLoc[nodeIdS])>PlanarIntersector::_precision) - { - ConnType curNodeSInCmode=OTT::coo2C(startOfCellNodeConnS[nodeIdS]); - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),resLoc[nodeIdS])); - else - { - double val=(*iterRes).second+resLoc[nodeIdS]; - resRow.erase(OTT::indFC(curNodeSInCmode)); - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); - } - } - } - } - } - } - } - - template - int PlanarIntersectorP1P1PL::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfNodes(); - } - - template - int PlanarIntersectorP1P1PL::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_meshS.getNumberOfNodes(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator2DIntersector.hxx b/src/INTERP_KERNEL/PointLocator2DIntersector.hxx deleted file mode 100644 index 6ee193353..000000000 --- a/src/INTERP_KERNEL/PointLocator2DIntersector.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATORINTERSECTOR_HXX__ -#define __POINTLOCATORINTERSECTOR_HXX__ - -#include "PlanarIntersectorP0P0.hxx" -#include "PlanarIntersectorP0P1.hxx" -#include "PlanarIntersectorP1P0.hxx" -#include "PlanarIntersectorP1P1.hxx" -#include "PlanarIntersectorP1P0Bary.hxx" - -namespace INTERP_KERNEL -{ - class QuadraticPolygon; - - template class InterpType> - class PointLocator2DIntersector : public InterpType > - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PointLocator2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation); - double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS); - double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad); - double intersectGeometryGeneral(const std::vector& targetCoords, const std::vector& sourceCoords); - double intersectGeoBary(const std::vector& targetCell, bool targetCellQuadratic, const double *sourceCell, std::vector& res); - private: - QuadraticPolygon *buildPolygonFrom(const std::vector& coords, NormalizedCellType type); - QuadraticPolygon *buildPolygonAFrom(ConnType cell, int nbOfPoints, NormalizedCellType type); - QuadraticPolygon *buildPolygonBFrom(ConnType cell, int nbOfPoints, NormalizedCellType type); - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator2DIntersector.txx b/src/INTERP_KERNEL/PointLocator2DIntersector.txx deleted file mode 100644 index f6a329047..000000000 --- a/src/INTERP_KERNEL/PointLocator2DIntersector.txx +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATORINTERSECTOR_TXX__ -#define __POINTLOCATORINTERSECTOR_TXX__ - -#include "PointLocator2DIntersector.hxx" -#include "PlanarIntersectorP0P0.txx" -#include "PlanarIntersectorP0P1.txx" -#include "PlanarIntersectorP1P0.txx" -#include "PlanarIntersectorP1P1.txx" -#include "PlanarIntersectorP1P0Bary.txx" -#include "CellModel.hxx" - -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "PointLocatorAlgos.txx" - -#define PTLOC2D_INTERSECTOR PointLocator2DIntersector -#define INTERSECTOR_TEMPLATE template class InterpType> - -namespace INTERP_KERNEL -{ - INTERSECTOR_TEMPLATE - PTLOC2D_INTERSECTOR::PointLocator2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double md3DSurf, double medianPlane, - double precision, int orientation): - InterpType(meshT,meshS,dimCaracteristic, precision, md3DSurf, medianPlane, true, orientation, 0) - { - } - - INTERSECTOR_TEMPLATE - double PTLOC2D_INTERSECTOR::intersectGeometry(ConnType icellT, ConnType icellS, - ConnType nbNodesT, ConnType nbNodesS) - { - int orientation = 1; - std::vector CoordsT; - std::vector CoordsS; - PlanarIntersector::getRealCoordinates(icellT,icellS,nbNodesT,nbNodesS,CoordsT,CoordsS,orientation); - NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(icellT); - QuadraticPolygon *pT=buildPolygonFrom(CoordsT,tT); - double baryT[SPACEDIM]; - pT->getBarycenterGeneral(baryT); - delete pT; - if(PointLocatorAlgos::isElementContainsPointAlg2D(baryT,&CoordsS[0],nbNodesS,InterpType::_precision)) - return 1.; - return 0.; - } - - INTERSECTOR_TEMPLATE - double PTLOC2D_INTERSECTOR::intersectGeometryWithQuadrangle(const double * quadrangle, - const std::vector& sourceCoords, - bool isSourceQuad) - { - int nbOfSourceNodes=sourceCoords.size()/SPACEDIM; - std::vector nodes2(nbOfSourceNodes); - for(int i=0;igetBarycenter(bary); - delete p2; - if( PointLocatorAlgos::isElementContainsPointAlg2D(bary,quadrangle,4) ) - return 1.; - return 0.; - } - - INTERSECTOR_TEMPLATE - double PTLOC2D_INTERSECTOR::intersectGeometryGeneral(const std::vector& targetCoords, - const std::vector& sourceCoords) - { - int nbOfTargetNodes=targetCoords.size()/SPACEDIM; - int nbOfSourceNodes=sourceCoords.size()/SPACEDIM; - std::vector nodes2(nbOfSourceNodes); - for(int i=0;igetBarycenterGeneral(bary); - delete p; - if( PointLocatorAlgos::isElementContainsPointAlg2D(bary,&targetCoords[0],nbOfTargetNodes) ) - return 1.; - return 0.; - } - - //================================================================================ - /*! - * \brief Intersect a triangle and a polygon for P1P0 barycentric algorithm - * \param targetCell - list of coordinates of target polygon in full interlace - * \param targetCellQuadratic - specifies if target polygon is quadratic or not - * \param sourceTria - list of coordinates of source triangle - * \param res - coefficients a,b and c associated to nodes of sourceTria - */ - //================================================================================ - - INTERSECTOR_TEMPLATE - double PTLOC2D_INTERSECTOR::intersectGeoBary(const std::vector& targetCell, - bool targetCellQuadratic, - const double * sourceTria, - std::vector& res) - { - throw INTERP_KERNEL::Exception("intersectGeoBary incompatible with PointLocator. Desactivate P1P0Bary to avoid the problem"); - return 0.; - } - - INTERSECTOR_TEMPLATE - QuadraticPolygon *PTLOC2D_INTERSECTOR::buildPolygonFrom(const std::vector& coords, NormalizedCellType type) - { - int nbNodes=coords.size()/SPACEDIM; - std::vector nodes(nbNodes); - for(int i=0;i::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[OTT::ind2C(cell)]); - std::vector nodes(nbOfPoints); - for(int i=0;i::_coordsT+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(CellModel::getCellModel(type).isQuadratic()) - return QuadraticPolygon::buildLinearPolygon(nodes); - else - return QuadraticPolygon::buildArcCirclePolygon(nodes); - } - - INTERSECTOR_TEMPLATE - QuadraticPolygon *PTLOC2D_INTERSECTOR::buildPolygonBFrom(ConnType cell, int nbOfPoints, NormalizedCellType type) - { - const ConnType *startOfCellNodeConn=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[OTT::ind2C(cell)]); - std::vector nodes(nbOfPoints); - for(int i=0;i::_coordsS+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(type!=NORM_TRI6 && type!=NORM_QUAD8) - return QuadraticPolygon::buildLinearPolygon(nodes); - else - return QuadraticPolygon::buildArcCirclePolygon(nodes); - } -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx deleted file mode 100644 index 7c9df49ed..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP0P0_HXX__ -#define __POINTLOCATOR3DINTERSECTORP0P0_HXX__ - -#include "Intersector3DP0P0.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - template - class PointLocator3DIntersectorP0P0 : public Intersector3DP0P0 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PointLocator3DIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision); - ~PointLocator3DIntersectorP0P0(); - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - protected: - double _precision; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx deleted file mode 100644 index b88c0b468..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP0P0_TXX__ -#define __POINTLOCATOR3DINTERSECTORP0P0_TXX__ - -#include "PointLocator3DIntersectorP0P0.hxx" -#include "Intersector3DP0P0.txx" -#include "MeshUtils.hxx" - -#include "SplitterTetra.txx" -#include "PointLocatorAlgos.txx" - -namespace INTERP_KERNEL -{ - - /** - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - */ - template - PointLocator3DIntersectorP0P0::PointLocator3DIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision): - Intersector3DP0P0(targetMesh,srcMesh),_precision(precision) - { - } - - template - PointLocator3DIntersectorP0P0::~PointLocator3DIntersectorP0P0() - { - } - - /** - * - * @param targetCell in C mode. - * @param srcCells in C mode. - * - */ - template - void PointLocator3DIntersectorP0P0::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - std::vector CoordsT; - Intersector3DP0P0::getRealTargetCoordinates(OTT::indFC(targetCell),CoordsT); - double bary[SPACEDIM]; - calculateBarycenterDyn2(&CoordsT[0],CoordsT.size()/SPACEDIM,bary); - typename MyMatrix::value_type& resRow=res[targetCell]; - const double *coordsS=Intersector3DP0P0::_src_mesh.getCoordinatesPtr(); - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - NormalizedCellType tS=Intersector3DP0P0::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); - const CellModel& cmTypeS=CellModel::getCellModel(tS); - std::vector connOfCurCellS; - Intersector3DP0P0::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); - if(PointLocatorAlgos::isElementContainsPointAlg3D(bary,&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision)) - { - resRow.insert(std::make_pair(OTT::indFC(*iterCellS),1)); - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx deleted file mode 100644 index 9b8c986b1..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP0P1_HXX__ -#define __POINTLOCATOR3DINTERSECTORP0P1_HXX__ - -#include "Intersector3DP0P1.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - template - class PointLocator3DIntersectorP0P1 : public Intersector3DP0P1 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PointLocator3DIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision); - ~PointLocator3DIntersectorP0P1(); - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - protected: - double _precision; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx deleted file mode 100644 index 1f84569d3..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP0P1_TXX__ -#define __POINTLOCATOR3DINTERSECTORP0P1_TXX__ - -#include "PointLocator3DIntersectorP0P1.hxx" -#include "Intersector3DP0P1.txx" -#include "MeshUtils.hxx" - -namespace INTERP_KERNEL -{ - - /** - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - */ - template - PointLocator3DIntersectorP0P1::PointLocator3DIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision): - Intersector3DP0P1(targetMesh,srcMesh),_precision(precision) - { - } - - template - PointLocator3DIntersectorP0P1::~PointLocator3DIntersectorP0P1() - { - } - - /** - * - * @param targetCell in C mode. - * @param srcCells in C mode. - * - */ - template - void PointLocator3DIntersectorP0P1::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - std::vector coordsTarget; - Intersector3DP0P1::getRealTargetCoordinates(OTT::indFC(targetCell),coordsTarget); - int nbNodesT=coordsTarget.size()/SPACEDIM; - const double *coordsS=Intersector3DP0P1::_src_mesh.getCoordinatesPtr(); - const ConnType *startOfCellNodeConnT=Intersector3DP0P1::getStartConnOfTargetCell(targetCell); - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - NormalizedCellType tS=Intersector3DP0P1::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); - const CellModel& cmTypeS=CellModel::getCellModel(tS); - std::vector connOfCurCellS; - Intersector3DP0P1::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); - for(int nodeIdT=0;nodeIdT::isElementContainsPointAlg3D(&coordsTarget[nodeIdT*SPACEDIM],&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision)) - { - ConnType curNodeTInCmode=OTT::coo2C(startOfCellNodeConnT[nodeIdT]); - typename MyMatrix::value_type& resRow=res[curNodeTInCmode]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(*iterCellS)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(*iterCellS),1.)); - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx deleted file mode 100644 index e3da28795..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP1P0_HXX__ -#define __POINTLOCATOR3DINTERSECTORP1P0_HXX__ - -#include "Intersector3DP1P0.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - template - class PointLocator3DIntersectorP1P0 : public Intersector3DP1P0 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PointLocator3DIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision); - ~PointLocator3DIntersectorP1P0(); - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - protected: - double _precision; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx deleted file mode 100644 index f67c2597d..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP1P0_TXX__ -#define __POINTLOCATOR3DINTERSECTORP1P0_TXX__ - -#include "PointLocator3DIntersectorP1P0.hxx" -#include "Intersector3DP1P0.txx" -#include "MeshUtils.hxx" - -namespace INTERP_KERNEL -{ - /** - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - * - * WARNING : in _split attribute, sourceMesh and targetMesh are switched in order to fit intersectCells feature. - */ - template - PointLocator3DIntersectorP1P0::PointLocator3DIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision):Intersector3DP1P0(targetMesh,srcMesh),_precision(precision) - { - } - - template - PointLocator3DIntersectorP1P0::~PointLocator3DIntersectorP1P0() - { - } - - /** - * @param targetCell in C mode. - * @param srcCells in C mode. - * - * WARNING : for all methods on _split object source and target are switched ! - */ - template - void PointLocator3DIntersectorP1P0::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - std::vector CoordsT; - typename MyMatrix::value_type& resRow=res[targetCell]; - const double *coordsS=Intersector3DP1P0::_src_mesh.getCoordinatesPtr(); - Intersector3DP1P0::getRealTargetCoordinates(OTT::indFC(targetCell),CoordsT); - double baryT[SPACEDIM]; - calculateBarycenterDyn2(&CoordsT[0],CoordsT.size()/SPACEDIM,baryT); - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - NormalizedCellType tS=Intersector3DP1P0::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); - if(tS!=NORM_TETRA4) - throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only TETRA4 supported !"); - const CellModel& cmTypeS=CellModel::getCellModel(tS); - std::vector connOfCurCellS; - Intersector3DP1P0::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); - if( PointLocatorAlgos::isElementContainsPointAlg3D(baryT,&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision) ) - { - double resLoc[4]; - std::vector srcCell; - Intersector3DP1P0::getRealSourceCoordinates(OTT::indFC(*iterCellS),srcCell); - std::vector eap(4); - eap[0]=&srcCell[0]; eap[1]=&srcCell[3]; eap[2]=&srcCell[6]; eap[3]=&srcCell[9]; - barycentric_coords(eap,baryT,resLoc); - const ConnType *startOfCellNodeConn=Intersector3DP1P0::getStartConnOfSourceCell(*iterCellS); - for(int nodeIdS=0;nodeIdS<4;nodeIdS++) - { - if(fabs(resLoc[nodeIdS])>_precision) - { - ConnType curNodeSInCmode=OTT::coo2C(startOfCellNodeConn[nodeIdS]); - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),resLoc[nodeIdS])); - else - { - double val=(*iterRes).second+resLoc[nodeIdS]; - resRow.erase(OTT::indFC(curNodeSInCmode)); - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); - } - } - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx deleted file mode 100644 index 402124fa4..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP1P1_HXX__ -#define __POINTLOCATOR3DINTERSECTORP1P1_HXX__ - -#include "Intersector3DP1P1.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - template - class PointLocator3DIntersectorP1P1 : public Intersector3DP1P1 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - PointLocator3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision); - ~PointLocator3DIntersectorP1P1(); - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - protected: - double _precision; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx deleted file mode 100644 index 78bbb7655..000000000 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATOR3DINTERSECTORP1P1_TXX__ -#define __POINTLOCATOR3DINTERSECTORP1P1_TXX__ - -#include "PointLocator3DIntersectorP1P1.hxx" -#include "Intersector3DP1P1.txx" -#include "MeshUtils.hxx" - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating object from target cell global number - * - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - */ - template - PointLocator3DIntersectorP1P1::PointLocator3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision): - Intersector3DP1P1(targetMesh,srcMesh),_precision(precision) - { - } - - template - PointLocator3DIntersectorP1P1::~PointLocator3DIntersectorP1P1() - { - } - - /** - * @param targetCell in C mode. - * @param srcCells in C mode. - */ - template - void PointLocator3DIntersectorP1P1::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - std::vector CoordsT; - Intersector3DP1P1::getRealTargetCoordinates(OTT::indFC(targetCell),CoordsT); - int nbOfNodesT=CoordsT.size()/SPACEDIM; - const double *coordsS=Intersector3DP1P1::_src_mesh.getCoordinatesPtr(); - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - NormalizedCellType tS=Intersector3DP1P1::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); - if(tS!=NORM_TETRA4) - throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only TETRA4 supported !"); - const CellModel& cmTypeS=CellModel::getCellModel(tS); - const ConnType *startOfCellNodeConnT=Intersector3DP1P1::getStartConnOfTargetCell(targetCell); - for(int nodeIdT=0;nodeIdT::ind2C(startOfCellNodeConnT[nodeIdT])]; - std::vector connOfCurCellS; - Intersector3DP1P1::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); - if( PointLocatorAlgos::isElementContainsPointAlg3D(&CoordsT[nodeIdT*SPACEDIM],&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision) ) - { - double resLoc[4]; - std::vector localCoordsS; - Intersector3DP1P1::getRealSourceCoordinates(OTT::indFC(*iterCellS),localCoordsS); - std::vector eap(4); - eap[0]=&localCoordsS[0]; eap[1]=&localCoordsS[3]; eap[2]=&localCoordsS[6]; eap[3]=&localCoordsS[9]; - barycentric_coords(eap,&CoordsT[nodeIdT*SPACEDIM],resLoc); - const ConnType *startOfCellNodeConnS=Intersector3DP1P1::getStartConnOfSourceCell(*iterCellS); - for(int nodeIdS=0;nodeIdS<4;nodeIdS++) - { - if(fabs(resLoc[nodeIdS])>_precision) - { - ConnType curNodeSInCmode=OTT::coo2C(startOfCellNodeConnS[nodeIdS]); - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),resLoc[nodeIdS])); - else - { - double val=(*iterRes).second+resLoc[nodeIdS]; - resRow.erase(OTT::indFC(curNodeSInCmode)); - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); - } - } - } - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PointLocatorAlgos.txx b/src/INTERP_KERNEL/PointLocatorAlgos.txx deleted file mode 100644 index d7dd7432e..000000000 --- a/src/INTERP_KERNEL/PointLocatorAlgos.txx +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (C) 2007-2010 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 __POINTLOCATORALGOS_TXX__ -#define __POINTLOCATORALGOS_TXX__ - -#include "InterpolationUtils.hxx" -#include "CellModel.hxx" -#include "BBTree.txx" - -#include -#include - -namespace INTERP_KERNEL -{ - class GenericPointLocatorAlgos - { - public: - virtual ~GenericPointLocatorAlgos() { } - virtual std::list locates(const double* x, double eps) = 0; - }; - - template - class PointLocatorAlgos: public GenericPointLocatorAlgos - { - private : - double* _bb; - BBTree* _tree; - const MyMeshType& _mesh; - public: - PointLocatorAlgos(const MyMeshType& mesh):_mesh(mesh) - { - typedef typename MyMeshType::MyConnType ConnType; - const int SPACEDIM=MyMeshType::MY_SPACEDIM; - const NumberingPolicy numPol=MyMeshType::My_numPol; - int nelem = _mesh.getNumberOfElements(); - _bb = new double[SPACEDIM*2*nelem]; - const ConnType* conn = _mesh.getConnectivityPtr(); - const ConnType* conn_index = _mesh.getConnectivityIndexPtr(); - const double* coords=_mesh.getCoordinatesPtr(); - for (int i=0; i::max(); - _bb[2*(i*SPACEDIM+idim)+1]=-std::numeric_limits::max(); - } - for (int index= conn_index[i]; index < conn_index[i+1];index++) - { - //coordelem points to the coordinates of the current node of the i-th element - const double* coordelem = coords+OTT::ind2C(conn[OTT::ind2C(index)])*SPACEDIM; - - //the bounding box is updated by checking wheher the node is at the min/max in exach dimension - for (int idim=0; idim_bb[2*(i*SPACEDIM+idim)+1])?coordelem[idim]:_bb[2*(i*SPACEDIM+idim)+1]; - } - } - } - _tree=new BBTree(_bb,0,0,nelem); - } - - ~PointLocatorAlgos() - { - delete[] _bb; - delete _tree; - } - - //returns the list of elements that contains - //the point pointed to by x - std::list locates(const double* x, double eps) - { - typedef typename MyMeshType::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshType::My_numPol; - std::vector candidates; - _tree->getElementsAroundPoint(x,candidates); - std::list retlist; - for(unsigned int i=0; i< candidates.size(); i++) - { - int ielem=candidates[i]; - if (elementContainsPoint(ielem,x,eps)) - retlist.push_back(OTT::indFC(ielem)); - } - return retlist; - } - - static bool isElementContainsPointAlg2D(const double *ptToTest, const double *cellPts, int nbEdges, double eps) - { - /* with dimension 2, it suffices to check all the edges - and see if the sign of double products from the point - is always the same. - C - / \ - / \ - Xo / \ - A-------B - - here XA^XC and XC^XB have different signs*/ - const int SPACEDIM=MyMeshType::MY_SPACEDIM; - int* sign = new int[nbEdges]; - for (int iedge=0; iedgeeps) - sign[iedge]=1; - else - sign[iedge]=0; - } - bool ret=decideFromSign(sign, nbEdges); - delete [] sign; - return ret; - } - - static bool isElementContainsPointAlg3D(const double *ptToTest, const typename MyMeshType::MyConnType *conn_elem, int conn_elem_sz, const double *coords, const CellModel& cmType, double eps) - { - const int SPACEDIM=MyMeshType::MY_SPACEDIM; - typedef typename MyMeshType::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshType::My_numPol; - - int nbfaces = cmType.getNumberOfSons2(conn_elem,conn_elem_sz); - int *sign = new int[nbfaces]; - int *connOfSon = new int[conn_elem_sz]; - for (int iface=0; iface::coo2C(connOfSon[0])); - const double* BB=coords+SPACEDIM*(OTT::coo2C(connOfSon[1])); - const double* CC=coords+SPACEDIM*(OTT::coo2C(connOfSon[2])); - double Vol=triple_product(AA,BB,CC,ptToTest); - if (Vol<-eps) - sign[iface]=-1; - else if (Vol>eps) - sign[iface]=1; - else - sign[iface]=0; - } - bool ret=decideFromSign(sign, nbfaces); - delete [] sign; - delete [] connOfSon; - return ret; - } - - static bool isElementContainsPoint(const double *ptToTest, NormalizedCellType type, const double *coords, const typename MyMeshType::MyConnType *conn_elem, int conn_elem_sz, double eps) - { - const int SPACEDIM=MyMeshType::MY_SPACEDIM; - typedef typename MyMeshType::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshType::My_numPol; - - const CellModel& cmType=CellModel::getCellModel(type); - // - if (SPACEDIM==2) - { - int nbEdges=cmType.getNumberOfSons(); - double *pts = new double[nbEdges*SPACEDIM]; - for (int iedge=0; iedge::ind2C(conn_elem[iedge])); - std::copy(a,a+SPACEDIM,pts+iedge*SPACEDIM); - } - bool ret=isElementContainsPointAlg2D(ptToTest,pts,nbEdges,eps); - delete [] pts; - return ret; - } - - if (SPACEDIM==3) - { - return isElementContainsPointAlg3D(ptToTest,conn_elem,conn_elem_sz,coords,cmType,eps); - } - } - - bool elementContainsPoint(typename MyMeshType::MyConnType i, const double* x, double eps) - { - //as i is extracted from the BBTRee, it is already in C numbering - //it is not necessary to convert it from F to C - typedef typename MyMeshType::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshType::My_numPol; - - const double* coords= _mesh.getCoordinatesPtr(); - const ConnType* conn=_mesh.getConnectivityPtr(); - const ConnType* conn_index= _mesh.getConnectivityIndexPtr(); - const ConnType* conn_elem=conn+OTT::ind2C(conn_index[i]); - int conn_elem_sz=conn_index[i+1]-conn_index[i]; - NormalizedCellType type=_mesh.getTypeOfElement(OTT::indFC(i)); - return isElementContainsPoint(x,type,coords,conn_elem,conn_elem_sz,eps); - } - - static bool decideFromSign(const int* sign, int nbelem) - { - int min_sign = 1; - int max_sign = -1; - for (int i=0; imax_sign)?sign[i]:max_sign; - } - return (min_sign!=-1 || max_sign!=1); - } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PolygonAlgorithms.hxx b/src/INTERP_KERNEL/PolygonAlgorithms.hxx deleted file mode 100644 index 05bfc42f6..000000000 --- a/src/INTERP_KERNEL/PolygonAlgorithms.hxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYGONALGORITHMS_HXX__ -#define __POLYGONALGORITHMS_HXX__ - -#include -#include -#include - -namespace INTERP_KERNEL -{ - template - class VertexLess - { - public: - bool operator()(const double * P_1, const double * P_2) - { - for(int idim=0; idim P_2[idim]) return false; - } - return false; - } - }; - - template - class PolygonAlgorithms - { - public: - PolygonAlgorithms(double epsilon, double precision); - std::deque intersectConvexPolygons(const double* P_1,const double* P_2, int N1, int N2); - - //Not yet tested - int convexDecomposition(const double * P, int N, std::vector< std::map< int,int > >& components, - std::vector< int >& components_index, const double epsilon); - private: - void defineIndices(int& i_loc, int& i_next, int& i_prev, - const double *& Poly1, const double *& Poly2, - int& j1, int& j1_glob, int& j2, int& j2_glob, - int& j3, int& j3_glob, int& j4, int& j4_glob, - int& i_glob, int& i_next_glob, int& i_prev_glob, - const double * P_1, const double * P_2, - int N1, int N2, int sign); - void addCrossings( const double * A, const double * B, int i , int i_next, - const double * C, const double * D, int j1, int j2, - const double * E, const double * F, int j3, int j4, - const double * G); - void addCrossing0(const double * A, const double * B, int i, int i_next, - const double * C, const double * D, int j, int j_next); - void addCrossing( double * ABCD, std::pair< int,int > i_i_next, std::pair< int,int > j_j_next); - void addNewVertex( int i, int i_glob, int i_next_glob, int i_prev_glob, const double * P); - bool intersectSegmentSegment(const double * A, const double * B, const double * C, - const double * D, const double * E, double * V); - - - //Not yet tested - void convexDecomposition(const double* P, int N, double* n, std::vector< int > subP, int NsubP, - std::vector< std::map< int,int > >& components, std::vector< int >& components_index, - int& Ncomp, int sign, const double epsilon); - void convHull(const double *P, int N, double * n, std::map< int,int >& subP, - std::map< int,int >& not_in_hull, int& NsubP, const double epsilon); - private: - std::deque< double > _Inter;/* vertices of the intersection P1^P2 */ - std::vector< std::pair< int,int > > _End_segments; /* segments containing inter final edges */ - /* status list of segments (ending point, starting point) intersected by the sweeping line */ - /* and a boolean true if the ending point is in the intersection */ - std::multimap< int, std::pair< int,bool> > _Status; - bool _is_in_intersection; - bool _terminus; - double _vdouble[DIM]; - double _epsilon; - double _precision; - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PolygonAlgorithms.txx b/src/INTERP_KERNEL/PolygonAlgorithms.txx deleted file mode 100644 index 099212992..000000000 --- a/src/INTERP_KERNEL/PolygonAlgorithms.txx +++ /dev/null @@ -1,823 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYGONALGORITHMS_TXX__ -#define __POLYGONALGORITHMS_TXX__ - -#include "PolygonAlgorithms.hxx" -#include "InterpolationUtils.hxx" -#include -#include -#include - -namespace INTERP_KERNEL -{ - template - PolygonAlgorithms::PolygonAlgorithms(double epsilon, double precision)//: (0) - { - _is_in_intersection = false; - _epsilon = epsilon; - _precision = precision; - } - /*************************************************************/ - /* Computes the 3D intersection between two COPLANAR */ - /* Segments [A,B] and [C,D], stores the result in V. */ - /* If A belongs to [CD] then the vertex E (preceeding A) */ - /* is used to decide if the crossing is real. If A coincides */ - /* with C or D, a special treatment is performed */ - /*************************************************************/ - template - bool PolygonAlgorithms::intersectSegmentSegment(const double * A, const double * B, const double * C, - const double * D, const double * E, double * V) - { - double AB[DIM], DC[DIM], AC[DIM], det, t1, t2, inv_det; - - /******* Initialisation of the linear system t1*AB+t2*DC=AC ***********/ - for(int idim=0;idim_epsilon) - { - inv_det = 1/det; - t1 = determinant(AC,DC)*inv_det;//solves the linear system t1*AB+t2*DC=AC - t2 = determinant(AB,AC)*inv_det;//solves the linear system t1*AB+t2*DC=AC - } - else - { - switch(DIM) - { - case 2: - { - if(distance2(A,D)<_epsilon) - crossprod(A,C,E,_vdouble);//store the crossprod between vectors AC and AE (E=vertex preceding A) - return false;//case of paralell segments - } - case 3://beware AB and CD may belong to a vertical plane - det = determinant(&AB[1],&DC[1]);//determinant of the last two coefficients - if(fabs(det) > _epsilon) - { - inv_det = 1/det; - t1=(AC[1]*DC[2]-AC[2]*DC[1])*inv_det; - t2=(AB[1]*AC[2]-AB[2]*AC[1])*inv_det; - } - else //beware AB and CD may belong to a plane y = constant - { - det = AB[0]*DC[2]-AB[2]*DC[0]; - if(fabs(det) > _epsilon) - { - inv_det = 1/det; - t1=(AC[0]*DC[2]-AC[2]*DC[0])*inv_det; - t2=(AB[0]*AC[2]-AB[2]*AC[0])*inv_det; - } - else - { - if(distance2(A,D)<_epsilon) - crossprod(A,C,E,_vdouble);//store the crossprod between vectors AC and AE (E=vertex preceding A) - return false;//case of paralell segments - } - } - } - } - - if(t1>_precision && t1<1-_precision) - { - if( t2>_precision && t2<1-_precision) - { - for(int idim=0;idim_precision && t2<1-_precision)//vertex on an edge - { - double V12[DIM]; - double V34[DIM]; - crossprod(A,D,B,V12); - crossprod(A,D,E,V34); - double same_side =dotprod(V12, V34); - if( same_side < -_epsilon ) // <= epsilon or 0 ?//crossing - { - for(int idim=0;idim _epsilon ) _terminus= !_is_in_intersection;//reflexion - else //separation of overlaping edges - { - if(_Inter.empty() ) _terminus=true; - else if(!_is_in_intersection) - { - for(int idim=0;idim(A,C,E,_vdouble);//store the angle between vectors AC and AE (E=vertex preceding A) - else if(fabs(t2) <= _precision)//vertex on a vertex (A=C), second run - { - double Vdoublebis[DIM]; - //crossprod(A,C,E,_vdouble); - crossprod(A,B,D,Vdoublebis); - double in_between =dotprod(Vdoublebis,_vdouble); - if(in_between>_epsilon)//crossing - { - for(int idim=0;idim(Vdoublebis,Vdoublebis) > _epsilon) - //ie _vdouble=0, separation of overlaping edges at a double point - { - //crossprod(A,E,B,_vdouble); - if(dotprod(_vdouble,Vdoublebis) >=_epsilon )//crossing - { - if(_Inter.empty()) _terminus=true; - else if(!_is_in_intersection) - { - for(int idim=0;idim - inline void PolygonAlgorithms::addNewVertex( int i, int i_glob, int i_next_glob, int i_prev_glob, - const double * P) - { - /* Question:Should we add vertex i to the front or back ? */ - if( _End_segments[1].second == i_glob) - { - for(int idim=0;idim-1;idim--) _Inter.push_front(P[DIM*i+idim]); - _End_segments[0] = std::make_pair(i_glob, i_next_glob); - } - } - - /************************************************************/ - /* adds a crossing between two segments starting at i and j */ - /* to the double ended list inter in the correct order */ - /* according to endsegments, updates _End_segments */ - /************************************************************/ - template - inline void PolygonAlgorithms::addCrossing( double * ABCD, std::pair< int,int > i_i_next, - std::pair< int,int > j_j_next) - { - if(!_Inter.empty() ) - { - if(_End_segments[0] ==i_i_next) - { - for(int idim=DIM-1;idim>=0;idim--) _Inter.push_front(ABCD[idim]); - _terminus= (_End_segments[1]== j_j_next); - _End_segments[0] = j_j_next; - } - else - { - if( _End_segments[0]== j_j_next) - { - for(int idim=DIM-1;idim>=0;idim--) _Inter.push_front(ABCD[idim]); - _terminus= (_End_segments[1]== i_i_next); - _End_segments[0] = i_i_next; - } - else - { - for(int idim=0;idim - void PolygonAlgorithms::addCrossing0(const double * A, const double * B, int i, int i_next, - const double * C, const double * D, int j, int j_next) - { - double ABCD[DIM]; - if(intersectSegmentSegment(A,B,C,D,ABCD, ABCD)) - //fifth and sixth arguments are useless here - { - /* Updating _End_segments */ - std::pair< int,int > i_i_next = std::make_pair(i, i_next); - std::pair< int,int > j_j_next = std::make_pair(j, j_next); - if( _End_segments[0] == i_i_next) - { - for(int idim=DIM-1;idim>-1;idim--) _Inter.push_front(ABCD[idim]); - _End_segments[0] = j_j_next; - } - else - { - for(int idim=0;idim >::iterator mi =_Status.find(j_next); - ((* mi).second).second= !((* mi).second).second; - } - else _Status.insert(std::make_pair(i_next,std::make_pair(i,true))); - } - - /*******************************************************/ - /* adds the possible crossings between segments [A,B] (with end-point global indices i and i_next) */ - /*and segments [C,D] and [E,F] to the list inter and updates _End_segments */ - /* In cases of ambiguity, the vertex G is used to decide wether the crossing should be accepted */ - /*******************************************************/ - template - inline void PolygonAlgorithms::addCrossings( const double * A, const double * B, int i , int i_next, - const double * C, const double * D, int j1, int j2, - const double * E, const double * F, int j3, int j4, - const double * G) - { - double ABCD[DIM]; - double ABEF[DIM]; - std::multimap< int, std::pair< int,bool> >::iterator mi; - - if(intersectSegmentSegment(A,B,C,D,G,ABCD)) - { - if(intersectSegmentSegment(A,B,E,F,G,ABEF)) - { - VertexLess vl; - if (vl(ABCD,ABEF)) - { - addCrossing(ABCD, std::make_pair(i, i_next), std::make_pair(j1, j2)); - addCrossing(ABEF, std::make_pair(i, i_next), std::make_pair(j3, j4)); - } - else - { - addCrossing(ABEF, std::make_pair(i, i_next), std::make_pair(j3, j4)); - addCrossing(ABCD, std::make_pair(i, i_next), std::make_pair(j1, j2)); - } - _Status.insert(std::make_pair(i_next,std::make_pair(i, _is_in_intersection))); - mi=_Status.find(j2); - ((* mi).second).second= !((* mi).second).second; - mi=_Status.find(j4); - ((* mi).second).second= !((* mi).second).second; - } - else - { - addCrossing(ABCD, std::make_pair( i, i_next), std::make_pair(j1,j2)); - _Status.insert(std::make_pair(i_next,std::make_pair(i, !_is_in_intersection))); - mi=_Status.find(j2); - ((* mi).second).second= !((* mi).second).second; - } - } - else - { - if(intersectSegmentSegment(A,B,E,F,G, ABEF)) - { - addCrossing(ABEF, std::make_pair( i, i_next), std::make_pair( j3, j4)); - _Status.insert(std::make_pair(i_next,std::make_pair(i, !_is_in_intersection))); - mi=_Status.find(j4); - ((* mi).second).second= !((* mi).second).second; - } - else _Status.insert(std::make_pair(i_next,std::make_pair(i, _is_in_intersection))); - } - } - - - /* define various indices required in the function intersect_conv_polygon */ - /* vertices from the both polygons are supposed to be present in the status */ - template - inline void PolygonAlgorithms::defineIndices(int& i_loc, int& i_next, int& i_prev, - const double *& Poly1, const double *& Poly2, - int& j1, int& j1_glob, int& j2, int& j2_glob, - int& j3, int& j3_glob, int& j4, int& j4_glob, - int& i_glob, int& i_next_glob, int& i_prev_glob, - const double * P_1, const double * P_2, - int N1, int N2, int sign) - { - int N0, shift; - if(i_glob < N1) - { - N0 = N1; - shift = 0; - Poly1 = P_1; - Poly2 = P_2; - - std::multimap< int, std::pair< int,bool> >::reverse_iterator mi1=_Status.rbegin(); - j1_glob=((*mi1).second).first; - j1=j1_glob-N1; - j2_glob=(*mi1).first; - j2=j2_glob-N1; - mi1++; - j3_glob=((*mi1).second).first; - j3=j3_glob-N1; - j4_glob=(*mi1).first; - j4=j4_glob-N1; - } - else - { - N0 = N2; - shift = N1; - Poly1 = P_2; - Poly2 = P_1; - - std::multimap< int, std::pair< int,bool> >::iterator mi2= _Status.begin(); - j1_glob=((*mi2).second).first; - j1=j1_glob; - j2_glob=(*mi2).first; - j2=j2_glob; - mi2++; - j3_glob=((*mi2).second).first; - j3=j3_glob; - j4_glob=(*mi2).first; - j4=j4_glob; - } - i_loc = i_glob-shift; - i_next = (i_next_glob-shift+N0)%N0;//end-point of segment starting at i - i_prev = (i_prev_glob-shift+N0)%N0; - i_next_glob = i_next+shift; - i_prev_glob = i_prev+shift; - //warning: sign is either 1 or -1; - //To do: test and remove from Convex_intersecor.cxx - // while(distance2(&Poly1[DIM*i_loc],&Poly1[DIM*i_next])< _epsilon && i_next != i_loc) - // i_next =(i_next+sign+N0)%N0; - // while(distance2(&Poly1[DIM*i_loc],&Poly1[DIM*i_prev])< _epsilon && i_prev != i_loc) - // i_prev =(i_prev+sign+N0)%N0; - } - /*******************************************************/ - /* computes the vertices of the intersection of two COPLANAR */ - /* simple (no dble points)convex polygons using line sweep algorithm */ - /* P1 and P2 contain the 3D coordinates of the successive vertices */ - /*******************************************************/ - template - std::deque< double > PolygonAlgorithms::intersectConvexPolygons(const double* P_1,const double* P_2, - int N1, int N2) - { - int i_loc, i_glob, j1, j1_glob, j2,j2_glob, j3, j3_glob, j4,j4_glob, - i_prev, i_prev_glob, i_next, i_next_glob, nb_prev, sign, idim; - const double * Poly1, * Poly2; - bool four_neighbours=false; - _terminus = N1 < 3 || N2<3; - - /* list of future events ordered according to their coordinates (x,y,z) (lexicographical order) */ - std::multimap< const double *, int, VertexLess > mmap_events; - typename std::list< std::pair< const double *, int > >::iterator mi1,mi2; - - std::multimap< int, std::pair< int,bool> >::iterator mi; - - /********** Initalisation of events with P1 and P2 vertices ************/ - for(i_loc=0;i_loc > events(mmap_events.begin(),mmap_events.end()); - - if(!_terminus) - { - /******** Treatment of the first vertex ********/ - mi1=events.begin(); - i_glob = (* mi1).second; - bool which_start = i_glob < N1; - if(i_glob < N1){ i_next_glob = (i_glob +1)%N1; i_prev_glob = (i_glob -1+N1)%N1;} - else{ i_next_glob = (i_glob-N1+1)%N2 + N1;i_prev_glob = (i_glob-N1-1+N2)%N2 + N1;} - _Status.insert(std::make_pair(i_next_glob,std::make_pair(i_glob, false))); - _Status.insert(std::make_pair(i_prev_glob,std::make_pair(i_glob, false))); - mi1++; - //std::cout<< "nb_prev= "<< 0 << " i_glob= " << i_glob << std::endl; - - /******* Loop until the second polygon is reached *******/ - while( !four_neighbours) - { - i_glob=(* mi1).second;//global index of vertex i - nb_prev = _Status.count(i_glob);//counts the number of segments ending at i - - //std::cout<< "nb_prev= "<< nb_prev << " i_glob= " << i_glob << std::endl; - switch (nb_prev) - { - case 1 : - mi=_Status.find(i_glob);// pointer to the segment ending at i - i_prev_glob = ((*mi).second).first;//starting point of the segment ending at i - i_next= (i_prev_glob - i_glob > 0) == (abs(i_prev_glob - i_glob) == 1) ? i_glob - 1 : i_glob + 1; - if(i_glob < N1) i_next_glob = (i_next +N1)%N1; - else i_next_glob = (i_next-N1+N2)%N2 + N1; - _Status.erase(mi); - _Status.insert(std::make_pair(i_next_glob,std::make_pair(i_glob, false))); - mi1++; - break; - case 2 : - return _Inter; - case 0 : - if( (i_glob < N1) != which_start) - { - mi2=mi1; - mi2++; - /* detection of double points */ - if(distance2((* mi1).first, (*mi2).first) > _epsilon) - four_neighbours = true; - else /* Rare pothological case: */ - { - const std::pair< const double *, int > next_pt= *mi2; - events.erase(mi2); - mi1=events.insert(mi1,next_pt); - } - } - break; - default: - throw Exception("intersectConvexPolygon: sequence of nodes does not describe a simple polygon (1)"); - } - } - /******** Loop until a terminal point or crossing is reached ************/ - while( !_terminus) - { - //std::cout<< "nb_prev= "<< nb_prev<< " nb_inter= " << _Inter.size()/DIM << std::endl; - switch (nb_prev) - { - case 1 : - mi=_Status.find(i_glob);// pointer to the segment ending at i - i_prev_glob = ((*mi).second).first;//starting point of the segment ending at i - sign = (i_prev_glob - i_glob > 0) == (abs(i_prev_glob - i_glob) == 1) ? - 1 : + 1; - i_next_glob = i_glob+sign; - _is_in_intersection = ((*mi).second).second;//boolean that tells if i is in the intersection - _Status.erase(mi); - defineIndices(i_loc,i_next,i_prev, Poly1,Poly2, - j1,j1_glob,j2,j2_glob,j3,j3_glob,j4,j4_glob, - i_glob,i_next_glob,i_prev_glob, P_1,P_2, N1, N2, sign); - if( _is_in_intersection ) addNewVertex(i_loc, i_glob, i_next_glob, i_prev_glob, Poly1); - addCrossings(&Poly1[DIM*i_loc], &Poly1[DIM*i_next], i_glob, i_next_glob, - &Poly2[DIM*j1] , &Poly2[DIM*j2] , j1_glob,j2_glob, - &Poly2[DIM*j3] , &Poly2[DIM*j4] , j3_glob,j4_glob, &Poly1[DIM*i_prev]); - break; - case 2 : - if(!_Inter.empty()) - { - if(i_glob < N1) for(idim=0;idim(&Poly1[DIM*i_loc],&Poly2[DIM*j1],&Poly2[DIM*j2], - &Poly2[DIM*j3], &Poly2[DIM*j4],V12, V34); - _is_in_intersection=( inside < _epsilon ); // <= epsilon or 0 ? - - if(fabs(inside) > _epsilon)//vertex clearly inside or outside - { - //std::cout<<"coucou1" << std::endl; - if( _is_in_intersection) - { - for(int idim=0;idim(V34,V34) > _epsilon)//vertex i on edge (j1,j2), not on (j3,j4) - { - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j2], &Poly1[DIM*i_next],Vnext); - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j2], &Poly1[DIM*i_prev],Vprev); - is_inside_next= (dotprod(Vnext,V34)<0); - is_inside_prev= (dotprod(Vprev,V34)<0); - - if(!(is_inside_next || is_inside_prev)) return std::deque< double >(); - - if(is_inside_next) - { - _End_segments.push_back(std::make_pair(i_glob,i_next_glob)); - addCrossing0(&Poly1[DIM*i_loc], &Poly1[DIM*i_next], i_glob, i_next_glob, - &Poly2[DIM*j3] , &Poly2[DIM*j4] , j3_glob,j4_glob); - } - else - { - _End_segments.push_back(std::make_pair(j1_glob,j2_glob)); - _Status.insert(std::make_pair(i_next_glob,std::make_pair(i_glob, false))); - mi=_Status.find(j2_glob); - ((* mi).second).second= !((* mi).second).second; - } - if(is_inside_prev) - { - _End_segments.push_back(std::make_pair(i_glob,i_prev_glob)); - addCrossing0(&Poly1[DIM*i_loc], &Poly1[DIM*i_prev], i_glob, i_prev_glob, - &Poly2[DIM*j3] , &Poly2[DIM*j4] , j3_glob,j4_glob); - } - else - { - _End_segments.push_back(std::make_pair(j1_glob,j2_glob)); - _Status.insert(std::make_pair(i_prev_glob,std::make_pair(i_glob, false))); - mi=_Status.find(j2_glob); - ((* mi).second).second= !((* mi).second).second; - } - } - else if(dotprod(V12,V12) > _epsilon)//vertex i on a edge (j3,j4), not on (j1,j2) - { - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j4], &Poly1[DIM*i_next],Vnext); - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j4], &Poly1[DIM*i_prev],Vprev); - is_inside_next= dotprod(Vnext,V12)<0; - is_inside_prev= dotprod(Vprev,V12)<0; - - if(!(is_inside_next || is_inside_prev)) return std::deque< double >(); - - if(is_inside_next) - { - _End_segments.push_back(std::make_pair(i_glob,i_next_glob)); - addCrossing0(&Poly1[DIM*i_loc], &Poly1[DIM*i_next], i_glob, i_next_glob, - &Poly2[DIM*j1] , &Poly2[DIM*j2] , j1_glob,j2_glob); - } - else - { - _End_segments.push_back(std::make_pair(j3_glob,j4_glob)); - _Status.insert(std::make_pair(i_next_glob,std::make_pair(i_glob, false))); - mi=_Status.find(j4_glob); - ((* mi).second).second= ! ((* mi).second).second; - } - if(is_inside_prev) - { - _End_segments.push_back(std::make_pair(i_glob,i_prev_glob)); - addCrossing0(&Poly1[DIM*i_loc], &Poly1[DIM*i_prev], i_glob, i_prev_glob, - &Poly2[DIM*j1] , &Poly2[DIM*j2] , j1_glob,j2_glob); - } - else - { - _End_segments.push_back(std::make_pair(j3_glob,j4_glob)); - _Status.insert(std::make_pair(i_prev_glob,std::make_pair(i_glob, false))); - mi=_Status.find(j4_glob); - ((* mi).second).second= !((* mi).second).second; - } - } - else //vertices i, j1 and j3 share the same coordinates - { - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j2], &Poly1[DIM*i_next],Vnext); - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j2], &Poly1[DIM*i_prev],Vprev); - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j4], &Poly1[DIM*i_next],V12); - crossprod(&Poly1[DIM*i_loc], &Poly2[DIM*j4], &Poly1[DIM*i_prev],V34); - - double inside_next= dotprod(Vnext,V12); - double inside_prev= dotprod(Vprev,V34); - double inside_j2 = dotprod(Vnext,Vprev); - double inside_j4 = dotprod(V12,V34); - - std::map > which_is_inside; - which_is_inside[inside_next] = std::make_pair(i_glob,i_next_glob); - which_is_inside[inside_prev] = std::make_pair(i_glob,i_prev_glob); - which_is_inside[inside_j2] = std::make_pair(j1_glob,j2_glob); - which_is_inside[inside_j4] = std::make_pair(j3_glob,j4_glob); - - std::map >::iterator min = which_is_inside.begin(); - std::map >::iterator minext = min; - minext++; - std::map >::reverse_iterator max = which_is_inside.rbegin(); - std::multimap< int, std::pair< int,bool> >::iterator j2_in_status = _Status.find(((*min).second).second); - std::multimap< int, std::pair< int,bool> >::iterator j4_in_status = _Status.find(((*minext).second).second); - - if((*min).first < -_epsilon) //there is someone clearly inside - { - _End_segments.push_back( (*min).second ); - _End_segments.push_back((* minext).second); - if(j2_in_status != _Status.end()) - ((*j2_in_status).second).second = ! ((*j2_in_status).second).second; - if(j4_in_status != _Status.end()) - ((*j4_in_status).second).second = ! ((*j4_in_status).second).second; - is_inside_next = ((*min).second).second == i_next_glob || ((*minext).second).second == i_next_glob; - is_inside_prev = ((*min).second).second == i_prev_glob || ((*minext).second).second == i_prev_glob; - } - else - if(fabs((*min).first) <= _epsilon) //nobody is clearly inside but two segments are superposed - { - if(fabs((*max).first) > _epsilon) - return std::deque< double >(); - else //all four segments are superposed - { - _End_segments.push_back(std::make_pair(i_glob,i_next_glob)); - _End_segments.push_back(std::make_pair(i_glob,i_prev_glob)); - is_inside_next= true; - is_inside_prev= true; - } - } - else //there is nobody inside - return std::deque< double >(); - - _Status.insert(std::make_pair(i_prev_glob,std::make_pair(i_glob,is_inside_prev))); - _Status.insert(std::make_pair(i_next_glob,std::make_pair(i_glob,is_inside_next))); - } - } - } - break; - default: - std::cout << "Problem: nbprev= " << nb_prev << " ; i_glob = " << i_glob << std::endl; - throw Exception("intersectConvexPolygon: sequence of nodes does not describe a simple polygon (2)"); - } - mi1++; - i_glob=(* mi1).second;//global index of vertex i - nb_prev = _Status.count(i_glob); - } - } - return _Inter; - } - - /**************************************************************************/ - /* computes the convex hull of a polygon subP which is a sub polygon of P */ - /* P is the array of coordinates, subP is a map containing initially the indices of a subpolygon of P */ - /* in the end, subP contains only the elements belonging to the convex hull, and not_in_hull the others */ - /**************************************************************************/ - template - inline void PolygonAlgorithms::convHull(const double *P, int N, double * normal, - std::map< int,int >& subP, std::map< int,int >& not_in_hull, - int& NsubP, const double epsilon) - { - if(NsubP>3) - { - std::map< int,int >::iterator mi_prev = subP.begin(); - std::map< int,int >::iterator mi = mi_prev; - mi++; - std::map< int,int >::iterator mi_next = mi; - mi_next++; - double directframe=0.; - - /* Check if the polygon subP is positively oriented */ - std::map< int,int >::iterator mi1=mi; - while(mi1 != subP.end() && distance2(&P[DIM*(*subP.begin()).second],&P[DIM*(*mi1).second])< epsilon) - mi1++; - std::map< int,int >::iterator mi2=mi1; - while(mi2 != subP.end() && fabs(directframe)(&P[DIM* (*mi1).second], - &P[DIM* (*subP.begin()).second], - &P[DIM* (*mi2).second], normal); - mi2++; - } - if(directframe < 0) for(int idim=0; idim< DIM; idim++) normal[idim] *= -1; - - /* Core of the algorithm */ - while(mi_next != subP.end()) - { - directframe = direct_frame(&P[DIM* (*mi).second], - &P[DIM* (*mi_prev).second], - &P[DIM* (*mi_next).second], normal); - if(directframe > -epsilon){ - mi ++; - mi_prev++; - mi_next++; - } - else - { - not_in_hull.insert(*mi); - subP.erase(mi); - NsubP--; - mi--; - } - } - directframe = direct_frame(&P[DIM*(*mi).second], - &P[DIM*(*mi_prev).second], - &P[DIM*(*subP.begin()).second], normal); - if(directframe < -epsilon) - { - not_in_hull.insert(*mi); - subP.erase(mi); - NsubP--; - } - } - } - - template - void PolygonAlgorithms::convexDecomposition(const double * P, int N, double *normal, std::vector< int > subP, int NsubP, - std::vector< std::map< int,int > >& components, std::vector< int >& components_index, - int& Ncomp, int sign, const double epsilon) - { - int i; - std::map< int, int > hull; - std::map< int, int > not_in_hull; - std::map< int, int >::iterator mi, mj; - std::vector< int > reflex_region; - int Nreflex; - int i_xmax=0; - const double * xmax=&P[DIM*subP[0]]; - /* checking an extremal point of subP */ - for(i=0; i xmax) - { - i_xmax=i; - xmax=&P[DIM*subP[i]]; - } - } - /* renumbering of SubP elements for the convex hull*/ - for(i=0; i - int PolygonAlgorithms::convexDecomposition(const double * P, int N, std::vector< std::map< int,int > >& components, - std::vector< int >& components_index, const double epsilon) - { - int Ncomp=0; - std::vector< int > subP(N); - double normal[3]={0,0,0}; - - for(int i = 0; i(&P[0],&P[i1])< epsilon) i1++; - int i2=i1+1; - while(i2(normal,normal))(&P[i1], &P[0], &P[i2],normal); - i2++; - } - - convexDecomposition(P, N, normal, subP, N, components, components_index, Ncomp, 1, epsilon); - return Ncomp; - } -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx deleted file mode 100644 index 30d3b2af7..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYHEDRONINTERSECTORP0P0_HXX__ -#define __POLYHEDRONINTERSECTORP0P0_HXX__ - -#include "Intersector3DP0P0.hxx" -#include "SplitterTetra.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - - - /** - * \brief Class responsible for calculating intersection between a hexahedron target element and - * the source elements. - * - */ - template - class PolyhedronIntersectorP0P0 : public Intersector3DP0P0 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - - PolyhedronIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); - - ~PolyhedronIntersectorP0P0(); - - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - - private: - void releaseArrays(); - private: - /// pointers to the SplitterTetra objects representing the tetrahedra - /// that result from the splitting of the hexahedron target cell - std::vector< SplitterTetra* > _tetra; - - SplitterTetra2 _split; - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx deleted file mode 100644 index 1fde5d1ae..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYHEDRONINTERSECTORP0P0_TXX__ -#define __POLYHEDRONINTERSECTORP0P0_TXX__ - -#include "PolyhedronIntersectorP0P0.hxx" -#include "Intersector3DP0P0.txx" -#include "MeshUtils.hxx" - -#include "SplitterTetra.txx" - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating object from target cell global number - * The constructor first calculates the necessary nodes, - * (depending on the splitting policy) and then splits the hexahedron into - * tetrahedra, placing these in the internal vector _tetra. - * - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - */ - template - PolyhedronIntersectorP0P0::PolyhedronIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy):Intersector3DP0P0(targetMesh,srcMesh),_split(targetMesh,srcMesh,policy) - { - } - - /** - * Destructor. - * Liberates the SplitterTetra objects and potential sub-node points that have been allocated. - * - */ - template - PolyhedronIntersectorP0P0::~PolyhedronIntersectorP0P0() - { - releaseArrays(); - } - - template - void PolyhedronIntersectorP0P0::releaseArrays() - { - for(typename std::vector< SplitterTetra* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) - delete *iter; - _split.releaseArrays(); - _tetra.clear(); - } - - /** - * Calculates the volume of intersection of an element in the source mesh and the target element - * represented by the object. - * The calculation is performed by calling the corresponding method for - * each SplitterTetra object created by the splitting. - * - * @param targetCell in C mode. - * @param srcCells in C mode. - * - */ - template - void PolyhedronIntersectorP0P0::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - int nbOfNodesT=Intersector3D::_target_mesh.getNumberOfNodesOfElement(OTT::indFC(targetCell)); - releaseArrays(); - _split.splitTargetCell(targetCell,nbOfNodesT,_tetra); - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - double volume = 0.; - for(typename std::vector*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) - volume += (*iter)->intersectSourceCell(*iterCellS); - if(volume!=0.) - res[targetCell].insert(std::make_pair(OTT::indFC(*iterCellS), volume)); - } - _split.releaseArrays(); - } -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx deleted file mode 100644 index 194449d90..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYHEDRONINTERSECTORP0P1_HXX__ -#define __POLYHEDRONINTERSECTORP0P1_HXX__ - -#include "Intersector3DP0P1.hxx" -#include "SplitterTetra.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - - - /** - * \brief Class responsible for calculating intersection between a hexahedron target element and - * the source elements. - * - */ - template - class PolyhedronIntersectorP0P1 : public Intersector3DP0P1 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - - PolyhedronIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); - - ~PolyhedronIntersectorP0P1(); - - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - - private: - void releaseArrays(); - private: - /// pointers to the SplitterTetra objects representing the tetrahedra - /// that result from the splitting of the hexahedron target cell - std::vector< SplitterTetra* > _tetra; - - SplitterTetra2 _split; - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx deleted file mode 100644 index 41f8bde6c..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYHEDRONINTERSECTORP0P1_TXX__ -#define __POLYHEDRONINTERSECTORP0P1_TXX__ - -#include "PolyhedronIntersectorP0P1.hxx" -#include "Intersector3DP0P1.txx" -#include "MeshUtils.hxx" - -#include "SplitterTetra.txx" - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating object from target cell global number - * The constructor first calculates the necessary nodes, - * (depending on the splitting policy) and then splits the hexahedron into - * tetrahedra, placing these in the internal vector _tetra. - * - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - */ - template - PolyhedronIntersectorP0P1::PolyhedronIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy):Intersector3DP0P1(targetMesh,srcMesh),_split(targetMesh,srcMesh,policy) - { - } - - /** - * Destructor. - * Liberates the SplitterTetra objects and potential sub-node points that have been allocated. - * - */ - template - PolyhedronIntersectorP0P1::~PolyhedronIntersectorP0P1() - { - releaseArrays(); - } - - template - void PolyhedronIntersectorP0P1::releaseArrays() - { - for(typename std::vector< SplitterTetra* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) - delete *iter; - _split.releaseArrays(); - _tetra.clear(); - } - - /** - * Calculates the volume of intersection of an element in the source mesh and the target element - * represented by the object. - * The calculation is performed by calling the corresponding method for - * each SplitterTetra object created by the splitting. - * - * @param targetCell in C mode. - * @param srcCells in C mode. - * - */ - template - void PolyhedronIntersectorP0P1::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - SplitterTetra* subTetras[24]; - int nbOfNodesT=Intersector3D::_target_mesh.getNumberOfNodesOfElement(OTT::indFC(targetCell)); - releaseArrays(); - _split.splitTargetCell(targetCell,nbOfNodesT,_tetra); - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - for(typename std::vector*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) - { - (*iter)->splitIntoDualCells(subTetras); - for(int i=0;i<24;i++) - { - SplitterTetra *tmp=subTetras[i]; - double volume = tmp->intersectSourceCell(*iterCellS); - if(volume!=0.) - { - typename MyMatrix::value_type& resRow=res[tmp->getId(0)]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(*iterCellS)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(*iterCellS),volume)); - else - { - double val=(*iterRes).second+volume; - resRow.erase(OTT::indFC(*iterCellS)); - resRow.insert(std::make_pair(OTT::indFC(*iterCellS),val)); - } - } - delete tmp; - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx deleted file mode 100644 index 206d2f999..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYHEDRONINTERSECTORP1P0_HXX__ -#define __POLYHEDRONINTERSECTORP1P0_HXX__ - -#include "Intersector3DP1P0.hxx" -#include "SplitterTetra.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - - - /** - * \brief Class responsible for calculating intersection between a hexahedron target element and - * the source elements. - * - */ - template - class PolyhedronIntersectorP1P0 : public Intersector3DP1P0 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - - PolyhedronIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); - - ~PolyhedronIntersectorP1P0(); - - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - - private: - void releaseArrays(); - private: - /// pointers to the SplitterTetra objects representing the tetrahedra - /// that result from the splitting of the hexahedron target cell - std::vector< SplitterTetra* > _tetra; - - SplitterTetra2 _split; - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx deleted file mode 100644 index b6aa026cb..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2007-2010 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 __POLYHEDRONINTERSECTORP1P0_TXX__ -#define __POLYHEDRONINTERSECTORP1P0_TXX__ - -#include "PolyhedronIntersectorP1P0.hxx" -#include "Intersector3DP1P0.txx" -#include "MeshUtils.hxx" - -#include "SplitterTetra.txx" - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating object from target cell global number - * The constructor first calculates the necessary nodes, - * (depending on the splitting policy) and then splits the hexahedron into - * tetrahedra, placing these in the internal vector _tetra. - * - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - * - * WARNING : in _split attribute, sourceMesh and targetMesh are switched in order to fit intersectCells feature. - */ - template - PolyhedronIntersectorP1P0::PolyhedronIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy):Intersector3DP1P0(targetMesh,srcMesh),_split(srcMesh,targetMesh,policy) - { - } - - /** - * Destructor. - * Liberates the SplitterTetra objects and potential sub-node points that have been allocated. - * - */ - template - PolyhedronIntersectorP1P0::~PolyhedronIntersectorP1P0() - { - releaseArrays(); - } - - template - void PolyhedronIntersectorP1P0::releaseArrays() - { - for(typename std::vector< SplitterTetra* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) - delete *iter; - _split.releaseArrays(); - _tetra.clear(); - } - - /** - * Calculates the volume of intersection of an element in the source mesh and the target element - * represented by the object. - * The calculation is performed by calling the corresponding method for - * each SplitterTetra object created by the splitting. - * - * @param targetCell in C mode. - * @param srcCells in C mode. - * - * WARNING : for all methods on _split object source and target are switched ! - */ - template - void PolyhedronIntersectorP1P0::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { - SplitterTetra* subTetras[24]; - typename MyMatrix::value_type& resRow=res[targetCell]; - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - releaseArrays(); - int nbOfNodesS=Intersector3D::_src_mesh.getNumberOfNodesOfElement(OTT::indFC(*iterCellS)); - _split.splitTargetCell(*iterCellS,nbOfNodesS,_tetra); - for(typename std::vector*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) - { - (*iter)->splitIntoDualCells(subTetras); - for(int i=0;i<24;i++) - { - SplitterTetra *tmp=subTetras[i]; - double volume = tmp->intersectSourceCell(targetCell); - ConnType sourceNode=tmp->getId(0); - if(volume!=0.) - { - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(sourceNode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(sourceNode),volume)); - else - { - double val=(*iterRes).second+volume; - resRow.erase(OTT::indFC(sourceNode)); - resRow.insert(std::make_pair(OTT::indFC(sourceNode),val)); - } - } - delete tmp; - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx deleted file mode 100644 index 899adc731..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2010 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 __PolyhedronIntersectorP1P0Bary_HXX__ -#define __PolyhedronIntersectorP1P0Bary_HXX__ - -#include "Intersector3DP1P0Bary.hxx" -#include "SplitterTetra.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - - - /** - * \brief Class responsible for calculating intersection between a hexahedron target element and - * the source elements. - * - */ - template - class PolyhedronIntersectorP1P0Bary : public Intersector3DP1P0Bary - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - - PolyhedronIntersectorP1P0Bary(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); - - ~PolyhedronIntersectorP1P0Bary(); - - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - - private: - void releaseArrays(); - private: - /// pointers to the SplitterTetra objects representing the tetrahedra - /// that result from the splitting of the hexahedron target cell - std::vector< SplitterTetra* > _tetra; - - SplitterTetra2 _split; - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx deleted file mode 100644 index c38e16d50..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (C) 2007-2010 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 __PolyhedronIntersectorP1P0Bary_TXX__ -#define __PolyhedronIntersectorP1P0Bary_TXX__ - -#include "PolyhedronIntersectorP1P0Bary.hxx" -#include "Intersector3DP1P0Bary.txx" -#include "MeshUtils.hxx" - -#include "SplitterTetra.txx" - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating object from target cell global number - * The constructor first calculates the necessary nodes, - * (depending on the splitting policy) and then splits the hexahedron into - * tetrahedra, placing these in the internal vector _tetra. - * - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - * - * WARNING : in _split attribute, sourceMesh and targetMesh are switched in order to fit intersectCells feature. - */ - template - PolyhedronIntersectorP1P0Bary::PolyhedronIntersectorP1P0Bary(const MyMeshType& targetMesh, - const MyMeshType& srcMesh, - SplittingPolicy policy) - :Intersector3DP1P0Bary(targetMesh,srcMesh),_split(targetMesh,srcMesh,policy) - { - // SPEC: - // "Limitation. For the P1P0 barycentric improvement only triangle source cells in 2D and - // tetrahedrons in 3D will be supported by interpolators. If a non - // triangle/tetrahedron source cell is detected an INTERP_KERNEL::Exception should be thrown." - - // Check types of source elements here rather than in intersectCells() since a wrong type can be - // found late after a long time of calculation. - - const unsigned long numSrcElems = srcMesh.getNumberOfElements(); - for(unsigned long i = 0 ; i < numSrcElems ; ++i) - if ( srcMesh.getTypeOfElement( OTT::indFC(i) ) != NORM_TETRA4 ) - throw INTERP_KERNEL::Exception("P1P0 barycentric algorithm works only with tetrahedral source meshes"); - } - - /** - * Destructor. - * Liberates the SplitterTetra objects and potential sub-node points that have been allocated. - * - */ - template - PolyhedronIntersectorP1P0Bary::~PolyhedronIntersectorP1P0Bary() - { - releaseArrays(); - } - - template - void PolyhedronIntersectorP1P0Bary::releaseArrays() - { - for(typename std::vector< SplitterTetra* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) - delete *iter; - _split.releaseArrays(); - _tetra.clear(); - } - - //================================================================================ - /*! - * \brief This method computes a value per each node of source cell for each target cell. - * \param srcCell - a source tetrahedron - * \param tgtCells - target elements - * \param res - matrix to fill in - */ - //================================================================================ - - template - void PolyhedronIntersectorP1P0Bary::intersectCells(ConnType tgtCell, - const std::vector& srcCells, - MyMatrix& res) - { - typename MyMatrix::value_type& resRow=res[tgtCell]; - - int nbOfNodesT=Intersector3D::_target_mesh.getNumberOfNodesOfElement(OTT::indFC(tgtCell)); - releaseArrays(); - _split.splitTargetCell(tgtCell,nbOfNodesT,_tetra); - - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - // intersect a source tetrahedron with each target tetrahedron: get intersection volume and barycenter - double baryCentre[SPACEDIM], total_baryCentre[3] = { 0., 0., 0.}; - double interVolume = 0; - for(typename std::vector*>::iterator iterTetraT = _tetra.begin(); iterTetraT != _tetra.end(); ++iterTetraT) - { - SplitterTetra *tmp=*iterTetraT; - tmp->clearVolumesCache(); - double volume = tmp->intersectSourceCell(*iterCellS, baryCentre); - if ( volume > 0 ) - { - interVolume += volume; - for ( int i = 0; i < SPACEDIM; ++i ) - total_baryCentre[i] += baryCentre[i]*volume; - } - } - if(interVolume!=0) - { - for ( int i = 0; i < SPACEDIM; ++i ) - total_baryCentre[i] /= interVolume; - - // coordinates of the source tetrahedron - std::vector srcCellCoords(4); - for ( int n = 0; n < 4; ++n ) - srcCellCoords[ n ] = getCoordsOfNode( n, *iterCellS, Intersector3D::_src_mesh ); - - // compute barycentric coordinates - double baryCoords[4]; - barycentric_coords( srcCellCoords, total_baryCentre, baryCoords); - - // store coeffs of each node of the source tetrahedron - const ConnType *srcCellNodes=Intersector3D::_src_mesh.getConnectivityPtr()+OTT::conn2C(Intersector3D::_src_mesh.getConnectivityIndexPtr()[*iterCellS]); - for ( int n = 0; n < 4; ++n ) - { - double val = baryCoords[n] * interVolume; - ConnType curNodeS = srcCellNodes[n]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(curNodeS); - if(iterRes!=resRow.end()) - { - val += iterRes->second; - resRow.erase( curNodeS ); - } - resRow.insert(std::make_pair(curNodeS,val)); - } - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx deleted file mode 100644 index 736188661..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2007-2010 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 __PolyhedronIntersectorP1P1_HXX__ -#define __PolyhedronIntersectorP1P1_HXX__ - -#include "Intersector3DP1P1.hxx" -#include "SplitterTetra.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - - - /** - * \brief Class responsible for calculating intersection between a hexahedron target element and - * the source elements. - * - */ - template - class PolyhedronIntersectorP1P1 : public Intersector3DP1P1 - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - - PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); - - ~PolyhedronIntersectorP1P1(); - - void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx deleted file mode 100644 index f80348924..000000000 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (C) 2007-2010 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 __PolyhedronIntersectorP1P1_TXX__ -#define __PolyhedronIntersectorP1P1_TXX__ - -#include "PolyhedronIntersectorP1P1.hxx" -#include "Intersector3DP1P1.txx" -#include "MeshUtils.hxx" - -#include "SplitterTetra.txx" - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating object from target cell global number - * - * @param targetMesh mesh containing the target elements - * @param srcMesh mesh containing the source elements - * @param policy splitting policy to be used - */ - template - PolyhedronIntersectorP1P1::PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy):Intersector3DP1P1(targetMesh,srcMesh) - { - // SPEC: - // "Limitation. Concerning P1P1 3D improvement only tetrahedron will be supported. - // If another type than tetrahedron is detected an INTERP_KERNEL::Exception should be thrown" - - // Check types of elements here rather than in intersectCells() since a wrong type can be - // found late after a long time of calculation. - - const unsigned long numSrcElems = srcMesh.getNumberOfElements(); - for(unsigned long i = 0 ; i < numSrcElems ; ++i) - if ( srcMesh.getTypeOfElement( OTT::indFC( i )) != NORM_TETRA4 ) - throw INTERP_KERNEL::Exception("P1P1 3D algorithm works only with tetrahedral meshes"); - - const unsigned long numTgtElems = targetMesh.getNumberOfElements(); - for(unsigned long i = 0 ; i < numTgtElems ; ++i) - if ( targetMesh.getTypeOfElement( OTT::indFC( i )) != NORM_TETRA4 ) - throw INTERP_KERNEL::Exception("P1P1 3D algorithm works only with tetrahedral meshes"); - } - - /** - * Destructor. - */ - template - PolyhedronIntersectorP1P1::~PolyhedronIntersectorP1P1() - { - } - - /** - * Calculates the volume of intersection of an element in the source mesh and the target element - * represented by the object. - * - * @param targetCell in C mode. - * @param srcCells in C mode. - */ - template - void PolyhedronIntersectorP1P1::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) - { -#ifdef _DEBUG_ - UnitTetraIntersectionBary b; b.init(); -#endif - // split the targetCell into dual cells - std::pair< int, std::vector > subTetraNodes[24]; // a node of sub tetra and its coordinates - const double* nodes[4]; int conn[4]; - for(int node = 0; node < 4 ; ++node) - nodes[node]=getCoordsOfNode2(node, OTT::indFC(targetCell), - Intersector3D::_target_mesh,conn[node]); - SplitterTetra tgtTetra(Intersector3D::_src_mesh, nodes, conn); - for (int i=0; i<24; i++) - { - subTetraNodes[i].second.resize(12); - tgtTetra.splitMySelfForDual(&subTetraNodes[i].second[0],i,subTetraNodes[i].first); - } - // intersect each source tetrahedron with each of target dual cells - SplitterTetra* subTetrasS[24]; - for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) - { - // split a source cell into dual cells - for(int node = 0; node < 4 ; ++node) - nodes[node]=getCoordsOfNode2(node, OTT::indFC(*iterCellS), - Intersector3D::_src_mesh,conn[node]); - - SplitterTetra srcTetra(Intersector3D::_target_mesh, nodes, conn); - srcTetra.splitIntoDualCells(subTetrasS); - - // intersect each target subTetra with each source one - for(int i=0;i<24;i++) - { - SplitterTetra *tmp=subTetrasS[i]; - ConnType sourceNode=OTT::indFC(tmp->getId(0)); - for(int j=0;j<24;j++) - { - const double* tetraNodes12 = &subTetraNodes[j].second[0]; - const double* tetraNodesT[4]={ tetraNodes12, tetraNodes12+3, tetraNodes12+6, tetraNodes12+9 }; - double volume = tmp->intersectTetra( tetraNodesT ); - if(volume!=0.) - { - ConnType tgtNode=subTetraNodes[j].first; - typename MyMatrix::value_type& resRow = res[tgtNode]; - typename MyMatrix::value_type::const_iterator iterRes=resRow.find( sourceNode ); - if(iterRes!=resRow.end()) - { - volume += (*iterRes).second; - resRow.erase(sourceNode); - } - resRow.insert(std::make_pair(sourceNode,volume)); - } - } - delete tmp; - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/RegionNode.hxx b/src/INTERP_KERNEL/RegionNode.hxx deleted file mode 100644 index 4f70d045a..000000000 --- a/src/INTERP_KERNEL/RegionNode.hxx +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2007-2010 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 __REGIONNODE_HXX__ -#define __REGIONNODE_HXX__ - -#include "MeshRegion.hxx" - -namespace INTERP_KERNEL -{ - - /** - * \brief Class containing a tuplet of a source region and a target region. - * This is used as the object to put on the stack in the depth-first search - * in the bounding-box filtering process. - */ - template - class RegionNode - { - public: - - RegionNode() { } - - ~RegionNode() { } - - /** - * Accessor to source region - * - * @return reference to source region - */ - MeshRegion& getSrcRegion() { return _srcRegion; } - - /** - * Accessor to target region - * - * @return reference to target region - */ - MeshRegion& getTargetRegion() { return _targetRegion; } - - private: - - /// source region - MeshRegion _srcRegion; - - /// target region - MeshRegion _targetRegion; - - }; - -} - -#endif diff --git a/src/INTERP_KERNEL/SplitterTetra.hxx b/src/INTERP_KERNEL/SplitterTetra.hxx deleted file mode 100644 index cbb04457d..000000000 --- a/src/INTERP_KERNEL/SplitterTetra.hxx +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (C) 2007-2010 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 __SPLITTERTETRA_HXX__ -#define __SPLITTERTETRA_HXX__ - -#include "TransformedTriangle.hxx" -#include "TetraAffineTransform.hxx" -#include "InterpolationOptions.hxx" -#include "InterpKernelHashMap.hxx" - -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - /** - * \brief Class representing a triangular face, used as key in caching hash map in SplitterTetra. - * - */ - class TriangleFaceKey - { - public: - - /** - * Constructor - * Sorts the given nodes (so that the order in which they are passed does not matter) and - * calculates a hash value for the key. - * - * @param node1 global number of the first node of the face - * @param node2 global number of the second node of the face - * @param node3 global number of the third node of the face - */ - TriangleFaceKey(int node1, int node2, int node3) - { - sort3Ints(_nodes, node1, node2, node3); - _hashVal = ( _nodes[0] + _nodes[1] + _nodes[2] ) % 29; - } - - /** - * Equality comparison operator. - * Compares this TriangleFaceKey object to another and determines if they represent the same face. - * - * @param key TriangleFaceKey with which to compare - * @return true if key has the same three nodes as this object, false if not - */ - bool operator==(const TriangleFaceKey& key) const - { - return _nodes[0] == key._nodes[0] && _nodes[1] == key._nodes[1] && _nodes[2] == key._nodes[2]; - } - - /** - * Returns a hash value for the object, based on its three nodes. - * This value is not unique for each face. - * - * @return a hash value for the object - */ - int hashVal() const - { - return _hashVal; - } - - inline void sort3Ints(int* sorted, int node1, int node2, int node3); - - private: - /// global numbers of the three nodes, sorted in ascending order - int _nodes[3]; - - /// hash value for the object, calculated in the constructor - int _hashVal; - }; - - /** - * Method to sort three integers in ascending order - * - * @param sorted int[3] array in which to store the result - * @param x1 first integer - * @param x2 second integer - * @param x3 third integer - */ - inline void TriangleFaceKey::sort3Ints(int* sorted, int x1, int x2, int x3) - { - if(x1 < x2) - { - if(x1 < x3) - { - // x1 is min - sorted[0] = x1; - sorted[1] = x2 < x3 ? x2 : x3; - sorted[2] = x2 < x3 ? x3 : x2; - } - else - { - // x3, x1, x2 - sorted[0] = x3; - sorted[1] = x1; - sorted[2] = x2; - } - } - else // x2 < x1 - { - if(x2 < x3) - { - // x2 is min - sorted[0] = x2; - sorted[1] = x1 < x3 ? x1 : x3; - sorted[2] = x1 < x3 ? x3 : x1; - } - else - { - // x3, x2, x1 - sorted[0] = x3; - sorted[1] = x2; - sorted[2] = x1; - } - } - } - - /** - * \brief Template specialization of INTERP_KERNEL::hash function object for use with a - * with TriangleFaceKey as key class. - * - */ - template<> class hash - { - public: - /** - * Operator() that returns the precalculated hashvalue of a TriangleFaceKey object. - * - * @param key a TriangleFaceKey object - * @return an integer hash value for key - */ - int operator()(const INTERP_KERNEL::TriangleFaceKey& key) const - { - return key.hashVal(); - } - }; -} - -namespace INTERP_KERNEL -{ - - /** - * \brief Class calculating the volume of intersection between a tetrahedral target element and - * source elements with triangular or quadratilateral faces. - * - */ - template - class SplitterTetra - { - public: - - SplitterTetra(const MyMeshType& srcMesh, const double** tetraCorners, const typename MyMeshType::MyConnType *nodesId); - - ~SplitterTetra(); - - double intersectSourceCell(typename MyMeshType::MyConnType srcCell, double* baryCentre=0); - - double intersectTetra(const double** tetraCorners); - - typename MyMeshType::MyConnType getId(int id) { return _conn[id]; } - - void splitIntoDualCells(SplitterTetra **output); - - void splitMySelfForDual(double* output, int i, typename MyMeshType::MyConnType& nodeId); - - void clearVolumesCache(); - - private: - // member functions - inline void createAffineTransform(const double** corners); - inline void checkIsOutside(const double* pt, bool* isOutside) const; - inline void calculateNode(typename MyMeshType::MyConnType globalNodeNum); - inline void calculateVolume(TransformedTriangle& tri, const TriangleFaceKey& key); - - - /// disallow copying - SplitterTetra(const SplitterTetra& t); - - /// disallow assignment - SplitterTetra& operator=(const SplitterTetra& t); - - // member variables - /// affine transform associated with this target element - TetraAffineTransform* _t; - - /// HashMap relating node numbers to transformed nodes, used for caching - HashMap< int , double* > _nodes; - - /// HashMap relating triangular faces to calculated volume contributions, used for caching - HashMap< TriangleFaceKey, double -// #ifdef WIN32 -// , hash_compare -// #endif - > _volumes; - - /// reference to the source mesh - const MyMeshType& _src_mesh; - - // node id of the first node in target mesh in C mode. - typename MyMeshType::MyConnType _conn[4]; - - double _coords[12]; - }; - - /** - * Creates the affine transform _t from the corners of the tetrahedron. Used by the constructors - * - * @param corners double*[4] array containing pointers to four double[3] arrays with the - * coordinates of the corners of the tetrahedron - */ - template - inline void SplitterTetra::createAffineTransform(const double** corners) - { - // create AffineTransform from tetrahedron - _t = new TetraAffineTransform( corners ); - } - - /** - * Function used to filter out elements by checking if they belong to one of the halfspaces - * x <= 0, x >= 1, y <= 0, y >= 1, z <= 0, z >= 1, (indexed 0 - 7). The function updates an array of boolean variables - * which indicates whether the points that have already been checked are all in a halfspace. For each halfspace, - * the corresponding array element will be true if and only if it was true when the method was called and pt lies in the halfspace. - * - * @param pt double[3] containing the coordiantes of a transformed point - * @param isOutside bool[8] which indicate the results of earlier checks. - */ - template - inline void SplitterTetra::checkIsOutside(const double* pt, bool* isOutside) const - { - isOutside[0] = isOutside[0] && (pt[0] <= 0.0); - isOutside[1] = isOutside[1] && (pt[0] >= 1.0); - isOutside[2] = isOutside[2] && (pt[1] <= 0.0); - isOutside[3] = isOutside[3] && (pt[1] >= 1.0); - isOutside[4] = isOutside[4] && (pt[2] <= 0.0); - isOutside[5] = isOutside[5] && (pt[2] >= 1.0); - isOutside[6] = isOutside[6] && (1.0 - pt[0] - pt[1] - pt[2] <= 0.0); - isOutside[7] = isOutside[7] && (1.0 - pt[0] - pt[1] - pt[2] >= 1.0); - } - - /** - * Calculates the transformed node with a given global node number. - * Gets the coordinates for the node in _src_mesh with the given global number and applies TetraAffineTransform - * _t to it. Stores the result in the cache _nodes. The non-existance of the node in _nodes should be verified before - * calling. - * - * @param globalNodeNum global node number of the node in the mesh _src_mesh - * - */ - template - inline void SplitterTetra::calculateNode(typename MyMeshType::MyConnType globalNodeNum) - { - const double* node = _src_mesh.getCoordinatesPtr()+MyMeshType::MY_SPACEDIM*globalNodeNum; - double* transformedNode = new double[MyMeshType::MY_SPACEDIM]; - assert(transformedNode != 0); - _t->apply(transformedNode, node); - _nodes[globalNodeNum] = transformedNode; - } - - /** - * Calculates the volume contribution from the given TransformedTriangle and stores it with the given key in . - * Calls TransformedTriangle::calculateIntersectionVolume to perform the calculation. - * - * @param tri triangle for which to calculate the volume contribution - * @param key key associated with the face - */ - template - inline void SplitterTetra::calculateVolume(TransformedTriangle& tri, const TriangleFaceKey& key) - { - const double vol = tri.calculateIntersectionVolume(); - _volumes.insert(std::make_pair(key, vol)); - } - - template - class SplitterTetra2 - { - public: - SplitterTetra2(const MyMeshTypeT& targetMesh, const MyMeshTypeS& srcMesh, SplittingPolicy policy); - ~SplitterTetra2(); - void releaseArrays(); - void splitTargetCell(typename MyMeshTypeT::MyConnType targetCell, typename MyMeshTypeT::MyConnType nbOfNodesT, - typename std::vector< SplitterTetra* >& tetra); - void fiveSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra); - void sixSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra); - void calculateGeneral24Tetra(typename std::vector< SplitterTetra* >& tetra); - void calculateGeneral48Tetra(typename std::vector< SplitterTetra* >& tetra); - void splitPyram5(typename std::vector< SplitterTetra* >& tetra); - void splitConvex(typename MyMeshTypeT::MyConnType targetCell, - typename std::vector< SplitterTetra* >& tetra); - void calculateSubNodes(const MyMeshTypeT& targetMesh, typename MyMeshTypeT::MyConnType targetCell); - inline const double* getCoordsOfSubNode(typename MyMeshTypeT::MyConnType node); - inline const double* getCoordsOfSubNode2(typename MyMeshTypeT::MyConnType node, typename MyMeshTypeT::MyConnType& nodeId); - //template - inline void calcBarycenter(int n, double* barycenter, const typename MyMeshTypeT::MyConnType* pts); - private: - const MyMeshTypeT& _target_mesh; - const MyMeshTypeS& _src_mesh; - SplittingPolicy _splitting_pol; - /// vector of pointers to double[3] containing the coordinates of the - /// (sub) - nodes of split target cell - std::vector _nodes; - std::vector _node_ids; - }; - - /** - * Calculates the barycenter of n (sub) - nodes - * - * @param n number of nodes for which to calculate barycenter - * @param barycenter pointer to double[3] array in which to store the result - * @param pts pointer to int[n] array containing the (sub)-nodes for which to calculate the barycenter - */ - template - //template - inline void SplitterTetra2::calcBarycenter(int n, double* barycenter, const typename MyMeshTypeT::MyConnType* pts) - { - barycenter[0] = barycenter[1] = barycenter[2] = 0.0; - for(int i = 0; i < n ; ++i) - { - const double* pt = getCoordsOfSubNode(pts[i]); - barycenter[0] += pt[0]; - barycenter[1] += pt[1]; - barycenter[2] += pt[2]; - } - - barycenter[0] /= n; - barycenter[1] /= n; - barycenter[2] /= n; - } - - /** - * Accessor to the coordinates of a given (sub)-node - * - * @param node local number of the (sub)-node 0,..,7 are the elements nodes, sub-nodes are numbered from 8,.. - * @return pointer to double[3] containing the coordinates of the nodes - */ - template - inline const double* SplitterTetra2::getCoordsOfSubNode(typename MyMeshTypeT::MyConnType node) - { - // replace "at()" with [] for unsafe but faster access - return _nodes.at(node); - } - - /** - * Accessor to the coordinates of a given (sub)-node - * - * @param node local number of the (sub)-node 0,..,7 are the elements nodes, sub-nodes are numbered from 8,.. - * @param nodeId is an output that is node id in target whole mesh in C mode. - * @return pointer to double[3] containing the coordinates of the nodes - */ - template - const double* SplitterTetra2::getCoordsOfSubNode2(typename MyMeshTypeT::MyConnType node, typename MyMeshTypeT::MyConnType& nodeId) - { - const double *ret=_nodes.at(node); - if(node<8) - nodeId=_node_ids[node]; - else - nodeId=-1; - return ret; - } -} - -#endif diff --git a/src/INTERP_KERNEL/SplitterTetra.txx b/src/INTERP_KERNEL/SplitterTetra.txx deleted file mode 100644 index d1e084876..000000000 --- a/src/INTERP_KERNEL/SplitterTetra.txx +++ /dev/null @@ -1,957 +0,0 @@ -// Copyright (C) 2007-2010 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 __SPLITTERTETRA_TXX__ -#define __SPLITTERTETRA_TXX__ - -#include "SplitterTetra.hxx" - -#include "TetraAffineTransform.hxx" -#include "TransformedTriangle.hxx" -#include "MeshUtils.hxx" -#include "VectorUtils.hxx" -#include "CellModel.hxx" -#include "Log.hxx" -#include "UnitTetraIntersectionBary.hxx" - -#include -#include -#include -#include -#include - -/// Smallest volume of the intersecting elements in the transformed space that will be returned as non-zero. -/// Since the scale is always the same in the transformed space (the target tetrahedron is unitary), this number is independent of the scale of the meshes. -#define SPARSE_TRUNCATION_LIMIT 1.0e-14 - -namespace INTERP_KERNEL -{ - - /** - * Constructor creating object from target cell global number - * - * @param srcMesh mesh containing the source elements - * @param targetMesh mesh containing the target elements - * @param targetCell global number of the target cell - * - */ - /*template - SplitterTetra::SplitterTetra(const MyMeshType& srcMesh, const MyMeshType& targetMesh, typename MyMeshType::MyConnType targetCell) - : _src_mesh(srcMesh), _t(0) - { - // get array of corners of target tetraedron - const double* tetraCorners[4]; - for(int i = 0 ; i < 4 ; ++i) - tetraCorners[i] = getCoordsOfNode(i, targetCell, targetMesh); - // create the affine transform - createAffineTransform(tetraCorners); - }*/ - - /*! - * output is expected to be allocated with 24*sizeof(void*) in order to store the 24 tetras. - * These tetras have to be deallocated. - */ - template - void SplitterTetra::splitIntoDualCells(SplitterTetra **output) - { - double tmp[12]; - const double *tmp2[4]={tmp,tmp+3,tmp+6,tmp+9}; - typename MyMeshType::MyConnType conn[4]={-1,-1,-1,-1}; - for(int i=0;i<24;i++) - { - splitMySelfForDual(tmp,i,conn[0]); - output[i]=new SplitterTetra(_src_mesh,tmp2,conn); - } - } - - /** - * Constructor creating object from the four corners of the tetrahedron. - * - * @param srcMesh mesh containing the source elements - * @param tetraCorners array of four pointers to double[3] arrays containing the coordinates of the - * corners of the tetrahedron - */ - template - SplitterTetra::SplitterTetra(const MyMeshType& srcMesh, const double** tetraCorners, const typename MyMeshType::MyConnType *nodesId) - : _t(0), _src_mesh(srcMesh) - { - std::copy(nodesId,nodesId+4,_conn); - _coords[0]=tetraCorners[0][0]; _coords[1]=tetraCorners[0][1]; _coords[2]=tetraCorners[0][2]; - _coords[3]=tetraCorners[1][0]; _coords[4]=tetraCorners[1][1]; _coords[5]=tetraCorners[1][2]; - _coords[6]=tetraCorners[2][0]; _coords[7]=tetraCorners[2][1]; _coords[8]=tetraCorners[2][2]; - _coords[9]=tetraCorners[3][0]; _coords[10]=tetraCorners[3][1]; _coords[11]=tetraCorners[3][2]; - // create the affine transform - createAffineTransform(tetraCorners); - } - - /*! - * This contructor is used to build part of 1/24th dual cell of tetraCorners. - * @param i is in 0..23 included. - * @param nodeId is the id of first node of this in target mesh in C mode. - */ - /*template - SplitterTetra::SplitterTetra(const MyMeshType& srcMesh, const double** tetraCorners, int i, typename MyMeshType::MyConnType nodeId) - : _t(0), _src_mesh(srcMesh), _conn(nodeId) - { - double *newCoords[4]; - splitMySelfForDual(tetraCorners,newCoords,i); - createAffineTransform(newCoords); - }*/ - - /** - * Destructor - * - * Deletes _t and the coordinates (double[3] vectors) in _nodes - * - */ - template - SplitterTetra::~SplitterTetra() - { - delete _t; - for(HashMap< int, double* >::iterator iter = _nodes.begin(); iter != _nodes.end() ; ++iter) - delete[] iter->second; - } - - /*! - * \Forget already calculated triangles, which is crucial for calculation of barycenter of intersection - */ - template - void SplitterTetra::clearVolumesCache() - { - _volumes.clear(); - } - - /*! - * This method destroys the 4 pointers pointed by tetraCorners[0],tetraCorners[1],tetraCorners[2] and tetraCorners[3] - * @param i is in 0..23 included. - * @param output is expected to be sized of 12 in order to. - */ - template - void SplitterTetra::splitMySelfForDual(double* output, int i, typename MyMeshType::MyConnType& nodeId) - { - double *tmp[4]; - int offset=i/6; - nodeId=_conn[offset]; - tmp[0]=_coords+3*offset; tmp[1]=_coords+((offset+1)%4)*3; tmp[2]=_coords+((offset+2)%4)*3; tmp[3]=_coords+((offset+3)%4)*3; - int caseToTreat=i%6; - int case1=caseToTreat/2; - int case2=caseToTreat%2; - const int tab[3][2]={{1,2},{3,2},{1,3}}; - const int *curTab=tab[case1]; - double pt0[3]; pt0[0]=(tmp[curTab[case2]][0]+tmp[0][0])/2.; pt0[1]=(tmp[curTab[case2]][1]+tmp[0][1])/2.; pt0[2]=(tmp[curTab[case2]][2]+tmp[0][2])/2.; - double pt1[3]; pt1[0]=(tmp[0][0]+tmp[curTab[0]][0]+tmp[curTab[1]][0])/3.; pt1[1]=(tmp[0][1]+tmp[curTab[0]][1]+tmp[curTab[1]][1])/3.; pt1[2]=(tmp[0][2]+tmp[curTab[0]][2]+tmp[curTab[1]][2])/3.; - double pt2[3]; pt2[0]=(tmp[0][0]+tmp[1][0]+tmp[2][0]+tmp[3][0])/4.; pt2[1]=(tmp[0][1]+tmp[1][1]+tmp[2][1]+tmp[3][1])/4.; pt2[2]=(tmp[0][2]+tmp[1][2]+tmp[2][2]+tmp[3][2])/4.; - std::copy(pt1,pt1+3,output+case2*3); - std::copy(pt0,pt0+3,output+(abs(case2-1))*3); - std::copy(pt2,pt2+3,output+2*3); - std::copy(tmp[0],tmp[0]+3,output+3*3); - } - - /** - * Calculates the volume of intersection of an element in the source mesh and the target element. - * It first calculates the transformation that takes the target tetrahedron into the unit tetrahedron. After that, the - * faces of the source element are triangulated and the calculated transformation is applied - * to each triangle. The algorithm of Grandy, implemented in INTERP_KERNEL::TransformedTriangle is used - * to calculate the contribution to the volume from each triangle. The volume returned is the sum of these contributions - * divided by the determinant of the transformation. - * - * The class will cache the intermediary calculations of transformed nodes of source cells and volumes associated - * with triangulated faces to avoid having to recalculate these. - * - * @param element global number of the source element in C mode. - */ - template - double SplitterTetra::intersectSourceCell(typename MyMeshType::MyConnType element, - double* baryCentre) - { - typedef typename MyMeshType::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshType::My_numPol; - //{ could be done on outside? - // check if we have planar tetra element - if(_t->determinant() == 0.0) - { - // tetra is planar - LOG(2, "Planar tetra -- volume 0"); - return 0.0; - } - - // get type of cell - NormalizedCellType normCellType=_src_mesh.getTypeOfElement(OTT::indFC(element)); - const CellModel& cellModelCell=CellModel::getCellModel(normCellType); - unsigned nbOfNodes4Type=cellModelCell.isDynamic() ? _src_mesh.getNumberOfNodesOfElement(OTT::indFC(element)) : cellModelCell.getNumberOfNodes(); - // halfspace filtering - bool isOutside[8] = {true, true, true, true, true, true, true, true}; - bool isTargetOutside = false; - - // calculate the coordinates of the nodes - int *cellNodes=new int[nbOfNodes4Type]; - for(int i = 0;i<(int)nbOfNodes4Type;++i) - { - // we could store mapping local -> global numbers too, but not sure it is worth it - const int globalNodeNum = getGlobalNumberOfNode(i, OTT::indFC(element), _src_mesh); - cellNodes[i]=globalNodeNum; - if(_nodes.find(globalNodeNum) == _nodes.end()) - { - //for(HashMap< int , double* >::iterator iter3=_nodes.begin();iter3!=_nodes.end();iter3++) - // std::cout << (*iter3).first << " "; - //std::cout << std::endl << "*** " << globalNodeNum << std::endl; - calculateNode(globalNodeNum); - } - - checkIsOutside(_nodes[globalNodeNum], isOutside); - } - - // halfspace filtering check - // NB : might not be beneficial for caching of triangles - for(int i = 0; i < 8; ++i) - { - if(isOutside[i]) - { - isTargetOutside = true; - } - } - - double totalVolume = 0.0; - - if(!isTargetOutside) - { - /// calculator of intersection barycentre - UnitTetraIntersectionBary baryCalculator( _t->determinant() < 0.); - - // get nb of sons of a cell - const ConnType* rawCellConn = _src_mesh.getConnectivityPtr() + OTT::conn2C( _src_mesh.getConnectivityIndexPtr()[ element ]); - const int rawNbCellNodes = _src_mesh.getConnectivityIndexPtr()[ element+1 ] - _src_mesh.getConnectivityIndexPtr()[ element ]; - unsigned nbOfSons = cellModelCell.getNumberOfSons2(rawCellConn, rawNbCellNodes); - - for(unsigned ii = 0 ; ii < nbOfSons; ++ii) - { - // get sons connectivity - NormalizedCellType faceType; - int *faceNodes, nbFaceNodes; - if ( cellModelCell.isDynamic() ) - { - faceNodes=new int[nbOfNodes4Type]; - nbFaceNodes = cellModelCell.fillSonCellNodalConnectivity2(ii,rawCellConn,rawNbCellNodes,faceNodes,faceType); - for ( int i = 0; i < nbFaceNodes; ++i ) - faceNodes[i] = OTT::coo2C(faceNodes[i]); - } - else - { - faceType = cellModelCell.getSonType(ii); - const CellModel& faceModel=CellModel::getCellModel(faceType); - assert(faceModel.getDimension() == 2); - faceNodes=new int[faceModel.getNumberOfNodes()]; - cellModelCell.fillSonCellNodalConnectivity(ii,cellNodes,faceNodes); - } - // intersect a son with the unit tetra - switch(faceType) - { - case NORM_TRI3: - { - // create the face key - TriangleFaceKey key = TriangleFaceKey(faceNodes[0], faceNodes[1], faceNodes[2]); - - // calculate the triangle if needed - if(_volumes.find(key) == _volumes.end()) - { - TransformedTriangle tri(_nodes[faceNodes[0]], _nodes[faceNodes[1]], _nodes[faceNodes[2]]); - calculateVolume(tri, key); - totalVolume += _volumes[key]; - if ( baryCentre ) - baryCalculator.addSide( tri ); - } else { - // count negative as face has reversed orientation - totalVolume -= _volumes[key]; - } - } - break; - - case NORM_QUAD4: - - // simple triangulation of faces along a diagonal : - // - // 2 ------ 3 - // | / | - // | / | - // | / | - // | / | - // | / | - // | / | - // 1 ------ 4 - // - //? not sure if this always works - { - // calculate the triangles if needed - - // local nodes 1, 2, 3 - TriangleFaceKey key1 = TriangleFaceKey(faceNodes[0], faceNodes[1], faceNodes[2]); - if(_volumes.find(key1) == _volumes.end()) - { - TransformedTriangle tri(_nodes[faceNodes[0]], _nodes[faceNodes[1]], _nodes[faceNodes[2]]); - calculateVolume(tri, key1); - totalVolume += _volumes[key1]; - } else { - // count negative as face has reversed orientation - totalVolume -= _volumes[key1]; - } - - // local nodes 1, 3, 4 - TriangleFaceKey key2 = TriangleFaceKey(faceNodes[0], faceNodes[2], faceNodes[3]); - if(_volumes.find(key2) == _volumes.end()) - { - TransformedTriangle tri(_nodes[faceNodes[0]], _nodes[faceNodes[2]], _nodes[faceNodes[3]]); - calculateVolume(tri, key2); - totalVolume += _volumes[key2]; - } - else - { - // count negative as face has reversed orientation - totalVolume -= _volumes[key2]; - } - } - break; - - case NORM_POLYGON: - { - int nbTria = nbFaceNodes - 2; // split polygon into nbTria triangles - for ( int iTri = 0; iTri < nbTria; ++iTri ) - { - TriangleFaceKey key = TriangleFaceKey(faceNodes[0], faceNodes[1+iTri], faceNodes[2+iTri]); - if(_volumes.find(key) == _volumes.end()) - { - TransformedTriangle tri(_nodes[faceNodes[0]], _nodes[faceNodes[1+iTri]], _nodes[faceNodes[2+iTri]]); - calculateVolume(tri, key); - totalVolume += _volumes[key]; - } - else - { - totalVolume -= _volumes[key]; - } - } - } - break; - - default: - std::cout << "+++ Error : Only elements with triangular and quadratilateral faces are supported at the moment." << std::endl; - assert(false); - } - delete [] faceNodes; - } - - if ( baryCentre ) { - baryCalculator.getBary( baryCentre ); - _t->reverseApply( baryCentre, baryCentre ); - } - } - delete [] cellNodes; - // reset if it is very small to keep the matrix sparse - // is this a good idea? - if(epsilonEqual(totalVolume, 0.0, SPARSE_TRUNCATION_LIMIT)) - { - totalVolume = 0.0; - } - - LOG(2, "Volume = " << totalVolume << ", det= " << _t->determinant()); - - // NB : fault in article, Grandy, [8] : it is the determinant of the inverse transformation - // that should be used (which is equivalent to dividing by the determinant) - return std::fabs(1.0 / _t->determinant() * totalVolume) ; - } - - /** - * Calculates the volume of intersection of this tetrahedron with another one. - */ - template - double SplitterTetra::intersectTetra(const double** tetraCorners) - { - //{ could be done on outside? - // check if we have planar tetra element - if(_t->determinant() == 0.0) - { - // tetra is planar - LOG(2, "Planar tetra -- volume 0"); - return 0.0; - } - - const unsigned nbOfNodes4Type=4; - // halfspace filtering - bool isOutside[8] = {true, true, true, true, true, true, true, true}; - bool isTargetOutside = false; - - // calculate the transformed coordinates of the nodes - double nodes[nbOfNodes4Type][3]; - for(int i = 0;i<(int)nbOfNodes4Type;++i) - { - _t->apply(nodes[i], tetraCorners[i]); - checkIsOutside(nodes[i], isOutside); - } - - // halfspace filtering check - // NB : might not be beneficial for caching of triangles - for(int i = 0; i < 8; ++i) - { - if(isOutside[i]) - { - isTargetOutside = true; - } - } - - double totalVolume = 0.0; - - if(!isTargetOutside) - { - const CellModel& cellModelCell=CellModel::getCellModel(NORM_TETRA4); - int cellNodes[4] = { 0, 1, 2, 3 }, faceNodes[3]; - - for(unsigned ii = 0 ; ii < 4 ; ++ii) - { - cellModelCell.fillSonCellNodalConnectivity(ii,cellNodes,faceNodes); - - TransformedTriangle tri(nodes[faceNodes[0]], nodes[faceNodes[1]], nodes[faceNodes[2]]); - double vol = tri.calculateIntersectionVolume(); - totalVolume += vol; - } - - // reset if it is very small to keep the matrix sparse - // is this a good idea? - if(epsilonEqual(totalVolume, 0.0, SPARSE_TRUNCATION_LIMIT)) - { - totalVolume = 0.0; - } - } - LOG(2, "Volume = " << totalVolume << ", det= " << _t->determinant()); - - // NB : fault in article, Grandy, [8] : it is the determinant of the inverse transformation - // that should be used (which is equivalent to dividing by the determinant) - return std::fabs(1.0 / _t->determinant() * totalVolume) ; - } - - //////////////////////////////////////////////////////// - - template - SplitterTetra2::SplitterTetra2(const MyMeshTypeT& targetMesh, const MyMeshTypeS& srcMesh, SplittingPolicy policy) - :_target_mesh(targetMesh),_src_mesh(srcMesh),_splitting_pol(policy) - { - } - - template - SplitterTetra2::~SplitterTetra2() - { - releaseArrays(); - } - - template - void SplitterTetra2::releaseArrays() - { - // free potential sub-mesh nodes that have been allocated - typename MyMeshTypeT::MyConnType nbOfNodesT = _node_ids.size();// Issue 0020634. - if((int)_nodes.size()>=/*8*/nbOfNodesT) - { - std::vector::iterator iter = _nodes.begin() + /*8*/nbOfNodesT; - while(iter != _nodes.end()) - { - delete[] *iter; - ++iter; - } - } - _nodes.clear(); - } - - /*! - * @param targetCell in C mode. - * @param tetra is the output result tetra containers. - */ - template - void SplitterTetra2::splitTargetCell(typename MyMeshTypeT::MyConnType targetCell, - typename MyMeshTypeT::MyConnType nbOfNodesT, - typename std::vector< SplitterTetra* >& tetra) - { - typedef typename MyMeshTypeT::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshTypeT::My_numPol; - const int numTetra = static_cast(_splitting_pol); - if(nbOfNodesT==4) - { - _nodes.resize(8); - _node_ids.resize(8); - tetra.reserve(1); - const double *nodes[4]; - int conn[4]; - for(int node = 0; node < 4 ; ++node) - { - nodes[node]=getCoordsOfNode2(node, OTT::indFC(targetCell),_target_mesh,conn[node]); - } - std::copy(conn,conn+4,_node_ids.begin()); - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); - tetra.push_back(t); - return ; - } - // Issue 0020634. To pass nbOfNodesT to calculateSubNodes (don't want to add an arg) - _node_ids.resize(nbOfNodesT); - - // pre-calculate nodes - calculateSubNodes(_target_mesh, OTT::indFC(targetCell)); - - tetra.reserve(numTetra); - _nodes.reserve(30); // we never have more than this - - switch ( nbOfNodesT ) - { - case 8: - { - switch(_splitting_pol) - { - case PLANAR_FACE_5: - { - const int subZone[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; - fiveSplit(subZone,tetra); - } - break; - - case PLANAR_FACE_6: - { - const int subZone[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; - sixSplit(subZone,tetra); - } - break; - - case GENERAL_24: - { - calculateGeneral24Tetra(tetra); - } - break; - - case GENERAL_48: - { - calculateGeneral48Tetra(tetra); - } - break; - default: - assert(false); - } - break; - } - case 5: - { - splitPyram5(tetra); - break; - } - default: - { - splitConvex(targetCell, tetra); - } - } - } - - /** - * Splits the hexahedron into five tetrahedra. - * This method adds five SplitterTetra objects to the vector tetra. - * - * @param subZone the local node numbers corresponding to the hexahedron corners - these are mapped onto {0,..,7}. Providing this allows the - * splitting to be reused on the subzones of the GENERAL_* types of splitting - */ - template - void SplitterTetra2::fiveSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra) - { - // Schema according to which the splitting is performed. - // Each line represents one tetrahedron. The numbering is as follows : - // - // 7 ------ 6 - // /| /| - // / | / | - // 3 ------ 2 | - // | | | | - // | | | | - // | 4-----|- 5 - // | / | / - // 0 ------ 1 - - - static const int SPLIT_NODES_5[20] = - { - 0, 1, 5, 2, - 0, 4, 5, 7, - 0, 3, 7, 2, - 5, 6, 7, 2, - 0, 2, 5, 7 - }; - - // create tetrahedra - for(int i = 0; i < 5; ++i) - { - const double* nodes[4]; - int conn[4]; - for(int j = 0; j < 4; ++j) - { - nodes[j] = getCoordsOfSubNode2(subZone[ SPLIT_NODES_5[4*i+j] ],conn[j]); - } - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); - tetra.push_back(t); - } - } - - /** - * Splits the hexahedron into six tetrahedra. - * This method adds six SplitterTetra objects to the vector tetra. - * - * @param subZone the local node numbers corresponding to the hexahedron corners - these are mapped onto {0,..,7}. Providing this allows the - * splitting to be reused on the subzones of the GENERAL_* types of splitting - */ - template - void SplitterTetra2::sixSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra) - { - // Schema according to which the splitting is performed. - // Each line represents one tetrahedron. The numbering is as follows : - // - // 7 ------ 6 - // /| /| - // / | / | - // 3 ------ 2 | - // | | | | - // | | | | - // | 4-----|- 5 - // | / | / - // 0 ------ 1 - - static const int SPLIT_NODES_6[24] = - { - 0, 1, 5, 6, - 0, 2, 1, 6, - 0, 5, 4, 6, - 0, 4, 7, 6, - 0, 3, 2, 6, - 0, 7, 3, 6 - }; - - for(int i = 0; i < 6; ++i) - { - const double* nodes[4]; - int conn[4]; - for(int j = 0; j < 4; ++j) - { - nodes[j] = getCoordsOfSubNode2(subZone[ SPLIT_NODES_6[4*i+j] ],conn[j]); - } - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); - tetra.push_back(t); - } - } - - /** - * Splits the hexahedron into 24 tetrahedra. - * The splitting is done by combining the barycenter of the tetrahedron, the barycenter of each face - * and the nodes of each edge of the face. This creates 6 faces * 4 edges / face = 24 tetrahedra. - * The submesh nodes introduced are the barycenters of the faces and the barycenter of the cell. - * - */ - template - void SplitterTetra2::calculateGeneral24Tetra(typename std::vector< SplitterTetra* >& tetra) - { - // The two nodes of the original mesh cell used in each tetrahedron. - // The tetrahedra all have nodes (cellCenter, faceCenter, edgeNode1, edgeNode2) - // For the correspondance of the nodes, see the GENERAL_48_SUB_NODES table in calculateSubNodes - static const int TETRA_EDGES[48] = - { - // face with center 9 - 0,1, - 1,5, - 5,4, - 4,0, - // face with center 10 - 0,1, - 1,2, - 2,3, - 3,0, - // face with center 11 - 0,4, - 4,7, - 7,3, - 3,0, - // face with center 12 - 1,5, - 5,6, - 6,2, - 2,1, - // face with center 13 - 5,6, - 6,7, - 7,4, - 4,5, - // face with center 14 - 2,6, - 6,7, - 7,3, - 3,2 - }; - - // nodes to use for tetrahedron - const double* nodes[4]; - int conn[4]; - // get the cell center - nodes[0] = getCoordsOfSubNode2(14,conn[0]); - - for(int faceCenterNode = 8; faceCenterNode < 14; ++faceCenterNode) - { - // get the face center - nodes[1] = getCoordsOfSubNode2(faceCenterNode,conn[1]); - for(int j = 0; j < 4; ++j) - { - const int row = 4*(faceCenterNode - 9) + j; - nodes[2] = getCoordsOfSubNode2(TETRA_EDGES[2*row],conn[2]); - nodes[3] = getCoordsOfSubNode2(TETRA_EDGES[2*row + 1],conn[3]); - - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes, conn); - tetra.push_back(t); - } - } - } - - - /** - * Splits the hexahedron into 48 tetrahedra. - * The splitting is done by introducing the midpoints of all the edges - * and the barycenter of the element as submesh nodes. The 8 hexahedral subzones thus defined - * are then split into 6 tetrahedra each, as in Grandy, p. 449. The division of the subzones - * is done by calling sixSplit(). - * - */ - template - void SplitterTetra2::calculateGeneral48Tetra(typename std::vector< SplitterTetra* >& tetra) - { - // Define 8 hexahedral subzones as in Grandy, p449 - // the values correspond to the nodes that correspond to nodes 1,2,3,4,5,6,7,8 in the subcell - // For the correspondance of the nodes, see the GENERAL_48_SUB_NODES table in calculateSubNodes - static const int subZones[64] = - { - 0,8,21,12,9,20,26,22, - 8,1,13,21,20,10,23,26, - 12,21,16,3,22,26,25,17, - 21,13,2,16,26,23,18,25, - 9,20,26,22,4,11,24,14, - 20,10,23,26,11,5,15,24, - 22,26,25,17,14,24,19,7, - 26,23,18,25,24,15,6,19 - }; - - for(int i = 0; i < 8; ++i) - { - sixSplit(&subZones[8*i],tetra); - } - } - - /** - * Splits the NORM_PYRA5 into 2 tetrahedra. - */ - template - void SplitterTetra2::splitPyram5(typename std::vector< SplitterTetra* >& tetra) - { - static const int SPLIT_PYPA5[2][4] = - { - { - 0, 1, 2, 4 - }, - { - 0, 2, 3, 4 - } - }; - - // create tetrahedra - const double* nodes[4]; - int conn[4]; - for(int i = 0; i < 2; ++i) - { - for(int j = 0; j < 4; ++j) - nodes[j] = getCoordsOfSubNode2(SPLIT_PYPA5[i][j],conn[j]); - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); - tetra.push_back(t); - } - } - - /** - * Splits a convex cell into tetrahedra. - */ - template - void SplitterTetra2::splitConvex(typename MyMeshTypeT::MyConnType targetCell, - typename std::vector< SplitterTetra* >& tetra) - { - // Each face of a cell is split into triangles and - // each of triangles and a cell barycenter form a tetrahedron. - - typedef typename MyMeshTypeT::MyConnType ConnType; - const NumberingPolicy numPol=MyMeshTypeT::My_numPol; - - // get type of cell and nb of cell nodes - NormalizedCellType normCellType=_target_mesh.getTypeOfElement(OTT::indFC(targetCell)); - const CellModel& cellModelCell=CellModel::getCellModel(normCellType); - unsigned nbOfCellNodes=cellModelCell.isDynamic() ? _target_mesh.getNumberOfNodesOfElement(OTT::indFC(targetCell)) : cellModelCell.getNumberOfNodes(); - - // get nb of cell sons (faces) - const ConnType* rawCellConn = _target_mesh.getConnectivityPtr() + OTT::conn2C( _target_mesh.getConnectivityIndexPtr()[ targetCell ]); - const int rawNbCellNodes = _target_mesh.getConnectivityIndexPtr()[ targetCell+1 ] - _target_mesh.getConnectivityIndexPtr()[ targetCell ]; - unsigned nbOfSons = cellModelCell.getNumberOfSons2(rawCellConn, rawNbCellNodes); - - // indices of nodes of a son - static std::vector allNodeIndices; // == 0,1,2,...,nbOfCellNodes-1 - while ( allNodeIndices.size() < nbOfCellNodes ) - allNodeIndices.push_back( allNodeIndices.size() ); - std::vector classicFaceNodes(4); - int* faceNodes = cellModelCell.isDynamic() ? &allNodeIndices[0] : &classicFaceNodes[0]; - - // nodes of tetrahedron - int conn[4]; - const double* nodes[4]; - nodes[3] = getCoordsOfSubNode2( nbOfCellNodes,conn[3]); // barycenter - - for(unsigned ii = 0 ; ii < nbOfSons; ++ii) - { - // get indices of son's nodes: it's just next portion of allNodeIndices for polyhedron - // and some of allNodeIndices accodring to cell model for a classsic cell - unsigned nbFaceNodes = cellModelCell.getNumberOfNodesConstituentTheSon2(ii, rawCellConn, rawNbCellNodes); - if ( normCellType != NORM_POLYHED ) - cellModelCell.fillSonCellNodalConnectivity(ii,&allNodeIndices[0],faceNodes); - - int nbTetra = nbFaceNodes - 2; // split polygon into nbTetra triangles - - // create tetrahedra - for(int i = 0; i < nbTetra; ++i) - { - nodes[0] = getCoordsOfSubNode2( faceNodes[0], conn[0]); - nodes[1] = getCoordsOfSubNode2( faceNodes[1+i],conn[1]); - nodes[2] = getCoordsOfSubNode2( faceNodes[2+i],conn[2]); - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); - tetra.push_back(t); - } - - if ( normCellType == NORM_POLYHED ) - faceNodes += nbFaceNodes; // go to the next face - } - } - - /** - * Precalculates all the nodes. - * Retrieves the mesh nodes and allocates the necessary sub-mesh - * nodes according to the splitting policy used. - * This method is meant to be called once by the constructor. - * - * @param targetMesh the target mesh - * @param targetCell the global number of the cell that the object represents, in targetMesh mode. - * @param policy the splitting policy of the object - * - */ - template - void SplitterTetra2::calculateSubNodes(const MyMeshTypeT& targetMesh, typename MyMeshTypeT::MyConnType targetCell) - { - // retrieve real mesh nodes - - typename MyMeshTypeT::MyConnType nbOfNodesT = _node_ids.size();// Issue 0020634. _node_ids.resize(8); - for(int node = 0; node < nbOfNodesT ; ++node) - { - // calculate only normal nodes - _nodes.push_back(getCoordsOfNode2(node, targetCell, targetMesh,_node_ids[node])); - } - - switch ( nbOfNodesT ) - { - case 8: - - // create sub-mesh nodes if needed - switch(_splitting_pol) - { - case GENERAL_24: - { - // Each sub-node is the barycenter of 4 other nodes. - // For the faces, these are on the orignal mesh. - // For the barycenter, the four face sub-nodes are used. - static const int GENERAL_24_SUB_NODES[28] = - { - 0,1,4,5,// sub-node 9 (face) - 0,1,2,3,// sub-node 10 (face) - 0,3,4,7,// sub-node 11 (face) - 1,2,5,6,// sub-node 12 (face) - 4,5,6,7,// sub-node 13 (face) - 2,3,6,7,// sub-node 14 (face) - 9,10,11,12// sub-node 15 (cell) - }; - - for(int i = 0; i < 7; ++i) - { - double* barycenter = new double[3]; - calcBarycenter(4, barycenter, &GENERAL_24_SUB_NODES[4*i]); - _nodes.push_back(barycenter); - } - } - break; - - case GENERAL_48: - { - // Each sub-node is the barycenter of two other nodes. - // For the edges, these lie on the original mesh. - // For the faces, these are the edge sub-nodes. - // For the cell these are two face sub-nodes. - static const int GENERAL_48_SUB_NODES[38] = - { - 0,1, // sub-node 9 (edge) - 0,4, // sub-node 10 (edge) - 1,5, // sub-node 11 (edge) - 4,5, // sub-node 12 (edge) - 0,3, // sub-node 13 (edge) - 1,2, // sub-node 14 (edge) - 4,7, // sub-node 15 (edge) - 5,6, // sub-node 16 (edge) - 2,3, // sub-node 17 (edge) - 3,7, // sub-node 18 (edge) - 2,6, // sub-node 19 (edge) - 6,7, // sub-node 20 (edge) - 8,11, // sub-node 21 (face) - 12,13, // sub-node 22 (face) - 9,17, // sub-node 23 (face) - 10,18, // sub-node 24 (face) - 14,15, // sub-node 25 (face) - 16,19, // sub-node 26 (face) - 20,25 // sub-node 27 (cell) - }; - - for(int i = 0; i < 19; ++i) - { - double* barycenter = new double[3]; - calcBarycenter(2, barycenter, &GENERAL_48_SUB_NODES[2*i]); - _nodes.push_back(barycenter); - } - } - break; - - default: - break; - } - - case 5: // NORM_PYRA5 - break; - - default: // convex 3d cell - { - // add barycenter of a cell - std::vector allIndices(nbOfNodesT); - for ( int i = 0; i < nbOfNodesT; ++i ) allIndices[i] = i; - double* barycenter = new double[3]; - calcBarycenter(nbOfNodesT, barycenter, &allIndices[0]); - _nodes.push_back(barycenter); - } - } - - } -} - -#endif diff --git a/src/INTERP_KERNEL/TargetIntersector.hxx b/src/INTERP_KERNEL/TargetIntersector.hxx deleted file mode 100644 index d7d2063a2..000000000 --- a/src/INTERP_KERNEL/TargetIntersector.hxx +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2007-2010 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 __TARGETINTERSECTOR__HXX__ -#define __TARGETINTERSECTOR__HXX__ - -#include "INTERPKERNELDefines.hxx" - -#include - -namespace INTERP_KERNEL -{ - /** - * \brief Abstract base class of Intersector classes. - * These classes represent a target element and calculate its intersection - * with the source elements. - */ - template - class TargetIntersector - { - public: - typedef typename MyMeshType::MyConnType ConnType; - public: - /*! - * \addtogroup InterpKerGrpIntPlan - * @{ - */ - /*! - * Tool for cell intersection, result is always positive. - * @param icellT id of cell in target mesh in \b C \b mode. - * @param icellsS ids of cells in source mesh in \b C \b mode. - * @param res is an IN/OUT parameter that represents the icellTth row in final matrix, fed with at most icellsS elements. - */ - virtual void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) = 0; - //! @} - //Tool for cell filtering - virtual int getNumberOfRowsOfResMatrix() const = 0; - virtual int getNumberOfColsOfResMatrix() const = 0; - virtual ~TargetIntersector() { } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/TetraAffineTransform.cxx b/src/INTERP_KERNEL/TetraAffineTransform.cxx deleted file mode 100644 index b8cae3a7b..000000000 --- a/src/INTERP_KERNEL/TetraAffineTransform.cxx +++ /dev/null @@ -1,394 +0,0 @@ -// Copyright (C) 2007-2010 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 "TetraAffineTransform.hxx" -#include "VectorUtils.hxx" - -#include -#include -#include - -#include "Log.hxx" - -namespace INTERP_KERNEL -{ - ///////////////////////////////////////////////////////////////////////////////////////// - /// PUBLIC INTERFACE METHODS ////////////// - ///////////////////////////////////////////////////////////////////////////////////////// - - /** - * Constructor - * Create the TetraAffineTransform object from the tetrahedron - * with corners specified in pts. If the tetrahedron is degenerate or almost degenerate, - * construction succeeds, but the determinant of the transform is set to 0. - * - * @param pts a 4x3 matrix containing 4 points (pts[0], ..., pts[3]) of 3 coordinates each - */ - TetraAffineTransform::TetraAffineTransform(const double** pts) - { - - LOG(2,"Creating transform from tetraeder : "); - LOG(2, vToStr(pts[0]) << ", " << vToStr(pts[1]) << ", " << vToStr(pts[2]) << ", " << vToStr(pts[3])); - - // three last points -> linear transform - for(int i = 0; i < 3 ; ++i) - { - for(int j = 0 ; j < 3 ; ++j) - { - // NB we insert columns, not rows - _linear_transform[3*j + i] = (pts[i+1])[j] - (pts[0])[j]; - } - } - - // remember _linear_transform for the reverse transformation - memcpy( _back_linear_transform, _linear_transform, 9*sizeof(double)); - memcpy( _back_translation, pts[0], 3*sizeof(double)); - - calculateDeterminant(); - - LOG(3, "determinant before inverse = " << _determinant); - - // check that tetra is non-planar -> determinant is not zero - // otherwise set _determinant to zero to signal caller that transformation did not work - if(epsilonEqual(_determinant, 0.0)) - { - _determinant = 0.0; - return; - } - - // we need the inverse transform - invertLinearTransform(); - - // first point -> translation - // calculate here because translation takes place in "transformed space", - // or in other words b = -A*O where A is the linear transform - // and O is the position vector of the point that is mapped onto the origin - for(int i = 0 ; i < 3 ; ++i) - { - _translation[i] = -(_linear_transform[3*i]*(pts[0])[0] + _linear_transform[3*i+1]*(pts[0])[1] + _linear_transform[3*i+2]*(pts[0])[2]) ; - } - - // precalculate determinant (again after inversion of transform) - calculateDeterminant(); - -#ifdef INVERSION_SELF_CHECK - // debugging : check that applying the inversed transform to the original points - // gives us the unit tetrahedron - LOG(4, "transform determinant is " << _determinant); - LOG(4, "*Self-check : Applying transformation to original points ... "); - for(int i = 0; i < 4 ; ++i) - { - double v[3]; - apply(v, pts[i]); - LOG(4, vToStr(v)) - for(int j = 0; j < 3; ++j) - { - assert(epsilonEqual(v[j], (3*i+j == 3 || 3*i+j == 7 || 3*i+j == 11 ) ? 1.0 : 0.0)); - } - } - - LOG(4, " ok"); -#endif - } - - /** - * Calculates the transform of point srcPt and stores the result in destPt. - * If destPt == srcPt, then srcPt is overwritten safely. - * - * - * @param destPt double[3] in which to store the transformed point - * @param srcPt double[3] containing coordinates of points to be transformed - * - */ - void TetraAffineTransform::apply(double* destPt, const double* srcPt) const - { - double* dest = destPt; - - // are we self-allocating ? - const bool selfAllocation = (destPt == srcPt); - - if(selfAllocation) - { - // alloc temporary memory - dest = new double[3]; - - LOG(6, "Info : Self-affectation in TetraAffineTransform::apply"); - } - - for(int i = 0 ; i < 3 ; ++i) - { - // matrix - vector multiplication - dest[i] = _linear_transform[3*i] * srcPt[0] + _linear_transform[3*i + 1] * srcPt[1] + _linear_transform[3*i + 2] * srcPt[2]; - - // translation - dest[i] += _translation[i]; - } - - if(selfAllocation) - { - // copy result back to destPt - for(int i = 0 ; i < 3 ; ++i) - { - destPt[i] = dest[i]; - } - delete[] dest; - } - } - - /** - * Calculates the reverse transform of point srcPt and stores the result in destPt. - * If destPt == srcPt, then srcPt is overwritten safely. - * - * @param destPt double[3] in which to store the transformed point - * @param srcPt double[3] containing coordinates of points to be transformed - */ - void TetraAffineTransform::reverseApply(double* destPt, const double* srcPt) const - { - double* dest = destPt; - - // are we self-allocating ? - const bool selfAllocation = (destPt == srcPt); - - if(selfAllocation) - { - // alloc temporary memory - dest = new double[3]; - - LOG(6, "Info : Self-affectation in TetraAffineTransform::reverseApply"); - } - - for(int i = 0 ; i < 3 ; ++i) - { - // matrix - vector multiplication - dest[i] = _back_linear_transform[3*i] * srcPt[0] + _back_linear_transform[3*i + 1] * srcPt[1] + _back_linear_transform[3*i + 2] * srcPt[2]; - - // translation - dest[i] += _back_translation[i]; - } - - if(selfAllocation) - { - // copy result back to destPt - for(int i = 0 ; i < 3 ; ++i) - { - destPt[i] = dest[i]; - } - delete[] dest; - } - } - - /** - * Returns the determinant of the linear part A of the transform. - * - * @return determinant of the transform - * - */ - double TetraAffineTransform::determinant() const - { - return _determinant; - } - - /** - * Outputs to std::cout the matrix A and the vector b - * of the transform Ax + b - * - */ - void TetraAffineTransform::dump() const - { - std::cout << "A = " << std::endl << "["; - for(int i = 0; i < 3; ++i) - { - std::cout << _linear_transform[3*i] << ", " << _linear_transform[3*i + 1] << ", " << _linear_transform[3*i + 2]; - if(i != 2 ) std::cout << std::endl; - } - std::cout << "]" << std::endl; - - std::cout << "b = " << "[" << _translation[0] << ", " << _translation[1] << ", " << _translation[2] << "]" << std::endl; - } - - ///////////////////////////////////////////////////////////////////////////////////////// - /// PRIVATE METHODS ////////////// - ///////////////////////////////////////////////////////////////////////////////////////// - - /** - * Calculates the inverse of the matrix A, stored in _linear_transform - * by LU-factorization and substitution - * - */ - void TetraAffineTransform::invertLinearTransform() - { - //{ we copy the matrix for the lu-factorization - // maybe inefficient - double lu[9]; - for(int i = 0 ; i < 9; ++i) - { - lu[i] = _linear_transform[i]; - } - - // calculate LU factorization - int idx[3]; - factorizeLU(lu, idx); - - // calculate inverse by forward and backward substitution - // store in _linear_transform - // NB _linear_transform cannot be overwritten with lu in the loop - for(int i = 0 ; i < 3 ; ++i) - { - // form standard base vector i - const double b[3] = - { - int(i == 0), - int(i == 1), - int(i == 2) - }; - - LOG(6, "b = [" << b[0] << ", " << b[1] << ", " << b[2] << "]"); - - double y[3]; - forwardSubstitution(y, lu, b, idx); - - double x[3]; - backwardSubstitution(x, lu, y, idx); - - // copy to _linear_transform matrix - // NB : this is a column operation, so we cannot - // do this directly when we calculate x - for(int j = 0 ; j < 3 ; j++) - { - _linear_transform[3*j + i] = x[idx[j]]; - } - } - } - - /** - * Updates the member _determinant of the matrix A of the transformation. - * - */ - void TetraAffineTransform::calculateDeterminant() - { - const double subDet[3] = - { - _linear_transform[4] * _linear_transform[8] - _linear_transform[5] * _linear_transform[7], - _linear_transform[3] * _linear_transform[8] - _linear_transform[5] * _linear_transform[6], - _linear_transform[3] * _linear_transform[7] - _linear_transform[4] * _linear_transform[6] - }; - - _determinant = _linear_transform[0] * subDet[0] - _linear_transform[1] * subDet[1] + _linear_transform[2] * subDet[2]; - } - - - ///////////////////////////////////////////////// - /// Auxiliary methods for inverse calculation /// - ///////////////////////////////////////////////// - - - /** - * Calculates the LU-factorization of the matrix A (_linear_transform) - * and stores it in lu. Since partial pivoting is used, there are - * row swaps. This is represented by the index permutation vector idx : to access element - * (i,j) of lu, use lu[3*idx[i] + j] - * - * @param lu double[9] in which to store LU-factorization - * @param idx int[3] in which to store row permutation vector - */ - void TetraAffineTransform::factorizeLU(double* lu, int* idx) const - { - // 3 x 3 LU factorization - // initialise idx - for(int i = 0 ; i < 3 ; ++i) - { - idx[i] = i; - } - - for(int k = 0; k < 2 ; ++k) - { - - // find pivot - int i = k; - double max = std::fabs(lu[3*idx[k] + k]); - int row = i; - while(i < 3) - { - if(std::fabs(lu[3*idx[i] + k]) > max) - { - max = fabs(lu[3*idx[i] + k]); - row = i; - } - ++i; - } - - // swap rows in index vector - int tmp = idx[k]; - idx[k] = idx[row]; - idx[row] = tmp; - - // calculate row - for(int j = k + 1 ; j < 3 ; ++j) - { - // l_jk = u_jk / u_kk - lu[3*idx[j] + k] /= lu[3*idx[k] + k]; - for(int s = k + 1; s < 3 ; ++s) - { - // case s = k will always become zero, and then be replaced by - // the l-value - // there's no need to calculate this explicitly - - // u_js = u_js - l_jk * u_ks - lu[3*idx[j] + s] -= lu[3*idx[j] + k] * lu[3*idx[k] + s] ; - } - } - } - } - - /** - * Solves the system Lx = b, where L is lower unit-triangular (ones on the diagonal) - * - * @param x double[3] in which the solution is stored - * @param lu double[9] containing the LU-factorization - * @param b double[3] containing the right-hand side - * @param idx int[3] containing the permutation vector associated with lu - * - */ - void TetraAffineTransform::forwardSubstitution(double* x, const double* lu, const double* b, const int* idx) const - { - // divisions are not carried out explicitly because lu does not store - // the diagonal values of L, which are all 1 - // Compare with backwardSubstitution() - x[idx[0]] = ( b[idx[0]] ); // / lu[3*idx[0]] - x[idx[1]] = ( b[idx[1]] - lu[3*idx[1]] * x[idx[0]] ); // / lu[3*idx[1] + 1]; - x[idx[2]] = ( b[idx[2]] - lu[3*idx[2]] * x[idx[0]] - lu[3*idx[2] + 1] * x[idx[1]] ); // / lu[3*idx[2] + 2]; - } - - /** - * Solves the system Ux = b, where U is upper-triangular - * - * @param x double[3] in which the solution is stored - * @param lu double[9] containing the LU-factorization - * @param b double[3] containing the right-hand side - * @param idx int[3] containing the permutation vector associated with lu - * - */ - void TetraAffineTransform::backwardSubstitution(double* x, const double* lu, const double* b, const int* idx) const - { - x[idx[2]] = ( b[idx[2]] ) / lu[3*idx[2] + 2]; - x[idx[1]] = ( b[idx[1]] - lu[3*idx[1] + 2] * x[idx[2]] ) / lu[3*idx[1] + 1]; - x[idx[0]] = ( b[idx[0]] - lu[3*idx[0] + 1] * x[idx[1]] - lu[3*idx[0] + 2] * x[idx[2]] ) / lu[3*idx[0]]; - } - -} diff --git a/src/INTERP_KERNEL/TetraAffineTransform.hxx b/src/INTERP_KERNEL/TetraAffineTransform.hxx deleted file mode 100644 index 89cd0a060..000000000 --- a/src/INTERP_KERNEL/TetraAffineTransform.hxx +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2007-2010 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 __TETRA_AFFINE_TRANSFORM_HXX__ -#define __TETRA_AFFINE_TRANSFORM_HXX__ - -#include "INTERPKERNELDefines.hxx" - -#undef INVERSION_SELF_CHECK // debugging : check that calculated inverse is correct - -namespace INTERP_KERNEL -{ - /** - * \brief Class representing an affine transformation x -> Ax + b that transforms a given tetrahedron - * into the unit tetrahedron. - * - */ - class INTERPKERNEL_EXPORT TetraAffineTransform - { - - public: - TetraAffineTransform(const double** pts); - - void apply(double* destPt, const double* srcPt) const; - - void reverseApply(double* destPt, const double* srcPt) const; - - double determinant() const; - - void dump() const; - - private: - - void invertLinearTransform(); - - void calculateDeterminant(); - - void factorizeLU(double* lu, int* idx) const; - - void forwardSubstitution(double* x, const double* lu, const double* b, const int* idx) const; - - void backwardSubstitution(double* x, const double* lu, const double* b, const int* idx) const; - - // The affine transformation Ax + b is represented with _linear_transformation containing the elements of - // A in row-first ordering and _translation containing the elements of b - - /// 3x3 matrix A in affine transform x -> Ax + b - double _linear_transform[9]; - - /// 3x1 vector b in affine transform x -> Ax + b - double _translation[3]; - - /// The determinant of the matrix A is calculated at the construction of the object and cached. - double _determinant; - - /// 3x3 matrix AT is transposed A matrix used for y -> ATy - c transformation - double _back_linear_transform[9]; - - /// 3x1 vector c in affine transform y -> ATy - c - double _back_translation[3]; - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/TransformedTriangle.cxx b/src/INTERP_KERNEL/TransformedTriangle.cxx deleted file mode 100644 index 56a47c232..000000000 --- a/src/INTERP_KERNEL/TransformedTriangle.cxx +++ /dev/null @@ -1,672 +0,0 @@ -// Copyright (C) 2007-2010 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 "TransformedTriangle.hxx" -#include "VectorUtils.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - - /** - * \brief Class representing a circular order of a set of points around their barycenter. - * It is used with the STL sort() algorithm to sort the point of the two polygons - * - */ - class ProjectedCentralCircularSortOrder - { - public: - - /// Enumeration of different planes to project on when calculating order - enum CoordType { XY, XZ, YZ }; - - /** - * Constructor - * - * @param barycenter double[3] containing the barycenter of the points to be compared - * @param type plane to project on when comparing. The comparison will not work if all the points are in a plane perpendicular - * to the plane being projected on - */ - ProjectedCentralCircularSortOrder(const double* barycenter, const CoordType type) - : _aIdx((type == YZ) ? 1 : 0), - _bIdx((type == XY) ? 1 : 2), - _a(barycenter[_aIdx]), - _b(barycenter[_bIdx]) - { - } - - /** - * Comparison operator. - * Compares the relative position between two points in their ordering around the barycenter. - * - * @param pt1 a double[3] representing a point - * @param pt2 a double[3] representing a point - * @return true if the angle of the difference vector between pt1 and the barycenter is greater than that - * of the difference vector between pt2 and the barycenter. - */ - bool operator()(const double* pt1, const double* pt2) - { - // calculate angles with the axis - const double ang1 = atan2(pt1[_aIdx] - _a, pt1[_bIdx] - _b); - const double ang2 = atan2(pt2[_aIdx] - _a, pt2[_bIdx] - _b); - - return ang1 > ang2; - } - - private: - /// index corresponding to first coordinate of plane on which points are projected - const int _aIdx; - - /// index corresponding to second coordinate of plane on which points are projected - const int _bIdx; - - /// value of first projected coordinate of the barycenter - const double _a; - - /// value of second projected coordinate of the barycenter - const double _b; - }; - - // ---------------------------------------------------------------------------------- - // TransformedTriangle PUBLIC - // ---------------------------------------------------------------------------------- - - /** - * Constructor - * - * The coordinates are copied to the internal member variables - * - * @param p array of three doubles containing coordinates of P - * @param q array of three doubles containing coordinates of Q - * @param r array of three doubles containing coordinates of R - */ - TransformedTriangle::TransformedTriangle(double* p, double* q, double* r) - : _is_double_products_calculated(false), _is_triple_products_calculated(false), _volume(0) - { - - for(int i = 0 ; i < 3 ; ++i) - { - // xyz coordinates - _coords[5*P + i] = p[i]; - _coords[5*Q + i] = q[i]; - _coords[5*R + i] = r[i]; - } - - // h coordinate - - _coords[5*P + 3] = 1 - p[0] - p[1] - p[2]; - _coords[5*Q + 3] = 1 - q[0] - q[1] - q[2]; - _coords[5*R + 3] = 1 - r[0] - r[1] - r[2]; - - // H coordinate - _coords[5*P + 4] = 1 - p[0] - p[1]; - _coords[5*Q + 4] = 1 - q[0] - q[1]; - _coords[5*R + 4] = 1 - r[0] - r[1]; - - resetNearZeroCoordinates(); - - // initialise rest of data - preCalculateDoubleProducts(); - - preCalculateTriangleSurroundsEdge(); - - preCalculateTripleProducts(); - - } - - /** - * Destructor - * - * Deallocates the memory used to store the points of the polygons. - * This memory is allocated in calculateIntersectionPolygons(). - */ - TransformedTriangle::~TransformedTriangle() - { - // delete elements of polygons - for(std::vector::iterator it = _polygonA.begin() ; it != _polygonA.end() ; ++it) - { - delete[] *it; - } - for(std::vector::iterator it = _polygonB.begin() ; it != _polygonB.end() ; ++it) - { - delete[] *it; - } - } - - /** - * Calculates the volume of intersection between the triangle and the - * unit tetrahedron. - * - * @return volume of intersection of this triangle with unit tetrahedron, - * as described in Grandy - * - */ - double TransformedTriangle::calculateIntersectionVolume() - { - // check first that we are not below z - plane - if(isTriangleBelowTetraeder()) - { - LOG(2, " --- Triangle is below tetraeder - V = 0.0"); - return 0.0; - } - - // get the sign of the volume - equal to the sign of the z-component of the normal - // of the triangle, u_x * v_y - u_y * v_x, where u = q - p and v = r - p - // if it is zero, the triangle is perpendicular to the z - plane and so the volume is zero -// const double uv_xy[4] = -// { -// _coords[5*Q] - _coords[5*P], _coords[5*Q + 1] - _coords[5*P + 1], // u_x, u_y -// _coords[5*R] - _coords[5*P], _coords[5*R + 1] - _coords[5*P + 1] // v_x, v_y -// }; - -// double sign = uv_xy[0] * uv_xy[3] - uv_xy[1] * uv_xy[2]; - int sign = isTriangleInclinedToFacet( OXY ); - - if(sign == 0 ) - { - LOG(2, " --- Triangle is perpendicular to z-plane - V = 0.0"); - return _volume = 0.0; - } - - - // normalize sign - //sign = sign > 0.0 ? 1.0 : -1.0; - - LOG(2, "-- Calculating intersection polygons ... "); - calculateIntersectionPolygons(); - - double barycenter[3]; - - // calculate volume under A - double volA = 0.0; - if(_polygonA.size() > 2) - { - LOG(2, "---- Treating polygon A ... "); - calculatePolygonBarycenter(A, barycenter); - sortIntersectionPolygon(A, barycenter); - volA = calculateVolumeUnderPolygon(A, barycenter); - LOG(2, "Volume is " << sign * volA); - } - - double volB = 0.0; - // if triangle is not in h = 0 plane, calculate volume under B - if(_polygonB.size() > 2 && !isTriangleInPlaneOfFacet(XYZ)) - { - LOG(2, "---- Treating polygon B ... "); - - calculatePolygonBarycenter(B, barycenter); - sortIntersectionPolygon(B, barycenter); - volB = calculateVolumeUnderPolygon(B, barycenter); - LOG(2, "Volume is " << sign * volB); - } - - LOG(2, "volA + volB = " << sign * (volA + volB) << std::endl << "***********"); - - return _volume = sign * (volA + volB); - - } - - // ---------------------------------------------------------------------------------- - // TransformedTriangle PRIVATE - // ---------------------------------------------------------------------------------- - - /** - * Calculates the intersection polygons A and B, performing the intersection tests - * and storing the corresponding points in the vectors _polygonA and _polygonB. - * - * @post _polygonA contains the intersection polygon A and _polygonB contains the - * intersection polygon B. - * - */ - void TransformedTriangle::calculateIntersectionPolygons() - { - assert(_polygonA.size() == 0); - assert(_polygonB.size() == 0); - // avoid reallocations in push_back() by pre-allocating enough memory - // we should never have more than 20 points - _polygonA.reserve(20); - _polygonB.reserve(20); - // -- surface intersections - // surface - edge - for(TetraEdge edge = OX ; edge <= ZX ; edge = TetraEdge(edge + 1)) - { - if(testSurfaceEdgeIntersection(edge)) - { - double* ptA = new double[3]; - calcIntersectionPtSurfaceEdge(edge, ptA); - _polygonA.push_back(ptA); - LOG(3,"Surface-edge : " << vToStr(ptA) << " added to A "); - if(edge >= XY) - { - double* ptB = new double[3]; - copyVector3(ptA, ptB); - _polygonB.push_back(ptB); - LOG(3,"Surface-edge : " << vToStr(ptB) << " added to B "); - } - - } - } - - // surface - ray - for(TetraCorner corner = X ; corner < NO_TET_CORNER ; corner = TetraCorner(corner + 1)) - { - if(testSurfaceRayIntersection(corner)) - { - double* ptB = new double[3]; - copyVector3(&COORDS_TET_CORNER[3 * corner], ptB); - _polygonB.push_back(ptB); - LOG(3,"Surface-ray : " << vToStr(ptB) << " added to B"); - } - } - - // -- segment intersections - for(TriSegment seg = PQ ; seg < NO_TRI_SEGMENT ; seg = TriSegment(seg + 1)) - { - - bool isZero[NO_DP]; - - // check beforehand which double-products are zero - for(DoubleProduct dp = C_YZ; dp < NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[dp] = (calcStableC(seg, dp) == 0.0); - } - - // segment - facet - for(TetraFacet facet = OYZ ; facet < NO_TET_FACET ; facet = TetraFacet(facet + 1)) - { - // is this test worth it? - const bool doTest = - !isZero[DP_FOR_SEG_FACET_INTERSECTION[3*facet]] && - !isZero[DP_FOR_SEG_FACET_INTERSECTION[3*facet + 1]] && - !isZero[DP_FOR_SEG_FACET_INTERSECTION[3*facet + 2]]; - - if(doTest && testSegmentFacetIntersection(seg, facet)) - { - double* ptA = new double[3]; - calcIntersectionPtSegmentFacet(seg, facet, ptA); - _polygonA.push_back(ptA); - LOG(3,"Segment-facet : " << vToStr(ptA) << " added to A"); - if(facet == XYZ) - { - double* ptB = new double[3]; - copyVector3(ptA, ptB); - _polygonB.push_back(ptB); - LOG(3,"Segment-facet : " << vToStr(ptB) << " added to B"); - } - - } - } - - // segment - edge - for(TetraEdge edge = OX ; edge <= ZX ; edge = TetraEdge(edge + 1)) - { - const DoubleProduct edge_dp = DoubleProduct(edge); - - if(isZero[edge_dp] && testSegmentEdgeIntersection(seg, edge)) - { - double* ptA = new double[3]; - calcIntersectionPtSegmentEdge(seg, edge, ptA); - _polygonA.push_back(ptA); - LOG(3,"Segment-edge : " << vToStr(ptA) << " added to A"); - if(edge >= XY) - { - double* ptB = new double[3]; - copyVector3(ptA, ptB); - _polygonB.push_back(ptB); - } - } - } - - // segment - corner - for(TetraCorner corner = O ; corner < NO_TET_CORNER ; corner = TetraCorner(corner + 1)) - { - const bool doTest = - isZero[DoubleProduct( EDGES_FOR_CORNER[3*corner] )] && - isZero[DoubleProduct( EDGES_FOR_CORNER[3*corner+1] )] && - isZero[DoubleProduct( EDGES_FOR_CORNER[3*corner+2] )]; - - if(doTest && testSegmentCornerIntersection(seg, corner)) - { - double* ptA = new double[3]; - copyVector3(&COORDS_TET_CORNER[3 * corner], ptA); - _polygonA.push_back(ptA); - LOG(3,"Segment-corner : " << vToStr(ptA) << " added to A"); - if(corner != O) - { - double* ptB = new double[3]; - _polygonB.push_back(ptB); - copyVector3(&COORDS_TET_CORNER[3 * corner], ptB); - LOG(3,"Segment-corner : " << vToStr(ptB) << " added to B"); - } - } - } - - // segment - ray - for(TetraCorner corner = X ; corner < NO_TET_CORNER ; corner = TetraCorner(corner + 1)) - { - if(isZero[DP_SEGMENT_RAY_INTERSECTION[7*(corner-1)]] && testSegmentRayIntersection(seg, corner)) - { - double* ptB = new double[3]; - copyVector3(&COORDS_TET_CORNER[3 * corner], ptB); - _polygonB.push_back(ptB); - LOG(3,"Segment-ray : " << vToStr(ptB) << " added to B"); - } - } - - // segment - halfstrip - for(TetraEdge edge = XY ; edge <= ZX ; edge = TetraEdge(edge + 1)) - { - -#if 0 - const int edgeIdx = int(edge) - 3; // offset since we only care for edges XY - ZX - const bool doTest = - !isZero[DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIdx]] && - !isZero[DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIdx+1]]; - - - if(doTest && testSegmentHalfstripIntersection(seg, edge)) -#endif - if(testSegmentHalfstripIntersection(seg, edge)) - { - double* ptB = new double[3]; - calcIntersectionPtSegmentHalfstrip(seg, edge, ptB); - _polygonB.push_back(ptB); - LOG(3,"Segment-halfstrip : " << vToStr(ptB) << " added to B"); - } - } - } - - // inclusion tests - for(TriCorner corner = P ; corner < NO_TRI_CORNER ; corner = TriCorner(corner + 1)) - { - // { XYZ - inclusion only possible if in Tetrahedron? - // tetrahedron - if(testCornerInTetrahedron(corner)) - { - double* ptA = new double[3]; - copyVector3(&_coords[5*corner], ptA); - _polygonA.push_back(ptA); - LOG(3,"Inclusion tetrahedron : " << vToStr(ptA) << " added to A"); - } - - // XYZ - plane - if(testCornerOnXYZFacet(corner)) - { - double* ptB = new double[3]; - copyVector3(&_coords[5*corner], ptB); - _polygonB.push_back(ptB); - LOG(3,"Inclusion XYZ-plane : " << vToStr(ptB) << " added to B"); - } - - // projection on XYZ - facet - if(testCornerAboveXYZFacet(corner)) - { - double* ptB = new double[3]; - copyVector3(&_coords[5*corner], ptB); - ptB[2] = 1 - ptB[0] - ptB[1]; - assert(epsilonEqual(ptB[0]+ptB[1]+ptB[2] - 1, 0.0)); - _polygonB.push_back(ptB); - LOG(3,"Projection XYZ-plane : " << vToStr(ptB) << " added to B"); - } - - } - - } - - /** - * Calculates the barycenters of the given intersection polygon. - * - * @pre the intersection polygons have been calculated with calculateIntersectionPolygons() - * - * @param poly one of the two intersection polygons - * @param barycenter array of three doubles where barycenter is stored - * - */ - void TransformedTriangle::calculatePolygonBarycenter(const IntersectionPolygon poly, double* barycenter) - { - LOG(3,"--- Calculating polygon barycenter"); - - // get the polygon points - std::vector& polygon = (poly == A) ? _polygonA : _polygonB; - - // calculate barycenter - const int m = polygon.size(); - - for(int j = 0 ; j < 3 ; ++j) - { - barycenter[j] = 0.0; - } - - if(m != 0) - { - for(int i = 0 ; i < m ; ++i) - { - const double* pt = polygon[i]; - for(int j = 0 ; j < 3 ; ++j) - { - barycenter[j] += pt[j] / double(m); - } - } - } - LOG(3,"Barycenter is " << vToStr(barycenter)); - } - - /** - * Sorts the given intersection polygon in circular order around its barycenter. - * @pre the intersection polygons have been calculated with calculateIntersectionPolygons() - * @post the vertices in _polygonA and _polygonB are sorted in circular order around their - * respective barycenters - * - * @param poly one of the two intersection polygons - * @param barycenter array of three doubles with the coordinates of the barycenter - * - */ - void TransformedTriangle::sortIntersectionPolygon(const IntersectionPolygon poly, const double* barycenter) - { - LOG(3,"--- Sorting polygon ..."); - - using INTERP_KERNEL::ProjectedCentralCircularSortOrder; - typedef ProjectedCentralCircularSortOrder SortOrder; // change is only necessary here and in constructor - typedef SortOrder::CoordType CoordType; - - // get the polygon points - std::vector& polygon = (poly == A) ? _polygonA : _polygonB; - - if(polygon.size() == 0) - return; - - // determine type of sorting - CoordType type = SortOrder::XY; - if(poly == A && !isTriangleInclinedToFacet( OXY )) // B is on h = 0 plane -> ok - { - // NB : the following test is never true if we have eliminated the - // triangles parallel to x == 0 and y == 0 in calculateIntersectionVolume(). - // We keep the test here anyway, to avoid interdependency. - - // is triangle inclined to x == 0 ? - if(isTriangleInclinedToFacet(OZX)) - { - type = SortOrder::XZ; - } - else //if(isTriangleParallelToFacet(OYZ)) - { - type = SortOrder::YZ; - } - } - - // create order object - SortOrder order(barycenter, type); - - // sort vector with this object - // NB : do not change place of first object, with respect to which the order - // is defined - sort((polygon.begin()), polygon.end(), order); - - LOG(3,"Sorted polygon is "); - for(size_t i = 0 ; i < polygon.size() ; ++i) - { - LOG(3,vToStr(polygon[i])); - } - - } - - /** - * Calculates the volume between the given polygon and the z = 0 plane. - * - * @pre the intersection polygones have been calculated with calculateIntersectionPolygons(), - * and they have been sorted in circular order with sortIntersectionPolygons(void) - * - * @param poly one of the two intersection polygons - * @param barycenter array of three doubles with the coordinates of the barycenter - * @return the volume between the polygon and the z = 0 plane - * - */ - double TransformedTriangle::calculateVolumeUnderPolygon(IntersectionPolygon poly, const double* barycenter) - { - LOG(2,"--- Calculating volume under polygon"); - - // get the polygon points - std::vector& polygon = (poly == A) ? _polygonA : _polygonB; - - double vol = 0.0; - const int m = polygon.size(); - - for(int i = 0 ; i < m ; ++i) - { - const double* ptCurr = polygon[i]; // pt "i" - const double* ptNext = polygon[(i + 1) % m]; // pt "i+1" (pt m == pt 0) - - const double factor1 = ptCurr[2] + ptNext[2] + barycenter[2]; - const double factor2 = - ptCurr[0]*(ptNext[1] - barycenter[1]) - + ptNext[0]*(barycenter[1] - ptCurr[1]) - + barycenter[0]*(ptCurr[1] - ptNext[1]); - vol += (factor1 * factor2) / 6.0; - } - - LOG(2,"Abs. Volume is " << vol); - return vol; - } - - - //////////////////////////////////////////////////////////////////////////////////// - // Detection of (very) degenerate cases ///////////// - //////////////////////////////////////////////////////////////////////////////////// - - /** - * Checks if the triangle lies in the plane of a given facet - * - * @param facet one of the facets of the tetrahedron - * @return true if PQR lies in the plane of the facet, false if not - */ - bool TransformedTriangle::isTriangleInPlaneOfFacet(const TetraFacet facet) const - { - - // coordinate to check - const int coord = static_cast(facet); - - for(TriCorner c = P ; c < NO_TRI_CORNER ; c = TriCorner(c + 1)) - { - if(_coords[5*c + coord] != 0.0) - { - return false; - } - } - - return true; - } - - /** - * Checks if the triangle is parallel to the given facet - * - * @param facet one of the facets of the unit tetrahedron - * @return true if triangle is parallel to facet, false if not - */ - bool TransformedTriangle::isTriangleParallelToFacet(const TetraFacet facet) const - { - // coordinate to check - const int coord = static_cast(facet); - return (_coords[5*P + coord] == _coords[5*Q + coord]) && (_coords[5*P + coord] == _coords[5*R + coord]); - } - - /** - * Checks if the triangle is not perpedicular to the given facet - * - * @param facet one of the facets of the unit tetrahedron - * @return zero if the triangle is perpendicular to the facet, - * else 1 or -1 depending on the sign of cross product of facet edges - */ - int TransformedTriangle::isTriangleInclinedToFacet(const TetraFacet facet) const - { - // coordinate to check - const int coord = static_cast(facet); - const int ind1 = ( coord+1 ) % 3, ind2 = ( coord+2 ) % 3; - const double uv_xy[4] = - { - // u_x, u_y - _coords[5*Q+ind1] - _coords[5*P+ind1], _coords[5*Q+ind2] - _coords[5*P+ind2], - // v_x, v_y - _coords[5*R+ind1] - _coords[5*P+ind1], _coords[5*R+ind2] - _coords[5*P+ind2] - }; - - double sign = uv_xy[0] * uv_xy[3] - uv_xy[1] * uv_xy[2]; - return (sign < 0.) ? -1 : (sign > 0.) ? 1 : 0; - } - - /** - * Determines whether the triangle is below the z-plane. - * - * @return true if the z-coordinate of the three corners of the triangle are all less than 0, false otherwise. - */ - bool TransformedTriangle::isTriangleBelowTetraeder() const - { - for(TriCorner c = P ; c < NO_TRI_CORNER ; c = TriCorner(c + 1)) - { - // check z-coords for all points - if(_coords[5*c + 2] >= 0.0) - { - return false; - } - } - return true; - } - - /** - * Prints the coordinates of the triangle to std::cout - * - */ - void TransformedTriangle::dumpCoords() const - { - std::cout << "Coords : "; - for(int i = 0 ; i < 3; ++i) - { - std::cout << vToStr(&_coords[5*i]) << ","; - } - std::cout << std::endl; - } - - } // NAMESPACE diff --git a/src/INTERP_KERNEL/TransformedTriangle.hxx b/src/INTERP_KERNEL/TransformedTriangle.hxx deleted file mode 100644 index c032faed7..000000000 --- a/src/INTERP_KERNEL/TransformedTriangle.hxx +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (C) 2007-2010 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 __TRANSFORMED_TRIANGLE_HXX__ -#define __TRANSFORMED_TRIANGLE_HXX__ - -#include "INTERPKERNELDefines.hxx" - -#include - -// Levels : -// 1 - overview of algorithm + volume result -// 2 - algorithm detail -// 3 - intersection polygon results detail -// 4 - intersection polygon search detail -// higher -> misc. gory details of calculation - -#include "Log.hxx" - -#ifdef WNT -#pragma warning(disable:4251) -#endif - -namespace INTERP_TEST -{ - class TransformedTriangleTest; - class TransformedTriangleIntersectTest; -} - - -namespace INTERP_KERNEL -{ - - /** \class TransformedTriangle - * \brief Class representing one of the faces of the triangulated source polyhedron after having been transformed - * with the affine transform that takes the target tetrahedron to the unit tetrahedron. It contains the - * logic for calculating the volume of intersection between the triangle and the unit tetrahedron. - * - * \see TransformedTriangle.hxx - * - * Reference : J. Grandy, "Conservative Remapping and Region Overlays by Intersecting Arbitrary Polyhedra", - * Journal of Computational Physics (1999) - * - */ - - /** \file TransformedTriangle.hxx - * - * OVERVIEW of how the class works : (details can be found in the documentation of each method) - * - * Constructor : - * The constructor takes as arguments three pointers to double[3] vectors holding the transformed - * coordinates of the corners of the triangle. It copies their coordinates and then proceeds to pre-calculating certain - * entities used in the intersection calculation : the double products, triple products and the values of the function E - * (Grandy, [53]). - * - * calculateIntersectionVolume() : - * This is the only method in the public interface. It calculates the volume under the intersection polygons - * between the triangle and the unit tetrahedron, as described in Grandy, pp. 435-447. It does this by first calculating the - * intersection polygons A and B, with the method calculateIntersectionPolygons(). It then calculates the barycenter of each - * polygon in calculatePolygonBarycenter(), and sorts their points in a circular order around the barycenter in - * sortIntersecionPolygon(). The sorting is done with STL sort, using the order defined in the class - * ProjectedCentralCircularSortOrder. The volume under each polygon is then calculated with calculateVolumeUnderPolygon(), which - * implements formula [34] in Grandy. - * - * calculateIntersectionPolygons() : - * This method goes through all the possible ways in which the triangle can intersect the tetrahedron and tests for these - * types of intersections in accordance with the formulas described in Grandy. These tests are implemented in the test* - methods. - * The formulas in the article are stated for one case each only, while the calculation must take into account all cases. - * To this end, a number of tables, implemented as static const arrays of different types, are used. The tables - * mainly contain values of the different enumeration types described at the beginning of the class interface. For example, - * the formula Grandy gives for the segment-halfstrip intersection tests ([30]) is for use with the halfstrip above the zx edge. - * For the other two halfstrips (above the xy and yz edges), other double products are used, which - * are stored in the table DP_FOR_HALFSTRIP_INTERSECTION. This allows us to treat - * all the edges equally, avoiding switch() - statements. It is the careful choice of order of the enumeration types that makes this - * possible. Notably, there is a correspondance between the TetraEdge type and the DoubleProduct type (see Grandy, table III) that - * is used throughout the code, permitting statements such as DoubleProduct(some_edge) to work. - * When an intersection point has been detected it is calculated with a corresponding calc* - method in the cases where it - * is not known directly. It is then added to the polygon A and/or B as necessary. - * - * OPTIMIZE : - * If OPTIMIZE is defined, a large number of methods will be prefixed with inline and some optimizations concerning the tests - * with zero double products will be used. - */ - class INTERPKERNEL_EXPORT TransformedTriangle - { - - - public: - - friend class INTERP_TEST::TransformedTriangleTest; - friend class INTERP_TEST::TransformedTriangleIntersectTest; - /* - * Enumerations representing the different geometric elements of the unit tetrahedron - * and the triangle. The end element, NO_* gives the number of elements in the enumeration - * and can be used as end element in loops. - */ - - /// Corners of tetrahedron - enum TetraCorner { O = 0, X, Y, Z, NO_TET_CORNER }; - - /// Edges of tetrahedron - enum TetraEdge { OX = 0, OY, OZ, XY, YZ, ZX, H01, H10, NO_TET_EDGE }; - - /// Facets (faces) of tetrahedron - enum TetraFacet { OYZ = 0, OZX, OXY, XYZ, NO_TET_FACET }; - - /// Corners of triangle - enum TriCorner { P = 0, Q, R, NO_TRI_CORNER }; - - /// Segments (edges) of triangle - enum TriSegment { PQ = 0, QR, RP, NO_TRI_SEGMENT }; - - /// Intersection polygons - enum IntersectionPolygon{ A = 0, B, NO_INTERSECTION_POLYGONS }; - - /// Double products - /// NB : order corresponds to TetraEdges (Grandy, table III) - enum DoubleProduct { C_YZ = 0, C_ZX, C_XY, C_ZH, C_XH, C_YH, C_01, C_10, NO_DP }; - - TransformedTriangle(double* p, double* q, double* r); - ~TransformedTriangle(); - - double calculateIntersectionVolume(); - - void dumpCoords() const; - - // Queries of member values used by UnitTetraIntersectionBary - - const double* getCorner(TriCorner corner) const { return _coords + 5*corner; } - - const std::vector& getPolygonA() const { return _polygonA; } - - double getVolume() const { return _volume; } - - protected: - - TransformedTriangle() { } - - // ---------------------------------------------------------------------------------- - // High-level methods called directly by calculateIntersectionVolume() - // ---------------------------------------------------------------------------------- - void calculateIntersectionPolygons(); - - void calculatePolygonBarycenter(const IntersectionPolygon poly, double* barycenter); - - void sortIntersectionPolygon(const IntersectionPolygon poly, const double* barycenter); - - double calculateVolumeUnderPolygon(IntersectionPolygon poly, const double* barycenter); - - // ---------------------------------------------------------------------------------- - // Detection of degenerate triangles - // ---------------------------------------------------------------------------------- - - bool isTriangleInPlaneOfFacet(const TetraFacet facet) const; - - bool isTriangleParallelToFacet(const TetraFacet facet) const; - - int isTriangleInclinedToFacet(const TetraFacet facet) const; - - bool isTriangleBelowTetraeder() const; - - // ---------------------------------------------------------------------------------- - // Intersection test methods and intersection point calculations - // ---------------------------------------------------------------------------------- - - inline bool testSurfaceEdgeIntersection(const TetraEdge edge) const; - - void calcIntersectionPtSurfaceEdge(const TetraEdge edge, double* pt) const; - - inline bool testSegmentFacetIntersection(const TriSegment seg, const TetraFacet facet) const; - - void calcIntersectionPtSegmentFacet(const TriSegment seg, const TetraFacet facet, double* pt) const; - - bool testSegmentEdgeIntersection(const TriSegment seg, const TetraEdge edge) const; - - void calcIntersectionPtSegmentEdge(const TriSegment seg, const TetraEdge edge, double* pt) const ; - - bool testSegmentCornerIntersection(const TriSegment seg, const TetraCorner corner) const ; - - inline bool testSurfaceRayIntersection(const TetraCorner corner) const; - - bool testSegmentHalfstripIntersection(const TriSegment seg, const TetraEdge edg); - - void calcIntersectionPtSegmentHalfstrip(const TriSegment seg, const TetraEdge edge, double* pt) const; - - bool testSegmentRayIntersection(const TriSegment seg, const TetraCorner corner) const; - - inline bool testCornerInTetrahedron(const TriCorner corner) const; - - inline bool testCornerOnXYZFacet(const TriCorner corner) const; - - inline bool testCornerAboveXYZFacet(const TriCorner corner) const; - - // ---------------------------------------------------------------------------------- - // Utility methods used in intersection tests - // ---------------------------------------------------------------------------------- - - bool testTriangleSurroundsEdge(const TetraEdge edge) const; - - inline bool testEdgeIntersectsTriangle(const TetraEdge edge) const; - - inline bool testFacetSurroundsSegment(const TriSegment seg, const TetraFacet facet) const; - - inline bool testSegmentIntersectsFacet(const TriSegment seg, const TetraFacet facet) const; - - bool testSegmentIntersectsHPlane(const TriSegment seg) const; - - bool testSurfaceAboveCorner(const TetraCorner corner) const; - - bool testTriangleSurroundsRay(const TetraCorner corner) const; - - // ---------------------------------------------------------------------------------- - // Double and triple product calculations - // ---------------------------------------------------------------------------------- - - void resetNearZeroCoordinates(); - - bool areDoubleProductsConsistent(const TriSegment seg) const; - - void preCalculateDoubleProducts(void); - - inline void resetDoubleProducts(const TriSegment seg, const TetraCorner corner); - - double calculateDistanceCornerSegment(const TetraCorner corner, const TriSegment seg) const; - - void preCalculateTripleProducts(void); - - double calculateAngleEdgeTriangle(const TetraEdge edge) const; - - inline double calcStableC(const TriSegment seg, const DoubleProduct dp) const; - - inline double calcStableT(const TetraCorner corner) const; - - inline double calcUnstableC(const TriSegment seg, const DoubleProduct dp) const; - - double calcTByDevelopingRow(const TetraCorner corner, const int row = 1, const bool project = false) const; - - // ---------------------------------------------------------------------------------- - // Member variables - // ---------------------------------------------------------------------------------- - protected: - - /// Array holding the coordinates of the triangle's three corners - /// order : - /// [ p_x, p_y, p_z, p_h, p_H, q_x, q_y, q_z, q_h, q_H, r_x, r_y, r_z, r_h, r_H ] - double _coords[15]; - - /// Flag showing whether the double products have been calculated yet - bool _is_double_products_calculated; - - /// Flag showing whether the triple products have been calculated yet - bool _is_triple_products_calculated; - - /// Array containing the 24 double products. - /// order : c^PQ_YZ, ... ,cPQ_10, ... c^QR_YZ, ... c^RP_YZ - /// following order in enumeration DoubleProduct - double _doubleProducts[24]; - - /// Array containing the 4 triple products. - /// order : t_O, t_X, t_Y, t_Z - double _tripleProducts[4]; - - /// Vector holding the points of the intersection polygon A. - /// these points are allocated in calculateIntersectionPolygons() and liberated in the destructor - std::vector _polygonA; - - /// Vector holding the points of the intersection polygon B. - /// These points are allocated in calculateIntersectionPolygons() and liberated in the destructor - std::vector _polygonB; - - /// Array holding the coordinates of the barycenter of the polygon A - /// This point is calculated in calculatePolygonBarycenter - double _barycenterA[3]; - - /// Array holding the coordinates of the barycenter of the polygon B - /// This point is calculated in calculatePolygonBarycenter - //double _barycenterB[3]; - - /// Array of flags indicating which of the four triple products have been correctly calculated. - /// Used for asserts in debug mode - bool _validTP[4]; - - /// calculated volume for use of UnitTetraIntersectionBary - double _volume; - - /** - * Calls TransformedTriangle::testTriangleSurroundsEdge for edges OX to ZX and stores the result in - * member variable array_triangleSurroundsEdgeCache. - * - */ - void preCalculateTriangleSurroundsEdge(); - - /// Array holding results of the test testTriangleSurroundsEdge() for all the edges. - /// These are calculated in preCalculateTriangleSurroundsEdge(). - bool _triangleSurroundsEdgeCache[NO_TET_EDGE]; - - // ---------------------------------------------------------------------------------- - // Constants - // ---------------------------------------------------------------------------------- - - // offsets : 0 -> x, 1 -> y, 2 -> z, 3 -> h, 4 -> H - // corresponds to order of double products in DoubleProduct - // so that offset[C_*] gives the right coordinate - static const int DP_OFFSET_1[8]; - static const int DP_OFFSET_2[8]; - - // the coordinates used in the expansion of triple products by a given row - // in constellation (corner, row-1) - // (0,1,2,3) <=> (x,y,z,h) - static const int COORDINATE_FOR_DETERMINANT_EXPANSION[12]; - - // contains the edge of the double product used when - // expanding the triple product determinant associated with each corner - // by a given row - static const DoubleProduct DP_FOR_DETERMINANT_EXPANSION[12]; - - // values used to decide how imprecise the double products - // should be to set them to 0.0 - static const long double MACH_EPS; // machine epsilon - static const long double MULT_PREC_F; // precision of multiplications (Grandy : f) - static const long double THRESHOLD_F; // threshold for zeroing (Grandy : F/f) - - static const double TRIPLE_PRODUCT_ANGLE_THRESHOLD; - - // correspondance facet - double product - // Grandy, table IV - static const DoubleProduct DP_FOR_SEG_FACET_INTERSECTION[12]; - - // signs associated with entries in DP_FOR_SEGMENT_FACET_INTERSECTION - static const double SIGN_FOR_SEG_FACET_INTERSECTION[12]; - - // coordinates of corners of tetrahedron - static const double COORDS_TET_CORNER[12]; - - // indices to use in tables DP_FOR_SEG_FACET_INTERSECTION and SIGN_FOR_SEG_FACET_INTERSECTION - // for the calculation of the coordinates (x,y,z) of the intersection points - // for Segment-Facet and Segment-Edge intersections - static const int DP_INDEX[12]; - - // correspondance edge - corners - static const TetraCorner CORNERS_FOR_EDGE[12]; - - // correspondance edge - facets - // facets shared by each edge - static const TetraFacet FACET_FOR_EDGE[12]; - - // correspondance edge - corners - static const TetraEdge EDGES_FOR_CORNER[12]; - - // double products used in segment-halfstrip test - static const DoubleProduct DP_FOR_HALFSTRIP_INTERSECTION[12]; - - // double products used in segment - ray test - static const DoubleProduct DP_SEGMENT_RAY_INTERSECTION[21]; - - }; - - // include definitions of inline methods - -#include "TransformedTriangleInline.hxx" -} - - -#endif diff --git a/src/INTERP_KERNEL/TransformedTriangleInline.hxx b/src/INTERP_KERNEL/TransformedTriangleInline.hxx deleted file mode 100644 index 4ba0a2dca..000000000 --- a/src/INTERP_KERNEL/TransformedTriangleInline.hxx +++ /dev/null @@ -1,284 +0,0 @@ -// Copyright (C) 2007-2010 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 __TRANSFORMEDTRIANGLEINLINE_HXX__ -#define __TRANSFORMEDTRIANGLEINLINE_HXX__ - -// This file contains inline versions of some of the methods in the TransformedTriangle*.cxx files. -// It replaces those methods if OPTIMIZE is defined. -// NB : most of these methods have documentation in their corresponding .cxx - file. - -// ---------------------------------------------------------------------------------- -// Optimization methods. These are only defined and used if OPTIMIZE is defined. -// ----------------------------------------------------------------------------------- - - -inline void TransformedTriangle::preCalculateTriangleSurroundsEdge() -{ - for(TetraEdge edge = OX ; edge <= ZX ; edge = TetraEdge(edge + 1)) - { - _triangleSurroundsEdgeCache[edge] = testTriangleSurroundsEdge(edge); - } -} - - -// ---------------------------------------------------------------------------------- -// TransformedTriangle_math.cxx -// ---------------------------------------------------------------------------------- - -inline void TransformedTriangle::resetDoubleProducts(const TriSegment seg, const TetraCorner corner) -{ - // set the three corresponding double products to 0.0 - static const DoubleProduct DOUBLE_PRODUCTS[12] = - { - C_YZ, C_ZX, C_XY, // O - C_YZ, C_ZH, C_YH, // X - C_ZX, C_ZH, C_XH, // Y - C_XY, C_YH, C_XH // Z - }; - - for(int i = 0 ; i < 3 ; ++i) { - const DoubleProduct dp = DOUBLE_PRODUCTS[3*corner + i]; - - LOG(6, std::endl << "resetting inconsistent dp :" << dp << " for corner " << corner); - _doubleProducts[8*seg + dp] = 0.0; - }; -} - -inline double TransformedTriangle::calcStableC(const TriSegment seg, const DoubleProduct dp) const -{ - return _doubleProducts[8*seg + dp]; -} - -inline double TransformedTriangle::calcStableT(const TetraCorner corner) const -{ - // assert(_isTripleProductsCalculated); - // assert(_validTP[corner]); - return _tripleProducts[corner]; -} - -inline double TransformedTriangle::calcUnstableC(const TriSegment seg, const DoubleProduct dp) const -{ - - // find the points of the triangle - // 0 -> P, 1 -> Q, 2 -> R - const int pt1 = seg; - const int pt2 = (seg + 1) % 3; - - // find offsets - const int off1 = DP_OFFSET_1[dp]; - const int off2 = DP_OFFSET_2[dp]; - - return _coords[5*pt1 + off1] * _coords[5*pt2 + off2] - _coords[5*pt1 + off2] * _coords[5*pt2 + off1]; -} - -// ---------------------------------------------------------------------------------- -// TransformedTriangle_intersect.cxx -// ---------------------------------------------------------------------------------- -inline bool TransformedTriangle::testSurfaceEdgeIntersection(const TetraEdge edge) const -{ - return _triangleSurroundsEdgeCache[edge] && testEdgeIntersectsTriangle(edge); -} - -inline bool TransformedTriangle::testSegmentFacetIntersection(const TriSegment seg, const TetraFacet facet) const -{ - return testFacetSurroundsSegment(seg, facet) && testSegmentIntersectsFacet(seg, facet); -} - -inline bool TransformedTriangle::testSurfaceRayIntersection(const TetraCorner corner) const -{ - return testTriangleSurroundsRay( corner ) && testSurfaceAboveCorner( corner ); -} - -inline bool TransformedTriangle::testCornerInTetrahedron(const TriCorner corner) const -{ - const double pt[4] = - { - _coords[5*corner], // x - _coords[5*corner + 1], // y - _coords[5*corner + 2], // z - _coords[5*corner + 3] // z - }; - - for(int i = 0 ; i < 4 ; ++i) - { - if(pt[i] < 0.0 || pt[i] > 1.0) - { - return false; - } - } - return true; -} - -inline bool TransformedTriangle::testCornerOnXYZFacet(const TriCorner corner) const -{ -#if 0 - const double pt[4] = - { - _coords[5*corner], // x - _coords[5*corner + 1], // y - _coords[5*corner + 2], // z - _coords[5*corner + 3] // h - }; -#endif - const double* pt = &_coords[5*corner]; - - if(pt[3] != 0.0) - { - return false; - } - - for(int i = 0 ; i < 3 ; ++i) - { - if(pt[i] < 0.0 || pt[i] > 1.0) - { - return false; - } - } - return true; -} - -inline bool TransformedTriangle::testCornerAboveXYZFacet(const TriCorner corner) const -{ - const double x = _coords[5*corner]; - const double y = _coords[5*corner + 1]; - const double h = _coords[5*corner + 3]; - const double H = _coords[5*corner + 4]; - - return h < 0.0 && H >= 0.0 && x >= 0.0 && y >= 0.0; - -} - -inline bool TransformedTriangle::testEdgeIntersectsTriangle(const TetraEdge edge) const -{ - - // assert(edge < H01); - - // correspondance edge - triple products - // for edges OX, ..., ZX (Grandy, table III) - static const TetraCorner TRIPLE_PRODUCTS[12] = - { - X, O, // OX - Y, O, // OY - Z, O, // OZ - X, Y, // XY - Y, Z, // YZ - Z, X, // ZX - }; - - // Grandy, [16] - const double t1 = calcStableT(TRIPLE_PRODUCTS[2*edge]); - const double t2 = calcStableT(TRIPLE_PRODUCTS[2*edge + 1]); - - //? should equality with zero use epsilon? - LOG(5, "testEdgeIntersectsTriangle : t1 = " << t1 << " t2 = " << t2 ); - return (t1*t2 <= 0.0) && (t1 - t2 != 0.0); -} - -inline bool TransformedTriangle::testFacetSurroundsSegment(const TriSegment seg, const TetraFacet facet) const -{ -#if 0 - const double signs[3] = - { - SIGN_FOR_SEG_FACET_INTERSECTION[3*facet], - SIGN_FOR_SEG_FACET_INTERSECTION[3*facet + 1], - SIGN_FOR_SEG_FACET_INTERSECTION[3*facet + 2] - }; -#endif - - const double* signs = &SIGN_FOR_SEG_FACET_INTERSECTION[3*facet]; - const double c1 = signs[0]*calcStableC(seg, DP_FOR_SEG_FACET_INTERSECTION[3*facet]); - const double c2 = signs[1]*calcStableC(seg, DP_FOR_SEG_FACET_INTERSECTION[3*facet + 1]); - const double c3 = signs[2]*calcStableC(seg, DP_FOR_SEG_FACET_INTERSECTION[3*facet + 2]); - - return (c1*c3 > 0.0) && (c2*c3 > 0.0); -} - -inline bool TransformedTriangle::testSegmentIntersectsFacet(const TriSegment seg, const TetraFacet facet) const -{ - // use correspondance facet a = 0 <=> offset for coordinate a in _coords - // and also correspondance segment AB => corner A - const double coord1 = _coords[5*seg + facet]; - const double coord2 = _coords[5*( (seg + 1) % 3) + facet]; - - //? should we use epsilon-equality here in second test? - LOG(5, "coord1 : " << coord1 << " coord2 : " << coord2 ); - - return (coord1*coord2 <= 0.0) && (coord1 != coord2); -} - -inline bool TransformedTriangle::testSegmentIntersectsHPlane(const TriSegment seg) const -{ - // get the H - coordinates - const double coord1 = _coords[5*seg + 4]; - const double coord2 = _coords[5*( (seg + 1) % 3) + 4]; - //? should we use epsilon-equality here in second test? - LOG(5, "coord1 : " << coord1 << " coord2 : " << coord2 ); - - return (coord1*coord2 <= 0.0) && (coord1 != coord2); -} - -inline bool TransformedTriangle::testSurfaceAboveCorner(const TetraCorner corner) const -{ - // ? There seems to be an error in Grandy -> it should be C_XY instead of C_YZ in [28]. - // ? I haven't really figured out why, but it seems to work. - const double normal = calcStableC(PQ, C_XY) + calcStableC(QR, C_XY) + calcStableC(RP, C_XY); - - LOG(6, "surface above corner " << corner << " : " << "n = " << normal << ", t = [" << calcTByDevelopingRow(corner, 1, false) << ", " << calcTByDevelopingRow(corner, 2, false) << ", " << calcTByDevelopingRow(corner, 3, false) ); - LOG(6, "] - stable : " << calcStableT(corner) ); - - //? we don't care here if the triple product is "invalid", that is, the triangle does not surround one of the - // edges going out from the corner (Grandy [53]) - if(!_validTP[corner]) - { - return ( calcTByDevelopingRow(corner, 1, false) * normal ) >= 0.0; - } - else - { - return ( calcStableT(corner) * normal ) >= 0.0; - } -} - -inline bool TransformedTriangle::testTriangleSurroundsRay(const TetraCorner corner) const -{ - // assert(corner == X || corner == Y || corner == Z); - - // double products to use for the possible corners - static const DoubleProduct DP_FOR_RAY_INTERSECTION[4] = - { - DoubleProduct(0), // O - only here to fill out and make indices match - C_10, // X - C_01, // Y - C_XY // Z - }; - - const DoubleProduct dp = DP_FOR_RAY_INTERSECTION[corner]; - - const double cPQ = calcStableC(PQ, dp); - const double cQR = calcStableC(QR, dp); - const double cRP = calcStableC(RP, dp); - - //? NB here we have no correction for precision - is this good? - // Our authority Grandy says nothing - LOG(5, "dp in triSurrRay for corner " << corner << " = [" << cPQ << ", " << cQR << ", " << cRP << "]" ); - - return ( cPQ*cQR > 0.0 ) && ( cPQ*cRP > 0.0 ); - -} -#endif diff --git a/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx b/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx deleted file mode 100644 index a69afa2c2..000000000 --- a/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx +++ /dev/null @@ -1,591 +0,0 @@ -// Copyright (C) 2007-2010 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 "TransformedTriangle.hxx" -#include -#include -#include -#include -#include "VectorUtils.hxx" - -namespace INTERP_KERNEL -{ - - // ---------------------------------------------------------------------------------- - // Correspondance tables describing all the variations of formulas. - // ---------------------------------------------------------------------------------- - - /// \brief Correspondance between facets and double products. - /// - /// This table encodes Grandy, table IV. Use 3*facet + {0,1,2} as index - const TransformedTriangle::DoubleProduct TransformedTriangle::DP_FOR_SEG_FACET_INTERSECTION[12] = - { - C_XH, C_XY, C_ZX, // OYZ - C_YH, C_YZ, C_XY, // OZX - C_ZH, C_ZX, C_YZ, // OXY - C_XH, C_YH, C_ZH // XYZ - }; - - /// \brief Signs associated with entries in DP_FOR_SEGMENT_FACET_INTERSECTION. - /// - /// This table encodes Grandy, table IV. Use 3*facet + {0,1,2} as index - const double TransformedTriangle::SIGN_FOR_SEG_FACET_INTERSECTION[12] = - { - 1.0, 1.0, -1.0, - 1.0, 1.0, -1.0, - 1.0, 1.0, -1.0, - 1.0, 1.0, 1.0 - }; - - /// \brief Coordinates of corners of tetrahedron. - /// - /// Use 3*Corner + coordinate as index - const double TransformedTriangle::COORDS_TET_CORNER[12] = - { - 0.0, 0.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0 - }; - - /// \brief Indices to use in tables DP_FOR_SEG_FACET_INTERSECTION and SIGN_FOR_SEG_FACET_INTERSECTION - /// for the calculation of the coordinates (x,y,z) of the intersection points - /// for Segment-Facet and Segment-Edge intersections. - /// - /// Use 3*facet + coordinate as index. -1 indicates that the coordinate is 0. - const int TransformedTriangle::DP_INDEX[12] = - { - // x, y, z - -1, 1, 2, // OYZ - 5, -1, 4, // OZX - 7, 8, -1, // OXY - 9, 10, 11 // XYZ - }; - - /// \brief Correspondance edge - corners. - /// - /// Gives the two corners associated with each edge - /// Use 2*edge + {0, 1} as index - const TransformedTriangle::TetraCorner TransformedTriangle::CORNERS_FOR_EDGE[12] = - { - O, X, // OX - O, Y, // OY - O, Z, // OZ - X, Y, // XY - Y, Z, // YZ - Z, X // ZX - }; - - /// \brief Correspondance edge - facets. - /// - /// Gives the two facets shared by and edge. Use 2*facet + {0, 1} as index - const TransformedTriangle::TetraFacet TransformedTriangle::FACET_FOR_EDGE[12] = - { - OXY, OZX, // OX - OXY, OYZ, // OY - OZX, OYZ, // OZ - OXY, XYZ, // XY - OYZ, XYZ, // YZ - OZX, XYZ // ZX - }; - - /// \brief Correspondance corners - edges. - /// - /// Gives edges meeting at a given corner. Use 3*corner + {0,1,2} as index - const TransformedTriangle::TetraEdge TransformedTriangle::EDGES_FOR_CORNER[12] = - { - OX, OY, OZ, // O - OX, XY, ZX, // X - OY, XY, YZ, // Y - OZ, ZX, YZ // Z - }; - - /// \brief Double products to use in halfstrip intersection tests. - /// - /// Use 4*(offset_edge) + {0,1,2,3} as index. offset_edge = edge - 3 (so that XY -> 0, YZ -> 1, ZX -> 2) - /// Entries with offset 0 and 1 are for the first condition (positive product) - /// and those with offset 2 and 3 are for the second condition (negative product). - const TransformedTriangle::DoubleProduct TransformedTriangle::DP_FOR_HALFSTRIP_INTERSECTION[12] = - { - C_10, C_01, C_ZH, C_10, // XY - C_01, C_XY, C_XH, C_01, // YZ - C_XY, C_10, C_YH, C_XY // ZX - }; - - /// \brief Double products to use in segment-ray test. - /// - /// Use 7*corner_offset + {0,1,2,3,4,5,6} as index. corner_offset = corner - 1 (so that X -> 0, Y-> 1, Z->2) - /// Entries with offset 0 are for first condition (zero double product) and the rest are for condition 3 (in the same - /// order as in the article) - const TransformedTriangle::DoubleProduct TransformedTriangle::DP_SEGMENT_RAY_INTERSECTION[21] = - { - C_10, C_YH, C_ZH, C_01, C_XY, C_YH, C_XY, // X - C_01, C_XH, C_ZH, C_XY, C_10, C_ZH, C_10, // Y - C_XY, C_YH, C_XH, C_10, C_01, C_XH, C_01 // Z - }; - - /** - * Calculates the point of intersection between the given edge of the tetrahedron and the - * triangle PQR. (Grandy, eq [22]) - * - * @pre testSurfaceEdgeIntersection(edge) returns true - * @param edge edge of tetrahedron - * @param pt array of three doubles in which to store the coordinates of the intersection point - */ - void TransformedTriangle::calcIntersectionPtSurfaceEdge(const TetraEdge edge, double* pt) const - { - assert(edge < H01); - - // barycentric interpolation between points A and B - // : (x,y,z)* = (1-alpha)*A + alpha*B where - // alpha = t_A / (t_A - t_B) - - const TetraCorner corners[2] = - { - CORNERS_FOR_EDGE[2*edge], - CORNERS_FOR_EDGE[2*edge + 1] - }; - - // calculate alpha - const double tA = calcStableT(corners[0]); - const double tB = calcStableT(corners[1]); - const double alpha = tA / (tA - tB); - - // calculate point - LOG(4, "corner A = " << corners[0] << " corner B = " << corners[1] ); - LOG(4, "tA = " << tA << " tB = " << tB << " alpha= " << alpha ); - for(int i = 0; i < 3; ++i) - { - - pt[i] = (1 - alpha) * COORDS_TET_CORNER[3*corners[0] + i] + - alpha * COORDS_TET_CORNER[3*corners[1] + i]; -#if 0 - pt[i] = (1 - alpha) * getCoordinateForTetCorner() + - alpha * getCoordinateForTetCorner(); -#endif - LOG(6, pt[i] ); - assert(pt[i] >= 0.0); - assert(pt[i] <= 1.0); - } - } - - /** - * Calculates the point of intersection between the given segment of the triangle - * and the given facet of the tetrahedron. (Grandy, eq. [23]) - * - * @pre testSurfaceEdgeIntersection(seg, facet) returns true - * - * @param seg segment of the triangle - * @param facet facet of the tetrahedron - * @param pt array of three doubles in which to store the coordinates of the intersection point - */ - void TransformedTriangle::calcIntersectionPtSegmentFacet(const TriSegment seg, const TetraFacet facet, double* pt) const - { - // calculate s - double s = 0.0; - for(int i = 0; i < 3; ++i) - { - const DoubleProduct dp = DP_FOR_SEG_FACET_INTERSECTION[3*facet + i]; - const double sign = SIGN_FOR_SEG_FACET_INTERSECTION[3*facet + i]; - s -= sign * calcStableC(seg, dp); - } - - assert(s != 0.0); - - // calculate coordinates of intersection point - for(int i = 0 ; i < 3; ++i) - { - const int dpIdx = DP_INDEX[3*facet + i]; - - if(dpIdx < 0) - { - pt[i] = 0.0; - } - else - { - const DoubleProduct dp = DP_FOR_SEG_FACET_INTERSECTION[dpIdx]; - const double sign = SIGN_FOR_SEG_FACET_INTERSECTION[dpIdx]; - pt[i] = -( sign * calcStableC(seg, dp) ) / s; - - LOG(4, "SegmentFacetIntPtCalc : pt[" << i << "] = " << pt[i] ); - LOG(4, "c(" << seg << ", " << dp << ") = " << sign * calcStableC(seg, dp) ); - assert(pt[i] >= 0.0); - assert(pt[i] <= 1.0); - } - } - - } - - /** - * Tests if the given segment of the triangle intersects the given edge of the tetrahedron (Grandy, eq. [20] - * If the OPTIMIZE is defined, it does not do the test the double product that should be zero. - * @param seg segment of the triangle - * @param edge edge of tetrahedron - * @return true if the segment intersects the edge - */ - bool TransformedTriangle::testSegmentEdgeIntersection(const TriSegment seg, const TetraEdge edge) const - { - { - // check condition that the double products for one of the two - // facets adjacent to the edge has a positive product - bool isFacetCondVerified = false; - TetraFacet facet[2]; - for(int i = 0 ; i < 2 ; ++i) - { - facet[i] = FACET_FOR_EDGE[2*edge + i]; - - // find the two c-values -> the two for the other edges of the facet - int idx1 = 0 ; - int idx2 = 1; - DoubleProduct dp1 = DP_FOR_SEG_FACET_INTERSECTION[3*facet[i] + idx1]; - DoubleProduct dp2 = DP_FOR_SEG_FACET_INTERSECTION[3*facet[i] + idx2]; - - if(dp1 == DoubleProduct( edge )) - { - idx1 = 2; - dp1 = DP_FOR_SEG_FACET_INTERSECTION[3*facet[i] + idx1]; - } - else if(dp2 == DoubleProduct( edge )) - { - idx2 = 2; - dp2 = DP_FOR_SEG_FACET_INTERSECTION[3*facet[i] + idx2]; - } - - const double c1 = SIGN_FOR_SEG_FACET_INTERSECTION[3*facet[i] + idx1]*calcStableC(seg, dp1); - const double c2 = SIGN_FOR_SEG_FACET_INTERSECTION[3*facet[i] + idx2]*calcStableC(seg, dp2); - - //isFacetCondVerified = isFacetCondVerified || c1*c2 > 0.0; - if(c1*c2 > 0.0) - { - isFacetCondVerified = true; - } - } - - if(!isFacetCondVerified) - { - return false; - } - else - { - return testSegmentIntersectsFacet(seg, facet[0]) || testSegmentIntersectsFacet(seg, facet[1]); - } - } - } - - /** - * Calculates the point of intersection between the given segment of the triangle - * and the given edge of the tetrahedron. (Grandy, eq. [25]) - * - * @pre testSegmentEdgeIntersection(seg, edge) returns true - * - * @param seg segment of the triangle - * @param edge edge of the tetrahedron - * @param pt array of three doubles in which to store the coordinates of the intersection point - */ - void TransformedTriangle::calcIntersectionPtSegmentEdge(const TriSegment seg, const TetraEdge edge, double* pt) const - { - assert(edge < H01); - - // get the two facets associated with the edge - static const TetraFacet FACETS_FOR_EDGE[12] = - { - OXY, OZX, // OX - OXY, OYZ, // OY - OZX, OYZ, // OZ - OXY, XYZ, // XY - OYZ, XYZ, // YZ - OZX, XYZ // ZX - }; - - const TetraFacet facets[2] = - { - FACETS_FOR_EDGE[2*edge], - FACETS_FOR_EDGE[2*edge + 1] - }; - - // calculate s for the two edges - double s[2]; - for(int i = 0; i < 2; ++i) - { - s[i] = 0.0; - for(int j = 0; j < 3; ++j) - { - const DoubleProduct dp = DP_FOR_SEG_FACET_INTERSECTION[3*facets[i] + j]; - const double sign = SIGN_FOR_SEG_FACET_INTERSECTION[3*facets[i] + j]; - s[i] += sign * calcStableC(seg, dp); - } - } - - // calculate denominator - const double denominator = s[0]*s[0] + s[1]*s[1]; - - // calculate intersection point - for(int i = 0; i < 3; ++i) - { - // calculate double product values for the two faces - double c[2]; - for(int j = 0 ; j < 2; ++j) - { - const int dpIdx = DP_INDEX[3*facets[j] + i]; - const DoubleProduct dp = DP_FOR_SEG_FACET_INTERSECTION[dpIdx]; - const double sign = SIGN_FOR_SEG_FACET_INTERSECTION[dpIdx]; - c[j] = dpIdx < 0.0 ? 0.0 : sign * calcStableC(seg, dp); - } - - // pt[i] = (c1*s1 + c2*s2) / (s1^2 + s2^2) - - pt[i] = (c[0] * s[0] + c[1] * s[1]) / denominator; - - // strange bug with -O2 enabled : assertion fails when we don't have the following - // trace - line - //std::cout << "pt[i] = " << pt[i] << std::endl; - //assert(pt[i] >= 0.0); // check we are in tetraeder - //assert(pt[i] <= 1.0); - - } - } - - - /** - * Tests if the given segment of the triangle intersects the given corner of the tetrahedron. - * (Grandy, eq. [21]). If OPTIMIZE is defined, the double products that should be zero are not verified. - * - * @param seg segment of the triangle - * @param corner corner of the tetrahedron - * @return true if the segment intersects the corner - */ - bool TransformedTriangle::testSegmentCornerIntersection(const TriSegment seg, const TetraCorner corner) const - { - - - // facets meeting at a given corner - static const TetraFacet FACETS_FOR_CORNER[12] = - { - OXY, OYZ, OZX, // O - OZX, OXY, XYZ, // X - OYZ, XYZ, OXY, // Y - OZX, XYZ, OYZ // Z - }; - - // check segment intersect a facet - for(int i = 0 ; i < 3 ; ++i) - { - const TetraFacet facet = FACETS_FOR_CORNER[3*corner + i]; - if(testSegmentIntersectsFacet(seg, facet)) - { - return true; - } - } - - return false; - } - - /** - * Tests if the given segment of the triangle intersects the half-strip above the - * given edge of the h = 0 plane. (Grandy, eq. [30]) - * - * @param seg segment of the triangle - * @param edge edge of the h = 0 plane of the tetrahedron (XY, YZ, ZX) - * @return true if the upwards ray from the corner intersects the triangle. - */ - bool TransformedTriangle::testSegmentHalfstripIntersection(const TriSegment seg, const TetraEdge edge) - { - // get right index here to avoid "filling out" array - const int edgeIndex = static_cast(edge) - 3; - - // double products used in test - // products 1 and 2 for each edge -> first condition in Grandy [30] - // products 3 and 4 for each edge -> third condition - // NB : some uncertainty whether these last are correct - static const DoubleProduct DP_FOR_HALFSTRIP_INTERSECTION[12] = - { - C_10, C_01, C_ZH, C_10, // XY - C_01, C_XY, C_XH, C_01, // YZ - C_XY, C_10, C_YH, C_XY // ZX - }; - - // facets to use in second condition (S_m) - static const TetraFacet FACET_FOR_HALFSTRIP_INTERSECTION[3] = - { - NO_TET_FACET, // XY -> special case : test with plane H = 0 - OYZ, // YZ - OZX // ZX - }; - - const double cVals[4] = - { - calcStableC(seg, DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIndex]), - calcStableC(seg, DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIndex + 1]), - calcStableC(seg, DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIndex + 2]), - calcStableC(seg, DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIndex + 3]) - }; - - const TetraFacet facet = FACET_FOR_HALFSTRIP_INTERSECTION[edgeIndex]; - - - // special case : facet H = 0 - const bool cond2 = (facet == NO_TET_FACET) ? testSegmentIntersectsHPlane(seg) : testSegmentIntersectsFacet(seg, facet); - LOG(4, "Halfstrip tests (" << seg << ", " << edge << ") : " << (cVals[0]*cVals[1] < 0.0) << ", " << cond2 << ", " << (cVals[2]*cVals[3] > 0.0) ); - LOG(4, "c2 = " << cVals[2] << ", c3 = " << cVals[3] ); - - return (cVals[0]*cVals[1] < 0.0) && cond2 && (cVals[2]*cVals[3] > 0.0); - } - - /** - * Calculates the point of intersection between the given segment of the triangle - * and the halfstrip above the given edge of the tetrahedron. (Grandy, eq. [31]) - * - * @pre testSegmentHalfstripIntersection(seg, edge) returns true - * - * @param seg segment of the triangle - * @param edge edge of the tetrahedron defining the halfstrip - * @param pt array of three doubles in which to store the coordinates of the intersection point - */ - void TransformedTriangle::calcIntersectionPtSegmentHalfstrip(const TriSegment seg, const TetraEdge edge, double* pt) const - { - assert(edge > OZ); - assert(edge < H01); - - // get right index here to avoid "filling out" array - const int edgeIndex = static_cast(edge) - 3; - assert(edgeIndex >= 0); - assert(edgeIndex < 3); - - // Barycentric interpolation on the edge - // for edge AB : (x,y,z)* = (1-alpha) * A + alpha * B - // where alpha = cB / (cB - cA) - - const double cA = calcStableC(seg, DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIndex]); - const double cB = calcStableC(seg, DP_FOR_HALFSTRIP_INTERSECTION[4*edgeIndex + 1]); - assert(cA != cB); - - const double alpha = cA / (cA - cB); - - for(int i = 0; i < 3; ++i) - { - const TetraCorner corners[2] = - { - CORNERS_FOR_EDGE[2*edge], - CORNERS_FOR_EDGE[2*edge + 1] - }; - - const double cornerCoords[2] = - { - COORDS_TET_CORNER[3*corners[0] + i], - COORDS_TET_CORNER[3*corners[1] + i] - }; - - pt[i] = (1 - alpha) * cornerCoords[0] + alpha * cornerCoords[1]; - LOG(6, pt[i] ); - assert(pt[i] >= 0.0); - assert(pt[i] <= 1.0); - } - assert(epsilonEqualRelative(pt[0] + pt[1] + pt[2], 1.0)); - } - - /** - * Tests if the given segment of triangle PQR intersects the ray pointing - * in the upwards z - direction from the given corner of the tetrahedron. (Grandy eq. [29]) - * If OPTIMIZE is defined, the double product that should be zero is not verified. - * - * @param seg segment of the triangle PQR - * @param corner corner of the tetrahedron on the h = 0 facet (X, Y, or Z) - * @return true if the upwards ray from the corner intersects the segment. - */ - bool TransformedTriangle::testSegmentRayIntersection(const TriSegment seg, const TetraCorner corner) const - { - assert(corner == X || corner == Y || corner == Z); - LOG(4, "Testing seg - ray intersection for seg = " << seg << ", corner = " << corner ); - - // readjust index since O is not used - const int cornerIdx = static_cast(corner) - 1; - - // facets to use - //? not sure this is correct - static const TetraFacet FIRST_FACET_SEGMENT_RAY_INTERSECTION[3] = - { - OZX, // X - OYZ, // Y - OZX, // Z - }; - - // cond 2 - const bool cond21 = testSegmentIntersectsFacet(seg, FIRST_FACET_SEGMENT_RAY_INTERSECTION[cornerIdx]); - const bool cond22 = (corner == Z) ? testSegmentIntersectsFacet(seg, OYZ) : testSegmentIntersectsHPlane(seg); - - if(!(cond21 || cond22)) - { - LOG(4, "SR fails at cond 2 : cond21 = " << cond21 << ", cond22 = " << cond22 ); - return false; - } - - // cond 3 - const double cVals[6] = - { - calcStableC(seg, DP_SEGMENT_RAY_INTERSECTION[7*cornerIdx + 1]), - calcStableC(seg, DP_SEGMENT_RAY_INTERSECTION[7*cornerIdx + 2]), - calcStableC(seg, DP_SEGMENT_RAY_INTERSECTION[7*cornerIdx + 3]), - calcStableC(seg, DP_SEGMENT_RAY_INTERSECTION[7*cornerIdx + 4]), - calcStableC(seg, DP_SEGMENT_RAY_INTERSECTION[7*cornerIdx + 5]), - calcStableC(seg, DP_SEGMENT_RAY_INTERSECTION[7*cornerIdx + 6]), - }; - - // cond. 3 - if(( (cVals[0] + cVals[1])*(cVals[2] - cVals[3]) - cVals[4]*cVals[5] ) >= 0.0) - { - LOG(4, "SR fails at cond 3 : " << (cVals[0] + cVals[1])*(cVals[2] - cVals[3]) - cVals[4]*cVals[5] ); - } - return ( (cVals[0] + cVals[1])*(cVals[2] - cVals[3]) - cVals[4]*cVals[5] ) < 0.0; - - } - - // ///////////////////////////////////////////////////////////////////////////////// - // Utility methods used in intersection tests /////////////// - // ///////////////////////////////////////////////////////////////////////////////// - /** - * Tests if the triangle PQR surrounds the axis on which the - * given edge of the tetrahedron lies. - * - * @param edge edge of tetrahedron - * @return true if PQR surrounds edge, false if not (see Grandy, eq. [53]) - */ - bool TransformedTriangle::testTriangleSurroundsEdge(const TetraEdge edge) const - { - // NB DoubleProduct enum corresponds to TetraEdge enum according to Grandy, table III - // so we can use the edge directly - - const double cPQ = calcStableC(PQ, DoubleProduct(edge)); - const double cQR = calcStableC(QR, DoubleProduct(edge)); - const double cRP = calcStableC(RP, DoubleProduct(edge)); - - LOG(5, "TriangleSurroundsEdge : edge = " << edge << " c = [" << cPQ << ", " << cQR << ", " << cRP << "]" ); - - // if two or more c-values are zero we disallow x-edge intersection - // Grandy, p.446 - const int numZeros = (cPQ == 0.0 ? 1 : 0) + (cQR == 0.0 ? 1 : 0) + (cRP == 0.0 ? 1 : 0); - - if(numZeros >= 2 ) - { - LOG(5, "TriangleSurroundsEdge test fails due to too many 0 dp" ); - } - - return (cPQ*cQR >= 0.0) && (cQR*cRP >= 0.0) && (cRP*cPQ >= 0.0) && numZeros < 2; - } - -} // NAMESPACE diff --git a/src/INTERP_KERNEL/TransformedTriangleMath.cxx b/src/INTERP_KERNEL/TransformedTriangleMath.cxx deleted file mode 100644 index 2a5373e48..000000000 --- a/src/INTERP_KERNEL/TransformedTriangleMath.cxx +++ /dev/null @@ -1,503 +0,0 @@ -// Copyright (C) 2007-2010 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 "TransformedTriangle.hxx" -#include -#include -#include -#include -#include -#include -#include - -#include "VectorUtils.hxx" - -namespace INTERP_KERNEL -{ - - // ---------------------------------------------------------------------------------- - // Tables - // ---------------------------------------------------------------------------------- - - /// Table with first coordinate (a) used to calculate double product c^pq_ab = p_a * q_b - p_b * q_a (index to be used : DoubleProduct) - const int TransformedTriangle::DP_OFFSET_1[8] = {1, 2, 0, 2, 0, 1, 4, 1}; - - /// Table with second coordinate (b) used to calculate double product c^pq_ab = p_a * q_b - p_b * q_a (index to be used : DoubleProduct) - const int TransformedTriangle::DP_OFFSET_2[8] = {2, 0, 1, 3, 3, 3, 0, 4}; - - /// Coordinates used to calculate triple products by the expanding one of the three rows of the determinant (index to be used : 3*Corner + row) - const int TransformedTriangle::COORDINATE_FOR_DETERMINANT_EXPANSION[12] = - { - // row 1, 2, 3 - 0, 1, 2, // O - 3, 1, 2, // X - 0, 3, 2, // Y - 0, 1, 3 // Z - }; - - /// Double products used to calculate triple products by expanding one of the three rows of the determinant (index to be used : 3*Corner + row) - const TransformedTriangle::DoubleProduct TransformedTriangle::DP_FOR_DETERMINANT_EXPANSION[12] = - { - // row 1, 2, 3 - C_YZ, C_ZX, C_XY, // O - C_YZ, C_ZH, C_YH, // X - C_ZH, C_ZX, C_XH, // Y - C_YH, C_XH, C_XY // Z - }; - - /// The machine epsilon, used in precision corrections - const long double TransformedTriangle::MACH_EPS = std::numeric_limits::epsilon(); - - /// 4.0 * the machine epsilon, represents the precision of multiplication when performing corrections corrections ( f in Grandy ) - const long double TransformedTriangle::MULT_PREC_F = 4.0 * TransformedTriangle::MACH_EPS; - - /// Threshold for resetting double and triple products to zero; ( F / f in Grandy ) - const long double TransformedTriangle::THRESHOLD_F = 500.0; - - /// Threshold for what is considered a small enough angle to warrant correction of triple products by Grandy, [57] - const double TransformedTriangle::TRIPLE_PRODUCT_ANGLE_THRESHOLD = 0.1; - - - // after transformation to the U-space, coordinates are inaccurate - // small variations around zero should not be taken into account - void TransformedTriangle::resetNearZeroCoordinates() - { - for (int i=0; i<15; i++) - if (fabs(_coords[i]) distances; - - // -- (1) for each segment : check that double products satisfy Grandy, [46] - // -- and make corrections if not - for(TriSegment seg = PQ ; seg <= RP ; seg = TriSegment(seg + 1)) - { - if(!areDoubleProductsConsistent(seg)) - { - LOG(4, "inconsistent! "); - for(TetraCorner corner = O ; corner <= Z ; corner = TetraCorner(corner + 1)) - { - // calculate distance corner - segment axis - const double dist = calculateDistanceCornerSegment(corner, seg); - distances.insert( std::make_pair( dist, corner ) ); - } - - // first element -> minimum distance - const TetraCorner minCorner = distances.begin()->second; - resetDoubleProducts(seg, minCorner); - distances.clear(); - } - } - - // -- (2) check that each double product statisfies Grandy, [47], else set to 0 - for(TriSegment seg = PQ ; seg <= RP ; seg = TriSegment(seg + 1)) - { - for(DoubleProduct dp = C_YZ ; dp <= C_10 ; dp = DoubleProduct(dp + 1)) - { - // find the points of the triangle - // 0 -> P, 1 -> Q, 2 -> R - const int pt1 = seg; - const int pt2 = (seg + 1) % 3; - - // find offsets - const int off1 = DP_OFFSET_1[dp]; - const int off2 = DP_OFFSET_2[dp]; - - const double term1 = _coords[5*pt1 + off1] * _coords[5*pt2 + off2]; - const double term2 = _coords[5*pt1 + off2] * _coords[5*pt2 + off1]; - - const long double delta = MULT_PREC_F * ( std::fabs(term1) + std::fabs(term2) ); - - if( epsilonEqual(_doubleProducts[8*seg + dp], 0.0, THRESHOLD_F * delta)) - { - // debug output -#if LOG_LEVEL >= 5 - if(_doubleProducts[8*seg + dp] != 0.0) - { - LOG(5, "Double product for (seg,dp) = (" << seg << ", " << dp << ") = " ); - LOG(5, std::fabs(_doubleProducts[8*seg + dp]) << " is imprecise, reset to 0.0" ); - } -#endif - - - _doubleProducts[8*seg + dp] = 0.0; - - } - } - } - - _is_double_products_calculated = true; - } - - /** - * Checks if the double products for a given segment are consistent, as defined by - * Grandy, [46]. - * - * @param seg Segment for which to check consistency of double products - * @return true if the double products are consistent, false if not - */ - bool TransformedTriangle::areDoubleProductsConsistent(const TriSegment seg) const - { - const double term1 = _doubleProducts[8*seg + C_YZ] * _doubleProducts[8*seg + C_XH]; - const double term2 = _doubleProducts[8*seg + C_ZX] * _doubleProducts[8*seg + C_YH]; - const double term3 = _doubleProducts[8*seg + C_XY] * _doubleProducts[8*seg + C_ZH]; - - LOG(2, "for seg " << seg << " consistency " << term1 + term2 + term3 ); - LOG(2, "term1 :" << term1 << " term2 :" << term2 << " term3: " << term3 ); - - const int num_zero = (term1 == 0.0 ? 1 : 0) + (term2 == 0.0 ? 1 : 0) + (term3 == 0.0 ? 1 : 0); - const int num_neg = (term1 < 0.0 ? 1 : 0) + (term2 < 0.0 ? 1 : 0) + (term3 < 0.0 ? 1 : 0); - const int num_pos = (term1 > 0.0 ? 1 : 0) + (term2 > 0.0 ? 1 : 0) + (term3 > 0.0 ? 1 : 0); - - assert( num_zero + num_neg + num_pos == 3 ); - - // calculated geometry is inconsistent if we have one of the following cases - // * one term zero and the other two of the same sign - // * two terms zero - // * all terms positive - // * all terms negative - if(((num_zero == 1 && num_neg != 1) || num_zero == 2 || (num_neg == 0 && num_zero != 3) || num_neg == 3 )) - { - LOG(4, "inconsistent dp found" ); - } - return !((num_zero == 1 && num_neg != 1) || num_zero == 2 || (num_neg == 0 && num_zero != 3) || num_neg == 3 ); - - } - - /** - * Calculate the shortest distance between a tetrahedron corner and a triangle segment. - * - * @param corner corner of the tetrahedron - * @param seg segment of the triangle - * @return shortest distance from the corner to the segment - */ - double TransformedTriangle::calculateDistanceCornerSegment(const TetraCorner corner, const TriSegment seg) const - { - // NB uses fact that TriSegment <=> TriCorner that is first point of segment (PQ <=> P) - const TriCorner ptP_idx = TriCorner(seg); - const TriCorner ptQ_idx = TriCorner( (seg + 1) % 3); - - const double ptP[3] = { _coords[5*ptP_idx], _coords[5*ptP_idx + 1], _coords[5*ptP_idx + 2] }; - const double ptQ[3] = { _coords[5*ptQ_idx], _coords[5*ptQ_idx + 1], _coords[5*ptQ_idx + 2] }; - - // coordinates of corner - const double ptTetCorner[3] = - { - COORDS_TET_CORNER[3*corner ], - COORDS_TET_CORNER[3*corner + 1], - COORDS_TET_CORNER[3*corner + 2] - }; - - // dist^2 = ( PQ x CP )^2 / |PQ|^2 where C is the corner point - - // difference vectors - const double diffPQ[3] = { ptQ[0] - ptP[0], ptQ[1] - ptP[1], ptQ[2] - ptP[2] }; - const double diffCornerP[3] = { ptP[0] - ptTetCorner[0], ptP[1] - ptTetCorner[1], ptP[2] - ptTetCorner[2] }; - - // cross product of difference vectors - double crossProd[3]; - cross(diffPQ, diffCornerP, crossProd); - - const double cross_squared = dot(crossProd, crossProd); - const double norm_diffPQ_squared = dot(diffPQ, diffPQ); - - assert(norm_diffPQ_squared != 0.0); - - return cross_squared / norm_diffPQ_squared; - } - - /** - * Pre-calculates all triple products for the tetrahedron with respect to - * this triangle, and stores them internally. This method takes into account - * the problem of errors due to cancellation. - * - */ - void TransformedTriangle::preCalculateTripleProducts(void) - { - if(_is_triple_products_calculated) - { - return; - } - - // find edge / row to use -> that whose edge makes the smallest angle to the triangle - // use a map to find the minimum - std::map anglesForRows; - - LOG(4, "Precalculating triple products" ); - for(TetraCorner corner = O ; corner <= Z ; corner = TetraCorner(corner + 1)) - { - LOG(6, "- Triple product for corner " << corner ); - - for(int row = 1 ; row < 4 ; ++row) - { - const DoubleProduct dp = DP_FOR_DETERMINANT_EXPANSION[3*corner + (row - 1)]; - - // get edge by using correspondance between Double Product and Edge - TetraEdge edge = TetraEdge(dp); - - // use edge only if it is surrounded by the surface - if( _triangleSurroundsEdgeCache[edge] ) - { - // -- calculate angle between edge and PQR - const double angle = calculateAngleEdgeTriangle(edge); - anglesForRows.insert(std::make_pair(angle, row)); - } - } - - if(anglesForRows.size() != 0) // we have found a good row - { - const double minAngle = anglesForRows.begin()->first; - const int minRow = anglesForRows.begin()->second; - - if(minAngle < TRIPLE_PRODUCT_ANGLE_THRESHOLD) - { - _tripleProducts[corner] = calcTByDevelopingRow(corner, minRow, true); - } - else - { - _tripleProducts[corner] = calcTByDevelopingRow(corner, minRow, false); - } - _validTP[corner] = true; - } - else - { - // this value will not be used - // we set it to whatever - LOG(6, "Triple product not calculated for corner " << corner ); - _tripleProducts[corner] = -3.14159265; - _validTP[corner] = false; - - } - anglesForRows.clear(); - - } - - _is_triple_products_calculated = true; - } - - /** - * Calculates the angle between an edge of the tetrahedron and the triangle - * - * @param edge edge of the tetrahedron - * @return angle between triangle and edge - */ - double TransformedTriangle::calculateAngleEdgeTriangle(const TetraEdge edge) const - { - // find normal to PQR - cross PQ and PR - const double pq[3] = - { - _coords[5*Q] - _coords[5*P], - _coords[5*Q + 1] - _coords[5*P + 1], - _coords[5*Q + 2] - _coords[5*P + 2] - }; - - const double pr[3] = - { - _coords[5*R] - _coords[5*P], - _coords[5*R + 1] - _coords[5*P + 1], - _coords[5*R + 2] - _coords[5*P + 2] - }; - - double normal[3]; - - cross(pq, pr, normal); - - static const double EDGE_VECTORS[18] = - { - 1.0, 0.0, 0.0, // OX - 0.0, 1.0, 0.0, // OY - 0.0, 0.0, 1.0, // OZ - -1.0, 1.0, 0.0, // XY - 0.0,-1.0, 1.0, // YZ - 1.0, 0.0,-1.0 // ZX - }; - - const double edgeVec[3] = { - EDGE_VECTORS[3*edge], - EDGE_VECTORS[3*edge + 1], - EDGE_VECTORS[3*edge + 2], - }; - - //return angleBetweenVectors(normal, edgeVec); - - const double lenNormal = norm(normal); - const double lenEdgeVec = norm(edgeVec); - const double dotProd = dot(normal, edgeVec); - - //? is this more stable? -> no subtraction - // return asin( dotProd / ( lenNormal * lenEdgeVec ) ) + 3.141592625358979 / 2.0; - double tmp=dotProd / ( lenNormal * lenEdgeVec ); - tmp=std::max(tmp,-1.); - tmp=std::min(tmp,1.); - return atan(1.0)*4.0 - acos(tmp); - - } - - /** - * Calculates triple product associated with the given corner of tetrahedron, developing - * the determinant by the given row. The triple product gives the signed volume of - * the tetrahedron between this corner and the triangle PQR. If the flag project is true, - * one coordinate is projected out in order to eliminate errors in the intersection point - * calculation due to cancellation. - * - * @pre double products have already been calculated - * @param corner corner for which the triple product is calculated - * @param row row (1 <= row <= 3) used to calculate the determinant - * @param project indicates whether or not to perform projection as inidicated in Grandy, p.446 - * @return triple product associated with corner (see Grandy, [50]-[52]) - */ - double TransformedTriangle::calcTByDevelopingRow(const TetraCorner corner, const int row, const bool project) const - { - - // OVERVIEW OF CALCULATION - // --- sign before the determinant - // the sign used depends on the sign in front of the triple product (Grandy, [15]), - // and the convention used in the definition of the double products - - // the sign in front of the determinant gives the following schema for the three terms (I): - // corner/row 1 2 3 - // O (sign:+) + - + - // X (sign:-) - + - - // Y (sign:-) - + - - // Z (sign:-) - + - - - // the 2x2 determinants are the following (C_AB <=> A_p*B_q - B_p*A_q, etc) - // corner/row 1 2 3 - // O (sign:+) C_YZ C_XZ C_XY - // X (sign:-) C_YZ C_HZ C_HY - // Y (sign:-) C_HZ C_XZ C_XH - // Z (sign:-) C_YH C_XH C_XY - - // these are represented in DP_FOR_DETERMINANT_EXPANSION, - // except for the fact that certain double products are inversed (C_AB <-> C_BA) - - // comparing with the DOUBLE_PRODUCTS and using the fact that C_AB = -C_BA - // we deduce the following schema (II) : - // corner/row 1 2 3 - // O (sign:+) + - + - // X (sign:-) + - - - // Y (sign:-) - - + - // Z (sign:-) + + + - - // comparing the two schemas (I) and (II) gives us the following matrix of signs, - // putting 1 when the signs in (I) and (II) are equal and -1 when they are different : - - static const int SIGNS[12] = - { - 1, 1, 1, - -1,-1, 1, - 1,-1,-1, - -1, 1,-1 - }; - - // find the offsets of the rows of the determinant - const int offset = COORDINATE_FOR_DETERMINANT_EXPANSION[3 * corner + (row - 1)]; - - const DoubleProduct dp = DP_FOR_DETERMINANT_EXPANSION[3 * corner + (row - 1)]; - - const int sign = SIGNS[3 * corner + (row - 1)]; - - const double cQR = calcStableC(QR, dp); - const double cRP = calcStableC(RP, dp); - const double cPQ = calcStableC(PQ, dp); - - double alpha = 0.0; - - // coordinate to use for projection (Grandy, [57]) with edges - // OX, OY, OZ, XY, YZ, ZX in order : - // (y, z, x, h, h, h) - // for the first three we could also use {2, 0, 1} - static const int PROJECTION_COORDS[6] = { 1, 2, 0, 3, 3, 3 } ; - - const int coord = PROJECTION_COORDS[ dp ]; - - // coordinate values for P, Q and R - const double coordValues[3] = { _coords[5*P + coord], _coords[5*Q + coord], _coords[5*R + coord] }; - - if(project) - { - // products coordinate values with corresponding double product - const double coordDPProd[3] = { coordValues[0] * cQR, coordValues[1] * cRP, coordValues[2] * cPQ }; - - const double sumDPProd = coordDPProd[0] + coordDPProd[1] + coordDPProd[2]; - const double sumDPProdSq = dot(coordDPProd, coordDPProd); - - // alpha = sumDPProd / sumDPProdSq; - alpha = (sumDPProdSq != 0.0) ? sumDPProd / sumDPProdSq : 0.0; - } - - const double cQRbar = cQR * (1.0 - alpha * coordValues[0] * cQR); - const double cRPbar = cRP * (1.0 - alpha * coordValues[1] * cRP); - const double cPQbar = cPQ * (1.0 - alpha * coordValues[2] * cPQ); - - // check sign of barred products - should not change - // assert(cQRbar * cQR >= 0.0); - //assert(cRPbar * cRP >= 0.0); - //assert(cPQbar * cPQ >= 0.0); - - const double p_term = _coords[5*P + offset] * cQRbar; - const double q_term = _coords[5*Q + offset] * cRPbar; - const double r_term = _coords[5*R + offset] * cPQbar; - - // check that we are not so close to zero that numerical errors could take over, - // otherwise reset to zero (cf Grandy, p. 446) -#ifdef FIXED_DELTA - const double delta = FIXED_DELTA; -#else - const long double delta = MULT_PREC_F * (std::fabs(p_term) + std::fabs(q_term) + std::fabs(r_term)); -#endif - - if( epsilonEqual( p_term + q_term + r_term, 0.0, THRESHOLD_F * delta) ) - { - LOG(4, "Reset imprecise triple product for corner " << corner << " to zero" ); - return 0.0; - } - else - { - // NB : using plus also for the middle term compensates for a double product - // which is inversely ordered - LOG(6, "Triple product for corner " << corner << ", row " << row << " = " << sign*( p_term + q_term + r_term ) ); - return sign*( p_term + q_term + r_term ); - } - - } - -} diff --git a/src/INTERP_KERNEL/TranslationRotationMatrix.cxx b/src/INTERP_KERNEL/TranslationRotationMatrix.cxx deleted file mode 100644 index 0e31b21e0..000000000 --- a/src/INTERP_KERNEL/TranslationRotationMatrix.cxx +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2007-2010 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 "TranslationRotationMatrix.hxx" - -const double INTERP_KERNEL::TranslationRotationMatrix::EPS=1e-12; diff --git a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx b/src/INTERP_KERNEL/TranslationRotationMatrix.hxx deleted file mode 100644 index e1108573b..000000000 --- a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2007-2010 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 __TRANSLATIONROTATIONMATRIX_HXX__ -#define __TRANSLATIONROTATIONMATRIX_HXX__ - -#include "INTERPKERNELDefines.hxx" - -#include - -namespace INTERP_KERNEL -{ - class INTERPKERNEL_EXPORT TranslationRotationMatrix - { - - public: - - TranslationRotationMatrix() - { - unsigned i; - for(i=0;i class InterpType > - class TriangulationIntersector : public InterpType > - { - public: - static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; - static const NumberingPolicy numPol=MyMeshType::My_numPol; - public: - TriangulationIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, double medianPlane, int orientation, int printLevel); - double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS); - double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad); - double intersectGeometryGeneral(const std::vector& targetCoords, const std::vector& sourceCoords); - double intersectGeoBary(const std::vector& targetCell, bool targetCellQuadratic, const double *sourceCell, std::vector& res); - - }; -} - -#endif diff --git a/src/INTERP_KERNEL/TriangulationIntersector.txx b/src/INTERP_KERNEL/TriangulationIntersector.txx deleted file mode 100644 index de8a83954..000000000 --- a/src/INTERP_KERNEL/TriangulationIntersector.txx +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (C) 2007-2010 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 __TRIANGULATIONINTERSECTOR_TXX__ -#define __TRIANGULATIONINTERSECTOR_TXX__ - -#include "TriangulationIntersector.hxx" -#include "PlanarIntersectorP0P0.txx" -#include "PlanarIntersectorP0P1.txx" -#include "PlanarIntersectorP1P0.txx" -#include "PlanarIntersectorP1P0Bary.txx" - -#include "InterpolationUtils.hxx" -#include "PlanarIntersector.hxx" - -#include - -#define TRI_INTERSECTOR TriangulationIntersector -#define TRI_INTER_TEMPLATE template class InterpType> - -namespace INTERP_KERNEL -{ - TRI_INTER_TEMPLATE - TRI_INTERSECTOR::TriangulationIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double DimCaracteristic, double Precision, double md3DSurf, - double MedianPlane, int orientation, int PrintLevel) - :InterpType(meshT,meshS,DimCaracteristic, Precision, md3DSurf, - MedianPlane, true, orientation, PrintLevel) - { - if(PlanarIntersector::_print_level >= 1) - { - std::cout << " - intersection type = triangles " << std::endl; - if(SPACEDIM==3) std::cout << "_do_rotate = true"<< std::endl; - } - } - - TRI_INTER_TEMPLATE - double TRI_INTERSECTOR::intersectGeometry(ConnType icellT, ConnType icellS, - ConnType nbNodesT, ConnType nbNodesS) - { - double result = 0.; - int orientation = 1; - - //Obtain the coordinates of T and S - std::vector CoordsT; - std::vector CoordsS; - PlanarIntersector::getRealCoordinates(icellT,icellS,nbNodesT,nbNodesS,CoordsT,CoordsS,orientation); - //Compute the intersection area - double area[SPACEDIM]; - for(ConnType iT = 1; iT inter; - INTERP_KERNEL::intersec_de_triangle(&CoordsT[0],&CoordsT[SPACEDIM*iT],&CoordsT[SPACEDIM*(iT+1)], - &CoordsS[0],&CoordsS[SPACEDIM*iS],&CoordsS[SPACEDIM*(iS+1)], - inter, PlanarIntersector::_dim_caracteristic, - PlanarIntersector::_precision); - ConnType nb_inter=((ConnType)inter.size())/2; - if(nb_inter >3) inter=reconstruct_polygon(inter); - for(ConnType i = 1; i(&inter[0],&inter[2*i],&inter[2*(i+1)],area); - result +=0.5*fabs(area[0]); - } - //DEBUG prints - if(PlanarIntersector::_print_level >= 3) - { - std::cout << std::endl << "Number of nodes of the intersection = "<< nb_inter << std::endl; - for(ConnType i=0; i< nb_inter; i++) - {for (int idim=0; idim<2; idim++) std::cout << inter[2*i+idim] << " "; std::cout << std::endl; } - } - } - } - - //DEBUG PRINTS - if(PlanarIntersector::_print_level >= 3) - std::cout << std::endl <<"Intersection area = " << result << std::endl; - - return orientation*result; - } - - TRI_INTER_TEMPLATE - double TRI_INTERSECTOR::intersectGeometryWithQuadrangle(const double * quadrangle, - const std::vector& sourceCoords, - bool isSourceQuad) - { - double result = 0.; - ConnType nbNodesS=sourceCoords.size()/SPACEDIM; - //Compute the intersection area - double area[SPACEDIM]; - for(ConnType iT = 1; iT<3; iT++) - { - for(ConnType iS = 1; iS inter; - INTERP_KERNEL::intersec_de_triangle(quadrangle,&quadrangle[SPACEDIM*iT],&quadrangle[SPACEDIM*(iT+1)], - &sourceCoords[0],&sourceCoords[SPACEDIM*iS],&sourceCoords[SPACEDIM*(iS+1)], - inter, PlanarIntersector::_dim_caracteristic, - PlanarIntersector::_precision); - ConnType nb_inter=((ConnType)inter.size())/2; - if(nb_inter >3) inter=reconstruct_polygon(inter); - for(ConnType i = 1; i(&inter[0],&inter[2*i],&inter[2*(i+1)],area); - result +=0.5*fabs(area[0]); - } - //DEBUG prints - if(PlanarIntersector::_print_level >= 3) - { - std::cout << std::endl << "Number of nodes of the intersection = "<< nb_inter << std::endl; - for(ConnType i=0; i< nb_inter; i++) - {for (int idim=0; idim<2; idim++) std::cout << inter[2*i+idim] << " "; std::cout << std::endl; } - } - } - } - - //DEBUG PRINTS - if(PlanarIntersector::_print_level >= 3) - std::cout << std::endl <<"Intersection area = " << result << std::endl; - - return result; - } - - TRI_INTER_TEMPLATE - double TRI_INTERSECTOR::intersectGeometryGeneral(const std::vector& targetCoords, - const std::vector& sourceCoords) - { - double result = 0.; - ConnType nbNodesS=sourceCoords.size()/SPACEDIM; - ConnType nbNodesT=targetCoords.size()/SPACEDIM; - //Compute the intersection area - double area[SPACEDIM]; - for(ConnType iT = 1; iT inter; - INTERP_KERNEL::intersec_de_triangle(&targetCoords[0],&targetCoords[SPACEDIM*iT],&targetCoords[SPACEDIM*(iT+1)], - &sourceCoords[0],&sourceCoords[SPACEDIM*iS],&sourceCoords[SPACEDIM*(iS+1)], - inter, PlanarIntersector::_dim_caracteristic, - PlanarIntersector::_precision); - ConnType nb_inter=((ConnType)inter.size())/2; - if(nb_inter >3) inter=reconstruct_polygon(inter); - for(ConnType i = 1; i(&inter[0],&inter[2*i],&inter[2*(i+1)],area); - result +=0.5*fabs(area[0]); - } - } - } - return result; - } - - //================================================================================ - /*! - * \brief Intersect a triangle and a polygon for P1P0 barycentric algorithm - * \param targetCell - list of coordinates of target polygon in full interlace - * \param targetCellQuadratic - specifies if target polygon is quadratic or not - * \param sourceTria - list of coordinates of source triangle - * \param res - coefficients a,b and c associated to nodes of sourceTria - */ - //================================================================================ - - TRI_INTER_TEMPLATE - double TRI_INTERSECTOR::intersectGeoBary(const std::vector& targetCell, - bool targetCellQuadratic, - const double * sourceTria, - std::vector& res) - { - std::vector sourceCell(3); - sourceCell[0] = &sourceTria[0]; - sourceCell[1] = &sourceTria[SPACEDIM]; - sourceCell[2] = &sourceTria[SPACEDIM*2]; - - //Compute the intersection area - double inter_area[SPACEDIM], total_area = 0.; - double total_barycenter[SPACEDIM]; - total_barycenter[0]=total_barycenter[1] = 0.; - - const ConnType nbNodesT=targetCell.size()/SPACEDIM; - for(ConnType iT = 1; iT inter; - INTERP_KERNEL::intersec_de_triangle(&targetCell[0],&targetCell[SPACEDIM*iT],&targetCell[SPACEDIM*(iT+1)], - sourceCell[0], sourceCell[1], sourceCell[2], - inter, PlanarIntersector::_dim_caracteristic, - PlanarIntersector::_precision); - ConnType nb_inter=((ConnType)inter.size())/2; - if(nb_inter >3) inter=reconstruct_polygon(inter); - for(ConnType i = 1; i(&inter[0],&inter[2*i],&inter[2*(i+1)],inter_area); - inter_area[0] = 0.5 * fabs( inter_area[0] ); - total_area += inter_area[0]; - std::vector inter_bary=INTERP_KERNEL::bary_poly(inter); - total_barycenter[0] += inter_area[0] * inter_bary[0]; - total_barycenter[1] += inter_area[0] * inter_bary[1]; - } - } - if ( total_area > std::numeric_limits::min() ) - { - total_barycenter[0] /= total_area; - total_barycenter[1] /= total_area; - res.resize(3); - barycentric_coords( sourceCell, &total_barycenter[0], &res[0]); - res[0] *= total_area; - res[1] *= total_area; - res[2] *= total_area; - } - else - { - total_area = 0; - } - return total_area; - } - -} - -#endif diff --git a/src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx b/src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx deleted file mode 100644 index 384d8d2e0..000000000 --- a/src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx +++ /dev/null @@ -1,755 +0,0 @@ -// Copyright (C) 2007-2010 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 : UnitTetraIntersectionBary.cxx -// Created : Tue Dec 9 16:48:49 2008 -// Author : Edward AGAPOV (eap) -// -#include "UnitTetraIntersectionBary.hxx" - -#include "VectorUtils.hxx" -#include "InterpolationUtils.hxx" -#include "VolSurfFormulae.hxx" - -#define NB_TETRA_SIDES 4 -#define NB_TETRA_NODES 4 - -//#define DMP_UNITTETRAINTERSECTIONBARY - - -namespace INTERP_KERNEL -{ - enum { _X=0, _Y, _Z }; - - inline bool samePoint( const double* p1, const double* p2 ) - { - return ( epsilonEqual( p1[0], p2[0]) && - epsilonEqual( p1[1], p2[1]) && - epsilonEqual( p1[2], p2[2])); - } - - //================================================================================ - /*! - * \brief Creates a ready-to-use tool - */ - //================================================================================ - - UnitTetraIntersectionBary::UnitTetraIntersectionBary(bool isTetraInversed) - :TransformedTriangle(),_int_volume(0),_isTetraInversed( isTetraInversed ) - { - //init(); - } - //================================================================================ - /*! - * \brief Initializes fields - */ - //================================================================================ - - void UnitTetraIntersectionBary::init(bool isTetraInversed) - { - _int_volume = 0; - _isTetraInversed = isTetraInversed; - _faces.clear(); - _polyNormals.clear(); - } - - //================================================================================ - /*! - * \brief Stores a part of triangle common with the unit tetrahedron - * \param triangle - triangle side of other cell - */ - //================================================================================ - - void UnitTetraIntersectionBary::addSide(const TransformedTriangle& triangle) - { - _int_volume += triangle.getVolume(); - - double triNormal[3], polyNormal[3]; - crossprod<3>( triangle.getCorner(P),triangle.getCorner(Q),triangle.getCorner(R), triNormal); - - const std::vector * pPolygonA = &triangle.getPolygonA(); - if ( pPolygonA->size() < 3 ) - { - if ( !epsilonEqual( triNormal[_Z], 0 )) - return; // not vertical triangle does not intersect the unit tetra - - // Vertical triangle. Use inherited methods of TransformedTriangle to - // calculate intesection polygon - *((TransformedTriangle*)this) = triangle; // copy triangle fields - _polygonA.clear(); - _polygonB.clear(); - calculateIntersectionPolygons(); - if (this->_polygonA.size() < 3) - return; - calculatePolygonBarycenter(A, _barycenterA); - sortIntersectionPolygon(A, _barycenterA); - pPolygonA = & _polygonA; - } - - // check if polygon orientation is same as the one of triangle - std::vector::const_iterator p = pPolygonA->begin(), pEnd = pPolygonA->end(); -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout.precision(18); - std::cout << "**** int polygon() " << std::endl; - while ( p != pEnd ) - { - double* pp = *p++; - std::cout << pEnd - p << ": ( " << pp[0] << ", " << pp[1] << ", " << pp[2] << " )" << std::endl; - } - p = pPolygonA->begin(); -#endif - double* p1 = *p++; - double* p2 = *p; - while ( samePoint( p1, p2 ) && ++p != pEnd ) - p2 = *p; - if ( p == pEnd ) - { -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "All points equal" << std::endl; -#endif - clearPolygons(); - return; - } - double* p3 = *p; - while (( samePoint( p2, p3 ) || samePoint( p1, p3 )) && ++p != pEnd ) - p3 = *p; - if ( p == pEnd ) - { -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "Only two points differ" << std::endl; -#endif - clearPolygons(); - return ; - } - crossprod<3>( p1, p2, p3, polyNormal ); - bool reverse = ( dotprod<3>( triNormal, polyNormal ) < 0.0 ); - if (_isTetraInversed) reverse = !reverse; - - // store polygon - _faces.push_back( std::vector< double* > () ); - std::vector< double* >& faceCorner = _faces.back(); - faceCorner.resize( pPolygonA->size()/* + 1*/ ); - - int i = 0; - if ( reverse ) - { - std::vector::const_reverse_iterator polyF = pPolygonA->rbegin(), polyEnd; - for ( polyEnd = pPolygonA->rend(); polyF != polyEnd; ++i, ++polyF ) - if ( i==0 || !samePoint( *polyF, faceCorner[i-1] )) - copyVector3( *polyF, faceCorner[i] = new double[3] ); - else - --i; - polyNormal[0] *= -1.; - polyNormal[1] *= -1.; - polyNormal[2] *= -1.; - } - else - { - std::vector::const_iterator polyF = pPolygonA->begin(), polyEnd; - for ( polyEnd = pPolygonA->end(); polyF != polyEnd; ++i, ++polyF ) - if ( i==0 || !samePoint( *polyF, faceCorner[i-1] )) - copyVector3( *polyF, faceCorner[i] = new double[3] ); - else - --i; - } - if ( i < 3 ) - { - clearPolygons(); // free memory of _polygonA - _polygonA = faceCorner; - _faces.pop_back(); - } - else - { - if ( i < (int)pPolygonA->size() ) - faceCorner.resize( i ); - - if ( _polyNormals.empty() ) - _polyNormals.reserve(4); - _polyNormals.push_back( std::vector< double >( polyNormal, polyNormal+3 )); - } - -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "**** addSide() " << _faces.size() << std::endl; - for ( int i = 0; i < faceCorner.size(); ++i ) - { - double* p = faceCorner[i]; - std::cout << i << ": ( " << p[0] << ", " << p[1] << ", " << p[2] << " )" << std::endl; - } - std::cout << "NORM: ( " << _polyNormals.back()[0] << ", " << _polyNormals.back()[1] << ", " << _polyNormals.back()[2] << " )" << std::endl; -#endif - clearPolygons(); - } - - //================================================================================ - /*! - * \brief Computes and returns coordinates of barycentre - */ - //================================================================================ - - bool UnitTetraIntersectionBary::getBary(double* baryCenter) - { - baryCenter[0] = baryCenter[1] = baryCenter[2] = -1.0; - if ( addSideFaces() < NB_TETRA_SIDES ) - { - // tetra is not intersected - if ( fabs(_int_volume) > 1e-10 ) - { - // tetra is fully inside the other cell - baryCenter[0] = baryCenter[1] = baryCenter[2] = 0.25; - _int_volume = 0.16666666666666666; - return true; - } - return false; - } - // Algo: - // - pick up one point P among the summits of the polyhedron - // - for each face of the polyhedron which does not contain the point : - // - compute the barycenter of the volume obtained by forming the "pyramid" with - // the face as a base and point P as a summit - // - compute the volume of the "pyramid" - // - Add up all barycenter positions weighting them with the volumes. - - baryCenter[0] = baryCenter[1] = baryCenter[2] = 0.; - - std::list< std::vector< double* > >::iterator f = _faces.begin(), fEnd = _faces.end(); - double * P = f->at(0); - - for ( ++f; f != fEnd; ++f ) - { - std::vector< double* >& polygon = *f; - if ( polygon.empty() ) - continue; - - bool pBelongsToPoly = false; - std::vector::iterator v = polygon.begin(), vEnd = polygon.end(); - for ( ; !pBelongsToPoly && v != vEnd; ++v ) - pBelongsToPoly = samePoint( P, *v ); - if ( pBelongsToPoly ) - continue; - - // Compute the barycenter of the volume. Barycenter of pyramid is on line - // ( barycenter of polygon -> P ) with 1/4 of pyramid height from polygon. - - double bary[] = { 0, 0, 0 }; - - // base polygon bary - for ( v = polygon.begin(); v != vEnd ; ++v ) - { - double* p = *v; - bary[0] += p[0]; - bary[1] += p[1]; - bary[2] += p[2]; - } - bary[0] /= polygon.size(); - bary[1] /= polygon.size(); - bary[2] /= polygon.size(); - - // pyramid volume - double vol = 0; - for ( int i = 0; i < (int)polygon.size(); ++i ) - { - double* p1 = polygon[i]; - double* p2 = polygon[(i+1)%polygon.size()]; - vol += std::fabs( calculateVolumeForTetra( p1, p2, bary, P )); - } - - // put bary on the line ( barycenter of polygon -> P ) and multiply by volume - baryCenter[0] += ( bary[0] * 0.75 + P[0] * 0.25 ) * vol; - baryCenter[1] += ( bary[1] * 0.75 + P[1] * 0.25 ) * vol; - baryCenter[2] += ( bary[2] * 0.75 + P[2] * 0.25 ) * vol; - } - if ( _int_volume < 0. ) - _int_volume = -_int_volume; - baryCenter[0] /= _int_volume; - baryCenter[1] /= _int_volume; - baryCenter[2] /= _int_volume; - -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout.precision(5); - std::cout << "**** Barycenter " << baryCenter[0] <<", "<< baryCenter[1] <<", "<< baryCenter[2] - << "\t **** Volume " << _int_volume << std::endl; - std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; -#endif - return true; - } - - //================================================================================ - /*! - * \brief Add faces of the intersection polyhedron formed on faces of the - * unit tetrahedron by sides of already added faces - * \retval int - number of faces of intersection polyhedron - */ - //================================================================================ - - int UnitTetraIntersectionBary::addSideFaces() - { - int nbPolyhedraFaces = 0; - - if ( _faces.empty() ) - return nbPolyhedraFaces; - - // ------------------------------------------- - // Detect polygons laying on sides of a tetra - // ------------------------------------------- - - bool sideAdded[NB_TETRA_SIDES] = { false, false, false, false }; - int nbAddedSides = 0; - std::list< std::vector< double* > >::iterator f = _faces.begin(), fEnd = _faces.end(); - for ( ; f != fEnd; ++f ) - { - std::vector< double* >& polygon = *f; - double coordSum[3] = {0,0,0}; - for ( int i = 0; i < (int)polygon.size(); ++i ) - { - double* p = polygon[i]; - coordSum[0] += p[0]; - coordSum[1] += p[1]; - coordSum[2] += p[2]; - } - for ( int j = 0; j < 3 && !sideAdded[j]; ++j ) - { - if ( epsilonEqual( coordSum[j], 0.0 )) - sideAdded[j] = ++nbAddedSides != 0 ; - } - if ( !sideAdded[3] && - ( epsilonEqual( (coordSum[0]+coordSum[1]+coordSum[2]) / polygon.size(), 1. ))) - sideAdded[3] = ++nbAddedSides != 0 ; - } - if ( nbAddedSides == NB_TETRA_SIDES ) - return nbAddedSides; - - // --------------------------------------------------------------------------------- - // Add segments of already added polygons to future polygonal faces on sides of tetra - // --------------------------------------------------------------------------------- - - int nbIntersectPolygs = _faces.size(); - - std::vector< double* > * sideFaces[ 4 ]; // future polygons on sides of tetra - for ( int i = 0; i < NB_TETRA_SIDES; ++i ) - { - sideFaces[ i ]=0; - if ( !sideAdded[ i ] ) - { - _faces.push_back( std::vector< double* > () ); - sideFaces[ i ] = &_faces.back(); - } - } - f = _faces.begin(), fEnd = _faces.end(); - for ( int iF = 0; iF < nbIntersectPolygs; ++f, ++iF ) // loop on added intersection polygons - { - std::vector< double* >& polygon = *f; - for ( int i = 0; i < (int)polygon.size(); ++i ) - { - // segment ends - double* p1 = polygon[i]; - double* p2 = polygon[(i+1)%polygon.size()]; - bool p1OnSide, p2OnSide;//, onZeroSide = false; - for ( int j = 0; j < 3; ++j ) - { - if ( !sideFaces[ j ] ) - continue; - p1OnSide = epsilonEqual( p1[j], 0. ); - p2OnSide = epsilonEqual( p2[j], 0. ); - if ( p1OnSide && p2OnSide ) - { - // segment p1-p2 is on j-th orthogonal side of tetra - sideFaces[j]->push_back( new double[3] ); - copyVector3( p1, sideFaces[j]->back() ); - sideFaces[j]->push_back( new double[3] ); - copyVector3( p2, sideFaces[j]->back() ); - //break; - } - } - // check if the segment p1-p2 is on the inclined side - if ( sideFaces[3] && - epsilonEqual( p1[_X] + p1[_Y] + p1[_Z], 1.0 ) && - epsilonEqual( p2[_X] + p2[_Y] + p2[_Z], 1.0 )) - { - sideFaces[3]->push_back( new double[3] ); - copyVector3( p1, sideFaces[3]->back() ); - sideFaces[3]->push_back( new double[3] ); - copyVector3( p2, sideFaces[3]->back() ); - } - } - } -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "**** after Add segments to sides " << std::endl; - for ( int i = 0; i < NB_TETRA_SIDES; ++i ) - { - std::cout << "\t Side " << i << std::endl; - if ( !sideFaces[i] ) - { - std::cout << "\t cut by triagle" << std::endl; - } - else - { - std::vector< double* >& sideFace = *sideFaces[i]; - for ( int i = 0; i < sideFace.size(); ++i ) - { - double* p = sideFace[i]; - std::cout << "\t" << i << ": ( " << p[0] << ", " << p[1] << ", " << p[2] << " )" << std::endl; - } - } - } -#endif - - // --------------------------------------------------------------------------- - // Make closed polygons on tetra sides by adding not cut off corners of tetra - // --------------------------------------------------------------------------- - - double origin[3] = { 0,0,0 }; - - // find corners of tetra cut off by triangles of other tetra - // --------------------------------------------------------- - - // corners are coded like this: index = 1*X + 2*Y + 3*Z - // (0,0,0) -> index == 0; (0,0,1) -> index == 3 - int cutOffCorners[NB_TETRA_NODES] = { false, false, false, false }; - int passedCorners[NB_TETRA_NODES] = { false, false, false, false }; - - // find cutOffCorners by normals of intersection polygons - int nbCutOffCorners = 0; - for ( int ic = 0; ic < NB_TETRA_NODES; ++ic ) - { - f = _faces.begin(), fEnd = _faces.end(); - for ( int iF = 0; iF < nbIntersectPolygs; ++f, ++iF ) // loop on added intersection polygons - { - std::vector< double* >& polygon = *f; - - double corner2Poly[3] = { polygon[0][0], polygon[0][1], polygon[0][2] }; - if ( ic ) corner2Poly[ ic-1 ] -= 1.0; - - // _polyNormals are outside of a tetrahedron - double dot = dotprod<3>( corner2Poly, &_polyNormals[iF][0] ); - if ( dot < -DEFAULT_ABS_TOL*DEFAULT_ABS_TOL ) - { -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "side " << iF+1 << ": cut " << ic << std::endl; -#endif - cutOffCorners[ ic ] = true; - nbCutOffCorners++; - break; - } - } - } - - for ( int i = 0; i < 3; ++i ) // loop on orthogonal faces of the unit tetra - { - if ( !sideFaces[i] ) continue; - std::vector< double* >& sideFace = *sideFaces[i]; - - int nbPoints = sideFace.size(); - if ( nbPoints == 0 ) - continue; // not intersected face at all - no cut off corners can be detected - - int ind1 = (i+1)%3, ind2 = (i+2)%3; // indices of coords on i-th tetra side - - int nbCutOnSide = 0; - bool isSegmentOnEdge; - for ( int ip = 0; ip < nbPoints; ++ip ) - { - int isSegmentEnd = ( ip % 2 ); - - double* p = sideFace[ ip ]; - double* p2 = isSegmentEnd ? 0 : sideFace[ip+1]; - - if ( !isSegmentEnd ) - isSegmentOnEdge = false; // initialize - - int cutOffIndex = -1, passThIndex = -1;// no cut off neither pass through - int pCut[] = { 0,0,0 }, pPass[] = { 0,0,0 }; - - if ( epsilonEqual( p[ind1], 0.)) - { - // point is on orthogonal edge - if ( !isSegmentEnd && epsilonEqual( p2[ind1], 0. )) - isSegmentOnEdge = true; - - if ( !isSegmentOnEdge ) - { // segment ends are on different edges - pCut[ind2] = isSegmentEnd; // believe that cutting triangles are well oriented - cutOffIndex = pCut[0] + 2*pCut[1] + 3*pCut[2]; - } - if ( epsilonEqual( p[ind2], 0.) || epsilonEqual( p[ind2], 1.)) - { - pPass[ind2] = ( p[ind2] < 0.5 ) ? 0 : 1; - passThIndex = pPass[0] + 2*pPass[1] + 3*pPass[2]; - } - } - else if ( epsilonEqual( p[ind2], 0.)) - { - // point is on orthogonal edge - if ( !isSegmentEnd && epsilonEqual( p2[ind2], 0. )) - isSegmentOnEdge = true; - if ( !isSegmentEnd ) - {// segment ends are on different edges - pCut[ind1] = 1-isSegmentEnd; - cutOffIndex = pCut[0] + 2*pCut[1] + 3*pCut[2]; - } - if ( epsilonEqual( p[ind1], 0.) || epsilonEqual( p[ind1], 1.)) - { - pPass[ind1] = ( p[ind1] < 0.5 ) ? 0 : 1; - passThIndex = pPass[0] + 2*pPass[1] + 3*pPass[2]; - } - } - else if ( epsilonEqual(p[ind1] + p[ind2], 1.0 )) - { - // point is on inclined edge - if ( !isSegmentEnd && epsilonEqual(p2[ind1] + p2[ind2], 1.0 )) - isSegmentOnEdge = true; - if ( !isSegmentOnEdge ) - { //segment ends are on different edges - pCut[ind1] = isSegmentEnd; - pCut[ind2] = 1-isSegmentEnd; - cutOffIndex = pCut[0] + 2*pCut[1] + 3*pCut[2]; - } - } - else - { - continue; - } - // remember cut off and passed through points - if ( passThIndex >= 0 ) - { - passedCorners[ passThIndex ] = true; - if ( cutOffCorners[ passThIndex ] ) - { - nbCutOffCorners--; - cutOffCorners[ passThIndex ] = false; -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "PASS THROUGH " << passThIndex << std::endl; -#endif - } - } - if ( cutOffIndex >= 0 ) - { - nbCutOnSide++; - if ( !passedCorners[ cutOffIndex ] && !cutOffCorners[ cutOffIndex ] ) - { - nbCutOffCorners++; - cutOffCorners[ cutOffIndex ] = true; - } - } - } // loop on points on a unit tetra side - - if ( nbCutOnSide == 0 && nbPoints <= 2 ) - continue; // one segment laying on edge at most - - if ( nbCutOffCorners == NB_TETRA_NODES ) - break; // all tetra corners are cut off - - if ( /*nbCutOnSide <= 2 &&*/ nbPoints >= 6 ) - { - // at least 3 segments - all corners of a side are cut off - for (int cutIndex = 0; cutIndex < NB_TETRA_NODES; ++cutIndex ) - if ( cutIndex != i+1 && !passedCorners[ cutIndex ] && !cutOffCorners[ cutIndex ]) - cutOffCorners[ cutIndex ] = ++nbCutOffCorners != 0 ; - } - - } - // loop on orthogonal faces of tetra - - // check if all corners are cut off on the inclined tetra side - if ( sideFaces[ XYZ ] && sideFaces[ XYZ ]->size() >= 6 ) - { - for (int cutIndex = 1; cutIndex < NB_TETRA_NODES; ++cutIndex ) - if ( !passedCorners[ cutIndex ] && !cutOffCorners[ cutIndex ]) - cutOffCorners[ cutIndex ] = ++nbCutOffCorners != 0 ; - } - - // Add to faces on tetra sides the corners not cut off by segments of intersection polygons - // ---------------------------------------------------------------------------------- - if ( nbCutOffCorners > 0 ) - { - for ( int i = 0; i < NB_TETRA_SIDES; ++i ) - { - if ( !sideFaces[ i ] ) continue; - std::vector< double* >& sideFace = *sideFaces[i]; - - int excludeCorner = (i + 1) % NB_TETRA_NODES; - for ( int ic = 0; ic < NB_TETRA_NODES; ++ic ) - { - if ( !cutOffCorners[ ic ] && ic != excludeCorner ) - { - sideFace.push_back( new double[3] ); - copyVector3( origin, sideFace.back() ); - if ( ic ) - sideFace.back()[ ic-1 ] = 1.0; - } - } - } - } - -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "**** after Add corners to sides " << std::endl; - for ( int i = 0; i < NB_TETRA_SIDES; ++i ) - { - std::cout << "\t Side " << i << std::endl; - if ( !sideFaces[i] ) { - std::cout << "\t cut by triagle" << std::endl; - } - else - { - std::vector< double* >& sideFace = *sideFaces[i]; - for ( int i = 0; i < sideFace.size(); ++i ) - { - double* p = sideFace[i]; - std::cout << "\t" << i << ": ( " << p[0] << ", " << p[1] << ", " << p[2] << " )" << std::endl; - } - } - } - std::cout << "Cut off corners: "; - if ( nbCutOffCorners == 0 ) - std::cout << "NO"; - else - for ( int ic = 0; ic < NB_TETRA_NODES; ++ic ) - std::cout << cutOffCorners[ ic ]; - std::cout << std::endl; -#endif - // ------------------------------------------------------------------------ - // Sort corners of filled up faces on tetra sides and exclude equal points - // ------------------------------------------------------------------------ - - int iF = 0; - for ( f = _faces.begin(); f != fEnd; ++f, ++iF ) - { - std::vector< double* >& face = *f; - if ( face.size() >= 3 ) - { - clearPolygons(); // free memory of _polygonA - _polygonA = face; - face.clear(); - face.reserve( _polygonA.size() ); - if ( iF >= nbIntersectPolygs ) - { // sort points of side faces - calculatePolygonBarycenter( A, _barycenterA ); - setTriangleOnSide( iF - nbIntersectPolygs ); - sortIntersectionPolygon( A, _barycenterA ); - } - // exclude equal points - std::vector< double* >::iterator v = _polygonA.begin(), vEnd = _polygonA.end(); - face.push_back( *v ); - *v = 0; - for ( ++v; v != vEnd; ++v ) - { - double* pPrev = face.back(); - double* p = *v; - if ( !samePoint( p, pPrev )) - { - face.push_back( p ); - *v = 0; - } - } - } - if ( face.size() < 3 ) - { // size could decrease - clearPolygons(); // free memory of _polygonA - _polygonA = face; - face.clear(); - } - else - { - nbPolyhedraFaces++; - } - } -#ifdef DMP_UNITTETRAINTERSECTIONBARY - std::cout << "**** after HEALING all faces " << std::endl; - for (iF=0, f = _faces.begin(); f != fEnd; ++f, ++iF ) - { - std::cout << "\t Side " << iF << std::endl; - std::vector< double* >& sideFace = *f; - for ( int i = 0; i < sideFace.size(); ++i ) - { - double* p = sideFace[i]; - std::cout << "\t" << i << ": ( " << p[0] << ", " << p[1] << ", " << p[2] << " )" << std::endl; - } - } -#endif - return nbPolyhedraFaces; - } - - //================================================================================ - /*! - * \brief set corners of inherited TransformedTriangle as corners of i-th side of - * the Unit tetra. It is necessary to sort points of faces on sides of the unit - * tetrahedron using sortIntersectionPolygon(A) - */ - //================================================================================ - - void UnitTetraIntersectionBary::setTriangleOnSide(int iSide) - { - if ( iSide >= 3 ) - iSide = 0; - for(int i = 0 ; i < 3 ; ++i) - { - _coords[5*i] = _coords[5*i + 1] = _coords[5*i + 2] = 0.; - if ( i != iSide ) - _coords[5*i + i] = 1.; - } - } - - //================================================================================ - /*! - * \brief Free memory of polygons - */ - //================================================================================ - - void UnitTetraIntersectionBary::clearPolygons(bool andFaces) - { - for(std::vector::iterator it = _polygonA.begin() ; it != _polygonA.end() ; ++it) - { delete[] *it; - *it = 0; - } - for(std::vector::iterator it = _polygonB.begin() ; it != _polygonB.end() ; ++it) - { - delete[] *it; - *it = 0; - } - - _polygonA.clear(); - _polygonB.clear(); - - if ( andFaces ) - { - std::list< std::vector< double* > >::iterator f = this->_faces.begin(), fEnd = this->_faces.end(); - for ( ; f != fEnd; ++f ) - { - std::vector< double* >& polygon = *f; - for(std::vector::iterator it = polygon.begin() ; it != polygon.end() ; ++it) - { - delete[] *it; - *it = 0; - } - } - this->_faces.clear(); - } - } - - //================================================================================ - /*! - * \brief Destructor clears coordinates of faces - */ - //================================================================================ - - UnitTetraIntersectionBary::~UnitTetraIntersectionBary() - { - clearPolygons(/*andFaces=*/true ); - } - -} diff --git a/src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx b/src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx deleted file mode 100644 index a6dc36109..000000000 --- a/src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2007-2010 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 : UnitTetraIntersectionBary.hxx -// Created : Tue Dec 9 16:06:33 2008 -// Author : Edward AGAPOV (eap) -// -#ifndef __UNITTETRAINTERSECTIONBARY_HXX__ -#define __UNITTETRAINTERSECTIONBARY_HXX__ - -#include "TransformedTriangle.hxx" -#include "INTERPKERNELDefines.hxx" - -#include -#include - -namespace INTERP_KERNEL -{ - class UnitTetraIntersectionBary : protected TransformedTriangle - { - public: - INTERPKERNEL_EXPORT UnitTetraIntersectionBary(bool isTetraInversed=false); - - INTERPKERNEL_EXPORT void init(bool isTetraInversed=false); - /*! - * \brief Stores a part of triangle common with the unit tetrahedron - * \param triangle - triangle side of other cell, whose calculateIntersectionVolume() - * must have already been called - */ - INTERPKERNEL_EXPORT void addSide(const TransformedTriangle& triangle); - - /*! - * \brief Computes and return coordinates of barycentre - */ - INTERPKERNEL_EXPORT bool getBary(double* baryCenter); - - /*! - * \brief Returns volume of intersection - * \retval double - - */ - INTERPKERNEL_EXPORT inline double getVolume() const { return _int_volume; } - - INTERPKERNEL_EXPORT virtual ~UnitTetraIntersectionBary(); - - private: - - int addSideFaces(); - - void setTriangleOnSide(int i); - - void clearPolygons(bool andFaces=false); - - /// volume of intersection - double _int_volume; - - /// faces of intersection polyhedron - std::list< std::vector< double* > > _faces; - std::vector< std::vector< double > > _polyNormals; - - bool _isTetraInversed; - }; - -} - -#endif diff --git a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx b/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx deleted file mode 100644 index b0beaf8c4..000000000 --- a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2007-2010 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 __VTKNORMALIZEDUNSTRUCTUREDMESH_HXX__ -#define __VTKNORMALIZEDUNSTRUCTUREDMESH_HXX__ - -#include "NormalizedUnstructuredMesh.hxx" - -#include "vtkType.h" - -class vtkUnstructuredGrid; - -template -class INTERPKERNEL_EXPORT VTKNormalizedUnstructuredMesh : public INTERP_KERNEL::GenericMesh -{ -public: - static const int MY_SPACEDIM=3; - static const int MY_MESHDIM=MESHDIM; - typedef vtkIdType MyConnType; - static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; -public: - VTKNormalizedUnstructuredMesh(vtkUnstructuredGrid *mesh); - ~VTKNormalizedUnstructuredMesh(); - void getBoundingBox(double *boundingBox) const; - NormalizedCellType getTypeOfElement(vtkIdType eltId) const; - unsigned long getNumberOfElements() const; - unsigned long getNumberOfNodes() const; - const vtkIdType *getConnectivityPtr() const; - const double *getCoordinatesPtr() const; - const vtkIdType *getConnectivityIndexPtr() const; - void releaseTempArrays(); -protected: - void putinMEDFormat() const; -protected: - vtkUnstructuredGrid *_mesh_in_vtk_mode; - mutable vtkIdType *_tmp_index_array; -}; - -#endif diff --git a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx b/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx deleted file mode 100644 index 2ff760e9b..000000000 --- a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2007-2010 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 __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__ -#define __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__ - -#include "VTKNormalizedUnstructuredMesh.hxx" - -#include "vtkUnstructuredGrid.h" -#include "vtkCellArray.h" -#include "vtkPoints.h" - -template -VTKNormalizedUnstructuredMesh::VTKNormalizedUnstructuredMesh(vtkUnstructuredGrid *mesh):_mesh_in_vtk_mode(mesh), - _tmp_index_array(0) -{ -} - -template -VTKNormalizedUnstructuredMesh::~VTKNormalizedUnstructuredMesh() -{ - _mesh_in_vtk_mode->Delete(); - releaseTempArrays(); -} - -template -void VTKNormalizedUnstructuredMesh::getBoundingBox(double *boundingBox) const -{ - double tmp[6]; - _mesh_in_vtk_mode->GetBounds(tmp); - for(unsigned i=0;i<3;i++) - { - boundingBox[i]=tmp[2*i]; - boundingBox[3+i]=tmp[2*i+1]; - } -} - -template -NormalizedCellType VTKNormalizedUnstructuredMesh::getTypeOfElement(vtkIdType eltId) const -{ - int cellType=_mesh_in_vtk_mode->GetCellType(eltId); - int convTab[30]={0,0,0,0,0,(int)NORM_TRI3,0,(int)NORM_POLYGON,0,(int)NORM_QUAD4,(int)NORM_TETRA4,0,(int)NORM_HEXA8 - 0,(int)NORM_PYRA5,0,0,0,(int)NORM_TRI6,(int)NORM_QUAD8,}; -} - -template -unsigned long VTKNormalizedUnstructuredMesh::getNumberOfElements() const -{ - return _mesh_in_vtk_mode->GetNumberOfCells(); -} - -template -unsigned long VTKNormalizedUnstructuredMesh::getNumberOfNodes() const -{ - return _mesh_in_vtk_mode->GetNumberOfPoints(); -} - -template -const vtkIdType *VTKNormalizedUnstructuredMesh::getConnectivityPtr() const -{ - vtkIdType *ret=_mesh_in_vtk_mode->GetCells()->GetPointer(); - if(_tmp_index_array) - return ret; - else - { - putinMEDFormat(); - return ret; - } -} - -template -const double *VTKNormalizedUnstructuredMesh::getCoordinatesPtr() const -{ - return (const double *)_mesh_in_vtk_mode->GetPoints()->GetVoidPointer(0); -} - -template -const vtkIdType *VTKNormalizedUnstructuredMesh::getConnectivityIndexPtr() const -{ - if(_tmp_index_array) - return _tmp_index_array; - else - { - putinMEDFormat(); - return _tmp_index_array; - } -} - -template -void VTKNormalizedUnstructuredMesh::putinMEDFormat() const -{ - long nbOfElem=getNumberOfElements(); - _tmp_index_array=new vtkIdType[nbOfElem+1]; - _tmp_index_array[0]=0; - vtkIdType *coarseConn=_mesh_in_vtk_mode->GetCells()->GetPointer(); - long ptInCC=0; - vtkIdType *finalConn=coarseConn; - for(long i=0;i -void VTKNormalizedUnstructuredMesh::releaseTempArrays() -{ - delete [] _tmp_index_array; - _tmp_index_array=0; -} - -#endif diff --git a/src/INTERP_KERNEL/VectorUtils.hxx b/src/INTERP_KERNEL/VectorUtils.hxx deleted file mode 100644 index 2deaa614d..000000000 --- a/src/INTERP_KERNEL/VectorUtils.hxx +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (C) 2007-2010 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 __VECTORUTILS_HXX__ -#define __VECTORUTILS_HXX__ - -#include -#include -#include -#include -#include - -namespace INTERP_KERNEL -{ - /// Precision used for tests of 3D part of INTERP_KERNEL - const double VOL_PREC = 1.0e-6; - - /// Default relative tolerance in epsilonEqualRelative - const double DEFAULT_REL_TOL = 1.0e-6; - - /// Default absolute tolerance in epsilonEqual and epsilonEqualRelative - const double DEFAULT_ABS_TOL = 5.0e-12; - - /** - * @param a first point. Should point on a array of size at least equal to SPACEDIM. - * @param b second point. Should point on a array of size at least equal to SPACEDIM. - */ - template - inline double getDistanceBtw2Pts(const double *a, const double *b) - { - double ret2=0.; - for(int i=0;i - -namespace INTERP_KERNEL -{ - inline void calculateBarycenterDyn(const double **pts, int nbPts, - int dim, double *bary); - - inline double calculateAreaForPolyg(const double **coords, int nbOfPtsInPolygs, - int spaceDim); - - - inline double calculateLgthForSeg2(const double *p1, const double *p2, int spaceDim) - { - if(spaceDim==1) - return *p2-*p1; - else - { - double ret=0; - for(int i=0;i - inline double calculateVolumeForPolyh2(const ConnType *connec, int lgth, const double *coords) - { - int nbOfFaces=std::count(connec,connec+lgth,-1)+1; - double volume=0.; - const int *work=connec; - for(int iFace=0;iFace::coo2C(work[ptId]); - const double *pti1=coords+3*OTT::coo2C(work[(ptId+1)%nbOfNodesOfCurFace]); - areaVector[0]+=pti[1]*pti1[2]-pti[2]*pti1[1]; - areaVector[1]+=pti[2]*pti1[0]-pti[0]*pti1[2]; - areaVector[2]+=pti[0]*pti1[1]-pti[1]*pti1[0]; - } - const double *pt=coords+3*work[0]; - volume+=pt[0]*areaVector[0]+pt[1]*areaVector[1]+pt[2]*areaVector[2]; - work=work2+1; - } - return volume/6.; - } - - /*! - * This method returns the area oriented vector of a polygon. This method is useful for normal computation without - * any troubles if several edges are colinears. - * @param res must be of size at least 3 to store the result. - */ - template - inline void areaVectorOfPolygon(const ConnType *connec, int lgth, const double *coords, double *res) - { - res[0]=0.; res[1]=0.; res[2]=0.; - for(int ptId=0;ptId::coo2C(connec[ptId]); - const double *pti1=coords+3*OTT::coo2C(connec[(ptId+1)%lgth]); - res[0]+=pti[1]*pti1[2]-pti[2]*pti1[1]; - res[1]+=pti[2]*pti1[0]-pti[0]*pti1[2]; - res[2]+=pti[0]*pti1[1]-pti[1]*pti1[0]; - } - } - - inline double integrationOverA3DLine(double u1, double v1, double u2, double v2, double A, double B, double C) - { - return (u1-u2)*(6.*C*C*(v1+v2)+B*B*(v1*v1*v1+v1*v1*v2+v1*v2*v2+v2*v2*v2)+A*A*(2.*u1*u2*(v1+v2)+u1*u1*(3.*v1+v2)+u2*u2*(v1+3.*v2))+ - 4.*C*(A*(2*u1*v1+u2*v1+u1*v2+2.*u2*v2)+B*(v1*v1+v1*v2+v2*v2))+A*B*(u1*(3.*v1*v1+2.*v1*v2+v2*v2)+u2*(v1*v1+2.*v1*v2+3.*v2*v2)))/24.; - } - - template - inline void barycenterOfPolyhedron(const ConnType *connec, int lgth, const double *coords, double *res) - { - int nbOfFaces=std::count(connec,connec+lgth,-1)+1; - res[0]=0.; res[1]=0.; res[2]=0.; - const int *work=connec; - for(int i=0;i(work,nbOfNodesOfCurFace,coords,normal); - double normOfNormal=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); - normal[0]/=normOfNormal; normal[1]/=normOfNormal; normal[2]/=normOfNormal; - double u[2]={normal[1],-normal[0]}; - double s=sqrt(u[0]*u[0]+u[1]*u[1]); - double c=normal[2]; - if(fabs(s)>1e-12) - { - u[0]/=std::abs(s); u[1]/=std::abs(s); - } - else - { u[0]=1.; u[1]=0.; } - //C : high in plane of polyhedron face : always constant - double w=normal[0]*coords[3*OTT::coo2C(work[0])]+ - normal[1]*coords[3*OTT::coo2C(work[0])+1]+ - normal[2]*coords[3*OTT::coo2C(work[0])+2]; - // A,B,D,F,G,H,L,M,N coeffs of rotation matrix defined by (u,c,s) - double A=u[0]*u[0]*(1-c)+c; - double B=u[0]*u[1]*(1-c); - double D=u[1]*s; - double F=B; - double G=u[1]*u[1]*(1-c)+c; - double H=-u[0]*s; - double L=-u[1]*s; - double M=u[0]*s; - double N=c; - double CX=-w*D; - double CY=-w*H; - double CZ=-w*N; - for(int j=0;j::coo2C(work[j]); - const double *p2=coords+3*OTT::coo2C(work[(j+1)%nbOfNodesOfCurFace]); - double u1=A*p1[0]+B*p1[1]+D*p1[2]; - double u2=A*p2[0]+B*p2[1]+D*p2[2]; - double v1=F*p1[0]+G*p1[1]+H*p1[2]; - double v2=F*p2[0]+G*p2[1]+H*p2[2]; - // - double gx=integrationOverA3DLine(u1,v1,u2,v2,A,B,CX); - double gy=integrationOverA3DLine(u1,v1,u2,v2,F,G,CY); - double gz=integrationOverA3DLine(u1,v1,u2,v2,L,M,CZ); - res[0]+=gx*normal[0]; - res[1]+=gy*normal[1]; - res[2]+=gz*normal[2]; - } - work=work2+1; - } - double vol=calculateVolumeForPolyh2(connec,lgth,coords); - res[0]/=vol; res[1]/=vol; res[2]/=vol; - } - - // ============================================================================================================================================ - // Calculate Volume for NON Generic Polyedron. Only polydrons with bary included in pts is supported by this method. Result is always positive. - // ============================================================================================================================================ - inline double calculateVolumeForPolyhAbs(const double ***pts, - const int *nbOfNodesPerFaces, - int nbOfFaces, - const double *bary) - { - double volume=0.; - - for ( int i=0; i - inline double addComponentsOfVec(const double **pts, int rk) - { - return pts[N-1][rk]+addComponentsOfVec(pts,rk); - } - - template<> - inline double addComponentsOfVec<1>(const double **pts, int rk) - { - return pts[0][rk]; - } - - template - inline void calculateBarycenter(const double **pts, double *bary) - { - bary[DIM-1]=addComponentsOfVec(pts,DIM-1)/N; - calculateBarycenter(pts,bary); - } - - template<> - inline void calculateBarycenter<2,0>(const double **pts, double *bary) - { - } - - template<> - inline void calculateBarycenter<3,0>(const double **pts, double *bary) - { - } - - template<> - inline void calculateBarycenter<4,0>(const double **pts, double *bary) - { - } - - template<> - inline void calculateBarycenter<5,0>(const double **pts, double *bary) - { - } - - template<> - inline void calculateBarycenter<6,0>(const double **pts, double *bary) - { - } - - template<> - inline void calculateBarycenter<7,0>(const double **pts, double *bary) - { - } - - template<> - inline void calculateBarycenter<8,0>(const double **pts, double *bary) - { - } - - inline void calculateBarycenterDyn(const double **pts, int nbPts, - int dim, double *bary) - { - for(int i=0;i - inline void calculateBarycenterDyn2(const double *pts, int nbPts, double *bary) - { - for(int i=0;i - inline void computePolygonBarycenter2D(const ConnType *connec, int lgth, const double *coords, double *res) - { - double area=0.; - res[0]=0.; res[1]=0.; - for(int i=0;i::coo2C(connec[i])]*coords[2*OTT::coo2C(connec[(i+1)%lgth])+1]- - coords[2*OTT::coo2C(connec[i])+1]*coords[2*OTT::coo2C(connec[(i+1)%lgth])]; - area+=cp; - res[0]+=cp*(coords[2*OTT::coo2C(connec[i])]+coords[2*OTT::coo2C(connec[(i+1)%lgth])]); - res[1]+=cp*(coords[2*OTT::coo2C(connec[i])+1]+coords[2*OTT::coo2C(connec[(i+1)%lgth])+1]); - } - res[0]/=3.*area; - res[1]/=3.*area; - } - - template - inline void computePolygonBarycenter3D(const ConnType *connec, int lgth, const double *coords, double *res) - { - double area[3]; - areaVectorOfPolygon(connec,lgth,coords,area); - double norm=sqrt(area[0]*area[0]+area[1]*area[1]+area[2]*area[2]); - area[0]/=norm; area[1]/=norm; area[2]/=norm; - res[0]=0.; res[1]=0.; res[2]=0.; - for(int i=1;i::coo2C(connec[0])]+ - coords[3*OTT::coo2C(connec[i])]+ - coords[3*OTT::coo2C(connec[i+1])])/3.; - v[1]=(coords[3*OTT::coo2C(connec[0])+1]+ - coords[3*OTT::coo2C(connec[i])+1]+ - coords[3*OTT::coo2C(connec[i+1])+1])/3.; - v[2]=(coords[3*OTT::coo2C(connec[0])+2]+ - coords[3*OTT::coo2C(connec[i])+2]+ - coords[3*OTT::coo2C(connec[i+1])+2])/3.; - ConnType tmpConn[3]={connec[0],connec[i],connec[i+1]}; - areaVectorOfPolygon(tmpConn,3,coords,tmpArea); - double norm2=sqrt(tmpArea[0]*tmpArea[0]+tmpArea[1]*tmpArea[1]+tmpArea[2]*tmpArea[2]); - if(norm2>1e-12) - { - tmpArea[0]/=norm2; tmpArea[1]/=norm2; tmpArea[2]/=norm2; - double signOfArea=area[0]*tmpArea[0]+area[1]*tmpArea[1]+area[2]*tmpArea[2]; - res[0]+=signOfArea*norm2*v[0]/norm; res[1]+=signOfArea*norm2*v[1]/norm; res[2]+=signOfArea*norm2*v[2]/norm; - } - } - } -} - -#endif diff --git a/src/INTERP_KERNEL/VolSurfUser.hxx b/src/INTERP_KERNEL/VolSurfUser.hxx deleted file mode 100644 index 99083c319..000000000 --- a/src/INTERP_KERNEL/VolSurfUser.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2010 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 __VOLSURFUSER_HXX__ -#define __VOLSURFUSER_HXX__ - -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - template - double computeVolSurfOfCell(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords); - - template - double computeVolSurfOfCell2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim); - - template - void computeBarycenter(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, double *res); - - template - void computeBarycenter2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim, double *res); -} - -#endif diff --git a/src/INTERP_KERNEL/VolSurfUser.txx b/src/INTERP_KERNEL/VolSurfUser.txx deleted file mode 100644 index 5a0109a43..000000000 --- a/src/INTERP_KERNEL/VolSurfUser.txx +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright (C) 2007-2010 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 __VOLSURFUSER_TXX__ -#define __VOLSURFUSER_TXX__ - -#include "VolSurfUser.hxx" -#include "VolSurfFormulae.hxx" -#include "InterpolationUtils.hxx" - -#include - -namespace INTERP_KERNEL -{ - template - double computeVolSurfOfCell(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords) - { - switch(type) - { - case INTERP_KERNEL::NORM_SEG2 : - case INTERP_KERNEL::NORM_SEG3 : - { - int N1 = OTT::coo2C(connec[0]); - int N2 = OTT::coo2C(connec[1]); - return INTERP_KERNEL::calculateLgthForSeg2(coords+(SPACEDIM*N1),coords+(SPACEDIM*N2),SPACEDIM); - } - case INTERP_KERNEL::NORM_TRI3 : - case INTERP_KERNEL::NORM_TRI6 : - { - int N1 = OTT::coo2C(connec[0]); - int N2 = OTT::coo2C(connec[1]); - int N3 = OTT::coo2C(connec[2]); - - return INTERP_KERNEL::calculateAreaForTria(coords+(SPACEDIM*N1), - coords+(SPACEDIM*N2), - coords+(SPACEDIM*N3), - SPACEDIM); - } - break; - - case INTERP_KERNEL::NORM_QUAD4 : - case INTERP_KERNEL::NORM_QUAD8 : - { - int N1 = OTT::coo2C(connec[0]); - int N2 = OTT::coo2C(connec[1]); - int N3 = OTT::coo2C(connec[2]); - int N4 = OTT::coo2C(connec[3]); - - return INTERP_KERNEL::calculateAreaForQuad(coords+SPACEDIM*N1, - coords+SPACEDIM*N2, - coords+SPACEDIM*N3, - coords+SPACEDIM*N4, - SPACEDIM); - } - break; - - case INTERP_KERNEL::NORM_POLYGON : - { - const double **pts=new const double *[lgth]; - for(int inod=0;inod::coo2C(connec[inod]); - double val=INTERP_KERNEL::calculateAreaForPolyg(pts,lgth,SPACEDIM); - delete [] pts; - return val; - } - break; - case INTERP_KERNEL::NORM_TETRA4 : - case INTERP_KERNEL::NORM_TETRA10 : - { - int N1 = OTT::coo2C(connec[0]); - int N2 = OTT::coo2C(connec[1]); - int N3 = OTT::coo2C(connec[2]); - int N4 = OTT::coo2C(connec[3]); - - return INTERP_KERNEL::calculateVolumeForTetra(coords+SPACEDIM*N1, - coords+SPACEDIM*N2, - coords+SPACEDIM*N3, - coords+SPACEDIM*N4); - } - break; - - case INTERP_KERNEL::NORM_PYRA5 : - case INTERP_KERNEL::NORM_PYRA13 : - { - int N1 = OTT::coo2C(connec[0]); - int N2 = OTT::coo2C(connec[1]); - int N3 = OTT::coo2C(connec[2]); - int N4 = OTT::coo2C(connec[3]); - int N5 = OTT::coo2C(connec[4]); - - return INTERP_KERNEL::calculateVolumeForPyra(coords+SPACEDIM*N1, - coords+SPACEDIM*N2, - coords+SPACEDIM*N3, - coords+SPACEDIM*N4, - coords+SPACEDIM*N5); - } - break; - - case INTERP_KERNEL::NORM_PENTA6 : - case INTERP_KERNEL::NORM_PENTA15 : - { - int N1 = OTT::coo2C(connec[0]); - int N2 = OTT::coo2C(connec[1]); - int N3 = OTT::coo2C(connec[2]); - int N4 = OTT::coo2C(connec[3]); - int N5 = OTT::coo2C(connec[4]); - int N6 = OTT::coo2C(connec[5]); - - return INTERP_KERNEL::calculateVolumeForPenta(coords+SPACEDIM*N1, - coords+SPACEDIM*N2, - coords+SPACEDIM*N3, - coords+SPACEDIM*N4, - coords+SPACEDIM*N5, - coords+SPACEDIM*N6); - } - break; - - case INTERP_KERNEL::NORM_HEXA8 : - case INTERP_KERNEL::NORM_HEXA20 : - { - int N1 = OTT::coo2C(connec[0]); - int N2 = OTT::coo2C(connec[1]); - int N3 = OTT::coo2C(connec[2]); - int N4 = OTT::coo2C(connec[3]); - int N5 = OTT::coo2C(connec[4]); - int N6 = OTT::coo2C(connec[5]); - int N7 = OTT::coo2C(connec[6]); - int N8 = OTT::coo2C(connec[7]); - - return INTERP_KERNEL::calculateVolumeForHexa(coords+SPACEDIM*N1, - coords+SPACEDIM*N2, - coords+SPACEDIM*N3, - coords+SPACEDIM*N4, - coords+SPACEDIM*N5, - coords+SPACEDIM*N6, - coords+SPACEDIM*N7, - coords+SPACEDIM*N8); - } - break; - - case INTERP_KERNEL::NORM_POLYHED : - { - return calculateVolumeForPolyh2(connec,lgth,coords); - } - break; - default: - throw INTERP_KERNEL::Exception("Not recognized cell type to get Length/Area/Volume on it !"); - } - } - - template - double computeVolSurfOfCell2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim) - { - if(spaceDim==3) - return computeVolSurfOfCell(type,connec,lgth,coords); - if(spaceDim==2) - return computeVolSurfOfCell(type,connec,lgth,coords); - if(spaceDim==1) - return computeVolSurfOfCell(type,connec,lgth,coords); - throw INTERP_KERNEL::Exception("Invalid spaceDim specified : must be 1, 2 or 3"); - } - - template - void computeBarycenter(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, double *res) - { - switch(type) - { - case NORM_SEG3: - case NORM_SEG2: - { - std::copy(coords+SPACEDIM*OTT::coo2C(connec[0]), - coords+SPACEDIM*OTT::coo2C(connec[0]+1),res); - std::transform(res,res+SPACEDIM,coords+SPACEDIM*OTT::coo2C(connec[1]),res,std::plus()); - std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies(),0.5)); - break; - } - case NORM_TRI3: - case NORM_TRI6: - { - std::copy(coords+SPACEDIM*OTT::coo2C(connec[0]), - coords+SPACEDIM*OTT::coo2C(connec[0]+1),res); - std::transform(res,res+SPACEDIM,coords+SPACEDIM*OTT::coo2C(connec[1]),res,std::plus()); - std::transform(res,res+SPACEDIM,coords+SPACEDIM*OTT::coo2C(connec[2]),res,std::plus()); - std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies(),1./3.)); - break; - } - case NORM_QUAD4: - case NORM_POLYGON: - { - if(SPACEDIM==2) - computePolygonBarycenter2D(connec,lgth,coords,res); - else if(SPACEDIM==3) - computePolygonBarycenter3D(connec,lgth,coords,res); - else - throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !"); - break; - } - case NORM_QUAD8: - { - if(SPACEDIM==2) - computePolygonBarycenter2D(connec,lgth/2,coords,res); - else if(SPACEDIM==3) - computePolygonBarycenter3D(connec,lgth/2,coords,res); - else - throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !"); - break; - } - case NORM_TETRA4: - { - res[0]=coords[3*OTT::coo2C(connec[0])]; - res[1]=coords[3*OTT::coo2C(connec[0])+1]; - res[2]=coords[3*OTT::coo2C(connec[0])+2]; - res[0]+=coords[3*OTT::coo2C(connec[1])]; - res[1]+=coords[3*OTT::coo2C(connec[1])+1]; - res[2]+=coords[3*OTT::coo2C(connec[1])+2]; - res[0]+=coords[3*OTT::coo2C(connec[2])]; - res[1]+=coords[3*OTT::coo2C(connec[2])+1]; - res[2]+=coords[3*OTT::coo2C(connec[2])+2]; - res[0]+=coords[3*OTT::coo2C(connec[3])]; - res[1]+=coords[3*OTT::coo2C(connec[3])+1]; - res[2]+=coords[3*OTT::coo2C(connec[3])+2]; - res[0]/=4.; res[1]/=4.; res[2]/=4.; - break; - } - case NORM_PYRA5: - { - double tmp[3]; - computePolygonBarycenter3D(connec,lgth,coords,tmp); - res[0]=(coords[3*OTT::coo2C(connec[4])]+3.*tmp[0])/4.; - res[1]=(coords[3*OTT::coo2C(connec[4])+1]+3.*tmp[1])/4.; - res[1]=(coords[3*OTT::coo2C(connec[4])+2]+3.*tmp[2])/4.; - break; - } - case NORM_POLYHED: - { - barycenterOfPolyhedron(connec,lgth,coords,res); - break; - } - default: - throw INTERP_KERNEL::Exception("Not recognized cell type to get Barycenter on it !"); - } - } - - template - void computeBarycenter2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim, double *res) - { - if(spaceDim==3) - return computeBarycenter(type,connec,lgth,coords,res); - if(spaceDim==2) - return computeBarycenter(type,connec,lgth,coords,res); - if(spaceDim==1) - return computeBarycenter(type,connec,lgth,coords,res); - throw INTERP_KERNEL::Exception("Invalid spaceDim specified for compute barycenter : must be 1, 2 or 3"); - } -} - -#endif diff --git a/src/INTERP_KERNELTest/BBTreeTest.cxx b/src/INTERP_KERNELTest/BBTreeTest.cxx deleted file mode 100644 index 11a5a78d2..000000000 --- a/src/INTERP_KERNELTest/BBTreeTest.cxx +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright (C) 2007-2010 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 "BBTreeTest.hxx" -#include -#include -#include "DirectedBoundingBox.hxx" - -namespace INTERP_TEST -{ - - - void BBTreeTest::setUp() - { - } - - - void BBTreeTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check that - * the results are correct in three - * cases : - * a non matching search - * a standard case - * a bbox overlapping the bboxes of the tree - */ - void BBTreeTest::test_BBTree() { - //bbox tree creation - const int N=10; - double* bbox=new double[4*N*N]; - for (int i=0; i tree(bbox,0,0,N*N); - std::vector elems; - - //box outside the tree - double bbox1[4]={-2.0, -1.0, 0.0, 1.0}; - tree.getIntersectingElems(bbox1,elems); - CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); - elems.clear(); - - //box intersecting 4 tree elems - double bbox2[4]={2.5, 3.5, 0.5, 1.5}; - tree.getIntersectingElems(bbox2,elems); - CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); - elems.clear(); - - //box exactly superimposed to two tree elems - double bbox3[4]={5.0,6.0,7.0,9.0}; - tree.getIntersectingElems(bbox3,elems); - CPPUNIT_ASSERT_EQUAL(2,(int)elems.size()); - elems.clear(); - - double xx[2]={1.0,1.0}; - tree.getElementsAroundPoint(xx,elems); - CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); - - delete[] bbox; - } - - void BBTreeTest::test_DirectedBB_3D() - { - // a rectangle 1x2 extruded along vector (10,0,10) - const int nbP = 8, dim = 3; - double coords[nbP*dim] = - { - 0,0,0, 2,0,0, 2,1,0, 0,1,0, - 10,0,10, 12,0,10, 12,1,10, 10,1,10 - }; - INTERP_KERNEL::DirectedBoundingBox bb( coords, nbP, dim); - bb.enlarge( 1e-12 ); - - // corners of extrusion are IN - for ( int i = 0; i < nbP*dim; i+=dim ) - CPPUNIT_ASSERT( !bb.isOut( coords + i )); - - // points near corners of extrusion are OUT - double p[nbP*dim] = - { - 0,0,3, 6,0,3, 5,1,2, 0,1,2, - 8,0,9, 11,0,8, 11,0.5,8, 8,0.5,9 - }; - for ( int i = 0; i < nbP*dim; i+=dim ) - CPPUNIT_ASSERT( bb.isOut( p + i )); - - // the extrusions shifted by 3 in XOY plane are OUT - double shifted_X[nbP*dim] = - { - 3,0,0, 5,0,0, 5,1,0, 3,1,0, - 13,0,10, 15,0,10, 15,1,10, 13,1,10 - }; - double shifted_x[nbP*dim] = - { - -3,0,0, -1,0,0, -1,1,0, -3,1,0, - 7,0,10, 9,0,10, 9,1,10, 7,1,10 - }; - double shifted_Y[nbP*dim] = - { - 0,3,0, 2,3,0, 2,4,0, 0,4,0, - 10,3,10, 12,3,10, 12,4,10, 10,4,10 - }; - double shifted_y[nbP*dim] = - { - 0,-3,0, 2,-3,0, 2,-2,0, 0,-2,0, - 10,-3,10, 12,-3,10, 12,-2,10, 10,-2,10 - }; - INTERP_KERNEL::DirectedBoundingBox shiftedBB_x( shifted_x, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_X( shifted_X, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_y( shifted_y, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_Y( shifted_Y, nbP, dim); - - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_x )); - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_X )); - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_y )); - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_Y )); - - // intersecting box is IN - double inters_coords[nbP*dim] = - { - 0,0,0, 2,0,0, 2,1,0, 0,1,0, - 0,0,2, 2,0,2, 2,1,2, 0,1,2 - }; - INTERP_KERNEL::DirectedBoundingBox ibb( inters_coords, nbP, dim); - CPPUNIT_ASSERT( !bb.isDisjointWith( ibb )); - - // overlapping non-directed BB - double overlappingBB[2*dim] = - { - 5,6, 0, 1, -5,4 - }; - CPPUNIT_ASSERT( !bb.isDisjointWith( overlappingBB )); - - // non-overlapping non-directed BB - double nonoverlappingBB_1[2*dim] = - { - 5,6, 0,1, -5,2 - }; - CPPUNIT_ASSERT( bb.isDisjointWith( nonoverlappingBB_1 )); - double nonoverlappingBB_2[2*dim] = - { - 5,6, 0,1, 7,20 - }; - CPPUNIT_ASSERT( bb.isDisjointWith( nonoverlappingBB_2 )); - } - - void BBTreeTest::test_DirectedBB_2D() - { - // a segment of length 2 extruded along vector (10,10) - const int nbP = 4, dim = 2; - double coords[nbP*dim] = - { - 0,0, 2,0, - 10,10, 12,10, - }; - INTERP_KERNEL::DirectedBoundingBox bb( coords, nbP, dim); - bb.enlarge( 1e-12 ); - - // corners of extrusion are IN - for ( int i = 0; i < nbP*dim; i+=dim ) - CPPUNIT_ASSERT( !bb.isOut( coords + i )); - - // points near corners of extrusion are OUT - double p[nbP*dim] = - { - 1,2, 4,1, - 11,8, 8,9, - }; - for ( int i = 0; i < nbP*dim; i+=dim ) - CPPUNIT_ASSERT( bb.isOut( p + i )); - - // the extrusions shifted by 3 along OX are OUT - double shifted_X[nbP*dim] = - { - 3,0, 5,0, - 13,10, 15,10, - }; - double shifted_x[nbP*dim] = - { - -3,0, -1,0, - 7,10, 9,10, - }; - INTERP_KERNEL::DirectedBoundingBox shiftedBB_x( shifted_x, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_X( shifted_X, nbP, dim); - - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_x )); - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_X )); - - // intersecting box is IN - double inters_coords[nbP*dim] = - { - 0,0, 2,0, - 0,2, 2,2 - }; - INTERP_KERNEL::DirectedBoundingBox ibb( inters_coords, nbP, dim); - CPPUNIT_ASSERT( !bb.isDisjointWith( ibb )); - - // overlapping non-directed BB - double overlappingBB[2*dim] = - { - 5,6, -5,4 - }; - CPPUNIT_ASSERT( !bb.isDisjointWith( overlappingBB )); - - // non-overlapping non-directed BB - double nonoverlappingBB_1[2*dim] = - { - 5,6, -5,2 - }; - CPPUNIT_ASSERT( bb.isDisjointWith( nonoverlappingBB_1 )); - double nonoverlappingBB_2[2*dim] = - { - 5,6, 7,20 - }; - CPPUNIT_ASSERT( bb.isDisjointWith( nonoverlappingBB_2 )); - } - - void BBTreeTest::test_DirectedBB_1D() - { - const int nbP = 2, dim = 1; - double coords[nbP*dim] = - { - 0, 10 - }; - INTERP_KERNEL::DirectedBoundingBox bb( coords, nbP, dim); - bb.enlarge( 1e-12 ); - - // coords are IN - for ( int i = 0; i < nbP*dim; i+=dim ) - CPPUNIT_ASSERT( !bb.isOut( coords + i )); - - // points near ends are OUT - double p[nbP*dim] = - { - -0.0001, 10.1 - }; - for ( int i = 0; i < nbP*dim; i+=dim ) - CPPUNIT_ASSERT( bb.isOut( p + i )); - - // shifted boxes are OUT - double shifted_X[nbP*dim] = - { - 10.1, 11 - }; - double shifted_x[nbP*dim] = - { - -3.0, -0.001 - }; - INTERP_KERNEL::DirectedBoundingBox shiftedBB_x( shifted_x, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_X( shifted_X, nbP, dim); - - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_x )); - CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_X )); - - // intersecting box is IN - double inters_coords[nbP*dim] = - { - -2,2 - }; - INTERP_KERNEL::DirectedBoundingBox ibb( inters_coords, nbP, dim); - CPPUNIT_ASSERT( !bb.isDisjointWith( ibb )); - - // overlapping non-directed BB - double overlappingBB[2*dim] = - { - -5,4 - }; - CPPUNIT_ASSERT( !bb.isDisjointWith( overlappingBB )); - - // non-overlapping non-directed BB - double nonoverlappingBB_1[2*dim] = - { - -5,-2 - }; - CPPUNIT_ASSERT( bb.isDisjointWith( nonoverlappingBB_1 )); - double nonoverlappingBB_2[2*dim] = - { - 11,16 - }; - CPPUNIT_ASSERT( bb.isDisjointWith( nonoverlappingBB_2 )); - } - -} diff --git a/src/INTERP_KERNELTest/BBTreeTest.hxx b/src/INTERP_KERNELTest/BBTreeTest.hxx deleted file mode 100644 index 7db6208d9..000000000 --- a/src/INTERP_KERNELTest/BBTreeTest.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_BB_TREE_HXX__ -#define __TU_BB_TREE_HXX__ - -#include - -#include "InterpKernelTestExport.hxx" -#include "BBTree.txx" - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class INTERPKERNELTEST_EXPORT BBTreeTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( BBTreeTest ); - CPPUNIT_TEST( test_BBTree ); - CPPUNIT_TEST( test_DirectedBB_1D ); - CPPUNIT_TEST( test_DirectedBB_2D ); - CPPUNIT_TEST( test_DirectedBB_3D ); - CPPUNIT_TEST_SUITE_END(); - - - public: - void setUp(); - - void tearDown(); - - // tests - void test_BBTree(); - void test_DirectedBB_1D(); - void test_DirectedBB_2D(); - void test_DirectedBB_3D(); - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNELTest/BasicMainTest.hxx b/src/INTERP_KERNELTest/BasicMainTest.hxx deleted file mode 100644 index 86b29845d..000000000 --- a/src/INTERP_KERNELTest/BasicMainTest.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2007-2010 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 _BASICMAINTEST_HXX_ -#define _BASICMAINTEST_HXX_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifndef WIN32 -#include -#endif - -// ============================================================================ -/*! - * Main program source for Unit Tests with cppunit package does not depend - * on actual tests, so we use the same for all partial unit tests. - */ -// ============================================================================ - -int main(int argc, char* argv[]) -{ -#ifndef WIN32 - fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM); - _FPU_SETCW(cw); -#endif - // --- Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // --- Add a listener that colllects test result - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // --- Add a listener that print dots as test run. -#ifdef WIN32 - CPPUNIT_NS::TextTestProgressListener progress; -#else - CPPUNIT_NS::BriefTestProgressListener progress; -#endif - controller.addListener( &progress ); - - // --- Get the top level suite from the registry - - CPPUNIT_NS::Test *suite = - CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); - - // --- Adds the test to the list of test to run - - CPPUNIT_NS::TestRunner runner; - runner.addTest( suite ); - runner.run( controller); - - // --- Print test in a compiler compatible format. - - std::ofstream testFile; - testFile.open("UnitTestsResult", std::ios::out | std::ios::trunc); - //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); - CPPUNIT_NS::CompilerOutputter outputter( &result, testFile ); - outputter.write(); - - // --- Run the tests. - - bool wasSucessful = result.wasSuccessful(); - testFile.close(); - - // --- Return error code 1 if the one of test failed. - - return wasSucessful ? 0 : 1; -} - -#endif diff --git a/src/INTERP_KERNELTest/CppUnitTest.cxx b/src/INTERP_KERNELTest/CppUnitTest.cxx deleted file mode 100644 index 3955a8424..000000000 --- a/src/INTERP_KERNELTest/CppUnitTest.cxx +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2007-2010 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 "CppUnitTest.hxx" diff --git a/src/INTERP_KERNELTest/CppUnitTest.hxx b/src/INTERP_KERNELTest/CppUnitTest.hxx deleted file mode 100644 index e889e098b..000000000 --- a/src/INTERP_KERNELTest/CppUnitTest.hxx +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_TEST_CPPUNIT_HXX__ -#define __TU_TEST_CPPUNIT_HXX__ - -#include - -/** - * \brief Class tested by TestBogusClass : not very useful - */ -class BogusClass { - friend class TestBogusClass; - -public: - BogusClass(double _x) : x(_x) {;} - - double getX() { return x; } - -private: - double x; -}; - -/** - * \brief Class used to figure out CppUnit : not very useful - * - */ -class TestBogusClass : public CppUnit::TestFixture -{ - - CPPUNIT_TEST_SUITE( TestBogusClass ); - CPPUNIT_TEST( test1 ); - CPPUNIT_TEST( test2 ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() { - obj = new BogusClass(3.14); - } - - void tearDown() { - delete obj; - } - - void test1() { - // test something - CPPUNIT_ASSERT(obj->x == 3.14); - CPPUNIT_ASSERT(obj->getX() == obj->x); - } - - void test2() { - // test something else - obj->x += 2.6; - CPPUNIT_ASSERT(obj->getX() > 3.14); - } - -private: - BogusClass* obj; - -}; - - - - - - - - -#endif diff --git a/src/INTERP_KERNELTest/ExprEvalInterpTest.cxx b/src/INTERP_KERNELTest/ExprEvalInterpTest.cxx deleted file mode 100644 index 947f8fa5c..000000000 --- a/src/INTERP_KERNELTest/ExprEvalInterpTest.cxx +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (C) 2007-2010 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 "ExprEvalInterpTest.hxx" -#include "InterpKernelExprParser.hxx" - -using namespace INTERP_TEST; - -void ExprEvalInterpTest::testBuildStringFromFortran() -{ - char toto1[]="123456 "; - char result[]="123456"; - std::string titi; - titi=INTERP_KERNEL::ExprParser::buildStringFromFortran(toto1,8); - CPPUNIT_ASSERT_EQUAL(6,(int)titi.length()); - CPPUNIT_ASSERT(titi==result); - // - char toto2[]=" 23456 "; - char result2[]=" 23456"; - titi=INTERP_KERNEL::ExprParser::buildStringFromFortran(toto2,8); - CPPUNIT_ASSERT(titi==result2); - CPPUNIT_ASSERT_EQUAL(6,(int)titi.length()); - // - char toto3[]=" 3456 "; - char result3[]=" 3456"; - titi=INTERP_KERNEL::ExprParser::buildStringFromFortran(toto3,8); - CPPUNIT_ASSERT(titi==result3); - CPPUNIT_ASSERT_EQUAL(6,(int)titi.length()); - // - char toto4[]=" "; - titi=INTERP_KERNEL::ExprParser::buildStringFromFortran(toto4,8); - CPPUNIT_ASSERT_EQUAL(0,(int)titi.length()); - // - char toto5[]=" 345677"; - titi=INTERP_KERNEL::ExprParser::buildStringFromFortran(toto5,8); - CPPUNIT_ASSERT(titi==toto5); - CPPUNIT_ASSERT_EQUAL(8,(int)titi.length()); -} - -void ExprEvalInterpTest::testDeleteWhiteSpaces() -{ - char toto[]=" jkhjkh ooooppp l "; - char result[]="jkhjkhoooopppl"; - std::string totoS(toto); - std::string totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - char toto2[]=" jkhjkh ooooppp l "; - totoS=toto2; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - char toto3[]=" jkhjkh oooo pppl "; - totoS=toto3; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - char toto4[]=" jkhjkh oooo pppl"; - totoS=toto4; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - char toto5[]="jkhjkh oooo pppl"; - totoS=toto5; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - totoS=result; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - char toto6[]="j k h j k h o o o o p p p l"; - totoS=toto6; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - char toto7[]="j k h j k h o o o o p pp l"; - totoS=toto7; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); - // - char toto8[]=" "; - totoS=toto8; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR.empty()); - // - char toto9[]=""; - totoS=toto9; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR.empty()); - // - char toto10[]="j\n k \nh\nj \n\n k\nh \n o \no\n o\n o \np\n\npp \n\n l"; - totoS=toto10; - totoR=INTERP_KERNEL::ExprParser::deleteWhiteSpaces(totoS); - CPPUNIT_ASSERT(totoR==result); - CPPUNIT_ASSERT_EQUAL(14,(int)totoR.length()); -} - -void ExprEvalInterpTest::testInterpreter0() -{ - INTERP_KERNEL::ExprParser expr1("3*-2"); - expr1.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.,expr1.evaluate(),1e-15); - INTERP_KERNEL::ExprParser expr2("-2.3"); - expr2.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-2.3,expr2.evaluate(),1e-15); - INTERP_KERNEL::ExprParser expr3("--2.3"); - expr3.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,expr3.evaluate(),1e-15); - INTERP_KERNEL::ExprParser expr4("-++2.3"); - expr4.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-2.3,expr4.evaluate(),1e-15); - INTERP_KERNEL::ExprParser expr5("+2.3"); - expr5.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,expr5.evaluate(),1e-15); - INTERP_KERNEL::ExprParser expr6("3^-1"); - expr6.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333333,expr6.evaluate(),1e-15); -} - -void ExprEvalInterpTest::testInterpreter1() -{ - INTERP_KERNEL::ExprParser expr1("3+2*5"); - expr1.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,expr1.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr2("3+2^3*5"); - expr2.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(43.,expr2.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr3("3+2^(2*5)"); - expr3.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1027.,expr3.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr4("(3.2+4.3)*(1.3+2.3*7.8)"); - expr4.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(144.3,expr4.evaluate(),1e-10); - INTERP_KERNEL::ExprParser expr5("(3.2+4.3)*cos(1.3+2.3*7.8)"); - expr5.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.9355510138337619,expr5.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr6("3+2-4-7+4.3"); - expr6.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.7,expr6.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr7("3.2*4.5/3.3/2.2"); - expr7.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.9834710743801653,expr7.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr8("3.2*4.5/3.3/2.2"); - expr8.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.9834710743801653,expr8.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr9("(((1.23456789)))"); - expr9.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23456789,expr9.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr10("3.2*((2*5.2+6.)+(1.2*1.2+3.))"); - expr10.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(66.688,expr10.evaluate(),1e-13); - INTERP_KERNEL::ExprParser expr11("((3.2*(((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr11.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(66.688,expr11.evaluate(),1e-13); - INTERP_KERNEL::ExprParser expr12("((3.2*(cos((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr12.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.3038041398761016,expr12.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr13("((3.2*(sin((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr13.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.9223440531261784,expr13.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr14("((3.2*(tan((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr14.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-7.1724737512280257,expr14.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr15("((3.2*(sqrt((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr15.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(14.608271629457059,expr15.evaluate(),1e-13); - INTERP_KERNEL::ExprParser expr16("-((3.2*(sqrt((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr16.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-14.608271629457059,expr16.evaluate(),1e-13); - INTERP_KERNEL::ExprParser expr17("(-(3.2*(sqrt((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr17.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-14.608271629457059,expr17.evaluate(),1e-13); - INTERP_KERNEL::ExprParser expr18("((-3.2*(sqrt((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr18.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-14.608271629457059,expr18.evaluate(),1e-13); - INTERP_KERNEL::ExprParser expr19("((3.2*(exp((6.+2*5.2)+(1.2*1.2+3.)))))"); - expr19.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3596226038.1784945,expr19.evaluate(),1e-6); - INTERP_KERNEL::ExprParser expr20("((3.2*(ln((2*5.2+6.)+(1.2*1.2+3.)))))"); - expr20.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.7179974940325309,expr20.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr21("max(3.2,4.5)"); - expr21.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5,expr21.evaluate(),1e-14); - INTERP_KERNEL::ExprParser expr22("3.*max(((3.2*(ln((2*5.2+6.)+(1.2*1.2+3.))))),((3.2*(exp((6.+2*5.2)+(1.2*1.2+3.))))))"); - expr22.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(10788678114.535484,expr22.evaluate(),1e-5); - INTERP_KERNEL::ExprParser expr23("min(3.2,4.5)"); - expr23.parse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2,expr23.evaluate(),1e-14); -} - -void ExprEvalInterpTest::testInterpreter2() -{ - INTERP_KERNEL::ExprParser expr1("3.5*x+x*x*x/(2+x)+2*5*y"); - expr1.parse(); - std::set res,expected; - expr1.getSetOfVars(res); - CPPUNIT_ASSERT_EQUAL(2,(int)res.size()); - expected.insert("x"); expected.insert("y"); - CPPUNIT_ASSERT(std::equal(res.begin(),res.end(),expected.begin())); - double xyValue[2]={1.,3.}; - double res1; - std::vector vars; vars.push_back("x"); vars.push_back("y"); - expr1.prepareExprEvaluation(vars); - expr1.evaluateExpr(1,&res1,xyValue); - CPPUNIT_ASSERT_DOUBLES_EQUAL(33.833333333333336,res1,1e-13); - xyValue[0]=-2.; - CPPUNIT_ASSERT_THROW(expr1.evaluateExpr(1,&res1,xyValue),INTERP_KERNEL::Exception); - double res2[2]; - xyValue[0]=1.; - expr1.evaluateExpr(2,res2,xyValue); - CPPUNIT_ASSERT_DOUBLES_EQUAL(33.833333333333336,res2[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(33.833333333333336,res2[1],1e-13); - INTERP_KERNEL::ExprParser expr2("3.5*tan(2.3*x)*IVec+(cos(1.2+y/x)*JVec)"); - expr2.parse(); - res.clear(); expected.clear(); - expr2.getSetOfVars(res); - CPPUNIT_ASSERT_EQUAL(4,(int)res.size()); - expected.insert("x"); expected.insert("y"); expected.insert("IVec"); expected.insert("JVec"); - CPPUNIT_ASSERT(std::equal(res.begin(),res.end(),expected.begin())); - expr2.prepareExprEvaluation(vars); - expr2.evaluateExpr(2,res2,xyValue); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.9172477460694637,res2[0],1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.49026082134069943,res2[1],1e-14); - INTERP_KERNEL::ExprParser expr3("3.5*u+u^2.4+2."); - expr3.parse(); - expr3.prepareExprEvaluationVec(); - expr3.evaluateExpr(2,res2,xyValue); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.5,res2[0],1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26.466610165238237,res2[1],1e-14); - INTERP_KERNEL::ExprParser expr4("3.5*v+u^2.4+2."); - expr4.parse(); - CPPUNIT_ASSERT_THROW(expr4.prepareExprEvaluationVec(),INTERP_KERNEL::Exception); -} - -void ExprEvalInterpTest::testInterpreterUnit0() -{ - INTERP_KERNEL::ExprParser expr1("kg"); - expr1.parse(); - INTERP_KERNEL::DecompositionInUnitBase unit=expr1.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(1,0,0,0,0,0.,1000.)); - INTERP_KERNEL::ExprParser expr2("kgT"); - expr2.parse(); - CPPUNIT_ASSERT_THROW(expr2.evaluateUnit(),INTERP_KERNEL::Exception); - INTERP_KERNEL::ExprParser expr3("g"); - expr3.parse(); - unit=expr3.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(1,0,0,0,0,0.,1.)); - INTERP_KERNEL::ExprParser expr4("g*m"); - expr4.parse(); - unit=expr4.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(1,1,0,0,0,0.,1.)); - INTERP_KERNEL::ExprParser expr5("g*m/K"); - expr5.parse(); - unit=expr5.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(1,1,0,0,-1,0.,1.)); - INTERP_KERNEL::ExprParser expr6("g*m/K^2"); - expr6.parse(); - unit=expr6.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(1,1,0,0,-2,0.,1.)); - INTERP_KERNEL::ExprParser expr7("g/K^2*m"); - expr7.parse(); - unit=expr7.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(1,1,0,0,-2,0.,1.)); - INTERP_KERNEL::ExprParser expr8("g/(K^2*m)"); - expr8.parse(); - unit=expr8.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(1,-1,0,0,-2,0.,1.)); - INTERP_KERNEL::ExprParser expr9("km/h"); - expr9.parse(); - unit=expr9.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,1,-1,0,0,0.,0.27777777777777779)); - INTERP_KERNEL::ExprParser expr10("m/s"); - expr10.parse(); - unit=expr10.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,1,-1,0,0,0.,1.)); - INTERP_KERNEL::ExprParser expr11("m+s"); - expr11.parse(); - CPPUNIT_ASSERT_THROW(expr11.evaluateUnit(),INTERP_KERNEL::Exception); - INTERP_KERNEL::ExprParser expr12("m-m"); - expr12.parse(); - CPPUNIT_ASSERT_THROW(expr12.evaluateUnit(),INTERP_KERNEL::Exception); - const char expr13C[3]={-0x50,0x43,0x0}; - INTERP_KERNEL::ExprParser expr13(expr13C); - expr13.parse(); - unit=expr13.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,0,0,0,1,273.15,1.)); - const char expr14C[4]={-0x3E,-0x50,0x43,0x0}; - INTERP_KERNEL::ExprParser expr14(expr14C); - expr14.parse(); - unit=expr14.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,0,0,0,1,273.15,1.)); - INTERP_KERNEL::ExprParser expr15("kN/kg"); - expr15.parse(); - unit=expr15.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,1,-2,0,0,0.,1000.)); - INTERP_KERNEL::ExprParser expr16("cm"); - expr16.parse(); - unit=expr16.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,1,0,0,0,0.,0.01)); - INTERP_KERNEL::ExprParser expr17("m"); - expr17.parse(); - unit=expr17.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,1,0,0,0,0.,1)); - const char expr18C[3]={-0x08,0x43,0x0}; - INTERP_KERNEL::ExprParser expr18(expr18C); - expr18.parse(); - unit=expr18.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,0,0,0,1,273.15,1.)); - const char expr19C[6]={-0x50,0x43,0x2F,-0x50,0x43,0x0}; - INTERP_KERNEL::ExprParser expr19(expr19C); - expr19.parse(); - unit=expr19.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,0,0,0,0,0.,1.)); - const char expr20C[9]={-0x50,0x43,0x2A,-0x50,0x43,0x2F,-0x50,0x43,0x0}; - INTERP_KERNEL::ExprParser expr20(expr20C); - expr20.parse(); - unit=expr20.evaluateUnit(); - CPPUNIT_ASSERT(unit.isEqual(0,0,0,0,1,0.,1.)); -} - -void ExprEvalInterpTest::testInterpreterUnit1() -{ - INTERP_KERNEL::Unit unit1("m/s"); - INTERP_KERNEL::Unit unit2("km/h"); - CPPUNIT_ASSERT(unit1.isCompatibleWith(unit2) && unit2.isCompatibleWith(unit1)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(360,unit1.convert(unit2,100.),1e-10); - INTERP_KERNEL::Unit unit3("J/s"); - INTERP_KERNEL::Unit unit4("kW"); - CPPUNIT_ASSERT(unit3.isCompatibleWith(unit4) && unit4.isCompatibleWith(unit3)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,unit3.convert(unit4,1000.),1e-10); - CPPUNIT_ASSERT(unit4.getCoarseRepr()=="kW"); - INTERP_KERNEL::Unit unit5("kpT"); - CPPUNIT_ASSERT(!unit5.isInterpretationOK()); - CPPUNIT_ASSERT(unit5.getCoarseRepr()=="kpT"); - INTERP_KERNEL::Unit unit6("m*kpT"); - CPPUNIT_ASSERT(!unit6.isInterpretationOK()); - INTERP_KERNEL::Unit unit7("m*s^-1"); - CPPUNIT_ASSERT(unit7.isCompatibleWith(unit2) && unit2.isCompatibleWith(unit7)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(360,unit7.convert(unit2,100.),1e-10); - const char unit8C[3]={-0x50,0x43,0x0}; - INTERP_KERNEL::Unit unit8(unit8C); - INTERP_KERNEL::Unit unit9("K"); - CPPUNIT_ASSERT(unit9.isCompatibleWith(unit8) && unit8.isCompatibleWith(unit9)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(335.15,unit8.convert(unit9,62.),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-16.37,unit9.convert(unit8,256.78),1e-10); - INTERP_KERNEL::Unit unit10("m"); - INTERP_KERNEL::Unit unit11("cm"); - CPPUNIT_ASSERT(unit10.isCompatibleWith(unit11) && unit11.isCompatibleWith(unit10)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6200.,unit10.convert(unit11,62.),1e-8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.62,unit11.convert(unit10,62.),1e-15); - INTERP_KERNEL::Unit unit12("m-m"); - CPPUNIT_ASSERT(!unit12.isInterpretationOK()); -} diff --git a/src/INTERP_KERNELTest/ExprEvalInterpTest.hxx b/src/INTERP_KERNELTest/ExprEvalInterpTest.hxx deleted file mode 100644 index a135201da..000000000 --- a/src/INTERP_KERNELTest/ExprEvalInterpTest.hxx +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2007-2010 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 _EXPREVALINTERPTEST_HXX_ -#define _EXPREVALINTERPTEST_HXX_ - -#include - -#include "InterpKernelTestExport.hxx" - -namespace INTERP_TEST -{ - class INTERPKERNELTEST_EXPORT ExprEvalInterpTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE( ExprEvalInterpTest ); - CPPUNIT_TEST( testBuildStringFromFortran ); - CPPUNIT_TEST( testDeleteWhiteSpaces ); - CPPUNIT_TEST( testInterpreter0 ); - CPPUNIT_TEST( testInterpreter1 ); - CPPUNIT_TEST( testInterpreter2 ); - CPPUNIT_TEST( testInterpreterUnit0 ); - CPPUNIT_TEST( testInterpreterUnit1 ); - CPPUNIT_TEST_SUITE_END(); - public: - void setUp() { } - void tearDown() { } - void cleanUp() { } - void testBuildStringFromFortran(); - void testDeleteWhiteSpaces(); - void testInterpreter0(); - void testInterpreter1(); - void testInterpreter2(); - void testInterpreterUnit0(); - void testInterpreterUnit1(); - }; -} - -#endif diff --git a/src/INTERP_KERNELTest/HexaTests.hxx b/src/INTERP_KERNELTest/HexaTests.hxx deleted file mode 100644 index aca8bcb61..000000000 --- a/src/INTERP_KERNELTest/HexaTests.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2007-2010 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 __HEXA_TESTS_HXX_ -#define __HEXA_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class performing intersection tests on meshes with hexahedral elements. - * - */ - class HexaTests : public InterpolationTestSuite<3,3> - { - CPPUNIT_TEST_SUITE( HexaTests ); - - CPPUNIT_TEST( simpleHexaBox ); - //VB : slightly inaccurate so that it triggers a failure of the test - // should be investigated in the future - // CPPUNIT_TEST( reflexiveHexaBox ); - CPPUNIT_TEST( hexaBoxes ); - CPPUNIT_TEST( hexaBoxesMoved ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - /// Intersection between two boxes, aligned with the axes.One has 60 hexahedral elements and the other has 39 tetrahedral elements - /// \brief Status : pass - void simpleHexaBox() - { - _testTools->intersectMeshes("BoxHexa1", "BoxTetra2", 65250, 1.0e-5); - } - - /// Intersection of a box with 60 hexahedral elements with itself - /// \brief Status : pass - void reflexiveHexaBox() - { - _testTools->intersectMeshes("BoxHexa1", "BoxHexa1", 204000); - } - - /// Intersection between two boxes, aligned with the axes.Both have hexahedral elements : one 36, the other 60 - /// \brief Status : pass - void hexaBoxes() - { - _testTools->intersectMeshes("BoxHexa1", "BoxHexa2", 65250); - } - - /// Intersection between two boxes in general position with hexahedral elements. One has 200 elements and the other 420. - /// \brief Status : fails - reason unknown. The matrix does not fulfil the transpose requirement : that W_AB = W_BA^T - void hexaBoxesMoved() - { - _testTools->intersectMeshes("MovedHexaBox1", "MovedHexaBox2", 65250); - } - - }; -} -#endif diff --git a/src/INTERP_KERNELTest/InterpKernelTestExport.hxx b/src/INTERP_KERNELTest/InterpKernelTestExport.hxx deleted file mode 100644 index 1c60231b2..000000000 --- a/src/INTERP_KERNELTest/InterpKernelTestExport.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2007-2010 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 _INTERPKERNELTESTEXPORT_HXX_ -#define _INTERPKERNELTESTEXPORT_HXX_ - -#ifdef WNT -# if defined InterpKernelTest_EXPORTS -# define INTERPKERNELTEST_EXPORT __declspec( dllexport ) -# else -# define INTERPKERNELTEST_EXPORT __declspec( dllimport ) -# endif -#else -# define INTERPKERNELTEST_EXPORT -#endif - -#endif diff --git a/src/INTERP_KERNELTest/Interpolation3DTest.cxx b/src/INTERP_KERNELTest/Interpolation3DTest.cxx deleted file mode 100644 index aa08ee06d..000000000 --- a/src/INTERP_KERNELTest/Interpolation3DTest.cxx +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright (C) 2007-2010 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 "Interpolation3DTest.hxx" -#include "MEDMEM_Mesh.hxx" - -#include -#include -#include -#include -#include - -#include "VectorUtils.hxx" - -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Support.hxx" - -// levels : -// 1 - titles and volume results -// 2 - symmetry / diagonal results and intersection matrix output -// 3 - empty -// 4 - empty -// 5 - misc -#include "Log.hxx" - - -//#define VOL_PREC 1.0e-6 - -using namespace MEDMEM; -using namespace INTERP_KERNEL; -using namespace MED_EN; - -double Interpolation3DTest::sumRow(const IntersectionMatrix& m, int i) const -{ - double vol = 0.0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - if(iter->count(i) != 0.0) - { - std::map::const_iterator iter2 = iter->find(i); - vol += iter2->second; - } - } - return vol; -} - -double Interpolation3DTest::sumCol(const IntersectionMatrix& m, int i) const -{ - double vol = 0.0; - const std::map& col = m[i]; - for(std::map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) - { - vol += std::fabs(iter->second); - } - return vol; -} - - -void Interpolation3DTest::getVolumes(MESH& mesh, double* tab) const -{ - SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); - FIELD* f=mesh.getVolume(sup); - const double *tabS=f->getValue(); - std::copy(tabS,tabS+mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS),tab) - delete sup; -} - -double Interpolation3DTest::sumVolume(const IntersectionMatrix& m) const -{ - - std::vector volumes; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - volumes.push_back(iter2->second); - // vol += std::abs(iter2->second); - } - } - - // sum in ascending order to avoid rounding errors - - sort(volumes.begin(), volumes.end()); - const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); - - return vol; -} - -bool Interpolation3DTest::testVolumes(const IntersectionMatrix& m, MESH& sMesh, MESH& tMesh) const -{ - bool ok = true; - - // source elements - double* sVol = new double[sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)]; - getVolumes(sMesh, sVol); - - for(int i = 0; i < sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); ++i) - { - const double sum_row = sumRow(m, i+1); - if(!epsilonEqualRelative(sum_row, sVol[i], VOL_PREC)) - { - LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row ); - ok = false; - } - LOG(1, "diff = " <::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double v1 = iter2->second; - //if(m2[j - 1].count(i+1) > 0) - // { - std::map theMap = m2.at(j-1); - const double v2 = theMap[i + 1]; - if(v1 != v2) - { - LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); - if(!epsilonEqualRelative(v1, v2, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isSymmetric = false; - } - } - } - ++i; - } - if(!isSymmetric) - { - LOG(1, "*** matrices are not symmetric"); - } - return isSymmetric; -} - -bool Interpolation3DTest::testDiagonal(const IntersectionMatrix& m) const -{ - LOG(1, "Checking if matrix is diagonal" ); - int i = 1; - bool isDiagonal = true; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double vol = iter2->second; - if(vol != 0.0 && (i != j)) - { - LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); - if(!epsilonEqual(vol, 0.0, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isDiagonal = false; - } - } - } - ++i; - } - if(!isDiagonal) - { - LOG(1, "*** matrix is not diagonal"); - } - return isDiagonal; -} - -void Interpolation3DTest::dumpIntersectionMatrix(const IntersectionMatrix& m) const -{ - int i = 0; - std::cout << "Intersection matrix is " << std::endl; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - - std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << std::endl; - - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; -} - -void Interpolation3DTest::setUp() -{ - interpolator = new Interpolation3D(); -} - -void Interpolation3DTest::tearDown() -{ - delete interpolator; -} - -void Interpolation3DTest::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const -{ - const string dataBaseDir = getenv("MED_ROOT_DIR"); - const string dataDir = dataBaseDir + "/share/salome/resources/med/"; - - LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); - - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); - - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); - - m = interpolator->interpolateMeshes(sMesh, tMesh); - - // if reflexive, check volumes - if(strcmp(mesh1path,mesh2path) == 0) - { - const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); - } - - LOG(1, "Intersection calculation done. " << std::endl ); - -} - -void Interpolation3DTest::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const -{ - LOG(1, std::endl << std::endl << "=============================" ); - - using std::string; - const string path1 = string(mesh1path) + string(mesh1); - const string path2 = string(mesh2path) + string(mesh2); - - const bool isTestReflexive = (path1.compare(path2) == 0); - - IntersectionMatrix matrix1; - calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix1); -#endif - - std::cout.precision(16); - - const double vol1 = sumVolume(matrix1); - - if(!doubleTest) - { - LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); - - if(isTestReflexive) - { - CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); - } - } - else - { - - IntersectionMatrix matrix2; - calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix2); -#endif - - const double vol2 = sumVolume(matrix2); - - LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testSymmetric(matrix1, matrix2)); - } - -} - - - diff --git a/src/INTERP_KERNELTest/Interpolation3DTest.hxx b/src/INTERP_KERNELTest/Interpolation3DTest.hxx deleted file mode 100644 index 621c20d7d..000000000 --- a/src/INTERP_KERNELTest/Interpolation3DTest.hxx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_INTERPOLATION_3D_TEST_HXX__ -#define __TU_INTERPOLATION_3D_TEST_HXX__ - -#include -#include "Interpolation3D.hxx" - -#define ERR_TOL 1.0e-8 - -using MEDMEM::Interpolation3D; -class MEDMEM::MESH; - -/// \brief OBSOLETE - renamed Interpolation3DTestSuite -class Interpolation3DTest : public CppUnit::TestFixture -{ - -public: - void setUp() - { - _testTools = new MeshTestToolkit(); - } - - void tearDown() - { - delete _testTools; - } - -protected: - - MeshToolkit* _testTools; - -}; - -#endif diff --git a/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx b/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx deleted file mode 100644 index 4db3c7b2f..000000000 --- a/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007-2010 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 "InterpolationOptionsTest.hxx" -#include "MEDNormalizedUnstructuredMesh.txx" -#include "Interpolation2D.txx" -#include "TestInterpKernelUtils.hxx" -#include -#include - -namespace INTERP_TEST -{ - - - void InterpolationOptionsTest::setUp() - { - } - - - void InterpolationOptionsTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check that - * the results are correct in three - * cases : - * a non matching search - * a standard case - * a bbox overlapping the bboxes of the tree - */ - void InterpolationOptionsTest::test_InterpolationOptions() { - string sourcename=INTERP_TEST::getResourceFile("square1.med"); - MEDMEM::MESH *source_mesh=new MEDMEM::MESH(MED_DRIVER,sourcename,"Mesh_2"); - - string targetname=INTERP_TEST::getResourceFile("square2.med"); - MEDMEM::MESH *target_mesh=new MEDMEM::MESH(MED_DRIVER,targetname,"Mesh_3"); - - MEDMEM::SUPPORT *source_support=new SUPPORT(source_mesh,"on All support"); - MEDMEM::FIELD *source_field=new FIELD(source_support,1); - double* value=const_cast(source_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS); i++) - value[i]=1.0; - source_support->removeReference(); - MEDMEM::SUPPORT *target_support=new MEDMEM::SUPPORT(target_mesh,"on All support"); - MEDMEM::FIELD *target_field=new FIELD(target_support,1); - double* targetvalue=const_cast(target_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS); i++) - targetvalue[i]=0.0; - target_support->removeReference(); - // Ok at this point we have our mesh in MED-Memory format. - // Go to wrap med_source_mesh and med_target_mesh. - MEDNormalizedUnstructuredMesh<2,2> wrap_source_mesh(source_mesh); - MEDNormalizedUnstructuredMesh<2,2> wrap_target_mesh(target_mesh); - // Go for interpolation... - INTERP_KERNEL::Interpolation2D myInterpolator; - //optionnal call to parametrize your interpolation. First precision, tracelevel, intersector wanted. - myInterpolator.setPrecision(1e-7); - myInterpolator.setPrintLevel(1); - source_mesh->removeReference(); - source_field->removeReference(); - target_field->removeReference(); - target_mesh->removeReference(); - } - - -} diff --git a/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx b/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx deleted file mode 100644 index 08d5267d2..000000000 --- a/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_INTERPOLATIONOPTIONS_HXX__ -#define __TU_INTERPOLATIONOPTIONS_HXX__ - -#include - -#include "InterpKernelTestExport.hxx" -#include "InterpolationOptions.hxx" -#include "MEDMEM_Field.hxx" - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class INTERPKERNELTEST_EXPORT InterpolationOptionsTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( InterpolationOptionsTest ); - CPPUNIT_TEST( test_InterpolationOptions ); - CPPUNIT_TEST_SUITE_END(); - - - public: - void setUp(); - - void tearDown(); - - // tests - void test_InterpolationOptions(); - - private: - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx b/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx deleted file mode 100644 index 97ab410ca..000000000 --- a/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ -#define __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ - -#include -#include -#include -#include - -namespace INTERP_TEST -{ - - /** - * \brief Base class for planar mesh intersection test suites. - * - */ - class InterpolationPlanarTestSuite : public CppUnit::TestFixture - { - - public: - double _Epsilon; - double _Precision; - - /** - * Sets up the test suite. - * - */ - void setUp() - { - _Epsilon = 1.e-6; - _Precision = 1.e-6; - } - void tearDown() {} - - // bool checkDequesEqual(std::deque< double > deque1, std::deque< double > deque2, double epsilon); - // bool checkVectorsEqual(std::vector< double > Vect1, std::vector< double > Vect2, double epsilon); - // void dequePrintOut(std::deque< double > deque1); - // void vectPrintOut(std::vector< double > vect); - // void tabPrintOut( const double * tab, int size); - - bool checkDequesEqual(std::deque< double > deque1, - std::deque< double > deque2, double epsilon) - { - int size1 = deque1.size(); - int size2 = deque2.size(); - bool are_equal = size1 == size2; - - if(are_equal) - for(int i = 0; i < size1 && are_equal; i++) - are_equal = fabs(deque1[i] - deque2[i]) < epsilon; - - return are_equal; - } - bool checkVectorsEqual(std::vector< double > vect1, - std::vector< double > vect2, double epsilon) - { - int size1 = vect1.size(); - int size2 = vect2.size(); - bool are_equal = size1 == size2; - - if(are_equal) - for(int i = 0; i < size1 && are_equal; i++) - are_equal = fabs(vect1[i] - vect2[i]) < epsilon; - - return are_equal; - } - void dequePrintOut(std::deque< double > deque1) - { - for(int i = 0; i< (int)deque1.size(); i++) - { - std::cerr << deque1[i] << " "; - } - std::cerr<< std::endl; - } - void vectPrintOut(std::vector< double > vect) - { - for(int i = 0; i< (int)vect.size(); i++) - { - std::cerr << vect[i] << " "; - } - std::cerr<< std::endl; - } - void tabPrintOut( const double * tab,int size) - { - for(int i = 0; i< size; i++) - { - std::cerr << tab[i] << " "; - } - std::cerr<< std::endl; - } - - /** - * Cleans up after the test suite. - * Liberates the MeshTestToolkit object used by the tests. - */ - // void tearDown() - // { - // delete _testTools; - // } - - - - // protected: - // /// MeshTestToolkit object to which the tests are delegated - // MeshTestToolkit* _testTools; - - }; -} -#endif diff --git a/src/INTERP_KERNELTest/InterpolationTestSuite.hxx b/src/INTERP_KERNELTest/InterpolationTestSuite.hxx deleted file mode 100644 index 90de96ffd..000000000 --- a/src/INTERP_KERNELTest/InterpolationTestSuite.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_INTERPOLATION_TEST_SUITE_HXX__ -#define __TU_INTERPOLATION_TEST_SUITE_HXX__ - -#include "MeshTestToolkit.txx" - -#include - -namespace INTERP_TEST -{ - - /** - * \brief Base class for mesh intersection test suites. - * - */ - template - class InterpolationTestSuite : public CppUnit::TestFixture - { - - public: - /** - * Sets up the test suite. - * Creates the MeshTestToolkit object used by the tests. - * - */ - void setUp() - { - _testTools = new MeshTestToolkit(); - } - - /** - * Cleans up after the test suite. - * Liberates the MeshTestToolkit object used by the tests. - */ - void tearDown() - { - delete _testTools; - } - - - - protected: - /// MeshTestToolkit object to which the tests are delegated - MeshTestToolkit* _testTools; - - }; -} -#endif diff --git a/src/INTERP_KERNELTest/MEDMeshMaker.cxx b/src/INTERP_KERNELTest/MEDMeshMaker.cxx deleted file mode 100644 index df0926bdb..000000000 --- a/src/INTERP_KERNELTest/MEDMeshMaker.cxx +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDMeshMaker.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" - -MEDMEM::MESH* MEDMeshMaker(int dim, int nbedge, MED_EN::medGeometryElement type) -{ - MEDMEM::MESHING* mesh=new MEDMEM::MESHING(); - int nbnodes; - int nbelems; - switch (dim) - { - case 2: - nbnodes=(nbedge+1)*(nbedge+1); - if(type==MED_EN::MED_QUAD4) - nbelems=(nbedge*nbedge); - else - throw MEDMEM::MEDEXCEPTION("MEDMeshMaker: type not impletmented"); - break; - case 3: - nbnodes=(nbedge+1)*(nbedge+1)*(nbedge+1); - if (type==MED_EN::MED_HEXA8) - nbelems= nbedge*nbedge*nbedge; - else - throw MEDMEM::MEDEXCEPTION("MEDMeshMaker: type not impletmented"); - break; - } - double* coords = new double[dim*nbnodes]; - int nz; - if (dim==2) nz =1; else nz=nbedge+1; - { - for (int ix=0; ix < nbedge+1; ix++) - for (int iy=0; iysetCoordinates(dim, nbnodes,coords,"CARTESIAN",MED_EN::MED_FULL_INTERLACE); - delete [] coords; - mesh->setNumberOfTypes(1,MED_EN::MED_CELL); - mesh->setTypes(&type,MED_EN::MED_CELL); - mesh->setNumberOfElements(&nbelems,MED_EN::MED_CELL); - - int* conn = new int [nbelems*(type%100)]; - if (dim==2) - { - for (int ix=0; ixsetConnectivity(MED_EN::MED_CELL,type,conn); - delete [] conn; - return mesh; -} diff --git a/src/INTERP_KERNELTest/MEDMeshMaker.hxx b/src/INTERP_KERNELTest/MEDMeshMaker.hxx deleted file mode 100644 index d77ba31ff..000000000 --- a/src/INTERP_KERNELTest/MEDMeshMaker.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDMEM_define.hxx" -namespace MEDMEM -{ - class MESH; -} - -MEDMEM::MESH* MEDMeshMaker(int dim, int nbedge, MED_EN::medGeometryElement type); diff --git a/src/INTERP_KERNELTest/Makefile.am b/src/INTERP_KERNELTest/Makefile.am deleted file mode 100644 index 4f9214a09..000000000 --- a/src/INTERP_KERNELTest/Makefile.am +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright (C) 2007-2010 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -# Library targets -lib_LTLIBRARIES = libInterpKernelTest.la - -UNUSED_FILES = \ - Interpolation3DTest.cxx \ - Interpolation3DTest.hxx \ - MultiElement3DSurfTests.hxx \ - TestingUtils.hxx - -EXTRA_DIST += \ - perf_test.sh \ - $(UNUSED_FILES) - -CLEANFILES = \ - UnitTestsResult - -libInterpKernelTest_la_SOURCES= \ - InterpKernelTestExport.hxx \ - BBTreeTest.hxx \ - BBTreeTest.cxx \ - CppUnitTest.hxx \ - CppUnitTest.cxx \ - InterpolationPlanarTestSuite.hxx \ - ExprEvalInterpTest.hxx \ - ExprEvalInterpTest.cxx \ - QuadraticPlanarInterpTest.hxx \ - QuadraticPlanarInterpTest.cxx \ - QuadraticPlanarInterpTest2.cxx \ - QuadraticPlanarInterpTest3.cxx \ - QuadraticPlanarInterpTest4.cxx \ - QuadraticPlanarInterpTest5.cxx \ - SingleElementPlanarTests.hxx \ - SingleElementPlanarTests.cxx \ - TransformedTriangleIntersectTest.hxx \ - TransformedTriangleIntersectTest.cxx \ - TransformedTriangleTest.hxx \ - TransformedTriangleTest.cxx \ - UnitTetraIntersectionBaryTest.hxx \ - UnitTetraIntersectionBaryTest.cxx \ - TestInterpKernelUtils.hxx \ - TestInterpKernelUtils.cxx - -libInterpKernelTest_la_CPPFLAGS = \ - @CPPUNIT_INCLUDES@ \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/ExprEval \ - -DOPTIMIZE -DLOG_LEVEL=0 - -libInterpKernelTest_la_LDFLAGS = \ - @CPPUNIT_LIBS@ \ - ../INTERP_KERNEL/libinterpkernel.la \ - ../INTERP_KERNEL/Geometric2D/libInterpGeometric2DAlg.la - -if !MED_ENABLE_MICROMED - libInterpKernelTest_la_SOURCES += \ - InterpolationOptionsTest.hxx \ - InterpolationOptionsTest.cxx \ - InterpolationTestSuite.hxx \ - MEDMeshMaker.hxx \ - MEDMeshMaker.cxx \ - MeshTestToolkit.hxx \ - MeshTestToolkit.txx \ - MultiElement2DTests.hxx \ - MultiElementTetraTests.hxx \ - PointLocatorTest.hxx \ - PointLocatorTest.cxx \ - SingleElementTetraTests.hxx - - libInterpKernelTest_la_CPPFLAGS += \ - -DDISABLE_MICROMED \ - $(MED2_INCLUDES) $(HDF5_INCLUDES) \ - -I$(srcdir)/../MEDMEM - - libInterpKernelTest_la_LDFLAGS += \ - ../MEDMEM/libmedmem.la -lm -endif - -if MED_ENABLE_KERNEL - libInterpKernelTest_la_CPPFLAGS += ${KERNEL_CXXFLAGS} - libInterpKernelTest_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace -endif - -# Executables targets -bin_PROGRAMS = TestINTERP_KERNEL - -if !MED_ENABLE_MICROMED - bin_PROGRAMS += PerfTest -endif - -TestINTERP_KERNEL_SOURCES = \ - BasicMainTest.hxx \ - TestInterpKernel.cxx - -TestINTERP_KERNEL_CPPFLAGS = $(libInterpKernelTest_la_CPPFLAGS) -TestINTERP_KERNEL_LDADD = $(libInterpKernelTest_la_LDFLAGS) libInterpKernelTest.la - -if !MED_ENABLE_MICROMED - TestINTERP_KERNEL_SOURCES += HexaTests.hxx -endif - -PerfTest_SOURCES = \ - PerfTest.cxx \ - MeshTestToolkit.hxx \ - MeshTestToolkit.txx - -PerfTest_CPPFLAGS = $(libInterpKernelTest_la_CPPFLAGS) -PerfTest_LDADD = $(MED2_LIBS) $(libInterpKernelTest_la_LDFLAGS) libInterpKernelTest.la - -if MED_ENABLE_KERNEL - TestINTERP_KERNEL_LDADD += -lSALOMEBasics - PerfTest_LDADD += -lSALOMEBasics -endif - -UNIT_TEST_PROG = TestINTERP_KERNEL - -check : tests - -clean-local: - rm -rf *.fig diff --git a/src/INTERP_KERNELTest/MeshTestToolkit.hxx b/src/INTERP_KERNELTest/MeshTestToolkit.hxx deleted file mode 100644 index 3046388a9..000000000 --- a/src/INTERP_KERNELTest/MeshTestToolkit.hxx +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_MESH_TEST_TOOLKIT_HXX__ -#define __TU_MESH_TEST_TOOLKIT_HXX__ - -#include "Interpolation3D.hxx" -#include "Interpolation3D.txx" -#include "InterpolationPlanar.hxx" - -#include -#include - -#define ERR_TOL 1.0e-8 - -typedef std::vector > IntersectionMatrix; - -namespace INTERP_KERNEL -{ - class Interpolation3D; -} - - -namespace MEDMEM { - class MESH; -} - -namespace INTERP_TEST -{ - /** - * \brief Class providing services for mesh intersection tests. - * - */ - template - class MeshTestToolkit - { - - public: - double _precision; - INTERP_KERNEL::IntersectionType _intersectionType;//Used only in the case MESHDIM==2 (planar intersections) - - MeshTestToolkit():_precision(1.e-6),_intersectionType(INTERP_KERNEL::Triangulation) {} - - ~MeshTestToolkit() {} - - void intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) const; - - // 1.0e-5 here is due to limited precision of "correct" volumes calculated in Salome - void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) const; - - void dumpIntersectionMatrix(const IntersectionMatrix& m) const; - - double sumRow(const IntersectionMatrix& m, int i) const; - - double sumCol(const IntersectionMatrix& m, int i) const; - - void getVolumes( MEDMEM::MESH& mesh, double* tab) const; - - bool testVolumes(const IntersectionMatrix& m, MEDMEM::MESH& sMesh, MEDMEM::MESH& tMesh) const; - - double sumVolume(const IntersectionMatrix& m) const; - - bool areCompatitable( const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; - - bool testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; - - bool testDiagonal(const IntersectionMatrix& m) const; - - void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const; - - }; -} -#endif diff --git a/src/INTERP_KERNELTest/MeshTestToolkit.txx b/src/INTERP_KERNELTest/MeshTestToolkit.txx deleted file mode 100644 index 3c7e2c997..000000000 --- a/src/INTERP_KERNELTest/MeshTestToolkit.txx +++ /dev/null @@ -1,507 +0,0 @@ -// Copyright (C) 2007-2010 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 "TestInterpKernelUtils.hxx" - -#include "MEDNormalizedUnstructuredMesh.hxx" -#include "MEDNormalizedUnstructuredMesh.txx" - -#include "MeshTestToolkit.hxx" -#include "MEDMEM_Mesh.hxx" - -#include "Interpolation3DSurf.txx" -#include "Interpolation2D.txx" -#include "Interpolation3D.txx" - -#include -#include -#include -#include -#include - -//#include "VectorUtils.hxx" - -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Support.hxx" - -// levels : -// 1 - titles and volume results -// 2 - symmetry / diagonal results and intersection matrix output -// 3 - empty -// 4 - empty -// 5 - misc -#include "Log.hxx" - -#include - -//#define VOL_PREC 1.0e-6 - -using namespace MEDMEM; -using namespace MED_EN; -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - - /** - * Calculates the sum of a row of an intersection matrix - * - * @param m an intersection matrix - * @param i the index of the row (1 <= i <= no. rows) - * @return the sum of the values of row i - * - */ - template - double MeshTestToolkit::sumRow(const IntersectionMatrix& m, int i) const - { - double vol = 0.0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - if(iter->count(i) != 0.0) - { - std::map::const_iterator iter2 = iter->find(i); - vol += fabs(iter2->second); - } - } - return vol; - } - - /** - * Calculates the sum of a column of an intersection matrix - * - * @param m an intersection matrix - * @param i the index of the column (0 <= i <= no. rows - 1) - * @return the sum of the values of column i - * - */ - template - double MeshTestToolkit::sumCol(const IntersectionMatrix& m, int i) const - { - double vol = 0.0; - const std::map& col = m[i]; - for(std::map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) - { - vol += fabs(iter->second); - } - return vol; - } - - /** - * Gets the volumes of the elements in a mesh. - * - * @param mesh the mesh - * @param tab pointer to double[no. elements of mesh] array in which to store the volumes - */ - template - void MeshTestToolkit::getVolumes(MEDMEM::MESH& mesh, double* tab) const - { - SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); - FIELD* f; - switch (MESHDIM) - { - case 2: - f=mesh.getArea(sup); - break; - case 3: - f=mesh.getVolume(sup); - break; - } - const double *tabS = f->getValue(); - std::copy(tabS,tabS+mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS),tab); - sup->removeReference(); - f->removeReference(); - } - - /** - * Sums all the elements (volumes) of an intersection matrix - * - * @param m the intersection matrix - * @return the sum of the elements of m - */ - - template - double MeshTestToolkit::sumVolume(const IntersectionMatrix& m) const - { - - std::vector volumes; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - volumes.push_back(fabs(iter2->second)); - } - } - - // sum in ascending order to avoid rounding errors - - sort(volumes.begin(), volumes.end()); - const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); - - return vol; - } - - /** - * Verifies if for a given intersection matrix the sum of each row is equal to the volumes - * of the corresponding source elements and the sum of each column is equal to the volumes - * of the corresponding target elements. This will be true as long as the meshes correspond - * to the same geometry. The equalities are in the "epsilon-sense", making sure the relative - * error is small enough. - * - * @param m the intersection matrix - * @param sMesh the source mesh - * @param tMesh the target mesh - * @return true if the condition is verified, false if not. - */ - template - bool MeshTestToolkit::testVolumes(const IntersectionMatrix& m, MEDMEM::MESH& sMesh, MEDMEM::MESH& tMesh) const - { - bool ok = true; - - // source elements - double* sVol = new double[sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)]; - getVolumes(sMesh, sVol); - - for(int i = 0; i < sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); ++i) - { - const double sum_row = sumRow(m, i+1); - if(!epsilonEqualRelative(sum_row, fabs(sVol[i]), _precision)) - { - LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row ); - ok = false; - } - LOG(1, "diff = " < - bool MeshTestToolkit::testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const - { - - int i = 0; - bool isSymmetric = true; - - LOG(1, "Checking symmetry src - target" ); - isSymmetric = isSymmetric & areCompatitable(m1, m2) ; - LOG(1, "Checking symmetry target - src" ); - isSymmetric = isSymmetric & areCompatitable(m2, m1); - - for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double v1 = fabs(iter2->second); - //if(m2[j - 1].count(i+1) > 0) - // { - std::map theMap = m2.at(j-1); - const double v2 = fabs(theMap[i + 1]); - if(v1 != v2) - { - LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); - if(!epsilonEqualRelative(v1, v2, _precision)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isSymmetric = false; - } - } - } - ++i; - } - if(!isSymmetric) - { - LOG(1, "*** matrices are not symmetric"); - } - return isSymmetric; - } - - /** - * Tests if an intersection matrix is diagonal. - * - * @param m the intersection matrix - * @return true if m is diagonal; false if not - * - */ - template - bool MeshTestToolkit::testDiagonal(const IntersectionMatrix& m) const - { - LOG(1, "Checking if matrix is diagonal" ); - int i = 1; - bool isDiagonal = true; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double vol = iter2->second; - if(vol != 0.0 && (i != j)) - { - LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); - if(!epsilonEqual(vol, 0.0, _precision)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isDiagonal = false; - } - } - } - ++i; - } - if(!isDiagonal) - { - LOG(1, "*** matrix is not diagonal"); - } - return isDiagonal; - } - - /** - * Outputs the intersection matrix as a list of all its elements to std::cout. - * - * @param m the intersection matrix to output - */ - template - void MeshTestToolkit::dumpIntersectionMatrix(const IntersectionMatrix& m) const - { - int i = 0; - std::cout << "Intersection matrix is " << endl; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - - std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; - - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; - } - - /** - * Calculates the intersection matrix for two meshes. - * If the source and target meshes are the same, a CppUnit assertion raised if testVolumes() returns false. - * - * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh1 the name of the source mesh - * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh2 the name of the target mesh - * @param m intersection matrix in which to store the result of the intersection - */ - template - void MeshTestToolkit::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const - { - LOG(1, std::endl << "=== -> intersecting src = " << mesh1path << ", target = " << mesh2path ); - - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - MESH sMesh(MED_DRIVER, INTERP_TEST::getResourceFile(mesh1path), mesh1); - - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - MESH tMesh(MED_DRIVER, INTERP_TEST::getResourceFile(mesh2path), mesh2); - - MEDNormalizedUnstructuredMesh sMesh_wrapper(&sMesh); - MEDNormalizedUnstructuredMesh tMesh_wrapper(&tMesh); - - if (SPACEDIM==2 && MESHDIM==2) - { - Interpolation2D interpolator; - interpolator.setOptions(_precision, LOG_LEVEL, _intersectionType,1); - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - } - else if (SPACEDIM==3 && MESHDIM==2) - { - Interpolation3DSurf interpolator; - interpolator.setOptions(_precision,LOG_LEVEL, 0.5,_intersectionType,false,1); - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - } - else if (SPACEDIM==3 && MESHDIM==3) - { - Interpolation3D interpolator; - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - } - else - { - throw MEDEXCEPTION("Wrong dimensions"); - } - // if reflexive, check volumes - if(strcmp(mesh1path,mesh2path) == 0) - { - const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); - const bool is_diagonal =testDiagonal(m); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Self intersection matrix is not diagonal", true, is_diagonal); - } - - LOG(1, "Intersection calculation done. " << std::endl ); - - } - - /** - * Tests the intersection algorithm for two meshes. - * Depending on the nature of the meshes, different tests will be performed. The sum of the elements will - * be compared to the given total volume of the intersection in all cases. If the two meshes are the same, then - * it will be confirmed that the intersection matrix is diagonal, otherwise the intersection matrices will be - * calculated once which each mesh as source mesh, and it will be verified that the they are each others' transpose. - * - * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh1 the name of the source mesh - * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh2 the name of the target mesh - * @param correctVol the total volume of the intersection of the two meshes - * @param prec maximum relative error to be tolerated in volume comparisions - * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed - * - */ - template - void MeshTestToolkit::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const - { - LOG(1, std::endl << std::endl << "=============================" ); - - using std::string; - const string path1 = string(mesh1path) + string(mesh1); - const string path2 = string(mesh2path) + string(mesh2); - - const bool isTestReflexive = (path1.compare(path2) == 0); - - IntersectionMatrix matrix1; - calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix1); -#endif - - std::cout.precision(16); - - const double vol1 = sumVolume(matrix1); - - if(!doubleTest) - { - LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); - - if(isTestReflexive) - { - CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); - } - } - else - { - - IntersectionMatrix matrix2; - calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix2); -#endif - - const double vol2 = sumVolume(matrix2); - - LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); - - CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testTranspose(matrix1, matrix2)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); - } - - } - - /** - * Utility method used to facilitate the call to intersect meshes. - * It calls intersectMeshes, using "mesh1.med" as file name for the mesh with name "mesh1" and - * "mesh2.med" as file name for the mesh with name "mesh2". The rest of the arguments are passed - * along as they are. - * - * @param mesh1 the name of the source mesh - * @param mesh2 the name of the target mesh - * @param correctVol the total volume of the intersection of the two meshes - * @param prec maximum relative error to be tolerated in volume comparisions - * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed - * - */ - template - void MeshTestToolkit::intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const - { - const string path1 = string(mesh1) + string(".med"); - std::cout << "here :" << path1 << std::endl; - const string path2 = string(mesh2) + string(".med"); - - intersectMeshes(path1.c_str(), mesh1, path2.c_str(), mesh2, correctVol, prec, doubleTest); - } - - -} diff --git a/src/INTERP_KERNELTest/MultiElement2DTests.hxx b/src/INTERP_KERNELTest/MultiElement2DTests.hxx deleted file mode 100644 index 5febf9dc3..000000000 --- a/src/INTERP_KERNELTest/MultiElement2DTests.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2010 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 __MULTI_ELEMENT_2D_TESTS_HXX_ -#define __MULTI_ELEMENT_2D_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting meshes of several - * polygonal elements - up to a few thousand. This serves to check the - * filtering methods and the matrix assemblage, as well as verifying - * that computation errors do not become unmanageable. It uses mehes of - * different geometries : triangle, quadrilateral. - * - */ - class MultiElement2DTests : public InterpolationTestSuite<2,2> - { - CPPUNIT_TEST_SUITE( MultiElement2DTests ); - - CPPUNIT_TEST(SymetryTranspose2DTest); - CPPUNIT_TEST(SelfIntersection2DTest); - - CPPUNIT_TEST_SUITE_END(); - - public: - void SymetryTranspose2DTest() - { - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - } - void SelfIntersection2DTest() - { - IntersectionMatrix m; - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - } - }; -} - -#endif diff --git a/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx b/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx deleted file mode 100644 index d7348d21a..000000000 --- a/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2010 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 __MULTI_ELEMENT_3DSurf_TESTS_HXX_ -#define __MULTI_ELEMENT_3DSurf_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting meshes of several - * polygonal elements - up to a few thousand. This serves to check the - * filtering methods and the matrix assemblage, as well as verifying - * that computation errors do not become unmanageable. It uses mehes of - * different geometries : triangle, quadrilateral. - * - */ - class MultiElement2DTests : public InterpolationTestSuite<3,2> - { - CPPUNIT_TEST_SUITE( MultiElement3DSurfTests ); - - CPPUNIT_TEST(SymetryTranspose3DSurfTest); - CPPUNIT_TEST(SelfIntersection3DSurfTest); - - CPPUNIT_TEST_SUITE_END(); - - public: - void SymetryTranspose3DSurfTest() - { - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->intersectMeshes("square1.med", "Mesh_2","square2.med","Mesh_3", 10000.); - } - void SelfIntersection3DSurfTest() - { - IntersectionMatrix m; - _testTools->_intersectionType=INTERP_KERNEL::Triangulation; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - _testTools->_intersectionType=INTERP_KERNEL::Convex; - _testTools->calcIntersectionMatrix("square1.med", "Mesh_2","square1.med","Mesh_2", m); - } - }; -} - -#endif diff --git a/src/INTERP_KERNELTest/MultiElementTetraTests.hxx b/src/INTERP_KERNELTest/MultiElementTetraTests.hxx deleted file mode 100644 index 74a4c416f..000000000 --- a/src/INTERP_KERNELTest/MultiElementTetraTests.hxx +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (C) 2007-2010 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 __MULTI_ELEMENT_TETRA_TESTS_HXX_ -#define __MULTI_ELEMENT_TETRA_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting meshes of several - * elements (all tetrahedra) - up to a few thousand. This serves to check the - * filtering methods and the matrix assemblage, as well as verifying - * that computation errors do not become unmanageable. It uses mehes of - * different geometries : tetrahedra, boxes and cylinders. - * - */ - class MultiElementTetraTests : public InterpolationTestSuite<3,3> - { - CPPUNIT_TEST_SUITE( MultiElementTetraTests ); - - CPPUNIT_TEST( tetraComplexIncluded ); - CPPUNIT_TEST( dividedUnitTetraSimplerReflexive ); - CPPUNIT_TEST( dividedUnitTetraReflexive ); - CPPUNIT_TEST( nudgedDividedUnitTetraSimpler ); - CPPUNIT_TEST( nudgedDividedUnitTetra ); - CPPUNIT_TEST( dividedGenTetra ); - CPPUNIT_TEST( tinyBoxReflexive ); - CPPUNIT_TEST( moderateBoxEvenSmallerReflexive ); - CPPUNIT_TEST( moderateBoxSmallReflexive ); - CPPUNIT_TEST( boxReflexive ); - CPPUNIT_TEST( boxReflexiveModerate ); - CPPUNIT_TEST( tetraBoxes ); - CPPUNIT_TEST( moderateBoxesSmaller ); - CPPUNIT_TEST( moderateBoxes ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - /// Tetrahedron situated totally inside another - /// \brief Status : pass - void tetraComplexIncluded() - { - _testTools->intersectMeshes("ComplexIncludedTetra", "ComplexIncludingTetra", 17.0156); - } - - /// Unit tetrahedron divided in 4 elements intersecting itself. - /// \brief Status : pass - void dividedUnitTetraSimplerReflexive() - { - _testTools->intersectMeshes("DividedUnitTetraSimpler", "DividedUnitTetraSimpler", 0.1666667); - } - - /// Unit tetrahedron divided in 14 elements intersecting itself. - /// \brief Status : pass - void dividedUnitTetraReflexive() - { - _testTools->intersectMeshes("DividedUnitTetra", "DividedUnitTetra", 0.1666667); - } - - /// Unit tetrahedron divided in 4 elements intersecting slightly displaced version of itself. - /// \brief Status : pass - void nudgedDividedUnitTetraSimpler() - { - _testTools->intersectMeshes("NudgedDividedUnitTetraSimpler", "DividedUnitTetraSimpler", 0.150191); - } - - /// Unit tetrahedron divided in 14 elements intersecting slightly displaced version of itself. - /// \brief Status : pass - void nudgedDividedUnitTetra() - { - _testTools->intersectMeshes("NudgedDividedUnitTetra", "DividedUnitTetra", 0.150191); - } - - /// Two intersecting tetrahedra in general position, one with 23 elements, the other with 643 elements - /// \brief Status : pass - void dividedGenTetra() - { - _testTools->intersectMeshes("DividedGenTetra1", "DividedGenTetra2", 0.546329); - } - - /// Large box in general position with 12 elements intersecting itself - /// \brief Status : pass - void tinyBoxReflexive() - { - _testTools->intersectMeshes("TinyBox", "TinyBox", 979200); - } - - /// Small box in general position with 33 elements intersecting itself - /// \brief Status : pass - void boxReflexive() - { - _testTools->intersectMeshes("Box3", "Box3", 13.9954); - } - - /// Box in general position with 67 elements intersecting itself - /// \brief Status : pass - void moderateBoxEvenSmallerReflexive() - { - _testTools->intersectMeshes("BoxEvenSmaller1", "BoxEvenSmaller1", 1.44018e6); - } - - /// Box in general position with 544 elements intersecting itself - /// \brief Status : pass - void moderateBoxSmallReflexive() - { - _testTools->intersectMeshes("BoxModSmall1", "BoxModSmall1", 1.44018e6); - } - - /// Large box in general position with 2943 elements intersecting itself - /// \brief Status : pass - void boxReflexiveModerate() - { - _testTools->intersectMeshes("Box1Moderate", "Box1Moderate", 1.0e6); - } - - /// Two intersecting boxes in general position with 12 and 18 elements - /// \brief Status : pass - void tetraBoxes() - { - _testTools->intersectMeshes("Box1", "Box2", 124.197); - } - - /// Two intersecting boxes in general position with 430 and 544 elements - /// \brief Status : pass - void moderateBoxesSmaller() - { - _testTools->intersectMeshes("BoxModSmall1", "BoxModSmall2", 321853); - } - - /// Two intersecting boxes in general position with 2943 and 3068 elements - /// \brief Status : pass - void moderateBoxes() - { - _testTools->intersectMeshes("Box1Moderate", "Box2Moderate", 376856); - } - - }; -} - -#endif diff --git a/src/INTERP_KERNELTest/PerfTest.cxx b/src/INTERP_KERNELTest/PerfTest.cxx deleted file mode 100644 index 1a5a532f7..000000000 --- a/src/INTERP_KERNELTest/PerfTest.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2007-2010 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 "Interpolation3D.hxx" -#include "Interpolation3D.txx" -#include "MeshTestToolkit.txx" -#include "Log.hxx" -#include "VectorUtils.hxx" -#include "TestInterpKernelUtils.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDNormalizedUnstructuredMesh.hxx" - -#include -#include - -using namespace MEDMEM; -using namespace MED_EN; - -/** - * \file PerfTest.cxx - * Test program which takes two meshes and calculates their intersection matrix. - * - * USAGE : PerfTest mesh1 mesh2 - * where mesh1 and mesh2 are the names of two meshes located in - * the files mesh1.med, mesh2.med in {$MED_ROOT_DIR}/share/salome/resources/med/ - * - */ - -namespace INTERP_TEST -{ - /** - * \brief Specialization of MeshTestToolkit for the purposes of performance testing. - * - */ - class PerfTestToolkit : public MeshTestToolkit<3,3> - { - - public: - - /** - * Calculates the intersection matrix for two meshes. - * Outputs the names of the meshes intersected, the number of elements in each mesh, - * the number of matrix elements and the number of non-zero matrix elements, etc. - * These values help to determine how well the filtering algorithm is working. - * - * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh1 the name of the source mesh - * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ - * @param mesh2 the name of the target mesh - * @param m intersection matrix in which to store the result of the intersection - */ - void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) - { - LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); - - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - const MESH sMesh(MED_DRIVER, INTERP_TEST::getResourceFile(mesh1path), mesh1); - - - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - const MESH tMesh(MED_DRIVER, INTERP_TEST::getResourceFile(mesh2path), mesh2); - - MEDNormalizedUnstructuredMesh<3,3> sMesh_wrapper(&sMesh); - MEDNormalizedUnstructuredMesh<3,3> tMesh_wrapper(&tMesh); - - Interpolation3D interpolator; - interpolator.interpolateMeshes(sMesh_wrapper, tMesh_wrapper,m,"P0P0"); - - std::pair eff = countNumberOfMatrixEntries(m); - LOG(1, eff.first << " of " << numTargetElems * numSrcElems << " intersections calculated : ratio = " - << double(eff.first) / double(numTargetElems * numSrcElems)); - LOG(1, eff.second << " non-zero elements of " << eff.first << " total : filter efficiency = " - << double(eff.second) / double(eff.first)); - - LOG(1, "Intersection calculation done. " << std::endl ); - - } - - /** - * Counts the number of elements in an intersection matrix, and the number of these which are non-zero. - * - * @param m the intersection matrix - * @return pair containing as its first element the number of elements in m and as its second element the - * number these which are non-zero - */ - std::pair countNumberOfMatrixEntries(const IntersectionMatrix& m) - { - - int numElems = 0; - int numNonZero = 0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - numElems += iter->size(); - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - if(!INTERP_KERNEL::epsilonEqual(iter2->second, 0.0, VOL_PREC)) - { - ++numNonZero; - } - } - } - return std::make_pair(numElems, numNonZero); - } - - }; -} - -/** - * Main method of the program. - * Intersects the meshes and outputs some information about the calculation as well as the - * intersection matrix on std::cout. - * - * @param argc number of arguments given to the program (should be 3, the user giving 2 mesh names) - * @param argv vector to the arguments as strings. - */ -int main(int argc, char** argv) -{ - using INTERP_TEST::PerfTestToolkit; - - assert(argc == 3); - - // load meshes - const string mesh1 = argv[1]; - const string mesh2 = argv[2]; - - const string mesh1path = mesh1 + ".med"; - const string mesh2path = mesh2 + ".med"; - - IntersectionMatrix m; - - PerfTestToolkit testTools; - - testTools.calcIntersectionMatrix(mesh1path.c_str(), mesh1.c_str(), mesh2path.c_str(), mesh2.c_str(), m); - - testTools.dumpIntersectionMatrix(m); - - return 0; - -} - diff --git a/src/INTERP_KERNELTest/PointLocatorTest.cxx b/src/INTERP_KERNELTest/PointLocatorTest.cxx deleted file mode 100644 index 7262908c3..000000000 --- a/src/INTERP_KERNELTest/PointLocatorTest.cxx +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2007-2010 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 "PointLocatorTest.hxx" -#include "PointLocator.hxx" -#include "MEDMeshMaker.hxx" -#include "MEDMEM_Mesh.hxx" - -#include -#include - -namespace INTERP_TEST -{ - - - void PointLocatorTest::setUp() - { - } - - - void PointLocatorTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check 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_PointLocator() { - MEDMEM::MESH* mesh2D= MEDMeshMaker(2,2,MED_EN::MED_QUAD4); - MEDMEM::PointLocator pl(*mesh2D) ; - double x[2]={0.0,0.0}; - std::list elems = pl.locate(x); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)(*(elems.begin()))); - elems.clear(); - - double x2[2]={0.25,0.25}; - elems = pl.locate(x2); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)(*(elems.begin()))); - elems.clear(); - - double x3[2]={0.5,0.5}; - elems = pl.locate(x3); - CPPUNIT_ASSERT_EQUAL(4,(int)elems.size()); - elems.clear(); - - double x4[2]={-1.0,0.0}; - elems = pl.locate(x4); - CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); - elems.clear(); - delete mesh2D; - - MEDMEM::MESH* mesh3D= MEDMeshMaker(3,2,MED_EN::MED_HEXA8); - MEDMEM::PointLocator pl3(*mesh3D); - double xx[3]={0.0,0.0,0.0}; - elems = pl3.locate(xx); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)*(elems.begin())); - elems.clear(); - - double xx2[3]={0.25,0.25,0.25}; - elems = pl3.locate(xx2); - CPPUNIT_ASSERT_EQUAL(1,(int)elems.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)*(elems.begin())); - elems.clear(); - - double xx3[3]={0.5,0.5,0.5}; - elems = pl3.locate(xx3); - CPPUNIT_ASSERT_EQUAL(8,(int)elems.size()); - elems.clear(); - - double xx4[3]={-1.0,0.0,0.0}; - elems = pl3.locate(xx4); - CPPUNIT_ASSERT_EQUAL(0,(int)elems.size()); - elems.clear(); - delete mesh3D; - - } - - -} diff --git a/src/INTERP_KERNELTest/PointLocatorTest.hxx b/src/INTERP_KERNELTest/PointLocatorTest.hxx deleted file mode 100644 index 1607b0049..000000000 --- a/src/INTERP_KERNELTest/PointLocatorTest.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_POINTLOCATOR_HXX__ -#define __TU_POINTLOCATOR_HXX__ - -#include - -#include "InterpKernelTestExport.hxx" -#include "PointLocator.hxx" - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class INTERPKERNELTEST_EXPORT PointLocatorTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( PointLocatorTest ); - CPPUNIT_TEST( test_PointLocator ); - CPPUNIT_TEST_SUITE_END(); - - - public: - void setUp(); - - void tearDown(); - - // tests - void test_PointLocator(); - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx deleted file mode 100644 index 13b30fd96..000000000 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx +++ /dev/null @@ -1,1022 +0,0 @@ -// Copyright (C) 2007-2010 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 "QuadraticPlanarInterpTest.hxx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" -#include "InterpKernelGeo2DComposedEdge.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" -#include "TestInterpKernelUtils.hxx" - -#include -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - -static const double ADMISSIBLE_ERROR = 1.e-14; - -void QuadraticPlanarInterpTest::setUp() -{ -} - -void QuadraticPlanarInterpTest::tearDown() -{ -} - -void QuadraticPlanarInterpTest::cleanUp() -{ -} - -void QuadraticPlanarInterpTest::ReadWriteInXfigElementary() -{ - //Testing bounds calculation. For Seg2 - std::istringstream stream("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4700"); - EdgeLin *e1=new EdgeLin(stream); - Bounds bound=e1->getBounds(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,bound[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,bound[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,bound[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.47,bound[3],ADMISSIBLE_ERROR); - e1->decrRef(); - std::istringstream stream2("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n4500 4700 3200 3400"); - e1=new EdgeLin(stream2); - bound=e1->getBounds(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,bound[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,bound[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,bound[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.47,bound[3],ADMISSIBLE_ERROR); - e1->decrRef(); - //Testing bounds calculation For Arc of circle. - -} - -void QuadraticPlanarInterpTest::ReadWriteInXfigGlobal() -{ - QuadraticPolygon pol1(INTERP_TEST::getResourceFile("Pol1.fig").c_str()); - pol1.dumpInXfigFile("Pol1_gen.fig"); - QuadraticPolygon pol2(INTERP_TEST::getResourceFile("Pol2.fig").c_str()); - pol2.dumpInXfigFile("Pol2_gen.fig"); - QuadraticPolygon pol3(INTERP_TEST::getResourceFile("Pol3.fig").c_str()); - pol3.dumpInXfigFile("Pol3_gen.fig"); - QuadraticPolygon pol4(INTERP_TEST::getResourceFile("Pol4.fig").c_str()); - CPPUNIT_ASSERT_EQUAL(1,pol4.size()); - ElementaryEdge *edge1=dynamic_cast(pol4[0]); - CPPUNIT_ASSERT(edge1); - Edge *edge2=edge1->getPtr(); - EdgeArcCircle *edge=dynamic_cast(edge2); - CPPUNIT_ASSERT(edge); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7857653289925404,edge->getAngle(),ADMISSIBLE_ERROR); - double center[2]; - edge->getCenter(center); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,center[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48375,center[1],ADMISSIBLE_ERROR); - const double *start=*edge->getStartNode(); - Node *n1=new Node(start[0]+2*(center[0]-start[0]),start[1]+2*(center[1]-start[1])); - edge->changeMiddle(n1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7857653289925404,edge->getAngle(),ADMISSIBLE_ERROR); - n1->decrRef(); - n1=new Node(center[0],center[1]+0.24375); - edge->changeMiddle(n1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.49741997818704586,edge->getAngle(),ADMISSIBLE_ERROR);//5.7857653289925404 + 2*PI - n1->decrRef(); - //A half circle. - EdgeArcCircle *e=new EdgeArcCircle(0.84,0.54,0.78,0.6,0.84,0.66); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.06,e->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.1415925921507317,e->getAngle(),1e-5); - e->decrRef(); - e=new EdgeArcCircle(0.84,0.54,0.9,0.6,0.84,0.66); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.06,e->getRadius(),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415925921507317,e->getAngle(),1e-5); - e->decrRef(); -} - -void QuadraticPlanarInterpTest::BasicGeometricTools() -{ - Node *n1=new Node(1.,1.); - Node *n2=new Node(4.,2.); - EdgeLin *e1=new EdgeLin(n1,n2); - double tmp[2]; - e1->getNormalVector(tmp); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.94868329805051377,tmp[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.31622776601683794,tmp[0],ADMISSIBLE_ERROR); - e1->decrRef(); - n1->decrRef(); n2->decrRef(); - n1=new Node(1.,1.); - n2=new Node(0.,4.); - e1=new EdgeLin(n1,n2); - double tmp2[2]; - e1->getNormalVector(tmp2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,Node::dot(tmp,tmp2),1e-10); - tmp[0]=0.5; tmp[1]=2.5; - CPPUNIT_ASSERT(e1->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,e1->getDistanceToPoint(tmp),1e-12); - tmp[1]=2.55; CPPUNIT_ASSERT(!e1->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0158113883008418,e1->getDistanceToPoint(tmp),1e-12); - tmp[0]=0.; tmp[1]=5.; - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,e1->getDistanceToPoint(tmp),1e-12); - EdgeArcCircle *e=new EdgeArcCircle(4.,3.,0.,5.,-5.,0.); - tmp[0]=-4.; tmp[1]=3.; - CPPUNIT_ASSERT(e->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,e->getDistanceToPoint(tmp),1e-12); - tmp[1]=3.1; CPPUNIT_ASSERT(!e->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.0632371551998077e-2,e->getDistanceToPoint(tmp),1e-12); - tmp[0]=-4.; tmp[1]=-3.; - CPPUNIT_ASSERT(!e->isNodeLyingOn(tmp)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1622776601683795,e->getDistanceToPoint(tmp),1e-12); - e->decrRef(); - e1->decrRef(); - n1->decrRef(); n2->decrRef(); -} - -void QuadraticPlanarInterpTest::IntersectionBasics() -{ - //Testing intersection of Bounds. - std::istringstream stream1("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); - EdgeLin *e1=new EdgeLin(stream1); - std::istringstream stream2("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); - EdgeLin *e2=new EdgeLin(stream2); - Bounds *bound=e1->getBounds().amIIntersectingWith(e2->getBounds()); CPPUNIT_ASSERT(bound); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,(*bound)[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,(*bound)[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.34,(*bound)[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,(*bound)[3],ADMISSIBLE_ERROR); - delete bound; - e2->decrRef(); e1->decrRef(); - // - std::istringstream stream3("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3000 7200 6000 3700"); - EdgeLin *e3=new EdgeLin(stream3); - std::istringstream stream4("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n4800 6600 7200 4200"); - EdgeLin *e4=new EdgeLin(stream4); - bound=e3->getBounds().amIIntersectingWith(e4->getBounds()); CPPUNIT_ASSERT(bound); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,(*bound)[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.6,(*bound)[1],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.42,(*bound)[2],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.66,(*bound)[3],ADMISSIBLE_ERROR); - delete bound; - e3->decrRef(); e4->decrRef(); -} - -void QuadraticPlanarInterpTest::EdgeLinUnitary() -{ - EdgeLin *e1=new EdgeLin(0.5,0.5,3.7,4.1); - Node *n=new Node(2.1,2.3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),0.5,1e-8); - n->decrRef(); - n=new Node(3.7,4.1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),1.,1e-8); - n->decrRef(); - n=new Node(0.5,0.5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),0.,1e-8); - n->decrRef(); - n=new Node(-1.1,-1.3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),-0.5,1e-8); - n->decrRef(); - n=new Node(5.3,5.9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),1.5,1e-8); - n->decrRef(); e1->decrRef(); -} - -/*! - * Here two things are tested. - * 1 ) One the overlapping calculation capability of edge/edge intersector. - * 2 ) Then the capability to handle the case where 2 segs (whatever their type) are overlapped. - * All the configuration of full or part overlapping have been tested. - */ -void QuadraticPlanarInterpTest::IntersectionEdgeOverlapUnitarySegSeg() -{ - ComposedEdge& v1=*(new ComposedEdge); - ComposedEdge& v2=*(new ComposedEdge); - MergePoints v3; - //Testing merge of geometric equals seg2. - Edge *e1=new EdgeLin(0.5,0.5,1.,1.); Edge *e2=new EdgeLin(0.5,0.5,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - v1.clear(); v2.clear(); v3.clear(); - // - testing by adding some noise - e1->decrRef(); e1=new EdgeLin(0.5+5.e-15,0.5-5.e-15,1.,1.+7.e-15); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Testing merge of geometric equals seg2 but now with opposite direction - e1=new EdgeLin(0.5,0.5,0.7,0.7); e2=new EdgeLin(0.7+6.e-15,0.7-2.e-15,0.5+3.e-15,0.5-4.e-15); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection());//compared 8 lines above !v2[0]->getDirection() - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 0 - //Test 1 - OUT_AFTER - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.5,0.,2.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.5,0.,1.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.5,0.,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,1.5,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqualDirSensitive(v2[0])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - INSIDE - OUT_AFTER | opp. dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.5,1.5,0.5,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(!v1[1]->intresicEqualDirSensitive(v2[1]) && v1[1]->intresicEqual(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.25,0.,0.75,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.25,0.,0.75); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.25,0.25,0.75,0.75); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - INSIDE - INSIDE | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.75,0.75,0.25,0.25); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && !v1[1]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==v1[2]->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()== e1->getStartNode()); CPPUNIT_ASSERT(v1[2]->getEndNode()== e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | opp dir. - double center[2]={0.,0.}; - double radius=1.; - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-2*M_PI/3.+2*M_PI,-M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(!v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(!v2[2]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | same dir. - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-M_PI/3.,-2*M_PI/3.+2*M_PI); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | opp dir. | e1<->e2 to test symetry - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-2*M_PI/3.+2*M_PI,-M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e2->intersectWith(e1,v3,v2,v1)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(!v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(!v1[2]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-5); // << not maximal precision because node switching - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3bis - INSIDE - INSIDE - Bis | same dir. | e1<->e2 to test symetry - e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-M_PI/3.,-2*M_PI/3.+2*M_PI); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. - CPPUNIT_ASSERT(e2->intersectWith(e1,v3,v2,v1)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[2]->getPtr())); CPPUNIT_ASSERT(v1[0]->getDirection()); CPPUNIT_ASSERT(v2[2]->getDirection()); - CPPUNIT_ASSERT(v1[2]->intresincEqCoarse(v2[0]->getPtr())); CPPUNIT_ASSERT(v1[2]->getDirection()); CPPUNIT_ASSERT(v2[0]->getDirection()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-5); // << not maximal precision because node switching - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getStartNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e2->getStartNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 4 - OUT_BEFORE - OUT_BEFORE | same dir. - 0 ° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-1.,0.,-0.5,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,0.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0,-0.5,0.,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,0.5,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqualDirSensitive(v2[1])); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 5 - OUT_BEFORE - INSIDE | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,-0.5,-0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(!v1[0]->intresicEqualDirSensitive(v2[0]) && v1[0]->intresicEqual(v2[0]) ); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,1.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,-0.5,0.,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,1.5,1.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 6 - OUT_BEFORE - OUT_AFTER | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.5,1.5,-0.5,-0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && !v2[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode() && v2[1]->getEndNode()==v2[2]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 7 - END - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,0.,1.5,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 7 - END - OUT_AFTER | opp dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.5,0.,1.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | same dir. - 0° - e1=new EdgeLin(0.,0.,0.7,0.); e2=new EdgeLin(0.,0.,0.7,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,0.7); e2=new EdgeLin(0.,0.,0.,0.7); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | same dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.,0.,0.7,0.7); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 8 - START - END | opp. dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.7,0.7,0.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 9 - OUT_BEFORE - START | same dir. - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,0.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(0,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v2.size()); - CPPUNIT_ASSERT(e2->getEndNode()==e1->getStartNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | same dir. - 0° - e1=new EdgeLin(0.,0.,0.7,0.); e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,0.7); e2=new EdgeLin(0.,0.,0.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | same dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(0.,0.,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 10 - START - OUT_AFTER | opp dir. - 45° - e1=new EdgeLin(0.,0.,0.7,0.7); e2=new EdgeLin(1.,1.,0.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && !v2[1]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.7,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.7,0.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.7,0.7,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 11 - INSIDE - END | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,1.,0.7,0.7); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(e1->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(e2) && !v1[1]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(-0.5,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,-0.5,0.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(-0.5,-0.5,1.,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[1]->intresincEqCoarse(e1) && v2[1]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 12 - OUT_BEFORE - END | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,1.,-0.5,-0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e1) && !v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v2[0]->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==e2->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==v2[1]->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | same dir. - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.,0.,0.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | same dir. - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.,0.,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | same dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.,0.,0.5,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getStartNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 13 - START - INSIDE | opp dir. - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.5,0.5,0.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e2) && !v1[0]->getDirection()); CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(e2->getEndNode()==v1[0]->getStartNode()); CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e1->getEndNode()==v1[1]->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 14 - INSIDE - START | same dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,M_PI/3.,-M_PI); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresicEqual(v2[0])); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2*M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v2[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 14 - INSIDE - START | opp dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,-M_PI,M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[1]->intresincEqCoarse(v2[1]->getPtr()) && !v2[1]->getDirection() && v1[1]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2*M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[0]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 15 - END - INSIDE | same dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,0.,-4.*M_PI/3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresicEqual(v2[1])); - CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.*M_PI/3.,v1[1]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 15 - END - INSIDE | opp dir. - e1=buildArcOfCircle(center,radius,-M_PI,2.*M_PI); e2=buildArcOfCircle(center,radius,-4.*M_PI/3,0.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.*M_PI/3.,e2->getCurveLength(),1e-12); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(v2[0]->getPtr()) && !v2[0]->getDirection() && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getEndNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode()); - CPPUNIT_ASSERT(v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v2[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/3.,v1[0]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,v2[1]->getCurveLength(),1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.*M_PI/3.,v1[1]->getCurveLength(),1.e-12); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - // - ComposedEdge::Delete(&v1); - ComposedEdge::Delete(&v2); -} - -/*! - * Here there is test of cases where between 2 edges intersects only in points not on edge. - */ -void QuadraticPlanarInterpTest::IntersectionPointOnlyUnitarySegSeg() -{ - // 0° - classical - EdgeLin *e1=new EdgeLin(0.,0.,1.,0.); - EdgeLin *e2=new EdgeLin(0.3,0.3,0.5,-0.3); - ComposedEdge& v1=*(new ComposedEdge); - ComposedEdge& v2=*(new ComposedEdge); MergePoints v3; - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,(*v1[0]->getEndNode())[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,(*v1[0]->getEndNode())[1],ADMISSIBLE_ERROR); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - // 90° - classical - e1=new EdgeLin(0.,0.,0.,1.); - e2=new EdgeLin(-0.3,0.3,0.3,0.5); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT(v1[0]->getEndNode()==v1[1]->getStartNode()); CPPUNIT_ASSERT(v2[0]->getEndNode()==v2[1]->getStartNode()); - CPPUNIT_ASSERT(e1->getStartNode()==v1.front()->getStartNode() && e1->getEndNode()==v1.back()->getEndNode()); - CPPUNIT_ASSERT(e2->getStartNode()==v2.front()->getStartNode() && e2->getEndNode()==v2.back()->getEndNode()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,(*v1[0]->getEndNode())[0],ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,(*v1[0]->getEndNode())[1],ADMISSIBLE_ERROR); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 1 - 0° - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(0.,0.,0.,1.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 1 - 90° - e1=new EdgeLin(0.,0.,0.,1.); e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 1 - 45° - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(0.,0.,1.,-1.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 2 - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,1.,1.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isEnd1(0)); CPPUNIT_ASSERT(v3.isEnd2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 3 - e1=new EdgeLin(0.,0.,1.,0.); e2=new EdgeLin(1.,0.,1.,1.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isEnd1(0)); CPPUNIT_ASSERT(v3.isStart2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Test 4 - e1=new EdgeLin(0.,0.,1.,1.); e2=new EdgeLin(1.,-1.,0.,0.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v3.isStart1(0)); CPPUNIT_ASSERT(v3.isEnd2(0)); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 2 End. - e1=new EdgeLin(0.,0.,1.,0.); - e2=new EdgeLin(0.5,1.,0.5,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode() && v1[0]->getEndNode()==e2->getEndNode() && v1[1]->getStartNode()==e2->getEndNode() && v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getDirection() && v1[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 2 Start. - e1=new EdgeLin(0.,0.,1.,0.); - e2=new EdgeLin(0.5,0.,0.5,1.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(2,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(1,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v2[0]->intresincEqCoarse(e2) && v2[0]->getDirection()); - CPPUNIT_ASSERT(v1[0]->getStartNode()==e1->getStartNode() && v1[0]->getEndNode()==e2->getStartNode() && v1[1]->getStartNode()==e2->getStartNode() && v1[1]->getEndNode()==e1->getEndNode()); - CPPUNIT_ASSERT(v1[0]->getDirection() && v1[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 1 Start. - e1=new EdgeLin(0.5,0.,0.5,1.); - e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e2->getStartNode() && v2[0]->getEndNode()==e1->getStartNode() && v2[1]->getStartNode()==e1->getStartNode() && v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getDirection() && v2[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - //Intersection extremity of one edge and inside of other edge. 1 End. - e1=new EdgeLin(0.5,1.,0.5,0.); - e2=new EdgeLin(0.,0.,1.,0.); - CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); - CPPUNIT_ASSERT_EQUAL(1,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(2,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(v1[0]->intresincEqCoarse(e1) && v1[0]->getDirection()); - CPPUNIT_ASSERT(v2[0]->getStartNode()==e2->getStartNode() && v2[0]->getEndNode()==e1->getEndNode() && v2[1]->getStartNode()==e1->getEndNode() && v2[1]->getEndNode()==e2->getEndNode()); - CPPUNIT_ASSERT(v2[0]->getDirection() && v2[1]->getDirection()); - e2->decrRef(); e1->decrRef(); - v1.clear(); v2.clear(); v3.clear(); - ComposedEdge::Delete(&v2); - ComposedEdge::Delete(&v1); -} - -} diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx deleted file mode 100644 index 7db081b61..000000000 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (C) 2007-2010 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 _QUADRATICPLANARINTERPTEST_HXX_ -#define _QUADRATICPLANARINTERPTEST_HXX_ - -#include - -#include "InterpKernelTestExport.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - class INTERPKERNELTEST_EXPORT QuadraticPlanarInterpTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE( QuadraticPlanarInterpTest ); - CPPUNIT_TEST( ReadWriteInXfigElementary ); - CPPUNIT_TEST( ReadWriteInXfigGlobal ); - CPPUNIT_TEST( BasicGeometricTools ); - CPPUNIT_TEST( IntersectionBasics ); - CPPUNIT_TEST( EdgeLinUnitary ); - CPPUNIT_TEST( IntersectionEdgeOverlapUnitarySegSeg ); - CPPUNIT_TEST( IntersectionPointOnlyUnitarySegSeg ); - CPPUNIT_TEST( IntersectArcCircleBase ); - CPPUNIT_TEST( IntersectArcCircleFull ); - CPPUNIT_TEST( IntersectArcCircleSegumentBase ); - CPPUNIT_TEST( checkInOutDetection ); - CPPUNIT_TEST( checkAssemblingBases1 ); - CPPUNIT_TEST( checkAssemblingBases2 ); - CPPUNIT_TEST( checkPolygonsIntersection1 ); - CPPUNIT_TEST( checkPolygonsIntersection2 ); - CPPUNIT_TEST( checkAreasCalculations ); - CPPUNIT_TEST( checkBarycenterCalculations ); - CPPUNIT_TEST( checkHighLevelFunctionTest1 ); - CPPUNIT_TEST( check1DInterpLin ); - CPPUNIT_TEST( checkEpsilonCoherency1 ); - CPPUNIT_TEST( checkNonRegression1 ); - CPPUNIT_TEST( checkNonRegression2 ); - CPPUNIT_TEST( checkNonRegression3 ); - CPPUNIT_TEST( checkNonRegression4 ); - CPPUNIT_TEST( checkNonRegression5 ); - CPPUNIT_TEST( checkNonRegression6 ); - CPPUNIT_TEST( checkNonRegression7 ); - CPPUNIT_TEST( checkNonRegression8 ); - CPPUNIT_TEST( checkNonRegression9 ); - CPPUNIT_TEST( checkNonRegression10 ); - CPPUNIT_TEST( checkNonRegression11 ); - CPPUNIT_TEST( checkNonRegression12 ); - CPPUNIT_TEST ( checkNonRegression13 ); - CPPUNIT_TEST ( checkNonRegression14 ); - CPPUNIT_TEST ( checkNonRegression15 ); - CPPUNIT_TEST ( checkNonRegression16 ); - CPPUNIT_TEST ( checkNonRegression17 ); - // - CPPUNIT_TEST ( checkNonRegressionOmar0000 ); - CPPUNIT_TEST ( checkNonRegressionOmar0001 ); - CPPUNIT_TEST ( checkNonRegressionOmar0002 ); - CPPUNIT_TEST ( checkNonRegressionOmar0003 ); - CPPUNIT_TEST ( checkNonRegressionOmar0004 ); - CPPUNIT_TEST ( checkNonRegressionOmar0005 ); - CPPUNIT_TEST ( checkNonRegressionOmar0006 ); - CPPUNIT_TEST ( checkNonRegressionOmar0007 ); - CPPUNIT_TEST ( checkNonRegressionOmar0008 ); - CPPUNIT_TEST ( checkNonRegressionOmar0009 ); - CPPUNIT_TEST ( checkNonRegressionOmar0010 ); - CPPUNIT_TEST ( checkNonRegressionOmar0011 ); - CPPUNIT_TEST ( checkNonRegressionOmar2511 ); - CPPUNIT_TEST ( checkNonRegressionOmar0012 ); - CPPUNIT_TEST ( checkNonRegressionOmar0013 ); - CPPUNIT_TEST ( checkNonRegressionOmar0014 ); - CPPUNIT_TEST ( checkNonRegressionOmar0015 ); - CPPUNIT_TEST ( checkNonRegressionOmar0016 ); - CPPUNIT_TEST ( checkNonRegressionOmar0017 ); - CPPUNIT_TEST ( checkNonRegressionOmar0018 ); - CPPUNIT_TEST ( checkNonRegressionOmar0019 ); - CPPUNIT_TEST ( checkNonRegressionOmar0020 ); - CPPUNIT_TEST ( checkNonRegressionOmar0021 ); - CPPUNIT_TEST ( checkNonRegressionOmar0022 ); - CPPUNIT_TEST ( checkNonRegressionOmar0023 ); - CPPUNIT_TEST ( checkNonRegressionOmar0024 ); - CPPUNIT_TEST ( checkNonRegressionOmar2524 ); - CPPUNIT_TEST ( checkNonRegressionOmar0025 ); - CPPUNIT_TEST ( checkNonRegressionOmar0026 ); - CPPUNIT_TEST ( checkNonRegressionOmar0027 ); - CPPUNIT_TEST ( checkNonRegressionOmar0028 ); - CPPUNIT_TEST ( checkNonRegressionOmar0029 ); - CPPUNIT_TEST ( checkNonRegressionOmar0030 ); - // - CPPUNIT_TEST( checkNormalize ); - CPPUNIT_TEST_SUITE_END(); - public: - void setUp(); - void tearDown(); - void cleanUp(); - // - void ReadWriteInXfigElementary(); - void ReadWriteInXfigGlobal(); - void BasicGeometricTools(); - void IntersectionBasics(); - void EdgeLinUnitary(); - void IntersectionEdgeOverlapUnitarySegSeg(); - void IntersectionPointOnlyUnitarySegSeg(); - // - void IntersectArcCircleBase(); - void IntersectArcCircleFull(); - void IntersectArcCircleSegumentBase(); - // - void checkInOutDetection(); - // - void checkAssemblingBases1(); - void checkAssemblingBases2(); - // - void checkPolygonsIntersection1(); - void checkPolygonsIntersection2(); - void checkAreasCalculations(); - void checkBarycenterCalculations(); - // - void checkHighLevelFunctionTest1(); - // - void check1DInterpLin(); - // - void checkEpsilonCoherency1(); - // - void checkNonRegression1(); - void checkNonRegression2(); - void checkNonRegression3(); - void checkNonRegression4(); - void checkNonRegression5(); - void checkNonRegression6(); - void checkNonRegression7(); - void checkNonRegression8(); - void checkNonRegression9(); - void checkNonRegression10(); - void checkNonRegression11(); - void checkNonRegression12(); - void checkNonRegression13(); - void checkNonRegression14(); - void checkNonRegression15(); - void checkNonRegression16(); - void checkNonRegression17(); - // - void checkNonRegressionOmar0000(); - void checkNonRegressionOmar0001(); - void checkNonRegressionOmar0002(); - void checkNonRegressionOmar0003(); - void checkNonRegressionOmar0004(); - void checkNonRegressionOmar0005(); - void checkNonRegressionOmar0006(); - void checkNonRegressionOmar0007(); - void checkNonRegressionOmar0008(); - void checkNonRegressionOmar0009(); - void checkNonRegressionOmar0010(); - void checkNonRegressionOmar0011(); - void checkNonRegressionOmar2511(); - void checkNonRegressionOmar0012(); - void checkNonRegressionOmar0013(); - void checkNonRegressionOmar0014(); - void checkNonRegressionOmar0015(); - void checkNonRegressionOmar0016(); - void checkNonRegressionOmar0017(); - void checkNonRegressionOmar0018(); - void checkNonRegressionOmar0019(); - void checkNonRegressionOmar0020(); - void checkNonRegressionOmar0021(); - void checkNonRegressionOmar0022(); - void checkNonRegressionOmar0023(); - void checkNonRegressionOmar0024(); - void checkNonRegressionOmar2524(); - void checkNonRegressionOmar0025(); - void checkNonRegressionOmar0026(); - void checkNonRegressionOmar0027(); - void checkNonRegressionOmar0028(); - void checkNonRegressionOmar0029(); - void checkNonRegressionOmar0030(); - // - void checkNormalize(); - private: - QuadraticPolygon *buildQuadraticPolygonCoarseInfo(const double *coords, const int *conn, int lgth); - EdgeArcCircle *buildArcOfCircle(const double *center, double radius, double alphaStart, double alphaEnd); - double btw2NodesAndACenter(const Node& n1, const Node& n2, const double *center); - void checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection); - }; -} - -#endif diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx deleted file mode 100644 index 7369c3068..000000000 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx +++ /dev/null @@ -1,674 +0,0 @@ -// Copyright (C) 2007-2010 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 "QuadraticPlanarInterpTest.hxx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" - -#include -#include -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - -static const double ADMISSIBLE_ERROR = 1.e-14; - -void QuadraticPlanarInterpTest::IntersectArcCircleBase() -{ - double center[2]={0.5,0.5}; - double radius=0.3; - EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/3),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,M_PI/3.,M_PI/2.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/2),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/2),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,M_PI/3.,3.*M_PI/4.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(3*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(3*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/2),ADMISSIBLE_ERROR);//<< - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,3*M_PI/4,7*M_PI/8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(7*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(3*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(7*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(3*M_PI/4),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,7.*M_PI/8.,9.*M_PI/8.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI),ADMISSIBLE_ERROR);//<< - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(7*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(9*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(7*M_PI/8),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,9.*M_PI/8.,11.*M_PI/8.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(9*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(11*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(11*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(9*M_PI/8),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,11.*M_PI/8.,7.*M_PI/4.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(11*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(7*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(3*M_PI/2),ADMISSIBLE_ERROR);//<< - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(7*M_PI/4),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,7.*M_PI/4.,15.*M_PI/8.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(7*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(15*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(7*M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(15*M_PI/8),ADMISSIBLE_ERROR); - e1->decrRef(); - // - e1=buildArcOfCircle(center,radius,-M_PI/8.,M_PI/4.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/4),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(0.),ADMISSIBLE_ERROR); //<< - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[2],center[1]+radius*sin(15*M_PI/8),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[3],center[1]+radius*sin(M_PI/4),ADMISSIBLE_ERROR); - e1->decrRef(); - // - // ArcCArcCIntersector - // - TypeOfLocInEdge where1,where2; - std::vector v4; - MergePoints v3; - EdgeArcCircle *e2; - ArcCArcCIntersector *intersector=0; - for(unsigned k=0;k<8;k++) - { - e1=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); - e2=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==START && where2==END); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,7*M_PI/24.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==INSIDE && where2==END); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,7*M_PI/24.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==START && where2==INSIDE); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,13.*M_PI/48.+k*M_PI/4.,15*M_PI/48.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==INSIDE && where2==INSIDE); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,-M_PI/4.+k*M_PI/4.,M_PI/6.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==OUT_BEFORE && where2==OUT_BEFORE); - delete intersector; v3.clear(); e2->decrRef(); - // - e2=buildArcOfCircle(center,radius,0+k*M_PI/4.,5*M_PI/6.+k*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - intersector->getPlacements(e2->getStartNode(),e2->getEndNode(),where1,where2,v3); - CPPUNIT_ASSERT(where1==OUT_BEFORE && where2==OUT_AFTER); - delete intersector; v3.clear(); e2->decrRef(); - e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 > R2 ; dist(circle1,circle2)>R1; Opposite order. - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); - e2=buildArcOfCircle(center2,1.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 > R2 ; dist(circle1,circle2)>R1; Same order. - for(unsigned k=0;k<7;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); - e2=buildArcOfCircle(center2,1.,M_PI+(k+1)*M_PI/4.,M_PI+(k-1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // 2 intersections R1>R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // 2 intersections R1>R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)>R2; Opposite order. - for(unsigned k=0;k<1;k++) - { - double center2[2]; center[0]=0.; center[1]=0.; - center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,1.,(k-1)*M_PI/4.,(k+1)*M_PI/4.); - e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)>R2; same order. - for(unsigned k=0;k<8;k++) - { - double center2[2]; center[0]=0.; center[1]=0.; - center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,1.,(k+1)*M_PI/4.,(k-1)*M_PI/4.); - e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Ok now let's see intersection only. 2 intersections R1 < R2 ; dist(circle1,circle2)areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); - CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Tangent intersection - QUADRATIC_PLANAR::setPrecision(1e-5); - for(unsigned k=0;k<8;k++) - { - double center2[2]; center[0]=0.; center[1]=0.; - center2[0]=4.*cos(k*M_PI/4.); center2[1]=4.*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,1.,(k+1)*M_PI/4.,(k-1)*M_PI/4.); - e2=buildArcOfCircle(center2,3.,M_PI+(k-1)*M_PI/4.,M_PI+(k+1)*M_PI/4.); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); // order has no sence here because v4.size() expected to 1 but for valgrind serenity test. - CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); - v4.clear(); v4.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - QUADRATIC_PLANAR::setPrecision(1e-14); - // Extremities # 1 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.-0.55978664859225125,M_PI+k*M_PI/4.+0.55978664859225125); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(!intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT_EQUAL(0,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getEndNode()); CPPUNIT_ASSERT(e2->getStartNode()==e1->getEndNode()); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.55978664859225125,M_PI+k*M_PI/4.-0.55978664859225125); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(!intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT_EQUAL(0,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(2,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e2->getEndNode()==e1->getEndNode()); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Extremities # 2 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.55978664859225125,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); - CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(1,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==e2->getStartNode()); CPPUNIT_ASSERT(e1->getEndNode()==v4[0]); - v4[0]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Extremities # 3 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - e1=buildArcOfCircle(center,3.,k*M_PI/4.-0.17793931986099812,k*M_PI/4.+0.17793931986099812); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); CPPUNIT_ASSERT(e1->getEndNode()==v4[1]); - v4[0]->decrRef(); v4[1]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - // Extremities # 4 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - Node *nodeS=new Node(center[0]+3.*cos(k*M_PI/4.-0.17793931986099812),center[1]+3.*sin(k*M_PI/4.-0.17793931986099812)); - Node *nodeE=new Node(center[0]+3.*cos(k*M_PI/4.),center[1]+3.*sin(k*M_PI/4.)); - double angle=k*M_PI/4.-0.17793931986099812; - angle=angle>M_PI?angle-2.*M_PI:angle; - e1=new EdgeArcCircle(nodeS,nodeE,//Problem of precision 1e-14 to easily reached. - center,3.,angle,0.17793931986099812); - nodeS->decrRef(); nodeE->decrRef(); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); - v4[0]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } - //Extremities # 5 - for(unsigned k=0;k<8;k++) - { - center[0]=0.; center[1]=0.; - double center2[2]; center2[0]=3.8*cos(k*M_PI/4.); center2[1]=3.8*sin(k*M_PI/4.); - Node *nodeS=new Node(center[0]+3.*cos(k*M_PI/4.-0.17793931986099812),center[1]+3.*sin(k*M_PI/4.-0.17793931986099812)); - Node *nodeE=new Node(center[0]+3.*cos(k*M_PI/4.)+0.5,center[1]+3.*sin(k*M_PI/4.)); - double angle=k*M_PI/4.-0.17793931986099812; - angle=angle>M_PI?angle-2.*M_PI:angle; - e1=new EdgeArcCircle(nodeS,nodeE,//Problem of precision 1e-14 to easily reached. - center,3.,angle,0.67793931986099812); - nodeS->decrRef(); nodeE->decrRef(); - e2=buildArcOfCircle(center2,1.,M_PI+k*M_PI/4.+0.7,M_PI+k*M_PI/4.-0.7); - intersector=new ArcCArcCIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT(e1->getStartNode()==v4[0]); - v4[0]->decrRef(); v4[1]->decrRef(); - v4.clear(); v3.clear(); - delete intersector; e2->decrRef(); e1->decrRef(); - } -} - -void QuadraticPlanarInterpTest::IntersectArcCircleFull() -{ - double center1[2]; center1[0]=0.; center1[1]=0.; double radius1=3.; - double center2[2]; center2[0]=0.75; center2[1]=-2.6; double radius2=1.; - EdgeArcCircle *e1=buildArcOfCircle(center1,radius1,-M_PI/3.,4.*M_PI/3.); - EdgeArcCircle *e2=buildArcOfCircle(center2,radius2,0.,M_PI/2.); - MergePoints commonNode; - QuadraticPolygon pol1; QuadraticPolygon pol2; - QuadraticPolygon pol3; QuadraticPolygon pol4; - pol3.pushBack(e1); pol4.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol3.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol4.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(19.6648305849,pol3.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol4.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol1,pol2)); - CPPUNIT_ASSERT_EQUAL(2,pol1.size()); - CPPUNIT_ASSERT_EQUAL(2,pol2.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(19.6648305849,pol1.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol2.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol1.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol2.getPerimeter(),1e-6); - // - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,0.,M_PI/2.); - commonNode.clear(); - QuadraticPolygon pol5; QuadraticPolygon pol6; - QuadraticPolygon pol7; QuadraticPolygon pol8; - pol7.pushBack(e1); pol8.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol7.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol8.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol7.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol8.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol5,pol6)); - CPPUNIT_ASSERT_EQUAL(2,pol5.size()); - CPPUNIT_ASSERT_EQUAL(2,pol6.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol5.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.8146018366,pol6.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol5.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol6.getPerimeter(),1e-6); - // - center2[0]=3.5; center2[1]=0.; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/2.,3*M_PI/2.); - commonNode.clear(); - QuadraticPolygon pol9; QuadraticPolygon pol10; - QuadraticPolygon pol11; QuadraticPolygon pol12; - pol11.pushBack(e1); pol12.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol11.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol12.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol11.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol12.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol9,pol10)); - CPPUNIT_ASSERT_EQUAL(3,pol9.size()); - CPPUNIT_ASSERT_EQUAL(3,pol10.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol9.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol10.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol9.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5707963267949,pol10.getArea(),1e-6); - // - center2[0]=0.; center2[1]=0.; radius2=radius1; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/3.,2*M_PI/3.); - commonNode.clear(); - QuadraticPolygon pol13; QuadraticPolygon pol14; - QuadraticPolygon pol15; QuadraticPolygon pol16; - pol15.pushBack(e1); pol16.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol15.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol16.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol15.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.6095032974147,pol16.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol13,pol14)); - CPPUNIT_ASSERT_EQUAL(3,pol13.size()); - CPPUNIT_ASSERT_EQUAL(1,pol14.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol13.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol13.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol14.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.6095032974147,pol14.getArea(),1e-6); - // - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,2*M_PI/3.,M_PI/3.); - commonNode.clear(); - QuadraticPolygon pol17; QuadraticPolygon pol18; - QuadraticPolygon pol19; QuadraticPolygon pol20; - pol19.pushBack(e1); pol20.pushBack(e2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol19.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol20.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol19.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.6095032974147,pol20.getArea(),1e-6); - CPPUNIT_ASSERT(e1->intersectWith(e2,commonNode,pol17,pol18)); - CPPUNIT_ASSERT_EQUAL(3,pol17.size()); - CPPUNIT_ASSERT_EQUAL(1,pol18.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.707963267948966,pol17.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-19.6648305849,pol17.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.1415926535897931,pol18.getPerimeter(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.6095032974147,pol18.getArea(),1e-6); - //no intersection #1 - center2[0]=4.277; center2[1]=-4.277; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/4.,5*M_PI/4.); - QuadraticPolygon polTemp1; QuadraticPolygon polTemp2; - CPPUNIT_ASSERT(!e1->intersectWith(e2,commonNode,polTemp1,polTemp2)); - e1->decrRef(); e2->decrRef(); - //no intersection #2 - center2[0]=1.; center2[1]=-1.; radius2=0.2; - e1=buildArcOfCircle(center1,radius1,-2*M_PI/3.,-7.*M_PI/3.); - e2=buildArcOfCircle(center2,radius2,M_PI/4.,5*M_PI/4.); - CPPUNIT_ASSERT(!e1->intersectWith(e2,commonNode,polTemp1,polTemp2)); - e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::IntersectArcCircleSegumentBase() -{ - double center[2]={2.,2.}; - EdgeArcCircle *e1=buildArcOfCircle(center,2.3,M_PI/4.,5.*M_PI/4.); - EdgeLin *e2=new EdgeLin(-1.3,1.,3.,5.3); - EdgeIntersector *intersector=new ArcCSegIntersector(*e1,*e2); - bool order; - bool obvious,areOverlapped; - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); - CPPUNIT_ASSERT(!obvious && !areOverlapped); - std::vector v4; - MergePoints v3; - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(!order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.3,(*v4[1])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[1])[1],1e-10); - v4[0]->decrRef(); v4[1]->decrRef(); e2->decrRef(); v3.clear(); v4.clear(); delete intersector; - // - e2=new EdgeLin(3.,5.3,-1.3,1.); - intersector=new ArcCSegIntersector(*e1,*e2); - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(2,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.3,(*v4[1])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[1])[1],1e-10); - v4[0]->decrRef(); v4[1]->decrRef(); e2->decrRef(); v3.clear(); v4.clear(); delete intersector; - // tangent intersection - e2=new EdgeLin(-1.,4.3,3.,4.3); - intersector=new ArcCSegIntersector(*e1,*e2); - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(!obvious && !areOverlapped); - CPPUNIT_ASSERT(intersector->intersect(0,v4,order,v3)); CPPUNIT_ASSERT(order); CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,(*v4[0])[0],1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.3,(*v4[0])[1],1e-10); - v4[0]->decrRef(); e2->decrRef(); v3.clear(); delete intersector; - // no intersection - e2=new EdgeLin(-2.,-2.,-1.,-3.); - intersector=new ArcCSegIntersector(*e1,*e2); - intersector->areOverlappedOrOnlyColinears(0,obvious,areOverlapped); CPPUNIT_ASSERT(obvious && !areOverlapped); - e2->decrRef(); v3.clear(); delete intersector; - // - e1->decrRef(); -} - -QuadraticPolygon *QuadraticPlanarInterpTest::buildQuadraticPolygonCoarseInfo(const double *coords, const int *conn, int lgth) -{ - std::vector nodes; - for(int i=0;i -#include -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - -void QuadraticPlanarInterpTest::checkInOutDetection() -{ - Node *n1=new Node(0.,0.); - Node *n2=new Node(1.,0.); - Node *n3=new Node(0.5,1.); - EdgeLin *e1=new EdgeLin(n1,n2); - EdgeLin *e2=new EdgeLin(n2,n3); - EdgeLin *e3=new EdgeLin(n3,n1); - ComposedEdge *tri=new ComposedEdge; - tri->pushBack(e1); tri->pushBack(e2); tri->pushBack(e3); - // - Node *where=new Node(0.4,0.1); - CPPUNIT_ASSERT(tri->isInOrOut(where)); where->decrRef(); - where=new Node(-0.1,1.); - CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef(); - where=new Node(0.6,-0.1); - CPPUNIT_ASSERT(!tri->isInOrOut(where)); where->decrRef(); - //Clean-up - n1->decrRef(); n2->decrRef(); n3->decrRef(); - ComposedEdge::Delete(tri); -} - -/*! - * Check Iterators mechanism. - */ -void QuadraticPlanarInterpTest::checkAssemblingBases1() -{ - Node *n1=new Node(0.,0.); - Node *n2=new Node(0.1,0.); EdgeLin *e1_2=new EdgeLin(n1,n2); - Node *n3=new Node(0.2,0.); EdgeLin *e2_3=new EdgeLin(n2,n3); - Node *n4=new Node(0.3,0.); EdgeLin *e3_4=new EdgeLin(n3,n4); - Node *n5=new Node(0.4,0.); EdgeLin *e4_5=new EdgeLin(n4,n5); - Node *n6=new Node(0.5,0.); EdgeLin *e5_6=new EdgeLin(n5,n6); - Node *n7=new Node(0.6,0.); EdgeLin *e6_7=new EdgeLin(n6,n7); - Node *n8=new Node(0.7,0.); EdgeLin *e7_8=new EdgeLin(n7,n8); - Node *n9=new Node(0.8,0.); EdgeLin *e8_9=new EdgeLin(n8,n9); - Node *n10=new Node(0.9,0.); EdgeLin *e9_10=new EdgeLin(n9,n10); - Node *n11=new Node(1.,0.); EdgeLin *e10_11=new EdgeLin(n10,n11); - Node *n12=new Node(0.5,1.); EdgeLin *e11_12=new EdgeLin(n11,n12); - EdgeLin *e12_1=new EdgeLin(n12,n1); - //Only one level - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); - e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - ComposedEdge *c=new ComposedEdge; - c->pushBack(e1_2); c->pushBack(e2_3); c->pushBack(e3_4); c->pushBack(e4_5); c->pushBack(e5_6); c->pushBack(e6_7); - c->pushBack(e7_8); c->pushBack(e8_9); c->pushBack(e9_10); c->pushBack(e10_11); c->pushBack(e11_12); c->pushBack(e12_1); - CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); - IteratorOnComposedEdge it(c); - CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished()); - it.next(); it.next(); CPPUNIT_ASSERT(it.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); - it.next(); CPPUNIT_ASSERT(it.finished()); - it.first(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.previousLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); - it.nextLoop(); CPPUNIT_ASSERT(it.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it.finished()); - it.last(); CPPUNIT_ASSERT(it.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it.finished()); - //Multi-Level - ComposedEdge::Delete(c); - //(e1_2, (e2_3,(e3_4, e4_5, e5_6, e6_7, (e7_8, e8_9 ), ( e9_10 , e10_11 ), e11_12 ),e12_1 ) ) - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); - e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - ComposedEdge *c2_2_4=new ComposedEdge; c2_2_4->pushBack(e7_8); c2_2_4->pushBack(e8_9); - ComposedEdge *c2_2_5=new ComposedEdge; c2_2_5->pushBack(e9_10); c2_2_5->pushBack(e10_11); - ComposedEdge *c2_2=new ComposedEdge; c2_2->pushBack(e3_4); c2_2->pushBack(e4_5); c2_2->pushBack(e5_6); c2_2->pushBack(e6_7); c2_2->pushBack(c2_2_4); c2_2->pushBack(c2_2_5); c2_2->pushBack(e11_12); - ComposedEdge *c2=new ComposedEdge; c2->pushBack(e2_3); c2->pushBack(c2_2); c2->pushBack(e12_1); - c=new ComposedEdge; c->pushBack(e1_2); c->pushBack(c2); CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); - IteratorOnComposedEdge it2(c); - CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.finished()); - it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.last(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - // substitutions. - /*it2.first(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - ElementaryEdge *&tmp=it2.current(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); CPPUNIT_ASSERT(!it2.finished()); - ComposedEdge *c1=new ComposedEdge; Node *n1_bis=new Node(0.,0.05); EdgeLin *e1_1bis=new EdgeLin(n1,n1_bis); EdgeLin *e1bis_2=new EdgeLin(n1_bis,n2); e1_1bis->incrRef(); e1bis_2->incrRef(); - c1->pushBack(e1_1bis); c1->pushBack(e1bis_2); delete tmp; tmp=(ElementaryEdge *)c1; CPPUNIT_ASSERT_EQUAL(13,c->recursiveSize()); - CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());// here testing capability of Iterator.'current' method to deal with change of hierarchy. - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.next(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); - it2.previousLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - //go forward - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1bis_2); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e2_3); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e3_4); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e4_5); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e5_6); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e6_7); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e7_8); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e8_9); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e9_10); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e10_11); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e11_12); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e12_1); CPPUNIT_ASSERT(!it2.finished()); - it2.nextLoop(); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_1bis); CPPUNIT_ASSERT(!it2.finished());*/ - ComposedEdge::SoftDelete(c2_2_4); - ComposedEdge::SoftDelete(c2_2_5); - ComposedEdge::SoftDelete(c2_2); - ComposedEdge::SoftDelete(c2); - ComposedEdge::Delete(c); - //clean-up - //e1_1bis->decrRef(); e1bis_2->decrRef(); - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_7->decrRef(); - e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef(); - //n1_bis->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef(); -} - -/*! - * Check splitting of 2 polygons. After this operation, all ElementaryEdge are either in/out/on. - */ -void QuadraticPlanarInterpTest::checkAssemblingBases2() -{ - //The "most" basic test1 - Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); - Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); - Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - QuadraticPolygon cpyPol1(pol1); int nbOfSplits=0; - cpyPol1.splitPolygonsEachOther(pol1,pol2,nbOfSplits); - CPPUNIT_ASSERT_EQUAL(5,pol1.recursiveSize()); - CPPUNIT_ASSERT_EQUAL(5,pol2.recursiveSize());CPPUNIT_ASSERT_EQUAL(15,nbOfSplits); - checkBasicsOfPolygons(pol1,pol2,true); - CPPUNIT_ASSERT(pol2[1]->getEndNode()==pol1[1]->getEndNode()); - CPPUNIT_ASSERT(pol2[1]->getEndNode()->getLoc()==ON_1); - CPPUNIT_ASSERT(pol2[3]->getEndNode()==pol1[0]->getEndNode()); - CPPUNIT_ASSERT(pol2[3]->getEndNode()->getLoc()==ON_1); - cpyPol1.performLocatingOperation(pol2); - ElementaryEdge *tmp=dynamic_cast(pol2[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol2[1]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol2[2]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); - tmp=dynamic_cast(pol2[3]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); - tmp=dynamic_cast(pol2[4]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - //clean-up for test1 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Deeper test some extremities of pol2 are on edges of pol1. - - n1=new Node(0.,0.); n4=new Node(1.5,-0.5); - n2=new Node(1.,0.); n5=new Node(0.5,0.); - n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5); - QuadraticPolygon cpyPol3(pol3); nbOfSplits=0; - cpyPol3.splitPolygonsEachOther(pol3,pol4,nbOfSplits); - CPPUNIT_ASSERT_EQUAL(5,pol3.recursiveSize()); - CPPUNIT_ASSERT_EQUAL(4,pol4.recursiveSize());CPPUNIT_ASSERT_EQUAL(16,nbOfSplits); - checkBasicsOfPolygons(pol3,pol4,true); - CPPUNIT_ASSERT(pol4[0]->getStartNode()==pol3[0]->getEndNode()); CPPUNIT_ASSERT(pol4[0]->getStartNode()==n5); - CPPUNIT_ASSERT(n5->getLoc()==ON_LIM_1); - CPPUNIT_ASSERT(pol4[2]->getEndNode()==pol3[2]->getEndNode()); CPPUNIT_ASSERT(pol4[2]->getEndNode()==n6); - CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1); - cpyPol3.performLocatingOperation(pol4); - tmp=dynamic_cast(pol4[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_7); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5); - tmp=dynamic_cast(pol4[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_4); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol4[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e7_6); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol4[3]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e6_5); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_IN_1); - //clean-up for test2 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); - - //Test with one edge of pol2 is included in pol1. - - n1=new Node(0.,0.); n4=new Node(-0.5,0.); - n2=new Node(1.,0.); n5=new Node(0.,-1.); - n3=new Node(0.5,1.); n6=new Node(0.5,0.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1); - QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4); - QuadraticPolygon cpyPol5(pol5); nbOfSplits=0; - cpyPol5.splitPolygonsEachOther(pol5,pol6,nbOfSplits); - CPPUNIT_ASSERT_EQUAL(4,pol5.recursiveSize()); - CPPUNIT_ASSERT_EQUAL(4,pol6.recursiveSize()); CPPUNIT_ASSERT_EQUAL(13,nbOfSplits); - checkBasicsOfPolygons(pol5,pol6,false); - CPPUNIT_ASSERT(pol6[2]->getStartNode()==pol5[0]->getEndNode()); CPPUNIT_ASSERT(pol6[2]->getStartNode()==n6); - CPPUNIT_ASSERT(n6->getLoc()==ON_LIM_1); - CPPUNIT_ASSERT(pol6[2]->getEndNode()==pol5[0]->getStartNode()); CPPUNIT_ASSERT(pol5[0]->getStartNode()==n1); - CPPUNIT_ASSERT(n1->getLoc()==ON_LIM_1); - cpyPol5.performLocatingOperation(pol6); - tmp=dynamic_cast(pol6[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol6[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e5_6); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - tmp=dynamic_cast(pol6[2]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - tmp=dynamic_cast(pol6[3]); CPPUNIT_ASSERT(tmp); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); - //clean-up test3 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Test of full overlapped polygons. - - n1=new Node(0.,0.); n4=new Node(0.,0.); - n2=new Node(1.,0.); n5=new Node(1.,0.); - n3=new Node(0.5,1.); n6=new Node(0.5,1.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1); - QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4); - QuadraticPolygon cpyPol7(pol7); nbOfSplits=0; - cpyPol7.splitPolygonsEachOther(pol7,pol8,nbOfSplits); - tmp=dynamic_cast(pol8[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e1_2); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - tmp=dynamic_cast(pol8[1]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e2_3); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - tmp=dynamic_cast(pol8[2]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e3_1); - CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); - //clean-up test4 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); -} - -void QuadraticPlanarInterpTest::checkBasicsOfPolygons(QuadraticPolygon& pol1, QuadraticPolygon& pol2, bool checkDirection) -{ - IteratorOnComposedEdge it1(&pol1),it2(&pol2); it1.previousLoop(); it2.previousLoop(); - Node *nIter1=it1.current()->getEndNode(); Node *nIter2=it2.current()->getEndNode(); - for(it2.first();!it2.finished();it2.next()) - { - CPPUNIT_ASSERT(nIter2==it2.current()->getStartNode()); - if(checkDirection) - CPPUNIT_ASSERT(it2.current()->getDirection()); - nIter2=it2.current()->getEndNode(); - } - for(it1.first();!it1.finished();it1.next()) - { - CPPUNIT_ASSERT(nIter1==it1.current()->getStartNode()); - if(checkDirection) - CPPUNIT_ASSERT(it1.current()->getDirection()); - nIter1=it1.current()->getEndNode(); - } -} - -} diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx deleted file mode 100644 index 9be27119d..000000000 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx +++ /dev/null @@ -1,1665 +0,0 @@ -// Copyright (C) 2007-2010 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 "QuadraticPlanarInterpTest.hxx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" - -#include -#include -#include -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - -void QuadraticPlanarInterpTest::checkPolygonsIntersection1() -{ - //The "most" basic test1 - Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); - Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); - Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); - // - std::vector result; - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<1;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol1; pol1.circularPermute(); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - double tmp1=0.,tmp2=0.,tmp3=0.; - pol1.intersectForPerimeter(pol2,tmp1,tmp2,tmp3); - std::vector v1,v2; - std::vector v3; - pol1.intersectForPerimeterAdvanced(pol2,v1,v2);//no common edge - pol1.intersectForPoint(pol2,v3); - CPPUNIT_ASSERT_EQUAL(3,(int)v1.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v2.size()); - CPPUNIT_ASSERT_EQUAL(3,(int)v3.size()); - if(k==0) - { - CPPUNIT_ASSERT_EQUAL(2,v3[(3-i)%3]); - CPPUNIT_ASSERT_EQUAL(0,v3[(4-i)%3]); - CPPUNIT_ASSERT_EQUAL(0,v3[(5-i)%3]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,v1[(3-i)%3],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(4-i)%3],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v1[(5-i)%3],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v2[0],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[1],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.78262379212492639,v2[2],1.e-14); - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7,tmp1,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5652475842498528,tmp2,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp3,1.e-14);//no common edge - delete result[0]; - } - } - //clean-up for test1 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Deeper test some extremities of pol2 are on edges of pol1. - - n1=new Node(0.,0.); n4=new Node(1.5,-0.5); - n2=new Node(1.,0.); n5=new Node(0.5,0.); - n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); - // - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<4;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - } - } - //clean-up for test2 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e5_4->decrRef(); e4_7->decrRef(); e7_6->decrRef(); e6_5->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); - - //Test with one edge of pol2 is included in pol1. - - n1=new Node(0.,0.); n4=new Node(-0.5,0.); - n2=new Node(1.,0.); n5=new Node(0.,-1.); - n3=new Node(0.5,1.); n6=new Node(0.5,0.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1); - for(int i1=0;i1decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Test of full overlapped polygons. - - n1=new Node(0.,0.); n4=new Node(0.,0.); - n2=new Node(1.,0.); n5=new Node(1.,0.); - n3=new Node(0.5,1.); n6=new Node(0.5,1.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - double tmp1=0.,tmp2=0.,tmp3=0.; - pol7.intersectForPerimeter(pol8,tmp1,tmp2,tmp3); - std::vector v1,v2; - pol7.intersectForPerimeterAdvanced(pol8,v1,v2);//only common edges. - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v1[0]+v1[1]+v1[2],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,v2[0]+v2[1]+v2[2],1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp1,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,tmp2,1.e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,tmp3,1.e-14); - } - } - //clean-up test4 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Test of closing process - - n1=new Node(0.,0.); n4=new Node(0.539,-0.266); - n2=new Node(1.,0.); n5=new Node(1.039,0.6); - n3=new Node(0.5,1.); n6=new Node(-0.077,0.667); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol9; pol9.pushBack(e1_2); pol9.pushBack(e2_3); pol9.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - } - } - //clean-up test5 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - // Full in case - - n1=new Node(0.,0.); n4=new Node(0.3,0.1); - n2=new Node(1.,0.); n5=new Node(0.7,0.1); - n3=new Node(0.5,1.); n6=new Node(0.5,0.7); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol11; pol11.pushBack(e1_2); pol11.pushBack(e2_3); pol11.pushBack(e3_1); - for(int i1=0;i1recursiveSize()); - delete result[0]; - } - } - //clean-up test6 - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - // Full out case - - n1=new Node(0.,0.); n4=new Node(-2,0.); - n2=new Node(1.,0.); n5=new Node(-1.,0.); - n3=new Node(0.5,1.); n6=new Node(-1.5,1.); - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - e4_5=new EdgeLin(n4,n5); e5_6=new EdgeLin(n5,n6); e6_4=new EdgeLin(n6,n4); - for(int k=0;k<2;k++) - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); - QuadraticPolygon pol13; pol13.pushBack(e1_2); pol13.pushBack(e2_3); pol13.pushBack(e3_1); - for(int i1=0;i1decrRef(); e2_3->decrRef(); e3_1->decrRef(); e4_5->decrRef(); e5_6->decrRef(); e6_4->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - - //Multi polygons - - n1=new Node(0.,0.); - n2=new Node(1.,0.); - n3=new Node(1.,1.); - n4=new Node(0.,1.); - // - n5=new Node(0.2,0.7); - n6=new Node(0.4,0.7); - n7=new Node(0.4,1.3); - Node *n8=new Node(0.6,1.3); - Node *n9=new Node(0.6,0.7); - Node *n10=new Node(0.9,0.7); - Node *n11=new Node(0.9,2.); - Node *n12=new Node(0.2,2.); - // - e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); Edge *e3_4=new EdgeLin(n3,n4); Edge *e4_1=new EdgeLin(n4,n1); - e5_6=new EdgeLin(n5,n6); Edge *e6_7=new EdgeLin(n6,n7); Edge *e7_8=new EdgeLin(n7,n8); Edge *e8_9=new EdgeLin(n8,n9); Edge *e9_10=new EdgeLin(n9,n10); Edge *e10_11=new EdgeLin(n10,n11); - Edge *e11_12=new EdgeLin(n11,n12); Edge *e12_1=new EdgeLin(n12,n5); - // - for(int k=0;k<2;k++) - for(int i=0;i<4;i++) - { - for(int j=0;j<8;j++) - { - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); e5_6->incrRef(); e6_7->incrRef(); e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - QuadraticPolygon pol15; pol15.pushBack(e1_2); pol15.pushBack(e2_3); pol15.pushBack(e3_4); pol15.pushBack(e4_1); - for(int i1=0;i1recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,result[1]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,result[0]->getArea()+result[1]->getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.03,fabs(result[0]->getArea()-result[1]->getArea()),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.15,pol15.intersectWith(pol16),1e-10); - delete result[0]; delete result[1]; - } - } - //clean-up test8 - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); e5_6->decrRef(); e6_7->decrRef(); e7_8->decrRef(); e8_9->decrRef(); e9_10->decrRef(); e10_11->decrRef(); e11_12->decrRef(); e12_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); n7->decrRef(); n8->decrRef(); n9->decrRef(); n10->decrRef(); n11->decrRef(); n12->decrRef(); -} - -/*! - * Testing case where a polygon pol1 is included in an onother polygon pol2. - */ -void QuadraticPlanarInterpTest::checkPolygonsIntersection2() -{ - Node *n1=new Node(0.,0.); Node *n4=new Node(0.2,0.2); - Node *n2=new Node(1.,0.); Node *n5=new Node(0.8,0.2); - Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.8); - Edge *e1_2=new EdgeLin(n1,n2); Edge *e4_5=new EdgeLin(n4,n5); - Edge *e2_3=new EdgeLin(n2,n3); Edge *e5_6=new EdgeLin(n5,n6); - Edge *e3_1=new EdgeLin(n3,n1); Edge *e6_4=new EdgeLin(n6,n4); - // - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - std::vector result=pol1.intersectMySelfWith(pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); - CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10); - delete result[0]; - result.clear(); - pol1.initLocations(); - pol2.initLocations(); - result=pol2.intersectMySelfWith(pol1); - CPPUNIT_ASSERT_EQUAL(1,(int)result.size()); - CPPUNIT_ASSERT_EQUAL(3,result[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.18,result[0]->getArea(),1e-10); - delete result[0]; - //clean-up - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); -} - -void QuadraticPlanarInterpTest::checkAreasCalculations() -{ - Node *n1=new Node(0.,0.); - Node *n2=new Node(1.,0.); - Node *n3=new Node(0.5,1.); - Edge *e1_2=new EdgeLin(n1,n2); - Edge *e2_3=new EdgeLin(n2,n3); - Edge *e3_1=new EdgeLin(n3,n1); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,pol1.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10); - pol1.reverse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.5,pol1.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.2360679774997898,pol1.getPerimeter(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.61803398874989479,pol1.getHydraulicDiameter(),1e-10); - //clean-up - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); - - //case 2 - - n1=new Node(0.,0.); - n2=new Node(1.,0.); - Node *n3m=new Node(1.5,0.5); - n3=new Node(1.,1.); - Node *n4=new Node(0.,1.); - e1_2=new EdgeLin(n1,n2); - e2_3=new EdgeArcCircle(n2,n3m,n3); - Edge *e3_4=new EdgeLin(n3,n4); - Edge *e4_1=new EdgeLin(n4,n1); - // - for(int k=0;k<8;k++) - { - n2->setNewCoords(cos(k*M_PI/4),sin(k*M_PI/4)); - n3->setNewCoords(sqrt(2.)*cos((k+1)*M_PI/4),sqrt(2.)*sin((k+1)*M_PI/4)); - n3m->setNewCoords(1.5811388300841898*cos(0.3217505543966423+k*M_PI/4),1.5811388300841898*sin(0.3217505543966423+k*M_PI/4)); - n4->setNewCoords(cos(k*M_PI/4+M_PI/2),sin(k*M_PI/4+M_PI/2)); - e1_2->update(n3m); e2_3->update(n3m); e3_4->update(n3m); e4_1->update(n3m); - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); - QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_3); pol2.pushBack(e3_4); pol2.pushBack(e4_1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.3926990816987241,pol2.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6); - pol2.reverse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.3926990816987241,pol2.getArea(),1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5707963267948966,pol2.getPerimeter(),1e-6); - } - //clean-up case2 - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef(); - - //case 3 - - const double radius1=0.7; - const double radius2=0.9; - n1=new Node(1.+radius1*cos(-2.*M_PI/3.),1.+radius1*sin(-2.*M_PI/3.)); - n2=new Node(1.+radius1*cos(-M_PI/3.),1.+radius1*sin(-M_PI/3.)); - Node *n2m=new Node(1.+radius1*cos(M_PI/2.),1.+radius1*sin(M_PI/2.)); - n3=new Node(1.+radius2*cos(-M_PI/3.),1.+radius2*sin(-M_PI/3.)); - n3m=new Node(1.+radius2*cos(M_PI/2.),1.+radius2*sin(M_PI/2.)); - n4=new Node(1.+radius2*cos(-2.*M_PI/3.),1.+radius2*sin(-2.*M_PI/3.)); - e1_2=new EdgeArcCircle(n1,n2m,n2); - e2_3=new EdgeLin(n2,n3); - e3_4=new EdgeArcCircle(n3,n3m,n4); - e4_1=new EdgeLin(n4,n1); - // - e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_1->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_4); pol3.pushBack(e4_1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.83775804095727857,pol3.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10); - pol3.reverse(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.83775804095727857,pol3.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.7775804095727832,pol3.getPerimeter(),1e-10); - //clean-up case3 - e1_2->decrRef(); e2_3->decrRef(); e3_4->decrRef(); e4_1->decrRef(); - n1->decrRef(); n2->decrRef(); n2m->decrRef(); n3->decrRef(); n3m->decrRef(); n4->decrRef(); -} - -void QuadraticPlanarInterpTest::checkBarycenterCalculations() -{ - Node *n1=new Node(3.,7.); - Node *n2=new Node(5.,7.); - Node *n3=new Node(4.,8.); - Edge *e1_2=new EdgeLin(n1,n2); - Edge *e2_3=new EdgeLin(n2,n3); - Edge *e3_1=new EdgeLin(n3,n1); - // - double bary[2]; - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - bary[0]=0.; bary[1]=0.; - e1_2->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-56.,bary[0],1.e-10); - bary[0]=0.; bary[1]=0.; - e2_3->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(33.66666666666667,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(28.16666666666667,bary[1],1.e-10); - bary[0]=0.; bary[1]=0.; - e3_1->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26.333333333333336,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(28.1666666666667,bary[1],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,pol1.getArea(),1e-10); - pol1.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); - // - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol4; pol4.pushBack(e3_1,false); pol4.pushBack(e2_3,false); pol4.pushBack(e1_2,false); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol4.getArea(),1e-10); - pol4.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); - //clean-up - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); - //Inverting polygon - n1=new Node(3.,7.); - n2=new Node(5.,7.); - n3=new Node(4.,8.); - e1_2=new EdgeLin(n1,n3); - e2_3=new EdgeLin(n3,n2); - e3_1=new EdgeLin(n2,n1); - e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - bary[0]=0.; bary[1]=0.; - pol3.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.,pol3.getArea(),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.333333333333333,bary[1],1.e-10); - //clean-up - e1_2->decrRef(); e2_3->decrRef(); e3_1->decrRef(); - n1->decrRef(); n2->decrRef(); n3->decrRef(); - // - double center[2]={3.,7.}; - e1_2=buildArcOfCircle(center,4.,M_PI/3.,4.*M_PI/3.); - bary[0]=0.; bary[1]=0.; - e1_2->getBarycenterOfZone(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(131.685410765053,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(303.262521934362,bary[1],1.e-10); - n1=new Node(0.99999999999999822,3.5358983848622465); - n2=new Node(5.,10.4641016151377544); - Edge *e2_1=new EdgeLin(n1,n2); - // - e1_2->incrRef(); e2_1->incrRef(); - QuadraticPolygon pol2; pol2.pushBack(e1_2); pol2.pushBack(e2_1); - pol2.getBarycenter(bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(25.132741228718345,pol2.getArea(),1e-10); - //4*radius/(3.*pi) - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5297896122085546,bary[0],1.e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8488263631567756,bary[1],1.e-10); - //clean-up - e1_2->decrRef(); e2_1->decrRef(); - n1->decrRef(); n2->decrRef(); -} - -/*! - * Testing user interface high level function. - */ -void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - double coords[]={ - 8.8334591186000004, 5.0999999999999996, - 7.1014083111000001, 6.0999999999999996, - 7.8334591186000004, 6.8320508074999999, - 7.9674337149000003, 5.5999999999999996, - 7.4192455562999999, 6.5142135623000001, - 8.3334591186000004, 5.9660254036999998 - }; - std::vector nodes; - nodes.push_back(new Node(coords)); - nodes.push_back(new Node(coords+2)); - nodes.push_back(new Node(coords+4)); - nodes.push_back(new Node(coords+6)); - nodes.push_back(new Node(coords+8)); - nodes.push_back(new Node(coords+10)); - QuadraticPolygon *pol=QuadraticPolygon::buildArcCirclePolygon(nodes); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5); - CPPUNIT_ASSERT_EQUAL(3,pol->size()); - ElementaryEdge *e0=dynamic_cast((*pol)[0]); - ElementaryEdge *e1=dynamic_cast((*pol)[1]); - ElementaryEdge *e2=dynamic_cast((*pol)[0]); - CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); - CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity - CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); - CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity - nodes.clear(); - delete pol; - nodes.push_back(new Node(coords)); - nodes.push_back(new Node(coords+4)); - nodes.push_back(new Node(coords+2)); - nodes.push_back(new Node(coords+10)); - nodes.push_back(new Node(coords+8)); - nodes.push_back(new Node(coords+6)); - pol=QuadraticPolygon::buildArcCirclePolygon(nodes); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.04719755,pol->getArea(),1e-5); - CPPUNIT_ASSERT_EQUAL(3,pol->size()); - e0=dynamic_cast((*pol)[0]); - e1=dynamic_cast((*pol)[1]); - e2=dynamic_cast((*pol)[0]); - CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); - CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));//<- testing detection of colinearity - CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); - CPPUNIT_ASSERT(dynamic_cast(e2->getPtr()));//<- testing detection of colinearity - delete pol; - const double coords2[]={ - 0.,0., - 1.5,0., - 1.5,1., - 0.,1. - }; - nodes.clear(); - nodes.push_back(new Node(coords2)); - nodes.push_back(new Node(coords2+2)); - nodes.push_back(new Node(coords2+4)); - nodes.push_back(new Node(coords2+6)); - pol=QuadraticPolygon::buildLinearPolygon(nodes); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,pol->getArea(),1e-12); - double tmp[2],tmp2; - pol->getBarycenter(tmp,tmp2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,tmp[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,tmp[1],1e-12); - delete pol; - const double coords3[]={ - 1.0999999999000001, -1.9052558882999999, - 1.9052558881999999, -1.0999999999000001, - 1.7320508075000001, -0.99999999989999999, - 0.99999999989999999, -1.7320508075000001, - 1.5556349186, -1.5556349185, - 1.8186533478, -1.0499999999, - 1.4142135623000001, -1.4142135623000001, - 1.0499999999, -1.8186533479 - }; - nodes.clear(); - nodes.push_back(new Node(coords3)); - nodes.push_back(new Node(coords3+2)); - nodes.push_back(new Node(coords3+4)); - nodes.push_back(new Node(coords3+6)); - nodes.push_back(new Node(coords3+8)); - nodes.push_back(new Node(coords3+10)); - nodes.push_back(new Node(coords3+12)); - nodes.push_back(new Node(coords3+14)); - pol=QuadraticPolygon::buildArcCirclePolygon(nodes); - pol->getBarycenter(tmp,tmp2); - delete pol; - QUADRATIC_PLANAR::setPrecision(1e-14); -} - -void QuadraticPlanarInterpTest::check1DInterpLin() -{ - QUADRATIC_PLANAR::setPrecision(1e-7); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - const int NB_OF_CELL_AXIAL_1=30; - static const double Z_VALS_1[NB_OF_CELL_AXIAL_1+1]= - { -0.1550 , -0.1356, -0.1162, -0.0969, -0.0775 ,-0.0581, -0.0387, -0.0194, 0.0000 , 0.0500, - 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500, - 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356, - 0.8550}; - std::vector zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1); - - const int NB_OF_CELL_AXIAL_2=46; - static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]= - { -0.3050 ,-0.2863,-0.2675,-0.2488,-0.2300,-0.2113,-0.1925,-0.1738,-0.1550,-0.1356 - , -0.1162,-0.0969,-0.0775,-0.0581,-0.0387,-0.0194,0.0000, 0.0500, 0.1 ,0.15 - , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700 - , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550 - , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050}; - std::vector zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1); - std::map > m; - Edge::interpolate1DLin(zLev1,zLev2,m); - CPPUNIT_ASSERT_EQUAL(30,(int)m.size()); - double ret=0; - for(int i=0;i<30;i++) - { - CPPUNIT_ASSERT_EQUAL(1,(int)m[i].size()); - CPPUNIT_ASSERT(m[i][8+i] > 0.15); - ret+=m[i][8+i]; - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(ret,30.,1e-12); - // - m.clear(); - const int NB_OF_CELL_AXIAL_3=13; - static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={ - 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30, - 0.35,0.40,0.45,0.50,0.55,0.60 }; - std::vector zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1); - Edge::interpolate1DLin(zLev3,zLev1,m); - CPPUNIT_ASSERT_EQUAL(13,(int)m.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[1][8],1e-12); - for(int i=0;i<11;i++) - { - CPPUNIT_ASSERT_EQUAL(1,(int)m[i+2].size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[i+2][i+9],1e-12); - } - QUADRATIC_PLANAR::setPrecision(1e-14); -} - -/*! - * This test looks if intersectors are in coherency. - */ -void QuadraticPlanarInterpTest::checkEpsilonCoherency1() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - - const double pol1[]={ - -2.1083388455000001, 1.2172499999999999, - -1.7320508075000001, 1, - -1.9201948265, 1.108625 - }; - - const double pol2[]={ - -2.2379999998, 0, - -1.9381648534, 1.1189999998, - -2.1617419990000002, 0.57923702298000002, - -1.9381648534, 1.1189999998, - -1.9909924031999999, 1.1494999999, - -1.9645786283, 1.1342499998 - }; - // - Node *n1=new Node(pol1[0],pol1[1]); - Node *n2=new Node(pol1[2],pol1[3]); - Node *n3; - // - Edge *e1=new EdgeLin(n1,n2); n1->decrRef(); n2->decrRef(); - n1=new Node(pol2[0],pol2[1]); - n2=new Node(pol2[4],pol2[5]); - n3=new Node(pol2[2],pol2[3]); - Edge *e2=new EdgeArcCircle(n1,n2,n3); n1->decrRef(); n2->decrRef(); n3->decrRef(); - e2->decrRef(); - e1->decrRef(); -} - -/*! - * Tests to avoid regressions : Basic one. - */ -void QuadraticPlanarInterpTest::checkNonRegression1() -{ - const double coords1[]= - { - 16.1732057215, -25.110999999800001, - 16.02555485246479, -25.340997988918762 - }; - Node *nS1=new Node(coords1); - Node *nE1=new Node(coords1+2); - const double radius1=2.902; - const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692; - const double center1[2]={13.66, -23.66}; - EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); - // - const double coords2[]= - { - 16.041579804000001, -25.350249998999999, - 16.367740958999999, -24.132999999999999 - }; - Node *nS2=new Node(coords2); - Node *nE2=new Node(coords2+2); - const double radius2=2.4345; - const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041; - const double center2[]={ 13.933240960547204, -24.132999998525658 }; - EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2); - MergePoints merge; - QuadraticPolygon c1,c2; - e1->intersectWith(e2,merge,c1,c2); - CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCurveLength(),c1.getPerimeter(),1e-5); - //clean-up - nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::checkNonRegression2() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - double coords1[]= - { - 15.141499999899999, -26.226033271399999, - 16.226033271199999, -25.141499999800001, - 16.1732057215, -25.110999999800001, - 15.110999999899999, -26.1732057217, - 15.755157392699999, -25.755157392499999, - 16.199619496299999, -25.126249999799999, - 15.7120238788, -25.712023879099998, - 15.126249999899999, -26.199619496499999 - }; - double coords2[]= - { - 15.933240959000001, -24.132999999999999, - 15.665291765999999, -25.132999998999999, - 16.041579804000001, -25.350249998999999, - 16.367740958999999, -24.132999999999999, - 15.865092611, -24.650638091000001, - 15.853435785, -25.241624998999999, - 16.284787383000001, -24.763094964, - 16.150490958999999, -24.132999999999999 - }; - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,v[0]->getArea(),1e-7); - delete v[0]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00173945,pol1->intersectWith(*pol2),1e-7); - delete pol1; - delete pol2; -} - -/*! - * Tests to avoid regressions : Basic one. - */ -void QuadraticPlanarInterpTest::checkNonRegression3() -{ - const double coords1[]= - { - 10.962340811000001, -22.417749999000002, - 12.217990959, -21.162099852000001 - }; - Node *nS1=new Node(coords1); - Node *nE1=new Node(coords1+2); - const double radius1=3.4304999897666599; - const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204; - const double center1[2]={13.933240950441375, -24.132999992807399}; - EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); - // - const double coords2[]= - { - 11.1467942784, -22.2090000002, - 11.0939667286, -22.178500000099998 - }; - Node *nS2=new Node(coords2); - Node *nE2=new Node(coords2+2); - EdgeLin *e2=new EdgeLin(nS2,nE2); - MergePoints merge; - QuadraticPolygon c1,c2; - CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2)); - CPPUNIT_ASSERT_EQUAL(2,c1.size()); - CPPUNIT_ASSERT_EQUAL(2,c2.size()); - ElementaryEdge *tmp1=dynamic_cast(c1.front()); CPPUNIT_ASSERT(tmp1); - EdgeArcCircle *tmp2=dynamic_cast(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14); - //clean-up - nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::checkNonRegression4() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-9); - double coords1[]= - { - 10.962340811000001, -22.417749999000002, - 12.217990959, -21.162099852000001, - 12.051990958999999, -20.874579418, - 10.674820377, -22.251749999000001, - 11.507511146000001, -21.707270185999999, - 12.134990959, -21.018339635, - 11.272751694, -21.472510735, - 10.818580594, -22.334749999 - }; - - double coords2[]= - { - 10.758000000199999, -23.66, - 11.1467942784, -22.2090000002, - 11.0939667286, -22.178500000099998, - 10.696999999999999, -23.66, - 10.856883252299999, -22.908907131159999, - 11.1203805035, -22.1937500001, - 10.797961776699999, -22.893119169449999, - 10.727500000099999, -23.66 - }; - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); - delete v[0]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression5() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-12); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - -1.7320508075000001, 1, - -1, 1.7320508075000001 , - -1.2172499999999999, 2.1083388455000001, - -2.1083388455000001, 1.2172499999999999, - -1.4142135623000001, 1.4142135623000001, - -1.108625, 1.9201948265, - -1.7214514588000001, 1.7214514588000001, - -1.9201948265, 1.108625}; - - double coords2[]= - { - -2.2379999998, 0, - -1.9381648534, 1.1189999998, - -1.9909924031999999, 1.1494999999, - -2.2989999998999999, 0, - -2.1617419990000002, 0.57923702298000002, - -1.9645786283, 1.1342499998, - -2.2206634745999998, 0.59502498461999997, - -2.2684999997999999, 0}; - //Edge1_of_pol2 inter Edge4_of_pol1 = {-1.9381648533711939, 1.1189999998498941} - //Edge4_of_pol1 _angle = -0.523598775922546, _angle0 = -3.1415926535897931, _radius = 2.2379999983074721, _center = {-1.4925279436059493e-09, 1.3300635705141101e-10}} - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); - //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); - //delete v[0]; - //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,pol1->intersectWith(*pol2),1e-7); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression6() -{ - QUADRATIC_PLANAR::setPrecision(1e-12); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - 10.962340811000001, -22.417749999000002, - 12.217990959, -21.162099852000001, - 12.051990958999999, -20.874579418, - 10.674820377, -22.251749999000001, - 11.507511146000001, -21.707270185999999, - 12.134990959, -21.018339635, - 11.272751694, -21.472510735, - 10.818580594, -22.334749999 - }; - double coords2[]= - { 10.426, -23.66, - 10.859273844199999, -22.043000000100001, - 10.806446294799999, -22.012500000199999, - 10.3650000002, -23.66, - 10.536195877799999, -22.822979208099998, - 10.832860069499999, -22.027750000200001, - 10.477274402499999, -22.80719124657, - 10.3955000001, -23.66}; - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(v[0]->getArea(),0.0150659,1e-7); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression7() -{ - QUADRATIC_PLANAR::setPrecision(1e-5); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - -2., 0, - -1.7320508075000001, 1, - -2.1083388455000001, 1.2172499999999999, - -2.4344999999999999, 0, - -1.9318516525603098, 0.51763809027157182, - -1.9201948265, 1.108625, - -2.3515464241024469, 0.63009496529570408, - -2.2172499999999999, 0 - }; - double coords2[]= - { -2.3369999999000002, 0, - -2.0239013684999998, 1.1684999999000001, - -2.1927763221999998, 1.2659999998, - -2.5319999998, 0, - -2.2573686559260442, 0.60486010843437632, - -2.1083388453499996, 1.2172499998499999, - -2.445724191994314, 0.65532982205982326, - -2.4344999998499999, 0 }; - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.121795,v[0]->getArea(),1.e-6); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression8() -{ - QUADRATIC_PLANAR::setPrecision(1e-3); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-5); - double coords1[]= - { - -13.933240959000001, -28.559499999, - -16.146490959000001, -27.966461449000001, - -16.383240958999998, -28.376524478, - -13.933240959000001, -29.032999999000001, - -15.078903461873765, -28.408670669106311, - -16.264865958999998, -28.1714929635, - -15.201454280317435, -28.866036547696734, - -13.933240959000001, -28.796249999 }; - double coords2[]= - { -16.382999999950002, -28.376524478457149, - -13.933000000014729, -29.03299999982551, - -13.93300000006697, -28.793999999915993, - -16.263500000000001, -28.169544407039268, - -15.201213320921273, -28.866036548734634, - -13.933000000040851, -28.913499999870751, - -15.139355569325469, -28.635180276305853, - -16.323249999975001, -28.273034442748209 }; - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.598232,v[0]->getArea(),1.e-6); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression9() -{ - QUADRATIC_PLANAR::setPrecision(1e-7); - QUADRATIC_PLANAR::setArcDetectionPrecision(1e-8); - double coords1[]= - { - -0.04476229252902969, -0.085118027765365603, - -0.046952683430894329, -0.085704941238358354, - -0.046952683430894329, -0.088063823748058725, - -0.043582851274179504, -0.087160879944491371, - -0.045818853668170414, -0.085555669718918592, - -0.046952683430894329, -0.086884382493208526, - -0.045208329947517549, -0.087834175256748526, - -0.044172571901604597, -0.086139453854928494 }; - - double coords2[]= - { -0.05065868681155701, -0.087744551996665671, - -0.046951871439587615, -0.088737790182236015, - -0.046951871439683469, -0.088063823751059062, - -0.050321703596054014, -0.087160879946116557, - -0.0488706602695924, -0.08848517684025306, - -0.046951871439635542, -0.088400806966647538, - -0.048696224921445964, -0.087834175258503858, - -0.050490195203805516, -0.087452715971391121}; - - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression10() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[]= - { -0.002269581957210453, -0.09851030343724453, - -0.004268022334182935, -0.1059685844580936, - -0.002777851483521377, -0.1023709937816271}; - double coords2[]= - { -0.004114727297178323, -0.1049870239624718, - -0.003544545103522544, -0.1053162188055505}; - Node *n1_1=new Node(coords1); - Node *n2_1=new Node(coords1+2); - Node *n3_1=new Node(coords1+4); - Node *n1_2=new Node(coords2); - Node *n2_2=new Node(coords2+2); - EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1); - EdgeLin *e2=new EdgeLin(n1_2,n2_2); - MergePoints merge; - ComposedEdge *c1=new ComposedEdge; - ComposedEdge *c2=new ComposedEdge; - CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2)); - CPPUNIT_ASSERT_EQUAL(2,c1->size()); - CPPUNIT_ASSERT_EQUAL(2,c2->size()); - ComposedEdge::Delete(c1); ComposedEdge::Delete(c2); - n1_1->decrRef(); n2_1->decrRef(); n3_1->decrRef(); - n1_2->decrRef(); n2_2->decrRef(); - e1->decrRef(); e2->decrRef(); -} - -void QuadraticPlanarInterpTest::checkNonRegression11() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[]= - { -0.002269581957210453, -0.09851030343724453, - -0.004268022334182935, -0.1059685844580936, - -0.002886178753789801, -0.1067663922211958, - -0.0006739664310059821, -0.09851030343724453, - -0.002777851483521377, -0.1023709937816271, - -0.003577100543986368, -0.1063674883396447, - -0.001236605237717319, -0.1027839694676665, - -0.001471774194108217, -0.09851030343724453}; - double coords2[]= - { -0.003544545103522544, -0.1053162188055505, - -0.001941023322604723, -0.09851030343724451, - -0.002598140593501099, -0.09851030343724451, - -0.004114727297178323, -0.1049870239624718, - -0.002347317802266182, -0.1020064358043286, - -0.002269581958052911, -0.09851030343724451, - -0.002982346712452072, -0.1018362598405457, - -0.003829636200350435, -0.1051516213840111}; - - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.28973e-06,v[0]->getArea(),1.e-11); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression12() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-6); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[]= - { -0.5032251558760915, -0.8716087994449138, - -0.4695268343089433, -0.8806382374805872, - -0.4695268343089433, -0.8570494123835835, - -0.4914307433275896, -0.8511802776536561, - -0.4869703691141082, -0.8783417525751493, - -0.4695268343089433, -0.8688438249320853, - -0.480865131947653, -0.8555566971861125, - -0.4973279496018406, -0.8613945385492849}; - - double coords2[]= - { -0.5065868681155701, -0.8774455199666568, - -0.4695187143958762, -0.8873779018223601, - -0.4695187143968347, -0.8806382375105907, - -0.5032170359605401, -0.8716087994611657, - -0.488706602695924, -0.8848517684025307, - -0.4695187143963554, -0.8840080696664754, - -0.4869622492144596, -0.8783417525850385, - -0.5049019520380551, -0.8745271597139112}; - - std::vector nodes1; - nodes1.push_back(new Node(coords1)); - nodes1.push_back(new Node(coords1+2)); - nodes1.push_back(new Node(coords1+4)); - nodes1.push_back(new Node(coords1+6)); - nodes1.push_back(new Node(coords1+8)); - nodes1.push_back(new Node(coords1+10)); - nodes1.push_back(new Node(coords1+12)); - nodes1.push_back(new Node(coords1+14)); - QuadraticPolygon *pol1=QuadraticPolygon::buildArcCirclePolygon(nodes1); - std::vector nodes2; - nodes2.push_back(new Node(coords2)); - nodes2.push_back(new Node(coords2+2)); - nodes2.push_back(new Node(coords2+4)); - nodes2.push_back(new Node(coords2+6)); - nodes2.push_back(new Node(coords2+8)); - nodes2.push_back(new Node(coords2+10)); - nodes2.push_back(new Node(coords2+12)); - nodes2.push_back(new Node(coords2+14)); - QuadraticPolygon *pol2=QuadraticPolygon::buildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)v.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,v[0]->getArea(),1.e-6); - delete v[0]; - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegression13() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); - - double coords_1[194]={ - 0, 0, 0.304375, -7.454791178893722e-17, 0.2152256265236553, -0.2152256265236555, -5.591093384170291e-17, -0.304375, - -0.2152256265236555, -0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, - 0.2152256265236554, 0.2152256265236554, 0.60875, -1.490958235778744e-16, 0.5624116654162459, -0.2329585394522483, 0.4304512530473107, -0.4304512530473109, - 0.2329585394522485, -0.5624116654162458, -1.118218676834058e-16, -0.60875, -0.2329585394522482, -0.5624116654162459, -0.4304512530473109, -0.4304512530473108, - -0.5624116654162459, -0.2329585394522483, -0.60875, 7.454791178893722e-17, -0.5624116654162458, 0.2329585394522485, -0.4304512530473108, 0.4304512530473109, - -0.2329585394522484, 0.5624116654162458, 3.727395589446861e-17, 0.60875, 0.2329585394522485, 0.5624116654162458, 0.4304512530473109, 0.4304512530473108, - 0.5624116654162458, 0.2329585394522484, 0.913125, -2.236437353668116e-16, 0.645676879570966, -0.6456768795709663, -1.677328015251087e-16, -0.913125, - -0.6456768795709663, -0.6456768795709661, -0.913125, 1.118218676834058e-16, -0.6456768795709661, 0.6456768795709662, 5.591093384170291e-17, 0.913125, - 0.6456768795709662, 0.6456768795709661, 1.2175, -2.981916471557489e-16, 1.124823330832492, -0.4659170789044966, 0.8609025060946214, -0.8609025060946218, - 0.4659170789044971, -1.124823330832492, -2.236437353668116e-16, -1.2175, -0.4659170789044965, -1.124823330832492, -0.8609025060946218, -0.8609025060946216, - -1.124823330832492, -0.4659170789044967, -1.2175, 1.490958235778744e-16, -1.124823330832492, 0.465917078904497, -0.8609025060946216, 0.8609025060946217, - -0.4659170789044967, 1.124823330832492, 7.454791178893722e-17, 1.2175, 0.4659170789044969, 1.124823330832492, 0.8609025060946217, 0.8609025060946216, - 1.124823330832492, 0.4659170789044968, 1.521875, -3.727395589446861e-16, 1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, - -1.076128132618277, -1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, - 1.076128132618277, 1.076128132618277, 1.82625, -4.472874707336233e-16, 1.687234996248738, -0.6988756183567448, 1.291353759141932, -1.291353759141933, - 0.6988756183567456, -1.687234996248737, -3.354656030502175e-16, -1.82625, -0.6988756183567447, -1.687234996248738, -1.291353759141933, -1.291353759141932, - -1.687234996248738, -0.6988756183567449, -1.82625, 2.236437353668116e-16, -1.687234996248737, 0.6988756183567454, -1.291353759141932, 1.291353759141932, - -0.6988756183567451, 1.687234996248737, 1.118218676834058e-16, 1.82625, 0.6988756183567453, 1.687234996248737, 1.291353759141932, 1.291353759141932, - 1.687234996248737, 0.6988756183567452, 2.130625, -5.218353825225606e-16, 1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, - -1.506579385665588, -1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, - 1.506579385665588, 1.506579385665588, 2.435, -5.963832943114977e-16, 2.249646661664984, -0.9318341578089931, 1.721805012189243, -1.721805012189244, - 0.9318341578089941, -2.249646661664983, -4.472874707336233e-16, -2.435, -0.9318341578089929, -2.249646661664984, -1.721805012189244, -1.721805012189243, - -2.249646661664984, -0.9318341578089934, -2.435, 2.981916471557489e-16, -2.249646661664983, 0.9318341578089939, -1.721805012189243, 1.721805012189243, - -0.9318341578089935, 2.249646661664983, 1.490958235778744e-16, 2.435, 0.9318341578089938, 2.249646661664983, 1.721805012189243, 1.721805012189243, - 2.249646661664983, 0.9318341578089936 }; - - int tab6_1[48]={ - 0, 9, 11, 1, 10, 2, 0, 11, 13, 2, 12, 3, 0, 13, 15, 3, 14, 4, 0, 15, - 17, 4, 16, 5, 0, 17, 19, 5, 18, 6, 0, 19, 21, 6, 20, 7, 0, 21, 23, 7, - 22, 8, 0, 23, 9, 8, 24, 1 }; - - int tab8_1[192]={ - 9, 33, 35, 11, 25, 34, 26, 10, 11, 35, 37, 13, 26, 36, 27, 12, 13, 37, 39, 15, - 27, 38, 28, 14, 15, 39, 41, 17, 28, 40, 29, 16, 17, 41, 43, 19, 29, 42, 30, 18, - 19, 43, 45, 21, 30, 44, 31, 20, 21, 45, 47, 23, 31, 46, 32, 22, 23, 47, 33, 9, - 32, 48, 25, 24, 33, 57, 59, 35, 49, 58, 50, 34, 35, 59, 61, 37, 50, 60, 51, 36, - 37, 61, 63, 39, 51, 62, 52, 38, 39, 63, 65, 41, 52, 64, 53, 40, 41, 65, 67, 43, - 53, 66, 54, 42, 43, 67, 69, 45, 54, 68, 55, 44, 45, 69, 71, 47, 55, 70, 56, 46, - 47, 71, 57, 33, 56, 72, 49, 48, 57, 81, 83, 59, 73, 82, 74, 58, 59, 83, 85, 61, - 74, 84, 75, 60, 61, 85, 87, 63, 75, 86, 76, 62, 63, 87, 89, 65, 76, 88, 77, 64, - 65, 89, 91, 67, 77, 90, 78, 66, 67, 91, 93, 69, 78, 92, 79, 68, 69, 93, 95, 71, - 79, 94, 80, 70, 71, 95, 81, 57, 80, 96, 73, 72 }; - - double coords_2[20]={ - 0.5159941860137611, 0, 0, -0.5159941860137611, -0.5159941860137611, 0, 0, 0.5159941860137611, - 0.6684941860137611, 0, 0, -0.6684941860137611, -0.6684941860137611, 0, 0, 0.6684941860137611, - 0.5922441860137611, 0, -0.5922441860137611, 0 }; - - int tab8_2[16]={ - 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 }; - - double perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2; - - const int *work1=tab6_1; - for(int i=0;i<8;i++,work1+=6) - { - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,6); - const int *work2=tab8_2; - for(int j=0;j<2;j++,work2+=8) - { - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); - //std::vector tmp; - //pol1->intersectForPoint(*pol2,tmp); - pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); - //pol1->intersectMySelfWith(*pol2); - delete pol2; - } - delete pol1; - } - work1=tab8_1; - for(int i=0;i<24;i++,work1+=8) - { - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords_1,work1,8); - const int *work2=tab8_2; - for(int j=0;j<2;j++,work2+=8) - { - - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords_2,work2,8); - //std::vector tmp; - //pol1->intersectForPoint(*pol2,tmp); - pol1->intersectForPerimeter(*pol2,perimeterFromPol1,perimeterFromPol2,perimeterFromPol1AndPol2); - delete pol2; - } - delete pol1; - } -} - -/*! - Some overlapping cases for intersectForPoint. -*/ -void QuadraticPlanarInterpTest::checkNonRegression14() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); - - double coords[72]={ - 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., - -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0., - -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658, - 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5, - -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65, - -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877, - -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565, - -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169, - 0.,-1.3,0.,-1.5 - }; - int tab[48]={ - 0,1,2,3,4,5,6,7, - 8,9,10,11,2,14,12,13, - 9,15,16,10,5,17,18,14, - 9,15,16,10,34,17,35,14, - 19,20,21,22,23,24,25,26, - 27,28,29,30,31,32,2,33 - }; - QuadraticPolygon *pol1,*pol2; - std::vector goalOfTest; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); - // Level 1 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res1[4]={0,1,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res1)); - delete pol2; - // Level 2 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res2[4]={0,2,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2)); - delete pol2; - //Level 2 bis - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+24,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res2Bis[4]={0,2,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res2Bis)); - delete pol2; - // Level 3 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+40,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res3[4]={0,3,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res3)); - delete pol2; - // Level 4 - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+32,8); - pol1->intersectForPoint(*pol2,goalOfTest); - const int res4[4]={0,4,0,0}; - CPPUNIT_ASSERT_EQUAL(4,(int)goalOfTest.size()); - CPPUNIT_ASSERT(equal(goalOfTest.begin(),goalOfTest.end(),res4)); - delete pol2; - // - delete pol1; -} - -/*! - * This test is one of the most complicated intersection configuration. - */ -void QuadraticPlanarInterpTest::checkNonRegression15() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-6); - - double coords[72]={ - 1.,0.,1.3,0.,-1.3,0.,-1.,0.,1.15,0.,0.,1.3,-1.15,0.,0.,1., - -0.91923881554251186,-0.91923881554251186,-0.91923881554251186,0.91923881554251186,-1.0606601717798214,1.0606601717798214,-1.0606601717798214,-1.0606601717798214,-1.5,0., - -0.98994949366116658,-0.98994949366116658,-0.98994949366116658,0.98994949366116658, - 0.91923881554251186,0.91923881554251186,1.0606601717798214,1.0606601717798214,0.98994949366116658,0.98994949366116658, 0., 1.5, - -0.83562389259250125,0.99585777605467141, -0.65, 1.1258330249197703, -1.2216004070216808, 0.44462618632336953, -1.1258330249197703, 0.65, - -0.74564936725635955, 1.0648976575756897, -1.6770646146510724, 1.4072242996141826, -1.1782001231476449, 0.54940374026290939, -1.5873847317707279, 0.74020965686300877, - -1.1782001231476449, 0.54940374026290939, -1.0648976575756894, 0.74564936725635977, -1.2950531075192693, -0.11330246557195534, -1.2950531075192693, 0.11330246557195565, - -1.1258330249197703, 0.65, -2.1146554070041046, 0.56662020857685746, -1.6918048488667423, 0.45331774300490169, - 0.,-1.3,0.,-1.5 - }; - - int tab[24]={ - 0,1,2,3,4,5,6,7, - 9,15,16,10,7,17,5,14, - 9,10,16,15,14,5,17,7 - }; - - const double RefLgth=3.88995883524451; - const double RefArea=0.383185168001075; - // - QuadraticPolygon *pol1,*pol2; - //pol1 and pol2 in same orientation - pol1=buildQuadraticPolygonCoarseInfo(coords,tab,8); - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+8,8); - std::vector res=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); - delete res[0]; - //pol1 and pol2 in same orientation but inversing intersection call pol1<->pol2 - res=pol2->intersectMySelfWith(*pol1); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); - delete res[0]; - delete pol2; - //pol1 and pol2 in opposite orientation - pol2=buildQuadraticPolygonCoarseInfo(coords,tab+16,8); - res=pol1->intersectMySelfWith(*pol2); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-RefArea,res[0]->getArea(),1e-12); - delete res[0]; - //pol1 and pol2 in opposite orientation but inversing intersection call pol1<->pol2 - res=pol2->intersectMySelfWith(*pol1); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_EQUAL(4,res[0]->recursiveSize()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefLgth,res[0]->getPerimeter(),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(RefArea,res[0]->getArea(),1e-12); - delete res[0]; - delete pol2; - // - delete pol1; -} - -class DoubleEqual -{ -public: - DoubleEqual(double eps):_eps(eps) { } - bool operator()(double x, double y) { return fabs(x-y)<_eps; } -private: - double _eps; -}; - -/*! - * This test is to see the reuse of a polygon in intersect* methods. initLocation needed ... - */ -void QuadraticPlanarInterpTest::checkNonRegression16() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords1[194]={ - 0, 0, 0.304375, 0, 0.2152256265236554, 0.2152256265236554, 1.86369779472343e-17, 0.304375, - -0.2152256265236554, 0.2152256265236554, -0.304375, 3.727395589446861e-17, -0.2152256265236555, -0.2152256265236554, -5.591093384170291e-17, -0.304375, - 0.2152256265236553, -0.2152256265236555, 0.60875, 0, 0.5624116654162458, 0.2329585394522484, 0.4304512530473109, 0.4304512530473108, - 0.2329585394522485, 0.5624116654162458, 3.727395589446861e-17, 0.60875, -0.2329585394522484, 0.5624116654162458, -0.4304512530473108, 0.4304512530473109, - -0.5624116654162458, 0.2329585394522485, -0.60875, 7.454791178893722e-17, -0.5624116654162459, -0.2329585394522483, -0.4304512530473109, -0.4304512530473108, - -0.2329585394522482, -0.5624116654162459, -1.118218676834058e-16, -0.60875, 0.2329585394522485, -0.5624116654162458, 0.4304512530473107, -0.4304512530473109, - 0.5624116654162459, -0.2329585394522483, 0.913125, 0, 0.6456768795709662, 0.6456768795709661, 5.591093384170291e-17, 0.913125, - -0.6456768795709661, 0.6456768795709662, -0.913125, 1.118218676834058e-16, -0.6456768795709663, -0.6456768795709661, -1.677328015251087e-16, -0.913125, - 0.645676879570966, -0.6456768795709663, 1.2175, 0, 1.124823330832492, 0.4659170789044968, 0.8609025060946217, 0.8609025060946216, - 0.4659170789044969, 1.124823330832492, 7.454791178893722e-17, 1.2175, -0.4659170789044967, 1.124823330832492, -0.8609025060946216, 0.8609025060946217, - -1.124823330832492, 0.465917078904497, -1.2175, 1.490958235778744e-16, -1.124823330832492, -0.4659170789044967, -0.8609025060946218, -0.8609025060946216, - -0.4659170789044965, -1.124823330832492, -2.236437353668116e-16, -1.2175, 0.4659170789044971, -1.124823330832492, 0.8609025060946214, -0.8609025060946218, - 1.124823330832492, -0.4659170789044966, 1.521875, 0, 1.076128132618277, 1.076128132618277, 9.318488973617152e-17, 1.521875, - -1.076128132618277, 1.076128132618277, -1.521875, 1.86369779472343e-16, -1.076128132618277, -1.076128132618277, -2.795546692085146e-16, -1.521875, - 1.076128132618277, -1.076128132618277, 1.82625, 0, 1.687234996248737, 0.6988756183567452, 1.291353759141932, 1.291353759141932, - 0.6988756183567453, 1.687234996248737, 1.118218676834058e-16, 1.82625, -0.6988756183567451, 1.687234996248737, -1.291353759141932, 1.291353759141932, - -1.687234996248737, 0.6988756183567454, -1.82625, 2.236437353668116e-16, -1.687234996248738, -0.6988756183567449, -1.291353759141933, -1.291353759141932, - -0.6988756183567447, -1.687234996248738, -3.354656030502175e-16, -1.82625, 0.6988756183567456, -1.687234996248737, 1.291353759141932, -1.291353759141933, - 1.687234996248738, -0.6988756183567448, 2.130625, 0, 1.506579385665588, 1.506579385665588, 1.304588456306401e-16, 2.130625, - -1.506579385665588, 1.506579385665588, -2.130625, 2.609176912612803e-16, -1.506579385665588, -1.506579385665588, -3.913765368919204e-16, -2.130625, - 1.506579385665588, -1.506579385665588, 2.435, 0, 2.249646661664983, 0.9318341578089936, 1.721805012189243, 1.721805012189243, - 0.9318341578089938, 2.249646661664983, 1.490958235778744e-16, 2.435, -0.9318341578089935, 2.249646661664983, -1.721805012189243, 1.721805012189243, - -2.249646661664983, 0.9318341578089939, -2.435, 2.981916471557489e-16, -2.249646661664984, -0.9318341578089934, -1.721805012189244, -1.721805012189243, - -0.9318341578089929, -2.249646661664984, -4.472874707336233e-16, -2.435, 0.9318341578089941, -2.249646661664983, 1.721805012189243, -1.721805012189244, - 2.249646661664984, -0.9318341578089931, }; - - int tab1_8[192]={ - 11, 35, 33, 9, 26, 34, 25, 10, 13, 37, 35, 11, 27, 36, 26, 12, 15, 39, 37, 13, - 28, 38, 27, 14, 17, 41, 39, 15, 29, 40, 28, 16, 19, 43, 41, 17, 30, 42, 29, 18, - 21, 45, 43, 19, 31, 44, 30, 20, 23, 47, 45, 21, 32, 46, 31, 22, 9, 33, 47, 23, - 25, 48, 32, 24, 35, 59, 57, 33, 50, 58, 49, 34, 37, 61, 59, 35, 51, 60, 50, 36, - 39, 63, 61, 37, 52, 62, 51, 38, 41, 65, 63, 39, 53, 64, 52, 40, 43, 67, 65, 41, - 54, 66, 53, 42, 45, 69, 67, 43, 55, 68, 54, 44, 47, 71, 69, 45, 56, 70, 55, 46, - 33, 57, 71, 47, 49, 72, 56, 48, 59, 83, 81, 57, 74, 82, 73, 58, 61, 85, 83, 59, - 75, 84, 74, 60, 63, 87, 85, 61, 76, 86, 75, 62, 65, 89, 87, 63, 77, 88, 76, 64, - 67, 91, 89, 65, 78, 90, 77, 66, 69, 93, 91, 67, 79, 92, 78, 68, 71, 95, 93, 69, - 80, 94, 79, 70, 57, 81, 95, 71, 73, 96, 80, 72, }; - - double coords2[20]={ - 2.435, 0, 0, -2.435, -2.435, 0, 0, 2.435, - 2.6925, 0, 0, -2.6925, -2.6925, 0, 0, 2.6925, - 2.56375, 0, -2.56375, 0, }; - - int tab2_8[16]={ 0, 4, 6, 2, 8, 5, 9, 1, 2, 6, 4, 0, 9, 7, 8, 3 }; - - QuadraticPolygon *pol1,*pol2; - //pol1 and pol2 in same orientation - std::vector test1,test2; - for(int ii=0;ii<24;ii++) - { - pol1=buildQuadraticPolygonCoarseInfo(coords1,tab1_8+8*ii,8); - for(int jj=0;jj<2;jj++) - { - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab2_8+jj*8,8); - // - std::vector v1,v2; - pol1->initLocations(); - pol1->intersectForPerimeterAdvanced(*pol2,v1,v2); - if(ii==16 && jj==1) - test1=v1; - if(ii==20 && jj==1) - test2=v1; - delete pol2; - } - delete pol1; - } - const double test1_res[4]={0.,1.9124445278727873,0.,0.}; - CPPUNIT_ASSERT(std::equal(test1.begin(),test1.end(),test1_res,DoubleEqual(1e-10))); - const double test2_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(test2.begin(),test2.end(),test2_res,DoubleEqual(1e-10))); -} - -/*! - * This test checks overlapped intersections END-INSIDE and INSIDE-START with same and opposite orientation. - */ -void QuadraticPlanarInterpTest::checkNonRegression17() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1., 0., 1., 0. , 1.5, 0., -1.5, 0., - 0. , 1., 1.25, 0., 0., 1.5, -1.25, 0.}; - - double coords2[16]={ - 0.70710678118654757, 0.70710678118654757, -1., 0., -1.25, 0., 0.88388347648318444, 0.88388347648318444, - 0., -1., -1.125, 0., 0., -1.25, 0.79549512883486606, 0.79549512883486606 }; - - double coords3[16]={ - 0.70710678118654757, 0.70710678118654757, 0.88388347648318444, 0.88388347648318444, -1.25, 0., -1., 0., - 0.79549512883486606, 0.79549512883486606, 0., -1.25, -1.125, 0., 0., -1. }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords3,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.22089323345553233,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNormalize() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-14); - Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.); - Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.); - Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); - // - QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); - QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - double area1Start=pol1.getArea(); - double xb,yb; - double fact=pol1.normalize(&pol2,xb,yb); - double area1End=pol1.getArea(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14); - double area=pol1.intersectWith(pol2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14); - // - n1=new Node(0.,0.); n4=new Node(0.,-3.); - n2=new Node(10.,0.); n5=new Node(10.,-3.); - n3=new Node(5.,10.); n6=new Node(5.,7.); - e1_2=new EdgeLin(n1,n2); e4_5=new EdgeLin(n4,n5); - e2_3=new EdgeLin(n2,n3); e5_6=new EdgeLin(n5,n6); - e3_1=new EdgeLin(n3,n1); e6_4=new EdgeLin(n6,n4); - QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); - QuadraticPolygon pol4; pol4.pushBack(e4_5); pol4.pushBack(e5_6); pol4.pushBack(e6_4); - n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14); - // Ok testing EdgeArcCircle update. - double center[2]={5.,5.}; - double radius=300.; - EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); - const Bounds& b=e1->getBounds(); - double x,y,fact2; - fact2=b.getCaracteristicDim(); - b.getBarycenter(x,y); - CPPUNIT_ASSERT_DOUBLES_EQUAL(78.539816339744817,e1->getCurveLength(),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15106.061037591669,e1->getAreaOfZone(),1e-10); - e1->getStartNode()->applySimilarity(x,y,fact2); - e1->getEndNode()->applySimilarity(x,y,fact2); - e1->applySimilarity(x,y,fact2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(62.132034355964237,fact2,1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2640792652913602,e1->getCurveLength(),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.034741420428165526,e1->getAreaOfZone(),1e-13); - e1->decrRef(); -} - -} diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx deleted file mode 100644 index c2100449d..000000000 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx +++ /dev/null @@ -1,1173 +0,0 @@ -// Copyright (C) 2007-2010 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 "QuadraticPlanarInterpTest.hxx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" - -#include -#include -#include -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - -class DoubleEqual -{ -public: - DoubleEqual(double eps):_eps(eps) { } - bool operator()(double x, double y) { return fabs(x-y)<_eps; } -private: - double _eps; -}; - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0000() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.383022221559489, -0.1786061951567303, -0.5745333323392334, -0.01790929273509539, 0.5745333323392335, -0.01790929273509556, 0.383022221559489, -0.1786061951567304, - -0.4787777769493612, -0.0982577439459128, 4.592273826833915e-17, 0.25, 0.4787777769493612, -0.09825774394591297, 3.061515884555943e-17, 0 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0001() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.272708,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.272708,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0002() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5745333323392334, 0.4820907072649046, 0.5745333323392335, 0.4820907072649044, 0.383022221559489, 0.3213938048432696, - -0.4787777769493612, 0.4017422560540872, 4.592273826833915e-17, 0.75, 0.4787777769493612, 0.401742256054087, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4979288880273356, 0.4178119462962507, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.4979288880273357, 0.4178119462962505, - -0.555382221261259, 0.4660210170227412, 4.898425415289509e-17, 0.8, 0.5553822212612591, 0.466021017022741, 3.979970649922726e-17, 0.65 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.122173,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.122173,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0003() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3535533905932737, 0.3535533905932738, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.3535533905932738, 0.3535533905932737, - -0.4419417382415922, 0.4419417382415922, 4.592273826833915e-17, 0.75, 0.4419417382415922, 0.4419417382415922, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4979288880273356, 0.4178119462962507, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.4979288880273357, 0.4178119462962505, - -0.555382221261259, 0.4660210170227412, 4.898425415289509e-17, 0.8, 0.5553822212612591, 0.466021017022741, 3.979970649922726e-17, 0.65 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0004() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4596194077712559, 0.4596194077712559, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.4596194077712559, 0.4596194077712559, - -0.4949747468305832, 0.4949747468305833, 4.592273826833915e-17, 0.75, 0.4949747468305833, 0.4949747468305832, 3.979970649922726e-17, 0.65 }; - - double coords2[16]={ - -0.383022221559489, 0.3213938048432697, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.383022221559489, 0.3213938048432696, - -0.4979288880273356, 0.4178119462962507, 4.898425415289509e-17, 0.8, 0.4979288880273357, 0.4178119462962505, 3.061515884555943e-17, 0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0005() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.6128355544951823, 0.5142300877492316, 0.6128355544951825, 0.5142300877492314, 0.383022221559489, 0.3213938048432696, - -0.4979288880273356, 0.4178119462962507, 4.898425415289509e-17, 0.8, 0.4979288880273357, 0.4178119462962505, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4596194077712559, 0.4596194077712559, -0.5303300858899106, 0.5303300858899107, 0.5303300858899107, 0.5303300858899106, 0.4596194077712559, 0.4596194077712559, - -0.4949747468305832, 0.4949747468305833, 4.592273826833915e-17, 0.75, 0.4949747468305833, 0.4949747468305832, 3.979970649922726e-17, 0.65 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol1->intersectWith(*pol2),1.e-6); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.109956,pol2->intersectWith(*pol1),1.e-6); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0006() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, - -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.1811733315717646, 0.6761480784023478, -0.2070552360820167, 0.7727406610312547, 0.2070552360820166, 0.7727406610312547, 0.1811733315717645, 0.6761480784023478, - -0.1941142838268906, 0.7244443697168013, 4.898425415289509e-17, 0.8, 0.1941142838268906, 0.7244443697168013, 4.28612223837832e-17, 0.7 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.366519,0.,0.}; - double test2_res[4]={0.,0.,0.,0.366519}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0007() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, - -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.4499513267805775, 0.5362311101832846, -0.5142300877492315, 0.6128355544951825, -0.1389185421335442, 0.7878462024097664, -0.1215537243668512, 0.6893654271085455, - -0.4820907072649045, 0.5745333323392335, -0.3380946093925595, 0.7250462296293201, -0.1302361332501977, 0.738605814759156, -0.2958327832184895, 0.634415450925655 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.366519,0.,0.}; - double test2_res[4]={0.,0.,0.,0.366519}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0008() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.383022221559489, 0.3213938048432697, -0.5362311101832845, 0.4499513267805776, 0.5362311101832846, 0.4499513267805774, 0.383022221559489, 0.3213938048432696, - -0.4596266658713867, 0.3856725658119237, 4.28612223837832e-17, 0.7, 0.4596266658713868, 0.3856725658119236, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -0.6344154509256549, 0.2958327832184896, -0.72504622962932, 0.3380946093925596, -0.4588611490808367, 0.6553216354311937, -0.401503505445732, 0.5734064310022944, - -0.6797308402774874, 0.3169636963055246, -0.6128355544951823, 0.5142300877492316, -0.4301823272632844, 0.614364033216744, -0.5362311101832845, 0.4499513267805776 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.18326,0.,0.}; - double test2_res[4]={0.,0.,0.,0.18326}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-5))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-5))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0009() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, - -0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; - double coords2[16]={ - 0.5, -1.224606353822377e-16, 0.6, -1.469527624586853e-16, -0.6, 7.347638122934263e-17, -0.5, 6.123031769111886e-17, - 0.55, -1.347066989204615e-16, -1.102145718440139e-16, -0.6, -0.55, 6.735334946023075e-17, -9.184547653667829e-17, -0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0010() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, --0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; - double coords2[16]={ - 0.4346666218300808, -0.1164685702961343, 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4346666218300808, -0.1164685702961342, -0.5071110588017609, -0.1358799986788234, -1.102145718440139e-16, -0.6, -0.507111058801761, -0.1358799986788232, -8.266092888301047e-17, -0.45 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0011() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, --0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4 }; - double coords2[16]={ - 0.4829629131445342, -0.1294095225512603, 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4829629131445342, -0.1294095225512602, -0.5312592044589877, -0.1423504748063864, -1.102145718440139e-16, -0.6, -0.5312592044589877, -0.1423504748063862, -9.184547653667829e-17, -0.5 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - double val1,val2,val3; - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - std::vector val4,val5; - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - double test1_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - val4.clear(); val5.clear(); - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar2511() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.3863703305156274, -0.1035276180410081, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512604, 0.3863703305156274, -0.1035276180410083, - -0.4346666218300808, -0.1164685702961342, 1.416374613080751e-16, 0.5, 0.4346666218300808, -0.1164685702961343, 1.133099690464601e-16, 0.4, }; - - double coords2[16]={ - 0.579555495773441, -0.1552914270615124, -0.579555495773441, -0.1552914270615122, -0.4829629131445342, -0.1294095225512602, 0.4829629131445342, -0.1294095225512603, - -1.102145718440139e-16, -0.6, -0.5312592044589877, -0.1423504748063862, -9.184547653667829e-17, -0.5, 0.5312592044589877, -0.1423504748063864, }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - double val1,val2,val3; - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - std::vector val4,val5; - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - double test1_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - pol1->intersectForPerimeter(*pol2,val1,val2,val3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val1,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val2,1.e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,val3,1.e-13); - val4.clear(); val5.clear(); - pol1->intersectForPerimeterAdvanced(*pol2,val4,val5); - CPPUNIT_ASSERT(std::equal(val4.begin(),val4.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val5.begin(),val5.end(),test1_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0012() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 1.85, 1.224606353822377e-17, 1.95, 1.224606353822377e-17, 1.55, 6.123031769111886e-18, 1.65, - 9.18454765366783e-18, 1.9, 0.2, 1.75, 9.18454765366783e-18, 1.6, 0.1, 1.75 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.05,0.}; - double test2_res[4]={0.,0.,0.05,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,1,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0013() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 1.7, 1.224606353822377e-17, 1.8, 1.224606353822377e-17, 1.4, 6.123031769111886e-18, 1.5, - 9.18454765366783e-18, 1.75, 0.2, 1.6, 9.18454765366783e-18, 1.45, 0.1, 1.6 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.1,0.}; - double test2_res[4]={0.,0.,0.1,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,2,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0014() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, --1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - double coords2[16]={ - 6.123031769111886e-18, 1.55, 1.224606353822377e-17, 1.65, 1.224606353822377e-17, 1.25, 6.123031769111886e-18, 1.35, -9.18454765366783e-18, 1.6, 0.2, 1.45, 9.18454765366783e-18, 1.3, 0.1, 1.45 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.15,0.}; - double test2_res[4]={0.05,0.,0.1,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,3,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0015() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, --1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - double coords2[16]={ - 6.123031769111886e-18, 1.4, 1.224606353822377e-17, 1.5, 1.224606353822377e-17, 1.1, 6.123031769111886e-18, 1.2, -9.18454765366783e-18, 1.45, 0.2, 1.3, 9.18454765366783e-18, 1.15, 0.1, 1.3 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.2,0.}; - double test2_res[4]={0.1,0.,0.1,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,4,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0016() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, --1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - double coords2[16]={ - 6.123031769111886e-18, 1.25, 1.224606353822377e-17, 1.35, 1.224606353822377e-17, 0.95, 6.123031769111886e-18, 1.05, -9.18454765366783e-18, 1.3, 0.2, 1.15, 9.18454765366783e-18, 0.9999999999999999, 0.1, 1.15 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.15,0.}; - double test2_res[4]={0.1,0.,0.05,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,3,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0017() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 1.1, 1.224606353822377e-17, 1.2, 1.224606353822377e-17, 0.8, 6.123031769111886e-18, 0.9, - 9.18454765366783e-18, 1.15, 0.2, 1, 9.18454765366783e-18, 0.85, 0.1, 1 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.1,0.}; - double test2_res[4]={0.1,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,2,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0018() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -1, 1.224606353822377e-16, -1.6, 1.959370166115804e-16, 9.796850830579018e-17, 1.6, 6.123031769111886e-17, 1, - -1.3, 1.591988259969091e-16, -1.131370849898476, 1.131370849898476, 7.959941299845453e-17, 1.3, -0.7071067811865475, 0.7071067811865476 }; - - double coords2[16]={ - 6.123031769111886e-18, 0.95, 1.224606353822377e-17, 1.05, 1.224606353822377e-17, 0.6499999999999999, 6.123031769111886e-18, 0.75, - 9.18454765366783e-18, 1, 0.2, 0.85, 9.18454765366783e-18, 0.7, 0.1, 0.85 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.05,0.}; - double test2_res[4]={0.05,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,1,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0019() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.9500000000000001, 1.836909530733566e-17, 0.8, 3.673819061467131e-17, 1.4, 0, 1.25, 0, - 0.8750000000000001, 2.755364296100349e-17, 1.1, 0.3, 1.325, 0, 1.1, 0.15 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0020() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.05000000000000002, 1.836909530733566e-17, -0.09999999999999998, 3.673819061467131e-17, 0.5, 0, 0.35, 0, - -0.02499999999999997, 2.755364296100349e-17, 0.2, 0.3, 0.425, 0, 0.2, 0.15 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0021() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - -1, -0.07999999999999999, -1.15, -0.07999999999999996, -0.55, -0.08, -0.7, -0.08, - -1.075, -0.07999999999999997, -0.85, 0.22, -0.625, -0.08, -0.85, 0.06999999999999999 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0311485,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0311485,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.162251,0.151523,0.,0.}; - double test2_res[4]={0.,0.311383,0.,0.0978193}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={2,2,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} -void QuadraticPlanarInterpTest::checkNonRegressionOmar0022() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.15, -0.07999999999999999, 0, -0.07999999999999996, 0.6, -0.08, 0.45, -0.08, - 0.07500000000000001, -0.07999999999999997, 0.3, 0.22, 0.5249999999999999, -0.08, 0.3, 0.06999999999999999 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00902229,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00902229,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0023() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5, }; - - double coords2[16]={ - 0.4156854249492381, 0.5656854249492381, 0.2656854249492381, 0.5656854249492381, 0.8656854249492381, 0.5656854249492381, 0.7156854249492381, 0.5656854249492381, - 0.3406854249492381, 0.5656854249492381, 0.5656854249492381, 0.8656854249492381, 0.7906854249492381, 0.5656854249492381, 0.5656854249492381, 0.7156854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0215659,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0215659,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0024() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, --0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - double coords2[16]={ - 0.5656854249492381, 0.5656854249492381, 0.4156854249492382, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, 0.8656854249492382, 0.5656854249492381, -0.4906854249492382, 0.5656854249492381, 0.7156854249492381, 0.8656854249492381, 0.9406854249492381, 0.5656854249492381, 0.7156854249492381, 0.7156854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar2524() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, --0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - double coords2[16]={ - 0.4156854249492382, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, 0.8656854249492382, 0.5656854249492381, 0.5656854249492381, 0.5656854249492381, -0.7156854249492381, 0.8656854249492381, 0.9406854249492381, 0.5656854249492381, 0.7156854249492381, 0.7156854249492381, 0.4906854249492382, 0.5656854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00877657,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0025() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.5, 6.123031769111886e-17, -0.8, 9.796850830579018e-17, 0.8, 0, 0.5, 0, - -0.65, 7.959941299845453e-17, 4.898425415289509e-17, 0.8, 0.65, 0, 3.061515884555943e-17, 0.5 }; - - double coords2[16]={ - 0.715685424949238, 0.5656854249492381, 0.565685424949238, 0.5656854249492381, 1.165685424949238, 0.5656854249492381, 1.015685424949238, 0.5656854249492381, - 0.6406854249492381, 0.5656854249492381, 0.8656854249492381, 0.8656854249492381, 1.090685424949238, 0.5656854249492381, 0.8656854249492381, 0.7156854249492381 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0026() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - 0.1, 0.95, 0.2, 0.95, -0.2, 0.95, -0.1, 0.95, - 0.15, 0.95, 1.224606353822377e-17, 0.75, -0.15, 0.95, 6.123031769111886e-18, 0.85 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0027() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.1, 0.7, -0.2, 0.7, 0.2, 0.7, 0.1, 0.7, - -0.15, 0.7, 1.224606353822377e-17, 0.8999999999999999, 0.15, 0.7, 6.123031769111886e-18, 0.7999999999999999 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00712309,pol1->intersectWith(*pol2),1.e-8); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00712309,pol2->intersectWith(*pol1),1.e-8); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.222704,0.,0.}; - double test2_res[4]={0.1,0.0465335,0.1,0.092554}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,4,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0028() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.07071067811865477, 0.4792893218813453, -0.1414213562373095, 0.4085786437626905, 0.1414213562373095, 0.6914213562373095, 0.07071067811865477, 0.6207106781186548, - -0.1060660171779822, 0.4439339828220179, -0.1414213562373095, 0.6914213562373096, 0.1060660171779822, 0.6560660171779822, -0.07071067811865475, 0.6207106781186548 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.1,0.628319,0.1,0.314159}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0029() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.07071067811865477, 0.1292893218813453, -0.1414213562373095, 0.05857864376269051, 0.1414213562373095, 0.3414213562373095, 0.07071067811865477, 0.2707106781186548, - -0.1060660171779822, 0.09393398282201787, -0.1414213562373095, 0.3414213562373095, 0.1060660171779822, 0.3060660171779822, -0.07071067811865475, 0.2707106781186548 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol1->intersectWith(*pol2),1.e-13); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,pol2->intersectWith(*pol1),1.e-13); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.,0.,0.,0.}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-13))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-13))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,0,0,1}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -void QuadraticPlanarInterpTest::checkNonRegressionOmar0030() -{ - INTERP_KERNEL::QUADRATIC_PLANAR::setPrecision(1e-7); - INTERP_KERNEL::QUADRATIC_PLANAR::setArcDetectionPrecision(1e-7); - double coords[16]={ - -0.4, 4.898425415289509e-17, -0.75, 9.184547653667829e-17, 0.75, 0, 0.4, 0, - -0.575, 7.041486534478669e-17, 4.592273826833915e-17, 0.75, 0.575, 0, 2.449212707644755e-17, 0.4 }; - - double coords2[16]={ - -0.4889087296526012, 0.3889087296526012, -0.5889087296526012, 0.3889087296526012, -0.1889087296526012, 0.3889087296526012, -0.2889087296526012, 0.3889087296526012, - -0.5389087296526012, 0.3889087296526012, -0.3889087296526012, 0.5889087296526012, -0.2389087296526012, 0.3889087296526012, -0.3889087296526012, 0.4889087296526012 }; - - int tab8[8]={ - 0, 1, 2, 3, 4, 5, 6, 7 }; - QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - QuadraticPolygon *pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol1->intersectWith(*pol2),1.e-7); - delete pol1; - delete pol2; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0471239,pol2->intersectWith(*pol1),1.e-7); - delete pol1; - delete pol2; - // - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - std::vector val1,val2; - pol1->intersectForPerimeterAdvanced(*pol2,val1,val2); - double test1_res[4]={0.,0.,0.,0.}; - double test2_res[4]={0.1,0.628319,0.1,0.314159}; - CPPUNIT_ASSERT(std::equal(val1.begin(),val1.end(),test1_res,DoubleEqual(1e-6))); - CPPUNIT_ASSERT(std::equal(val2.begin(),val2.end(),test2_res,DoubleEqual(1e-6))); - delete pol1; - delete pol2; - std::vector val3; - pol1=buildQuadraticPolygonCoarseInfo(coords,tab8,8); - pol2=buildQuadraticPolygonCoarseInfo(coords2,tab8,8); - pol1->intersectForPoint(*pol2,val3); - int test3_res[4]={0,1,0,0}; - CPPUNIT_ASSERT(std::equal(val3.begin(),val3.end(),test3_res)); - delete pol1; - delete pol2; -} - -} diff --git a/src/INTERP_KERNELTest/RemapperTest.cxx b/src/INTERP_KERNELTest/RemapperTest.cxx deleted file mode 100644 index d2876d9a6..000000000 --- a/src/INTERP_KERNELTest/RemapperTest.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2007-2010 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 "RemapperTest.hxx" -#include "Remapper.hxx" -#include "TestInterpKernelUtils.hxx" - -#include -#include - -namespace INTERP_TEST -{ - - - void RemapperTest::setUp() - { - } - - - void RemapperTest::tearDown() - { - } - - /** - * Test that creates a tree in 2D and check that - * the results are correct in three - * cases : - * a non matching search - * a standard case - * a bbox overlapping the bboxes of the tree - */ - void RemapperTest::test_Remapper() { - string sourcename=INTERP_TEST::getResourceFile("square1.med"); - MEDMEM::MESH source_mesh (MED_DRIVER,sourcename,"Mesh_2"); - - string targetname=INTERP_TEST::getResourceFile("square2.med"); - MEDMEM::MESH target_mesh (MED_DRIVER,targetname,"Mesh_3"); - - MEDMEM::SUPPORT source_support(&source_mesh,"on All support"); - MEDMEM::FIELD source_field(&source_support,1); - double* value=const_cast(source_field.getValue()); - for (int i=0; i target_field(&target_support,1); - double* targetvalue=const_cast(target_field.getValue()); - for (int i=0; i *source_areas=source_mesh.getArea(&source_support); - MEDMEM::FIELD *target_areas=target_mesh.getArea(&target_support); - absField(*source_areas); //absolute value - absField(*target_areas); //absolute value - - //target square is in reverse order as compared to initial square - double source_integral=source_field.normL2(1,source_areas); - double target_integral=target_field.normL2(1,target_areas); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(source_integral,target_integral,1e-10); - delete source_areas; - delete target_areas; - - } - - void RemapperTest::absField(MEDMEM::FIELD& field) - { - double* areas=const_cast(field.getValue()); - for (int i=0; i< field.getNumberOfValues();i++) - { - areas[i]=fabs(areas[i]); - } - } - -} diff --git a/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx b/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx deleted file mode 100644 index acbeb72ad..000000000 --- a/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx +++ /dev/null @@ -1,1051 +0,0 @@ -// Copyright (C) 2007-2010 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 "SingleElementPlanarTests.hxx" -#include "InterpolationUtils.hxx" -#include "PolygonAlgorithms.hxx" -#include "PolygonAlgorithms.txx" -#include "InterpolationPlanarTestSuite.hxx" -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - const double _Epsilon = 1.e-12; - const double _Precision = 1.e-12; - const double _losange1[8] = { 1,0, 0,1, -1,0, 0,-1 }; - const double _losange2[8] = { 2,0, 1,1, 0,0, 1,-1 }; - const double _losange3[8] = {2.5,0.5,1.5,1.5,0.5,0.5,1.5,-0.5 }; - const double _square1[8] = { -1,-1, -1,1, 1,1, 1,-1}; - const double _square2[8] = {1,-0.25,0,-0.25,0,0.25,1,0.25 }; - const double _losange4[8] = { 3,0, 2,1, 1,0, 2,-1 }; - const double _losange5[8] = { 1.5,0, 0,1.5,-1.5,0, 0,-1.5 }; - const double _losange6[12]= { 2,0, 1,1, 0.5,0.5,0,0, 0.5,-0.5, 1,-1 }; - const double _losange7[10]= { 1,0, 0,1, -1,0, 0,-1, 0.5,-0.5 }; - const double _square3[10] = { -1,-1, -1,1, 0.5,1, 1,1, 1,-1, }; - const double _square4[8] = {-0.5,-1,-0.5,1,1.5,1,1.5,-1 }; - const double _square5[10] = { -1,-1, -1,1, 0,1, 1,1, 1,-1 }; - const double _losange8[8] = { 0,1, 1,-1, 0,-1.5,-0.5,-1 }; - const double _losange9[8] = {0.5,0, 0,1, -1.5,0, 0,-1 }; - const double _hexagon1[12]= { -2,0, -1,-1, 1,-1, 2,0, 1,1, -1,1 }; - const double _hexagon2[12]= {-1.5,0.5,-1,-1, 1,-1, 2,1, 1,1, -1,1 }; - const double _hexagon3[12]= { -2,2, -1,1, 1,1, 2,2, 1,3, -1,3 }; - const double _square6[8] = { -1,1, -1,3, 0.5,3,0.5,1 }; - const double _losange10[8]= { 0,-1, 1,-2, 0,-3, -1,-2 }; - const double _triangle1[6]= {0.5,0, 1,1, 0,1 }; - const double _triangle2[6]= { 0,0.5, 0,-0.5,1.5,0 }; - const double _triangle3[9]= {-1,2,0, 1,2,0, 0,2,1 }; - const double _triangle4[9]= {1./2,2,0, 1, 2, 1, 1, 2, 0.5 }; - const double _parallel1[8] = {-1,0, -0.5,1, 0.5,1, 0,0}; - const double _parallel2[8]= {-0.5,1, 0,0, 1.,0, 0.5,1 }; - const double _parallel3[8]= {-0.5,-1, 0,0, 1,0, 0.5,-1}; - const double _triangle5[6]= { 0,0, 0,0.5, 0.5,0.5 }; - const double _triangle6[6]= { 1./3,1./3, 1./3,2./3, 2./3,2./3 }; - const double _triangle7[6]= {0.5,2, 1,1, 0,1 }; - const double _triangle8[6]= {22.4601,35.2129, 13.9921,34.693, 18.2853,26.2812 }; - const double _triangle9[6]= {13.9921,34.693, 22.4601,35.2129, 18.2785,42.3869 }; - const double _triangle10[6]= {84.8575,98.2042, 80,100, 82.2601,95.7202}; - const double _triangle11[6]= {80,100, 76.6659,91.9804, 85.3912,92.5061 }; - - /*/ Two diamonds intersecting without degeneracy (two distinct crossing points) - // /\ /\ - // / \/ \ - // / /\ \ - // / / \ \ - // \ \ / / - // \ \/ / - // \ /\ / - // \/ \/ - */ - - // \brief Status : pass - void SingleElementPlanarTests::diamondsBasic() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange2,4,4); - std::deque< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(-0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(1);expected_result.push_back(0); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - void SingleElementPlanarTests::diamondsBasic_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange2,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(1);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(-0.5); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - - /*/ Two diamonds with overlapping edges in an exclusion configuration - // /\ - // / \ - // /\ / \ - // / \/ \ - // / \ / - // / \ / - // \ /\ / - // \ / \/ - // \ / - // \/ - // \brief Status : pass - */ - void SingleElementPlanarTests::tangentDiamonds() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange3,4,4); - std::deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Diamond exclusion tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::tangentDiamonds_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange3,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(1);expected_result.push_back(0); - - CPPUNIT_ASSERT_MESSAGE("Diamond exclusion tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two tangent squares with overlapping edges, in an inclusion configuration - // _____________ - // | | - // | _______| - // | | | - // | |_______| - // | | - // |_____________| - - // \brief Status : pass - void SingleElementPlanarTests::tangentSquares() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square2,4,4); - std::deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(0.25); - expected_result.push_back(0.);expected_result.push_back(-0.25); - expected_result.push_back(1.);expected_result.push_back(-0.25); - expected_result.push_back(1.);expected_result.push_back(0.25); - - CPPUNIT_ASSERT_MESSAGE("Squares inclusion tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::tangentSquares_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square2,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(0.25); - expected_result.push_back(0.25);expected_result.push_back(0.25); - expected_result.push_back(1./6);expected_result.push_back(1./6); - expected_result.push_back(0.);expected_result.push_back(0.25); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(-0.25); - expected_result.push_back(1.);expected_result.push_back(-0.25); - - CPPUNIT_ASSERT_MESSAGE("Squares inclusion tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - /*/ Two diamonds sharing a vertex in an exclusion configuration - // /\ /\ - // / \ / \ - // / \ / \ - // / \/ \ - // \ /\ / - // \ / \ / - // \ / \ / - // \/ \/ - */ - - // \brief Status : pass - void SingleElementPlanarTests::diamondsSharingVertex1() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange4,4,4); - std::deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Diamond sharing (1) vertex test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::diamondsSharingVertex1_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange4,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(1.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Diamonds sharing (1) vertex test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two identical squares - // _____________ - // | | - // | | - // | | - // | | - // | | - // |_____________| - - // \brief Status : pass - void SingleElementPlanarTests::identicalSquares() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square1,4,4); - std::deque< double > expected_result; - - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::identicalSquares_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square1,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - /*/ Square and diamond intersecting with no degeneracy - // /\ - // / \ - // / \ - // __/______\__ - // | / \ | - // |/ \| - // / \ - // /| |\ - // \| |/ - // \ / - // |\ /| - // |_\________/_| - // \ / - // \ / - // \ / - // \/ - // \brief Status : pass - */ - void SingleElementPlanarTests::squareAndDiamondBasic() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_losange5,4,4); - std::deque< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(0.5); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(0.5); - expected_result.push_back(-1.);expected_result.push_back(-0.5); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-0.5); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::squareAndDiamondBasic_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_losange5,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(0.); - expected_result.push_back(1.);expected_result.push_back(0.5); - expected_result.push_back(0.75);expected_result.push_back(0.75); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(0.5); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(-1.);expected_result.push_back(-0.5); - expected_result.push_back(-0.75);expected_result.push_back(-0.75); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-0.5); - - - // EAP: different place of (0,0) point on 32 and 64-bits platforms - // we comment it for the sake of "make check" to pass - //CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (TRIANGULATION), maybe not significant (0,0) should be removed", - //(INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // square and diamond intersecting at four degenerated pointss - // ______ - // | /\ | - // | / \ | - // |/ \| - // |\ /| - // | \ / | - // |__\/__| - // \brief Status : pass - - void SingleElementPlanarTests::squareAndDiamondCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_losange1,4,4); - std::deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(1.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::squareAndDiamondCritical_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_losange1,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(-0.5);expected_result.push_back(-0.5); - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(0.); - - // 0020208: Unit Test of MED failed -// CPPUNIT_ASSERT_MESSAGE("Square and diamond basic test failed (TRIANGULATION) maybe not significant (0,0) should be removed", -// (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - /*/ Two diamonds intersecting at one vertex on edge and one double vertex - // /\ /\ - // / \ / \ - // / ¤ \ - // / / \ \ - // \ \ / / - // \ * / - // \ / \ / - // \/ \/ - */ - - // \brief Status : pass - void SingleElementPlanarTests::diamondsCritical() - { - - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_losange6,_losange7,6,5); - std::deque< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(-0.5); - expected_result.push_back(0.5);expected_result.push_back(-0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(1);expected_result.push_back(0); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::diamondsCritical_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange6,_losange7,6,5,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(0.5); - expected_result.push_back(0);expected_result.push_back(0); - expected_result.push_back(0.5);expected_result.push_back(-0.5); - - CPPUNIT_ASSERT_MESSAGE("Basic diamond crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two tangent squares with starting and ending vertices on edges - // _____ ___.___ ______ - // | | | | - // | | | | - // | | | | - // | | | | - // | | | | - // |_____|_______|______| - - // \brief Status : pass - void SingleElementPlanarTests::quadranglesCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square4,_square3,4,5); - std::deque< double > expected_result; - - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Critical quadrangles with tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::quadranglesCritical_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square4,_square3,4,5,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(0.5); - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(-1./3); - expected_result.push_back(-0.5);expected_result.push_back(-0.5); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Critical quadrangles with tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - - // square and diamond crossing and tangency at double vertices, starting vertex on edge - // _____.____ - // | / \ | - // | / \ | - // | / \ | - // |_/_______\| - // \ / - // \ / - // \ / - // \ / - // \brief Status : pass - void SingleElementPlanarTests::quadrangleAndDiamondCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square5,_losange8,5,4); - std::deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::quadrangleAndDiamondCritical_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square5,_losange8,5,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1./3);expected_result.push_back(1./3); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(-1./3);expected_result.push_back(-1./3); - expected_result.push_back(-0.5);expected_result.push_back(-1.); - expected_result.push_back(0.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Square and diamond critical tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } // square and diamond intersecting at four degenerated pointss - /*/ - // ²/²\ - // ² / ² \ - // ² / ² \ - // ² \ ² / - // ² \ ² / - // ²\²/ - // \brief Status : pass - */ - void SingleElementPlanarTests::diamondsCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange9,4,4); - std::deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(-1.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Diamonds with crossing at double vertex test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::diamondsCritical2_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange9,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(-1.); - expected_result.push_back(0.5);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Diamonds with crossing at double vertex test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - /*/ Two tangent hexagons with double vertices and a critical starting vertex on edge - // _________ - // / \²²² - // ² \² - // / \ - // / ² ² \ - // \ / - // \ ² ² / - // \ / - // \²_______²/ - */ - - // \brief Status : pass - void SingleElementPlanarTests::hexagonsCritical1() - { - - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_hexagon1,_hexagon2,6,6); - std::deque< double > expected_result; - - expected_result.push_back(5./3);expected_result.push_back(1./3); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(-1.5);expected_result.push_back(0.5); - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("First hexagon critical crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::hexagonsCritical1_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_hexagon1,_hexagon2,6,6,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(-1.5);expected_result.push_back(0.5); - expected_result.push_back(-8./7);expected_result.push_back(2./7); - expected_result.push_back(-1.4);expected_result.push_back(0.2); - expected_result.push_back(-4./3);expected_result.push_back(0.); - expected_result.push_back(-2./3);expected_result.push_back(0.); - expected_result.push_back(-1.25);expected_result.push_back(-0.25); - expected_result.push_back(-1.);expected_result.push_back(-1.); - expected_result.push_back(1.);expected_result.push_back(-1.); - expected_result.push_back(1.5);expected_result.push_back(0.); - expected_result.push_back(5./3);expected_result.push_back(1./3); - expected_result.push_back(1.125);expected_result.push_back(0.875); - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(0.25);expected_result.push_back(0.75); - - CPPUNIT_ASSERT_MESSAGE("First hexagon critical crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - /*/ Two tangent hexagons with double vertices and a critical starting vertex on edge - // _______ - // / \ - // / \ - // \ / - // \_______/ - // / \ - // / \ - // \ / - // \_______/ - */ - - // \brief Status : pass - void SingleElementPlanarTests::hexagonsCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_hexagon1,_hexagon3,6,6); - std::deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Second hexagon critical crossing test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::hexagonsCritical2_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_hexagon1,_hexagon3,6,6,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(-1.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Second hexagon critical crossing test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Square and quadrilateron with outer tangency - // ________ - // | | - // | | - // | | - // |________|___ - // | | - // | | - // | | - // | | - // | | - // |____________| - - // \brief Status : pass - void SingleElementPlanarTests::squareAndQuadrangleCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_square6,4,4); - std::deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::squareAndQuadrangleCritical_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_square6,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(-1.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - /*/ Two diamonds sharing a vertex in an exclusion configuration - // /\ - // / \ - // / \ - // / \ - // \ / - // \ / - // \ / - // \/ - // /\ - // / \ - // / \ - // / \ - // \ / - // \ / - // \ / - // \/ - */ - - // \brief Status : pass - void SingleElementPlanarTests:: diamondsSharingVertex2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_losange10,4,4); - std::deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Diamond sharing vertex (2) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests:: diamondsSharingVertex2_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_losange10,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(0.);expected_result.push_back(-1.); - - CPPUNIT_ASSERT_MESSAGE("Diamond sharing vertex (2) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - /*/ Triangle and diamond with a critical crossing at double starting vertex - // ____ - // /|\ / - // / | \/ - // / | /\ - // / |/ \ - // \ / - // \ / - // \ / - // \ / - */ - // \brief Status : pass - void SingleElementPlanarTests:: triangleAndDiamondCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_losange1,_triangle1,4,3); - std::deque< double > expected_result; - - expected_result.push_back(2./3);expected_result.push_back(1./3); - expected_result.push_back(0.5);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Triangle and diamonds critical test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests:: triangleAndDiamondCritical_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_losange1,_triangle1,4,3,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(2./3);expected_result.push_back(1./3); - expected_result.push_back(0.);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Triangle and diamonds critical test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - /*/ Basic triangle and square intersection (two distinct points) - // __________ - // | | - // | |\ | - // | | \| - // | | \ - // | | |\ - // | | |/ - // | | / - // | | /| - // | |/ | - // |__________| - */ - // \brief Status : pass - void SingleElementPlanarTests::triangleAndSquareBasic() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_square1,_triangle2,4,3); - std::deque< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(1./6); - expected_result.push_back(1.);expected_result.push_back(-1./6); - expected_result.push_back(0.);expected_result.push_back(-0.5); - expected_result.push_back(0.);expected_result.push_back(0.5); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - void SingleElementPlanarTests::triangleAndSquareBasic_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_square1,_triangle2,4,3,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1.);expected_result.push_back(1./6); - expected_result.push_back(0.375);expected_result.push_back(0.375); - expected_result.push_back(0.);expected_result.push_back(0.5); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(-0.5); - expected_result.push_back(1.);expected_result.push_back(-1./6); - - CPPUNIT_ASSERT_MESSAGE("Identical squares test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - /*/ Two triangles with a starting vertex on edge - - // /\ ²²²² - // / ² ² - // / ² ² - // /__²___\ - */ - // \brief Status : pass - void SingleElementPlanarTests::trianglesCritical() - { - INTERP_KERNEL::PolygonAlgorithms<3> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_triangle3,_triangle4,3,3); - std::deque< double > expected_result; - - expected_result.push_back(2./3);expected_result.push_back(2.);expected_result.push_back(1./3); - expected_result.push_back(0.5);expected_result.push_back(2.);expected_result.push_back(0.); - expected_result.push_back(0.75);expected_result.push_back(2.);expected_result.push_back(0.25); - - CPPUNIT_ASSERT_MESSAGE("Triangles critical test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,3>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesCritical_Triangulation() - { - std::vector< double > actual_result; - double _triangle3rotated[6],_triangle4rotated[6]; - for (int i=0; i<3; i++)_triangle3rotated[2*i] = _triangle3[3*i]; - for (int i=0; i<3; i++)_triangle3rotated[2*i+1] = _triangle3[3*i+2]; - for (int i=0; i<3; i++)_triangle4rotated[2*i] = _triangle4[3*i]; - for (int i=0; i<3; i++)_triangle4rotated[2*i+1] = _triangle4[3*i+2]; - - INTERP_KERNEL::intersec_de_polygone<2>(_triangle3rotated,_triangle4rotated,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(0.5);expected_result.push_back(0.); - expected_result.push_back(2./3);expected_result.push_back(1./3); - expected_result.push_back(0.75);expected_result.push_back(0.25); - - CPPUNIT_ASSERT_MESSAGE("Triangles critical test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - /*/ Two tangent paralellograms intersecting at 3 double vertices (one being a starting vertex) - // _______ - // /\ /\ - // / \ / \ - // / \ / \ - // /______\/______\ - */ - - // \brief Status : pass - void SingleElementPlanarTests::paralellogramsCritical1() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_parallel1,_parallel2,4,4); - std::deque< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(0.);expected_result.push_back(0.); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(0.5);expected_result.push_back(1.); - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test (1) failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::paralellogramsCritical1_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_parallel1,_parallel2,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(0.25);expected_result.push_back(0.5); - expected_result.push_back(0.5);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(2./3); - expected_result.push_back(-0.5);expected_result.push_back(1.); - expected_result.push_back(-0.25);expected_result.push_back(0.5); - expected_result.push_back(0.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test (1) failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two paralellograms sharing a vertex in an exclusion configuration - // ________ - // / / - // / / - // / / - // /_______/_______ - // / / - // / / - // / / - // /_______/ - - - // \brief Status : pass - void SingleElementPlanarTests::paralellogramsCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_parallel1,_parallel3,4,4); - std::deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::paralellogramsCritical2_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_parallel1,_parallel3,4,4,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(0.);expected_result.push_back(0.); - - CPPUNIT_ASSERT_MESSAGE("Paralellogram tangency test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - // Two triangles in a tangency configuration with a starting vertex on edge - - // _____ - // | / - // __|___/ - // | | / - // | | / - // | |/ - // | / - // | / - // |/ - - // \brief Status : pass - void SingleElementPlanarTests::trianglesTangencyCritical() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_triangle5,_triangle6,3,3); - std::deque< double > expected_result; - - expected_result.push_back(1./3);expected_result.push_back(1./2); - expected_result.push_back(1./3);expected_result.push_back(1./3); - expected_result.push_back(1./2);expected_result.push_back(1./2); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle5,_triangle6,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - - expected_result.push_back(1./3);expected_result.push_back(1./2); - expected_result.push_back(1./2);expected_result.push_back(1./2); - expected_result.push_back(1./3);expected_result.push_back(1./3); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - - /*/ Two triangles with double starting point in an outer tangency configuration - // /\ - // / \ - // / \ - // /______\ - // \ / - // \ / - // \ / - // \/ - */ - - // \brief Status : pass - void SingleElementPlanarTests::trianglesTangencyCritical2() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_triangle1,_triangle7,3,3); - std::deque< double > expected_result; - - // if(!checkDequesEqual(actual_result,expected_result, _Epsilon)) - // { - // std::cerr<< "CPP_UNIT expected result= " << std::endl; - // dequePrintOut(expected_result); - // std::cerr<< "CPP_UNIT actual result= " << std::endl; - // dequePrintOut(actual_result); - // } - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (2) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical2_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle1,_triangle7,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(1.);expected_result.push_back(1.); - expected_result.push_back(0.);expected_result.push_back(1.); - - // if(!checkVectorsEqual(actual_result,expected_result, _Epsilon)) - // { - // cerr<< "CPP_UNIT expected result= " << endl; - // vectPrintOut(expected_result); - // cerr<< "CPP_UNIT actual result= " << endl; - // vectPrintOut(actual_result); - // } - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (2) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - // \brief Status : pass - void SingleElementPlanarTests::trianglesTangencyCritical3() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_triangle8,_triangle9,3,3); - std::deque< double > expected_result; - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (3) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical3_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle8,_triangle9,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(22.4601);expected_result.push_back(35.2129); - expected_result.push_back(13.9921);expected_result.push_back(34.693); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (3) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical4() - { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; - std::deque< double > actual_result = intersector.intersectConvexPolygons(_triangle10,_triangle11,3,3); - - std::deque< double > expected_result; - expected_result.push_back(82.745193090443536);expected_result.push_back(96.184114390029166); - expected_result.push_back(82.260099999999994);expected_result.push_back(95.720200000000006); - expected_result.push_back(80);expected_result.push_back(100.); - - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (4) test failed (CONVEX)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - void SingleElementPlanarTests::trianglesTangencyCritical4_Triangulation() - { - std::vector< double > actual_result; - INTERP_KERNEL::intersec_de_polygone<2>(_triangle10,_triangle11,3,3,actual_result,_Epsilon/_Precision, _Precision ); - - std::vector< double > expected_result; - expected_result.push_back(80);expected_result.push_back(100.); - expected_result.push_back(82.745193090443536);expected_result.push_back(96.184114390029166); - expected_result.push_back(82.260099999999994);expected_result.push_back(95.720200000000006); - - CPPUNIT_ASSERT_MESSAGE("Triangles tangency critical (4) test failed (TRIANGULATION)", - (INTERP_KERNEL::checkEqualPolygons,2>(&actual_result, &expected_result, _Epsilon))); - } - -} diff --git a/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx b/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx deleted file mode 100644 index 79e49ba04..000000000 --- a/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2007-2010 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 __SINGLE_ELEMENT_PLANAR_TESTS_HXX_ -#define __SINGLE_ELEMENT_PLANAR_TESTS_HXX_ - -#include "InterpKernelTestExport.hxx" -#include "InterpolationPlanarTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting simple meshes having only one planar element each. - * This serves mainly to verify that the volume calculations between elements is correct. - * - */ - class INTERPKERNELTEST_EXPORT SingleElementPlanarTests : public InterpolationPlanarTestSuite - { - CPPUNIT_TEST_SUITE( SingleElementPlanarTests ); - - CPPUNIT_TEST( diamondsBasic ); - CPPUNIT_TEST( tangentDiamonds ); - CPPUNIT_TEST( tangentSquares ); - CPPUNIT_TEST( diamondsSharingVertex1 ); - CPPUNIT_TEST( identicalSquares ); - CPPUNIT_TEST( squareAndDiamondBasic ); - CPPUNIT_TEST( squareAndDiamondCritical ); - CPPUNIT_TEST( diamondsCritical ); - CPPUNIT_TEST( quadranglesCritical ); - CPPUNIT_TEST( quadrangleAndDiamondCritical ); - CPPUNIT_TEST( diamondsCritical2 ); - CPPUNIT_TEST( hexagonsCritical1 ); - CPPUNIT_TEST( hexagonsCritical2 ); - CPPUNIT_TEST( squareAndQuadrangleCritical ); - CPPUNIT_TEST( diamondsSharingVertex2 ); - CPPUNIT_TEST( triangleAndDiamondCritical ); - CPPUNIT_TEST( triangleAndSquareBasic ); - CPPUNIT_TEST( trianglesCritical ); - CPPUNIT_TEST( paralellogramsCritical1 ); - CPPUNIT_TEST( paralellogramsCritical2 ); - CPPUNIT_TEST( trianglesTangencyCritical ); - CPPUNIT_TEST( trianglesTangencyCritical2 ); - CPPUNIT_TEST( trianglesTangencyCritical3 ); - CPPUNIT_TEST( trianglesTangencyCritical4 ); - CPPUNIT_TEST( diamondsBasic_Triangulation ); - CPPUNIT_TEST( tangentDiamonds_Triangulation ); - CPPUNIT_TEST( tangentSquares_Triangulation ); - CPPUNIT_TEST( diamondsSharingVertex1_Triangulation ); - CPPUNIT_TEST( identicalSquares_Triangulation ); - //CPPUNIT_TEST( squareAndDiamondBasic_Triangulation ); - //CPPUNIT_TEST( squareAndDiamondCritical_Triangulation ); - CPPUNIT_TEST( diamondsCritical_Triangulation ); - CPPUNIT_TEST( quadranglesCritical_Triangulation ); - CPPUNIT_TEST( quadrangleAndDiamondCritical_Triangulation ); - CPPUNIT_TEST( diamondsCritical2_Triangulation ); - CPPUNIT_TEST( hexagonsCritical1_Triangulation ); - CPPUNIT_TEST( hexagonsCritical2_Triangulation ); - CPPUNIT_TEST( squareAndQuadrangleCritical_Triangulation ); - CPPUNIT_TEST( diamondsSharingVertex2_Triangulation ); - CPPUNIT_TEST( triangleAndDiamondCritical_Triangulation ); - CPPUNIT_TEST( triangleAndSquareBasic_Triangulation ); - CPPUNIT_TEST( trianglesCritical_Triangulation ); - CPPUNIT_TEST( paralellogramsCritical1_Triangulation ); - CPPUNIT_TEST( paralellogramsCritical2_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical2_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical3_Triangulation ); - CPPUNIT_TEST( trianglesTangencyCritical4_Triangulation ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - void diamondsBasic(); - void tangentDiamonds(); - void tangentSquares(); - void diamondsSharingVertex1(); - void identicalSquares(); - void squareAndDiamondBasic(); - void squareAndDiamondCritical(); - void diamondsCritical(); - void quadranglesCritical(); - void quadrangleAndDiamondCritical(); - void diamondsCritical2(); - void hexagonsCritical1(); - void hexagonsCritical2(); - void squareAndQuadrangleCritical(); - void diamondsSharingVertex2(); - void triangleAndDiamondCritical(); - void triangleAndSquareBasic(); - void trianglesCritical(); - void paralellogramsCritical1(); - void paralellogramsCritical2(); - void trianglesTangencyCritical(); - void trianglesTangencyCritical2(); - void trianglesTangencyCritical3(); - void trianglesTangencyCritical4(); - void diamondsBasic_Triangulation(); - void tangentDiamonds_Triangulation(); - void tangentSquares_Triangulation(); - void diamondsSharingVertex1_Triangulation(); - void identicalSquares_Triangulation(); - void squareAndDiamondBasic_Triangulation(); - void squareAndDiamondCritical_Triangulation(); - void diamondsCritical_Triangulation(); - void quadranglesCritical_Triangulation(); - void quadrangleAndDiamondCritical_Triangulation(); - void diamondsCritical2_Triangulation(); - void hexagonsCritical1_Triangulation(); - void hexagonsCritical2_Triangulation(); - void squareAndQuadrangleCritical_Triangulation(); - void diamondsSharingVertex2_Triangulation(); - void triangleAndDiamondCritical_Triangulation(); - void triangleAndSquareBasic_Triangulation(); - void trianglesCritical_Triangulation(); - void paralellogramsCritical1_Triangulation(); - void paralellogramsCritical2_Triangulation(); - void trianglesTangencyCritical_Triangulation(); - void trianglesTangencyCritical2_Triangulation(); - void trianglesTangencyCritical3_Triangulation(); - void trianglesTangencyCritical4_Triangulation(); - }; -} -#endif diff --git a/src/INTERP_KERNELTest/SingleElementTetraTests.hxx b/src/INTERP_KERNELTest/SingleElementTetraTests.hxx deleted file mode 100644 index 0d3b75570..000000000 --- a/src/INTERP_KERNELTest/SingleElementTetraTests.hxx +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2007-2010 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 __SINGLE_ELEMENT_TETRA_TESTS_HXX_ -#define __SINGLE_ELEMENT_TETRA_TESTS_HXX_ - -#include "InterpolationTestSuite.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Class testing algorithm by intersecting simple meshes having only one element each. This serves mainly to verify that - * the volume calculations between elements is correct. - * - */ - class SingleElementTetraTests : public InterpolationTestSuite<3,3> - { - CPPUNIT_TEST_SUITE( SingleElementTetraTests ); - - CPPUNIT_TEST( tetraReflexiveUnit ); - CPPUNIT_TEST( tetraReflexiveGeneral ); - CPPUNIT_TEST( tetraNudgedSimpler ); - CPPUNIT_TEST( tetraNudged ); - CPPUNIT_TEST( tetraCorner ); - CPPUNIT_TEST( tetraSimpleIncluded ); - CPPUNIT_TEST( tetraDegenEdge ); - CPPUNIT_TEST( tetraDegenFace ); - CPPUNIT_TEST( tetraDegenTranslatedInPlane ); - CPPUNIT_TEST( tetraHalfstripOnly ); - CPPUNIT_TEST( tetraHalfstripOnly2 ); - CPPUNIT_TEST( tetraSimpleHalfstripOnly ); - CPPUNIT_TEST( generalTetra ); - CPPUNIT_TEST( trickyTetra1 ); - // CPPUNIT_TEST( inconsistentTetra ); - - CPPUNIT_TEST_SUITE_END(); - - public: - - /// Unit tetrahedron mesh intersecting itself - /// \brief Status : pass - void tetraReflexiveUnit() - { - _testTools->intersectMeshes("UnitTetra", "UnitTetra", 1.0/6.0); - } - - /// Tetrahedron mesh with itself - /// \brief Status : pass - void tetraReflexiveGeneral() - { - _testTools->intersectMeshes("GeneralTetra", "GeneralTetra", 0.428559); - } - - /// Unit tetrahedron mesh intersecting slightly displaced copy of itself - /// \brief Status : pass - void tetraNudged() - { - _testTools->intersectMeshes("UnitTetra", "NudgedTetra", 0.142896); - } - - /// Single-element unit tetrahedron mesh intersecting even slightly displaced (along one axis only) copy of itself - /// \brief Status : pass - void tetraNudgedSimpler() - { - _testTools->intersectMeshes("UnitTetra", "NudgedSimpler", 0.152112); - } - - /// Tetrahedron intersecting unit tetrahedron with in non-degenerate way around corner O - /// \brief Status : pass - void tetraCorner() - { - _testTools->intersectMeshes("UnitTetra", "CornerTetra", 0.0135435); - } - - /// Tetrahedron situated totally inside another - /// \brief Status : pass - void tetraSimpleIncluded() - { - _testTools->intersectMeshes("SimpleIncludedTetra", "SimpleIncludingTetra", 17.0156); - } - - /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares an edge - /// \brief Status : pass - void tetraDegenEdge() - { - _testTools->intersectMeshes("UnitTetraDegenT", "DegenEdgeXY", 0.0); - } - - /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares a face - /// \brief Status : pass - void tetraDegenFace() - { - _testTools->intersectMeshes("UnitTetraDegenT", "DegenFaceXYZ", 0.0); - } - - /// Displaced unit tetrahedron intersecting another unit tetrahedron with which it shares a part of the face XYZ - /// \brief Status : pass - void tetraDegenTranslatedInPlane() - { - _testTools->intersectMeshes("UnitTetraDegenT", "DegenTranslatedInPlane", 0.0571667); - } - - /// Tetrahedron having only half-strip intersections with the unit tetrahedron - /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. - void tetraHalfstripOnly() - { - // NB this test is not completely significant : we should also verify that - // there are triangles on the element that give a non-zero volume - _testTools->intersectMeshes("HalfstripOnly", "UnitTetra", 0.0); - } - - /// Tetrahedron having only half-strip intersections with the unit tetrahedron - /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. - void tetraHalfstripOnly2() - { - // NB this test is not completely significant : we should also verify that - // there are triangles on the element that give a non-zero volume - _testTools->intersectMeshes("HalfstripOnly2", "UnitTetra", 0.0); - } - - /// Tetrahedron having only half-strip intersections with the unit tetrahedron - /// \brief Status : pass, but does not really test what it should - does not check that the intersections are detected. No longer needed. - void tetraSimpleHalfstripOnly() - { - // NB this test is not completely significant : we should also verify that - // there are triangles on the element that give a non-zero volume - _testTools->intersectMeshes("SimpleHalfstripOnly", "UnitTetra", 0.0); - } - - /// Two intersecting tetrahedra situated in a general position in space - /// \brief Status : pass - void generalTetra() - { - _testTools->intersectMeshes("GenTetra1", "GenTetra2", 4.91393); - } - - /// Tetrahedron which is in a tricky position relative to unit tetrahedron. - /// \brief Status : pass - void trickyTetra1() - { - _testTools->intersectMeshes("UnitTetra", "TrickyTetra1", 0.0); - } - - /// Two large tetrahedra which nearly share part of an edge and intersect at the origin. Created with goal of getting the as-of-yet uncovered "consistency" test - /// part of the correction of double products covered. However, it does not succeed with this. - /// \brief Status : fails, but is quite far-fetched as far as typical use cases are concerned - void inconsistentTetra() - { - _testTools->intersectMeshes("LargeUnitTetra.med", "LargeUnitTetra", "LargeInconsistentTetra.med", "LargeInconsistent", 7.86231e7); - } - - }; -} -#endif diff --git a/src/INTERP_KERNELTest/TestInterpKernel.cxx b/src/INTERP_KERNELTest/TestInterpKernel.cxx deleted file mode 100644 index 9c10a2142..000000000 --- a/src/INTERP_KERNELTest/TestInterpKernel.cxx +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2007-2010 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 "CppUnitTest.hxx" -#include "BBTreeTest.hxx" -#include "ExprEvalInterpTest.hxx" -#include "QuadraticPlanarInterpTest.hxx" -#include "SingleElementPlanarTests.hxx" -#include "TransformedTriangleIntersectTest.hxx" -#include "TransformedTriangleTest.hxx" -#include "UnitTetraIntersectionBaryTest.hxx" - -#ifdef DISABLE_MICROMED -#include "HexaTests.hxx" -#include "InterpolationOptionsTest.hxx" -#include "MultiElement2DTests.hxx" -#include "MultiElementTetraTests.hxx" -#include "PointLocatorTest.hxx" -#include "SingleElementTetraTests.hxx" -#endif - -using namespace INTERP_TEST; - -//--- Registers the fixture into the 'registry' - -CPPUNIT_TEST_SUITE_REGISTRATION( BBTreeTest); -CPPUNIT_TEST_SUITE_REGISTRATION( ExprEvalInterpTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( QuadraticPlanarInterpTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( SingleElementPlanarTests ); -CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleIntersectTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( UnitTetraIntersectionBaryTest ); - -#ifdef DISABLE_MICROMED -CPPUNIT_TEST_SUITE_REGISTRATION( HexaTests ); -CPPUNIT_TEST_SUITE_REGISTRATION( InterpolationOptionsTest ); -CPPUNIT_TEST_SUITE_REGISTRATION( MultiElement2DTests ); -CPPUNIT_TEST_SUITE_REGISTRATION( MultiElementTetraTests ); -CPPUNIT_TEST_SUITE_REGISTRATION( PointLocatorTest); -CPPUNIT_TEST_SUITE_REGISTRATION( SingleElementTetraTests ); -#endif - -// --- generic Main program from KERNEL_SRC/src/Basics/Test - -#include "BasicMainTest.hxx" diff --git a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx deleted file mode 100644 index 1d98bdf27..000000000 --- a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2007-2010 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 "TestInterpKernelUtils.hxx" - -#include - -namespace INTERP_TEST -{ - std::string getResourceFile( const std::string& filename ) - { - std::string resourceFile = ""; - - if ( getenv("top_srcdir") ) { - // we are in 'make check' step - resourceFile = getenv("top_srcdir"); - resourceFile += "/resources/"; - } - else if ( getenv("MED_ROOT_DIR") ) { - // use MED_ROOT_DIR env.var - resourceFile = getenv("MED_ROOT_DIR"); - resourceFile += "/share/salome/resources/med/"; - } - resourceFile += filename; - return resourceFile; - } - -} // namespace INTERP_TEST diff --git a/src/INTERP_KERNELTest/TestInterpKernelUtils.hxx b/src/INTERP_KERNELTest/TestInterpKernelUtils.hxx deleted file mode 100644 index 1cedbd291..000000000 --- a/src/INTERP_KERNELTest/TestInterpKernelUtils.hxx +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2007-2010 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 _TESTINTERPKERNELUTILS_HXX_ -#define _TESTINTERPKERNELUTILS_HXX_ - -#include "InterpKernelTestExport.hxx" - -#include - -namespace INTERP_TEST -{ - - INTERPKERNELTEST_EXPORT std::string getResourceFile( const std::string& ); - -} // namespace INTERP_TEST - -#endif // _TESTINTERPKERNELUTILS_HXX_ diff --git a/src/INTERP_KERNELTest/TestingUtils.hxx b/src/INTERP_KERNELTest/TestingUtils.hxx deleted file mode 100644 index 0ba270798..000000000 --- a/src/INTERP_KERNELTest/TestingUtils.hxx +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (C) 2007-2010 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 _TESTING_UTILS_HXX_ -#define _TESTING_UTILS_HXX_ - -#include "Interpolation3D.hxx" -#include "MEDMEM_Mesh.hxx" - -#include -#include -#include -#include -#include - -#include "VectorUtils.hxx" - -// levels : -// 1 - titles and volume results -// 2 - symmetry / diagonal results and intersection matrix output -// 3 - empty -// 4 - empty -// 5 - misc -#include "Log.hxx" - -using namespace MEDMEM; -using namespace INTERP_KERNEL; -using namespace MED_EN; - - -double sumVolume(const IntersectionMatrix& m) -{ - - vector volumes; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - volumes.push_back(iter2->second); - // vol += std::fabs(iter2->second); - } - } - - // sum in ascending order to avoid rounding errors - - sort(volumes.begin(), volumes.end()); - const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); - - return vol; -} - -#if 0 - -bool areCompatitable(const IntersectionMatrix& m1, const IntersectionMatrix& m2) -{ - bool compatitable = true; - int i = 0; - for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - if(m2.at(j-1).count(i+1) == 0) - { - if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) - { - LOG(2, "V1( " << i << ", " << j << ") exists, but V2( " << j - 1 << ", " << i + 1 << ") " << " does not " ); - LOG(2, "(" << i << ", " << j << ") fails"); - compatitable = false; - } - } - } - ++i; - } - if(!compatitable) - { - LOG(1, "*** matrices are not compatitable"); - } - return compatitable; -} - -bool testSymmetric(const IntersectionMatrix& m1, const IntersectionMatrix& m2) -{ - - int i = 0; - bool isSymmetric = true; - - LOG(1, "Checking symmetry src - target" ); - isSymmetric = isSymmetric & areCompatitable(m1, m2) ; - LOG(1, "Checking symmetry target - src" ); - isSymmetric = isSymmetric & areCompatitable(m2, m1); - - for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double v1 = iter2->second; - //if(m2[j - 1].count(i+1) > 0) - // { - std::map theMap = m2.at(j-1); - const double v2 = theMap[i + 1]; - if(v1 != v2) - { - LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); - if(!epsilonEqualRelative(v1, v2, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isSymmetric = false; - } - } - } - ++i; - } - if(!isSymmetric) - { - LOG(1, "*** matrices are not symmetric"); - } - return isSymmetric; -} - -bool testDiagonal(const IntersectionMatrix& m) -{ - LOG(1, "Checking if matrix is diagonal" ); - int i = 1; - bool isDiagonal = true; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double vol = iter2->second; - if(vol != 0.0 && (i != j)) - { - LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); - if(!epsilonEqual(vol, 0.0, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isDiagonal = false; - } - } - } - ++i; - } - if(!isDiagonal) - { - LOG(1, "*** matrix is not diagonal"); - } - return isDiagonal; -} - -#endif - -void dumpIntersectionMatrix(const IntersectionMatrix& m) -{ - int i = 0; - std::cout << "Intersection matrix is " << std::endl; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - - std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << std::endl; - - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; -} - -std::pair countNumberOfMatrixEntries(const IntersectionMatrix& m) -{ - - int numElems = 0; - int numNonZero = 0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - numElems += iter->size(); - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) - { - ++numNonZero; - } - } - } - return std::make_pair(numElems, numNonZero); -} - - -void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) -{ - const std::string dataBaseDir = getenv("MED_ROOT_DIR"); - const std::string dataDir = dataBaseDir + "/share/salome/resources/med/"; - - LOG(1, std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 ); - - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - const MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); - const int numSrcElems = sMesh.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - LOG(1, "Source mesh has " << numSrcElems << " elements"); - - - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - const MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); - const int numTargetElems = tMesh.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - - LOG(1, "Target mesh has " << numTargetElems << " elements"); - - Interpolation3D* interpolator = new Interpolation3D(); - - m = interpolator->interpolateMeshes(sMesh, tMesh); - - std::pair eff = countNumberOfMatrixEntries(m); - LOG(1, eff.first << " of " << numTargetElems * numSrcElems << " intersections calculated : ratio = " - << double(eff.first) / double(numTargetElems * numSrcElems)); - LOG(1, eff.second << " non-zero elements of " << eff.first << " total : filter efficiency = " - << double(eff.second) / double(eff.first)); - - delete interpolator; - - LOG(1, "Intersection calculation done. " << std::endl ); - -} - - - - - - - - -#if 0 -void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) -{ - LOG(1, std::endl << std::endl << "=============================" ); - - using std::string; - const string path1 = string(mesh1path) + string(mesh1); - const string path2 = string(mesh2path) + string(mesh2); - - const bool isTestReflexive = (path1.compare(path2) == 0); - - IntersectionMatrix matrix1; - calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix1); -#endif - - std::cout.precision(16); - - const double vol1 = sumVolume(matrix1); - - if(!doubleTest) - { - LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); - - if(isTestReflexive) - { - // CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); - } - } - else - { - - IntersectionMatrix matrix2; - calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); - -#if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix2); -#endif - - const double vol2 = sumVolume(matrix2); - - LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); - - // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); - // CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testSymmetric(matrix1, matrix2)); - } - -} - - - -#endif - - -#endif diff --git a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx deleted file mode 100644 index 1a5b9a7ac..000000000 --- a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx +++ /dev/null @@ -1,2284 +0,0 @@ -// Copyright (C) 2007-2010 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 "TransformedTriangleIntersectTest.hxx" -#include - -#include "Log.hxx" - -/// macro to test for zero double products outside the segment-edge intersection test method -/// as is done in TransformedTriangle when OPTIMIZE is defined -#define TEST_ZERO_DP_EDGE(seg, edge) isZero[TT::NO_DP*int(seg) + int(DoubleProduct(edge))] - -/// macro to test for zero double products outside the segment-corner intersection test method -/// as is done in TransformedTriangle when OPTIMIZE is defined -#define TEST_ZERO_DP_CORNER(seg, corner) \ - isZero[DoubleProduct(TT::NO_DP*int(seg) + TT::EDGES_FOR_CORNER[3*corner] )] && \ - isZero[DoubleProduct(TT::NO_DP*int(seg) + TT::EDGES_FOR_CORNER[3*corner+1] )] && \ - isZero[DoubleProduct(TT::NO_DP*int(seg) + TT::EDGES_FOR_CORNER[3*corner+2] )] - -/// macro to test for zero double products outside the segment-ray intersection test method -/// as is done in TransformedTriangle when OPTIMIZE is defined -#define TEST_ZERO_DP_RAY(seg, corner) isZero[TT::NO_DP*int(seg) + TT::DP_SEGMENT_RAY_INTERSECTION[7*(corner-1)]] - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// \class TransformedTriangleIntersectTest - /// \brief Class testing the intersection detection methods of TransformedTriangle. - /// - /// This class contains unit tests for the intersection methods of the TransformedTriangle class. - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Each method in the class runs all the intersection tests with some triangle. The goal is to cover all - /// the different types of intersections between a triangle and a tetrahedron. The table below gives a - /// a summary of what is being tested. Before each method, there is also a summary of what how the - /// triangle in the method intersects the unit tetrahedron. - /// - /// Since performing all tests would require a large number of triangles, we have limited our coverage to - /// be such that each column and each row in the table below has at least one entry for each type of - /// intersection. The intersection forumlae are totally symmetric with respect to changing the segment - /// (PQ, QR, or RP) of the triangle, so they only enter in a very simple way in the code. Testing - /// all these cases is therefore of low priority. - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Intersections tested (number indicates first triangle which contains the intersection): - ///
-  /// -----------------------------------------------------------------------------------------------------
-  /// CI  ->  P: 3      Q: 4     R: 7
-  /// COH ->  P: 9      Q: 8     R: 10
-  /// CAH ->  P: 4      Q: 10    R: 9
-  /// -----------------------------------------------------------------------------------------------------
-  /// SF  ->  (PQ, OZX) : 1   (PQ, OYZ) : 2   (PQ, OXY) : 1   (PQ, XYZ) : 3
-  ///     ->  (QR, OZX) : 8   (QR, OYZ) : -   (QR, OXY) : 4   (QR, XYZ) : 7
-  ///     ->  (RP, OZX) : 1   (RP, OYZ) : 3   (RP, OXY) : 7   (RP, XYZ) : 1
-  /// -----------------------------------------------------------------------------------------------------
-  /// SE  ->  (PQ, OX)  : 11  (PQ, OY)  : -   (PQ, OZ)  : 12  (PQ, XY)  : 2   (PQ, ZX)  : -  (PQ, YZ)  : 10
-  ///     ->  (QR, OX)  : -   (QR, OY)  : -   (QR, OZ)  : -   (QR, XY)  : -   (QR, ZX)  : 9  (QR, YZ)  : -
-  ///     ->  (RP, OX)  : -   (RP, OY)  : 12  (RP, OZ)  : -   (RP, XY)  : -   (RP, ZX)  : -  (RP, YZ)  : -
-  /// -----------------------------------------------------------------------------------------------------
-  /// SC  ->  (PQ, O)   : -   (PQ, X)   : -   (PQ, Y)   : 8   (PQ, Z)   : -
-  ///     ->  (QR, O)   : -   (QR, X)   : 2   (QR, Y)   : -   (QR, Z)   : 13
-  ///     ->  (RP, O)   : 11  (RP, X)   : -   (RP, Y)   : -   (RP, Z)   : -
-  /// -----------------------------------------------------------------------------------------------------
-  /// SHS ->  (PQ, XY)  : 3   (PQ, ZX)  : -   (PQ, YZ)  : 13
-  ///     ->  (QR, XY)  : 3   (QR, ZX)  : 5   (QR, YZ)  : 3
-  ///     ->  (RP, XY)  : 1   (RP, ZX)  : 4   (RP, YZ)  : -
-  /// -----------------------------------------------------------------------------------------------------
-  /// SR  ->  (PQ, X)   : 6   (PQ, Y)   : 5   (PQ, Z)   : -
-  ///     ->  (QR, X)   : -   (QR, Y)   : -   (QR, Z)   : 6
-  ///     ->  (RP, X)   : -   (RP, Y)   : -   (RP, Z)   : -
-  /// -----------------------------------------------------------------------------------------------------
-  /// TE  ->  OX : 4   OY : 7    OZ : 8     XY : 1     ZX : 4    YZ : 3
-  /// -----------------------------------------------------------------------------------------------------
-  /// TR  ->  X  : 7    Y : 6     Z : 5
-  /// -----------------------------------------------------------------------------------------------------
-  /// 
- //////////////////////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Key to triangle descriptions : - /// CI = Triangle corner contained in tetrahedron - /// COH = Triangle corner on h = 0 face of tetrahedron - /// CAH = Triangle corner above h = 0 face of tetrahedron in z-direction - /// SF = Segment - facet intersection - /// SE = Segment - edge intersection - /// SC = Segment - corner intersection - /// SHS = Segment - halfstrip intersection - /// SR = Segment - ray intersection - /// TE = Tetrahedron edge intersects triangle (surface - edge intersection) - /// TR = Surface - ray intersection - /// - /// In the descriptions for each triangle, square brackets indicate superfluous but allowed intersections - /// that arise as by-products of for instance segment-corner intersections. - /// E.g. A segment - corner intersection can imply three surface - edge intersections - /// Since these "extra" intersections arise under special circumstances, they are not counted in the - /// table above - //////////////////////////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Triangle 1 has the following intersections - ///
-  /// CI     -
-  /// COH    -
-  /// CAH    -
-  /// SF     (PQ, OXY), (PQ, OZX), (RP, XYZ), (RP, OZX)
-  /// SE     -
-  /// SC     - 
-  /// SHS    (RP, XY)
-  /// SR     - 
-  /// TE     XY
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle1() - { - LOG(1, "+++++++ Testing triangle 1" ); - - typedef TransformedTriangle TT; - - double coords[9] = - { - 0.4,-0.5, 0.5, // P - 0.4, 2.5,-1.0, // Q - 0.4, 2.5, 0.5 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT(tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - - } - - /// Triangle 2 has the following intersections - ///
-  /// CI     -
-  /// COH    -
-  /// CAH    -
-  /// SF     (PQ, OYZ)
-  /// SE     (PQ, XY)
-  /// SC     (QR, X)
-  /// SHS    -
-  /// SR     - 
-  /// TE     [OX, OZ, ZX]
-  /// TR     - 
-  /// 
- /// \brief Status: pass - void TransformedTriangleIntersectTest::testTriangle2() - { - LOG(1, "+++++++ Testing triangle 2" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.5, 0.5, 0.25, // P - 1.5, 0.5,-0.25, // Q - -0.5,-1.5, 0.75 // R - }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 3 has the following intersections - ///
-  /// CI     P
-  /// COH    -
-  /// CAH    -
-  /// SF     (PQ, XYZ), (RP, OYZ)
-  /// SE     -
-  /// SC     -
-  /// SHS    (PQ, XY), (QR, YZ), (QR, XY)
-  /// SR     - 
-  /// TE     YZ
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle3() - { - LOG(1, "+++++++ Testing triangle 3" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - 0.35, 0.15, 0.1, // P - 0.8, 0.8, 0.8, // Q - -0.4, 0.3, 0.9 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 4 has the following intersections - ///
-  /// CI     Q
-  /// COH    -
-  /// CAH    P
-  /// SF     (PQ, XYZ), (QR, OXY)
-  /// SE     -
-  /// SC     -
-  /// SHS    (RP, ZX)
-  /// SR     - 
-  /// TE     (OX, ZX)
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle4() - { - LOG(1, "+++++++ Testing triangle 4" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - 0.3, 0.3, 1.8, // P - 0.75, 0.1, 0.1, // Q - 0.2, -1.3, -1.4 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 5 has the following intersections - ///
-  /// CI     -
-  /// COH    -
-  /// CAH    -
-  /// SF     -
-  /// SE     -
-  /// SC     -
-  /// SHS    (QR, ZX), (QR, XY)
-  /// SR     (PQ, Y)
-  /// TE     -
-  /// TR     Z
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle5() - { - LOG(1, "+++++++ Testing triangle 5" ); - - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.5, 0.5, 2.3, // P - 0.5, 1.5, 2.8, // Q - 0.5, -2.6, 1.3 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 6 has the following intersections - ///
-  /// CI     -
-  /// COH    -
-  /// CAH    -
-  /// SF     -
-  /// SE     -
-  /// SC     -
-  /// SHS    -
-  /// SR     (PQ, X), (QR, Z) 
-  /// TE     -
-  /// TR     Y 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle6() - { - LOG(1, "+++++++ Testing triangle 6" ); - - typedef TransformedTriangle TT; - - double coords[9] = - { - 1.5, 0.5, 1.35, // P - 0.5, -0.5, 2.1, // Q - -3.0, 3.0, -0.5 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 7 has the following intersections - ///
-  /// CI     R
-  /// COH    -
-  /// CAH    -
-  /// SF     (RP, OXY),(QR,XYZ)
-  /// SE     -
-  /// SC     -
-  /// SHS    (QR, XY)
-  /// SR     - 
-  /// TE     OX, ZX
-  /// TR     X 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle7() - { - - LOG(1, "+++++++ Testing triangle 7" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -2.3, -1.5, -2.5, // P - 3.1, 0.15, 0.8, // Q - 0.3, 0.4, 0.2 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 8 has the following intersections - ///
-  /// CI     [Q] 
-  /// COH    Q
-  /// CAH    -
-  /// SF     (QR, OZX), [ (QR, XYZ) ]
-  /// SE     -
-  /// SC     (PQ,Y)
-  /// SHS    -
-  /// SR     - 
-  /// TE     OZ, [YZ,OY,XY]
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle8() - { - LOG(1, "+++++++ Testing triangle 8" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.75, 3.25, -1.5, // P - 0.25, 0.25, 0.5, // Q - -0.1, -0.4, 0.9 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 9 has the following intersections - ///
-  /// CI     [P]
-  /// COH    P
-  /// CAH    R
-  /// SF     (PQ, OZX), [(PQ, XYZ), (RP,XYZ)]
-  /// SE     (QR, ZX)
-  /// SC     -
-  /// SHS    -
-  /// SR     - 
-  /// TE     [ZX]
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle9() - { - LOG(1, "+++++++ Testing triangle 9" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - 0.6, 0.2, 0.2, // P - 0.3, -0.2, 0.8, // Q - 0.1, 0.2, 0.8 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - - /// Triangle 10 has the following intersections - ///
-  /// CI     [R]
-  /// COH    R
-  /// CAH    Q
-  /// SF     (RP, OYZ), [ (RP, XYZ), (QR, XYZ) ]
-  /// SE     (PQ, YZ)
-  /// SC     -
-  /// SHS    -
-  /// SR     - 
-  /// TE     [YZ]
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle10() - { - LOG(1, "+++++++ Testing triangle 10" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.1, 0.3, 0.6, // P - 0.1, 0.1, 1.0, // Q - 0.4, 0.3, 0.3 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - /// Triangle 11 has the following intersections - ///
-  /// CI     Q, R
-  /// COH    -
-  /// CAH    -
-  /// SF     -
-  /// SE     (PQ, OX)
-  /// SC     (RP, O)
-  /// SHS    -
-  /// SR     - 
-  /// TE     [OY, OZ]
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle11() - { - LOG(1, "+++++++ Testing triangle 11" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.2, -0.2, -0.2, // P - 0.2, 0.1, 0.1, // Q - 0.3, 0.3, 0.3 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(true , tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(true, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - - /// Triangle 12 has the following intersections - ///
-  /// CI     -
-  /// COH    -
-  /// CAH    -
-  /// SF     (QR, OXY), (QR, OZX)
-  /// SE     (RP, OY), (PQ, OZ)
-  /// SC     -
-  /// SHS    -
-  /// SR     - 
-  /// TE     [OY], [OZ]
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle12() - { - LOG(1, "+++++++ Testing triangle 12" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.2, 0.2, 0.2, // P - 0.2, -0.2, 0.3, // Q - 0.6, 0.6, -0.6 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - - /// Triangle 13 has the following intersections - ///
-  /// CI     -
-  /// COH    -
-  /// CAH    -
-  /// SF     (QR, OYZ), (PQ, OXY), (PQ, XYZ)
-  /// SE     -
-  /// SC     (QR, Z)
-  /// SHS    (PQ, YZ)
-  /// SR     - 
-  /// TE     [OZ, YZ, ZX]
-  /// TR     - 
-  /// 
- /// \brief Status : pass - void TransformedTriangleIntersectTest::testTriangle13() - { - LOG(1, "+++++++ Testing triangle 13" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - -0.2, 0.3, 5.0, // P - 0.2, 0.1, -1.0, // Q - -0.2, -0.1, 3.0 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - bool isZero[TT::NO_TRI_SEGMENT * TT::NO_DP]; - - for(TriSegment seg = TT::PQ ; seg < TT::NO_TRI_SEGMENT ; seg = TT::TriSegment(seg + 1)) - { - // check beforehand which double-products are zero - for(DoubleProduct dp = TT::C_YZ; dp < TT::NO_DP; dp = DoubleProduct(dp + 1)) - { - isZero[TT::NO_DP*int(seg) + int(dp)] = (tri->calcStableC(seg, dp) == 0.0); - } - } - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::OZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::YZ) && tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::ZX) && tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::PQ, TT::XY) && tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OX) && tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OY) && tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::OZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::YZ) && tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::ZX) && tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::QR, TT::XY) && tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OX) && tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OY) && tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::OZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::YZ) && tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::ZX) && tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_EDGE(TT::RP, TT::XY) && tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::O) && tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::X) && tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Y) && tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::PQ, TT::Z) && tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::O) && tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::X) && tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::QR, TT::Y) && tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(true , TEST_ZERO_DP_CORNER(TT::QR, TT::Z) && tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::O) && tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::X) && tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Y) && tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_CORNER(TT::RP, TT::Z) && tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(true , tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::X) && tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Y) && tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::PQ, TT::Z) && tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::X) && tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Y) && tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::QR, TT::Z) && tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::X) && tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Y) && tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, TEST_ZERO_DP_RAY(TT::RP, TT::Z) && tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(true , tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; - } - - -} // NAMESPACE - - - - - - - -///// TEMPLATE /////////////////////////////// - - - -#if 0 -// Triangle x has the following intersections -// CI - -// COH - -// CAH - -// SF - -// SE - -// SC - -// SHS - -// SR - -// TE - -// TR - - -void TransformedTriangleIntersectTest::testTriangleX() -{ - LOG(1, "+++++++ Testing triangle X" ); - typedef TransformedTriangle TT; - - double coords[9] = - { - 0.0, 0.0, 0.0, // P - 0.0, 0.0, 0.0, // Q - 0.0, 0.0, 0.0 // R - }; - - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); - - // run all intersection tests and ensure that the ones - // listed with yes in the tables above return true and - // that the ones listed with no or not listed at all return false - - // corner in tetrahedron (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerInTetrahedron(TT::R)); - - // corner on XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerOnXYZFacet(TT::R)); - - // corner above XYZ facet (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::P)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::Q)); - CPPUNIT_ASSERT_EQUAL(false, tri->testCornerAboveXYZFacet(TT::R)); - - // segment-facet (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::PQ, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::QR, TT::XYZ)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OYZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::OXY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentFacetIntersection(TT::RP, TT::XYZ)); - - // segment-edge (18 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentEdgeIntersection(TT::RP, TT::XY)); - - // segment - corner (12 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::O)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentCornerIntersection(TT::RP, TT::Z)); - - // segment-halfstrip (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::PQ, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::QR, TT::XY)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentHalfstripIntersection(TT::RP, TT::XY)); - - // segment-ray (9 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::PQ, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::QR, TT::Z)); - - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSegmentRayIntersection(TT::RP, TT::Z)); - - // surface-edge (6 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OY)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::OZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::YZ)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::ZX)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceEdgeIntersection(TT::XY)); - - // surface-ray (3 possibilities) - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::X)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Y)); - CPPUNIT_ASSERT_EQUAL(false, tri->testSurfaceRayIntersection(TT::Z)); - - delete tri; -} -#endif diff --git a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx deleted file mode 100644 index 1dfee9224..000000000 --- a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ -#define __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ - -#include - -#include "InterpKernelTestExport.hxx" -#include "TransformedTriangle.hxx" - -namespace INTERP_TEST -{ - - class INTERPKERNELTEST_EXPORT TransformedTriangleIntersectTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( TransformedTriangleIntersectTest ); - - CPPUNIT_TEST( testTriangle1 ); - CPPUNIT_TEST( testTriangle2 ); - CPPUNIT_TEST( testTriangle3 ); - CPPUNIT_TEST( testTriangle4 ); - CPPUNIT_TEST( testTriangle5 ); - CPPUNIT_TEST( testTriangle6 ); - CPPUNIT_TEST( testTriangle7 ); - CPPUNIT_TEST( testTriangle8 ); - CPPUNIT_TEST( testTriangle9 ); - CPPUNIT_TEST( testTriangle10 ); - CPPUNIT_TEST( testTriangle11 ); - CPPUNIT_TEST( testTriangle12 ); - CPPUNIT_TEST( testTriangle13 ); - - CPPUNIT_TEST_SUITE_END(); - - typedef INTERP_KERNEL::TransformedTriangle::TriSegment TriSegment; - typedef INTERP_KERNEL::TransformedTriangle::DoubleProduct DoubleProduct; - - public: - - void testTriangle1(); - - void testTriangle2(); - - void testTriangle3(); - - void testTriangle4(); - - void testTriangle5(); - - void testTriangle6(); - - void testTriangle7(); - - void testTriangle8(); - - void testTriangle9(); - - void testTriangle10(); - - void testTriangle11(); - - void testTriangle12(); - - void testTriangle13(); - - private: - - }; - -} - - - - - - -#endif diff --git a/src/INTERP_KERNELTest/TransformedTriangleTest.cxx b/src/INTERP_KERNELTest/TransformedTriangleTest.cxx deleted file mode 100644 index d845cb8b1..000000000 --- a/src/INTERP_KERNELTest/TransformedTriangleTest.cxx +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright (C) 2007-2010 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 "TransformedTriangleTest.hxx" - -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - - /** - * Creates the TransformedTriangle objects used by the tests. - * - */ - void TransformedTriangleTest::setUp() - { - // tri1 -> no unstable double products - no changes brought about by preCalculateDoubleProducts - // this allows the testing of calcUnstableT - // tri2 -> unstable double products - for testing calcStableC / preCalculateDoubleProducts - - // triangle to test unstable C and T calculations - p1[0] = -1.5 ; p1[1] = 0.5; p1[2] = 0.5; - q1[0] = 2.0 ; q1[1] = 0.4; q1[2] = 0.6; - r1[0] = 1.0 ; r1[1] = 2.4; r1[2] = 1.2; - hp1 = 1 - p1[0] - p1[1] - p1[2]; - hq1 = 1 - q1[0] - q1[1] - q1[2]; - hr1 = 1 - r1[0] - r1[1] - r1[2]; - Hp1 = 1 - p1[0] - p1[1]; - Hq1 = 1 - q1[0] - q1[1]; - Hr1 = 1 - r1[0] - r1[1]; - - // std::cout <_coords[i], ERR_TOL); - CPPUNIT_ASSERT_DOUBLES_EQUAL(good_values2[i], tri2->_coords[i], ERR_TOL); - } - - CPPUNIT_ASSERT_EQUAL(true, tri1->_is_double_products_calculated); - CPPUNIT_ASSERT_EQUAL(true, tri2->_is_double_products_calculated); - } - - /// Tests the calculation of double products (without the corrections) - /// \brief Status : pass - void TransformedTriangleTest::test_calcUnstableC() { - typedef TransformedTriangle::TriSegment TriSegment; - - // test that the correct c-values are calculated - - double correct_c_vals[24] = - { - p1[0] * q1[1] - p1[1] * q1[0], - p1[1] * q1[2] - p1[2] * q1[1], - p1[2] * q1[0] - p1[0] * q1[2], - p1[0] * hq1 - hp1 * q1[0], - p1[1] * hq1 - hp1 * q1[1], - p1[2] * hq1 - hp1 * q1[2], - Hp1 * q1[0] - p1[0] * Hq1, - p1[1] * Hq1 - Hp1 * q1[1], - q1[0] * r1[1] - q1[1] * r1[0], - q1[1] * r1[2] - q1[2] * r1[1], - q1[2] * r1[0] - q1[0] * r1[2], - q1[0] * hr1 - hq1 * r1[0], - q1[1] * hr1 - hq1 * r1[1], - q1[2] * hr1 - hq1 * r1[2], - Hq1 * r1[0] - q1[0] * Hr1, - q1[1] * Hr1 - Hq1 * r1[1], - r1[0]*p1[1]-r1[1]*p1[0], - r1[1]*p1[2]-r1[2]*p1[1], - r1[2]*p1[0]-r1[0]*p1[2], - r1[0] * hp1 - hr1 * p1[0], - r1[1] * hp1 - hr1 * p1[1], - r1[2] * hp1 - hr1 * p1[2], - Hr1 * p1[0] - r1[0] * Hp1, - r1[1] * Hp1 - Hr1 * p1[1] - }; - - double c_vals[3 * 8]; - for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) { - - c_vals[seg*8 + 0] = tri1->calcUnstableC(seg, TransformedTriangle::C_XY); - c_vals[seg*8 + 1] = tri1->calcUnstableC(seg, TransformedTriangle::C_YZ); - c_vals[seg*8 + 2] = tri1->calcUnstableC(seg, TransformedTriangle::C_ZX); - c_vals[seg*8 + 3] = tri1->calcUnstableC(seg, TransformedTriangle::C_XH); - c_vals[seg*8 + 4] = tri1->calcUnstableC(seg, TransformedTriangle::C_YH); - c_vals[seg*8 + 5] = tri1->calcUnstableC(seg, TransformedTriangle::C_ZH); - c_vals[seg*8 + 6] = tri1->calcUnstableC(seg, TransformedTriangle::C_01); - c_vals[seg*8 + 7] = tri1->calcUnstableC(seg, TransformedTriangle::C_10); - - } - - for(int i = 0 ; i < 3*8 ; ++i) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( correct_c_vals[i], c_vals[i], ERR_TOL ); - } - - - } - - /// Tests the calculation of triple products (without corrections) - /// \brief Status : pass - void TransformedTriangleTest::test_calcUnstableT() - { - typedef TransformedTriangle::TetraCorner TetraCorner; - - // correct values calculated by determinants (Grandy, [15]) - const double correct_t_vals[4] = - { - p1[0]*(q1[1]*r1[2] - q1[2]*r1[1]) - - q1[0]*(p1[1]*r1[2] - p1[2]*r1[1]) + - r1[0]*(p1[1]*q1[2] - p1[2]*q1[1]), - - -(hp1*(q1[1]*r1[2] - q1[2]*r1[1]) - - hq1*(p1[1]*r1[2] - p1[2]*r1[1]) + - hr1*(p1[1]*q1[2] - p1[2]*q1[1])), - - -(p1[0]*(hq1*r1[2] - q1[2]*hr1) - - q1[0]*(hp1*r1[2] - p1[2]*hr1) + - r1[0]*(hp1*q1[2] - p1[2]*hq1)), - - -(p1[0]*(q1[1]*hr1 - r1[1]*hq1) - - q1[0]*(p1[1]*hr1 - r1[1]*hp1) + - r1[0]*(p1[1]*hq1 - q1[1]*hp1)) - }; - - - // test that triple products are correctly calculated - for(TetraCorner corner = TransformedTriangle::O ; corner <= TransformedTriangle::Z ; corner = TetraCorner(corner + 1)) - { - - for(int row = 1 ; row < 4 ; ++row) - { - const double t = tri1->calcTByDevelopingRow(corner, row, false); - // std::cout << std::endl << " Corner = " << corner << " Row = " << row << " got: " << t << - // " expected: " << correct_t_vals[corner]<< std::endl; - CPPUNIT_ASSERT_DOUBLES_EQUAL(correct_t_vals[corner], t, ERR_TOL); - } - } - } - - /// Tests the consistency correction - /// \brief Status : fails because it is not significant - the consistency correction is not brought into play - void TransformedTriangleTest::test_calcStableC_Consistency() - { - - typedef TransformedTriangle::TriSegment TriSegment; - typedef TransformedTriangle::TetraCorner TetraCorner; - - // grandy, eq 14 - double correct_c_vals[24] = - { - p2[0] * q2[1] - p2[1] * q2[0], - p2[1] * q2[2] - p2[2] * q2[1], - p2[2] * q2[0] - p2[0] * q2[2], - p2[0] * hq2 - hp2 * q2[0], - p2[1] * hq2 - hp2 * q2[1], - p2[2] * hq2 - hp2 * q2[2], - Hp2 * q2[0] - p2[0] * Hq2, - p2[1] * Hq2 - Hp2 * q2[1], - q2[0] * r2[1] - q2[1] * r2[0], - q2[1] * r2[2] - q2[2] * r2[1], - q2[2] * r2[0] - q2[0] * r2[2], - q2[0] * hr2 - hq2 * r2[0], - q2[1] * hr2 - hq2 * r2[1], - q2[2] * hr2 - hq2 * r2[2], - Hq2 * r2[0] - q2[0] * Hr2, - q2[1] * Hr2 - Hq2 * r2[1], - r2[0]*p2[1]-r2[1]*p2[0], - r2[1]*p2[2]-r2[2]*p2[1], - r2[2]*p2[0]-r2[0]*p2[2], - r2[0] * hp2 - hr2 * p2[0], - r2[1] * hp2 - hr2 * p2[1], - r2[2] * hp2 - hr2 * p2[2], - Hr2 * p2[0] - r2[0] * Hp2, - r2[1] * Hp2 - Hr2 * p2[1] - }; - - - // number of inconsistent cases found : - // should be (at least) 1 for the test to be meaningful - int num_cases = 0; - - // find unstable products to check for consistency (Grandy [46]) - for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) - { - const double c_xy = tri2->calcUnstableC(seg, TransformedTriangle::C_XY); - const double c_yz = tri2->calcUnstableC(seg, TransformedTriangle::C_YZ); - const double c_zx = tri2->calcUnstableC(seg, TransformedTriangle::C_ZX); - const double c_xh = tri2->calcUnstableC(seg, TransformedTriangle::C_XH); - const double c_yh = tri2->calcUnstableC(seg, TransformedTriangle::C_YH); - const double c_zh = tri2->calcUnstableC(seg, TransformedTriangle::C_ZH); - - const int num_zero = (c_yz*c_xh == 0.0 ? 1 : 0) + (c_zx*c_yh == 0.0 ? 1 : 0) + (c_xy*c_zh == 0.0 ? 1 : 0); - const int num_neg = (c_yz*c_xh < 0.0 ? 1 : 0) + (c_zx*c_yh < 0.0 ? 1 : 0) + (c_xy*c_zh < 0.0 ? 1 : 0); - - if((num_zero == 1 && num_neg != 1) || num_zero == 2 || (num_neg == 0 && num_zero !=3) || num_neg == 3 ) - { - ++num_cases; - - double min_dist = -1.0; // initialised first time through loop - TetraCorner min_corner = TransformedTriangle::O; - - for(TetraCorner corner = TransformedTriangle::O ; corner <= TransformedTriangle::Z ; corner = TetraCorner(corner + 1)) - { - // calculate distance from each corner of tetraeder to the segment - // formula : ( (Q-P) x (P - corner) )^2 / norm(Q-P)^2 - - const double ptP[3] = { tri2->_coords[5*seg], tri2->_coords[5*seg + 1], tri2->_coords[5*seg + 2] }; - const double ptQ[3] = { tri2->_coords[5*( (seg+1) % 3)], tri2->_coords[5*( (seg+1) % 3) + 1], tri2->_coords[5*( (seg+1) % 3) + 2] }; - const double ptCorner[3] = { - corner == TransformedTriangle::X ? 1.0 : 0.0, - corner == TransformedTriangle::Y ? 1.0 : 0.0, - corner == TransformedTriangle::Z ? 1.0 : 0.0, - }; - - const double diff_21[3] = { ptQ[0] - ptP[0], ptQ[1] - ptP[1], ptQ[2] - ptP[2] }; - const double diff_1_corner[3] = { ptP[0] - ptCorner[0], ptP[1] - ptCorner[1], ptP[2] - ptCorner[2] }; - - const double cross[3] = { - diff_21[1]*diff_1_corner[2] - diff_21[2]*diff_1_corner[1], - diff_21[2]*diff_1_corner[0] - diff_21[0]*diff_1_corner[2], - diff_21[0]*diff_1_corner[1] - diff_21[1]*diff_1_corner[0] - }; - - const double cross_sq = cross[0]*cross[0] + cross[1]*cross[1] + cross[2]*cross[2]; - - const double norm_pq = diff_21[0]*diff_21[0] + diff_21[1]*diff_21[1] + diff_21[2]*diff_21[2]; - - if(corner == TransformedTriangle::O || (cross_sq / norm_pq) < min_dist) - { - min_dist = cross_sq / norm_pq; - min_corner = corner; - } - } - - // now check if the corresponding double products are zero - static const DoubleProduct DOUBLE_PRODUCTS[12] = - { - TransformedTriangle::C_YZ, TransformedTriangle::C_XY, TransformedTriangle::C_ZX, // O - TransformedTriangle::C_ZH, TransformedTriangle::C_YZ, TransformedTriangle::C_YH, // X - TransformedTriangle::C_ZH, TransformedTriangle::C_ZX, TransformedTriangle::C_XH, // Y - TransformedTriangle::C_XY, TransformedTriangle::C_YH, TransformedTriangle::C_XH // Z - }; - - for(int i = 0; i < 3 ; ++i) - { - DoubleProduct dp = DOUBLE_PRODUCTS[3*min_corner + i]; - // std::cout << std::endl << "in test inconsistent (seg,dp) :(" << seg <<", " << dp << ")" << std::endl; - CPPUNIT_ASSERT_EQUAL(0.0, tri2->calcStableC(seg, dp)); - correct_c_vals[8*seg + dp] = 0.0; - } - } - - } - - if(num_cases < 1) - { - CPPUNIT_FAIL("Consistency test not pertinent"); - } - - // std::cout << std::endl << "Number of geometric inconsistencies : " << num_cases << std::endl; - - // check that all other double products have right value too - double c_vals[8*3]; - - for(TriSegment seg = TransformedTriangle::PQ ; seg <= TransformedTriangle::RP ; seg = TriSegment(seg + 1)) { - - c_vals[seg*8 + 0] = tri2->calcStableC(seg, TransformedTriangle::C_XY); - c_vals[seg*8 + 1] = tri2->calcStableC(seg, TransformedTriangle::C_YZ); - c_vals[seg*8 + 2] = tri2->calcStableC(seg, TransformedTriangle::C_ZX); - c_vals[seg*8 + 3] = tri2->calcStableC(seg, TransformedTriangle::C_XH); - c_vals[seg*8 + 4] = tri2->calcStableC(seg, TransformedTriangle::C_YH); - c_vals[seg*8 + 5] = tri2->calcStableC(seg, TransformedTriangle::C_ZH); - c_vals[seg*8 + 6] = tri2->calcStableC(seg, TransformedTriangle::C_01); - c_vals[seg*8 + 7] = tri2->calcStableC(seg, TransformedTriangle::C_10); - - } - - for(int i = 0 ; i < 24 ; ++i) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(correct_c_vals[i], c_vals[i], ERR_TOL); - } - } - -} diff --git a/src/INTERP_KERNELTest/TransformedTriangleTest.hxx b/src/INTERP_KERNELTest/TransformedTriangleTest.hxx deleted file mode 100644 index 7a729be25..000000000 --- a/src/INTERP_KERNELTest/TransformedTriangleTest.hxx +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007-2010 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 __TU_TRANSFORMED_TRIANGLE_HXX__ -#define __TU_TRANSFORMED_TRIANGLE_HXX__ - -#include - -#include "InterpKernelTestExport.hxx" -#include "TransformedTriangle.hxx" - -#define ERR_TOL 1.0e-8 - -using INTERP_KERNEL::TransformedTriangle; - -namespace INTERP_TEST -{ - - /** - * \brief Test suite testing some of the low level methods of TransformedTriangle. - * - */ - class INTERPKERNELTEST_EXPORT TransformedTriangleTest : public CppUnit::TestFixture - { - - CPPUNIT_TEST_SUITE( TransformedTriangleTest ); - CPPUNIT_TEST( test_constructor ); - CPPUNIT_TEST( test_calcUnstableC ); - CPPUNIT_TEST( test_calcUnstableT ); - //removed because the test fails to enter the desired code branch - // CPPUNIT_TEST( test_calcStableC_Consistency ); - CPPUNIT_TEST_SUITE_END(); - - typedef INTERP_KERNEL::TransformedTriangle::TriSegment TriSegment; - typedef INTERP_KERNEL::TransformedTriangle::DoubleProduct DoubleProduct; - - public: - void setUp(); - - void tearDown(); - - // tests - void test_constructor(); - - void test_calcUnstableC(); - - void test_calcUnstableT(); - - void test_calcStableC_Consistency(); - - double p1[3], q1[3], r1[3]; - double hp1, hq1, hr1; - double Hp1, Hq1, Hr1; - - double p2[3], q2[3], r2[3]; - double hp2, hq2, hr2; - double Hp2, Hq2, Hr2; - - double stable_c2[24]; - - private: - TransformedTriangle* tri1; - TransformedTriangle* tri2; - - }; - - - - -} - - - -#endif diff --git a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx deleted file mode 100644 index b7fa9348c..000000000 --- a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx +++ /dev/null @@ -1,347 +0,0 @@ -// Copyright (C) 2007-2010 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 "UnitTetraIntersectionBaryTest.hxx" - -#include "UnitTetraIntersectionBary.hxx" -#include "TetraAffineTransform.hxx" -#include "InterpolationUtils.hxx" -#include "SplitterTetra.txx" - -#include - -using namespace INTERP_KERNEL; - -namespace INTERP_TEST -{ - static void fill_UnitTetraIntersectionBary(UnitTetraIntersectionBary& bary, double nodes[][3]) - { - int faceConn[4][3] = { { 0, 1, 2 },// inverse order - { 0, 3, 1 }, - { 1, 3, 2 }, - { 3, 0, 2 } }; -// int faceConn[4][3] = { { 0, 2, 1 }, -// { 0, 1, 3 }, -// { 1, 2, 3 }, -// { 3, 2, 0 } }; - bary.init(true); - for ( int i = 0; i < 4; ++i ) { - int* faceNodes = faceConn[ i ]; - TransformedTriangle tri(nodes[faceNodes[0]], nodes[faceNodes[1]], nodes[faceNodes[2]]); - tri.calculateIntersectionVolume(); - bary.addSide( tri ); - } - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_1() - { - // cutting tetra coincides with the unit one - double nodes[4][3] = { { 0.0, 0.0, 0.0 }, - { 1.0, 0.0, 0.0 }, - { 0.0, 1.0, 0.0 }, - { 0.0, 0.0, 1.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_2() - { - // cutting tetra fully include the unit one - double nodes[4][3] = { {-0.1,-0.1,-0.1 }, - { 1.5,-0.1,-0.1 }, - {-0.1, 1.5,-0.1 }, - {-0.1,-0.1, 1.5 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_3() - { - // cutting tetra is same as the unit one but moved up by 0.5 - double nodes[4][3] = { { 0.0, 0.0, 0.5 }, - { 1.0, 0.0, 0.5 }, - { 0.0, 1.0, 0.5 }, - { 0.0, 0.0, 1.5 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.625, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_4() - { - // same as previous but no cutting sides lay on the sides of unit tetra - double nodes[4][3] = { {-0.2,-0.2, 0.5 }, - { 1.0, 0.0, 0.5 }, - { 0.0, 1.0, 0.5 }, - { 0.0, 0.0, 2.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.625, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_5() - { - // cutting tetra is similar and parallel to the UT but moved (-0.1,-0.1,-0.1) - double nodes[4][3] = { {-0.1,-0.1,-0.1 }, - { 1.1,-0.1,-0.1 }, - {-0.1, 1.1,-0.1 }, - {-0.1,-0.1, 1.1 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1215, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_6() - { - // cutting tetra is deeped into the UT with one corner - double nodes[4][3] = { { 0.2, 0.2, 0.2 }, - { 1.0, 0.2, 0.2 }, - { 0.9, 1.0, 0.2 }, - { 0.9, 9.0, 1.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.000441855, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.353463 , baryCenter[0], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.33877 , baryCenter[1], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.207767 , baryCenter[2], 1e-5 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_7() - { - // cutting tetra passes through the UT with one corner - double nodes[4][3] = { {-0.2, 0.2, 0.2 }, - { 1.0, 0.2, 0.2 }, - { 0.9, 1.0, 0.2 }, - { 0.9, 0.9, 1.0 } }; - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0103501, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.215578 , baryCenter[0], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.341363 , baryCenter[1], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.263903 , baryCenter[2], 1e-5 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_8() - { - // cutting tetra passes through the UT with one edge - double nodes[4][3] = { { 0.5, 0.2, -0.2 }, // O - {-0.5,-0.2, -0.2 }, // OX - { 1.0,-0.5, -0.2 }, // OY - { 0.5, 0.2, 1.5 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0349217, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.332275 , baryCenter[0], 1e-2 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0565892 , baryCenter[1], 1e-3 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.308713 , baryCenter[2], 1e-2 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_9() - { - // cutting tetra touches the UT at an edge, intersection volume == 0 - double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 - {-1.0, 2.0, 2.0 }, // OX - {-1.0,-2.0, 2.0 }, // OY - { 1.0, 0.0, 2.0 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( !ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, vol, 1e-15); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[0], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[1], 1e-5 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[2], 1e-5 ); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_10() - { - // cutting tetra fully includes theUT and touches it at an edge - double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 - {-1.0,-4.0, 2.0 }, // OX - {-1.0, 4.0, 2.0 }, // OY - { 1.0, 0.0,-2.0 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_11() - { - // cutting tetra intersects the UT and touches it at an edge - double nodes[4][3] = { { 1.0, 0.0, 0.0 }, // 0 - {-1.0,-4.0, 2.0 }, // OX - {-1.0, 4.0, 2.0 }, // OY - {-1.0, 0.0,-1.0 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.15873 , vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.250000, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.230952, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.260714, baryCenter[2], 1e-5); - } - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_12() - { - // cutting tetra has one corner inside the UT and one its side passes through an UT edge - double nodes[4][3] = { { 0.25, 0.25, 0.25 }, // 0 - { 1.75,-0.25,-0.25 }, // OX - { 0.5 , 0.25, 0.25 }, // OY - { 0.5 , 0 , 0.5 } };//OZ - UnitTetraIntersectionBary bary; - fill_UnitTetraIntersectionBary(bary,nodes); - double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); - CPPUNIT_ASSERT( ok ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.005208 , vol, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.562500, baryCenter[0], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125000, baryCenter[1], 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.250000, baryCenter[2], 1e-5); - } - - struct __MESH_DUMMY - { - typedef int MyConnType; - }; - - void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_13() - { - double T[] = { - 66.6666666666666714,133.333333333333343,66.6666666666666714, - 100,200,100, - 100,100,100, - 200,200,0 }; - - double S[] = { - 100,166.666666666666657,66.6666666666666714, - 100,150,50, - 75,150,75, - 100,100,100}; - - int conn[4] = { 0,1,2,3 }; - - const double* tnodes[4]={ T, T+3, T+6, T+9 }; - const double* snodes[4]={ S, S+3, S+6, S+9 }; - - __MESH_DUMMY dummyMesh; - SplitterTetra<__MESH_DUMMY> src( dummyMesh, snodes, conn ); - double volume = src.intersectTetra( tnodes ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6944.4444444444443,volume,1e-9); - } - - void UnitTetraIntersectionBaryTest::test_TetraAffineTransform_reverseApply() - { - double nodes[4][3] = { {-4.0, 9.0, 3.0 }, - {11.0, 0.0, 2.0 }, - { 0.0, 0.0, 0.0 }, - { 2.0, 1.0,10.0 }}; - // double pSrc[3] = { -4.0, 9.0, 3.0 }; - double pSrc[3] = { 40., -20., 100. }; - double pDest[] = {1,1,1}; - const double* n[4] = { &nodes[0][0], &nodes[1][0], &nodes[2][0], &nodes[3][0] }; - TetraAffineTransform a(&n[0]); - a.apply( pDest, pSrc ); - a.reverseApply( pDest, pDest ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[0], pDest[0], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[1], pDest[1], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[2], pDest[2], 1e-12); - } - - void UnitTetraIntersectionBaryTest::test_barycentric_coords() - { - // compute barycentric coordinates - double nodes[4][3] = { {11.0, 0.0, 2.0 }, - {-4.0, 9.0, 3.0 }, - { 0.0, 0.0, 0.0 }, - { 6.0, 1.0,10.0 }}; - std::vector n (4); - n[0] = &nodes[0][0]; - n[1] = &nodes[1][0]; - n[2] = &nodes[2][0]; - n[3] = &nodes[3][0]; - double p [3] = { 2, 2, 5 }, bc[4]; - barycentric_coords(n, p, bc); - double bcSum = 0; - double p2 [3] = { 0,0,0 }; - for ( int i = 0; i < 4; ++i ) { - bcSum += bc[i]; - p2[0] += bc[i]*n[i][0]; - p2[1] += bc[i]*n[i][1]; - p2[2] += bc[i]*n[i][2]; - } - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., bcSum, 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( p[0], p2[0], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( p[1], p2[1], 1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL( p[2], p2[2], 1e-12); - } -} diff --git a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx deleted file mode 100644 index 0d5890d0e..000000000 --- a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2007-2010 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 __UNITTETRAINTERSECTIONBARYTEST_HXX__ -#define __UNITTETRAINTERSECTIONBARYTEST_HXX__ - -#include - -#include "InterpKernelTestExport.hxx" - -namespace INTERP_TEST -{ - /** - * \brief Test suite testing UnitTetraIntersectionBary class. - * - */ - class INTERPKERNELTEST_EXPORT UnitTetraIntersectionBaryTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE( UnitTetraIntersectionBaryTest ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_13 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_12 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_1 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_2 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_3 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_4 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_5 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_6 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_7 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_8 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_9 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_10 ); - CPPUNIT_TEST( test_UnitTetraIntersectionBary_11 ); - CPPUNIT_TEST( test_TetraAffineTransform_reverseApply ); - CPPUNIT_TEST( test_barycentric_coords ); - CPPUNIT_TEST_SUITE_END(); - public: - void test_UnitTetraIntersectionBary_1(); - void test_UnitTetraIntersectionBary_2(); - void test_UnitTetraIntersectionBary_3(); - void test_UnitTetraIntersectionBary_4(); - void test_UnitTetraIntersectionBary_5(); - void test_UnitTetraIntersectionBary_6(); - void test_UnitTetraIntersectionBary_7(); - void test_UnitTetraIntersectionBary_8(); - void test_UnitTetraIntersectionBary_9(); - void test_UnitTetraIntersectionBary_10(); - void test_UnitTetraIntersectionBary_11(); - void test_UnitTetraIntersectionBary_12(); - void test_UnitTetraIntersectionBary_13(); - void test_TetraAffineTransform_reverseApply(); - void test_barycentric_coords(); - }; -} - -#endif diff --git a/src/INTERP_KERNELTest/perf_test.sh b/src/INTERP_KERNELTest/perf_test.sh deleted file mode 100755 index 264a115cb..000000000 --- a/src/INTERP_KERNELTest/perf_test.sh +++ /dev/null @@ -1,166 +0,0 @@ -#!/bin/bash -# Copyright (C) 2007-2010 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 -# - -# should be run from the build directory, so that ./PerfTest is available -# output file -# -RES_FILE=perf_OPTIMIZE - -#outputs lines of form : -#"no. source elems no. target elems user time" -function test_pair { - echo -n $1 | sed 's/\(PerfCyl\)\([0-9]*\)/\2/' | sed 's/\(PerfBoxT\)\([0-9]*\)/\2/' | sed 's/\(PerfBox\)\([0-9]*\)/\2/' >> $RES_FILE - echo -n " " >> $RES_FILE - echo -n $2 | sed 's/\(PerfCyl\)\([0-9]*\)/\2/' | sed 's/\(PerfBoxT\)\([0-9]*\)/\2/' | sed 's/\(PerfBox\)\([0-9]*\)/\2/' >> $RES_FILE - echo -n " " >> $RES_FILE - time -o $RES_FILE --append -f"%U" ./PerfTest $1 $2 - echo -} - -function test_box_box { -echo PerfBox PerfBox >> $RES_FILE - -test_pair PerfBox1495 PerfBox1495 -test_pair PerfBox2506 PerfBox2506 -test_pair PerfBox5708 PerfBox5708 -test_pair PerfBox13461 PerfBox13461 -test_pair PerfBox30808 PerfBox30808 -test_pair PerfBox47176 PerfBox47176 - -test_pair PerfBox1495 PerfBox2506 -test_pair PerfBox1495 PerfBox5708 -test_pair PerfBox1495 PerfBox13461 -test_pair PerfBox1495 PerfBox30808 -test_pair PerfBox1495 PerfBox47176 - -test_pair PerfBox2506 PerfBox5708 -test_pair PerfBox2506 PerfBox13461 -test_pair PerfBox2506 PerfBox30808 -test_pair PerfBox2506 PerfBox47176 - -test_pair PerfBox5708 PerfBox13461 -test_pair PerfBox5708 PerfBox30808 -test_pair PerfBox5708 PerfBox47176 - -test_pair PerfBox13461 PerfBox30808 -test_pair PerfBox13461 PerfBox47176 - -test_pair PerfBox30808 PerfBox47176 - -} - -function test_cyl_cyl { -echo PerfCyl PerfCyl >> $RES_FILE - -test_pair PerfCyl1047 PerfCyl1047 -test_pair PerfCyl3020 PerfCyl3020 -test_pair PerfCyl6556 PerfCyl6556 -test_pair PerfCyl9766 PerfCyl9766 -test_pair PerfCyl25745 PerfCyl25745 -test_pair PerfCyl47601 PerfCyl47601 - -test_pair PerfCyl1047 PerfCyl3020 -test_pair PerfCyl1047 PerfCyl6556 -test_pair PerfCyl1047 PerfCyl9766 -test_pair PerfCyl1047 PerfCyl25745 -test_pair PerfCyl1047 PerfCyl47601 - -test_pair PerfCyl3020 PerfCyl6556 -test_pair PerfCyl3020 PerfCyl9766 -test_pair PerfCyl3020 PerfCyl25745 -test_pair PerfCyl3020 PerfCyl47601 - -test_pair PerfCyl6556 PerfCyl9766 -test_pair PerfCyl6556 PerfCyl25745 -test_pair PerfCyl6556 PerfCyl47601 - -test_pair PerfCyl9766 PerfCyl25745 -test_pair PerfCyl9766 PerfCyl47601 - -test_pair PerfCyl25745 PerfCyl47601 - -} - -function test_box_cyl { - echo PerfBox PerfCyl >> $RES_FILE - test_pair PerfBox1495 PerfCyl1047 - test_pair PerfBox1495 PerfCyl3020 - test_pair PerfBox1495 PerfCyl6556 - test_pair PerfBox1495 PerfCyl9766 - test_pair PerfBox1495 PerfCyl25745 - test_pair PerfBox1495 PerfCyl47601 - - test_pair PerfBox2506 PerfCyl1047 - test_pair PerfBox2506 PerfCyl3020 - test_pair PerfBox2506 PerfCyl6556 - test_pair PerfBox2506 PerfCyl9766 - test_pair PerfBox2506 PerfCyl25745 - test_pair PerfBox2506 PerfCyl47601 - - test_pair PerfBox5708 PerfCyl1047 - test_pair PerfBox5708 PerfCyl3020 - test_pair PerfBox5708 PerfCyl6556 - test_pair PerfBox5708 PerfCyl9766 - test_pair PerfBox5708 PerfCyl25745 - test_pair PerfBox5708 PerfCyl47601 - - test_pair PerfBox13461 PerfCyl1047 - test_pair PerfBox13461 PerfCyl3020 - test_pair PerfBox13461 PerfCyl6556 - test_pair PerfBox13461 PerfCyl9766 - test_pair PerfBox13461 PerfCyl25745 - test_pair PerfBox13461 PerfCyl47601 - - test_pair PerfBox30808 PerfCyl1047 - test_pair PerfBox30808 PerfCyl3020 - test_pair PerfBox30808 PerfCyl6556 - test_pair PerfBox30808 PerfCyl9766 - test_pair PerfBox30808 PerfCyl25745 - test_pair PerfBox30808 PerfCyl47601 - - test_pair PerfBox47176 PerfCyl1047 - test_pair PerfBox47176 PerfCyl3020 - test_pair PerfBox47176 PerfCyl6556 - test_pair PerfBox47176 PerfCyl9766 - test_pair PerfBox47176 PerfCyl25745 - test_pair PerfBox47176 PerfCyl47601 -} - -function test_box_transbox { - echo PerfBox PerfBoxT >> $RES_FILE - test_pair PerfBox1495 PerfBoxT1493 - test_pair PerfBox2506 PerfBoxT2676 - test_pair PerfBox5708 PerfBoxT5717 - test_pair PerfBox13461 PerfBoxT12469 - test_pair PerfBox30808 PerfBoxT29019 - test_pair PerfBox47176 PerfBoxT47278 -} - - - -#functions to execute : - -echo PerfTest execution on `date` > $RES_FILE -test_box_cyl -test_box_box -test_cyl_cyl -test_box_transbox - -cat $RES_FILE \ No newline at end of file diff --git a/src/MEDCoupling/MEDCoupling.hxx b/src/MEDCoupling/MEDCoupling.hxx deleted file mode 100644 index 5f718343a..000000000 --- a/src/MEDCoupling/MEDCoupling.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2010 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 _MEDCOUPLING_HXX_ -#define _MEDCOUPLING_HXX_ - -#ifdef WNT -# if defined medcoupling_EXPORTS -# define MEDCOUPLING_EXPORT __declspec( dllexport ) -# else -# define MEDCOUPLING_EXPORT __declspec( dllimport ) -# endif -#else -# define MEDCOUPLING_EXPORT -#endif - -#ifdef WNT -# if defined medcouplingremapper_EXPORTS -# define MEDCOUPLINGREMAPPER_EXPORT __declspec( dllexport ) -# else -# define MEDCOUPLINGREMAPPER_EXPORT __declspec( dllimport ) -# endif -#else -# define MEDCOUPLINGREMAPPER_EXPORT -#endif - -#ifdef WNT -#pragma warning( disable : 4290 ) -#endif - -#endif diff --git a/src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx b/src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx deleted file mode 100644 index 9a30b7d8f..000000000 --- a/src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGAUTOREFCOUNTOBJECTPTR_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGAUTOREFCOUNTOBJECTPTR_HXX__ - -#include "MEDCouplingRefCountObject.hxx" - -namespace ParaMEDMEM -{ - template - class MEDCouplingAutoRefCountObjectPtr - { - public: - MEDCouplingAutoRefCountObjectPtr(const MEDCouplingAutoRefCountObjectPtr& other):_ptr(0) { referPtr(other._ptr); } - MEDCouplingAutoRefCountObjectPtr(T *ptr=0):_ptr(ptr) { } - ~MEDCouplingAutoRefCountObjectPtr() { destroyPtr(); } - MEDCouplingAutoRefCountObjectPtr &operator=(const MEDCouplingAutoRefCountObjectPtr& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; } - MEDCouplingAutoRefCountObjectPtr &operator=(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; } - T *operator->() { return _ptr ; } - const T *operator->() const { return _ptr; } - T& operator*() { return *_ptr; } - const T& operator*() const { return *_ptr; } - operator T *() { return _ptr; } - operator const T *() const { return _ptr; } - private: - void referPtr(T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); } - void destroyPtr() { if(_ptr) _ptr->decrRef(); } - private: - T *_ptr; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx deleted file mode 100644 index a8aeaf1ef..000000000 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ /dev/null @@ -1,636 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingCMesh.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingFieldDouble.hxx" - -#include -#include -#include - -using namespace ParaMEDMEM; - -MEDCouplingCMesh::MEDCouplingCMesh():_x_array(0),_y_array(0),_z_array(0) -{ -} - -MEDCouplingCMesh::MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy):MEDCouplingMesh(other) -{ - if(deepCpy) - { - if(other._x_array) - _x_array=_x_array->deepCopy(); - if(other._y_array) - _y_array=_y_array->deepCopy(); - if(other._z_array) - _z_array=_z_array->deepCopy(); - } - else - { - _x_array=other._x_array; - if(_x_array) - _x_array->incrRef(); - _y_array=other._y_array; - if(_y_array) - _y_array->incrRef(); - _z_array=other._z_array; - if(_z_array) - _z_array->incrRef(); - } -} - -MEDCouplingCMesh::~MEDCouplingCMesh() -{ - if(_x_array) - _x_array->decrRef(); - if(_y_array) - _y_array->decrRef(); - if(_z_array) - _z_array->decrRef(); -} - -MEDCouplingCMesh *MEDCouplingCMesh::New() -{ - return new MEDCouplingCMesh; -} - -MEDCouplingMesh *MEDCouplingCMesh::deepCpy() const -{ - return clone(true); -} - -MEDCouplingCMesh *MEDCouplingCMesh::clone(bool recDeepCpy) const -{ - return new MEDCouplingCMesh(*this,recDeepCpy); -} - -void MEDCouplingCMesh::updateTime() -{ - if(_x_array) - updateTimeWith(*_x_array); - if(_y_array) - updateTimeWith(*_y_array); - if(_z_array) - updateTimeWith(*_z_array); -} - -/*! - * This method copyies all tiny strings from other (name and components name). - * @throw if other and this have not same mesh type. - */ -void MEDCouplingCMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingCMesh *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("MEDCouplingCMesh::copyTinyStringsFrom : meshes have not same type !"); - MEDCouplingMesh::copyTinyStringsFrom(other); - if(_x_array && otherC->_x_array) - _x_array->copyStringInfoFrom(*otherC->_x_array); - if(_y_array && otherC->_y_array) - _y_array->copyStringInfoFrom(*otherC->_y_array); - if(_z_array && otherC->_z_array) - _z_array->copyStringInfoFrom(*otherC->_z_array); -} - -bool MEDCouplingCMesh::isEqual(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingCMesh *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!MEDCouplingMesh::isEqual(other,prec)) - return false; - const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; - const DataArrayDouble *otherArr[3]={otherC->_x_array,otherC->_y_array,otherC->_z_array}; - for(int i=0;i<3;i++) - { - if((thisArr[i]!=0 && otherArr[i]==0) || (thisArr[i]==0 && otherArr[i]!=0)) - return false; - if(thisArr[i]) - if(!thisArr[i]->isEqual(*otherArr[i],prec)) - return false; - } - return true; -} - -bool MEDCouplingCMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingCMesh *otherC=dynamic_cast(other); - if(!otherC) - return false; - const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; - const DataArrayDouble *otherArr[3]={otherC->_x_array,otherC->_y_array,otherC->_z_array}; - for(int i=0;i<3;i++) - { - if((thisArr[i]!=0 && otherArr[i]==0) || (thisArr[i]==0 && otherArr[i]!=0)) - return false; - if(thisArr[i]) - if(!thisArr[i]->isEqualWithoutConsideringStr(*otherArr[i],prec)) - return false; - } - return true; -} - -void MEDCouplingCMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingCMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - const char msg0[]="Invalid "; - const char msg1[]=" array ! Must contain more than 1 element."; - const char msg2[]=" array ! Must be with only one component."; - if(_x_array) - { - if(_x_array->getNbOfElems()<2) - { - std::ostringstream os; os << msg0 << 'X' << msg1; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - if(_x_array->getNumberOfComponents()!=1) - { - std::ostringstream os; os << msg0 << 'X' << msg2; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - } - if(_y_array) - { - if(_y_array->getNbOfElems()<2) - { - std::ostringstream os; os << msg0 << 'Y' << msg1; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - if(_y_array->getNumberOfComponents()!=1) - { - std::ostringstream os; os << msg0 << 'Y' << msg2; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - - } - if(_z_array) - { - if(_z_array->getNbOfElems()<2) - { - std::ostringstream os; os << msg0 << 'Z' << msg1; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - if(_z_array->getNumberOfComponents()!=1) - { - std::ostringstream os; os << msg0 << 'Z' << msg2; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } - } -} - -int MEDCouplingCMesh::getNumberOfCells() const -{ - int ret=1; - if(_x_array) - ret*=_x_array->getNbOfElems()-1; - if(_y_array) - ret*=_y_array->getNbOfElems()-1; - if(_z_array) - ret*=_z_array->getNbOfElems()-1; - return ret; -} - -int MEDCouplingCMesh::getNumberOfNodes() const -{ - int ret=1; - if(_x_array) - ret*=_x_array->getNbOfElems(); - if(_y_array) - ret*=_y_array->getNbOfElems(); - if(_z_array) - ret*=_z_array->getNbOfElems(); - return ret; -} - -void MEDCouplingCMesh::getSplitCellValues(int *res) const -{ - int spaceDim=getSpaceDimension(); - for(int l=0;lgetNbOfElems()-1; - res[spaceDim-l-1]=val; - } -} - -void MEDCouplingCMesh::getSplitNodeValues(int *res) const -{ - int spaceDim=getSpaceDimension(); - for(int l=0;lgetNbOfElems(); - res[spaceDim-l-1]=val; - } -} - -int MEDCouplingCMesh::getCellIdFromPos(int i, int j, int k) const -{ - int tmp[3]={i,j,k}; - int tmp2[3]; - int spaceDim=getSpaceDimension(); - getSplitCellValues(tmp2); - std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies()); - return std::accumulate(tmp,tmp+spaceDim,0); -} - -int MEDCouplingCMesh::getNodeIdFromPos(int i, int j, int k) const -{ - int tmp[3]={i,j,k}; - int tmp2[3]; - int spaceDim=getSpaceDimension(); - getSplitNodeValues(tmp2); - std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies()); - return std::accumulate(tmp,tmp+spaceDim,0); -} - -void MEDCouplingCMesh::getPosFromId(int nodeId, int spaceDim, const int *split, int *res) -{ - int work=nodeId; - for(int i=spaceDim-1;i>=0;i--) - { - int pos=work/split[i]; - work=work%split[i]; - res[i]=pos; - } -} - -int MEDCouplingCMesh::getSpaceDimension() const -{ - int ret=0; - if(_x_array) - ret++; - if(_y_array) - ret++; - if(_z_array) - ret++; - return ret; -} - -int MEDCouplingCMesh::getMeshDimension() const -{ - return getSpaceDimension(); -} - -INTERP_KERNEL::NormalizedCellType MEDCouplingCMesh::getTypeOfCell(int cellId) const -{ - switch(getMeshDimension()) - { - case 3: - return INTERP_KERNEL::NORM_HEXA8; - case 2: - return INTERP_KERNEL::NORM_QUAD4; - case 1: - return INTERP_KERNEL::NORM_SEG2; - default: - throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingCMesh::getTypeOfCell !"); - } -} - -int MEDCouplingCMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const -{ - int ret=getNumberOfCells(); - int dim=getMeshDimension(); - switch(type) - { - case INTERP_KERNEL::NORM_HEXA8: - if(dim==3) - return ret; - case INTERP_KERNEL::NORM_QUAD4: - if(dim==2) - return ret; - case INTERP_KERNEL::NORM_SEG2: - if(dim==1) - return ret; - default: - throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingCMesh::getTypeOfCell !"); - } - return 0; -} - -void MEDCouplingCMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const -{ - //not implemented yet -} - -void MEDCouplingCMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const -{ - //not implemented yet -} - -std::string MEDCouplingCMesh::simpleRepr() const -{ - std::ostringstream ret; - ret << "Cartesian mesh with name : \"" << getName() << "\"\n"; - ret << "Mesh and SpaceDimension dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n"; - if(_x_array) - { - ret << "X Array :\n"; - _x_array->reprZipWithoutNameStream(ret); - } - if(_y_array) - { - ret << "Y Array :\n"; - _y_array->reprZipWithoutNameStream(ret); - } - if(_z_array) - { - ret << "Z Array :\n"; - _z_array->reprZipWithoutNameStream(ret); - } - return ret.str(); -} - -std::string MEDCouplingCMesh::advancedRepr() const -{ - return simpleRepr(); -} - -DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception) -{ - switch(i) - { - case 0: - return _x_array; - case 1: - return _y_array; - case 2: - return _z_array; - default: - throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2."); - } -} - -void MEDCouplingCMesh::setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception) -{ - DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array}; - if(i<0 || i>2) - throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2."); - if(arr!=*(thisArr[i])) - { - if(*(thisArr[i])) - (*(thisArr[i]))->decrRef(); - (*(thisArr[i]))=arr; - if(*(thisArr[i])) - (*(thisArr[i]))->incrRef(); - declareAsNew(); - } -} - -void MEDCouplingCMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ) -{ - if(_x_array) - _x_array->decrRef(); - _x_array=coordsX; - if(_x_array) - _x_array->incrRef(); - if(_y_array) - _y_array->decrRef(); - _y_array=coordsY; - if(_y_array) - _y_array->incrRef(); - if(_z_array) - _z_array->decrRef(); - _z_array=coordsZ; - if(_z_array) - _z_array->incrRef(); - declareAsNew(); -} - -MEDCouplingMesh *MEDCouplingCMesh::buildPart(const int *start, const int *end) const -{ - //not implemented yet ! - return 0; -} - -MEDCouplingMesh *MEDCouplingCMesh::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const -{ - //not implemented yet ! - return 0; -} - -void MEDCouplingCMesh::getBoundingBox(double *bbox) const -{ - //not implemented yet ! -} - -MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool isAbs) const -{ - //not implemented yet ! - return 0; -} - -MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureFieldOnNode(bool isAbs) const -{ - //not implemented yet ! - return 0; -} - -MEDCouplingFieldDouble *MEDCouplingCMesh::buildOrthogonalField() const -{ - if(getMeshDimension()!=2) - throw INTERP_KERNEL::Exception("Expected a cmesh with meshDim == 2 !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - DataArrayDouble *array=DataArrayDouble::New(); - int nbOfCells=getNumberOfCells(); - array->alloc(nbOfCells,3); - double *vals=array->getPointer(); - for(int i=0;isetArray(array); - array->decrRef(); - ret->setMesh(this); - return ret; -} - -int MEDCouplingCMesh::getCellContainingPoint(const double *pos, double eps) const -{ - //not implemented yet ! - return -1; -} - -void MEDCouplingCMesh::rotate(const double *center, const double *vector, double angle) -{ - throw INTERP_KERNEL::Exception("No rotation available on CMesh : Traduce it to StructuredMesh to apply it !"); -} - -void MEDCouplingCMesh::translate(const double *vector) -{ - if(_x_array) - std::transform(_x_array->getConstPointer(),_x_array->getConstPointer()+_x_array->getNbOfElems(), - _x_array->getPointer(),std::bind2nd(std::plus(),vector[0])); - if(_y_array) - std::transform(_y_array->getConstPointer(),_y_array->getConstPointer()+_y_array->getNbOfElems(), - _y_array->getPointer(),std::bind2nd(std::plus(),vector[1])); - if(_z_array) - std::transform(_z_array->getConstPointer(),_z_array->getConstPointer()+_z_array->getNbOfElems(), - _z_array->getPointer(),std::bind2nd(std::plus(),vector[2])); -} - -void MEDCouplingCMesh::scale(const double *point, double factor) -{ - //not implemented yet ! - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -MEDCouplingMesh *MEDCouplingCMesh::mergeMyselfWith(const MEDCouplingMesh *other) const -{ - //not implemented yet ! - return 0; -} - -DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const -{ - DataArrayDouble *ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - int nbNodes=getNumberOfNodes(); - ret->alloc(nbNodes,spaceDim); - double *pt=ret->getPointer(); - int tmp[3]; - getSplitNodeValues(tmp); - DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; - const double *tabsPtr[3]; - for(int j=0;jgetConstPointer(); - int tmp2[3]; - for(int i=0;ialloc(nbCells,spaceDim); - double *pt=ret->getPointer(); - int tmp[3]; - getSplitCellValues(tmp); - DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; - std::vector tabsPtr[3]; - for(int j=0;jgetNbOfElems()-1; - const double *srcPtr=tabs[j]->getConstPointer(); - tabsPtr[j].insert(tabsPtr[j].end(),srcPtr,srcPtr+sz); - std::transform(tabsPtr[j].begin(),tabsPtr[j].end(),srcPtr+1,tabsPtr[j].begin(),std::plus()); - std::transform(tabsPtr[j].begin(),tabsPtr[j].end(),tabsPtr[j].begin(),std::bind2nd(std::multiplies(),0.5)); - } - int tmp2[3]; - for(int i=0;i& tinyInfo, std::vector& littleStrings) const -{ - tinyInfo.clear(); - littleStrings.clear(); - littleStrings.push_back(getName()); - const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; - for(int i=0;i<3;i++) - { - int val=-1; - std::string st; - if(thisArr[i]) - { - val=thisArr[i]->getNumberOfTuples(); - st=thisArr[i]->getInfoOnComponent(0); - } - tinyInfo.push_back(val); - littleStrings.push_back(st); - } -} - -void MEDCouplingCMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const -{ - a1->alloc(0,1); - int sum=0; - for(int i=0;i<3;i++) - if(tinyInfo[i]!=-1) - sum+=tinyInfo[i]; - a2->alloc(sum,1); -} - -void MEDCouplingCMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const -{ - a1=DataArrayInt::New(); - a1->alloc(0,1); - const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; - int sz=0; - for(int i=0;i<3;i++) - { - if(thisArr[i]) - sz+=thisArr[i]->getNumberOfTuples(); - } - a2=DataArrayDouble::New(); - a2->alloc(sz,1); - double *a2Ptr=a2->getPointer(); - for(int i=0;i<3;i++) - if(thisArr[i]) - a2Ptr=std::copy(thisArr[i]->getConstPointer(),thisArr[i]->getConstPointer()+thisArr[i]->getNumberOfTuples(),a2Ptr); -} - -void MEDCouplingCMesh::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings) -{ - setName(littleStrings[0].c_str()); - DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array}; - const double *data=a2->getConstPointer(); - for(int i=0;i<3;i++) - { - if(tinyInfo[i]!=-1) - { - (*(thisArr[i]))=DataArrayDouble::New(); - (*(thisArr[i]))->alloc(tinyInfo[i],1); - (*(thisArr[i]))->setInfoOnComponent(0,littleStrings[i+1].c_str()); - std::copy(data,data+tinyInfo[i],(*(thisArr[i]))->getPointer()); - data+=tinyInfo[i]; - } - } -} - diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx deleted file mode 100644 index 3cdee7c39..000000000 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingMesh.hxx" - -namespace ParaMEDMEM -{ - class DataArrayDouble; - - class MEDCOUPLING_EXPORT MEDCouplingCMesh : public MEDCouplingMesh - { - public: - static MEDCouplingCMesh *New(); - MEDCouplingMesh *deepCpy() const; - MEDCouplingCMesh *clone(bool recDeepCpy) const; - void updateTime(); - MEDCouplingMeshType getType() const { return CARTESIAN; } - void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); - bool isEqual(const MEDCouplingMesh *other, double prec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception); - void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception); - void checkCoherency() const throw(INTERP_KERNEL::Exception); - int getNumberOfCells() const; - int getNumberOfNodes() const; - int getSpaceDimension() const; - int getMeshDimension() const; - int getCellIdFromPos(int i, int j, int k) const; - int getNodeIdFromPos(int i, int j, int k) const; - static void getPosFromId(int nodeId, int spaceDim, const int *split, int *res); - INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; - int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - void getNodeIdsOfCell(int cellId, std::vector& conn) const; - void getCoordinatesOfNode(int nodeId, std::vector& coo) const; - std::string simpleRepr() const; - std::string advancedRepr() const; - DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception); - void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); - void setCoords(DataArrayDouble *coordsX, - DataArrayDouble *coordsY=0, - DataArrayDouble *coordsZ=0); - // tools - MEDCouplingMesh *buildPart(const int *start, const int *end) const; - MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; - void getBoundingBox(double *bbox) const; - MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCouplingFieldDouble *buildOrthogonalField() const; - int getCellContainingPoint(const double *pos, double eps) const; - void rotate(const double *center, const double *vector, double angle); - void translate(const double *vector); - void scale(const double *point, double factor); - MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - DataArrayDouble *getCoordinatesAndOwner() const; - DataArrayDouble *getBarycenterAndOwner() const; - void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - //some useful methods - void getSplitCellValues(int *res) const; - void getSplitNodeValues(int *res) const; - //serialisation-unserialization - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - private: - MEDCouplingCMesh(); - MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy); - ~MEDCouplingCMesh(); - private: - DataArrayDouble *_x_array; - DataArrayDouble *_y_array; - DataArrayDouble *_z_array; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx deleted file mode 100644 index d01e29149..000000000 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ /dev/null @@ -1,782 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "CellModel.hxx" - -#include "InterpolationUtils.hxx" - -#include -#include -#include -#include -#include -#include -#include - -using namespace ParaMEDMEM; - -/*! - * Build an extruded mesh instance from 3D and 2D unstructured mesh lying on the \b same \b coords. - * @param mesh3D 3D unstructured mesh. - * @param mesh2D 2D unstructured mesh lying on the same coordinates than mesh3D. \b Warning mesh2D is \b not \b const - * because the mesh is aggregated and potentially modified by rotate or translate method. - * @param cell2DId Id of cell in mesh2D mesh where the computation of 1D mesh will be done. - */ -MEDCouplingExtrudedMesh *MEDCouplingExtrudedMesh::New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception) -{ - return new MEDCouplingExtrudedMesh(mesh3D,mesh2D,cell2DId); -} - -/*! - * This constructor is here only for unserialisation process. - * This constructor is normally completely useless for end user. - */ -MEDCouplingExtrudedMesh *MEDCouplingExtrudedMesh::New() -{ - return new MEDCouplingExtrudedMesh; -} - -MEDCouplingMeshType MEDCouplingExtrudedMesh::getType() const -{ - return EXTRUDED; -} - -/*! - * This method copyies all tiny strings from other (name and components name). - * @throw if other and this have not same mesh type. - */ -void MEDCouplingExtrudedMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingExtrudedMesh *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::copyTinyStringsFrom : meshes have not same type !"); - MEDCouplingMesh::copyTinyStringsFrom(other); - _mesh2D->copyTinyStringsFrom(otherC->_mesh2D); - _mesh1D->copyTinyStringsFrom(otherC->_mesh1D); -} - -MEDCouplingExtrudedMesh::MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception) -try:_mesh2D(mesh2D),_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(cell2DId) -{ - if(_mesh2D!=0) - _mesh2D->incrRef(); - computeExtrusion(mesh3D); - setName(mesh3D->getName()); -} -catch(INTERP_KERNEL::Exception& e) - { - if(_mesh2D) - _mesh2D->decrRef(); - if(_mesh1D) - _mesh1D->decrRef(); - if(_mesh3D_ids) - _mesh3D_ids->decrRef(); - throw e; - } - -MEDCouplingExtrudedMesh::MEDCouplingExtrudedMesh():_mesh2D(0),_mesh1D(0),_mesh3D_ids(0),_cell_2D_id(-1) -{ -} - -MEDCouplingExtrudedMesh::MEDCouplingExtrudedMesh(const MEDCouplingExtrudedMesh& other, bool deepCpy):MEDCouplingMesh(other),_cell_2D_id(other._cell_2D_id) -{ - if(deepCpy) - { - _mesh2D=other._mesh2D->clone(true); - _mesh1D=other._mesh1D->clone(true); - _mesh3D_ids=other._mesh3D_ids->deepCopy(); - } - else - { - _mesh2D=other._mesh2D; - if(_mesh2D) - _mesh2D->incrRef(); - _mesh1D=other._mesh1D; - if(_mesh1D) - _mesh1D->incrRef(); - _mesh3D_ids=other._mesh3D_ids; - if(_mesh3D_ids) - _mesh3D_ids->incrRef(); - } -} - -int MEDCouplingExtrudedMesh::getNumberOfCells() const -{ - return _mesh2D->getNumberOfCells()*_mesh1D->getNumberOfCells(); -} - -int MEDCouplingExtrudedMesh::getNumberOfNodes() const -{ - return _mesh2D->getNumberOfNodes(); -} - -int MEDCouplingExtrudedMesh::getSpaceDimension() const -{ - return 3; -} - -int MEDCouplingExtrudedMesh::getMeshDimension() const -{ - return 3; -} - -MEDCouplingMesh *MEDCouplingExtrudedMesh::deepCpy() const -{ - return clone(true); -} - -MEDCouplingExtrudedMesh *MEDCouplingExtrudedMesh::clone(bool recDeepCpy) const -{ - return new MEDCouplingExtrudedMesh(*this,recDeepCpy); -} - -bool MEDCouplingExtrudedMesh::isEqual(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingExtrudedMesh *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!MEDCouplingMesh::isEqual(other,prec)) - return false; - if(!_mesh2D->isEqual(otherC->_mesh2D,prec)) - return false; - if(!_mesh1D->isEqual(otherC->_mesh1D,prec)) - return false; - if(!_mesh3D_ids->isEqual(*otherC->_mesh3D_ids)) - return false; - if(_cell_2D_id!=otherC->_cell_2D_id) - return false; - return true; -} - -bool MEDCouplingExtrudedMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingExtrudedMesh *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!_mesh2D->isEqualWithoutConsideringStr(otherC->_mesh2D,prec)) - return false; - if(!_mesh1D->isEqualWithoutConsideringStr(otherC->_mesh1D,prec)) - return false; - if(!_mesh3D_ids->isEqualWithoutConsideringStr(*otherC->_mesh3D_ids)) - return false; - if(_cell_2D_id!=otherC->_cell_2D_id) - return false; - return true; -} - -void MEDCouplingExtrudedMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::checkDeepEquivalWith : not implemented yet !"); -} - -void MEDCouplingExtrudedMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::checkDeepEquivalOnSameNodesWith : not implemented yet !"); -} - -INTERP_KERNEL::NormalizedCellType MEDCouplingExtrudedMesh::getTypeOfCell(int cellId) const -{ - const int *ids=_mesh3D_ids->getConstPointer(); - int nbOf3DCells=_mesh3D_ids->getNumberOfTuples(); - const int *where=std::find(ids,ids+nbOf3DCells,cellId); - if(where==ids+nbOf3DCells) - throw INTERP_KERNEL::Exception("Invalid cellId specified >= getNumberOfCells() !"); - int nbOfCells2D=_mesh2D->getNumberOfCells(); - int locId=std::distance(ids,where)%nbOfCells2D; - INTERP_KERNEL::NormalizedCellType tmp=_mesh2D->getTypeOfCell(locId); - return INTERP_KERNEL::CellModel::getCellModel(tmp).getExtrudedType(); -} - -int MEDCouplingExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const -{ - int ret=0; - int nbOfCells2D=_mesh2D->getNumberOfCells(); - for(int i=0;igetTypeOfCell(i); - if(INTERP_KERNEL::CellModel::getCellModel(t).getExtrudedType()==type) - ret++; - } - return ret*_mesh1D->getNumberOfCells(); -} - -void MEDCouplingExtrudedMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const -{ - int nbOfCells2D=_mesh2D->getNumberOfCells(); - int nbOfNodes2D=_mesh2D->getNumberOfNodes(); - int locId=cellId%nbOfCells2D; - int lev=cellId/nbOfCells2D; - std::vector tmp,tmp2; - _mesh2D->getNodeIdsOfCell(locId,tmp); - tmp2=tmp; - std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::plus(),nbOfNodes2D*lev)); - std::transform(tmp2.begin(),tmp2.end(),tmp2.begin(),std::bind2nd(std::plus(),nbOfNodes2D*(lev+1))); - conn.insert(conn.end(),tmp.begin(),tmp.end()); - conn.insert(conn.end(),tmp2.begin(),tmp2.end()); -} - -void MEDCouplingExtrudedMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const -{ - int nbOfNodes2D=_mesh2D->getNumberOfNodes(); - int locId=nodeId%nbOfNodes2D; - int lev=nodeId/nbOfNodes2D; - std::vector tmp,tmp2; - _mesh2D->getCoordinatesOfNode(locId,tmp); - tmp2=tmp; - int spaceDim=_mesh1D->getSpaceDimension(); - const double *z=_mesh1D->getCoords()->getConstPointer(); - std::transform(tmp.begin(),tmp.end(),z+lev*spaceDim,tmp.begin(),std::plus()); - std::transform(tmp2.begin(),tmp2.end(),z+(lev+1)*spaceDim,tmp2.begin(),std::plus()); - coo.insert(coo.end(),tmp.begin(),tmp.end()); - coo.insert(coo.end(),tmp2.begin(),tmp2.end()); -} - -std::string MEDCouplingExtrudedMesh::simpleRepr() const -{ - std::ostringstream ret; - ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n"; - ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n"; - ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n"; - ret << "1D Mesh info : _____________________\n\n\n"; - ret << _mesh1D->simpleRepr(); - ret << "\n\n\n2D Mesh info : _____________________\n\n\n" << _mesh2D->simpleRepr() << "\n\n\n"; - return ret.str(); -} - -std::string MEDCouplingExtrudedMesh::advancedRepr() const -{ - std::ostringstream ret; - ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n"; - ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n"; - ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n"; - ret << "1D Mesh info : _____________________\n\n\n"; - ret << _mesh1D->advancedRepr(); - ret << "\n\n\n2D Mesh info : _____________________\n\n\n" << _mesh2D->advancedRepr() << "\n\n\n"; - ret << "3D cell ids per level :\n"; - return ret.str(); -} - -void MEDCouplingExtrudedMesh::checkCoherency() const throw (INTERP_KERNEL::Exception) -{ -} - -void MEDCouplingExtrudedMesh::getBoundingBox(double *bbox) const -{ - double bbox2D[6]; - _mesh2D->getBoundingBox(bbox2D); - const double *nodes1D=_mesh1D->getCoords()->getConstPointer(); - int nbOfNodes1D=_mesh1D->getNumberOfNodes(); - double bbox1DMin[3],bbox1DMax[3],tmp[3]; - std::fill(bbox1DMin,bbox1DMin+3,std::numeric_limits::max()); - std::fill(bbox1DMax,bbox1DMax+3,-(std::numeric_limits::max())); - for(int i=0;i(std::min)); - std::transform(nodes1D+3*i,nodes1D+3*(i+1),bbox1DMax,bbox1DMax,static_cast(std::max)); - } - std::transform(bbox1DMax,bbox1DMax+3,bbox1DMin,tmp,std::minus()); - int id=std::max_element(tmp,tmp+3)-tmp; - bbox[0]=bbox1DMin[0]; bbox[1]=bbox1DMax[0]; - bbox[2]=bbox1DMin[1]; bbox[3]=bbox1DMax[1]; - bbox[4]=bbox1DMin[2]; bbox[5]=bbox1DMax[2]; - bbox[2*id+1]+=tmp[id]; -} - -void MEDCouplingExtrudedMesh::updateTime() -{ - if(_mesh2D) - { - updateTimeWith(*_mesh2D); - } - if(_mesh1D) - { - updateTimeWith(*_mesh1D); - } -} - -void MEDCouplingExtrudedMesh::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Functionnality of renumbering cells unavailable for ExtrudedMesh"); -} - -MEDCouplingUMesh *MEDCouplingExtrudedMesh::build3DUnstructuredMesh() const -{ - MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMeshFromThis(_mesh1D,0); - const int *renum=_mesh3D_ids->getConstPointer(); - ret->renumberCells(renum,false); - ret->setName(getName()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::getMeasureField(bool) const -{ - std::string name="MeasureOfMesh_"; - name+=getName(); - MEDCouplingFieldDouble *ret2D=_mesh2D->getMeasureField(true); - MEDCouplingFieldDouble *ret1D=_mesh1D->getMeasureField(true); - const double *ret2DPtr=ret2D->getArray()->getConstPointer(); - const double *ret1DPtr=ret1D->getArray()->getConstPointer(); - int nbOf2DCells=_mesh2D->getNumberOfCells(); - int nbOf1DCells=_mesh1D->getNumberOfCells(); - int nbOf3DCells=nbOf2DCells*nbOf1DCells; - const int *renum=_mesh3D_ids->getConstPointer(); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - ret->setMesh(this); - DataArrayDouble *da=DataArrayDouble::New(); - da->alloc(nbOf3DCells,1); - double *retPtr=da->getPointer(); - for(int i=0;isetArray(da); - da->decrRef(); - ret->setName(name.c_str()); - ret2D->decrRef(); - ret1D->decrRef(); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::getMeasureFieldOnNode(bool isAbs) const -{ - //not implemented yet - return 0; -} - -MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::buildOrthogonalField() const -{ - throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::buildOrthogonalField : This method has no sense for MEDCouplingExtrudedMesh that is 3D !"); -} - -int MEDCouplingExtrudedMesh::getCellContainingPoint(const double *pos, double eps) const -{ - //not implemented yet - return -1; -} - -MEDCouplingExtrudedMesh::~MEDCouplingExtrudedMesh() -{ - if(_mesh2D) - _mesh2D->decrRef(); - if(_mesh1D) - _mesh1D->decrRef(); - if(_mesh3D_ids) - _mesh3D_ids->decrRef(); -} - -void MEDCouplingExtrudedMesh::computeExtrusion(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception) -{ - const char errMsg1[]="2D mesh is empty unable to compute extrusion !"; - const char errMsg2[]="Coords between 2D and 3D meshes are not the same ! Try MEDCouplingPointSet::tryToShareSameCoords method"; - const char errMsg3[]="No chance to find extrusion pattern in mesh3D,mesh2D couple because nbCells3D%nbCells2D!=0 !"; - if(_mesh2D==0 || mesh3D==0) - throw INTERP_KERNEL::Exception(errMsg1); - if(_mesh2D->getCoords()!=mesh3D->getCoords()) - throw INTERP_KERNEL::Exception(errMsg2); - if(mesh3D->getNumberOfCells()%_mesh2D->getNumberOfCells()!=0) - throw INTERP_KERNEL::Exception(errMsg3); - if(!_mesh3D_ids) - _mesh3D_ids=DataArrayInt::New(); - if(!_mesh1D) - _mesh1D=MEDCouplingUMesh::New(); - computeExtrusionAlg(mesh3D); -} - -void MEDCouplingExtrudedMesh::build1DExtrusion(int idIn3DDesc, int newId, int nbOf1DLev, MEDCouplingUMesh *subMesh, - const int *desc3D, const int *descIndx3D, - const int *revDesc3D, const int *revDescIndx3D, - bool computeMesh1D) throw(INTERP_KERNEL::Exception) -{ - int nbOf2DCells=_mesh2D->getNumberOfCells(); - int start=revDescIndx3D[idIn3DDesc]; - int end=revDescIndx3D[idIn3DDesc+1]; - if(end-start!=1) - { - std::ostringstream ost; ost << "Invalid bases 2D mesh specified : 2D cell # " << idIn3DDesc; - ost << " shared by more than 1 3D cell !!!"; - throw INTERP_KERNEL::Exception(ost.str().c_str()); - } - int current3DCell=revDesc3D[start]; - int current2DCell=idIn3DDesc; - int *mesh3DIDs=_mesh3D_ids->getPointer(); - mesh3DIDs[newId]=current3DCell; - const int *conn2D=subMesh->getNodalConnectivity()->getConstPointer(); - const int *conn2DIndx=subMesh->getNodalConnectivityIndex()->getConstPointer(); - for(int i=1;i conn(conn2D+conn2DIndx[current2DCell]+1,conn2D+conn2DIndx[current2DCell+1]); - std::sort(conn.begin(),conn.end()); - if(computeMesh1D) - computeBaryCenterOfFace(conn,i-1); - current2DCell=findOppositeFaceOf(current2DCell,current3DCell,conn, - desc3D,descIndx3D,conn2D,conn2DIndx); - start=revDescIndx3D[current2DCell]; - end=revDescIndx3D[current2DCell+1]; - if(end-start!=2) - { - std::ostringstream ost; ost << "Expecting to have 2 3D cells attached to 2D cell " << current2DCell << "!"; - ost << " : Impossible or call tryToShareSameCoords method !"; - throw INTERP_KERNEL::Exception(ost.str().c_str()); - } - if(revDesc3D[start]!=current3DCell) - current3DCell=revDesc3D[start]; - else - current3DCell=revDesc3D[start+1]; - mesh3DIDs[i*nbOf2DCells+newId]=current3DCell; - } - if(computeMesh1D) - { - std::vector conn(conn2D+conn2DIndx[current2DCell]+1,conn2D+conn2DIndx[current2DCell+1]); - std::sort(conn.begin(),conn.end()); - computeBaryCenterOfFace(conn,nbOf1DLev-1); - current2DCell=findOppositeFaceOf(current2DCell,current3DCell,conn, - desc3D,descIndx3D,conn2D,conn2DIndx); - conn.clear(); - conn.insert(conn.end(),conn2D+conn2DIndx[current2DCell]+1,conn2D+conn2DIndx[current2DCell+1]); - std::sort(conn.begin(),conn.end()); - computeBaryCenterOfFace(conn,nbOf1DLev); - } -} - -int MEDCouplingExtrudedMesh::findOppositeFaceOf(int current2DCell, int current3DCell, const std::vector& connSorted, - const int *desc3D, const int *descIndx3D, - const int *conn2D, const int *conn2DIndx) throw(INTERP_KERNEL::Exception) -{ - int start=descIndx3D[current3DCell]; - int end=descIndx3D[current3DCell+1]; - bool found=false; - for(const int *candidate2D=desc3D+start;candidate2D!=desc3D+end && !found;candidate2D++) - { - if(*candidate2D!=current2DCell) - { - std::vector conn2(conn2D+conn2DIndx[*candidate2D]+1,conn2D+conn2DIndx[*candidate2D+1]); - std::sort(conn2.begin(),conn2.end()); - std::list intersect; - std::set_intersection(connSorted.begin(),connSorted.end(),conn2.begin(),conn2.end(), - std::insert_iterator< std::list >(intersect,intersect.begin())); - if(intersect.empty()) - return *candidate2D; - } - } - std::ostringstream ost; ost << "Impossible to find an opposite 2D face of face # " << current2DCell; - ost << " in 3D cell # " << current3DCell << " : Impossible or call tryToShareSameCoords method !"; - throw INTERP_KERNEL::Exception(ost.str().c_str()); -} - -void MEDCouplingExtrudedMesh::computeBaryCenterOfFace(const std::vector& nodalConnec, int lev1DId) -{ - double *zoneToUpdate=_mesh1D->getCoords()->getPointer()+lev1DId*3; - std::fill(zoneToUpdate,zoneToUpdate+3,0.); - const double *coords=_mesh2D->getCoords()->getConstPointer(); - for(std::vector::const_iterator iter=nodalConnec.begin();iter!=nodalConnec.end();iter++) - std::transform(zoneToUpdate,zoneToUpdate+3,coords+3*(*iter),zoneToUpdate,std::plus()); - std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind2nd(std::multiplies(),(double)(1./nodalConnec.size()))); -} - -int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception) -{ - std::vector::const_iterator iter=nodalConnec.begin(); - std::set s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]); - iter++; - for(;iter!=nodalConnec.end();iter++) - { - std::set s2(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]); - std::set s3; - std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),std::insert_iterator< std::set >(s3,s3.end())); - s1=s3; - } - if(s1.size()==1) - return *(s1.begin()); - std::ostringstream ostr; - ostr << "Cell with nodal connec : "; - std::copy(nodalConnec.begin(),nodalConnec.end(),std::ostream_iterator(ostr," ")); - ostr << " is not part of mesh"; - throw INTERP_KERNEL::Exception(ostr.str().c_str()); -} - -/*! - * This method is callable on 1Dmeshes (meshDim==1 && spaceDim==3) returned by MEDCouplingExtrudedMesh::getMesh1D typically. - * These 1Dmeshes (meshDim==1 && spaceDim==3) have a special semantic because these meshes do not specify a static location but a translation along a path. - * This method checks that 'm1' and 'm2' are compatible, if not an exception is thrown. In case these meshes ('m1' and 'm2') are compatible 2 corresponding meshes - * are created ('m1r' and 'm2r') that can be used for interpolation. - * @param m1 input mesh with meshDim==1 and spaceDim==3 - * @param m2 input mesh with meshDim==1 and spaceDim==3 - * @param eps tolerance acceptable to determine compatibility - * @param m1r output mesh with ref count equal to 1 with meshDim==1 and spaceDim==1 - * @param m2r output mesh with ref count equal to 1 with meshDim==1 and spaceDim==1 - * @param v is the output normalized vector of the common direction of 'm1' and 'm2' - * @throw in case that m1 and m2 are not compatible each other. - */ -void MEDCouplingExtrudedMesh::project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, - MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception) -{ - if(m1->getSpaceDimension()!=3 || m1->getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for projec1D !"); - m1r=m1->clone(true); - m2r=m2->clone(true); - m1r->changeSpaceDimension(1); - m2r->changeSpaceDimension(1); - std::vector c; - std::vector ref,ref2; - m1->getNodeIdsOfCell(0,c); - m1->getCoordinatesOfNode(c[0],ref); - m1->getCoordinatesOfNode(c[1],ref2); - std::transform(ref2.begin(),ref2.end(),ref.begin(),v,std::minus()); - double n=INTERP_KERNEL::norm<3>(v); - std::transform(v,v+3,v,std::bind2nd(std::multiplies(),1/n)); - m1->project1D(&ref[0],v,eps,m1r->getCoords()->getPointer()); - m2->project1D(&ref[0],v,eps,m2r->getCoords()->getPointer()); - -} - -void MEDCouplingExtrudedMesh::rotate(const double *center, const double *vector, double angle) -{ - _mesh2D->rotate(center,vector,angle); - _mesh1D->rotate(center,vector,angle); -} - -void MEDCouplingExtrudedMesh::translate(const double *vector) -{ - _mesh2D->translate(vector); - _mesh1D->translate(vector); -} - -void MEDCouplingExtrudedMesh::scale(const double *point, double factor) -{ - _mesh2D->scale(point,factor); - _mesh1D->scale(point,factor); -} - -MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPart(const int *start, const int *end) const -{ - // not implemented yet ! - return 0; -} - -MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const -{ - // not implemented yet ! - return 0; -} - -MEDCouplingMesh *MEDCouplingExtrudedMesh::mergeMyselfWith(const MEDCouplingMesh *other) const -{ - // not implemented yet ! - return 0; -} - -DataArrayDouble *MEDCouplingExtrudedMesh::getCoordinatesAndOwner() const -{ - DataArrayDouble *arr2D=_mesh2D->getCoords(); - DataArrayDouble *arr1D=_mesh1D->getCoords(); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(getNumberOfNodes(),3); - int nbOf1DLev=_mesh1D->getNumberOfNodes(); - int nbOf2DNodes=_mesh2D->getNumberOfNodes(); - const double *ptSrc=arr2D->getConstPointer(); - double *pt=ret->getPointer(); - std::copy(ptSrc,ptSrc+3*nbOf2DNodes,pt); - for(int i=1;igetConstPointer()+3*i,arr1D->getConstPointer()+3*(i+1),vec); - std::transform(arr1D->getConstPointer()+3*(i-1),arr1D->getConstPointer()+3*i,vec,vec,std::minus()); - for(int j=0;j()); - } - return ret; -} - -DataArrayDouble *MEDCouplingExtrudedMesh::getBarycenterAndOwner() const -{ - //not yet implemented - return 0; -} - -void MEDCouplingExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception) -{ - _mesh3D_ids->alloc(mesh3D->getNumberOfCells(),1); - int nbOf1DLev=mesh3D->getNumberOfCells()/_mesh2D->getNumberOfCells(); - _mesh1D->setMeshDimension(1); - _mesh1D->allocateCells(nbOf1DLev); - int tmpConn[2]; - for(int i=0;iinsertNextCell(INTERP_KERNEL::NORM_SEG2,2,tmpConn); - } - _mesh1D->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(nbOf1DLev+1,3); - _mesh1D->setCoords(myCoords); - myCoords->decrRef(); - DataArrayInt *desc,*descIndx,*revDesc,*revDescIndx; - desc=DataArrayInt::New(); descIndx=DataArrayInt::New(); revDesc=DataArrayInt::New(); revDescIndx=DataArrayInt::New(); - MEDCouplingUMesh *subMesh=mesh3D->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - DataArrayInt *revNodal2D,*revNodalIndx2D; - revNodal2D=DataArrayInt::New(); revNodalIndx2D=DataArrayInt::New(); - subMesh->getReverseNodalConnectivity(revNodal2D,revNodalIndx2D); - const int *nodal2D=_mesh2D->getNodalConnectivity()->getConstPointer(); - const int *nodal2DIndx=_mesh2D->getNodalConnectivityIndex()->getConstPointer(); - const int *revNodal2DPtr=revNodal2D->getConstPointer(); - const int *revNodalIndx2DPtr=revNodalIndx2D->getConstPointer(); - const int *descP=desc->getConstPointer(); - const int *descIndxP=descIndx->getConstPointer(); - const int *revDescP=revDesc->getConstPointer(); - const int *revDescIndxP=revDescIndx->getConstPointer(); - // - int nbOf2DCells=_mesh2D->getNumberOfCells(); - for(int i=0;i nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]); - try - { - idInSubMesh=findCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr); - } - catch(INTERP_KERNEL::Exception& e) - { - std::ostringstream ostr; ostr << "mesh2D cell # " << i << " is not part of any cell of 3D mesh !\n"; - ostr << e.what(); - throw INTERP_KERNEL::Exception(ostr.str().c_str()); - } - build1DExtrusion(idInSubMesh,i,nbOf1DLev,subMesh,descP,descIndxP,revDescP,revDescIndxP,i==_cell_2D_id); - } - // - revNodal2D->decrRef(); - revNodalIndx2D->decrRef(); - subMesh->decrRef(); - desc->decrRef(); - descIndx->decrRef(); - revDesc->decrRef(); - revDescIndx->decrRef(); -} - -void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const -{ - std::vector tinyInfo1; - std::vector ls1; - _mesh2D->getTinySerializationInformation(tinyInfo1,ls1); - std::vector tinyInfo2; - std::vector ls2; - _mesh1D->getTinySerializationInformation(tinyInfo2,ls2); - tinyInfo.clear(); littleStrings.clear(); - tinyInfo.insert(tinyInfo.end(),tinyInfo1.begin(),tinyInfo1.end()); - littleStrings.insert(littleStrings.end(),ls1.begin(),ls1.end()); - tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end()); - littleStrings.insert(littleStrings.end(),ls2.begin(),ls2.end()); - tinyInfo.push_back(_cell_2D_id); - tinyInfo.push_back(tinyInfo1.size()); - tinyInfo.push_back(_mesh3D_ids->getNbOfElems()); - littleStrings.push_back(getName()); -} - -void MEDCouplingExtrudedMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const -{ - int sz=tinyInfo.size(); - int sz1=tinyInfo[sz-2]; - std::vector ti1(tinyInfo.begin(),tinyInfo.begin()+sz1); - std::vector ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3); - MEDCouplingUMesh *um=MEDCouplingUMesh::New(); - DataArrayInt *a1tmp=DataArrayInt::New(); - DataArrayDouble *a2tmp=DataArrayDouble::New(); - int la1=0,la2=0; - std::vector ls1,ls2; - um->resizeForUnserialization(ti1,a1tmp,a2tmp,ls1); - la1+=a1tmp->getNbOfElems(); la2+=a2tmp->getNbOfElems(); - a1tmp->decrRef(); a2tmp->decrRef(); - a1tmp=DataArrayInt::New(); a2tmp=DataArrayDouble::New(); - um->resizeForUnserialization(ti2,a1tmp,a2tmp,ls2); - la1+=a1tmp->getNbOfElems(); la2+=a2tmp->getNbOfElems(); - a1tmp->decrRef(); a2tmp->decrRef(); - um->decrRef(); - // - a1->alloc(la1+tinyInfo[sz-1],1); - a2->alloc(la2,1); - littleStrings.resize(ls1.size()+ls2.size()+1); -} - -void MEDCouplingExtrudedMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const -{ - a1=DataArrayInt::New(); a2=DataArrayDouble::New(); - DataArrayInt *a1_1=0,*a1_2=0; - DataArrayDouble *a2_1=0,*a2_2=0; - _mesh2D->serialize(a1_1,a2_1); - _mesh1D->serialize(a1_2,a2_2); - a1->alloc(a1_1->getNbOfElems()+a1_2->getNbOfElems()+_mesh3D_ids->getNbOfElems(),1); - int *ptri=a1->getPointer(); - ptri=std::copy(a1_1->getConstPointer(),a1_1->getConstPointer()+a1_1->getNbOfElems(),ptri); - a1_1->decrRef(); - ptri=std::copy(a1_2->getConstPointer(),a1_2->getConstPointer()+a1_2->getNbOfElems(),ptri); - a1_2->decrRef(); - std::copy(_mesh3D_ids->getConstPointer(),_mesh3D_ids->getConstPointer()+_mesh3D_ids->getNbOfElems(),ptri); - a2->alloc(a2_1->getNbOfElems()+a2_2->getNbOfElems(),1); - double *ptrd=a2->getPointer(); - ptrd=std::copy(a2_1->getConstPointer(),a2_1->getConstPointer()+a2_1->getNbOfElems(),ptrd); - a2_1->decrRef(); - std::copy(a2_2->getConstPointer(),a2_2->getConstPointer()+a2_2->getNbOfElems(),ptrd); - a2_2->decrRef(); -} - -void MEDCouplingExtrudedMesh::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) -{ - setName(littleStrings.back().c_str()); - int sz=tinyInfo.size(); - int sz1=tinyInfo[sz-2]; - _cell_2D_id=tinyInfo[sz-3]; - std::vector ti1(tinyInfo.begin(),tinyInfo.begin()+sz1); - std::vector ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3); - DataArrayInt *a1tmp=DataArrayInt::New(); - DataArrayDouble *a2tmp=DataArrayDouble::New(); - const int *a1Ptr=a1->getConstPointer(); - const double *a2Ptr=a2->getConstPointer(); - _mesh2D=MEDCouplingUMesh::New(); - std::vector ls1,ls2; - _mesh2D->resizeForUnserialization(ti1,a1tmp,a2tmp,ls1); - std::copy(a2Ptr,a2Ptr+a2tmp->getNbOfElems(),a2tmp->getPointer()); - std::copy(a1Ptr,a1Ptr+a1tmp->getNbOfElems(),a1tmp->getPointer()); - a2Ptr+=a2tmp->getNbOfElems(); - a1Ptr+=a1tmp->getNbOfElems(); - ls2.insert(ls2.end(),littleStrings.begin(),littleStrings.begin()+ls1.size()); - _mesh2D->unserialization(ti1,a1tmp,a2tmp,ls2); - a1tmp->decrRef(); a2tmp->decrRef(); - // - ls2.clear(); - ls2.insert(ls2.end(),littleStrings.begin()+ls1.size(),littleStrings.end()-1); - _mesh1D=MEDCouplingUMesh::New(); - a1tmp=DataArrayInt::New(); a2tmp=DataArrayDouble::New(); - _mesh1D->resizeForUnserialization(ti2,a1tmp,a2tmp,ls1); - std::copy(a2Ptr,a2Ptr+a2tmp->getNbOfElems(),a2tmp->getPointer()); - std::copy(a1Ptr,a1Ptr+a1tmp->getNbOfElems(),a1tmp->getPointer()); - a1Ptr+=a1tmp->getNbOfElems(); - _mesh1D->unserialization(ti2,a1tmp,a2tmp,ls2); - a1tmp->decrRef(); a2tmp->decrRef(); - // - _mesh3D_ids=DataArrayInt::New(); - int szIds=std::distance(a1Ptr,a1->getConstPointer()+a1->getNbOfElems()); - _mesh3D_ids->alloc(szIds,1); - std::copy(a1Ptr,a1Ptr+szIds,_mesh3D_ids->getPointer()); -} diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx deleted file mode 100644 index 39a0dbf47..000000000 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingMesh.hxx" - -#include - -namespace ParaMEDMEM -{ - class DataArrayInt; - class DataArrayDouble; - class MEDCouplingUMesh; - class MEDCouplingFieldDouble; - - class MEDCOUPLING_EXPORT MEDCouplingExtrudedMesh : public MEDCouplingMesh - { - public: - static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); - static MEDCouplingExtrudedMesh *New(); - MEDCouplingMeshType getType() const; - void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); - int getNumberOfCells() const; - int getNumberOfNodes() const; - int getSpaceDimension() const; - int getMeshDimension() const; - MEDCouplingMesh *deepCpy() const; - MEDCouplingExtrudedMesh *clone(bool recDeepCpy) const; - bool isEqual(const MEDCouplingMesh *other, double prec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception); - void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception); - INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; - int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - void getNodeIdsOfCell(int cellId, std::vector& conn) const; - void getCoordinatesOfNode(int nodeId, std::vector& coo) const; - std::string simpleRepr() const; - std::string advancedRepr() const; - void checkCoherency() const throw (INTERP_KERNEL::Exception); - void getBoundingBox(double *bbox) const; - void updateTime(); - void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - MEDCouplingUMesh *getMesh2D() const { return _mesh2D; } - MEDCouplingUMesh *getMesh1D() const { return _mesh1D; } - DataArrayInt *getMesh3DIds() const { return _mesh3D_ids; } - MEDCouplingUMesh *build3DUnstructuredMesh() const; - MEDCouplingFieldDouble *getMeasureField(bool) const; - MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const; - MEDCouplingFieldDouble *buildOrthogonalField() const; - int getCellContainingPoint(const double *pos, double eps) const; - static int findCorrespCellByNodalConn(const std::vector& nodalConnec, - const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception); - static void project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, - MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception); - void rotate(const double *center, const double *vector, double angle); - void translate(const double *vector); - void scale(const double *point, double factor); - MEDCouplingMesh *buildPart(const int *start, const int *end) const; - MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; - MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - DataArrayDouble *getCoordinatesAndOwner() const; - DataArrayDouble *getBarycenterAndOwner() const; - //Serialization unserialisation - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - private: - MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); - MEDCouplingExtrudedMesh(const MEDCouplingExtrudedMesh& other, bool deepCpy); - MEDCouplingExtrudedMesh(); - void computeExtrusion(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception); - void computeExtrusionAlg(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception); - void build1DExtrusion(int idIn3DDesc, int newId, int nbOf1DLev, MEDCouplingUMesh *subMesh, - const int *desc3D, const int *descIndx3D, - const int *revDesc3D, const int *revDescIndx3D, - bool computeMesh1D) throw(INTERP_KERNEL::Exception); - int findOppositeFaceOf(int current2DCell, int current3DCell, const std::vector& connSorted, - const int *desc3D, const int *descIndx3D, - const int *conn2D, const int *conn2DIndx) throw(INTERP_KERNEL::Exception); - void computeBaryCenterOfFace(const std::vector& nodalConnec, int lev1DId); - ~MEDCouplingExtrudedMesh(); - private: - MEDCouplingUMesh *_mesh2D; - MEDCouplingUMesh *_mesh1D; - //! New to old 3D cell Ids Array - DataArrayInt *_mesh3D_ids; - int _cell_2D_id; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingField.cxx b/src/MEDCoupling/MEDCouplingField.cxx deleted file mode 100644 index 41c3029f3..000000000 --- a/src/MEDCoupling/MEDCouplingField.cxx +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingField.hxx" -#include "MEDCouplingMesh.hxx" -#include "MEDCouplingFieldDiscretization.hxx" - -using namespace ParaMEDMEM; - -bool MEDCouplingField::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const -{ - if(_name!=other->_name) - return false; - if(_desc!=other->_desc) - return false; - if(!_type->isEqual(other->_type,valsPrec)) - return false; - if(_mesh==0 && other->_mesh==0) - return true; - if(_mesh==0 || other->_mesh==0) - return false; - if(_mesh==other->_mesh) - return true; - return _mesh->isEqual(other->_mesh,meshPrec); -} - -bool MEDCouplingField::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const -{ - if(!_type->isEqualWithoutConsideringStr(other->_type,valsPrec)) - return false; - if(_mesh==0 && other->_mesh==0) - return true; - if(_mesh==0 || other->_mesh==0) - return false; - if(_mesh==other->_mesh) - return true; - return _mesh->isEqualWithoutConsideringStr(other->_mesh,meshPrec); -} - -/*! - * This method states if 'this' and 'other' are compatibles each other before performing any treatment. - * This method is good for methods like : mergeFields. - * This method is not very demanding compared to areStrictlyCompatible that is better for operation on fields. - */ -bool MEDCouplingField::areCompatibleForMerge(const MEDCouplingField *other) const -{ - if(!_type->isEqual(other->_type,1.)) - return false; - if(_mesh==other->_mesh) - return true; - return _mesh->areCompatibleForMerge(other->_mesh); -} - -/*! - * This method is more strict than MEDCouplingField::areCompatibleForMerge method. - * This method is used for operation on fields to operate a first check before attempting operation. - */ -bool MEDCouplingField::areStrictlyCompatible(const MEDCouplingField *other) const -{ - if(!_type->isEqual(other->_type,1.e-12)) - return false; - return _mesh==other->_mesh; -} - -void MEDCouplingField::updateTime() -{ - if(_mesh) - updateTimeWith(*_mesh); - if(_type) - updateTimeWith(*_type); -} - -TypeOfField MEDCouplingField::getTypeOfField() const -{ - return _type->getEnum(); -} - -/*! - * This method retrieves the measure field of 'this'. If no '_mesh' is defined an exception will be thrown. - * Warning the retrieved field life cycle is the responsability of caller. - */ -MEDCouplingFieldDouble *MEDCouplingField::buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception) -{ - if(_mesh==0) - throw INTERP_KERNEL::Exception("MEDCouplingField::getMeasureField : no mesh defined !!!"); - return _type->getMeasureField(_mesh,isAbs); -} - -void MEDCouplingField::setMesh(const MEDCouplingMesh *mesh) -{ - if(mesh!=_mesh) - { - if(_mesh) - ((MEDCouplingMesh *)_mesh)->decrRef(); - _mesh=mesh; - if(_mesh) - { - _mesh->incrRef(); - updateTimeWith(*_mesh); - } - } -} - -/*! - * This method sets gauss localization by geometric type. - * @param type geometric type on which the gauss localization will be set. - * @param refCoo is the reference coordinates of the specified element. Its size has to be equal to nbOfNodesPerCell*dimOfType - * @param gsCoo are the coordinates of Gauss points in reference element specified by 'refCoo'. Its size must be equal to wg.size()*dimOfType - * @param wg are the weights on Gauss points. The size of this array is used to determine the number of Gauss point in the element. - * @throw when size of 'RefCoo' is not valid regarding 'type' parameter, it throws too when the mesh is not set before or if it is not a field on Gauss points. - */ -void MEDCouplingField::setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling setGaussLocalizationOnType method !"); - _type->setGaussLocalizationOnType(_mesh,type,refCoo,gsCoo,wg); -} - -/*! - * This method sets on ids defined by [begin;end) their gauss localization. This method checks the coherency of cells ids in [begin;end) and 'refCoo' size. - * If an incoherence appears an exception will be thrown and no seting will be performed. - * An exception is thrown too if [begin,end) has a size lesser than 1. - * - * @param refCoo is the reference coordinates of the specified element. Its size has to be equal to nbOfNodesPerCell*dimOfType - * @param gsCoo are the coordinates of Gauss points in reference element specified by 'refCoo'. Its size must be equal to wg.size()*dimOfType - * @param wg are the weights on Gauss points. The size of this array is used to determine the number of Gauss point in the element. - * @throw when size of 'RefCoo' is not valid regarding cells in [begin,end) parameters, it throws too when the mesh is not set before or if it is not a field on Gauss points. - */ -void MEDCouplingField::setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling setGaussLocalizationOnCells method !"); - _type->setGaussLocalizationOnCells(_mesh,begin,end,refCoo,gsCoo,wg); -} - -/*! - * This method resets all Gauss loalizations if any. - */ -void MEDCouplingField::clearGaussLocalizations() -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling clearGaussLocalizations method !"); - _type->clearGaussLocalizations(); -} - -/*! - * This method returns reference to the Gauss localization object corresponding to 'locId' id. - * This method throws an exception if there is no mesh, invalid FieldDescription (different from Gauss) and if 'locId' is invalid because out of range given by - * MEDCouplingField::getNbOfGaussLocalization method. - * Warning this method is not const, so the returned object could be modified without any problem. - */ -MEDCouplingGaussLocalization& MEDCouplingField::getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalization method !"); - return _type->getGaussLocalization(locId); -} - -/*! - * This method returns reference to the Gauss localization object corresponding to 'locId' id. - * This method throws an exception if there is no mesh, invalid FieldDescription (different from Gauss) and if several localization ids have been found - * for a type. - */ -int MEDCouplingField::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalizationIdOfOneType method !"); - return _type->getGaussLocalizationIdOfOneType(type); -} - -/*! - * This method returns number of Gauss localization available. Implicitely all ids in [0,getNbOfGaussLocalization()) is a valid Gauss localisation id. - * This method throws an exception if there is no mesh, invalid FieldDescription (different from Gauss) - */ -int MEDCouplingField::getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling getNbOfGaussLocalization method !"); - return _type->getNbOfGaussLocalization(); -} - -/*! - * This method returns an id of Gauss localization in [0,getNbOfGaussLocalization()) that corresponds to the localization of the cell specified by its cellId. - * This methods throws an exception if there is no mesh, invalid FieldDescription (different from Gauss) or if at the cell with id 'cellId' in this->_mesh no - * Gauss localization has been set. - */ -int MEDCouplingField::getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalizationIdOfOneCell method !"); - return _type->getGaussLocalizationIdOfOneCell(cellId); -} - -/*! - * This method returns all cellIds that share the same Gauss localization given by 'locId' parameter (in range [0,getNbOfGaussLocalization()) ). - * If no cells fit the Gauss localization given by 'locId' cellIds will be returned empty. - * @param locId input that specifies the id of Gauss localization. - * @param cellIds output parameter, that will contain the result if this method succeds. This parameter is systematically cleared when called. - * @throw if there is no mesh, invalid FieldDescription (different from Gauss) or if locId not in [0,getNbOfGaussLocalization()) - */ -void MEDCouplingField::getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception) -{ - cellIds.clear(); - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalizationIdOfOneCell method !"); - _type->getCellIdsHavingGaussLocalization(locId,cellIds); -} - -/*! - * This method returns reference to the Gauss localization object corresponding to 'locId' id. - * This method throws an exception if there is no mesh, invalid FieldDescription (different from Gauss) and if 'locId' is invalid because out of range given by - * MEDCouplingField::getNbOfGaussLocalization method. - * Warning this method is const. - */ -const MEDCouplingGaussLocalization& MEDCouplingField::getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Mesh has to be set before calling getGaussLocalization method !"); - return _type->getGaussLocalization(locId); -} - -MEDCouplingField::~MEDCouplingField() -{ - if(_mesh) - ((MEDCouplingMesh *)_mesh)->decrRef(); - delete _type; -} - -MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type):_mesh(0),_type(type) -{ -} - -MEDCouplingField::MEDCouplingField(TypeOfField type):_mesh(0),_type(MEDCouplingFieldDiscretization::New(type)) -{ -} - -MEDCouplingField::MEDCouplingField(const MEDCouplingField& other):_name(other._name),_desc(other._desc), - _mesh(0),_type(other._type->clone()) -{ - if(other._mesh) - { - _mesh=other._mesh; - _mesh->incrRef(); - } -} - -/*! - * This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end). - * @param di is an array returned that specifies entity ids (nodes, cells ids...) in mesh 'mesh' of entity in returned submesh. - */ -MEDCouplingMesh *MEDCouplingField::buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const -{ - return _type->buildSubMeshData(_mesh,start,end,di); -} diff --git a/src/MEDCoupling/MEDCouplingField.hxx b/src/MEDCoupling/MEDCouplingField.hxx deleted file mode 100644 index e6eedb5bc..000000000 --- a/src/MEDCoupling/MEDCouplingField.hxx +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class DataArrayInt; - class MEDCouplingMesh; - class MEDCouplingFieldDouble; - class MEDCouplingFieldDiscretization; - class MEDCouplingGaussLocalization; - - class MEDCOUPLING_EXPORT MEDCouplingField : public RefCountObject, public TimeLabel - { - public: - virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0; - virtual bool areCompatibleForMerge(const MEDCouplingField *other) const; - virtual bool areStrictlyCompatible(const MEDCouplingField *other) const; - virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const; - virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const; - void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh); - const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; } - void setName(const char *name) { _name=name; } - const char *getDescription() const { return _desc.c_str(); } - void setDescription(const char *desc) { _desc=desc; } - const char *getName() const { return _name.c_str(); } - TypeOfField getTypeOfField() const; - MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception); - MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const; - MEDCouplingFieldDiscretization *getDiscretization() const { return _type; } - // Gauss point specific methods - void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - void setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - void clearGaussLocalizations(); - MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception); - int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception); - int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception); - int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); - void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); - const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); - protected: - void updateTime(); - protected: - MEDCouplingField(TypeOfField type); - MEDCouplingField(const MEDCouplingField& other); - MEDCouplingField(MEDCouplingFieldDiscretization *type); - virtual ~MEDCouplingField(); - protected: - std::string _name; - std::string _desc; - const MEDCouplingMesh *_mesh; - MEDCouplingFieldDiscretization *_type; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx deleted file mode 100644 index cadfb04f4..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ /dev/null @@ -1,1153 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingFieldDiscretization.hxx" -#include "MEDCouplingCMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "CellModel.hxx" - -#include "InterpolationUtils.hxx" - -#include -#include -#include -#include - -using namespace ParaMEDMEM; - -const double MEDCouplingFieldDiscretization::DFLT_PRECISION=1.e-12; - -const char MEDCouplingFieldDiscretizationP0::REPR[]="P0"; - -const TypeOfField MEDCouplingFieldDiscretizationP0::TYPE=ON_CELLS; - -const char MEDCouplingFieldDiscretizationP1::REPR[]="P1"; - -const TypeOfField MEDCouplingFieldDiscretizationP1::TYPE=ON_NODES; - -const char MEDCouplingFieldDiscretizationGauss::REPR[]="GAUSS"; - -const TypeOfField MEDCouplingFieldDiscretizationGauss::TYPE=ON_GAUSS_PT; - -const char MEDCouplingFieldDiscretizationGaussNE::REPR[]="GSSNE"; - -const TypeOfField MEDCouplingFieldDiscretizationGaussNE::TYPE=ON_GAUSS_NE; - -MEDCouplingFieldDiscretization::MEDCouplingFieldDiscretization():_precision(DFLT_PRECISION) -{ -} - -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::New(TypeOfField type) -{ - switch(type) - { - case MEDCouplingFieldDiscretizationP0::TYPE: - return new MEDCouplingFieldDiscretizationP0; - case MEDCouplingFieldDiscretizationP1::TYPE: - return new MEDCouplingFieldDiscretizationP1; - case MEDCouplingFieldDiscretizationGauss::TYPE: - return new MEDCouplingFieldDiscretizationGauss; - case MEDCouplingFieldDiscretizationGaussNE::TYPE: - return new MEDCouplingFieldDiscretizationGaussNE; - default: - throw INTERP_KERNEL::Exception("Choosen discretization is not implemented yet."); - } -} - -TypeOfField MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception) -{ - std::string reprCpp(repr); - if(reprCpp==MEDCouplingFieldDiscretizationP0::REPR) - return MEDCouplingFieldDiscretizationP0::TYPE; - if(reprCpp==MEDCouplingFieldDiscretizationP1::REPR) - return MEDCouplingFieldDiscretizationP1::TYPE; - if(reprCpp==MEDCouplingFieldDiscretizationGauss::REPR) - return MEDCouplingFieldDiscretizationGauss::TYPE; - if(reprCpp==MEDCouplingFieldDiscretizationGaussNE::REPR) - return MEDCouplingFieldDiscretizationGaussNE::TYPE; - throw INTERP_KERNEL::Exception("Representation does not match with any field discretization !"); -} - -bool MEDCouplingFieldDiscretization::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const -{ - return isEqual(other,eps); -} - -/*! - * Excepted for MEDCouplingFieldDiscretizationPerCell no underlying TimeLabel object : nothing to do in generally. - */ -void MEDCouplingFieldDiscretization::updateTime() -{ -} - -/*! - * Computes normL1 of DataArrayDouble instance arr. - * @param res output parameter expected to be of size arr->getNumberOfComponents(); - * @throw when the field discretization fails on getMeasure fields (gauss points for example) - */ -void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingFieldDouble *vol=getMeasureField(mesh,true); - int nbOfCompo=arr->getNumberOfComponents(); - int nbOfElems=getNumberOfTuples(mesh); - std::fill(res,res+nbOfCompo,0.); - const double *arrPtr=arr->getConstPointer(); - const double *volPtr=vol->getArray()->getConstPointer(); - for(int i=0;idecrRef(); -} - -/*! - * Computes normL2 of DataArrayDouble instance arr. - * @param res output parameter expected to be of size arr->getNumberOfComponents(); - * @throw when the field discretization fails on getMeasure fields (gauss points for example) - */ -void MEDCouplingFieldDiscretization::normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingFieldDouble *vol=getMeasureField(mesh,true); - int nbOfCompo=arr->getNumberOfComponents(); - int nbOfElems=getNumberOfTuples(mesh); - std::fill(res,res+nbOfCompo,0.); - const double *arrPtr=arr->getConstPointer(); - const double *volPtr=vol->getArray()->getConstPointer(); - for(int i=0;i(std::sqrt)); - vol->decrRef(); -} - -/*! - * Computes integral of DataArrayDouble instance arr. - * @param res output parameter expected to be of size arr->getNumberOfComponents(); - * @throw when the field discretization fails on getMeasure fields (gauss points for example) - */ -void MEDCouplingFieldDiscretization::integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingFieldDouble *vol=getMeasureField(mesh,isWAbs); - int nbOfCompo=arr->getNumberOfComponents(); - int nbOfElems=getNumberOfTuples(mesh); - std::fill(res,res+nbOfCompo,0.); - const double *arrPtr=arr->getConstPointer(); - const double *volPtr=vol->getArray()->getConstPointer(); - double *tmp=new double[nbOfCompo]; - for (int i=0;i(),volPtr[i])); - std::transform(tmp,tmp+nbOfCompo,res,res,std::plus()); - } - delete [] tmp; - vol->decrRef(); -} - -void MEDCouplingFieldDiscretization::getSerializationIntArray(DataArrayInt *& arr) const -{ - arr=0; -} - -/*! - * Empty : Not a bug - */ -void MEDCouplingFieldDiscretization::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ -} - -/*! - * Empty : Not a bug - */ -void MEDCouplingFieldDiscretization::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ -} - -void MEDCouplingFieldDiscretization::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *& arr) -{ - arr=0; -} - -/*! - * Empty : Not a bug - */ -void MEDCouplingFieldDiscretization::finishUnserialization(const std::vector& tinyInfo) -{ -} - -/*! - * This method is typically the first step of renumbering. The implementation is empty it is not a bug only gauss is impacted - * virtualy by this method. - */ -void MEDCouplingFieldDiscretization::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ -} - -double MEDCouplingFieldDiscretization::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, - int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("getIJK Invalid ! only for GaussPoint and GaussNE discretizations !"); -} - -void MEDCouplingFieldDiscretization::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -void MEDCouplingFieldDiscretization::setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -void MEDCouplingFieldDiscretization::clearGaussLocalizations() throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -const MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -int MEDCouplingFieldDiscretization::getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -int MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -int MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -void MEDCouplingFieldDiscretization::getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); -} - -MEDCouplingFieldDiscretization::~MEDCouplingFieldDiscretization() -{ -} - -TypeOfField MEDCouplingFieldDiscretizationP0::getEnum() const -{ - return TYPE; -} - -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationP0::clone() const -{ - return new MEDCouplingFieldDiscretizationP0; -} - -const char *MEDCouplingFieldDiscretizationP0::getStringRepr() const -{ - return REPR; -} - -bool MEDCouplingFieldDiscretizationP0::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const -{ - const MEDCouplingFieldDiscretizationP0 *otherC=dynamic_cast(other); - return otherC!=0; -} - -int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const -{ - return mesh->getNumberOfCells(); -} - -void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - const int *array=old2NewBg; - if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); - for(std::vector::const_iterator it=arrays.begin();it!=arrays.end();it++) - { - if(*it) - (*it)->renumberInPlace(array); - } - if(check) - delete [] array; -} - -DataArrayDouble *MEDCouplingFieldDiscretizationP0::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const -{ - return mesh->getBarycenterAndOwner(); -} - -void MEDCouplingFieldDiscretizationP0::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest) -{ - cellRest=DataArrayInt::New(); - cellRest->alloc(std::distance(partBg,partEnd),1); - std::copy(partBg,partEnd,cellRest->getPointer()); -} - -void MEDCouplingFieldDiscretizationP0::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) -{ -} - -void MEDCouplingFieldDiscretizationP0::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) -{ - if(mesh->getNumberOfCells()!=da->getNumberOfTuples()) - { - std::ostringstream message; - message << "Field on cells invalid because there are " << mesh->getNumberOfCells(); - message << " cells in mesh and " << da->getNumberOfTuples() << " tuples in field !"; - throw INTERP_KERNEL::Exception(message.str().c_str()); - } -} - -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP0::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const -{ - return mesh->getMeasureField(isAbs); -} - -void MEDCouplingFieldDiscretizationP0::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const -{ - int id=mesh->getCellContainingPoint(loc,_precision); - if(id==-1) - throw INTERP_KERNEL::Exception("Specified point is detected outside of mesh : unable to apply P0::getValueOn !"); - arr->getTuple(id,res); -} - -void MEDCouplingFieldDiscretizationP0::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const -{ - const MEDCouplingCMesh *meshC=dynamic_cast(mesh); - if(!meshC) - throw INTERP_KERNEL::Exception("P0::getValueOnPos is only accessible for structured meshes !"); - int id=meshC->getCellIdFromPos(i,j,k); - arr->getTuple(id,res); -} - -/*! - * Nothing to do. It's not a bug. - */ -void MEDCouplingFieldDiscretizationP0::renumberValuesOnNodes(const int *, DataArrayDouble *) const -{ -} - -/*! - * This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end). - * @param di is an array returned that specifies entity ids (here cells ids) in mesh 'mesh' of entity in returned submesh. - * Example : The first cell id of returned mesh has the (*di)[0] id in 'mesh' - */ -MEDCouplingMesh *MEDCouplingFieldDiscretizationP0::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const -{ - MEDCouplingMesh *ret=mesh->buildPart(start,end); - di=DataArrayInt::New(); - di->alloc(std::distance(start,end),1); - int *pt=di->getPointer(); - std::copy(start,end,pt); - return ret; -} - -TypeOfField MEDCouplingFieldDiscretizationP1::getEnum() const -{ - return TYPE; -} - -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationP1::clone() const -{ - return new MEDCouplingFieldDiscretizationP1; -} - -const char *MEDCouplingFieldDiscretizationP1::getStringRepr() const -{ - return REPR; -} - -bool MEDCouplingFieldDiscretizationP1::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const -{ - const MEDCouplingFieldDiscretizationP1 *otherC=dynamic_cast(other); - return otherC!=0; -} - -/*! - * Nothing to do here. - */ -void MEDCouplingFieldDiscretizationP1::renumberArraysForCell(const MEDCouplingMesh *, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ -} - -int MEDCouplingFieldDiscretizationP1::getNumberOfTuples(const MEDCouplingMesh *mesh) const -{ - return mesh->getNumberOfNodes(); -} - -DataArrayDouble *MEDCouplingFieldDiscretizationP1::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const -{ - return mesh->getCoordinatesAndOwner(); -} - -void MEDCouplingFieldDiscretizationP1::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest) -{ - cellRest=mesh->getCellIdsFullyIncludedInNodeIds(partBg,partEnd); -} - -void MEDCouplingFieldDiscretizationP1::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) -{ - if(nat!=ConservativeVolumic) - throw INTERP_KERNEL::Exception("Invalid nature for P1 field !"); -} - -void MEDCouplingFieldDiscretizationP1::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) -{ - if(mesh->getNumberOfNodes()!=da->getNumberOfTuples()) - { - std::ostringstream message; - message << "Field on nodes invalid because there are " << mesh->getNumberOfNodes(); - message << " nodes in mesh and " << da->getNumberOfTuples() << " tuples in field !"; - throw INTERP_KERNEL::Exception(message.str().c_str()); - } -} - -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const -{ - return mesh->getMeasureFieldOnNode(isAbs); -} - -void MEDCouplingFieldDiscretizationP1::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const -{ - int id=mesh->getCellContainingPoint(loc,_precision); - if(id==-1) - throw INTERP_KERNEL::Exception("Specified point is detected outside of mesh : unable to apply P1::getValueOn !"); - INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(id); - if(type!=INTERP_KERNEL::NORM_SEG2 && type!=INTERP_KERNEL::NORM_TRI3 && type!=INTERP_KERNEL::NORM_TETRA4) - throw INTERP_KERNEL::Exception("P1 getValueOn is not specified for not simplex cells !"); - std::vector conn; - std::vector coo; - mesh->getNodeIdsOfCell(id,conn); - for(std::vector::const_iterator iter=conn.begin();iter!=conn.end();iter++) - mesh->getCoordinatesOfNode(*iter,coo); - int spaceDim=mesh->getSpaceDimension(); - int nbOfNodes=conn.size(); - std::vector vec(nbOfNodes); - for(int i=0;igetNumberOfComponents(); - double *tmp2=new double[sz]; - std::fill(res,res+sz,0.); - for(int i=0;igetTuple(conn[i],tmp2); - std::transform(tmp2,tmp2+sz,tmp2,std::bind2nd(std::multiplies(),tmp[i])); - std::transform(res,res+sz,tmp2,res,std::plus()); - } - delete [] tmp; - delete [] tmp2; -} - -void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const -{ - const MEDCouplingCMesh *meshC=dynamic_cast(mesh); - if(!meshC) - throw INTERP_KERNEL::Exception("P1::getValueOnPos is only accessible for structured meshes !"); - int id=meshC->getNodeIdFromPos(i,j,k); - arr->getTuple(id,res); -} - -void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(const int *old2NewPtr, DataArrayDouble *arr) const -{ - int oldNbOfElems=arr->getNumberOfTuples(); - int nbOfComp=arr->getNumberOfComponents(); - int newNbOfTuples=(*std::max_element(old2NewPtr,old2NewPtr+oldNbOfElems))+1; - DataArrayDouble *arrCpy=arr->deepCopy(); - const double *ptSrc=arrCpy->getConstPointer(); - arr->reAlloc(newNbOfTuples); - double *ptToFill=arr->getPointer(); - std::fill(ptToFill,ptToFill+nbOfComp*newNbOfTuples,std::numeric_limits::max()); - for(int i=0;i(),std::numeric_limits::max())) - ==ptToFill+(newNb+1)*nbOfComp) - std::copy(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp); - else - { - if(!std::equal(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp)) - { - arrCpy->decrRef(); - std::ostringstream oss; - oss << "Node " << i << " and " << std::find(old2NewPtr,old2NewPtr+i,newNb)-old2NewPtr - << " have been merged and nodal field on them are different !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - } - arrCpy->decrRef(); -} - -/*! - * This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end). -* @param di is an array returned that specifies entity ids (here nodes ids) in mesh 'mesh' of entity in returned submesh. - * Example : The first node id of returned mesh has the (*di)[0] id in 'mesh' - */ -MEDCouplingMesh *MEDCouplingFieldDiscretizationP1::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const -{ - MEDCouplingMesh *ret=mesh->buildPartAndReduceNodes(start,end,di); - return ret; -} - -MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell():_discr_per_cell(0) -{ -} - -MEDCouplingFieldDiscretizationPerCell::~MEDCouplingFieldDiscretizationPerCell() -{ - if(_discr_per_cell) - _discr_per_cell->decrRef(); -} - -MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other):_discr_per_cell(0) -{ - DataArrayInt *arr=other._discr_per_cell; - if(arr) - _discr_per_cell=arr->deepCopy(); -} - -void MEDCouplingFieldDiscretizationPerCell::updateTime() -{ - if(_discr_per_cell) - updateTimeWith(*_discr_per_cell); -} - -void MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) -{ - if(!_discr_per_cell) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has no discretization per cell !"); - int nbOfTuples=_discr_per_cell->getNumberOfTuples(); - if(nbOfTuples!=mesh->getNumberOfCells()) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has a discretization per cell but it's not matching the underlying mesh !"); -} - -bool MEDCouplingFieldDiscretizationPerCell::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const -{ - const MEDCouplingFieldDiscretizationPerCell *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_discr_per_cell==0) - return otherC->_discr_per_cell==0; - if(otherC->_discr_per_cell==0) - return false; - return _discr_per_cell->isEqual(*otherC->_discr_per_cell); -} - -bool MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const -{ - const MEDCouplingFieldDiscretizationPerCell *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_discr_per_cell==0) - return otherC->_discr_per_cell==0; - if(otherC->_discr_per_cell==0) - return false; - return _discr_per_cell->isEqualWithoutConsideringStr(*otherC->_discr_per_cell); -} - -/*! - * This method is typically the first step of renumbering. The impact on _discr_per_cell is necessary here. - * virtualy by this method. - */ -void MEDCouplingFieldDiscretizationPerCell::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - int nbCells=_discr_per_cell->getNumberOfTuples(); - const int *array=old2NewBg; - if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells); - // - DataArrayInt *dpc=_discr_per_cell->renumber(array); - _discr_per_cell->decrRef(); - _discr_per_cell=dpc; - // - if(check) - delete [] (int *)array; -} - -void MEDCouplingFieldDiscretizationPerCell::buildDiscrPerCellIfNecessary(const MEDCouplingMesh *m) -{ - if(!_discr_per_cell) - { - _discr_per_cell=DataArrayInt::New(); - int nbTuples=m->getNumberOfCells(); - _discr_per_cell->alloc(nbTuples,1); - int *ptr=_discr_per_cell->getPointer(); - std::fill(ptr,ptr+nbTuples,-1); - } -} - -MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss() -{ -} - -MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other):MEDCouplingFieldDiscretizationPerCell(other),_loc(other._loc) -{ -} - -TypeOfField MEDCouplingFieldDiscretizationGauss::getEnum() const -{ - return TYPE; -} - -bool MEDCouplingFieldDiscretizationGauss::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const -{ - const MEDCouplingFieldDiscretizationGauss *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!MEDCouplingFieldDiscretizationPerCell::isEqual(other,eps)) - return false; - if(_loc.size()!=otherC->_loc.size()) - return false; - int sz=_loc.size(); - for(int i=0;i_loc[i],eps)) - return false; - return true; -} - -bool MEDCouplingFieldDiscretizationGauss::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const -{ - const MEDCouplingFieldDiscretizationGauss *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(other,eps)) - return false; - if(_loc.size()!=otherC->_loc.size()) - return false; - int sz=_loc.size(); - for(int i=0;i_loc[i],eps)) - return false; - return true; -} - -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationGauss::clone() const -{ - return new MEDCouplingFieldDiscretizationGauss(*this); -} - -const char *MEDCouplingFieldDiscretizationGauss::getStringRepr() const -{ - return REPR; -} - -int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh *) const -{ - int ret=0; - const int *dcPtr=_discr_per_cell->getConstPointer(); - int nbOfTuples=_discr_per_cell->getNumberOfTuples(); - for(const int *w=dcPtr;w!=dcPtr+nbOfTuples;w++) - ret+=_loc[*w].getNumberOfGaussPt(); - return ret; -} - -void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - const int *array=old2NewBg; - if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); - int nbOfCells=_discr_per_cell->getNumberOfTuples(); - int nbOfTuples=getNumberOfTuples(0); - const int *dcPtr=_discr_per_cell->getConstPointer(); - int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. - int *array3=new int[nbOfCells];//store for each cell in present dcp array (already renumbered) the offset needed by each cell in new numbering. - array3[0]=0; - for(int i=1;i::const_iterator it=arrays.begin();it!=arrays.end();it++) - if(*it) - (*it)->renumberInPlace(array2); - delete [] array2; - if(check) - delete [] (int*)array; -} - -DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingFieldDiscretizationGauss::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest) -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -/*! - * Empty : not a bug - */ -void MEDCouplingFieldDiscretizationGauss::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) -{ -} - -void MEDCouplingFieldDiscretizationGauss::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - int val=-1; - if(_discr_per_cell) - val=_discr_per_cell->getNumberOfTuples(); - tinyInfo.push_back(val); - tinyInfo.push_back(_loc.size()); - if(_loc.empty()) - tinyInfo.push_back(-1); - else - tinyInfo.push_back(_loc[0].getDimension()); - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++) - (*iter).pushTinySerializationIntInfo(tinyInfo); -} - -void MEDCouplingFieldDiscretizationGauss::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++) - (*iter).pushTinySerializationDblInfo(tinyInfo); -} - -void MEDCouplingFieldDiscretizationGauss::getSerializationIntArray(DataArrayInt *& arr) const -{ - arr=0; - if(_discr_per_cell) - arr=_discr_per_cell; -} - -void MEDCouplingFieldDiscretizationGauss::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *& arr) -{ - int val=tinyInfo[0]; - if(val>=0) - { - _discr_per_cell=DataArrayInt::New(); - _discr_per_cell->alloc(val,1); - } - else - _discr_per_cell=0; - arr=_discr_per_cell; - int nbOfLoc=tinyInfo[1]; - _loc.clear(); - int dim=tinyInfo[2]; - int delta=-1; - if(nbOfLoc>0) - delta=(tinyInfo.size()-3)/nbOfLoc; - for(int i=0;i tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta); - MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo(dim,tmp); - _loc.push_back(elt); - } -} - -void MEDCouplingFieldDiscretizationGauss::finishUnserialization(const std::vector& tinyInfo) -{ - double *tmp=new double[tinyInfo.size()]; - std::copy(tinyInfo.begin(),tinyInfo.end(),tmp); - const double *work=tmp; - for(std::vector::iterator iter=_loc.begin();iter!=_loc.end();iter++) - work=(*iter).fillWithValues(work); - delete [] tmp; -} - -double MEDCouplingFieldDiscretizationGauss::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, - int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception) -{ - int offset=getOffsetOfCell(cellId); - return da->getIJ(offset+nodeIdInCell,compoId); -} - -void MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(mesh,da); - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++) - (*iter).checkCoherency(); - int nbOfDesc=_loc.size(); - int nbOfCells=mesh->getNumberOfCells(); - const int *dc=_discr_per_cell->getConstPointer(); - for(int i=0;i=nbOfDesc) - { - std::ostringstream oss; oss << "Cell # " << i << " of mesh \"" << mesh->getName() << "\" has an undefined gauss location ! Should never happend !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - if(dc[i]<0) - { - std::ostringstream oss; oss << "Cell # " << i << " of mesh \"" << mesh->getName() << "\" has no gauss location !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - if(mesh->getTypeOfCell(i)!=_loc[dc[i]].getType()) - { - std::ostringstream oss; oss << "Types of mesh and gauss location mismatch for cell # " << i; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - int nbOfTuples=getNumberOfTuples(mesh); - if(nbOfTuples!=da->getNumberOfTuples()) - { - std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } -} - -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingFieldDiscretizationGauss::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingFieldDiscretizationGauss::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const -{ - throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !"); -} - -MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -/*! - * No implementation needed ! - */ -void MEDCouplingFieldDiscretizationGauss::renumberValuesOnNodes(const int *, DataArrayDouble *) const -{ -} - -void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) -{ - buildDiscrPerCellIfNecessary(m); - int id=_loc.size(); - MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg); - _loc.push_back(elt); - int *ptr=_discr_per_cell->getPointer(); - int nbCells=m->getNumberOfCells(); - for(int i=0;igetTypeOfCell(i)==type) - ptr[i]=id; - zipGaussLocalizations(); -} - -void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) -{ - buildDiscrPerCellIfNecessary(m); - if(std::distance(begin,end)<1) - throw INTERP_KERNEL::Exception("Size of [begin,end) must be equal or greater than 1 !"); - INTERP_KERNEL::NormalizedCellType type=m->getTypeOfCell(*begin); - MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg); - int id=_loc.size(); - int *ptr=_discr_per_cell->getPointer(); - for(const int *w=begin+1;w!=end;w++) - { - if(m->getTypeOfCell(*w)!=type) - { - std::ostringstream oss; oss << "The cell with id " << *w << " has been detected to be incompatible in the [begin,end) array specified !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - // - for(const int *w2=begin;w2!=end;w2++) - ptr[*w2]=id; - // - _loc.push_back(elt); - zipGaussLocalizations(); -} - -void MEDCouplingFieldDiscretizationGauss::clearGaussLocalizations() throw(INTERP_KERNEL::Exception) -{ - if(_discr_per_cell) - { - _discr_per_cell->decrRef(); - _discr_per_cell=0; - } - _loc.clear(); -} - -MEDCouplingGaussLocalization& MEDCouplingFieldDiscretizationGauss::getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception) -{ - checkLocalizationId(locId); - return _loc[locId]; -} - -int MEDCouplingFieldDiscretizationGauss::getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception) -{ - return _loc.size(); -} - -int MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception) -{ - if(!_discr_per_cell) - throw INTERP_KERNEL::Exception("No Gauss localization still set !"); - int locId=_discr_per_cell->getConstPointer()[cellId]; - if(locId<0) - throw INTERP_KERNEL::Exception("No Gauss localization set for the specified cell !"); - return locId; -} - -int MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) -{ - if(!_discr_per_cell) - throw INTERP_KERNEL::Exception("No Gauss localization still set !"); - std::set ret; - int id=0; - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++,id++) - if((*iter).getType()==type) - ret.insert(id); - if(ret.empty()) - throw INTERP_KERNEL::Exception("No gauss discretization found for the specified type !"); - if(ret.size()>1) - throw INTERP_KERNEL::Exception("Several gauss discretizations have been found for the specified type !"); - return *ret.begin(); -} - -void MEDCouplingFieldDiscretizationGauss::getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception) -{ - if(locId<0 || locId>=(int)_loc.size()) - throw INTERP_KERNEL::Exception("Invalid locId given : must be in range [0:getNbOfGaussLocalization()) !"); - int nbOfTuples=_discr_per_cell->getNumberOfTuples(); - const int *ptr=_discr_per_cell->getConstPointer(); - for(int i=0;i=(int)_loc.size()) - throw INTERP_KERNEL::Exception("Invalid locId given : must be in range [0:getNbOfGaussLocalization()) !"); -} - -int MEDCouplingFieldDiscretizationGauss::getOffsetOfCell(int cellId) const throw(INTERP_KERNEL::Exception) -{ - int ret=0; - const int *start=_discr_per_cell->getConstPointer(); - for(const int *w=start;w!=start+cellId;w++) - ret+=_loc[*w].getNumberOfGaussPt(); - return ret; -} - -/*! - * This method makes the assumption that _discr_per_cell is set. - * This method reduces as much as possible number size of _loc. - * This method is usefull when several set on same cells has been done and that some Gauss Localization are no more used. - */ -void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations() -{ - const int *start=_discr_per_cell->getConstPointer(); - int nbOfTuples=_discr_per_cell->getNumberOfTuples(); - int *tmp=new int[_loc.size()]; - std::fill(tmp,tmp+_loc.size(),-2); - for(const int *w=start;w!=start+nbOfTuples;w++) - if(*w>=0) - tmp[*w]=1; - int fid=0; - for(int i=0;i<(int)_loc.size();i++) - if(tmp[i]!=-2) - tmp[i]=fid++; - if(fid==(int)_loc.size()) - {//no zip needed - delete [] tmp; - return; - } - // zip needed - int *start2=_discr_per_cell->getPointer(); - for(int *w2=start2;w2!=start2+nbOfTuples;w2++) - *w2=tmp[*w2]; - std::vector tmpLoc; - for(int i=0;i<(int)_loc.size();i++) - if(tmp[i]!=-2) - tmpLoc.push_back(_loc[tmp[i]]); - delete [] tmp; - _loc=tmpLoc; -} - -MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE() -{ -} - -TypeOfField MEDCouplingFieldDiscretizationGaussNE::getEnum() const -{ - return TYPE; -} - -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationGaussNE::clone() const -{ - return new MEDCouplingFieldDiscretizationGaussNE(*this); -} - -const char *MEDCouplingFieldDiscretizationGaussNE::getStringRepr() const -{ - return REPR; -} - -bool MEDCouplingFieldDiscretizationGaussNE::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const -{ - const MEDCouplingFieldDiscretizationGaussNE *otherC=dynamic_cast(other); - return otherC!=0; -} - -int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMesh *mesh) const -{ - int ret=0; - int nbOfCells=mesh->getNumberOfCells(); - for(int i=0;igetTypeOfCell(i); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); - if(cm.isDynamic()) - throw INTERP_KERNEL::Exception("Not implemented yet Gauss node on elements for polygons and polyedrons !"); - ret+=cm.getNumberOfNodes(); - } - return ret; -} - -void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - const int *array=old2NewBg; - if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); - int nbOfCells=mesh->getNumberOfCells(); - int nbOfTuples=getNumberOfTuples(mesh); - int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. - int *array3=new int[nbOfCells];//store for each cell in after renumbering the offset needed by each cell in new numbering. - array3[0]=0; - for(int i=1;igetTypeOfCell(std::distance(array,std::find(array,array+nbOfCells,i-1))); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); - array3[i]=array3[i-1]+cm.getNumberOfNodes(); - } - int j=0; - for(int i=0;igetTypeOfCell(i); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); - for(int k=0;k<(int)cm.getNumberOfNodes();k++,j++) - array2[j]=array3[array[i]]+k; - } - delete [] array3; - for(std::vector::const_iterator it=arrays.begin();it!=arrays.end();it++) - if(*it) - (*it)->renumberInPlace(array2); - delete [] array2; - if(check) - delete [] (int*)array; -} - -DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingFieldDiscretizationGaussNE::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest) -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingFieldDiscretizationGaussNE::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) -{ -} - -double MEDCouplingFieldDiscretizationGaussNE::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, - int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception) -{ - int offset=0; - for(int i=0;igetTypeOfCell(i); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); - offset+=cm.getNumberOfNodes(); - } - return da->getIJ(offset+nodeIdInCell,compoId); -} - -void MEDCouplingFieldDiscretizationGaussNE::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) -{ - int nbOfTuples=getNumberOfTuples(mesh); - if(nbOfTuples!=da->getNumberOfTuples()) - { - std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } -} - -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGaussNE::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingFieldDiscretizationGaussNE::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -void MEDCouplingFieldDiscretizationGaussNE::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const -{ - throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !"); -} - -MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -/*! - * No implementation needed ! - */ -void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnNodes(const int *, DataArrayDouble *) const -{ -} - -MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other):MEDCouplingFieldDiscretization(other) -{ -} - diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx deleted file mode 100644 index 0e502cc35..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "InterpKernelException.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingNatureOfField.hxx" -#include "MEDCouplingGaussLocalization.hxx" - -#include - -namespace ParaMEDMEM -{ - class DataArrayInt; - class MEDCouplingMesh; - class DataArrayDouble; - class MEDCouplingFieldDouble; - - class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization : public TimeLabel - { - public: - static MEDCouplingFieldDiscretization *New(TypeOfField type); - double getPrecision() const { return _precision; } - void setPrecision(double val) { _precision=val; } - void updateTime(); - static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception); - virtual TypeOfField getEnum() const = 0; - virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const = 0; - virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const; - virtual MEDCouplingFieldDiscretization *clone() const = 0; - virtual const char *getStringRepr() const = 0; - virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0; - virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception); - virtual void normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception); - virtual void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception); - virtual DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const = 0; - virtual void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest) = 0; - virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0; - virtual void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0; - virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception); - virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0; - virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0; - virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0; - virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0; - virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0; - virtual void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const = 0; - virtual void getSerializationIntArray(DataArrayInt *& arr) const; - virtual void getTinySerializationIntInformation(std::vector& tinyInfo) const; - virtual void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - virtual void finishUnserialization(const std::vector& tinyInfo); - virtual void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *& arr); - virtual void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - virtual void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - virtual void clearGaussLocalizations() throw(INTERP_KERNEL::Exception); - virtual MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception); - virtual int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception); - virtual int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); - virtual int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception); - virtual void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); - virtual const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); - virtual ~MEDCouplingFieldDiscretization(); - protected: - MEDCouplingFieldDiscretization(); - protected: - double _precision; - static const double DFLT_PRECISION; - }; - - class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization - { - public: - TypeOfField getEnum() const; - MEDCouplingFieldDiscretization *clone() const; - const char *getStringRepr() const; - bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; - int getNumberOfTuples(const MEDCouplingMesh *mesh) const; - void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; - void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception); - void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest); - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; - void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; - void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; - public: - static const char REPR[]; - static const TypeOfField TYPE; - }; - - class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretization - { - public: - TypeOfField getEnum() const; - MEDCouplingFieldDiscretization *clone() const; - const char *getStringRepr() const; - bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; - int getNumberOfTuples(const MEDCouplingMesh *mesh) const; - void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; - void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest); - void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception); - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; - void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; - void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; - MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - public: - static const char REPR[]; - static const TypeOfField TYPE; - }; - - /*! - * This class abstracts MEDCouplingFieldDiscretization that needs an information on each cell to perform their job. - * All classes that inherits from this are more linked to mesh. - */ - class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization - { - protected: - MEDCouplingFieldDiscretizationPerCell(); - MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other); - ~MEDCouplingFieldDiscretizationPerCell(); - void updateTime(); - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); - bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; - bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const; - void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - protected: - void buildDiscrPerCellIfNecessary(const MEDCouplingMesh *m); - protected: - DataArrayInt *_discr_per_cell; - }; - - class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss : public MEDCouplingFieldDiscretizationPerCell - { - public: - MEDCouplingFieldDiscretizationGauss(); - TypeOfField getEnum() const; - bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; - bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const; - MEDCouplingFieldDiscretization *clone() const; - const char *getStringRepr() const; - int getNumberOfTuples(const MEDCouplingMesh *mesh) const; - void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; - void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest); - void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception); - void getTinySerializationIntInformation(std::vector& tinyInfo) const; - void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - void finishUnserialization(const std::vector& tinyInfo); - void getSerializationIntArray(DataArrayInt *& arr) const; - void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *& arr); - double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception); - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; - void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; - void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; - MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - void clearGaussLocalizations() throw(INTERP_KERNEL::Exception); - MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception); - int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception); - int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); - int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception); - void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); - const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); - protected: - MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other); - void zipGaussLocalizations(); - int getOffsetOfCell(int cellId) const throw(INTERP_KERNEL::Exception); - void checkLocalizationId(int locId) const throw(INTERP_KERNEL::Exception); - public: - static const char REPR[]; - static const TypeOfField TYPE; - private: - std::vector _loc; - }; - - /*! - * Gauss with points of values located on nodes of element. This is a specialization of MEDCouplingFieldDiscretizationGauss. - */ - class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE : public MEDCouplingFieldDiscretization - { - public: - MEDCouplingFieldDiscretizationGaussNE(); - TypeOfField getEnum() const; - MEDCouplingFieldDiscretization *clone() const; - const char *getStringRepr() const; - bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; - int getNumberOfTuples(const MEDCouplingMesh *mesh) const; - void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; - void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, - DataArrayInt *&cellRest); - void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception); - double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception); - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; - void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; - void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; - MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - protected: - MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other); - public: - static const char REPR[]; - static const TypeOfField TYPE; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx deleted file mode 100644 index 5ba6492a2..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ /dev/null @@ -1,1131 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingPointSet.hxx" -#include "MEDCouplingTimeDiscretization.hxx" -#include "MEDCouplingFieldDiscretization.hxx" -#include "MEDCouplingAutoRefCountObjectPtr.hxx" -#include "MEDCouplingNatureOfField.hxx" - -#include -#include -#include - -using namespace ParaMEDMEM; - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(TypeOfField type, TypeOfTimeDiscretization td) -{ - return new MEDCouplingFieldDouble(type,td); -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::clone(bool recDeepCpy) const -{ - return new MEDCouplingFieldDouble(*this,recDeepCpy); -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::cloneWithMesh(bool recDeepCpy) const -{ - MEDCouplingFieldDouble *ret=clone(recDeepCpy); - if(_mesh) - { - MEDCouplingMesh *mCpy=_mesh->deepCpy(); - ret->setMesh(mCpy); - mCpy->decrRef(); - } - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const -{ - MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(_time_discr,td,deepCpy); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),tdo,_type->clone()); - ret->setMesh(getMesh()); - ret->setName(getName()); - ret->setDescription(getDescription()); - return ret; -} - -/*! - * Copy tiny info (component names, name, description) but warning the underlying mesh is not renamed (for safety reason). - */ -void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception) -{ - if(other) - { - setName(other->_name.c_str()); - setDescription(other->_desc.c_str()); - _time_discr->copyTinyStringsFrom(*other->_time_discr); - } -} - -std::string MEDCouplingFieldDouble::simpleRepr() const -{ - std::ostringstream ret; - ret << "FieldDouble with name : \"" << getName() << "\"\n"; - ret << "Description of field is : \"" << getDescription() << "\"\n"; - ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n"; - ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n"; - ret << "FieldDouble nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n"; - if(getArray()) - ret << "FieldDouble default array has " << getArray()->getNumberOfComponents() << " components and " << getArray()->getNumberOfTuples() << " tuples.\n"; - if(_mesh) - ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr(); - else - ret << "Mesh support information : No mesh set !\n"; - return ret.str(); -} - -std::string MEDCouplingFieldDouble::advancedRepr() const -{ - std::ostringstream ret; - ret << "FieldDouble with name : \"" << getName() << "\"\n"; - ret << "Description of field is : \"" << getDescription() << "\"\n"; - ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n"; - ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n"; - if(getArray()) - ret << "FieldDouble default array has " << getArray()->getNumberOfComponents() << " components and " << getArray()->getNumberOfTuples() << " tuples.\n"; - if(_mesh) - ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr(); - else - ret << "Mesh support information : No mesh set !\n"; - std::vector arrays; - _time_discr->getArrays(arrays); - int arrayId=0; - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++,arrayId++) - { - ret << "Array #" << arrayId << " :\n__________\n"; - if(*iter) - (*iter)->reprWithoutNameStream(ret); - else - ret << "Array empty !"; - ret << "\n"; - } - return ret.str(); -} - -bool MEDCouplingFieldDouble::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const -{ - const MEDCouplingFieldDouble *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_nature!=otherC->_nature) - return false; - if(!MEDCouplingField::isEqual(other,meshPrec,valsPrec)) - return false; - if(!_time_discr->isEqual(otherC->_time_discr,valsPrec)) - return false; - return true; -} - -bool MEDCouplingFieldDouble::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const -{ - const MEDCouplingFieldDouble *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_nature!=otherC->_nature) - return false; - if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec)) - return false; - if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr,valsPrec)) - return false; - return true; -} - -/*! - * This method states if 'this' and 'other' are compatibles each other before performing any treatment. - * This method is good for methods like : mergeFields. - * This method is not very demanding compared to areStrictlyCompatible that is better for operation on fields. - */ -bool MEDCouplingFieldDouble::areCompatibleForMerge(const MEDCouplingField *other) const -{ - if(!MEDCouplingField::areCompatibleForMerge(other)) - return false; - const MEDCouplingFieldDouble *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_nature!=otherC->_nature) - return false; - if(!_time_discr->areCompatible(otherC->_time_discr)) - return false; - return true; -} - -/*! - * This method is more strict than MEDCouplingField::areCompatibleForMerge method. - * This method is used for operation on fields to operate a first check before attempting operation. - */ -bool MEDCouplingFieldDouble::areStrictlyCompatible(const MEDCouplingField *other) const -{ - if(!MEDCouplingField::areStrictlyCompatible(other)) - return false; - const MEDCouplingFieldDouble *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_nature!=otherC->_nature) - return false; - if(!_time_discr->areStrictlyCompatible(otherC->_time_discr)) - return false; - return true; -} - -/*! - * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatible method except that - * number of components between 'this' and 'other' can be different here (for operator*). - */ -bool MEDCouplingFieldDouble::areCompatibleForMul(const MEDCouplingField *other) const -{ - if(!MEDCouplingField::areStrictlyCompatible(other)) - return false; - const MEDCouplingFieldDouble *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_nature!=otherC->_nature) - return false; - if(!_time_discr->areStrictlyCompatibleForMul(otherC->_time_discr)) - return false; - return true; -} - -/*! - * This method performs a clone of mesh and a renumbering of underlying cells of it. The number of cells remains the same. - * The values of field are impacted in consequence to have the same geometrical field. - */ -void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - renumberCellsWithoutMesh(old2NewBg,check); - MEDCouplingAutoRefCountObjectPtr m=_mesh->deepCpy(); - m->renumberCells(old2NewBg,check); - setMesh(m); - updateTime(); -} - -/*! - * \b WARNING : use this method with lot of care ! - * This method performs half job of MEDCouplingFieldDouble::renumberCells. That is to say no permutation of cells is done on underlying mesh. - * That is to say, the field content is changed by this method. The reason of this method is only for multi-field instances lying on the same mesh to - * avoid a systematic duplication and renumbering of _mesh attribute. - */ -void MEDCouplingFieldDouble::renumberCellsWithoutMesh(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Expecting a defined mesh to be able to operate a renumbering !"); - // - _type->renumberCells(old2NewBg,check); - std::vector arrays; - _time_discr->getArrays(arrays); - _type->renumberArraysForCell(_mesh,arrays,old2NewBg,check); - // - updateTime(); -} - -/*! - * This method performs a clone of mesh and a renumbering of underlying nodes of it. The number of nodes remains not compulsory the same as renumberCells method. - * The values of field are impacted in consequence to have the same geometrical field. - */ -void MEDCouplingFieldDouble::renumberNodes(const int *old2NewBg) throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); - if(!meshC) - throw INTERP_KERNEL::Exception("Invalid mesh to apply renumberNodes on it !"); - int nbOfNodes=meshC->getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr meshC2((MEDCouplingPointSet *)meshC->deepCpy()); - renumberNodesWithoutMesh(old2NewBg); - meshC2->renumberNodes(old2NewBg,*std::max_element(old2NewBg,old2NewBg+nbOfNodes)+1); - setMesh(meshC2); -} - -/*! - * \b WARNING : use this method with lot of care ! - * This method performs half job of MEDCouplingFieldDouble::renumberNodes. That is to say no permutation of cells is done on underlying mesh. - * That is to say, the field content is changed by this method. - */ -void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg) throw(INTERP_KERNEL::Exception) -{ - std::vector arrays; - _time_discr->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - _type->renumberValuesOnNodes(old2NewBg,*iter); -} - -/*! - * This method makes the assumption that the default array is set. If not an exception will be thrown. - * This method is usable only if the default array has exactly one component. If not an exception will be thrown too. - * This method returns all tuples ids that fit the range [vmin,vmax]. - * The caller has the responsability of the returned DataArrayInt. - */ -DataArrayInt *MEDCouplingFieldDouble::getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception) -{ - if(getArray()==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getIdsInRange : no default array set !"); - return getArray()->getIdsInRange(vmin,vmax); -} - -/*! - * Builds a newly created field, that the caller will have the responsability. - * This method makes the assumption that the field is correctly defined when this method is called, no check of this will be done. - * This method returns a restriction of 'this' so that only tuples id specified in 'part' will be contained in returned field. - */ -MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception) -{ - if(part==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : not empty array must be passed to this method !"); - const int *start=part->getConstPointer(); - const int *end=start+part->getNbOfElems(); - return buildSubPart(start,end); -} - -/*! - * Builds a newly created field, that the caller will have the responsability. - * This method makes the assumption that the field is correctly defined when this method is called, no check of this will be done. - * This method returns a restriction of 'this' so that only tuples id specified in ['partBg';'partEnd') will be contained in returned field. - */ -MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, const int *partEnd) const throw(INTERP_KERNEL::Exception) -{ - DataArrayInt *cellRest; - _type->computeMeshRestrictionFromTupleIds(_mesh,partBg,partEnd,cellRest); - DataArrayInt *arrSelect; - MEDCouplingMesh *m=_type->buildSubMeshData(_mesh,cellRest->getConstPointer(),cellRest->getConstPointer()+cellRest->getNbOfElems(),arrSelect); - if(cellRest) - cellRest->decrRef(); - MEDCouplingFieldDouble *ret=clone(false);//quick shallow copy. - ret->setMesh(m); - m->decrRef(); - std::vector arrays; - _time_discr->getArrays(arrays); - std::vector arrs; - const int *arrSelBg=arrSelect->getConstPointer(); - const int *arrSelEnd=arrSelBg+arrSelect->getNbOfElems(); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - { - DataArrayDouble *arr=0; - if(*iter) - arr=(*iter)->selectByTupleId(arrSelBg,arrSelEnd); - arrs.push_back(arr); - } - ret->_time_discr->setArrays(arrs,0); - for(std::vector::const_iterator iter=arrs.begin();iter!=arrs.end();iter++) - if(*iter) - (*iter)->decrRef(); - arrSelect->decrRef(); - return ret; -} - -TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const -{ - return _time_discr->getEnum(); -} - -MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_nature(NoNature), - _time_discr(MEDCouplingTimeDiscretization::New(td)) -{ -} - -MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingField(other),_nature(other._nature), - _time_discr(other._time_discr->performCpy(deepCpy)) -{ -} - -MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type), - _nature(n),_time_discr(td) -{ -} - -MEDCouplingFieldDouble::~MEDCouplingFieldDouble() -{ - delete _time_discr; -} - -void MEDCouplingFieldDouble::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Field invalid because no mesh specified !"); - _time_discr->checkCoherency(); - _type->checkCoherencyBetween(_mesh,getArray()); -} - -/*! - * Returns the accumulation (the sum) of comId_th component of each tuples of \b default and \b only \b default array. - */ -double MEDCouplingFieldDouble::accumulate(int compId) const -{ - if(getArray()==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::accumulate : no default array defined !"); - return getArray()->accumulate(compId); -} - -/*! - * Returns the accumulation (the sum) of all tuples of \b default and \b only default array. - * The res is expected to be of size getNumberOfComponents(). - */ -void MEDCouplingFieldDouble::accumulate(double *res) const -{ - if(getArray()==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::accumulate : no default array defined !"); - getArray()->accumulate(res); -} - -/*! - * This method returns the max value in 'this'. 'This' is expected to be a field with exactly \b one component. If not an exception will be thrown. - * To getMaxValue on vector field applyFunc is needed before. This method looks only on all arrays stored in 'this->_time_discr'. - * If no arrays exists, an exception will be thrown. - */ -double MEDCouplingFieldDouble::getMaxValue() const throw(INTERP_KERNEL::Exception) -{ - std::vector arrays; - _time_discr->getArrays(arrays); - double ret=-std::numeric_limits::max(); - bool isExistingArr=false; - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - { - if(*iter) - { - isExistingArr=true; - int loc; - ret=std::max(ret,(*iter)->getMaxValue(loc)); - } - } - if(!isExistingArr) - throw INTERP_KERNEL::Exception("getMaxValue : No arrays defined !"); - return ret; -} - -/*! - * This method returns the min value in 'this'. 'This' is expected to be a field with exactly \b one component. If not an exception will be thrown. - * To getMinValue on vector field applyFunc is needed before. This method looks only on all arrays stored in 'this->_time_discr'. - * If no arrays exists, an exception will be thrown. - */ -double MEDCouplingFieldDouble::getMinValue() const throw(INTERP_KERNEL::Exception) -{ - std::vector arrays; - _time_discr->getArrays(arrays); - double ret=std::numeric_limits::max(); - bool isExistingArr=false; - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - { - if(*iter) - { - isExistingArr=true; - int loc; - ret=std::min(ret,(*iter)->getMinValue(loc)); - } - } - if(!isExistingArr) - throw INTERP_KERNEL::Exception("getMinValue : No arrays defined !"); - return ret; -} - -/*! - * This method returns the average value in 'this'. 'This' is expected to be a field with exactly \b one component. If not an exception will be thrown. - * To getAverageValue on vector field applyFunc is needed before. This method looks only \b default array \b and \b only \b default. - * If default array does not exist, an exception will be thrown. - */ -double MEDCouplingFieldDouble::getAverageValue() const throw(INTERP_KERNEL::Exception) -{ - if(getArray()==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getAverageValue : no default array defined !"); - return getArray()->getAverageValue(); -} - -/*! - * This method returns the average value in 'this' weighted by ParaMEDMEM::MEDCouplingField::buildMeasureField. - * 'This' is expected to be a field with exactly \b one component. If not an exception will be thrown. - * To getAverageValue on vector field applyFunc is needed before. This method looks only \b default array \b and \b only \b default. - * If default array does not exist, an exception will be thrown. - */ -double MEDCouplingFieldDouble::getWeightedAverageValue() const throw(INTERP_KERNEL::Exception) -{ - if(getArray()==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !"); - MEDCouplingFieldDouble *w=buildMeasureField(true); - double deno=w->getArray()->accumulate(0); - w->getArray()->multiplyEqual(getArray()); - double res=w->getArray()->accumulate(0); - w->decrRef(); - return res/deno; -} - -/*! - * Returns the normL1 of current field on compId component : - * \f[ - * \frac{\sum_{0 \leq i < nbOfEntity}|val[i]*Vol[i]|}{\sum_{0 \leq i < nbOfEntity}|Vol[i]|} - * \f] - * If compId>=nbOfComponent an exception is thrown. - */ -double MEDCouplingFieldDouble::normL1(int compId) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1"); - int nbComps=getArray()->getNumberOfComponents(); - if(compId>=nbComps) - throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !"); - double *res=new double[nbComps]; - try - { - _type->normL1(_mesh,getArray(),res); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] res; - throw e; - } - double ret=res[compId]; - delete [] res; - return ret; -} - -/*! - * Returns the normL1 of current field on each components : - * \f[ - * \frac{\sum_{0 \leq i < nbOfEntity}|val[i]*Vol[i]|}{\sum_{0 \leq i < nbOfEntity}|Vol[i]|} - * \f] - * The res is expected to be of size getNumberOfComponents(). - */ -void MEDCouplingFieldDouble::normL1(double *res) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1"); - _type->normL1(_mesh,getArray(),res); -} - -/*! - * Returns the normL2 of current field on compId component : - * \f[ - * \sqrt{\frac{\sum_{0 \leq i < nbOfEntity}|val[i]^{2}*Vol[i]|}{\sum_{0 \leq i < nbOfEntity}|Vol[i]|}} - * \f] - * If compId>=nbOfComponent an exception is thrown. - */ -double MEDCouplingFieldDouble::normL2(int compId) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2"); - int nbComps=getArray()->getNumberOfComponents(); - if(compId>=nbComps) - throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !"); - double *res=new double[nbComps]; - try - { - _type->normL2(_mesh,getArray(),res); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] res; - throw e; - } - double ret=res[compId]; - delete [] res; - return ret; -} - -/*! - * Returns the normL2 of current field on each components : - * \f[ - * \sqrt{\frac{\sum_{0 \leq i < nbOfEntity}|val[i]^{2}*Vol[i]|}{\sum_{0 \leq i < nbOfEntity}|Vol[i]|}} - * \f] - * The res is expected to be of size getNumberOfComponents(). - */ -void MEDCouplingFieldDouble::normL2(double *res) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2"); - _type->normL2(_mesh,getArray(),res); -} - -/*! - * Returns the accumulation (the sum) of comId_th component of each tuples weigthed by the field - * returns by getWeightingField relative of the _type of field of default array. - * This method is usefull to check the conservativity of interpolation method. - */ -double MEDCouplingFieldDouble::integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral"); - int nbComps=getArray()->getNumberOfComponents(); - if(compId>=nbComps) - throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !"); - double *res=new double[nbComps]; - try - { - _type->integral(_mesh,getArray(),isWAbs,res); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] res; - throw e; - } - double ret=res[compId]; - delete [] res; - return ret; -} - -/*! - * Returns the accumulation (the sum) of each tuples weigthed by the field - * returns by getWeightingField relative of the _type of field of default array. - * This method is usefull to check the conservativity of interpolation method. - */ -void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral2"); - _type->integral(_mesh,getArray(),isWAbs,res); -} - -/*! - * This method is reserved for field lying on structured mesh spatial support. It returns the value of cell localized by (i,j,k) - * If spatial support is not structured mesh an exception will be thrown. - * @param res out array expected to be equal to size getNumberOfComponents() - */ -void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception) -{ - const DataArrayDouble *arr=_time_discr->getArray(); - _type->getValueOnPos(arr,_mesh,i,j,k,res); -} - -/*! - * Returns value of 'this' on default time of point 'spaceLoc' using spatial discretization. - * If 'point' is outside the spatial discretization of this an exception will be thrown. - */ -void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception) -{ - const DataArrayDouble *arr=_time_discr->getArray(); - _type->getValueOn(arr,_mesh,spaceLoc,res); -} - -/*! - * Returns value of 'this' on time 'time' of point 'spaceLoc' using spatial discretization. - * If 'time' is not covered by this->_time_discr an exception will be thrown. - * If 'point' is outside the spatial discretization of this an exception will be thrown. - */ -void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception) -{ - std::vector< const DataArrayDouble *> arrs=_time_discr->getArraysForTime(time); - std::vector res2; - for(std::vector< const DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++) - { - int sz=res2.size(); - res2.resize(sz+(*iter)->getNumberOfComponents()); - _type->getValueOn(*iter,_mesh,spaceLoc,&res2[sz]); - } - _time_discr->getValueForTime(time,res2,res); -} - -/*! - * Applies a*x+b on 'compoId'th component of each cell. - */ -void MEDCouplingFieldDouble::applyLin(double a, double b, int compoId) -{ - _time_discr->applyLin(a,b,compoId); -} - -/*! - * Applyies the function specified by pointer 'func' on each tuples on all arrays contained in _time_discr. - * If '*func' returns false during one evaluation an exception will be thrown. - */ -void MEDCouplingFieldDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) -{ - _time_discr->applyFunc(nbOfComp,func); -} - -/*! - * Applyies the function specified by the string repr 'func' on each tuples on all arrays contained in _time_discr. - * If '*func' fails in evaluation during one evaluation an exception will be thrown. - * The field will contain 'nbOfComp' components after the call. - */ -void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) -{ - _time_discr->applyFunc(nbOfComp,func); -} - -/*! - * Applyies the function specified by the string repr 'func' on each tuples on all arrays contained in _time_discr. - * If '*func' fails in evaluation during one evaluation an exception will be thrown. - * The field will contain exactly the same number of components after the call. - */ -void MEDCouplingFieldDouble::applyFunc(const char *func) -{ - _time_discr->applyFunc(func); -} - -/*! - * Applyies the function specified by the string repr 'func' on each tuples on all arrays contained in _time_discr. - * The field will contain exactly the same number of components after the call. - * Use is not warranted and can cause SIGSEGV ! - */ -void MEDCouplingFieldDouble::applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception) -{ - _time_discr->applyFuncFast32(func); -} - -void MEDCouplingFieldDouble::applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception) -{ - _time_discr->applyFuncFast64(func); -} - -/*! - * This method makes the assumption that the default array has been set before. - * If not an exception will be sent. - * If default array set, the number of components will be sent. - */ -int MEDCouplingFieldDouble::getNumberOfComponents() const throw(INTERP_KERNEL::Exception) -{ - if(getArray()==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getNumberOfComponents : No array specified !"); - return getArray()->getNumberOfComponents(); -} - -/*! - * This method makes the assumption that _mesh has be set before the call of this method and description of gauss - * localizations in case of Gauss field. If not an exception will sent. - * \b Contrary to MEDCouplingFieldDouble::getNumberOfComponents and MEDCouplingFieldDouble::getNumberOfValues is - * \b not aware of the presence of the default array. - * \b WARNING \b no coherency check is done here. MEDCouplingFieldDouble::checkCoherency method should be called to check that ! - */ -int MEDCouplingFieldDouble::getNumberOfTuples() const throw(INTERP_KERNEL::Exception) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Impossible to retrieve number of tuples because no mesh specified !"); - return _type->getNumberOfTuples(_mesh); -} - -/*! - * This method makes the assumption that the default array has been set before. - * If not an exception will be sent. - * If default array set, the number of values present in the default array will be sent. - */ -int MEDCouplingFieldDouble::getNumberOfValues() const throw(INTERP_KERNEL::Exception) -{ - if(getArray()==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getNumberOfValues : No array specified !"); - return getArray()->getNbOfElems(); -} - -void MEDCouplingFieldDouble::updateTime() -{ - MEDCouplingField::updateTime(); - updateTimeWith(*_time_discr); -} - -void MEDCouplingFieldDouble::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception) -{ - _type->checkCompatibilityWithNature(nat); - _nature=nat; -} - -double MEDCouplingFieldDouble::getIJK(int cellId, int nodeIdInCell, int compoId) const -{ - return _type->getIJK(_mesh,getArray(),cellId,nodeIdInCell,compoId); -} - -void MEDCouplingFieldDouble::setArray(DataArrayDouble *array) -{ - _time_discr->setArray(array,this); -} - -void MEDCouplingFieldDouble::setEndArray(DataArrayDouble *array) -{ - _time_discr->setEndArray(array,this); -} - -void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector& tinyInfo) const -{ - tinyInfo.clear(); - _time_discr->getTinySerializationStrInformation(tinyInfo); - tinyInfo.push_back(_name); - tinyInfo.push_back(_desc); -} - -/*! - * This method retrieves some critical values to resize and prepare remote instance. - * The first two elements returned in tinyInfo correspond to the parameters to give in constructor. - * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny. - */ -void MEDCouplingFieldDouble::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - tinyInfo.clear(); - tinyInfo.push_back((int)_type->getEnum()); - tinyInfo.push_back((int)_time_discr->getEnum()); - tinyInfo.push_back((int)_nature); - _time_discr->getTinySerializationIntInformation(tinyInfo); - std::vector tinyInfo2; - _type->getTinySerializationIntInformation(tinyInfo2); - tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end()); - tinyInfo.push_back(tinyInfo2.size()); -} - -/*! - * This method retrieves some critical values to resize and prepare remote instance. - * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny. - */ -void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - tinyInfo.clear(); - _time_discr->getTinySerializationDbleInformation(tinyInfo); - std::vector tinyInfo2; - _type->getTinySerializationDbleInformation(tinyInfo2); - tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end()); - tinyInfo.push_back(tinyInfo2.size()); -} - -/*! - * This method has to be called to the new instance filled by CORBA, MPI, File... - * @param tinyInfoI is the value retrieves from distant result of getTinySerializationIntInformation on source instance to be copied. - * @param dataInt out parameter. If not null the pointer is already owned by 'this' after the call of this method. In this case no decrRef must be applied. - * @param arrays out parameter is a vector resized to the right size. The pointers in the vector is already owned by 'this' after the call of this method. - * No decrRef must be applied to every instances in returned vector. - */ -void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector& tinyInfoI, DataArrayInt *&dataInt, std::vector& arrays) -{ - dataInt=0; - std::vector tinyInfoITmp(tinyInfoI); - int sz=tinyInfoITmp.back(); - tinyInfoITmp.pop_back(); - std::vector tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz); - std::vector tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end()); - _time_discr->resizeForUnserialization(tinyInfoI2,arrays); - std::vector tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end()); - _type->resizeForUnserialization(tinyInfoITmp3,dataInt); -} - -void MEDCouplingFieldDouble::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) -{ - std::vector tinyInfoI2(tinyInfoI.begin()+3,tinyInfoI.end()); - // - std::vector tmp(tinyInfoD); - int sz=tinyInfoD.back(); - tmp.pop_back(); - std::vector tmp1(tmp.begin(),tmp.end()-sz); - std::vector tmp2(tmp.end()-sz,tmp.end()); - // - _time_discr->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS); - _nature=(NatureOfField)tinyInfoI[2]; - _type->finishUnserialization(tmp2); - int nbOfElemS=tinyInfoS.size(); - _name=tinyInfoS[nbOfElemS-2]; - _desc=tinyInfoS[nbOfElemS-1]; -} - -/*! - * Contrary to MEDCouplingPointSet class the returned arrays are \b not the responsabilities of the caller. - * The values returned must be consulted only in readonly mode. - */ -void MEDCouplingFieldDouble::serialize(DataArrayInt *&dataInt, std::vector& arrays) const -{ - _time_discr->getArrays(arrays); - _type->getSerializationIntArray(dataInt); -} - -/*! - * This method tries to to change the mesh support of 'this' following the parameter 'levOfCheck' and 'prec'. - * Semantic of 'levOfCheck' is explained in MEDCouplingMesh::checkGeoEquivalWith method. This method is used to perform the job. - * If this->_mesh is not defined or other an exeption will be throw. - */ -void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception) -{ - if(_mesh==0 || other==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::changeUnderlyingMesh : is expected to operate on not null meshes !"); - DataArrayInt *cellCor,*nodeCor; - _mesh->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor); - if(cellCor) - { - renumberCellsWithoutMesh(cellCor->getConstPointer(),false); - cellCor->decrRef(); - } - if(nodeCor) - { - renumberNodesWithoutMesh(nodeCor->getConstPointer()); - nodeCor->decrRef(); - } - setMesh((MEDCouplingMesh *)other); -} - -/*! - * This method is an extension of MEDCouplingFieldDouble::operator-=. It allows a user to operate a difference of 2 fields ('this' and 'f') even if they do not share same meshes. - * No interpolation will be done here only an analyze of two underlying mesh will be done to see if the meshes are geometrically equivalent. If yes, the eventual renumbering will be done and operator-= applyed after. - * This method requires that 'f' and 'this' are coherent (check coherency) and that 'f' and 'this' would be coherent for a merge. - * Semantic of 'levOfCheck' is explained in MEDCouplingMesh::checkGeoEquivalWith method. - */ -void MEDCouplingFieldDouble::substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception) -{ - checkCoherency(); - f->checkCoherency(); - if(!areCompatibleForMerge(f)) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::diffWith : Fields are not compatible ; unable to apply mergeFields on them !"); - changeUnderlyingMesh(f->getMesh(),levOfCheck,prec); - operator-=(*f); -} - -/*! - * Merge nodes of underlying mesh. In case of some node will be merged the underlying mesh instance will change. - */ -bool MEDCouplingFieldDouble::mergeNodes(double eps) throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); - if(!meshC) - throw INTERP_KERNEL::Exception("Invalid mesh to apply mergeNodes on it !"); - MEDCouplingAutoRefCountObjectPtr meshC2((MEDCouplingPointSet *)meshC->deepCpy()); - bool ret; - int ret2; - MEDCouplingAutoRefCountObjectPtr arr=meshC2->mergeNodes(eps,ret,ret2); - if(!ret)//no nodes have been merged. - return ret; - std::vector arrays; - _time_discr->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - _type->renumberValuesOnNodes(arr->getConstPointer(),*iter); - setMesh(meshC2); - return true; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::doublyContractedProduct() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->doublyContractedProduct(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("DoublyContractedProduct"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::determinant() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->determinant(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("Determinant"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenValues() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->eigenValues(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("EigenValues"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenVectors() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->eigenVectors(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("EigenVectors"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::inverse() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->inverse(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("Inversion"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::trace() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->trace(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("Trace"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::deviator() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->deviator(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("Trace"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::magnitude() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->magnitude(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - ret->setName("Magnitude"); - ret->setMesh(getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *td=_time_discr->maxPerTuple(); - td->copyTinyAttrFrom(*_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); - std::ostringstream oss; - oss << "Max_" << getName(); - ret->setName(oss.str().c_str()); - ret->setMesh(getMesh()); - return ret; -} - -void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception) -{ - _time_discr->changeNbOfComponents(newNbOfComp,dftValue); -} - -void MEDCouplingFieldDouble::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception) -{ - _time_discr->sortPerTuple(asc); -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areCompatibleForMerge(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !"); - const MEDCouplingMesh *m1=f1->getMesh(); - const MEDCouplingMesh *m2=f2->getMesh(); - MEDCouplingMesh *m=m1->mergeMyselfWith(m2); - MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(m); - m->decrRef(); - ret->setName(f1->getName()); - ret->setDescription(f1->getDescription()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply dotFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply crossProductFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply maxFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply minFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply addFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other) -{ - if(!areStrictlyCompatible(&other)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply += on them !"); - _time_discr->addEqual(other._time_discr); - return *this; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply substractFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other) -{ - if(!areStrictlyCompatible(&other)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply -= on them !"); - _time_discr->substractEqual(other._time_discr); - return *this; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areCompatibleForMul(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply multiplyFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other) -{ - if(!areCompatibleForMul(&other)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply *= on them !"); - _time_discr->multiplyEqual(other._time_discr); - return *this; -} - -MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) -{ - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply divideFields on them !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); - MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); - ret->setMesh(f1->getMesh()); - return ret; -} - -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other) -{ - if(!areStrictlyCompatible(&other)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply /= on them !"); - _time_discr->divideEqual(other._time_discr); - return *this; -} diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx deleted file mode 100644 index cbc0cf924..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGFIELDDOUBLE_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGFIELDDOUBLE_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingField.hxx" -#include "MEDCouplingTimeDiscretization.hxx" -#include "MEDCouplingNatureOfField.hxx" -#include "MEDCouplingMemArray.hxx" - -namespace ParaMEDMEM -{ - class MEDCOUPLING_EXPORT MEDCouplingFieldDouble : public MEDCouplingField - { - public: - static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME); - void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); - std::string simpleRepr() const; - std::string advancedRepr() const; - bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const; - bool areCompatibleForMerge(const MEDCouplingField *other) const; - bool areStrictlyCompatible(const MEDCouplingField *other) const; - bool areCompatibleForMul(const MEDCouplingField *other) const; - void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - void renumberCellsWithoutMesh(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - void renumberNodes(const int *old2NewBg) throw(INTERP_KERNEL::Exception); - void renumberNodesWithoutMesh(const int *old2NewBg) throw(INTERP_KERNEL::Exception); - DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *buildSubPart(const int *partBg, const int *partEnd) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *clone(bool recDeepCpy) const; - MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const; - MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const; - TypeOfTimeDiscretization getTimeDiscretization() const; - void checkCoherency() const throw(INTERP_KERNEL::Exception); - NatureOfField getNature() const { return _nature; } - void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); - void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); } - void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); } - void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); } - double getTime(int& iteration, int& order) const { return _time_discr->getTime(iteration,order); } - double getStartTime(int& iteration, int& order) const { return _time_discr->getStartTime(iteration,order); } - double getEndTime(int& iteration, int& order) const { return _time_discr->getEndTime(iteration,order); } - double getIJ(int tupleId, int compoId) const { return getArray()->getIJ(tupleId,compoId); } - double getIJK(int cellId, int nodeIdInCell, int compoId) const; - void setArray(DataArrayDouble *array); - void setEndArray(DataArrayDouble *array); - DataArrayDouble *getArray() const { return _time_discr->getArray(); } - DataArrayDouble *getEndArray() const { return _time_discr->getEndArray(); } - double accumulate(int compId) const; - void accumulate(double *res) const; - double getMaxValue() const throw(INTERP_KERNEL::Exception); - double getMinValue() const throw(INTERP_KERNEL::Exception); - double getAverageValue() const throw(INTERP_KERNEL::Exception); - double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception); - double normL1(int compId) const throw(INTERP_KERNEL::Exception); - void normL1(double *res) const throw(INTERP_KERNEL::Exception); - double normL2(int compId) const throw(INTERP_KERNEL::Exception); - void normL2(double *res) const throw(INTERP_KERNEL::Exception); - double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception); - void integral(bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception); - void getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception); - void getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception); - void getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception); - //! \b temporary - void applyLin(double a, double b, int compoId); - void applyFunc(int nbOfComp, FunctionToEvaluate func); - void applyFunc(int nbOfComp, const char *func); - void applyFunc(const char *func); - void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception); - void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception); - int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); - int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); - int getNumberOfValues() const throw(INTERP_KERNEL::Exception); - void updateTime(); - // - void getTinySerializationIntInformation(std::vector& tinyInfo) const; - void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - void getTinySerializationStrInformation(std::vector& tinyInfo) const; - void resizeForUnserialization(const std::vector& tinyInfoI, DataArrayInt *&dataInt, std::vector& arrays); - void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - void serialize(DataArrayInt *&dataInt, std::vector& arrays) const; - // - void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); - void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); - bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception); - void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception); - void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const { return dotFields(this,&other); } - static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const { return crossProductFields(this,&other); } - static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const { return maxFields(this,&other); } - static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const { return minFields(this,&other); } - MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const { return addFields(this,&other); } - const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const { return substractFields(this,&other); } - const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const { return multiplyFields(this,&other); } - const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const { return divideFields(this,&other); } - const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - private: - MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td); - MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy); - MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type); - ~MEDCouplingFieldDouble(); - private: - NatureOfField _nature; - MEDCouplingTimeDiscretization *_time_discr; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx deleted file mode 100644 index 68c9a0611..000000000 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingGaussLocalization.hxx" -#include "CellModel.hxx" - -#include -#include -#include -#include - -ParaMEDMEM::MEDCouplingGaussLocalization::MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& w) throw(INTERP_KERNEL::Exception) -try:_type(type),_ref_coord(refCoo),_gauss_coord(gsCoo),_weight(w) - { - checkCoherency(); - } -catch(INTERP_KERNEL::Exception& e) - { - _type=INTERP_KERNEL::NORM_ERROR; - _ref_coord.clear(); - _gauss_coord.clear(); - _weight.clear(); - throw e; - } - -void ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type); - int nbNodes=cm.getNumberOfNodes(); - int dim=cm.getDimension(); - if(!cm.isDynamic()) - { - if((int)_ref_coord.size()!=nbNodes*dim) - { - std::ostringstream oss; oss << "Invalid size of refCoo : expecting to be : " << nbNodes << " (nbNodePerCell) * " << dim << " (dim) !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - if(_gauss_coord.size()!=dim*_weight.size()) - { - std::ostringstream oss; oss << "Invalid gsCoo size and weight size : gsCoo.size() must be equal to _weight.size() * " << dim << " (dim) !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } -} - -int ParaMEDMEM::MEDCouplingGaussLocalization::getDimension() const -{ - if(_weight.empty()) - return -1; - return _gauss_coord.size()/_weight.size(); -} - -int ParaMEDMEM::MEDCouplingGaussLocalization::getNumberOfPtsInRefCell() const -{ - int dim=getDimension(); - if(dim==0) - return -1; - return _ref_coord.size()/dim; -} - -bool ParaMEDMEM::MEDCouplingGaussLocalization::isEqual(const MEDCouplingGaussLocalization& other, double eps) const -{ - if(_type!=other._type) - return false; - if(!areAlmostEqual(_ref_coord,other._ref_coord,eps)) - return false; - if(!areAlmostEqual(_gauss_coord,other._gauss_coord,eps)) - return false; - if(!areAlmostEqual(_weight,other._weight,eps)) - return false; - return true; -} - -double ParaMEDMEM::MEDCouplingGaussLocalization::getRefCoord(int ptIdInCell, int comp) const throw(INTERP_KERNEL::Exception) -{ - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type); - int nbNodes=cm.getNumberOfNodes(); - int dim=cm.getDimension(); - if(ptIdInCell<0 || ptIdInCell>=nbNodes) - throw INTERP_KERNEL::Exception("ptIdInCell specified is invalid : must be in [0;nbNodesPerCell) !"); - if(comp<0 || comp>=dim) - throw INTERP_KERNEL::Exception("comp specified is invalid : must be in [0:dimOfCell) !"); - return _ref_coord[ptIdInCell*dim+comp]; -} - -double ParaMEDMEM::MEDCouplingGaussLocalization::getGaussCoord(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception) -{ - int dim=checkCoherencyOfRequest(gaussPtIdInCell,comp); - return _gauss_coord[gaussPtIdInCell*dim+comp]; -} - -double ParaMEDMEM::MEDCouplingGaussLocalization::getWeight(int gaussPtIdInCell, double newVal) const throw(INTERP_KERNEL::Exception) -{ - checkCoherencyOfRequest(gaussPtIdInCell,0); - return _weight[gaussPtIdInCell]; -} - -/*! - * Completely useless method for end user. Only for CORBA MPI serialization/unserialization. - * push at the end of tinyInfo its basic serialization info. The size of pushed data is always the same. - * @param tinyInfo inout parameter. - */ -void ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo(std::vector& tinyInfo) const -{ - tinyInfo.push_back((int)_type); - tinyInfo.push_back(getNumberOfPtsInRefCell()); - tinyInfo.push_back(getNumberOfGaussPt()); -} - -/*! - * Completely useless method for end user. Only for CORBA MPI serialization/unserialization. - * push at the end of tinyInfo its basic serialization info. The size of pushed data is \b NOT always the same contrary to pushTinySerializationIntInfo. - * @param tinyInfo inout parameter. - */ -void ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo(std::vector& tinyInfo) const -{ - tinyInfo.insert(tinyInfo.end(),_ref_coord.begin(),_ref_coord.end()); - tinyInfo.insert(tinyInfo.end(),_gauss_coord.begin(),_gauss_coord.end()); - tinyInfo.insert(tinyInfo.end(),_weight.begin(),_weight.end()); -} - -/*! - * This method operates the exact inverse operation than ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo method. This is one of the last step of unserialization process. - * This method should be called on an object resized by buildNewInstanceFromTinyInfo static method. - * This method takes in argument a pointer 'vals' that point to the begin of double data pushed remotely by pushTinySerializationDblInfo method. - * This method returns the pointer 'vals' with an offset of size what it has been read in this method. - */ -const double *ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues(const double *vals) -{ - const double *work=vals; - std::copy(work,work+_ref_coord.size(),_ref_coord.begin()); - work+=_ref_coord.size(); - std::copy(work,work+_gauss_coord.size(),_gauss_coord.begin()); - work+=_gauss_coord.size(); - std::copy(work,work+_weight.size(),_weight.begin()); - work+=_weight.size(); - return work; -} - -/*! - * This method sets the comp_th component of ptIdInCell_th point coordinate of reference element of type this->_type. - * @throw if not 0<=ptIdInCell=nbNodes) - throw INTERP_KERNEL::Exception("ptIdInCell specified is invalid : must be in [0;nbNodesPerCell) !"); - if(comp<0 || comp>=dim) - throw INTERP_KERNEL::Exception("comp specified is invalid : must be in [0:dimOfCell) !"); - _ref_coord[ptIdInCell*dim+comp]=newVal; -} - -void ParaMEDMEM::MEDCouplingGaussLocalization::setGaussCoord(int gaussPtIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception) -{ - int dim=checkCoherencyOfRequest(gaussPtIdInCell,comp); - _gauss_coord[gaussPtIdInCell*dim+comp]=newVal; -} - -void ParaMEDMEM::MEDCouplingGaussLocalization::setWeight(int gaussPtIdInCell, double newVal) throw(INTERP_KERNEL::Exception) -{ - checkCoherencyOfRequest(gaussPtIdInCell,0); - _weight[gaussPtIdInCell]=newVal; -} - -/*! - * The format of 'tinyData' parameter is the same than pushed in method ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo. - */ -ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo(int dim, const std::vector& tinyData) -{ - std::vector v1(dim*tinyData[1]),v2(dim*tinyData[2]),v3(tinyData[2]); - return ParaMEDMEM::MEDCouplingGaussLocalization((INTERP_KERNEL::NormalizedCellType)tinyData[0],v1,v2,v3); -} - -int ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception) -{ - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type); - int dim=cm.getDimension(); - int nbGsPts=getNumberOfGaussPt(); - if(gaussPtIdInCell<0 || gaussPtIdInCell>=nbGsPts) - throw INTERP_KERNEL::Exception("gaussPtIdInCell specified is invalid : must be in [0:nbGsPts) !"); - if(comp<0 || comp>=dim) - throw INTERP_KERNEL::Exception("comp specified is invalid : must be in [0:dimOfCell) !"); - return dim; -} - -bool ParaMEDMEM::MEDCouplingGaussLocalization::areAlmostEqual(const std::vector& v1, const std::vector& v2, double eps) -{ - int sz=v1.size(); - if(sz!=(int)v2.size()) - return false; - std::vector tmp(sz); - std::transform(v1.begin(),v1.end(),v2.begin(),tmp.begin(),std::minus()); - std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::ptr_fun(fabs)); - return *std::max_element(tmp.begin(),tmp.end()) - -namespace ParaMEDMEM -{ - class MEDCouplingMesh; - - class MEDCOUPLING_EXPORT MEDCouplingGaussLocalization - { - public: - MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& w) throw(INTERP_KERNEL::Exception); - INTERP_KERNEL::NormalizedCellType getType() const { return _type; } - int getNumberOfGaussPt() const { return _weight.size(); } - int getDimension() const; - int getNumberOfPtsInRefCell() const; - void checkCoherency() const throw(INTERP_KERNEL::Exception); - bool isEqual(const MEDCouplingGaussLocalization& other, double eps) const; - void pushTinySerializationIntInfo(std::vector& tinyInfo) const; - void pushTinySerializationDblInfo(std::vector& tinyInfo) const; - const double *fillWithValues(const double *vals); - // - const std::vector& getRefCoords() const { return _ref_coord; } - double getRefCoord(int ptIdInCell, int comp) const throw(INTERP_KERNEL::Exception); - const std::vector& getGaussCoords() const { return _gauss_coord; } - double getGaussCoord(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception); - const std::vector& getWeights() const { return _weight; } - double getWeight(int gaussPtIdInCell, double newVal) const throw(INTERP_KERNEL::Exception); - void setRefCoord(int ptIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception); - void setGaussCoord(int gaussPtIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception); - void setWeight(int gaussPtIdInCell, double newVal) throw(INTERP_KERNEL::Exception); - // - static MEDCouplingGaussLocalization buildNewInstanceFromTinyInfo(int dim, const std::vector& tinyData); - private: - int checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception); - static bool areAlmostEqual(const std::vector& v1, const std::vector& v2, double eps); - private: - INTERP_KERNEL::NormalizedCellType _type; - std::vector _ref_coord; - std::vector _gauss_coord; - std::vector _weight; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx deleted file mode 100644 index 7ced3782b..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ /dev/null @@ -1,1367 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingMemArray.txx" - -#include "GenMathFormulae.hxx" -#include "InterpKernelExprParser.hxx" - -#include -#include -#include -#include - -typedef double (*MYFUNCPTR)(double); - -using namespace ParaMEDMEM; - -void DataArray::setName(const char *name) -{ - _name=name; -} - -void DataArray::copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception) -{ - if(_info_on_compo.size()!=other._info_on_compo.size()) - throw INTERP_KERNEL::Exception("Size of arrays mismatches on copyStringInfoFrom !"); - _name=other._name; - _info_on_compo=other._info_on_compo; -} - -bool DataArray::areInfoEquals(const DataArray& other) const -{ - if(_nb_of_tuples!=other._nb_of_tuples) - return false; - if(_name!=other._name) - return false; - return _info_on_compo==other._info_on_compo; -} - -void DataArray::reprWithoutNameStream(std::ostream& stream) const -{ - stream << "Nb of components : "<< getNumberOfComponents() << "\n"; - stream << "Info of these components : "; - for(std::vector::const_iterator iter=_info_on_compo.begin();iter!=_info_on_compo.end();iter++) - stream << "\"" << *iter << "\" "; - stream << "\n"; -} - -std::string DataArray::getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception) -{ - if(i<(int)_info_on_compo.size()) - return _info_on_compo[i]; - else - { - std::ostringstream oss; oss << "getInfoOnComponent : Invalid component id transmitted (" << i << ") >= " << (int) _info_on_compo.size(); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } -} - -void DataArray::setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception) -{ - if(i<(int)_info_on_compo.size()) - _info_on_compo[i]=info; - else - { - std::ostringstream oss; oss << "setInfoOnComponent : Invalid component id transmitted (" << i << ") >= " << (int) _info_on_compo.size(); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } -} - -DataArrayDouble *DataArrayDouble::New() -{ - return new DataArrayDouble; -} - -DataArrayDouble *DataArrayDouble::deepCopy() const -{ - return new DataArrayDouble(*this); -} - -DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const -{ - if(deepCpy) - return deepCopy(); - else - { - incrRef(); - return const_cast(this); - } -} - -void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo) -{ - _nb_of_tuples=nbOfTuple; - _info_on_compo.resize(nbOfCompo); - _mem.alloc(nbOfCompo*_nb_of_tuples); - declareAsNew(); -} - -void DataArrayDouble::fillWithZero() -{ - _mem.fillWithValue(0.); -} - -std::string DataArrayDouble::repr() const -{ - std::ostringstream ret; - reprStream(ret); - return ret.str(); -} - -std::string DataArrayDouble::reprZip() const -{ - std::ostringstream ret; - reprZipStream(ret); - return ret.str(); -} - -void DataArrayDouble::reprStream(std::ostream& stream) const -{ - stream << "Name of double array : \"" << _name << "\"\n"; - reprWithoutNameStream(stream); -} - -void DataArrayDouble::reprZipStream(std::ostream& stream) const -{ - stream << "Name of double array : \"" << _name << "\"\n"; - reprZipWithoutNameStream(stream); -} - -void DataArrayDouble::reprWithoutNameStream(std::ostream& stream) const -{ - DataArray::reprWithoutNameStream(stream); - stream.precision(15); - _mem.repr(getNumberOfComponents(),stream); -} - -void DataArrayDouble::reprZipWithoutNameStream(std::ostream& stream) const -{ - DataArray::reprWithoutNameStream(stream); - stream.precision(15); - _mem.reprZip(getNumberOfComponents(),stream); -} - -bool DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const -{ - if(!areInfoEquals(other)) - return false; - return _mem.isEqual(other._mem,prec); -} - -bool DataArrayDouble::isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const -{ - return _mem.isEqual(other._mem,prec); -} - -void DataArrayDouble::reAlloc(int nbOfTuples) -{ - _mem.reAlloc(_info_on_compo.size()*nbOfTuples); - _nb_of_tuples=nbOfTuples; - declareAsNew(); -} - -DataArrayInt *DataArrayDouble::convertToIntArr() const -{ - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(getNumberOfTuples(),getNumberOfComponents()); - int nbOfVals=getNbOfElems(); - const double *src=getConstPointer(); - int *dest=ret->getPointer(); - std::copy(src,src+nbOfVals,dest); - ret->copyStringInfoFrom(*this); - return ret; -} - -/*! - * This method does \b not change the number of tuples after this call. - * Only a permutation is done. If a permutation reduction is needed substr, or selectByTupleId should be used. - */ -void DataArrayDouble::renumberInPlace(const int *old2New) -{ - int nbTuples=getNumberOfTuples(); - int nbOfCompo=getNumberOfComponents(); - double *tmp=new double[nbTuples*nbOfCompo]; - const double *iptr=getConstPointer(); - for(int i=0;ialloc(nbTuples,nbOfCompo); - ret->copyStringInfoFrom(*this); - const double *iptr=getConstPointer(); - double *optr=ret->getPointer(); - for(int i=0;iend()) will be kept. - * This method check that interval is valid regarding this, if not an exception will be thrown. - */ -DataArrayDouble *DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception) -{ - int nbt=getNumberOfTuples(); - if(tupleIdBg<0) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !"); - if(tupleIdBg>=nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); - int trueEnd=tupleIdEnd; - if(tupleIdEnd!=-1) - { - if(tupleIdEnd>nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); - } - else - trueEnd=nbt; - int nbComp=getNumberOfComponents(); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(trueEnd-tupleIdBg,nbComp); - ret->copyStringInfoFrom(*this); - std::copy(getConstPointer()+tupleIdBg*nbComp,getConstPointer()+trueEnd*nbComp,ret->getPointer()); - return ret; -} - -/*! - * This method builds a new instance of DataArrayDouble (to deal with) that is reduction or an extension of 'this'. - * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept. - * If 'newNbOfComp' > this->getNumberOfComponents() an extension is done, and for each components i such that i > getNumberOfComponents() 'dftValue' parameter is taken. - */ -DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception) -{ - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(getNumberOfTuples(),newNbOfComp); - const double *oldc=getConstPointer(); - double *nc=ret->getPointer(); - int nbOfTuples=getNumberOfTuples(); - int oldNbOfComp=getNumberOfComponents(); - int dim=std::min(oldNbOfComp,newNbOfComp); - for(int i=0;isetName(getName().c_str()); - for(int i=0;isetInfoOnComponent(i,getInfoOnComponent(i).c_str()); - ret->setName(getName().c_str()); - return ret; -} - -/*! - * This method is a generalization of DataArrayDouble::substr method because a not contigous range can be specified here. - */ -DataArrayDouble *DataArrayDouble::selectByTupleId(const int *start, const int *end) const -{ - DataArrayDouble *ret=DataArrayDouble::New(); - int nbComp=getNumberOfComponents(); - ret->alloc(std::distance(start,end),nbComp); - ret->copyStringInfoFrom(*this); - double *pt=ret->getPointer(); - const double *srcPt=getConstPointer(); - int i=0; - for(const int *w=start;w!=end;w++,i++) - std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp); - return ret; -} - -void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet) -{ - if(newArray!=arrayToSet) - { - if(arrayToSet) - arrayToSet->decrRef(); - arrayToSet=newArray; - if(arrayToSet) - arrayToSet->incrRef(); - } -} - -void DataArrayDouble::useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo) -{ - _nb_of_tuples=nbOfTuple; - _info_on_compo.resize(nbOfCompo); - _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo); - declareAsNew(); -} - -void DataArrayDouble::checkNoNullValues() const throw(INTERP_KERNEL::Exception) -{ - const double *tmp=getConstPointer(); - int nbOfElems=getNbOfElems(); - const double *where=std::find(tmp,tmp+nbOfElems,0.); - if(where!=tmp+nbOfElems) - throw INTERP_KERNEL::Exception("A value 0.0 have been detected !"); -} - -double DataArrayDouble::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception) -{ - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !"); - int nbOfTuples=getNumberOfTuples(); - if(nbOfTuples<=0) - throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !"); - const double *vals=getConstPointer(); - const double *loc=std::max_element(vals,vals+nbOfTuples); - tupleId=std::distance(vals,loc); - return *loc; -} - -double DataArrayDouble::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception) -{ - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component !"); - int nbOfTuples=getNumberOfTuples(); - if(nbOfTuples<=0) - throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : array exists but number of tuples must be > 0 !"); - const double *vals=getConstPointer(); - const double *loc=std::min_element(vals,vals+nbOfTuples); - tupleId=std::distance(vals,loc); - return *loc; -} - -double DataArrayDouble::getAverageValue() const throw(INTERP_KERNEL::Exception) -{ - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : must be applied on DataArrayDouble with only one component !"); - int nbOfTuples=getNumberOfTuples(); - if(nbOfTuples<=0) - throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : array exists but number of tuples must be > 0 !"); - const double *vals=getConstPointer(); - double ret=std::accumulate(vals,vals+nbOfTuples,0.); - return ret/nbOfTuples; -} - -void DataArrayDouble::accumulate(double *res) const -{ - const double *ptr=getConstPointer(); - int nbTuple=getNumberOfTuples(); - int nbComps=getNumberOfComponents(); - std::fill(res,res+nbComps,0.); - for(int i=0;i()); -} - -double DataArrayDouble::accumulate(int compId) const -{ - const double *ptr=getConstPointer(); - int nbTuple=getNumberOfTuples(); - int nbComps=getNumberOfComponents(); - if(compId>=nbComps) - throw INTERP_KERNEL::Exception("DataArrayDouble::accumulate : Invalid compId specified : No such nb of components !"); - double ret=0.; - for(int i=0;ialloc(nbOfTuple,1); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - for(int i=0;ialloc(nbOfTuple,1); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - switch(getNumberOfComponents()) - { - case 6: - for(int i=0;idecrRef(); - throw INTERP_KERNEL::Exception("DataArrayDouble::determinant : Invalid number of components ! must be in 4,6,9 !"); - } -} - -DataArrayDouble *DataArrayDouble::eigenValues() const throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=6) - throw INTERP_KERNEL::Exception("DataArrayDouble::eigenValues : must be an array with exactly 6 components !"); - DataArrayDouble *ret=DataArrayDouble::New(); - int nbOfTuple=getNumberOfTuples(); - ret->alloc(nbOfTuple,3); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - for(int i=0;ialloc(nbOfTuple,9); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - for(int i=0;ialloc(nbOfTuple,nbOfComp); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); -if(nbOfComp==6) - for(int i=0;ialloc(nbOfTuple,1); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - if(nbOfComp==6) - for(int i=0;ialloc(nbOfTuple,6); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - for(int i=0;ialloc(nbOfTuple,1); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - for(int i=0;ialloc(nbOfTuple,1); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - for(int i=0;i()); - declareAsNew(); -} - -void DataArrayDouble::applyLin(double a, double b, int compoId) -{ - double *ptr=getPointer()+compoId; - int nbOfComp=getNumberOfComponents(); - int nbOfTuple=getNumberOfTuples(); - for(int i=0;ialloc(nbOfTuples,nbOfComp); - const double *ptr=getConstPointer(); - double *ptrToFill=newArr->getPointer(); - for(int i=0;i(oss,", ")); - oss << ") : Evaluation of function failed !"; - newArr->decrRef(); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - return newArr; -} - -DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception) -{ - INTERP_KERNEL::ExprParser expr(func); - expr.parse(); - std::set vars; - expr.getTrueSetOfVars(vars); - int oldNbOfComp=getNumberOfComponents(); - if((int)vars.size()>oldNbOfComp) - { - std::ostringstream oss; oss << "The field has a " << oldNbOfComp << " components and there are "; - oss << vars.size() << " variables : "; - std::copy(vars.begin(),vars.end(),std::ostream_iterator(oss," ")); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - std::vector varsV(vars.begin(),vars.end()); - expr.prepareExprEvaluation(varsV); - // - DataArrayDouble *newArr=DataArrayDouble::New(); - int nbOfTuples=getNumberOfTuples(); - newArr->alloc(nbOfTuples,nbOfComp); - const double *ptr=getConstPointer(); - double *ptrToFill=newArr->getPointer(); - for(int i=0;i(oss,", ")); - oss << ") : Evaluation of function failed !" << e.what(); - newArr->decrRef(); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - return newArr; -} - -DataArrayDouble *DataArrayDouble::applyFunc(const char *func) const throw(INTERP_KERNEL::Exception) -{ - INTERP_KERNEL::ExprParser expr(func); - expr.parse(); - expr.prepareExprEvaluationVec(); - // - DataArrayDouble *newArr=DataArrayDouble::New(); - int nbOfTuples=getNumberOfTuples(); - int nbOfComp=getNumberOfComponents(); - newArr->alloc(nbOfTuples,nbOfComp); - const double *ptr=getConstPointer(); - double *ptrToFill=newArr->getPointer(); - for(int i=0;i(oss,", ")); - oss << ") : Evaluation of function failed ! " << e.what(); - newArr->decrRef(); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - return newArr; -} - -void DataArrayDouble::applyFuncFast32(const char *func) -{ - INTERP_KERNEL::ExprParser expr(func); - expr.parse(); - char *funcStr=expr.compileX86(); - MYFUNCPTR funcPtr=(MYFUNCPTR)funcStr;//he he... - // - double *ptr=getPointer(); - int nbOfComp=getNumberOfComponents(); - int nbOfTuples=getNumberOfTuples(); - int nbOfElems=nbOfTuples*nbOfComp; - for(int i=0;i res; - int nbOfTuples=getNumberOfTuples(); - for(int i=0;i=vmin && *cptr<=vmax) - res.push_back(i); - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(res.size(),1); - std::copy(res.begin(),res.end(),ret->getPointer()); - return ret; -} - -DataArrayDouble *DataArrayDouble::aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !"); - int nbOfTuple1=a1->getNumberOfTuples(); - int nbOfTuple2=a2->getNumberOfTuples(); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple1+nbOfTuple2,nbOfComp); - double *pt=std::copy(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple1*nbOfComp,ret->getPointer()); - std::copy(a2->getConstPointer(),a2->getConstPointer()+nbOfTuple2*nbOfComp,pt); - ret->copyStringInfoFrom(*a1); - return ret; -} - -DataArrayDouble *DataArrayDouble::dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array dot !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array dot !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,1); - double *retPtr=ret->getPointer(); - const double *a1Ptr=a1->getConstPointer(); - const double *a2Ptr=a2->getConstPointer(); - for(int i=0;isetInfoOnComponent(0,a1->getInfoOnComponent(0).c_str()); - ret->setName(a1->getName().c_str()); - return ret; -} - -DataArrayDouble *DataArrayDouble::crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array crossProduct !"); - if(nbOfComp!=3) - throw INTERP_KERNEL::Exception("Nb of components must be equal to 3 for array crossProduct !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array crossProduct !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,3); - double *retPtr=ret->getPointer(); - const double *a1Ptr=a1->getConstPointer(); - const double *a2Ptr=a2->getConstPointer(); - for(int i=0;icopyStringInfoFrom(*a1); - return ret; -} - -DataArrayDouble *DataArrayDouble::max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array max !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array max !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - double *retPtr=ret->getPointer(); - const double *a1Ptr=a1->getConstPointer(); - const double *a2Ptr=a2->getConstPointer(); - int nbElem=nbOfTuple*nbOfComp; - for(int i=0;icopyStringInfoFrom(*a1); - return ret; -} - -DataArrayDouble *DataArrayDouble::min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array min !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array min !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - double *retPtr=ret->getPointer(); - const double *a1Ptr=a1->getConstPointer(); - const double *a2Ptr=a2->getConstPointer(); - int nbElem=nbOfTuple*nbOfComp; - for(int i=0;icopyStringInfoFrom(*a1); - return ret; -} - -DataArrayDouble *DataArrayDouble::add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array add !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array add !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::plus()); - ret->copyStringInfoFrom(*a1); - return ret; -} - -void DataArrayDouble::addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=other->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array add !"); - int nbOfTuple=getNumberOfTuples(); - if(nbOfTuple!=other->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array add !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::plus()); - declareAsNew(); -} - -DataArrayDouble *DataArrayDouble::substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus()); - ret->copyStringInfoFrom(*a1); - return ret; -} - -void DataArrayDouble::substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=other->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !"); - int nbOfTuple=getNumberOfTuples(); - if(nbOfTuple!=other->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::minus()); - declareAsNew(); -} - -DataArrayDouble *DataArrayDouble::multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfTuple=a1->getNumberOfTuples(); - int nbOfTuple2=a2->getNumberOfTuples(); - int nbOfComp=a1->getNumberOfComponents(); - int nbOfComp2=a2->getNumberOfComponents(); - if(nbOfTuple!=nbOfTuple2) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiply !"); - DataArrayDouble *ret=0; - if(nbOfComp==nbOfComp2) - { - ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::multiplies()); - ret->copyStringInfoFrom(*a1); - } - else - { - int nbOfCompMin,nbOfCompMax; - const DataArrayDouble *aMin, *aMax; - if(nbOfComp>nbOfComp2) - { - nbOfCompMin=nbOfComp2; nbOfCompMax=nbOfComp; - aMin=a2; aMax=a1; - } - else - { - nbOfCompMin=nbOfComp; nbOfCompMax=nbOfComp2; - aMin=a1; aMax=a2; - } - if(nbOfCompMin==1) - { - ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfCompMax); - const double *aMinPtr=aMin->getConstPointer(); - const double *aMaxPtr=aMax->getConstPointer(); - double *res=ret->getPointer(); - for(int i=0;i(),aMinPtr[i])); - ret->copyStringInfoFrom(*aMax); - } - else - throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiply !"); - } - return ret; -} - -void DataArrayDouble::multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) -{ - int nbOfTuple=getNumberOfTuples(); - int nbOfTuple2=other->getNumberOfTuples(); - int nbOfComp=getNumberOfComponents(); - int nbOfComp2=other->getNumberOfComponents(); - if(nbOfTuple!=nbOfTuple2) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiplyEqual !"); - if(nbOfComp==nbOfComp2) - { - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::multiplies()); - } - else - { - if(nbOfComp2==1) - { - const double *ptr=other->getConstPointer(); - double *myPtr=getPointer(); - for(int i=0;i(),ptr[i])); - } - else - throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiplyEqual !"); - } - declareAsNew(); -} - -DataArrayDouble *DataArrayDouble::divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array divide !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divide !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides()); - ret->copyStringInfoFrom(*a1); - return ret; -} - -void DataArrayDouble::divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) -{ - int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=other->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !"); - int nbOfTuple=getNumberOfTuples(); - if(nbOfTuple!=other->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides()); - declareAsNew(); -} - -DataArrayInt *DataArrayInt::New() -{ - return new DataArrayInt; -} - -DataArrayInt *DataArrayInt::deepCopy() const -{ - return new DataArrayInt(*this); -} - -DataArrayInt *DataArrayInt::performCpy(bool deepCpy) const -{ - if(deepCpy) - return deepCopy(); - else - { - incrRef(); - return const_cast(this); - } -} - -void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo) -{ - _nb_of_tuples=nbOfTuple; - _info_on_compo.resize(nbOfCompo); - _mem.alloc(nbOfCompo*_nb_of_tuples); - declareAsNew(); -} - -void DataArrayInt::fillWithZero() -{ - _mem.fillWithValue(0); -} - -std::string DataArrayInt::repr() const -{ - std::ostringstream ret; - reprStream(ret); - return ret.str(); -} - -std::string DataArrayInt::reprZip() const -{ - std::ostringstream ret; - reprZipStream(ret); - return ret.str(); -} - -void DataArrayInt::reprStream(std::ostream& stream) const -{ - stream << "Name of int array : \"" << _name << "\"\n"; - reprWithoutNameStream(stream); -} - -void DataArrayInt::reprZipStream(std::ostream& stream) const -{ - stream << "Name of int array : \"" << _name << "\"\n"; - reprZipWithoutNameStream(stream); -} - -void DataArrayInt::reprWithoutNameStream(std::ostream& stream) const -{ - DataArray::reprWithoutNameStream(stream); - _mem.repr(getNumberOfComponents(),stream); -} - -void DataArrayInt::reprZipWithoutNameStream(std::ostream& stream) const -{ - DataArray::reprWithoutNameStream(stream); - _mem.reprZip(getNumberOfComponents(),stream); -} - -void DataArrayInt::transformWithIndArr(const int *indArr) -{ - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component !"); - int nbOfTuples=getNumberOfTuples(); - int *pt=getPointer(); - for(int i=0;ialloc(newNbOfElem,1); - int nbOfOldNodes=getNumberOfTuples(); - const int *old2New=getConstPointer(); - int *pt=ret->getPointer(); - for(int i=0;i!=nbOfOldNodes;i++) - if(old2New[i]!=-1) - pt[old2New[i]]=i; - return ret; -} - -bool DataArrayInt::isEqual(const DataArrayInt& other) const -{ - if(!areInfoEquals(other)) - return false; - return _mem.isEqual(other._mem,0); -} - -bool DataArrayInt::isEqualWithoutConsideringStr(const DataArrayInt& other) const -{ - return _mem.isEqual(other._mem,0); -} - -void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo) -{ - _nb_of_tuples=nbOfTuple; - _info_on_compo.resize(nbOfCompo); - _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo); - declareAsNew(); -} - -void DataArrayInt::renumberInPlace(const int *old2New) -{ - int nbTuples=getNumberOfTuples(); - int nbOfCompo=getNumberOfComponents(); - int *tmp=new int[nbTuples*nbOfCompo]; - const int *iptr=getConstPointer(); - for(int i=0;ialloc(nbTuples,nbOfCompo); - ret->copyStringInfoFrom(*this); - const int *iptr=getConstPointer(); - int *optr=ret->getPointer(); - for(int i=0;ialloc(getNumberOfTuples(),getNumberOfComponents()); - int nbOfVals=getNbOfElems(); - const int *src=getConstPointer(); - double *dest=ret->getPointer(); - std::copy(src,src+nbOfVals,dest); - ret->copyStringInfoFrom(*this); - return ret; -} - -/*! - * This methods has a similar behaviour than std::string::substr. This method returns a newly created DataArrayInt that is part of this with same number of components. - * The intervall is specified by [tupleIdBg,tupleIdEnd) except if tupleIdEnd ==-1 in this case the [tupleIdBg,this->end()) will be kept. - * This method check that interval is valid regarding this, if not an exception will be thrown. - */ -DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception) -{ - int nbt=getNumberOfTuples(); - if(tupleIdBg<0) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !"); - if(tupleIdBg>=nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); - int trueEnd=tupleIdEnd; - if(tupleIdEnd!=-1) - { - if(tupleIdEnd>nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); - } - else - trueEnd=nbt; - int nbComp=getNumberOfComponents(); - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(trueEnd-tupleIdBg,nbComp); - ret->copyStringInfoFrom(*this); - std::copy(getConstPointer()+tupleIdBg*nbComp,getConstPointer()+trueEnd*nbComp,ret->getPointer()); - return ret; -} - -/*! - * This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'. - * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept. - * If 'newNbOfComp' > this->getNumberOfComponents() an extension is done, and for each components i such that i > getNumberOfComponents() 'dftValue' parameter is taken. - */ -DataArrayInt *DataArrayInt::changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception) -{ - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(getNumberOfTuples(),newNbOfComp); - const int *oldc=getConstPointer(); - int *nc=ret->getPointer(); - int nbOfTuples=getNumberOfTuples(); - int oldNbOfComp=getNumberOfComponents(); - int dim=std::min(oldNbOfComp,newNbOfComp); - for(int i=0;isetName(getName().c_str()); - for(int i=0;isetInfoOnComponent(i,getInfoOnComponent(i).c_str()); - ret->setName(getName().c_str()); - return ret; -} - - -/*! - * This method is a generalization of DataArrayDouble::substr method because a not contigous range can be specified here. - */ -DataArrayInt *DataArrayInt::selectByTupleId(const int *start, const int *end) const -{ - DataArrayInt *ret=DataArrayInt::New(); - int nbComp=getNumberOfComponents(); - ret->alloc(std::distance(start,end),nbComp); - ret->copyStringInfoFrom(*this); - int *pt=ret->getPointer(); - const int *srcPt=getConstPointer(); - int i=0; - for(const int *w=start;w!=end;w++,i++) - std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp); - return ret; -} - -void DataArrayInt::reAlloc(int nbOfTuples) -{ - _mem.reAlloc(_info_on_compo.size()*nbOfTuples); - _nb_of_tuples=nbOfTuples; - declareAsNew(); -} - -void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet) -{ - if(newArray!=arrayToSet) - { - if(arrayToSet) - arrayToSet->decrRef(); - arrayToSet=newArray; - if(arrayToSet) - arrayToSet->incrRef(); - } -} - -DataArrayInt *DataArrayInt::aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2) -{ - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !"); - int nbOfTuple1=a1->getNumberOfTuples(); - int nbOfTuple2=a2->getNumberOfTuples(); - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(nbOfTuple1+nbOfTuple2-offsetA2,nbOfComp); - int *pt=std::copy(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple1*nbOfComp,ret->getPointer()); - std::copy(a2->getConstPointer()+offsetA2*nbOfComp,a2->getConstPointer()+nbOfTuple2*nbOfComp,pt); - ret->copyStringInfoFrom(*a1); - return ret; -} - -/*! - * This method create a minimal partition of groups 'groups' the std::iota array of size 'newNb'. - * This method returns an array of size 'newNb' that specifies for each item at which familyId it owns to, and this method returns - * for each group the familyId it contains. If an id so that id& groups, int newNb, std::vector< std::vector >& fidsOfGroups) -{ - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(newNb,1); - int *retPtr=ret->getPointer(); - std::fill(retPtr,retPtr+newNb,0); - int fid=1; - for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++) - { - const int *ptr=(*iter)->getConstPointer(); - int nbOfElem=(*iter)->getNbOfElems(); - int sfid=fid; - for(int j=0;j::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++) - { - std::set tmp; - const int *ptr=(*iter)->getConstPointer(); - int nbOfElem=(*iter)->getNbOfElems(); - for(const int *p=ptr;p!=ptr+nbOfElem;p++) - tmp.insert(retPtr[*p]); - fidsOfGroups[grId].insert(fidsOfGroups[grId].end(),tmp.begin(),tmp.end()); - } - return ret; -} - -int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end) -{ - int sz=std::distance(start,end); - int *ret=new int[sz]; - int *work=new int[sz]; - std::copy(start,end,work); - std::sort(work,work+sz); - if(std::unique(work,work+sz)!=work+sz) - { - delete [] work; - delete [] ret; - throw INTERP_KERNEL::Exception("Some elements are equals in the specified array !"); - } - int *iter2=ret; - for(const int *iter=start;iter!=end;iter++,iter2++) - *iter2=std::distance(work,std::find(work,work+sz,*iter)); - delete [] work; - return ret; -} diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx deleted file mode 100644 index 33b8896b6..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "InterpKernelException.hxx" - -#include -#include -#include - -namespace ParaMEDMEM -{ - template - class MEDCouplingPointer - { - public: - MEDCouplingPointer():_internal(0),_external(0) { } - void null() { _internal=0; _external=0; } - bool isNull() const { return _internal==0 && _external==0; } - void setInternal(T *pointer); - void setExternal(const T *pointer); - const T *getConstPointer() const { if(_internal) return _internal; else return _external; } - const T *getConstPointerLoc(int offset) const { if(_internal) return _internal+offset; else return _external+offset; } - T *getPointer() const { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; } - private: - T *_internal; - const T *_external; - }; - - template - class MemArray - { - public: - MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { } - MemArray(const MemArray& other); - const T *getConstPointerLoc(int offset) const { return _pointer.getConstPointerLoc(offset); } - const T *getConstPointer() const { return _pointer.getConstPointer(); } - T *getPointer() const { return _pointer.getPointer(); } - MemArray &operator=(const MemArray& other); - T operator[](int id) const { return _pointer.getConstPointer()[id]; } - T& operator[](int id) { return _pointer.getPointer()[id]; } - bool isEqual(const MemArray& other, T prec) const; - void repr(int sl, std::ostream& stream) const; - void reprZip(int sl, std::ostream& stream) const; - void fillWithValue(const T& val); - void alloc(int nbOfElements); - void reAlloc(int newNbOfElements); - void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem); - void writeOnPlace(int id, T element0, const T *others, int sizeOfOthers); - ~MemArray() { destroy(); } - private: - void destroy(); - static void destroyPointer(T *pt, DeallocType type); - private: - int _nb_of_elem; - bool _ownership; - MEDCouplingPointer _pointer; - DeallocType _dealloc; - }; - - class DataArray : public RefCountObject, public TimeLabel - { - public: - MEDCOUPLING_EXPORT void setName(const char *name); - MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const; - MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT std::string getName() const { return _name; } - MEDCOUPLING_EXPORT const std::vector &getInfoOnComponent() const { return _info_on_compo; } - MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT int getNumberOfComponents() const { return _info_on_compo.size(); } - MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _nb_of_tuples; } - MEDCOUPLING_EXPORT int getNbOfElems() const { return _info_on_compo.size()*_nb_of_tuples; } - protected: - DataArray():_nb_of_tuples(-1) { } - protected: - int _nb_of_tuples; - std::string _name; - std::vector _info_on_compo; - }; -} - -#include "MEDCouplingMemArray.txx" - -namespace ParaMEDMEM -{ - class DataArrayInt; - class DataArrayDouble : public DataArray - { - public: - MEDCOUPLING_EXPORT static DataArrayDouble *New(); - MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const; - MEDCOUPLING_EXPORT DataArrayDouble *performCpy(bool deepCpy) const; - MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo); - MEDCOUPLING_EXPORT void fillWithZero(); - MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT std::string reprZip() const; - MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const; - //!alloc or useArray should have been called before. - MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples); - MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const; - MEDCOUPLING_EXPORT void renumberInPlace(const int *old2New); - MEDCOUPLING_EXPORT DataArrayDouble *renumber(const int *old2New) const; - MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *start, const int *end) const; - MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); } - MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } - MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); } - MEDCOUPLING_EXPORT double *getPointer() const { return _mem.getPointer(); } - MEDCOUPLING_EXPORT static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet); - MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); } - MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); - MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } - MEDCOUPLING_EXPORT void checkNoNullValues() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT double getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT double getAverageValue() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void accumulate(double *res) const; - MEDCOUPLING_EXPORT double accumulate(int compId) const; - MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *determinant() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *eigenVectors() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *inverse() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *trace() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *deviator() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId); - MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const char *func) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void applyFuncFast32(const char *func); - MEDCOUPLING_EXPORT void applyFuncFast64(const char *func); - MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - //! nothing to do here because this class does not aggregate any TimeLabel instance. - MEDCOUPLING_EXPORT void updateTime() { } - private: - DataArrayDouble() { } - private: - MemArray _mem; - }; - - class DataArrayInt : public DataArray - { - public: - MEDCOUPLING_EXPORT static DataArrayInt *New(); - MEDCOUPLING_EXPORT DataArrayInt *deepCopy() const; - MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const; - MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo); - MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const; - MEDCOUPLING_EXPORT void fillWithZero(); - MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT std::string reprZip() const; - MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArr); - MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const; - //!alloc or useArray should have been called before. - MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples); - MEDCOUPLING_EXPORT DataArrayDouble *convertToDblArr() const; - MEDCOUPLING_EXPORT void renumberInPlace(const int *old2New); - MEDCOUPLING_EXPORT DataArrayInt *renumber(const int *old2New) const; - MEDCOUPLING_EXPORT bool isIdentity() const; - MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *start, const int *end) const; - MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); } - MEDCOUPLING_EXPORT int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } - MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } - MEDCOUPLING_EXPORT int *getPointer() const { return _mem.getPointer(); } - MEDCOUPLING_EXPORT static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet); - MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); } - MEDCOUPLING_EXPORT static DataArrayInt *aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); - MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); - MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); - MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } - //! nothing to do here because this class does not aggregate any TimeLabel instance. - MEDCOUPLING_EXPORT void updateTime() { } - public: - MEDCOUPLING_EXPORT static int *checkAndPreparePermutation(const int *start, const int *end); - private: - DataArrayInt() { } - private: - MemArray _mem; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx deleted file mode 100644 index 5a1a048d5..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__ -#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__ - -#include "MEDCouplingMemArray.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - template - void MEDCouplingPointer::setInternal(T *pointer) - { - _internal=pointer; - _external=0; - } - - template - void MEDCouplingPointer::setExternal(const T *pointer) - { - _external=pointer; - _internal=0; - } - - template - MemArray::MemArray(const MemArray& other):_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) - { - if(!other._pointer.isNull()) - { - T *pointer=new T[other._nb_of_elem]; - std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+other._nb_of_elem,pointer); - useArray(pointer,true,CPP_DEALLOC,other._nb_of_elem); - } - } - - template - void MemArray::useArray(const T *array, bool ownership, DeallocType type, int nbOfElem) - { - _nb_of_elem=nbOfElem; - destroy(); - if(ownership) - _pointer.setInternal((T *)array); - else - _pointer.setExternal(array); - _ownership=ownership; - _dealloc=type; - } - - template - void MemArray::writeOnPlace(int id, T element0, const T *others, int sizeOfOthers) - { - if(id+sizeOfOthers>=_nb_of_elem) - reAlloc(2*_nb_of_elem+sizeOfOthers+1); - T *pointer=_pointer.getPointer(); - pointer[id]=element0; - std::copy(others,others+sizeOfOthers,pointer+id+1); - } - - template - bool MemArray::isEqual(const MemArray& other, T prec) const - { - if(_nb_of_elem!=other._nb_of_elem) - return false; - const T *pt1=_pointer.getConstPointer(); - const T *pt2=other._pointer.getConstPointer(); - if(pt1==0 && pt2==0) - return true; - if(pt1==0 || pt2==0) - return false; - if(pt1==pt2) - return true; - for(int i=0;i<_nb_of_elem;i++) - if(pt1[i]-pt2[i]<-prec || (pt1[i]-pt2[i])>prec) - return false; - return true; - } - - /*! - * @param sl is typically the number of components [in parameter] - */ - template - void MemArray::repr(int sl, std::ostream& stream) const - { - stream << "Number of tuples : "; - if(!_pointer.isNull()) - { - if(sl!=0) - stream << _nb_of_elem/sl; - else - stream << "Empty Data"; - } - else - stream << "No data"; - stream << "\n"; - stream << "Data content :\n"; - const T *data=getConstPointer(); - if(!_pointer.isNull()) - { - if(_nb_of_elem!=0 && sl!=0) - { - int nbOfTuples=_nb_of_elem/sl; - for(int i=0;i(stream," ")); - stream << "\n"; - data+=sl; - } - } - else - stream << "Empty Data\n"; - } - else - stream << "No data !\n"; - } - - /*! - * @param sl is typically the number of components [in parameter] - */ - template - void MemArray::reprZip(int sl, std::ostream& stream) const - { - stream << "Number of tuples : "; - if(!_pointer.isNull()) - { - if(sl!=0) - stream << _nb_of_elem/sl; - else - stream << "Empty Data"; - } - else - stream << "No data"; - stream << "\n"; - stream << "Data content : "; - const T *data=getConstPointer(); - if(!_pointer.isNull()) - { - if(_nb_of_elem!=0 && sl!=0) - { - int nbOfTuples=_nb_of_elem/sl; - for(int i=0;i(stream," ")); - stream << "| "; - data+=sl; - } - stream << "\n"; - } - else - stream << "Empty Data\n"; - } - else - stream << "No data !\n"; - } - - template - void MemArray::fillWithValue(const T& val) - { - T *pt=_pointer.getPointer(); - std::fill(pt,pt+_nb_of_elem,val); - } - - template - void MemArray::alloc(int nbOfElements) - { - destroy(); - _nb_of_elem=nbOfElements; - _pointer.setInternal(new T[_nb_of_elem]); - _ownership=true; - _dealloc=CPP_DEALLOC; - } - - template - void MemArray::reAlloc(int newNbOfElements) - { - T *pointer=new T[newNbOfElements]; - std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min(_nb_of_elem,newNbOfElements),pointer); - if(_ownership) - destroyPointer((T *)_pointer.getConstPointer(),_dealloc); - _pointer.setInternal(pointer); - _nb_of_elem=newNbOfElements; - _ownership=true; - _dealloc=CPP_DEALLOC; - } - - template - void MemArray::destroyPointer(T *pt, DeallocType type) - { - switch(type) - { - case CPP_DEALLOC: - { - delete [] pt; - return ; - } - case C_DEALLOC: - { - free(pt); - return ; - } - default: - std::stringstream stream; - stream << "Invalid deallocation requested for pointer " << pt; - throw INTERP_KERNEL::Exception(stream.str().c_str()); - } - } - - template - void MemArray::destroy() - { - if(_ownership) - destroyPointer((T *)_pointer.getConstPointer(),_dealloc); - _pointer.null(); - _ownership=false; - } - - template - MemArray &MemArray::operator=(const MemArray& other) - { - alloc(other._nb_of_elem); - std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+_nb_of_elem,_pointer.getPointer()); - return *this; - } -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx deleted file mode 100644 index 5ad1928d3..000000000 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingMesh.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingFieldDiscretization.hxx" - -#include "InterpKernelExprParser.hxx" - -#include -#include - -using namespace ParaMEDMEM; - -/*! - * This method is only for ParaMEDMEM in ParaFIELD constructor. - */ -bool MEDCouplingMesh::isStructured() const -{ - return getType()==CARTESIAN; -} - -bool MEDCouplingMesh::isEqual(const MEDCouplingMesh *other, double prec) const -{ - return _name==other->_name; -} - -/*! - * This method checks geo equivalence between two meshes : 'this' and 'other'. - * If no exception is throw 'this' and 'other' are geometrically equivalent regarding 'levOfCheck' level. - * This method is typically used to change the mesh of a field "safely" depending the 'levOfCheck' level considered. - * - * @param levOfCheck input that specifies the level of check specified. The possible values are listed below. - * @param prec input that specifies precision for double float data used for comparison in meshes. - * @param cellCor output array not always informed (depending 'levOfCheck' param) that gives the corresponding array for cells from 'other' to 'this'. - * @param nodeCor output array not always informed (depending 'levOfCheck' param) that gives the corresponding array for nodes from 'other' to 'this'. - * - * Possible values for levOfCheck : - * - 0 for strict equality. This is the strongest level. 'cellCor' and 'nodeCor' params are never informed. - * - 10,11,12 for less strict equality. Two meshes are compared geometrically. In case of success 'cellCor' and 'nodeCor' are informed. Warning ! These equivalences are CPU/Mem costly. The 3 values correspond respectively to policy used for cell comparison (see MEDCouplingUMesh::zipConnectivityTraducer to have more details) - * - 20,21,22, for less strict equality. Two meshes are compared geometrically. The difference with the previous version is that nodes(coordinates) are expected to be the same between this and other. In case of success 'cellCor' is informed. Warning ! These equivalences are CPU/Mem costly. The 3 values correspond respectively to policy used for cell comparison (see MEDCouplingUMesh::zipConnectivityTraducer to have more details) - * - 1 for fast 'equality'. This is a lazy level. Just number of cells and number of nodes are considered here and 3 cells (begin,middle,end) - * - 2 for deep 'equality' as 0 option except that no control is done on all strings in mesh. - */ -void MEDCouplingMesh::checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) -{ - cellCor=0; - nodeCor=0; - if(this==other) - return ; - switch(levOfCheck) - { - case 0: - { - if(!isEqual(other,prec)) - throw INTERP_KERNEL::Exception("checkGeoFitWith : Meshes are not equal !"); - return ; - } - case 10: - case 11: - case 12: - { - checkDeepEquivalWith(other,levOfCheck-10,prec,cellCor,nodeCor); - return ; - } - case 20: - case 21: - case 22: - { - checkDeepEquivalOnSameNodesWith(other,levOfCheck-20,prec,cellCor); - return ; - } - case 1: - { - checkFastEquivalWith(other,prec); - return; - } - case 2: - { - if(!isEqualWithoutConsideringStr(other,prec)) - throw INTERP_KERNEL::Exception("checkGeoFitWith : Meshes are not equal without considering strings !"); - return ; - } - default: - throw INTERP_KERNEL::Exception("checkGeoFitWith : Invalid levOfCheck specified ! Value must be in 0,1,2,10,11 or 12."); - } -} - -/*! - * Given a nodeIds range ['partBg','partEnd'), this method returns the set of cell ids in ascendant order whose connectivity of - * these cells are fully included in the range. As a consequence the returned set of cell ids does \b not \b always fit the nodes in ['partBg','partEnd') - * This method returns the corresponding cells in a newly created array that the caller has the responsability. - */ -DataArrayInt *MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const -{ - std::vector crest; - std::set p(partBg,partEnd); - int nbOfCells=getNumberOfCells(); - for(int i=0;i conn; - getNodeIdsOfCell(i,conn); - bool cont=true; - for(std::vector::const_iterator iter=conn.begin();iter!=conn.end() && cont;iter++) - if(p.find(*iter)==p.end()) - cont=false; - if(cont) - crest.push_back(i); - } - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(crest.size(),1); - std::copy(crest.begin(),crest.end(),ret->getPointer()); - return ret; -} - -/*! - * This method checks fastly that 'this' and 'other' are equal. All common checks are done here. - */ -void MEDCouplingMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception) -{ - if(getMeshDimension()!=other->getMeshDimension()) - throw INTERP_KERNEL::Exception("checkFastEquivalWith : Mesh dimensions are not equal !"); - if(getSpaceDimension()!=other->getSpaceDimension()) - throw INTERP_KERNEL::Exception("checkFastEquivalWith : Space dimensions are not equal !"); - if(getNumberOfCells()!=other->getNumberOfCells()) - throw INTERP_KERNEL::Exception("checkFastEquivalWith : number of cells are not equal !"); -} - -/*! - * This method is very poor and looks only if 'this' and 'other' are candidate for merge of fields lying repectively on them. - */ -bool MEDCouplingMesh::areCompatibleForMerge(const MEDCouplingMesh *other) const -{ - if(getMeshDimension()!=other->getMeshDimension()) - return false; - if(getSpaceDimension()!=other->getSpaceDimension()) - return false; - return true; -} - -/*! - * This method builds a field lying on 'this' with 'nbOfComp' components. - * 'func' is a pointer that points to a function that takes 2 arrays in parameter and returns a boolean. - * The first array is a in-param of size this->getSpaceDimension and the second an out param of size 'nbOfComp'. - * The return field will have type specified by 't'. 't' is also used to determine where values of field will be - * evaluate. - * @param t type of field returned and specifies where the evaluation of func will be done. - * @param nbOfComp number of components of returned field. - * @param func pointer to a function that should return false if the evaluation failed. (division by 0. for example) - * @return field with counter = 1. - */ -MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const -{ - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(t); - ret->setMesh(this); - DataArrayDouble *loc=ret->getDiscretization()->getLocalizationOfDiscValues(this); - DataArrayDouble *array=DataArrayDouble::New(); - int nbOfTuple=loc->getNumberOfTuples(); - int nbCompIn=loc->getNumberOfComponents(); - const double *locPtr=loc->getConstPointer(); - array->alloc(nbOfTuple,nbOfComp); - double *ptToFill=array->getPointer(); - for(int i=0;i(oss,", ")); - oss << ") : Evaluation of function failed !"; - loc->decrRef(); - array->decrRef(); - ret->decrRef(); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - ptToFill+=nbOfComp; - } - loc->decrRef(); - ret->setArray(array); - array->decrRef(); - return ret; -} - -/*! - * This method copyies all tiny strings from other (name and components name). - * @throw if other and this have not same mesh type. - */ -void MEDCouplingMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) -{ - _name=other->_name; -} - -/*! - * This method builds a field lying on 'this' with 'nbOfComp' components. - * 'func' is a string that is the expression to evaluate. - * The return field will have type specified by 't'. 't' is also used to determine where values of field will be - * evaluate. - * @param t type of field returned and specifies where the evaluation of func will be done. - * @param nbOfComp number of components of returned field. - * @param func expression. - * @return field with counter = 1. - */ -MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const -{ - INTERP_KERNEL::ExprParser expr(func); - expr.parse(); - std::set vars; - expr.getTrueSetOfVars(vars); - if((int)vars.size()>getSpaceDimension()) - { - std::ostringstream oss; oss << "The mesh has a spaceDim==" << getSpaceDimension() << " and there are "; - oss << vars.size() << " variables : "; - std::copy(vars.begin(),vars.end(),std::ostream_iterator(oss," ")); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - std::vector varsV(vars.begin(),vars.end()); - expr.prepareExprEvaluation(varsV); - // - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(t); - ret->setMesh(this); - DataArrayDouble *loc=ret->getDiscretization()->getLocalizationOfDiscValues(this); - DataArrayDouble *array=DataArrayDouble::New(); - int nbOfTuple=loc->getNumberOfTuples(); - int nbCompIn=loc->getNumberOfComponents(); - const double *locPtr=loc->getConstPointer(); - array->alloc(nbOfTuple,nbOfComp); - double *ptToFill=array->getPointer(); - for(int i=0;i(oss,", ")); - oss << ") : Evaluation of function failed ! " << e.what(); - loc->decrRef(); - array->decrRef(); - ret->decrRef(); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - ptToFill+=nbOfComp; - } - loc->decrRef(); - ret->setArray(array); - array->decrRef(); - return ret; -} - -/*! - * retruns a newly created mesh with counter=1 - * that is the union of mesh1 and mesh2 if possible. The cells of mesh2 will appear after cells of 'mesh1'. Idem for nodes. - */ -MEDCouplingMesh *MEDCouplingMesh::mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) -{ - return mesh1->mergeMyselfWith(mesh2); -} diff --git a/src/MEDCoupling/MEDCouplingMesh.hxx b/src/MEDCoupling/MEDCouplingMesh.hxx deleted file mode 100644 index 524c23017..000000000 --- a/src/MEDCoupling/MEDCouplingMesh.hxx +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGMESH_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGMESH_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" - -#include - -namespace ParaMEDMEM -{ - typedef enum - { - UNSTRUCTURED = 5, - UNSTRUCTURED_DESC = 6, - CARTESIAN = 7, - EXTRUDED = 8 - } MEDCouplingMeshType; - - class DataArrayInt; - class DataArrayDouble; - class MEDCouplingFieldDouble; - - class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel - { - public: - void setName(const char *name) { _name=name; } - const char *getName() const { return _name.c_str(); } - virtual MEDCouplingMesh *deepCpy() const = 0; - virtual MEDCouplingMeshType getType() const = 0; - bool isStructured() const; - virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); - // comparison methods - virtual bool isEqual(const MEDCouplingMesh *other, double prec) const; - virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0; - virtual void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) = 0; - virtual void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception) = 0; - virtual void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception); - void checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception); - // - virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getNumberOfCells() const = 0; - virtual int getNumberOfNodes() const = 0; - virtual int getSpaceDimension() const = 0; - virtual int getMeshDimension() const = 0; - virtual DataArrayDouble *getCoordinatesAndOwner() const = 0; - virtual DataArrayDouble *getBarycenterAndOwner() const = 0; - virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0; - virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0; - virtual void getNodeIdsOfCell(int cellId, std::vector& conn) const = 0; - virtual DataArrayInt *getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const; - virtual void getCoordinatesOfNode(int nodeId, std::vector& coo) const = 0; - virtual std::string simpleRepr() const = 0; - virtual std::string advancedRepr() const = 0; - // tools - virtual void getBoundingBox(double *bbox) const = 0; - virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0; - virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0; - virtual int getCellContainingPoint(const double *pos, double eps) const = 0; - virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const; - virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const; - virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0; - virtual void rotate(const double *center, const double *vector, double angle) = 0; - virtual void translate(const double *vector) = 0; - virtual void scale(const double *point, double factor) = 0; - virtual void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0; - virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const = 0; - virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0; - virtual MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const = 0; - virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const; - static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2); - //serialisation-unserialization - virtual void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const = 0; - virtual void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const = 0; - virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const = 0; - virtual void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings) = 0; - protected: - MEDCouplingMesh() { } - MEDCouplingMesh(const MEDCouplingMesh& other):_name(other._name) { } - virtual ~MEDCouplingMesh() { } - private: - std::string _name; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.cxx b/src/MEDCoupling/MEDCouplingNatureOfField.cxx deleted file mode 100644 index 7969909f1..000000000 --- a/src/MEDCoupling/MEDCouplingNatureOfField.cxx +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingNatureOfField.hxx" - -#include - -namespace ParaMEDMEM -{ - const char *MEDCouplingNatureOfField::REPR_OF_NATUREOFFIELD[NB_OF_POSSIBILITIES]= - { "NoNature", - "ConservativeVolumic", - "Integral", - "IntegralGlobConstraint", - "RevIntegral"}; - - const int MEDCouplingNatureOfField::POS_OF_NATUREOFFIELD[NB_OF_POSSIBILITIES]={17,26,32,35,37}; - - const char *MEDCouplingNatureOfField::getRepr(NatureOfField nat) throw(INTERP_KERNEL::Exception) - { - const int *pos=std::find(POS_OF_NATUREOFFIELD,POS_OF_NATUREOFFIELD+NB_OF_POSSIBILITIES,(int)nat); - if(pos==POS_OF_NATUREOFFIELD+NB_OF_POSSIBILITIES) - throw INTERP_KERNEL::Exception("MEDCouplingNatureOfField::getRepr : Unrecognized nature of field !"); - int pos2=std::distance(POS_OF_NATUREOFFIELD,pos); - return REPR_OF_NATUREOFFIELD[pos2]; - } -} - diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.hxx b/src/MEDCoupling/MEDCouplingNatureOfField.hxx deleted file mode 100644 index 89f9125e0..000000000 --- a/src/MEDCoupling/MEDCouplingNatureOfField.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGNATUREOFFIELD_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGNATUREOFFIELD_HXX__ - -#include "MEDCoupling.hxx" -#include "InterpKernelException.hxx" - -namespace ParaMEDMEM -{ - typedef enum - { - NoNature = 17, - ConservativeVolumic = 26, - Integral = 32, - IntegralGlobConstraint = 35, - RevIntegral = 37 - } NatureOfField; - - class MEDCouplingNatureOfField - { - public: - MEDCOUPLING_EXPORT static const char *getRepr(NatureOfField nat) throw(INTERP_KERNEL::Exception); - private: - static const int NB_OF_POSSIBILITIES=5; - static const char *REPR_OF_NATUREOFFIELD[NB_OF_POSSIBILITIES]; - static const int POS_OF_NATUREOFFIELD[NB_OF_POSSIBILITIES]; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx deleted file mode 100644 index c2643f327..000000000 --- a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGNORMALIZEDCARTESIANMESH_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGNORMALIZEDCARTESIANMESH_HXX__ - -#include "NormalizedUnstructuredMesh.hxx" - -namespace ParaMEDMEM -{ - class MEDCouplingCMesh; -} - -template -class MEDCouplingNormalizedCartesianMesh : public INTERP_KERNEL::GenericMesh -{ -public: - static const int MY_SPACEDIM=SPACEDIM; - static const int MY_MESHDIM=SPACEDIM; - typedef int MyConnType; - static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; -public: - MEDCouplingNormalizedCartesianMesh(ParaMEDMEM::MEDCouplingCMesh *mesh); - //void getBoundingBox(double *boundingBox) const; - //INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const; - //unsigned char getNumberOfNodesOfElement(int eltId) const; - //unsigned long getNumberOfNodes() const; - unsigned long getNumberOfElements() const; - unsigned long nbCellsAlongAxis(int axis) const; - const double * getCoordsAlongAxis(int axis) const; - ~MEDCouplingNormalizedCartesianMesh(); -private: - ParaMEDMEM::MEDCouplingCMesh *_mesh; -}; - -#endif diff --git a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx deleted file mode 100644 index 468eea71a..000000000 --- a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2010 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 : MEDCouplingNormalizedCartesianMesh.txx -// Created : Mon Aug 17 12:00:38 2009 -// Author : Edward AGAPOV (eap) -// - -#include "MEDCouplingNormalizedCartesianMesh.hxx" -#include "MEDCouplingCMesh.hxx" - -template -MEDCouplingNormalizedCartesianMesh::MEDCouplingNormalizedCartesianMesh(ParaMEDMEM::MEDCouplingCMesh *mesh):_mesh(mesh) -{ - if(_mesh) - _mesh->incrRef(); -} - -template -MEDCouplingNormalizedCartesianMesh::~MEDCouplingNormalizedCartesianMesh() -{ - if(_mesh) - _mesh->decrRef(); -} - -template -unsigned long MEDCouplingNormalizedCartesianMesh::getNumberOfElements() const -{ - return _mesh->getNumberOfCells(); -} - -template -unsigned long MEDCouplingNormalizedCartesianMesh::nbCellsAlongAxis(int axis) const -{ - return _mesh->getCoordsAt(axis)->getNumberOfTuples() - 1; -} - -template -const double * MEDCouplingNormalizedCartesianMesh::getCoordsAlongAxis(int axis) const -{ - return _mesh->getCoordsAt(axis)->getConstPointer(); -} diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx deleted file mode 100644 index 5ebd3ae19..000000000 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_HXX__ - -#include "NormalizedUnstructuredMesh.hxx" - -namespace ParaMEDMEM -{ - class MEDCouplingUMesh; -} - -template -class MEDCouplingNormalizedUnstructuredMesh : public INTERP_KERNEL::GenericMesh -{ -public: - static const int MY_SPACEDIM=SPACEDIM; - static const int MY_MESHDIM=MESHDIM; - typedef int MyConnType; - static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; -public: - MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh); - void getBoundingBox(double *boundingBox) const; - INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const; - unsigned char getNumberOfNodesOfElement(int eltId) const; - unsigned long getNumberOfElements() const; - unsigned long getNumberOfNodes() const; - const int *getConnectivityPtr() const; - const double *getCoordinatesPtr() const; - const int *getConnectivityIndexPtr() const; - void releaseTempArrays(); - ~MEDCouplingNormalizedUnstructuredMesh(); -private: - void prepare(); -private: - ParaMEDMEM::MEDCouplingUMesh *_mesh; - int *_conn_for_interp; - int *_conn_index_for_interp; -}; - -#endif diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx deleted file mode 100644 index ae5ad015e..000000000 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2007-2010 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 __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__ -#define __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__ - -#include "MEDCouplingNormalizedUnstructuredMesh.hxx" - -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingMemArray.hxx" - -#include - -template -MEDCouplingNormalizedUnstructuredMesh::MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh) -{ - if(_mesh) - _mesh->incrRef(); - prepare(); -} - -template -void MEDCouplingNormalizedUnstructuredMesh::getBoundingBox(double *boundingBox) const -{ - for(int i=0;i::max(); - boundingBox[SPACEDIM+i]=-std::numeric_limits::max(); - } - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); - const double *ptr=array->getConstPointer(); - int nbOfPts=array->getNbOfElems()/SPACEDIM; - for(int j=0;j*work) - boundingBox[j]=*work; - if(boundingBox[j+SPACEDIM]<*work) - boundingBox[j+SPACEDIM]=*work; - } - } -} - -template -INTERP_KERNEL::NormalizedCellType MEDCouplingNormalizedUnstructuredMesh::getTypeOfElement(int eltId) const -{ - return _mesh->getTypeOfCell(eltId); -} - -template -unsigned char MEDCouplingNormalizedUnstructuredMesh::getNumberOfNodesOfElement(int eltId) const -{ - return _mesh->getNumberOfNodesInCell(eltId); -} - -template -unsigned long MEDCouplingNormalizedUnstructuredMesh::getNumberOfElements() const -{ - return _mesh->getNumberOfCells(); -} - -template -unsigned long MEDCouplingNormalizedUnstructuredMesh::getNumberOfNodes() const -{ - return _mesh->getNumberOfNodes(); -} - -template -const int *MEDCouplingNormalizedUnstructuredMesh::getConnectivityPtr() const -{ - return _conn_for_interp; -} - -template -const double *MEDCouplingNormalizedUnstructuredMesh::getCoordinatesPtr() const -{ - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); - return array->getConstPointer(); -} - -template -const int *MEDCouplingNormalizedUnstructuredMesh::getConnectivityIndexPtr() const -{ - return _conn_index_for_interp; -} - -template -void MEDCouplingNormalizedUnstructuredMesh::releaseTempArrays() -{ - delete [] _conn_for_interp; - delete [] _conn_index_for_interp; - _conn_for_interp=0; - _conn_index_for_interp=0; -} - -template -MEDCouplingNormalizedUnstructuredMesh::~MEDCouplingNormalizedUnstructuredMesh() -{ - if(_mesh) - _mesh->decrRef(); - releaseTempArrays(); -} - -template -void MEDCouplingNormalizedUnstructuredMesh::prepare() -{ - int nbOfCell=_mesh->getNumberOfCells(); - int initialConnSize=_mesh->getNodalConnectivity()->getNbOfElems(); - _conn_for_interp=new int[initialConnSize-nbOfCell]; - _conn_index_for_interp=new int[nbOfCell+1]; - _conn_index_for_interp[0]=0; - const int *work_conn=_mesh->getNodalConnectivity()->getConstPointer()+1; - const int *work_conn_index=_mesh->getNodalConnectivityIndex()->getConstPointer(); - int *work_conn_for_interp=_conn_for_interp; - int *work_conn_index_for_interp=_conn_index_for_interp; - for(int i=0;i -#include -#include - -using namespace ParaMEDMEM; - -MEDCouplingPointSet::MEDCouplingPointSet():_coords(0) -{ -} - -MEDCouplingPointSet::MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy):MEDCouplingMesh(other),_coords(0) -{ - if(other._coords) - _coords=other._coords->performCpy(deepCpy); -} - -MEDCouplingPointSet::~MEDCouplingPointSet() -{ - if(_coords) - _coords->decrRef(); -} - -int MEDCouplingPointSet::getNumberOfNodes() const -{ - if(_coords) - return _coords->getNumberOfTuples(); - else - throw INTERP_KERNEL::Exception("Unable to get number of nodes because no coordinates specified !"); -} - -int MEDCouplingPointSet::getSpaceDimension() const -{ - if(_coords) - return _coords->getNumberOfComponents(); - else - throw INTERP_KERNEL::Exception("Unable to get space dimension because no coordinates specified !"); -} - -void MEDCouplingPointSet::updateTime() -{ - if(_coords) - { - updateTimeWith(*_coords); - } -} - -void MEDCouplingPointSet::setCoords(DataArrayDouble *coords) -{ - if( coords != _coords ) - { - if (_coords) - _coords->decrRef(); - _coords=coords; - if(_coords) - _coords->incrRef(); - declareAsNew(); - } -} - -DataArrayDouble *MEDCouplingPointSet::getCoordinatesAndOwner() const -{ - if(_coords) - _coords->incrRef(); - return _coords; -} - -/*! - * This method copyies all tiny strings from other (name and components name). - * @throw if other and this have not same mesh type. - */ -void MEDCouplingPointSet::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingPointSet *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::copyTinyStringsFrom : meshes have not same type !"); - MEDCouplingMesh::copyTinyStringsFrom(other); - if(_coords && otherC->_coords) - _coords->copyStringInfoFrom(*otherC->_coords); -} - -bool MEDCouplingPointSet::isEqual(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingPointSet *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!MEDCouplingMesh::isEqual(other,prec)) - return false; - if(!areCoordsEqual(*otherC,prec)) - return false; - return true; -} - -bool MEDCouplingPointSet::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingPointSet *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!areCoordsEqualWithoutConsideringStr(*otherC,prec)) - return false; - return true; -} - -bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, double prec) const -{ - if(_coords==0 && other._coords==0) - return true; - if(_coords==0 || other._coords==0) - return false; - if(_coords==other._coords) - return true; - return _coords->isEqual(*other._coords,prec); -} - -bool MEDCouplingPointSet::areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const -{ - if(_coords==0 && other._coords==0) - return true; - if(_coords==0 || other._coords==0) - return false; - if(_coords==other._coords) - return true; - return _coords->isEqualWithoutConsideringStr(*other._coords,prec); -} - -/*! - * This method is typically the base method used for implementation of mergeNodes. This method computes this permutation array using as input, - * This method is const ! So this method simply computes the array, no permutation of nodes is done. - * a precision 'precision' and a 'limitNodeId' that is the node id so that every nodes which id is strictly lower than 'limitNodeId' will not be merged. - * To desactivate this advanced feature put -1 to this argument. - * @param areNodesMerged output parameter that states if some nodes have been "merged" in returned array - * @param newNbOfNodes output parameter too this is the maximal id in returned array to avoid to recompute it. - */ -DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const -{ - DataArrayInt *comm,*commI; - findCommonNodes(limitNodeId,precision,comm,commI); - int oldNbOfNodes=getNumberOfNodes(); - DataArrayInt *ret=buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes); - areNodesMerged=(oldNbOfNodes!=newNbOfNodes); - comm->decrRef(); - commI->decrRef(); - return ret; -} - -/*! - * This methods searches for each node n1 nodes in _coords that are less far than 'prec' from n1. if any these nodes are stored in params - * comm and commIndex. - * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged. - * @param comm out parameter (not inout) - * @param commIndex out parameter (not inout) - */ -void MEDCouplingPointSet::findCommonNodes(int limitNodeId, double prec, DataArrayInt *&comm, DataArrayInt *&commIndex) const -{ - comm=DataArrayInt::New(); - commIndex=DataArrayInt::New(); - // - int nbNodesOld=getNumberOfNodes(); - int spaceDim=getSpaceDimension(); - std::vector bbox(2*nbNodesOld*spaceDim); - const double *coordsPtr=_coords->getConstPointer(); - for(int i=0;i c,cI(1); - switch(spaceDim) - { - case 3: - findCommonNodesAlg<3>(bbox,nbNodesOld,limitNodeId,prec,c,cI); - break; - case 2: - findCommonNodesAlg<2>(bbox,nbNodesOld,limitNodeId,prec,c,cI); - break; - case 1: - findCommonNodesAlg<1>(bbox,nbNodesOld,limitNodeId,prec,c,cI); - break; - default: - throw INTERP_KERNEL::Exception("Unexpected spacedim of coords. Must be 1,2 or 3."); - } - commIndex->alloc(cI.size(),1); - std::copy(cI.begin(),cI.end(),commIndex->getPointer()); - comm->alloc(cI.back(),1); - std::copy(c.begin(),c.end(),comm->getPointer()); -} - -/*! - * @param comm in param in the same format than one returned by findCommonNodes method. - * @param commI in param in the same format than one returned by findCommonNodes method. - * @return the old to new correspondance array. - */ -DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex, - int& newNbOfNodes) const -{ - DataArrayInt *ret=DataArrayInt::New(); - int nbNodesOld=getNumberOfNodes(); - ret->alloc(nbNodesOld,1); - std::fill(ret->getPointer(),ret->getPointer()+nbNodesOld,-1); - int *retPtr=ret->getPointer(); - std::vector commRemain(comm->getConstPointer(),comm->getConstPointer()+comm->getNumberOfTuples()); - std::vector commIRemain(commIndex->getConstPointer(),commIndex->getConstPointer()+commIndex->getNumberOfTuples()); - int newNb=0; - for(int iNode=0;iNode::const_iterator iNode2=commRemain.begin(); - iNode2!=commRemain.begin()+commIRemain[1];iNode2++) - retPtr[*iNode2]=newNb; - int delta=commIRemain[1]; - commRemain.erase(commRemain.begin(),commRemain.begin()+commIRemain[1]); - commIRemain.erase(commIRemain.begin()); - std::transform(commIRemain.begin(),commIRemain.end(),commIRemain.begin(),std::bind2nd(std::minus(),delta)); - } - newNb++; - } - newNbOfNodes=newNb; - return ret; -} - -/* - * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes. - * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) - * This value is asked because often known by the caller of this method. - * @param newNodeNumbers array specifying the new numbering. - * @param newNbOfNodes the new number of nodes. - */ -void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) -{ - DataArrayDouble *newCoords=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - newCoords->alloc(newNbOfNodes,spaceDim); - newCoords->copyStringInfoFrom(*_coords); - int oldNbOfNodes=getNumberOfNodes(); - double *ptToFill=newCoords->getPointer(); - const double *oldCoordsPtr=_coords->getConstPointer(); - for(int i=0;idecrRef(); -} - -/*! - * This method fills bbox params like that : bbox[0]=XMin, bbox[1]=XMax, bbox[2]=YMin... - * The returned bounding box is arranged along trihedron. - * @param bbox out array of size 2*this->getSpaceDimension(). - */ -void MEDCouplingPointSet::getBoundingBox(double *bbox) const -{ - int dim=getSpaceDimension(); - for (int idim=0; idim::max(); - bbox[idim*2+1]=-std::numeric_limits::max(); - } - const double *coords=_coords->getConstPointer(); - int nbnodes=getNumberOfNodes(); - for (int i=0; i coords[i*dim+idim] ) - { - bbox[idim*2] = coords[i*dim+idim] ; - } - if ( bbox[idim*2+1] < coords[i*dim+idim] ) - { - bbox[idim*2+1] = coords[i*dim+idim] ; - } - } - } -} - -/*! - * This method removes useless nodes in coords. - */ -void MEDCouplingPointSet::zipCoords() -{ - checkFullyDefined(); - DataArrayInt *traducer=zipCoordsTraducer(); - traducer->decrRef(); -} - -struct MEDCouplingCompAbs -{ - bool operator()(double x, double y) { return std::abs(x)getConstPointer(); - int nbOfValues=_coords->getNbOfElems(); - return std::abs(*std::max_element(coords,coords+nbOfValues,MEDCouplingCompAbs())); -} - -/*! - * Non const method that operates a rotation of 'this'. - * If spaceDim==2 'vector' parameter is ignored (and could be 0) and the rotation is done around 'center' with angle specified by 'angle'. - * If spaceDim==3 the rotation axe is defined by ('center','vector') and the angle is 'angle'. - * @param center an array of size getSpaceDimension(). - * @param vector in array of size getSpaceDimension(). - * @param angle angle of rotation in radian. - */ -void MEDCouplingPointSet::rotate(const double *center, const double *vector, double angle) -{ - int spaceDim=getSpaceDimension(); - if(spaceDim==3) - rotate3D(center,vector,angle); - else if(spaceDim==2) - rotate2D(center,angle); - else - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::rotate : invalid space dim for rotation must be 2 or 3"); - _coords->declareAsNew(); - updateTime(); -} - -/*! - * Non const method that operates a translation of 'this'. - * @param vector in array of size getSpaceDimension(). - */ -void MEDCouplingPointSet::translate(const double *vector) -{ - double *coords=_coords->getPointer(); - int nbNodes=getNumberOfNodes(); - int dim=getSpaceDimension(); - for(int i=0; ideclareAsNew(); - updateTime(); -} - -/*! - * Non const method that operates a scale on 'this' with 'point' as reference point of scale and with factor 'factor'. - * @param point in array of size getSpaceDimension(). - * @param factor factor of the scaling - */ -void MEDCouplingPointSet::scale(const double *point, double factor) -{ - double *coords=_coords->getPointer(); - int nbNodes=getNumberOfNodes(); - int dim=getSpaceDimension(); - double *tmp=new double[dim]; - for(int i=0;i()); - std::transform(coords+i*dim,coords+(i+1)*dim,coords+i*dim,std::bind2nd(std::multiplies(),factor)); - std::transform(coords+i*dim,coords+(i+1)*dim,point,coords+i*dim,std::plus()); - } - delete [] tmp; - _coords->declareAsNew(); - updateTime(); -} - -/*! - * This method is only available for already defined coordinates. - * If not an INTERP_KERNEL::Exception is thrown. The 'newSpaceDim' input must be greater or equal to 1. - * This method simply convert this to newSpaceDim space : - * - by putting a 0. for each \f$ i^{th} \f$ components of each coord of nodes so that i>=getSpaceDim(), if 'newSpaceDim'>getSpaceDimsion() - * - by ignoring each \f$ i^{th} \f$ components of each coord of nodes so that i >= 'newSpaceDim', 'newSpaceDim'=1 !"); - int oldSpaceDim=getSpaceDimension(); - if(newSpaceDim==oldSpaceDim) - return ; - DataArrayDouble *newCoords=getCoords()->changeNbOfComponents(newSpaceDim,dftValue); - setCoords(newCoords); - newCoords->decrRef(); - updateTime(); -} - -/*! - * This method try to substitute this->_coords with other._coords if arrays match. - * This method potentially modifies 'this' if it succeeds, otherway an exception is thrown. - */ -void MEDCouplingPointSet::tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) -{ - if(_coords==other._coords) - return ; - if(!_coords) - throw INTERP_KERNEL::Exception("Current instance has no coords whereas other has !"); - if(!other._coords) - throw INTERP_KERNEL::Exception("Other instance has no coords whereas current has !"); - if(!_coords->isEqualWithoutConsideringStr(*other._coords,epsilon)) - throw INTERP_KERNEL::Exception("Coords are not the same !"); - setCoords(other._coords); -} - -/*! - * This method is expecting to be called for meshes so that getSpaceDimension() returns 3. - * This method returns in 'nodes' output all the nodes that are at a distance lower than epsilon from plane - * defined by the point 'pt' and the vector 'vec'. - * @param pt points to an array of size 3 and represents a point that owns to plane. - * @param vec points to an array of size 3 and represents the normal vector of the plane. The norm of the vector is not compulsory equal to 1. But norm must be greater than 10*abs(eps) - * @param eps is the maximal distance around the plane where node in this->_coords will be picked. - * @param nodes is the output of the method. The vector is not compulsory empty before call. The nodes that fulfills the condition will be added at the end of the nodes. - */ -void MEDCouplingPointSet::findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector& nodes) const throw(INTERP_KERNEL::Exception) -{ - if(getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid spacedim to be applied on this ! Must be equal to 3 !"); - int nbOfNodes=getNumberOfNodes(); - double a=vec[0],b=vec[1],c=vec[2],d=-pt[0]*vec[0]-pt[1]*vec[1]-pt[2]*vec[2]; - double deno=sqrt(a*a+b*b+c*c); - const double *work=_coords->getConstPointer(); - for(int i=0;igetSpaceDimension(); - if(spaceDim!=m2->getSpaceDimension()) - throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of mergeNodesArray !"); - return DataArrayDouble::aggregate(m1->getCoords(),m2->getCoords()); -} - -/*! - * Factory to build new instance of instanciable subclasses of MEDCouplingPointSet. - * This method is used during unserialization process. - */ -MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type) -{ - switch(type) - { - case UNSTRUCTURED: - return MEDCouplingUMesh::New(); - case UNSTRUCTURED_DESC: - return MEDCouplingUMeshDesc::New(); - default: - throw INTERP_KERNEL::Exception("Invalid type of mesh specified"); - } -} - -/*! - * First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process. - */ -void MEDCouplingPointSet::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const -{ - if(_coords) - { - int spaceDim=getSpaceDimension(); - littleStrings.resize(spaceDim+1); - littleStrings[0]=getName(); - for(int i=0;igetInfoOnComponent(i); - tinyInfo.clear(); - tinyInfo.push_back(getType()); - tinyInfo.push_back(spaceDim); - tinyInfo.push_back(getNumberOfNodes()); - } - else - { - littleStrings.resize(1); - littleStrings[0]=getName(); - tinyInfo.clear(); - tinyInfo.push_back(getType()); - tinyInfo.push_back(-1); - tinyInfo.push_back(-1); - } -} - -/*! - * Third and final step of serialization process. - */ -void MEDCouplingPointSet::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const -{ - if(_coords) - { - a2=getCoords(); - a2->incrRef(); - } - else - a2=0; -} - -/*! - * Second step of serialization process. - * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. - */ -void MEDCouplingPointSet::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const -{ - if(tinyInfo[2]>=0 && tinyInfo[1]>=1) - { - a2->alloc(tinyInfo[2],tinyInfo[1]); - littleStrings.resize(tinyInfo[1]+1); - } - else - { - littleStrings.resize(1); - } -} - -/*! - * Second and final unserialization process. - * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. - */ -void MEDCouplingPointSet::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) -{ - if(tinyInfo[2]>=0 && tinyInfo[1]>=1) - { - setCoords(a2); - setName(littleStrings[0].c_str()); - for(int i=0;isetInfoOnComponent(i,littleStrings[i+1].c_str()); - } - else - setName(littleStrings[0].c_str()); -} - -/*! - * Intersect Bounding Box given 2 Bounding Boxes. - */ -bool MEDCouplingPointSet::intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps) -{ - double* bbtemp = new double[2*dim]; - double deltamax=0.0; - - for (int i=0; i< dim; i++) - { - double delta = bb1[2*i+1]-bb1[2*i]; - if ( delta > deltamax ) - { - deltamax = delta ; - } - } - for (int i=0; i deltamax ) - { - deltamax = delta ; - } - } - for (int i=0; igetPointer(); - int nbNodes=getNumberOfNodes(); - rotate3DAlg(center,vect,angle,nbNodes,coords); -} - -/*! - * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' - * around an axe ('center','vect') and with angle 'angle'. - */ -void MEDCouplingPointSet::rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords) -{ - double sina=sin(angle); - double cosa=cos(angle); - double vectorNorm[3]; - double matrix[9]; - double matrixTmp[9]; - double norm=sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2]); - std::transform(vect,vect+3,vectorNorm,std::bind2nd(std::multiplies(),1/norm)); - //rotation matrix computation - matrix[0]=cosa; matrix[1]=0.; matrix[2]=0.; matrix[3]=0.; matrix[4]=cosa; matrix[5]=0.; matrix[6]=0.; matrix[7]=0.; matrix[8]=cosa; - matrixTmp[0]=vectorNorm[0]*vectorNorm[0]; matrixTmp[1]=vectorNorm[0]*vectorNorm[1]; matrixTmp[2]=vectorNorm[0]*vectorNorm[2]; - matrixTmp[3]=vectorNorm[1]*vectorNorm[0]; matrixTmp[4]=vectorNorm[1]*vectorNorm[1]; matrixTmp[5]=vectorNorm[1]*vectorNorm[2]; - matrixTmp[6]=vectorNorm[2]*vectorNorm[0]; matrixTmp[7]=vectorNorm[2]*vectorNorm[1]; matrixTmp[8]=vectorNorm[2]*vectorNorm[2]; - std::transform(matrixTmp,matrixTmp+9,matrixTmp,std::bind2nd(std::multiplies(),1-cosa)); - std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus()); - matrixTmp[0]=0.; matrixTmp[1]=-vectorNorm[2]; matrixTmp[2]=vectorNorm[1]; - matrixTmp[3]=vectorNorm[2]; matrixTmp[4]=0.; matrixTmp[5]=-vectorNorm[0]; - matrixTmp[6]=-vectorNorm[1]; matrixTmp[7]=vectorNorm[0]; matrixTmp[8]=0.; - std::transform(matrixTmp,matrixTmp+9,matrixTmp,std::bind2nd(std::multiplies(),sina)); - std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus()); - //rotation matrix computed. - double tmp[3]; - for(int i=0; i()); - coords[i*3]=matrix[0]*tmp[0]+matrix[1]*tmp[1]+matrix[2]*tmp[2]+center[0]; - coords[i*3+1]=matrix[3]*tmp[0]+matrix[4]*tmp[1]+matrix[5]*tmp[2]+center[1]; - coords[i*3+2]=matrix[6]*tmp[0]+matrix[7]*tmp[1]+matrix[8]*tmp[2]+center[2]; - } -} - -/*! - * This method implements pure virtual method MEDCouplingMesh::buildPart. - * This method build a part of 'this' by simply keeping cells whose ids are in ['start','end'). - * The coords are kept unchanged contrary to pure virtual method MEDCouplingMesh::buildPartAndReduceNodes. - * The returned mesh has to be managed by the caller. - */ -MEDCouplingMesh *MEDCouplingPointSet::buildPart(const int *start, const int *end) const -{ - return buildPartOfMySelf(start,end,false); -} - -/*! - * This method implements pure virtual method MEDCouplingMesh::buildPartAndReduceNodes. - * This method build a part of 'this' by simply keeping cells whose ids are in ['start','end') \b and potentially reduces the nodes set - * behind returned mesh. This cause an overhead but it is lesser in memory. - * This method returns an array too. This array allows to the caller to know the mapping between nodeids in 'this' and nodeids in - * returned mesh. This is quite usefull for MEDCouplingFieldDouble on nodes for example... - * The returned mesh has to be managed by the caller. - */ -MEDCouplingMesh *MEDCouplingPointSet::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const -{ - MEDCouplingPointSet *ret=buildPartOfMySelf(start,end,true); - arr=ret->zipCoordsTraducer(); - return ret; -} - - -/*! - * 'This' is expected to be of spaceDim==2. Idem for 'center' and 'vect' - */ -void MEDCouplingPointSet::rotate2D(const double *center, double angle) -{ - double *coords=_coords->getPointer(); - int nbNodes=getNumberOfNodes(); - rotate2DAlg(center,angle,nbNodes,coords); -} - -/*! - * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' - * around the center point 'center' and with angle 'angle'. - */ -void MEDCouplingPointSet::rotate2DAlg(const double *center, double angle, int nbNodes, double *coords) -{ - double cosa=cos(angle); - double sina=sin(angle); - double matrix[4]; - matrix[0]=cosa; matrix[1]=-sina; matrix[2]=sina; matrix[3]=cosa; - double tmp[2]; - for(int i=0; i()); - coords[i*2]=matrix[0]*tmp[0]+matrix[1]*tmp[1]+center[0]; - coords[i*2+1]=matrix[2]*tmp[0]+matrix[3]*tmp[1]+center[1]; - } -} - -class DummyClsMCPS -{ -public: - static const int MY_SPACEDIM=3; - static const int MY_MESHDIM=2; - typedef int MyConnType; - static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; -}; - -/*! - * res should be an empty vector before calling this method. - * This method returns all the node coordinates included in _coords which ids are in [startConn;endConn) and put it into 'res' vector. - * If spaceDim==3 a projection will be done for each nodes on the middle plane containing these all nodes in [startConn;endConn). - * And after each projected nodes are moved to Oxy plane in order to consider these nodes as 2D nodes. - */ -void MEDCouplingPointSet::project2DCellOnXY(const int *startConn, const int *endConn, std::vector& res) const -{ - const double *coords=_coords->getConstPointer(); - int spaceDim=getSpaceDimension(); - for(const int *it=startConn;it!=endConn;it++) - res.insert(res.end(),coords+spaceDim*(*it),coords+spaceDim*(*it+1)); - if(spaceDim==2) - return ; - if(spaceDim==3) - { - std::vector cpy(res); - int nbNodes=endConn-startConn; - INTERP_KERNEL::PlanarIntersector::projection(&res[0],&cpy[0],nbNodes,nbNodes,1.e-12,0.,0.,true); - res.resize(2*nbNodes); - for(int i=0;i& res, bool isQuad) -{ - int nbOfNodes=res.size()/2; - std::vector nodes(nbOfNodes); - for(int i=0;iisButterfly(); - delete pol; - return ret; -} diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx deleted file mode 100644 index 87a4c04ec..000000000 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingMesh.hxx" - -#include - -namespace INTERP_KERNEL -{ - class DirectedBoundingBox; -} - -namespace ParaMEDMEM -{ - class DataArrayInt; - class DataArrayDouble; - - class MEDCOUPLING_EXPORT MEDCouplingPointSet : public MEDCouplingMesh - { - protected: - MEDCouplingPointSet(); - MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy); - ~MEDCouplingPointSet(); - public: - void updateTime(); - int getNumberOfNodes() const; - int getSpaceDimension() const; - void setCoords(DataArrayDouble *coords); - DataArrayDouble *getCoords() const { return _coords; } - DataArrayDouble *getCoordinatesAndOwner() const; - void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); - bool isEqual(const MEDCouplingMesh *other, double prec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const; - bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const; - virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0; - DataArrayInt *buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const; - void findCommonNodes(int limitNodeId, double prec, DataArrayInt *&comm, DataArrayInt *&commIndex) const; - DataArrayInt *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex, - int& newNbOfNodes) const; - void getBoundingBox(double *bbox) const; - void zipCoords(); - double getCaracteristicDimension() const; - void rotate(const double *center, const double *vector, double angle); - void translate(const double *vector); - void scale(const double *point, double factor); - void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception); - void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); - virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0; - void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector& nodes) const throw(INTERP_KERNEL::Exception); - static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2); - static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type); - static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords); - static void rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords); - MEDCouplingMesh *buildPart(const int *start, const int *end) const; - MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; - virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0; - virtual MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0; - virtual MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0; - virtual void findBoundaryNodes(std::vector& nodes) const = 0; - virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0; - virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); - virtual bool isEmptyMesh(const std::vector& tinyInfo) const = 0; - //! size of returned tinyInfo must be always the same. - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) = 0; - virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) = 0; - virtual DataArrayInt *zipCoordsTraducer() = 0; - protected: - virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception) = 0; - static bool intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps); - static bool intersectsBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bb1, const double* bb2, int dim, double eps); - void rotate2D(const double *center, double angle); - void rotate3D(const double *center, const double *vect, double angle); - void project2DCellOnXY(const int *startConn, const int *endConn, std::vector& res) const; - static bool isButterfly2DCell(const std::vector& res, bool isQuad); - template - void findCommonNodesAlg(std::vector& bbox, - int nbNodes, int limitNodeId, double prec, std::vector& c, std::vector& cI) const; - protected: - DataArrayDouble *_coords; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingPointSet.txx b/src/MEDCoupling/MEDCouplingPointSet.txx deleted file mode 100644 index bae195566..000000000 --- a/src/MEDCoupling/MEDCouplingPointSet.txx +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGPOINTSET_TXX__ -#define __PARAMEDMEM_MEDCOUPLINGPOINTSET_TXX__ - -#include "MEDCouplingPointSet.txx" -#include "InterpolationUtils.hxx" -#include "BBTree.txx" - -#include - -namespace ParaMEDMEM -{ - template - void MEDCouplingPointSet::findCommonNodesAlg(std::vector& bbox, - int nbNodes, int limitNodeId, double prec, - std::vector& c, std::vector& cI) const - { - const double *coordsPtr=_coords->getConstPointer(); - BBTree myTree(&bbox[0],0,0,nbNodes,-prec); - double bb[2*SPACEDIM]; - double prec2=prec*prec; - for(int i=0;i intersectingElems; - myTree.getIntersectingElems(bb,intersectingElems); - if(intersectingElems.size()>1) - { - std::vector commonNodes; - for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) - if(*it!=i) - if(*it>=limitNodeId) - if(INTERP_KERNEL::distance2(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it))incrRef(); _target_mesh->incrRef(); - int meshInterpType=((int)_src_mesh->getType()*16)+(int)_target_mesh->getType(); - switch(meshInterpType) - { - case 85://Unstructured-Unstructured - return prepareUU(method); - case 136://Extruded-Extruded - return prepareEE(method); - default: - throw INTERP_KERNEL::Exception("Not managed type of meshes !"); - } -} - -void MEDCouplingRemapper::transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception) -{ - if(_src_method!=srcField->getDiscretization()->getStringRepr()) - throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field"); - if(_target_method!=targetField->getDiscretization()->getStringRepr()) - throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field"); - if(srcField->getNature()!=targetField->getNature()) - throw INTERP_KERNEL::Exception("Natures of fields mismatch !"); - DataArrayDouble *array=targetField->getArray(); - int srcNbOfCompo=srcField->getNumberOfComponents(); - if(array) - { - if(srcNbOfCompo!=targetField->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Number of components mismatch !"); - } - else - { - array=DataArrayDouble::New(); - array->alloc(targetField->getNumberOfTuples(),srcNbOfCompo); - targetField->setArray(array); - array->decrRef(); - } - computeDeno(srcField->getNature(),srcField,targetField); - double *resPointer=array->getPointer(); - const double *inputPointer=srcField->getArray()->getConstPointer(); - computeProduct(inputPointer,srcNbOfCompo,dftValue,resPointer); -} - -void MEDCouplingRemapper::reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception) -{ - if(_src_method!=srcField->getDiscretization()->getStringRepr()) - throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field"); - if(_target_method!=targetField->getDiscretization()->getStringRepr()) - throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field"); - if(srcField->getNature()!=targetField->getNature()) - throw INTERP_KERNEL::Exception("Natures of fields mismatch !"); - DataArrayDouble *array=srcField->getArray(); - int trgNbOfCompo=targetField->getNumberOfComponents(); - if(array) - { - if(trgNbOfCompo!=srcField->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Number of components mismatch !"); - } - else - { - array=DataArrayDouble::New(); - array->alloc(srcField->getNumberOfTuples(),trgNbOfCompo); - srcField->setArray(array); - array->decrRef(); - } - computeDeno(srcField->getNature(),srcField,targetField); - double *resPointer=array->getPointer(); - const double *inputPointer=targetField->getArray()->getConstPointer(); - computeReverseProduct(inputPointer,trgNbOfCompo,dftValue,resPointer); -} - -MEDCouplingFieldDouble *MEDCouplingRemapper::transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception) -{ - if(_src_method!=srcField->getDiscretization()->getStringRepr()) - throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_target_method.c_str())); - ret->setNature(srcField->getNature()); - ret->setMesh(_target_mesh); - transfer(srcField,ret,dftValue); - return ret; -} - -MEDCouplingFieldDouble *MEDCouplingRemapper::reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception) -{ - if(_target_method!=targetField->getDiscretization()->getStringRepr()) - throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_target_method.c_str())); - ret->setNature(targetField->getNature()); - ret->setMesh(_src_mesh); - reverseTransfer(ret,targetField,dftValue); - return ret; -} - -bool MEDCouplingRemapper::setOptionInt(const std::string& key, int value) -{ - return INTERP_KERNEL::InterpolationOptions::setOptionInt(key,value); -} - -bool MEDCouplingRemapper::setOptionDouble(const std::string& key, double value) -{ - return INTERP_KERNEL::InterpolationOptions::setOptionDouble(key,value); -} - -bool MEDCouplingRemapper::setOptionString(const std::string& key, const std::string& value) -{ - return INTERP_KERNEL::InterpolationOptions::setOptionString(key,value); -} - -int MEDCouplingRemapper::prepareUU(const char *method) throw(INTERP_KERNEL::Exception) -{ - MEDCouplingUMesh *src_mesh=(MEDCouplingUMesh *)_src_mesh; - MEDCouplingUMesh *target_mesh=(MEDCouplingUMesh *)_target_mesh; - INTERP_KERNEL::Interpolation::checkAndSplitInterpolationMethod(method,_src_method,_target_method); - const int srcMeshDim=src_mesh->getMeshDimension(); - int srcSpaceDim=-1; - if(srcMeshDim!=-1) - srcSpaceDim=src_mesh->getSpaceDimension(); - const int trgMeshDim=target_mesh->getMeshDimension(); - int trgSpaceDim=-1; - if(trgMeshDim!=-1) - trgSpaceDim=target_mesh->getSpaceDimension(); - if(trgSpaceDim!=srcSpaceDim) - if(trgSpaceDim!=-1 && srcSpaceDim!=-1) - throw INTERP_KERNEL::Exception("Incoherent space dimension detected between target and source."); - int nbCols; - if(srcMeshDim==1 && trgMeshDim==1 && srcSpaceDim==1) - { - MEDCouplingNormalizedUnstructuredMesh<1,1> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<1,1> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation1D interpolation(*this); - nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - } - else if(srcMeshDim==1 && trgMeshDim==1 && srcSpaceDim==2) - { - MEDCouplingNormalizedUnstructuredMesh<2,1> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<2,1> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation2DCurve interpolation(*this); - nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - } - else if(srcMeshDim==2 && trgMeshDim==2 && srcSpaceDim==2) - { - MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation2D interpolation(*this); - nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - } - else if(srcMeshDim==3 && trgMeshDim==3 && srcSpaceDim==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); - nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - } - else if(srcMeshDim==2 && trgMeshDim==2 && srcSpaceDim==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - } - else if(srcMeshDim==3 && trgMeshDim==1 && srcSpaceDim==3) - { - if(getIntersectionType()!=INTERP_KERNEL::PointLocator) - throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !"); - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); - nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - } - else if(srcMeshDim==1 && trgMeshDim==3 && srcSpaceDim==3) - { - if(getIntersectionType()!=INTERP_KERNEL::PointLocator) - throw INTERP_KERNEL::Exception("Invalid interpolation requested between 3D and 1D ! Select PointLocator as intersection type !"); - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); - std::vector > matrixTmp; - nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method); - reverseMatrix(matrixTmp,nbCols,_matrix); - nbCols=matrixTmp.size(); - } - else if(srcMeshDim==2 && trgMeshDim==1 && srcSpaceDim==2) - { - if(getIntersectionType()!=INTERP_KERNEL::PointLocator) - throw INTERP_KERNEL::Exception("Invalid interpolation requested between 2D and 1D ! Select PointLocator as intersection type !"); - MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation2D interpolation(*this); - nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - } - else if(srcMeshDim==1 && trgMeshDim==2 && srcSpaceDim==2) - { - if(getIntersectionType()!=INTERP_KERNEL::PointLocator) - throw INTERP_KERNEL::Exception("Invalid interpolation requested between 1D and 2D ! Select PointLocator as intersection type !"); - MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation2D interpolation(*this); - std::vector > matrixTmp; - nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method); - reverseMatrix(matrixTmp,nbCols,_matrix); - nbCols=matrixTmp.size(); - } - else if(trgMeshDim==-1) - { - if(srcMeshDim==2 && srcSpaceDim==2) - { - MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh); - INTERP_KERNEL::Interpolation2D interpolation(*this); - nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,_src_method.c_str()); - } - else if(srcMeshDim==3 && srcSpaceDim==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); - nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,_src_method.c_str()); - } - else if(srcMeshDim==2 && srcSpaceDim==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh); - INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,_src_method.c_str()); - } - else - throw INTERP_KERNEL::Exception("No interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh"); - } - else if(srcMeshDim==-1) - { - if(trgMeshDim==2 && trgSpaceDim==2) - { - MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation2D interpolation(*this); - nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,_target_method.c_str()); - } - else if(trgMeshDim==3 && trgSpaceDim==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3D interpolation(*this); - nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,_target_method.c_str()); - } - else if(trgMeshDim==2 && trgSpaceDim==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(target_mesh); - INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,_target_method.c_str()); - } - else - throw INTERP_KERNEL::Exception("No interpolation available for the given mesh and space dimension of source mesh from -1D sourceMesh"); - } - else - throw INTERP_KERNEL::Exception("No interpolation available for the given mesh and space dimension"); - _deno_multiply.clear(); - _deno_multiply.resize(_matrix.size()); - _deno_reverse_multiply.clear(); - _deno_reverse_multiply.resize(nbCols); - declareAsNew(); - return 1; -} - -int MEDCouplingRemapper::prepareEE(const char *method) throw(INTERP_KERNEL::Exception) -{ - MEDCouplingExtrudedMesh *src_mesh=(MEDCouplingExtrudedMesh *)_src_mesh; - MEDCouplingExtrudedMesh *target_mesh=(MEDCouplingExtrudedMesh *)_target_mesh; - std::string methC(method); - if(methC!="P0P0") - throw INTERP_KERNEL::Exception("Only P0P0 method implemented for Extruded/Extruded meshes !"); - INTERP_KERNEL::Interpolation::checkAndSplitInterpolationMethod(method,_src_method,_target_method); - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh->getMesh2D()); - MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(target_mesh->getMesh2D()); - INTERP_KERNEL::Interpolation3DSurf interpolation2D(*this); - std::vector > matrix2D; - int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,method); - MEDCouplingUMesh *s1D,*t1D; - double v[3]; - MEDCouplingExtrudedMesh::project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v); - MEDCouplingNormalizedUnstructuredMesh<1,1> s1DWrapper(s1D); - MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D); - std::vector > matrix1D; - INTERP_KERNEL::Interpolation1D interpolation1D(*this); - int nbCols1D=interpolation1D.interpolateMeshes(s1DWrapper,t1DWrapper,matrix1D,method); - s1D->decrRef(); - t1D->decrRef(); - buildFinalInterpolationMatrixByConvolution(matrix1D,matrix2D,src_mesh->getMesh3DIds()->getConstPointer(),nbCols2D,nbCols1D, - target_mesh->getMesh3DIds()->getConstPointer()); - // - _deno_multiply.clear(); - _deno_multiply.resize(_matrix.size()); - _deno_reverse_multiply.clear(); - _deno_reverse_multiply.resize(nbCols2D*nbCols1D); - declareAsNew(); - return 1; -} - -void MEDCouplingRemapper::updateTime() -{ -} - -void MEDCouplingRemapper::releaseData(bool matrixSuppression) -{ - if(_src_mesh) - _src_mesh->decrRef(); - if(_target_mesh) - _target_mesh->decrRef(); - _src_mesh=0; - _target_mesh=0; - if(matrixSuppression) - { - _matrix.clear(); - _deno_multiply.clear(); - _deno_reverse_multiply.clear(); - } -} - -void MEDCouplingRemapper::computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) -{ - if(nat==NoNature) - return computeDenoFromScratch(nat,srcField,trgField); - else if(nat!=_nature_of_deno) - return computeDenoFromScratch(nat,srcField,trgField); - else if(nat==_nature_of_deno && _time_deno_update!=getTimeOfThis()) - return computeDenoFromScratch(nat,srcField,trgField); -} - -void MEDCouplingRemapper::computeDenoFromScratch(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) throw(INTERP_KERNEL::Exception) -{ - _nature_of_deno=nat; - _time_deno_update=getTimeOfThis(); - switch(_nature_of_deno) - { - case ConservativeVolumic: - { - computeRowSumAndColSum(_matrix,_deno_multiply,_deno_reverse_multiply); - break; - } - case Integral: - { - MEDCouplingFieldDouble *deno=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),true); - MEDCouplingFieldDouble *denoR=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),true); - const double *denoPtr=deno->getArray()->getConstPointer(); - const double *denoRPtr=denoR->getArray()->getConstPointer(); - if(trgField->getMesh()->getMeshDimension()==-1) - { - double *denoRPtr2=denoR->getArray()->getPointer(); - denoRPtr2[0]=std::accumulate(denoPtr,denoPtr+deno->getNumberOfTuples(),0.); - } - if(srcField->getMesh()->getMeshDimension()==-1) - { - double *denoPtr2=deno->getArray()->getPointer(); - denoPtr2[0]=std::accumulate(denoRPtr,denoRPtr+denoR->getNumberOfTuples(),0.); - } - int idx=0; - for(std::vector >::const_iterator iter1=_matrix.begin();iter1!=_matrix.end();iter1++,idx++) - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - { - _deno_multiply[idx][(*iter2).first]=denoPtr[(*iter2).first]; - _deno_reverse_multiply[(*iter2).first][idx]=denoRPtr[idx]; - } - deno->decrRef(); - denoR->decrRef(); - break; - } - case IntegralGlobConstraint: - { - computeColSumAndRowSum(_matrix,_deno_multiply,_deno_reverse_multiply); - break; - } - case RevIntegral: - { - MEDCouplingFieldDouble *deno=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),true); - MEDCouplingFieldDouble *denoR=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),true); - const double *denoPtr=deno->getArray()->getConstPointer(); - const double *denoRPtr=denoR->getArray()->getConstPointer(); - if(trgField->getMesh()->getMeshDimension()==-1) - { - double *denoRPtr2=denoR->getArray()->getPointer(); - denoRPtr2[0]=std::accumulate(denoPtr,denoPtr+deno->getNumberOfTuples(),0.); - } - if(srcField->getMesh()->getMeshDimension()==-1) - { - double *denoPtr2=deno->getArray()->getPointer(); - denoPtr2[0]=std::accumulate(denoRPtr,denoRPtr+denoR->getNumberOfTuples(),0.); - } - int idx=0; - for(std::vector >::const_iterator iter1=_matrix.begin();iter1!=_matrix.end();iter1++,idx++) - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - { - _deno_multiply[idx][(*iter2).first]=denoPtr[idx]; - _deno_reverse_multiply[(*iter2).first][idx]=denoRPtr[(*iter2).first]; - } - deno->decrRef(); - denoR->decrRef(); - break; - } - case NoNature: - throw INTERP_KERNEL::Exception("No nature specified ! Select one !"); - } -} - -void MEDCouplingRemapper::computeProduct(const double *inputPointer, int inputNbOfCompo, double dftValue, double *resPointer) -{ - int idx=0; - double *tmp=new double[inputNbOfCompo]; - for(std::vector >::const_iterator iter1=_matrix.begin();iter1!=_matrix.end();iter1++,idx++) - { - if((*iter1).empty()) - { - std::fill(resPointer+idx*inputNbOfCompo,resPointer+(idx+1)*inputNbOfCompo,dftValue); - continue; - } - else - std::fill(resPointer+idx*inputNbOfCompo,resPointer+(idx+1)*inputNbOfCompo,0.); - std::map::const_iterator iter3=_deno_multiply[idx].begin(); - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++,iter3++) - { - std::transform(inputPointer+(*iter2).first*inputNbOfCompo,inputPointer+((*iter2).first+1)*inputNbOfCompo,tmp,std::bind2nd(std::multiplies(),(*iter2).second/(*iter3).second)); - std::transform(tmp,tmp+inputNbOfCompo,resPointer+idx*inputNbOfCompo,resPointer+idx*inputNbOfCompo,std::plus()); - } - } - delete [] tmp; -} - -void MEDCouplingRemapper::computeReverseProduct(const double *inputPointer, int inputNbOfCompo, double dftValue, double *resPointer) -{ - std::vector isReached(_deno_reverse_multiply.size(),false); - int idx=0; - double *tmp=new double[inputNbOfCompo]; - std::fill(resPointer,resPointer+inputNbOfCompo*_deno_reverse_multiply.size(),0.); - for(std::vector >::const_iterator iter1=_matrix.begin();iter1!=_matrix.end();iter1++,idx++) - { - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - { - isReached[(*iter2).first]=true; - std::transform(inputPointer+idx*inputNbOfCompo,inputPointer+(idx+1)*inputNbOfCompo,tmp,std::bind2nd(std::multiplies(),(*iter2).second/_deno_reverse_multiply[(*iter2).first][idx])); - std::transform(tmp,tmp+inputNbOfCompo,resPointer+((*iter2).first)*inputNbOfCompo,resPointer+((*iter2).first)*inputNbOfCompo,std::plus()); - } - } - delete [] tmp; - idx=0; - for(std::vector::const_iterator iter3=isReached.begin();iter3!=isReached.end();iter3++,idx++) - if(!*iter3) - std::fill(resPointer+idx*inputNbOfCompo,resPointer+(idx+1)*inputNbOfCompo,dftValue); -} - -void MEDCouplingRemapper::reverseMatrix(const std::vector >& matIn, int nbColsMatIn, std::vector >& matOut) -{ - matOut.resize(nbColsMatIn); - int id=0; - for(std::vector >::const_iterator iter1=matIn.begin();iter1!=matIn.end();iter1++,id++) - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - matOut[(*iter2).first][id]=(*iter2).second; -} - -void MEDCouplingRemapper::computeRowSumAndColSum(const std::vector >& matrixDeno, - std::vector >& deno, std::vector >& denoReverse) -{ - std::map values; - int idx=0; - for(std::vector >::const_iterator iter1=matrixDeno.begin();iter1!=matrixDeno.end();iter1++,idx++) - { - double sum=0.; - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - { - sum+=(*iter2).second; - values[(*iter2).first]+=(*iter2).second; - } - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - deno[idx][(*iter2).first]=sum; - } - idx=0; - for(std::vector >::const_iterator iter1=matrixDeno.begin();iter1!=matrixDeno.end();iter1++,idx++) - { - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - denoReverse[(*iter2).first][idx]=values[(*iter2).first]; - } -} - -void MEDCouplingRemapper::computeColSumAndRowSum(const std::vector >& matrixDeno, - std::vector >& deno, std::vector >& denoReverse) -{ - std::map values; - int idx=0; - for(std::vector >::const_iterator iter1=matrixDeno.begin();iter1!=matrixDeno.end();iter1++,idx++) - { - double sum=0.; - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - { - sum+=(*iter2).second; - values[(*iter2).first]+=(*iter2).second; - } - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - denoReverse[(*iter2).first][idx]=sum; - } - idx=0; - for(std::vector >::const_iterator iter1=matrixDeno.begin();iter1!=matrixDeno.end();iter1++,idx++) - { - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - deno[idx][(*iter2).first]=values[(*iter2).first]; - } -} - -void MEDCouplingRemapper::buildFinalInterpolationMatrixByConvolution(const std::vector< std::map >& m1D, - const std::vector< std::map >& m2D, - const int *corrCellIdSrc, int nbOf2DCellsSrc, int nbOf1DCellsSrc, - const int *corrCellIdTrg) -{ - int nbOf2DCellsTrg=m2D.size(); - int nbOf1DCellsTrg=m1D.size(); - int nbOf3DCellsTrg=nbOf2DCellsTrg*nbOf1DCellsTrg; - _matrix.resize(nbOf3DCellsTrg); - int id2R=0; - for(std::vector< std::map >::const_iterator iter2R=m2D.begin();iter2R!=m2D.end();iter2R++,id2R++) - { - for(std::map::const_iterator iter2C=(*iter2R).begin();iter2C!=(*iter2R).end();iter2C++) - { - int id1R=0; - for(std::vector< std::map >::const_iterator iter1R=m1D.begin();iter1R!=m1D.end();iter1R++,id1R++) - { - for(std::map::const_iterator iter1C=(*iter1R).begin();iter1C!=(*iter1R).end();iter1C++) - { - _matrix[corrCellIdTrg[id1R*nbOf2DCellsTrg+id2R]][corrCellIdSrc[(*iter1C).first*nbOf2DCellsSrc+(*iter2C).first]]=(*iter1C).second*((*iter2C).second); - } - } - } - } -} - -void MEDCouplingRemapper::printMatrix(const std::vector >& m) -{ - int id=0; - for(std::vector >::const_iterator iter1=m.begin();iter1!=m.end();iter1++,id++) - { - std::cout << "Target Cell # " << id << " : "; - for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - std::cout << "(" << (*iter2).first << "," << (*iter2).second << "), "; - std::cout << std::endl; - } -} diff --git a/src/MEDCoupling/MEDCouplingRemapper.hxx b/src/MEDCoupling/MEDCouplingRemapper.hxx deleted file mode 100644 index 14d402d03..000000000 --- a/src/MEDCoupling/MEDCouplingRemapper.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "InterpolationOptions.hxx" -#include "MEDCouplingNatureOfField.hxx" -#include "InterpKernelException.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class MEDCouplingMesh; - class MEDCouplingUMesh; - class MEDCouplingFieldDouble; -} - -namespace ParaMEDMEM -{ - class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions - { - public: - MEDCOUPLINGREMAPPER_EXPORT MEDCouplingRemapper(); - MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper(); - MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception); - MEDCOUPLINGREMAPPER_EXPORT void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception); - MEDCOUPLINGREMAPPER_EXPORT void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception); - MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception); - MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception); - MEDCOUPLINGREMAPPER_EXPORT bool setOptionInt(const std::string& key, int value); - MEDCOUPLINGREMAPPER_EXPORT bool setOptionDouble(const std::string& key, double value); - MEDCOUPLINGREMAPPER_EXPORT bool setOptionString(const std::string& key, const std::string& value); - public: - MEDCOUPLINGREMAPPER_EXPORT static void printMatrix(const std::vector >& m); - private: - int prepareUU(const char *method) throw(INTERP_KERNEL::Exception); - int prepareEE(const char *method) throw(INTERP_KERNEL::Exception); - void updateTime(); - void releaseData(bool matrixSuppression); - void computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField); - void computeDenoFromScratch(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) throw(INTERP_KERNEL::Exception); - void computeProduct(const double *inputPointer, int inputNbOfCompo, double dftValue, double *resPointer); - void computeReverseProduct(const double *inputPointer, int inputNbOfCompo, double dftValue, double *resPointer); - void buildFinalInterpolationMatrixByConvolution(const std::vector< std::map >& m1D, - const std::vector< std::map >& m2D, - const int *corrCellIdSrc, int nbOf2DCellsSrc, int nbOf1DCellsSrc, - const int *corrCellIdTrg); - static void reverseMatrix(const std::vector >& matIn, int nbColsMatIn, - std::vector >& matOut); - static void computeRowSumAndColSum(const std::vector >& matrixDeno, - std::vector >& deno, std::vector >& denoReverse); - static void computeColSumAndRowSum(const std::vector >& matrixDeno, - std::vector >& deno, std::vector >& denoReverse); - private: - MEDCouplingMesh *_src_mesh; - MEDCouplingMesh *_target_mesh; - std::string _src_method; - std::string _target_method; - NatureOfField _nature_of_deno; - unsigned int _time_deno_update; - std::vector > _matrix; - std::vector > _deno_multiply; - std::vector > _deno_reverse_multiply; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx deleted file mode 100644 index c9c8a41d2..000000000 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ /dev/null @@ -1,2014 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingTimeDiscretization.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingAutoRefCountObjectPtr.hxx" - -#include -#include -#include - -using namespace ParaMEDMEM; - -const double MEDCouplingTimeDiscretization::TIME_TOLERANCE_DFT=1.e-12; - -const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached."; - -const char MEDCouplingNoTimeLabel::REPR[]="No time label defined."; - -const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time."; - -const char MEDCouplingWithTimeStep::REPR[]="One time label."; - -const char MEDCouplingConstOnTimeInterval::EXCEPTION_MSG[]="No data on this time."; - -const char MEDCouplingConstOnTimeInterval::REPR[]="Constant on a time interval."; - -const char MEDCouplingTwoTimeSteps::EXCEPTION_MSG[]="No data on this time."; - -const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps."; - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type) -{ - switch(type) - { - case MEDCouplingNoTimeLabel::DISCRETIZATION: - return new MEDCouplingNoTimeLabel; - case MEDCouplingWithTimeStep::DISCRETIZATION: - return new MEDCouplingWithTimeStep; - case MEDCouplingConstOnTimeInterval::DISCRETIZATION: - return new MEDCouplingConstOnTimeInterval; - case MEDCouplingLinearTime::DISCRETIZATION: - return new MEDCouplingLinearTime; - default: - throw INTERP_KERNEL::Exception("Time discretization not implemented yet"); - } -} - -void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) -{ - _time_tolerance=other._time_tolerance; -} - -void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) -{ - if(_array && other._array) - _array->copyStringInfoFrom(*other._array); -} - -void MEDCouplingTimeDiscretization::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - if(!_array) - throw INTERP_KERNEL::Exception("Field invalid because no values set !"); - if(_time_tolerance<0.) - throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !"); -} - -void MEDCouplingTimeDiscretization::updateTime() -{ - if(_array) - updateTimeWith(*_array); -} - -bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) - return false; - if(_array==0 && other->_array==0) - return true; - if(_array==0 || other->_array==0) - return false; - if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents()) - return false; - return true; -} - -bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) - return false; - if(_array==0 && other->_array==0) - return true; - if(_array==0 || other->_array==0) - return false; - if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents()) - return false; - if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples()) - return false; - return true; -} - -bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) - return false; - if(_array==0 && other->_array==0) - return true; - if(_array==0 || other->_array==0) - return false; - int nbC1=_array->getNumberOfComponents(); - int nbC2=other->_array->getNumberOfComponents(); - int nbMin=std::min(nbC1,nbC2); - if(nbC1!=nbC2 && nbMin!=1) - return false; - return true; -} - -bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const -{ - if(!areStrictlyCompatible(other)) - return false; - if(_array==other->_array) - return true; - return _array->isEqual(*other->_array,prec); -} - -bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const -{ - if(!areStrictlyCompatible(other)) - return false; - if(_array==other->_array) - return true; - return _array->isEqualWithoutConsideringStr(*other->_array,prec); -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other, - TypeOfTimeDiscretization type, bool deepCpy) const -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type); - DataArrayDouble *arrSrc=getArray(); - DataArrayDouble *arr=0; - if(arrSrc) - arr=arrSrc->performCpy(deepCpy); - else - arr=0; - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - if(_array) - { - tinyInfo.push_back(_array->getNumberOfTuples()); - tinyInfo.push_back(_array->getNumberOfComponents()); - } - else - { - tinyInfo.push_back(-1); - tinyInfo.push_back(-1); - } -} - -void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays) -{ - arrays.resize(1); - if(_array!=0) - _array->decrRef(); - DataArrayDouble *arr=0; - if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) - { - arr=DataArrayDouble::New(); - arr->alloc(tinyInfoI[0],tinyInfoI[1]); - } - _array=arr; - arrays[0]=arr; -} - -void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) -{ - _time_tolerance=tinyInfoD[0]; - int nbOfCompo=_array->getNumberOfComponents(); - for(int i=0;isetInfoOnComponent(i,tinyInfoS[i].c_str()); -} - -void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - tinyInfo.push_back(_time_tolerance); -} - -void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector& tinyInfo) const -{ - int nbOfCompo=_array->getNumberOfComponents(); - for(int i=0;igetInfoOnComponent(i)); -} - -MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0) -{ -} - -MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_tolerance(other._time_tolerance) -{ - if(other._array) - _array=other._array->performCpy(deepCpy); - else - _array=0; -} - -MEDCouplingTimeDiscretization::~MEDCouplingTimeDiscretization() -{ - if(_array) - _array->decrRef(); -} - -void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner) -{ - if(array!=_array) - { - if(_array) - _array->decrRef(); - _array=array; - if(_array) - _array->incrRef(); - if(owner) - owner->declareAsNew(); - } -} - -DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const -{ - throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !"); -} - -void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner) -{ - throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !"); -} - -void MEDCouplingTimeDiscretization::setArrays(const std::vector& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception) -{ - if(arrays.size()!=1) - throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one."); - setArray(arrays.back(),owner); -} - -void MEDCouplingTimeDiscretization::getArrays(std::vector& arrays) const -{ - arrays.resize(1); - arrays[0]=_array; -} - -bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) -{ - int iteration,order; - double time1=getEndTime(iteration,order)-_time_tolerance; - double time2=other->getStartTime(iteration,order)+other->getTimeTolerance(); - return time1<=time2; -} - -bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) -{ - int iteration,order; - double time1=getEndTime(iteration,order)+_time_tolerance; - double time2=other->getStartTime(iteration,order)-other->getTimeTolerance(); - return time1 arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->doublyContractedProduct(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->determinant(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->eigenValues(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->eigenVectors(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->inverse(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->trace(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->deviator(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->magnitude(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->maxPerTuple(); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - ret->setArrays(arrays3,0); - return ret; -} - -void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception) -{ - std::vector arrays; - getArrays(arrays); - std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue); - else - arrays2[j]=0; - } - std::vector arrays3(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - arrays3[j]=arrays2[j]; - setArrays(arrays3,0); -} - -void MEDCouplingTimeDiscretization::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception) -{ - std::vector arrays; - getArrays(arrays); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays[j]->sortPerTuple(asc); - } -} - -void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId) -{ - std::vector arrays; - getArrays(arrays); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays[j]->applyLin(a,b,compoId); - } -} - -void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func) -{ - std::vector arrays; - getArrays(arrays); - std::vector arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->applyFunc(nbOfComp,func); - else - arrays2[j]=0; - } - setArrays(arrays2,0); - for(int j=0;j<(int)arrays.size();j++) - if(arrays2[j]) - arrays2[j]->decrRef(); -} - -void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func) -{ - std::vector arrays; - getArrays(arrays); - std::vector arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->applyFunc(nbOfComp,func); - else - arrays2[j]=0; - } - setArrays(arrays2,0); - for(int j=0;j<(int)arrays.size();j++) - if(arrays2[j]) - arrays2[j]->decrRef(); -} - -void MEDCouplingTimeDiscretization::applyFunc(const char *func) -{ - std::vector arrays; - getArrays(arrays); - std::vector arrays2(arrays.size()); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays2[j]=arrays[j]->applyFunc(func); - else - arrays2[j]=0; - } - setArrays(arrays2,0); - for(int j=0;j<(int)arrays.size();j++) - if(arrays2[j]) - arrays2[j]->decrRef(); -} - -void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func) -{ - std::vector arrays; - getArrays(arrays); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays[j]->applyFuncFast32(func); - } -} - -void MEDCouplingTimeDiscretization::applyFuncFast64(const char *func) -{ - std::vector arrays; - getArrays(arrays); - for(int j=0;j<(int)arrays.size();j++) - { - if(arrays[j]) - arrays[j]->applyFuncFast64(func); - } -} - -MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel() -{ -} - -MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy) -{ -} - -std::string MEDCouplingNoTimeLabel::getStringRepr() const -{ - std::ostringstream stream; - stream << REPR; - return stream.str(); -} - -bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatible(other)) - return false; - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other)) - return false; - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) - return false; - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - return false; - return MEDCouplingTimeDiscretization::isEqual(other,prec); -} - -bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - return false; - return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec); -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setTimeTolerance(getTimeTolerance()); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !"); - getArray()->addEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !"); - getArray()->substractEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !"); - getArray()->multiplyEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !"); - getArray()->divideEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const -{ - return new MEDCouplingNoTimeLabel(*this,deepCpy); -} - -void MEDCouplingNoTimeLabel::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector& vals, double *res) const -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy), - _time(other._time),_iteration(other._iteration),_order(other._order) -{ -} - -MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_iteration(-1),_order(-1) -{ -} - -std::string MEDCouplingWithTimeStep::getStringRepr() const -{ - std::ostringstream stream; - stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << "."; - return stream.str(); -} - -void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo); - tinyInfo.push_back(_iteration); - tinyInfo.push_back(_order); -} - -void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo); - tinyInfo.push_back(_time); -} - -void MEDCouplingWithTimeStep::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) -{ - MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS); - _time=tinyInfoD[1]; - _iteration=tinyInfoI[2]; - _order=tinyInfoI[3]; -} - -bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatible(other)) - return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other)) - return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) - return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_iteration!=otherC->_iteration) - return false; - if(_order!=otherC->_order) - return false; - if(std::fabs(_time-otherC->_time)>_time_tolerance) - return false; - return MEDCouplingTimeDiscretization::isEqual(other,prec); -} - -bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_iteration!=otherC->_iteration) - return false; - if(_order!=otherC->_order) - return false; - if(std::fabs(_time-otherC->_time)>_time_tolerance) - return false; - return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec); -} - -void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) -{ - MEDCouplingTimeDiscretization::copyTinyAttrFrom(other); - const MEDCouplingWithTimeStep& otherC=dynamic_cast(other); - _time=otherC._time; - _iteration=otherC._iteration; - _order=otherC._order; -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setTimeTolerance(getTimeTolerance()); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !"); - getArray()->addEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !"); - getArray()->substractEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !"); - getArray()->multiplyEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !"); - getArray()->divideEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const -{ - return new MEDCouplingWithTimeStep(*this,deepCpy); -} - -void MEDCouplingWithTimeStep::checkNoTimePresence() const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("No time specified on a field defined on one time"); -} - -void MEDCouplingWithTimeStep::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) -{ - if(std::fabs(time-_time)>_time_tolerance) - { - std::ostringstream stream; - stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !"; - throw INTERP_KERNEL::Exception(stream.str().c_str()); - } -} - -std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) -{ - if(std::fabs(time-_time)<=_time_tolerance) - { - std::vector< const DataArrayDouble *> ret(1); - ret[0]=_array; - return ret; - } - else - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector& vals, double *res) const -{ - std::copy(vals.begin(),vals.end(),res); -} - -void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) -{ - if(std::fabs(time-_time)<=_time_tolerance) - if(_array) - _array->getTuple(eltId,value); - else - throw INTERP_KERNEL::Exception("No array existing."); - else - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception) -{ - if(_iteration==iteration && _order==order) - if(_array) - _array->getTuple(eltId,value); - else - throw INTERP_KERNEL::Exception("No array existing."); - else - throw INTERP_KERNEL::Exception("No data on this discrete time."); -} - -MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1) -{ -} - -void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) -{ - MEDCouplingTimeDiscretization::copyTinyAttrFrom(other); - const MEDCouplingConstOnTimeInterval& otherC=dynamic_cast(other); - _start_time=otherC._start_time; - _end_time=otherC._end_time; - _start_iteration=otherC._start_iteration; - _end_iteration=otherC._end_iteration; - _start_order=otherC._start_order; - _end_order=otherC._end_order; -} - -void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo); - tinyInfo.push_back(_start_iteration); - tinyInfo.push_back(_start_order); - tinyInfo.push_back(_end_iteration); - tinyInfo.push_back(_end_order); -} - -void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo); - tinyInfo.push_back(_start_time); - tinyInfo.push_back(_end_time); -} - -void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) -{ - MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS); - _start_time=tinyInfoD[1]; - _end_time=tinyInfoD[2]; - _start_iteration=tinyInfoI[2]; - _start_order=tinyInfoI[3]; - _end_iteration=tinyInfoI[4]; - _end_order=tinyInfoI[5]; -} - -MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy): - MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration), - _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order) -{ -} - -std::string MEDCouplingConstOnTimeInterval::getStringRepr() const -{ - std::ostringstream stream; - stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n"; - stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n"; - return stream.str(); -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const -{ - return new MEDCouplingConstOnTimeInterval(*this,deepCpy); -} - -std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) -{ - if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance) - { - std::vector< const DataArrayDouble *> ret(1); - ret[0]=_array; - return ret; - } - else - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector& vals, double *res) const -{ - std::copy(vals.begin(),vals.end(),res); -} - -bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatible(other)) - return false; - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other)) - return false; - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other)) - return false; - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingConstOnTimeInterval::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_start_iteration!=otherC->_start_iteration) - return false; - if(_start_order!=otherC->_start_order) - return false; - if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance) - return false; - if(_end_iteration!=otherC->_end_iteration) - return false; - if(_end_order!=otherC->_end_order) - return false; - if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance) - return false; - return MEDCouplingTimeDiscretization::isEqual(other,prec); -} - -bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_start_iteration!=otherC->_start_iteration) - return false; - if(_start_order!=otherC->_start_order) - return false; - if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance) - return false; - if(_end_iteration!=otherC->_end_iteration) - return false; - if(_end_order!=otherC->_end_order) - return false; - if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance) - return false; - return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec); -} - -void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) -{ - if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance) - if(_array) - _array->getTuple(eltId,value); - else - throw INTERP_KERNEL::Exception("No array existing."); - else - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception) -{ - if(iteration>=_start_iteration && iteration<=_end_iteration) - if(_array) - _array->getTuple(eltId,value); - else - throw INTERP_KERNEL::Exception("No array existing."); - else - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval"); -} - -void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) -{ - if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance) - { - std::ostringstream stream; - stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance "; - stream << _time_tolerance << " and trying to access on time = " << time; - throw INTERP_KERNEL::Exception(stream.str().c_str()); - } -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setTimeTolerance(getTimeTolerance()); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - tmp3=getEndTime(tmp1,tmp2); - ret->setEndTime(tmp3,tmp1,tmp2); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - tmp3=getEndTime(tmp1,tmp2); - ret->setEndTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !"); - getArray()->addEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - tmp3=getEndTime(tmp1,tmp2); - ret->setEndTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !"); - getArray()->substractEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - tmp3=getEndTime(tmp1,tmp2); - ret->setEndTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !"); - getArray()->multiplyEqual(other->getArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); - ret->setArray(arr,0); - arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - tmp3=getEndTime(tmp1,tmp2); - ret->setEndTime(tmp3,tmp1,tmp2); - return ret; -} - -void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !"); - getArray()->divideEqual(other->getArray()); -} - -MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy), - _start_time(other._start_time),_end_time(other._end_time), - _start_iteration(other._start_iteration),_end_iteration(other._end_iteration), - _start_order(other._start_order),_end_order(other._end_order) -{ - if(other._end_array) - _end_array=other._end_array->performCpy(deepCpy); - else - _end_array=0; -} - -void MEDCouplingTwoTimeSteps::updateTime() -{ - MEDCouplingTimeDiscretization::updateTime(); - if(_end_array) - updateTimeWith(*_end_array); -} - -void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) -{ - MEDCouplingTimeDiscretization::copyTinyAttrFrom(other); - const MEDCouplingTwoTimeSteps& otherC=dynamic_cast(other); - _start_time=otherC._start_time; - _end_time=otherC._end_time; - _start_iteration=otherC._start_iteration; - _end_iteration=otherC._end_iteration; - _start_order=otherC._start_order; - _end_order=otherC._end_order; -} - -void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) -{ - MEDCouplingTimeDiscretization::copyTinyStringsFrom(other); - const MEDCouplingTwoTimeSteps* otherC=dynamic_cast(&other); - if(!otherC) - throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !"); - if(_end_array && otherC->_end_array) - _end_array->copyStringInfoFrom(*otherC->_end_array); -} - -DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const -{ - return _end_array; -} - -void MEDCouplingTwoTimeSteps::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTimeDiscretization::checkCoherency(); - if(!_end_array) - throw INTERP_KERNEL::Exception("No end array specified !"); - if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !"); - if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !"); -} - -bool MEDCouplingTwoTimeSteps::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingTwoTimeSteps *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_start_iteration!=otherC->_start_iteration) - return false; - if(_end_iteration!=otherC->_end_iteration) - return false; - if(_start_order!=otherC->_start_order) - return false; - if(_end_order!=otherC->_end_order) - return false; - if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance) - return false; - if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance) - return false; - if(_end_array!=otherC->_end_array) - if(!_end_array->isEqual(*otherC->_end_array,prec)) - return false; - return MEDCouplingTimeDiscretization::isEqual(other,prec); -} - -bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingTwoTimeSteps *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_start_iteration!=otherC->_start_iteration) - return false; - if(_end_iteration!=otherC->_end_iteration) - return false; - if(_start_order!=otherC->_start_order) - return false; - if(_end_order!=otherC->_end_order) - return false; - if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance) - return false; - if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance) - return false; - if(_end_array!=otherC->_end_array) - if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec)) - return false; - return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec); -} - -MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0) -{ -} - -MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps() -{ - if(_end_array) - _end_array->decrRef(); -} - -void MEDCouplingTwoTimeSteps::checkNoTimePresence() const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !"); -} - -void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) -{ - if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance) - { - std::ostringstream stream; - stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance "; - stream << _time_tolerance << " and trying to access on time = " << time; - throw INTERP_KERNEL::Exception(stream.str().c_str()); - } -} - -void MEDCouplingTwoTimeSteps::getArrays(std::vector& arrays) const -{ - arrays.resize(2); - arrays[0]=_array; - arrays[1]=_end_array; -} - -void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner) -{ - if(array!=_end_array) - { - if(_end_array) - _end_array->decrRef(); - _end_array=array; - if(_end_array) - _end_array->incrRef(); - if(owner) - owner->declareAsNew(); - } -} - -void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo); - tinyInfo.push_back(_start_iteration); - tinyInfo.push_back(_start_order); - tinyInfo.push_back(_end_iteration); - tinyInfo.push_back(_end_order); - if(_end_array) - { - tinyInfo.push_back(_end_array->getNumberOfTuples()); - tinyInfo.push_back(_end_array->getNumberOfComponents()); - } - else - { - tinyInfo.push_back(-1); - tinyInfo.push_back(-1); - } -} - -void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo); - tinyInfo.push_back(_start_time); - tinyInfo.push_back(_end_time); -} - -void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector& tinyInfo) const -{ - int nbOfCompo=_array->getNumberOfComponents(); - for(int i=0;igetInfoOnComponent(i)); - for(int i=0;igetInfoOnComponent(i)); -} - -void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays) -{ - arrays.resize(2); - if(_array!=0) - _array->decrRef(); - if(_end_array!=0) - _end_array->decrRef(); - DataArrayDouble *arr=0; - if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) - { - arr=DataArrayDouble::New(); - arr->alloc(tinyInfoI[0],tinyInfoI[1]); - } - _array=arr; - arrays[0]=arr; - arr=0; - if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1) - { - arr=DataArrayDouble::New(); - arr->alloc(tinyInfoI[6],tinyInfoI[7]); - } - _end_array=arr; - arrays[1]=arr; -} - -void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) -{ - MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS); - _start_time=tinyInfoD[1]; - _end_time=tinyInfoD[2]; - _start_iteration=tinyInfoI[2]; - _start_order=tinyInfoI[3]; - _end_iteration=tinyInfoI[4]; - _end_order=tinyInfoI[5]; -} - -std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) -{ - if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance) - { - std::vector< const DataArrayDouble *> ret(2); - ret[0]=_array; - ret[1]=_end_array; - return ret; - } - else - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingTwoTimeSteps::setArrays(const std::vector& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception) -{ - if(arrays.size()!=2) - throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two."); - setArray(arrays.front(),owner); - setEndArray(arrays.back(),owner); -} - -MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy):MEDCouplingTwoTimeSteps(other,deepCpy) -{ -} - -MEDCouplingLinearTime::MEDCouplingLinearTime() -{ -} - -std::string MEDCouplingLinearTime::getStringRepr() const -{ - std::ostringstream stream; - stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n"; - stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n"; - return stream.str(); -} - -void MEDCouplingLinearTime::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - MEDCouplingTwoTimeSteps::checkCoherency(); - if(std::fabs(_start_time-_end_time)<_time_tolerance) - throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance."); -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const -{ - return new MEDCouplingLinearTime(*this,deepCpy); -} - -bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatible(other)) - return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other)) - return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) - return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - return otherC!=0; -} - -/*! - * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples() - */ -void MEDCouplingLinearTime::getValueForTime(double time, const std::vector& vals, double *res) const -{ - double alpha=(_end_time-time)/(_end_time-_start_time); - int nbComp=vals.size()/2; - std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies(),alpha)); - std::vector tmp(nbComp); - std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies(),1-alpha)); - std::transform(tmp.begin(),tmp.end(),res,res,std::plus()); -} - -void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) -{ - double alpha=(_end_time-time)/(_end_time-_start_time); - int nbComp; - if(_array) - _array->getTuple(eltId,value); - else - throw INTERP_KERNEL::Exception("No start array existing."); - nbComp=_array->getNumberOfComponents(); - std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies(),alpha)); - std::vector tmp(nbComp); - if(_end_array) - _end_array->getTuple(eltId,&tmp[0]); - else - throw INTERP_KERNEL::Exception("No end array existing."); - std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies(),1-alpha)); - std::transform(tmp.begin(),tmp.end(),value,value,std::plus()); -} - -void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception) -{ - if(iteration==_start_iteration && order==_start_order) - { - if(_array) - _array->getTuple(eltId,value); - else - throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing."); - } - if(iteration==_end_iteration && order==_end_order) - { - if(_end_array) - _end_array->getTuple(eltId,value); - else - throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing."); - } - else - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - ret->setTimeTolerance(getTimeTolerance()); - DataArrayDouble *arr1=DataArrayDouble::aggregate(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::aggregate(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::dot(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::dot(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::crossProduct(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::crossProduct(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::max(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::max(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::min(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::min(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::add(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::add(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); - getArray()->addEqual(other->getArray()); - getEndArray()->addEqual(other->getEndArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::substract(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::substract(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); - getArray()->substractEqual(other->getArray()); - getEndArray()->substractEqual(other->getEndArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::multiply(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::multiply(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); - getArray()->multiplyEqual(other->getArray()); - getEndArray()->multiplyEqual(other->getEndArray()); -} - -MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::divide(getArray(),other->getArray()); - ret->setArray(arr1,0); - arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::divide(getEndArray(),other->getEndArray()); - ret->setEndArray(arr2,0); - arr2->decrRef(); - return ret; -} - -void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other) -{ - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); - getArray()->divideEqual(other->getArray()); - getEndArray()->divideEqual(other->getEndArray()); -} diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx deleted file mode 100644 index a9f1de097..000000000 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "InterpKernelException.hxx" - -#include - -namespace ParaMEDMEM -{ - class DataArrayDouble; - class TimeLabel; - - class MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization : public TimeLabel - { - protected: - MEDCouplingTimeDiscretization(); - MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy); - public: - void updateTime(); - static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type); - virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); - virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other); - virtual void checkCoherency() const throw(INTERP_KERNEL::Exception); - virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const; - virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; - virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; - virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; - virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; - virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other, - TypeOfTimeDiscretization type, bool deepCpy) const; - virtual std::string getStringRepr() const = 0; - virtual TypeOfTimeDiscretization getEnum() const = 0; - virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0; - virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const = 0; - virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const = 0; - virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const = 0; - virtual MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const = 0; - virtual MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const = 0; - virtual void addEqual(const MEDCouplingTimeDiscretization *other) = 0; - virtual MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const = 0; - virtual void substractEqual(const MEDCouplingTimeDiscretization *other) = 0; - virtual MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const = 0; - virtual void multiplyEqual(const MEDCouplingTimeDiscretization *other) = 0; - virtual MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const = 0; - virtual void divideEqual(const MEDCouplingTimeDiscretization *other) = 0; - virtual void getTinySerializationIntInformation(std::vector& tinyInfo) const; - virtual void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - virtual void getTinySerializationStrInformation(std::vector& tinyInfo) const; - virtual void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); - virtual void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0; - void setTimeTolerance(double val) { _time_tolerance=val; } - double getTimeTolerance() const { return _time_tolerance; } - virtual void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) = 0; - virtual void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) = 0; - virtual void setArray(DataArrayDouble *array, TimeLabel *owner); - virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner); - virtual void setArrays(const std::vector& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getArray() const { return _array; } - virtual DataArrayDouble *getEndArray() const; - virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) = 0; - virtual void getValueForTime(double time, const std::vector& vals, double *res) const = 0; - virtual void getArrays(std::vector& arrays) const; - virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception); - virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception); - double getTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { return getStartTime(iteration,order); } - virtual double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0; - virtual double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0; - void setTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { setStartTime(time,iteration,order); } - virtual void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0; - virtual void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0; - virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0; - virtual void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception) = 0; - // - virtual MEDCouplingTimeDiscretization *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *determinant() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *eigenValues() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *eigenVectors() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *inverse() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *trace() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *deviator() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *magnitude() const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingTimeDiscretization *maxPerTuple() const throw(INTERP_KERNEL::Exception); - virtual void changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception); - virtual void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - virtual void applyLin(double a, double b, int compoId); - virtual void applyFunc(int nbOfComp, FunctionToEvaluate func); - virtual void applyFunc(int nbOfComp, const char *func); - virtual void applyFunc(const char *func); - virtual void applyFuncFast32(const char *func); - virtual void applyFuncFast64(const char *func); - - // - virtual ~MEDCouplingTimeDiscretization(); - protected: - double _time_tolerance; - DataArrayDouble *_array; - protected: - static const double TIME_TOLERANCE_DFT; - }; - - class MEDCOUPLING_EXPORT MEDCouplingNoTimeLabel : public MEDCouplingTimeDiscretization - { - public: - MEDCouplingNoTimeLabel(); - MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy); - std::string getStringRepr() const; - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - void divideEqual(const MEDCouplingTimeDiscretization *other); - bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; - bool areCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const; - void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { } - void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); - std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); - void getValueForTime(double time, const std::vector& vals, double *res) const; - bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception); - bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception); - double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception); - double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception); - void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception); - void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception); - void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); - void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception); - public: - static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME; - static const char REPR[]; - private: - static const char EXCEPTION_MSG[]; - }; - - class MEDCOUPLING_EXPORT MEDCouplingWithTimeStep : public MEDCouplingTimeDiscretization - { - protected: - MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy); - public: - MEDCouplingWithTimeStep(); - std::string getStringRepr() const; - void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - void divideEqual(const MEDCouplingTimeDiscretization *other); - bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; - bool areCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; - void getTinySerializationIntInformation(std::vector& tinyInfo) const; - void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const; - void checkNoTimePresence() const throw(INTERP_KERNEL::Exception); - void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); - void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; } - void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; } - double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; } - double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; } - std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); - void getValueForTime(double time, const std::vector& vals, double *res) const; - void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); - void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception); - public: - static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME; - static const char REPR[]; - private: - static const char EXCEPTION_MSG[]; - protected: - double _time; - int _iteration; - int _order; - }; - - class MEDCOUPLING_EXPORT MEDCouplingConstOnTimeInterval : public MEDCouplingTimeDiscretization - { - protected: - MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy); - public: - MEDCouplingConstOnTimeInterval(); - void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); - void getTinySerializationIntInformation(std::vector& tinyInfo) const; - void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const; - bool areCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; - bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; - std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); - void getValueForTime(double time, const std::vector& vals, double *res) const; - void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); - void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception); - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - std::string getStringRepr() const; - MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - void divideEqual(const MEDCouplingTimeDiscretization *other); - void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; } - void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; } - double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; } - double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; } - void checkNoTimePresence() const throw(INTERP_KERNEL::Exception); - void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); - public: - static const TypeOfTimeDiscretization DISCRETIZATION=CONST_ON_TIME_INTERVAL; - static const char REPR[]; - private: - static const char EXCEPTION_MSG[]; - protected: - double _start_time; - double _end_time; - int _start_iteration; - int _end_iteration; - int _start_order; - int _end_order; - }; - - class MEDCOUPLING_EXPORT MEDCouplingTwoTimeSteps : public MEDCouplingTimeDiscretization - { - protected: - MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy); - MEDCouplingTwoTimeSteps(); - ~MEDCouplingTwoTimeSteps(); - public: - void updateTime(); - void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); - void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other); - DataArrayDouble *getEndArray() const; - void checkCoherency() const throw(INTERP_KERNEL::Exception); - bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; - bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; - void checkNoTimePresence() const throw(INTERP_KERNEL::Exception); - void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); - void getArrays(std::vector& arrays) const; - void setEndArray(DataArrayDouble *array, TimeLabel *owner); - void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; } - void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; } - double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; } - double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; } - void getTinySerializationIntInformation(std::vector& tinyInfo) const; - void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - void getTinySerializationStrInformation(std::vector& tinyInfo) const; - void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); - void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); - void setArrays(const std::vector& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception); - protected: - static const char EXCEPTION_MSG[]; - protected: - double _start_time; - double _end_time; - int _start_iteration; - int _end_iteration; - int _start_order; - int _end_order; - DataArrayDouble *_end_array; - }; - - class MEDCOUPLING_EXPORT MEDCouplingLinearTime : public MEDCouplingTwoTimeSteps - { - protected: - MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy); - public: - MEDCouplingLinearTime(); - std::string getStringRepr() const; - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - void checkCoherency() const throw(INTERP_KERNEL::Exception); - MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const; - bool areCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; - void getValueForTime(double time, const std::vector& vals, double *res) const; - void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); - void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception); - MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - void divideEqual(const MEDCouplingTimeDiscretization *other); - public: - static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME; - static const char REPR[]; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx deleted file mode 100644 index dad0d5900..000000000 --- a/src/MEDCoupling/MEDCouplingTimeLabel.cxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingTimeLabel.hxx" - -using namespace ParaMEDMEM; - -unsigned int TimeLabel::GLOBAL_TIME=0; - -TimeLabel::TimeLabel():_time(GLOBAL_TIME++) -{ -} - -TimeLabel::~TimeLabel() -{ -} - - TimeLabel& TimeLabel::operator=(const TimeLabel& other) -{ - _time=GLOBAL_TIME++; - return *this; -} - -void TimeLabel::declareAsNew() -{ - _time=GLOBAL_TIME++; -} - -void TimeLabel::updateTimeWith(const TimeLabel& other) -{ - if(_time -#include -#include -#include -#include - -using namespace ParaMEDMEM; - -const char MEDCouplingUMesh::PART_OF_NAME[]="PartOf_"; - -double MEDCouplingUMesh::EPS_FOR_POLYH_ORIENTATION=1.e-14; - -MEDCouplingUMesh *MEDCouplingUMesh::New() -{ - return new MEDCouplingUMesh; -} - -MEDCouplingUMesh *MEDCouplingUMesh::New(const char *meshName, int meshDim) -{ - MEDCouplingUMesh *ret=new MEDCouplingUMesh; - ret->setName(meshName); - ret->setMeshDimension(meshDim); - return ret; -} - -MEDCouplingMesh *MEDCouplingUMesh::deepCpy() const -{ - return clone(true); -} - -MEDCouplingUMesh *MEDCouplingUMesh::clone(bool recDeepCpy) const -{ - return new MEDCouplingUMesh(*this,recDeepCpy); -} - -void MEDCouplingUMesh::updateTime() -{ - MEDCouplingPointSet::updateTime(); - if(_nodal_connec) - { - updateTimeWith(*_nodal_connec); - } - if(_nodal_connec_index) - { - updateTimeWith(*_nodal_connec_index); - } -} - -MEDCouplingUMesh::MEDCouplingUMesh():_iterator(-1),_mesh_dim(-2), - _nodal_connec(0),_nodal_connec_index(0) -{ -} - -/*! - * This method checks that this is correctly designed. For example le coordinates are set, nodal connectivity. - * When this method returns without throwing any exception, 'this' is expected to be writable, exchangeable and to be - * available for most of algorithm. When a mesh has been constructed from scratch it is a good habits to call this method to check - * that all is in order in 'this'. - */ -void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - if(_mesh_dim<-1) - throw INTERP_KERNEL::Exception("No mesh dimension specified !"); - for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) - { - if((int)INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim) - { - std::ostringstream message; - message << "Mesh invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter); - throw INTERP_KERNEL::Exception(message.str().c_str()); - } - } - if(_nodal_connec) - { - if(_nodal_connec->getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("Nodal connectivity array is expected to be with number of components set to one !"); - if(_nodal_connec->getInfoOnComponent(0)!="") - throw INTERP_KERNEL::Exception("Nodal connectivity array is expected to have no info on its single component !"); - } - if(_nodal_connec_index) - { - if(_nodal_connec_index->getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to be with number of components set to one !"); - if(_nodal_connec_index->getInfoOnComponent(0)!="") - throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to have no info on its single component !"); - } -} - -void MEDCouplingUMesh::setMeshDimension(int meshDim) -{ - if(meshDim<-1) - throw INTERP_KERNEL::Exception("Invalid meshDim specified ! Must be greater or equal to -1 !"); - _mesh_dim=meshDim; - declareAsNew(); -} - -void MEDCouplingUMesh::allocateCells(int nbOfCells) -{ - if(_nodal_connec_index) - { - _nodal_connec_index->decrRef(); - } - if(_nodal_connec) - { - _nodal_connec->decrRef(); - } - - _nodal_connec_index=DataArrayInt::New(); - _nodal_connec_index->alloc(nbOfCells+1,1); - int *pt=_nodal_connec_index->getPointer(); - pt[0]=0; - _nodal_connec=DataArrayInt::New(); - _nodal_connec->alloc(2*nbOfCells,1); - _iterator=0; - _types.clear(); - declareAsNew(); -} - -/*! - * Appends a cell in connectivity array. - * @param type type of cell to add. - * @param size number of nodes constituting this cell. - * @param nodalConnOfCell the connectivity of the cell to add. - */ -void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) -{ - int *pt=_nodal_connec_index->getPointer(); - int idx=pt[_iterator]; - - _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size); - _types.insert(type); - pt[++_iterator]=idx+size+1; -} - -/*! - * Method to be called to cloture the insertion of cells using this->insertNextCell. - */ -void MEDCouplingUMesh::finishInsertingCells() -{ - const int *pt=_nodal_connec_index->getConstPointer(); - int idx=pt[_iterator]; - - _nodal_connec->reAlloc(idx); - _nodal_connec_index->reAlloc(_iterator+1); - _iterator=-1; - _nodal_connec->declareAsNew(); - _nodal_connec_index->declareAsNew(); - updateTime(); -} - -/*! - * This method is a method that compares 'this' and 'other'. - * This method compares \b all attributes, even names and component names. - */ -bool MEDCouplingUMesh::isEqual(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingUMesh *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!MEDCouplingPointSet::isEqual(other,prec)) - return false; - if(_mesh_dim!=otherC->_mesh_dim) - return false; - if(_types!=otherC->_types) - return false; - if(_nodal_connec!=0 || otherC->_nodal_connec!=0) - if(_nodal_connec==0 || otherC->_nodal_connec==0) - return false; - if(_nodal_connec!=otherC->_nodal_connec) - if(!_nodal_connec->isEqual(*otherC->_nodal_connec)) - return false; - if(_nodal_connec_index!=0 || otherC->_nodal_connec_index!=0) - if(_nodal_connec_index==0 || otherC->_nodal_connec_index==0) - return false; - if(_nodal_connec_index!=otherC->_nodal_connec_index) - if(!_nodal_connec_index->isEqual(*otherC->_nodal_connec_index)) - return false; - return true; -} - -bool MEDCouplingUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingUMesh *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(!MEDCouplingPointSet::isEqualWithoutConsideringStr(other,prec)) - return false; - if(_mesh_dim!=otherC->_mesh_dim) - return false; - if(_types!=otherC->_types) - return false; - if(_nodal_connec!=0 || otherC->_nodal_connec!=0) - if(_nodal_connec==0 || otherC->_nodal_connec==0) - return false; - if(_nodal_connec!=otherC->_nodal_connec) - if(!_nodal_connec->isEqualWithoutConsideringStr(*otherC->_nodal_connec)) - return false; - if(_nodal_connec_index!=0 || otherC->_nodal_connec_index!=0) - if(_nodal_connec_index==0 || otherC->_nodal_connec_index==0) - return false; - if(_nodal_connec_index!=otherC->_nodal_connec_index) - if(!_nodal_connec_index->isEqualWithoutConsideringStr(*otherC->_nodal_connec_index)) - return false; - return true; -} - -/*! - * This method looks if 'this' and 'other' are geometrically equivalent that is to say if each cell in 'other' correspond to one cell and only one - * in 'this' is found regarding 'prec' parameter and 'cellCompPol' parameter. - * - * In case of success cellCor and nodeCor are informed both. - * @param cellCompPol values are described in MEDCouplingUMesh::zipConnectivityTraducer method. - * @param cellCor output array giving the correspondance of cells from 'other' to 'this'. - * @param nodeCor output array giving the correspondance of nodes from 'other' to 'this'. - */ -void MEDCouplingUMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingUMesh *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Two meshes are not not unstructured !"); - MEDCouplingMesh::checkFastEquivalWith(other,prec); - if(_types!=otherC->_types) - throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Types are not equal !"); - MEDCouplingAutoRefCountObjectPtr m=mergeUMeshes(this,otherC); - bool areNodesMerged; - int newNbOfNodes; - int oldNbOfNodes=getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr da=m->buildPermArrayForMergeNode(oldNbOfNodes,prec,areNodesMerged,newNbOfNodes); - //mergeNodes - if(!areNodesMerged) - throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Nodes are incompatible ! "); - const int *pt=std::find_if(da->getConstPointer()+oldNbOfNodes,da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),oldNbOfNodes-1)); - if(pt!=da->getConstPointer()+da->getNbOfElems()) - throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some nodes in other are not in this !"); - m->renumberNodes(da->getConstPointer(),newNbOfNodes); - // - nodeCor=da->substr(oldNbOfNodes); - da=m->mergeNodes(prec,areNodesMerged,newNbOfNodes); - if(nodeCor->isIdentity()) - { - nodeCor->decrRef(); - nodeCor=0; - } - // - da=m->zipConnectivityTraducer(cellCompPol); - int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells()); - pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),maxId)); - if(pt!=da->getConstPointer()+da->getNbOfElems()) - { - nodeCor->decrRef(); nodeCor=0; - throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); - } - cellCor=DataArrayInt::New(); - cellCor->alloc(otherC->getNumberOfCells(),1); - std::copy(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),cellCor->getPointer()); - if(cellCor->isIdentity()) - { - cellCor->decrRef(); - cellCor=0; - } -} - -/*! - * This method looks if 'this' and 'other' are geometrically equivalent that is to say if each cell in 'other' correspond to one cell and only one - * in 'this' is found regarding 'prec' parameter and 'cellCompPol' parameter. The difference with MEDCouplingUMesh::checkDeepEquivalWith method is that - * coordinates of 'this' and 'other' are expected to be the same. If not an exception will be thrown. - * - * In case of success cellCor are informed both. - * @param cellCompPol values are described in MEDCouplingUMesh::zipConnectivityTraducer method. - * @param cellCor output array giving the correspondance of cells from 'other' to 'this'. - */ -void MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingUMesh *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : Two meshes are not not unstructured !"); - MEDCouplingMesh::checkFastEquivalWith(other,prec); - if(_types!=otherC->_types) - throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : Types are not equal !"); - if(_coords!=otherC->_coords) - throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : meshes do not share the same coordinates ! Use tryToShareSameCoordinates or call checkDeepEquivalWith !"); - std::vector ms(2); - ms[0]=const_cast(this); - ms[1]=const_cast(otherC); - MEDCouplingAutoRefCountObjectPtr m=mergeUMeshesOnSameCoords(ms); - MEDCouplingAutoRefCountObjectPtr da=m->zipConnectivityTraducer(cellCompPol); - int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells()); - const int *pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),maxId)); - if(pt!=da->getConstPointer()+da->getNbOfElems()) - { - throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : some cells in other are not in this !"); - } - cellCor=DataArrayInt::New(); - cellCor->alloc(otherC->getNumberOfCells(),1); - std::copy(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),cellCor->getPointer()); - if(cellCor->isIdentity()) - { - cellCor->decrRef(); - cellCor=0; - } -} - -/*! - * This method checks fastly that 'this' and 'other' are equal. - */ -void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception) -{ - const MEDCouplingUMesh *otherC=dynamic_cast(other); - if(!otherC) - throw INTERP_KERNEL::Exception("checkFastEquivalWith : Two meshes are not not unstructured !"); - MEDCouplingPointSet::checkFastEquivalWith(other,prec); - int nbOfCells=getNumberOfCells(); - if(nbOfCells<1) - return ; - bool status=true; - status&=areCellsFrom2MeshEqual(otherC,0,prec); - status&=areCellsFrom2MeshEqual(otherC,nbOfCells/2,prec); - status&=areCellsFrom2MeshEqual(otherC,nbOfCells-1,prec); - if(!status) - throw INTERP_KERNEL::Exception("checkFastEquivalWith : Two meshes are not equal because on 3 test cells some difference have been detected !"); -} - -/*! - * \b WARNING this method do the assumption that connectivity lies on the coordinates set. - * For speed reasons no check of this will be done. - */ -void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const -{ - checkFullyDefined(); - int nbOfNodes=getNumberOfNodes(); - int *revNodalIndxPtr=new int[nbOfNodes+1]; - revNodalIndx->useArray(revNodalIndxPtr,true,CPP_DEALLOC,nbOfNodes+1,1); - std::fill(revNodalIndxPtr,revNodalIndxPtr+nbOfNodes+1,0); - const int *conn=_nodal_connec->getConstPointer(); - const int *connIndex=_nodal_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - int nbOfEltsInRevNodal=0; - for(int eltId=0;eltId=0)//for polyhedrons - { - nbOfEltsInRevNodal++; - revNodalIndxPtr[(*iter)+1]++; - } - } - std::transform(revNodalIndxPtr+1,revNodalIndxPtr+nbOfNodes+1,revNodalIndxPtr,revNodalIndxPtr+1,std::plus()); - int *revNodalPtr=new int[nbOfEltsInRevNodal]; - revNodal->useArray(revNodalPtr,true,CPP_DEALLOC,nbOfEltsInRevNodal,1); - std::fill(revNodalPtr,revNodalPtr+nbOfEltsInRevNodal,-1); - for(int eltId=0;eltId=0)//for polyhedrons - *std::find_if(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1],std::bind2nd(std::equal_to(),-1))=eltId; - } -} - -/*! - * \b WARNING this method do the assumption that connectivity lies on the coordinates set. - * For speed reasons no check of this will be done. - */ -MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const -{ - checkFullyDefined(); - int nbOfCells=getNumberOfCells(); - int nbOfNodes=getNumberOfNodes(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connIndex=_nodal_connec_index->getConstPointer(); - std::vector< std::vector > descMeshConnB(nbOfCells); - std::vector< std::vector > revDescMeshConnB; - std::vector< std::vector > revNodalB(nbOfNodes); - std::vector meshDM1Conn; - std::vector meshDM1ConnIndex(1); meshDM1ConnIndex[0]=0; - std::vector meshDM1Type; - for(int eltId=0;eltId shareableCells(revNodalB[tmp[0]].begin(),revNodalB[tmp[0]].end()); - for(unsigned j=1;j tmp2(revNodalB[tmp[j]].begin(),revNodalB[tmp[j]].end()); - std::set tmp3; - std::set_intersection(tmp2.begin(),tmp2.end(),shareableCells.begin(),shareableCells.end(),inserter(tmp3,tmp3.begin())); - shareableCells=tmp3; - } - std::list shareableCellsL(shareableCells.begin(),shareableCells.end()); - std::set ref(tmp,tmp+nbOfNodesSon); - for(std::list::iterator iter=shareableCellsL.begin();iter!=shareableCellsL.end();) - { - if(cms.isCompatibleWith((INTERP_KERNEL::NormalizedCellType)meshDM1Type[*iter])) - { - std::set ref2(meshDM1Conn.begin()+meshDM1ConnIndex[*iter],meshDM1Conn.begin()+meshDM1ConnIndex[(*iter)+1]); - if(ref==ref2) - break; - else - iter=shareableCellsL.erase(iter); - } - else - iter=shareableCellsL.erase(iter); - } - if(shareableCellsL.empty()) - { - meshDM1Conn.insert(meshDM1Conn.end(),tmp,tmp+nbOfNodesSon); - meshDM1ConnIndex.push_back(meshDM1ConnIndex.back()+nbOfNodesSon); - int cellDM1Id=meshDM1Type.size(); - meshDM1Type.push_back((int)cmsId); - for(unsigned k=0;ksetCoords(getCoords()); - int nbOfCellsInConstituent=meshDM1Type.size(); - ret->allocateCells(nbOfCellsInConstituent); - revDescIndx->alloc(nbOfCellsInConstituent+1,1); - int *tmp3=revDescIndx->getPointer(); tmp3[0]=0; - for(int ii=0;iiinsertNextCell((INTERP_KERNEL::NormalizedCellType)meshDM1Type[ii],meshDM1ConnIndex[ii+1]-meshDM1ConnIndex[ii],&meshDM1Conn[meshDM1ConnIndex[ii]]); - tmp3[ii+1]=tmp3[ii]+revDescMeshConnB[ii].size(); - } - ret->finishInsertingCells(); - revDesc->alloc(tmp3[nbOfCellsInConstituent],1); - tmp3=revDesc->getPointer(); - for(std::vector< std::vector >::const_iterator iter2=revDescMeshConnB.begin();iter2!=revDescMeshConnB.end();iter2++) - tmp3=std::copy((*iter2).begin(),(*iter2).end(),tmp3); - meshDM1Type.clear(); meshDM1ConnIndex.clear(); meshDM1Conn.clear(); - descIndx->alloc(nbOfCells+1,1); - tmp3=descIndx->getPointer(); tmp3[0]=0; - for(int jj=0;jjalloc(tmp3[nbOfCells],1); - tmp3=desc->getPointer(); - for(std::vector< std::vector >::const_iterator iter3=descMeshConnB.begin();iter3!=descMeshConnB.end();iter3++) - tmp3=std::copy((*iter3).begin(),(*iter3).end(),tmp3); - // - return ret; -} - -struct MEDCouplingAccVisit -{ - MEDCouplingAccVisit():_new_nb_of_nodes(0) { } - int operator()(int val) { if(val!=-1) return _new_nb_of_nodes++; else return -1; } - int _new_nb_of_nodes; -}; - -/*! - * This method convert this into dynamic types without changing geometry. - * That is to say if 'this' is a 2D, mesh after the invocation of this method it will contain only polygons. - * If 'this' is a 3D mesh after the invocation of this method it will contain only polyhedra. - * If mesh dimension is not in [2,3] an exception is thrown. - * Of course pay attention that the resulting mesh is slower than previous one. - * This method is above all designed to test more extensively algorithms able to deal with polygons/polyhedra. - */ -void MEDCouplingUMesh::convertToPolyTypes(const std::vector& cellIdsToConvert) -{ - checkFullyDefined(); - int dim=getMeshDimension(); - if(dim<2 || dim>3) - throw INTERP_KERNEL::Exception("Invalid mesh dimension : must be 2 or 3 !"); - if(dim==2) - { - const int *connIndex=_nodal_connec_index->getConstPointer(); - int *conn=_nodal_connec->getPointer(); - for(std::vector::const_iterator iter=cellIdsToConvert.begin();iter!=cellIdsToConvert.end();iter++) - conn[connIndex[*iter]]=INTERP_KERNEL::NORM_POLYGON; - } - else - { - int *connIndex=_nodal_connec_index->getPointer(); - int connIndexLgth=_nodal_connec_index->getNbOfElems(); - const int *connOld=_nodal_connec->getConstPointer(); - int connOldLgth=_nodal_connec->getNbOfElems(); - std::vector connNew(connOld,connOld+connOldLgth); - for(std::vector::const_iterator iter=cellIdsToConvert.begin();iter!=cellIdsToConvert.end();iter++) - { - int pos=connIndex[*iter]; - int posP1=connIndex[(*iter)+1]; - int lgthOld=posP1-pos-1; - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel((INTERP_KERNEL::NormalizedCellType)connNew[pos]); - connNew[pos]=INTERP_KERNEL::NORM_POLYHED; - unsigned nbOfFaces=cm.getNumberOfSons2(&connNew[pos+1],lgthOld); - int *tmp=new int[nbOfFaces*lgthOld]; - int *work=tmp; - for(int j=0;j<(int)nbOfFaces;j++) - { - INTERP_KERNEL::NormalizedCellType type; - unsigned offset=cm.fillSonCellNodalConnectivity2(j,&connNew[pos+1],lgthOld,work,type); - work+=offset; - *work++=-1; - } - unsigned newLgth=work-tmp-1; - unsigned delta=newLgth-lgthOld; - std::transform(connIndex+(*iter)+1,connIndex+connIndexLgth,connIndex+(*iter)+1,std::bind2nd(std::plus(),delta)); - connNew.insert(connNew.begin()+posP1,tmp+lgthOld,tmp+newLgth); - std::copy(tmp,tmp+lgthOld,connNew.begin()+pos+1); - delete [] tmp; - } - _nodal_connec->alloc(connNew.size(),1); - int *newConnPtr=_nodal_connec->getPointer(); - std::copy(connNew.begin(),connNew.end(),newConnPtr); - } - computeTypes(); -} - -/*! - * Array returned is the correspondance new to old. - * The maximum value stored in returned array is the number of nodes of 'this' minus 1 after call of this method. - * The size of returned array is the number of nodes of the old (previous to the call of this method) number of nodes. - * -1 values in returned array means that the corresponding old node is no more used. - */ -DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() -{ - int nbOfNodes=getNumberOfNodes(); - int *traducer=new int[nbOfNodes]; - std::fill(traducer,traducer+nbOfNodes,-1); - int nbOfCells=getNumberOfCells(); - const int *connIndex=_nodal_connec_index->getConstPointer(); - int *conn=_nodal_connec->getPointer(); - for(int i=0;i=0) - traducer[conn[j]]=1; - int newNbOfNodes=std::count(traducer,traducer+nbOfNodes,1); - std::transform(traducer,traducer+nbOfNodes,traducer,MEDCouplingAccVisit()); - for(int i=0;i=0) - conn[j]=traducer[conn[j]]; - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(newNbOfNodes,1); - int *retPtr=ret->getPointer(); - for(int i=0;iselectByTupleId(retPtr,retPtr+newNbOfNodes); - setCoords(newCoords); - newCoords->decrRef(); - return ret; -} - -/*! - * This method stands if 'cell1' and 'cell2' are equals regarding 'compType' policy. - * The semantic of 'compType' is specified in MEDCouplingUMesh::zipConnectivityTraducer method. - */ -bool MEDCouplingUMesh::areCellsEqual(int cell1, int cell2, int compType) const -{ - switch(compType) - { - case 0: - return areCellsEqual0(cell1,cell2); - case 1: - return areCellsEqual1(cell1,cell2); - case 2: - return areCellsEqual2(cell1,cell2); - } - throw INTERP_KERNEL::Exception("Unknown comparison asked ! Must be in 0,1 or 2."); -} - -/*! - * This method is the last step of the MEDCouplingUMesh::zipConnectivityTraducer with policy 0. - */ -bool MEDCouplingUMesh::areCellsEqual0(int cell1, int cell2) const -{ - const int *conn=getNodalConnectivity()->getConstPointer(); - const int *connI=getNodalConnectivityIndex()->getConstPointer(); - return std::equal(conn+connI[cell1],conn+connI[cell1+1],conn+connI[cell2]); -} - -/*! - * This method is the last step of the MEDCouplingUMesh::zipConnectivityTraducer with policy 1. - */ -bool MEDCouplingUMesh::areCellsEqual1(int cell1, int cell2) const -{ - throw INTERP_KERNEL::Exception("Policy comparison, not implemented yet !"); -} - -/*! - * This method is the last step of the MEDCouplingUMesh::zipConnectivityTraducer with policy 2. - */ -bool MEDCouplingUMesh::areCellsEqual2(int cell1, int cell2) const -{ - const int *conn=getNodalConnectivity()->getConstPointer(); - const int *connI=getNodalConnectivityIndex()->getConstPointer(); - std::set s1(conn+connI[cell1],conn+connI[cell1+1]); - std::set s2(conn+connI[cell2],conn+connI[cell2+1]); - return s1==s2; -} - -/*! - * This method compares 2 cells coming from two unstructured meshes : 'this' and 'other'. - * This method compares 2 cells having the same id 'cellId' in 'this' and 'other'. - */ -bool MEDCouplingUMesh::areCellsFrom2MeshEqual(const MEDCouplingUMesh *other, int cellId, double prec) const -{ - if(getTypeOfCell(cellId)!=other->getTypeOfCell(cellId)) - return false; - std::vector c1,c2; - getNodeIdsOfCell(cellId,c1); - other->getNodeIdsOfCell(cellId,c2); - int sz=c1.size(); - if(sz!=(int)c2.size()) - return false; - for(int i=0;i n1,n2; - getCoordinatesOfNode(c1[0],n1); - other->getCoordinatesOfNode(c2[0],n2); - std::transform(n1.begin(),n1.end(),n2.begin(),n1.begin(),std::minus()); - std::transform(n1.begin(),n1.end(),n1.begin(),std::ptr_fun(fabs)); - if(*std::max_element(n1.begin(),n1.end())>prec) - return false; - } - return true; -} - -/*! - * This method find in candidate pool defined by 'candidates' the cells equal following the polycy 'compType'. - * If any true is returned and the results will be put at the end of 'result' output parameter. If not false is returned - * and result remains unchanged. - * The semantic of 'compType' is specified in MEDCouplingUMesh::zipConnectivityTraducer method. - * If in 'candidates' pool -1 value is considered as an empty value. - * WARNING this method returns only ONE set of result ! - */ -bool MEDCouplingUMesh::areCellsEqualInPool(const std::vector& candidates, int compType, std::vector& result) const -{ - std::set cand(candidates.begin(),candidates.end()); - cand.erase(-1); - if(cand.size()<=1) - return false; - std::set::const_iterator end=cand.end(); end--; - bool ret=false; - for(std::set::const_iterator iter=cand.begin();iter!=end && !ret;iter++) - { - std::set::const_iterator begin2=iter; begin2++; - for(std::set::const_iterator iter2=begin2;iter2!=cand.end();iter2++) - { - if(areCellsEqual(*iter,*iter2,compType)) - { - if(!ret) - { - result.push_back(*iter); - ret=true; - } - result.push_back(*iter2); - } - } - } - return ret; -} - -/*! - * This method common cells base regarding 'compType' comparison policy described in ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer for details. - * This method returns 2 values 'res' and 'resI'. - * If 'res' and 'resI' are not empty before calling this method they will be cleared before set. - * The format of 'res' and 'resI' is as explained here. - * resI.size()-1 is the number of set of cells equal. - * The nth set is [res.begin()+resI[n];res.begin()+resI[n+1]) with 0<=n -void MEDCouplingUMesh::findCommonCellsBase(int compType, std::vector& res, std::vector& resI) const -{ - res.clear(); resI.clear(); - resI.push_back(0); - std::vector bbox; - int nbOfCells=getNumberOfCells(); - getBoundingBoxForBBTree(bbox); - double bb[2*SPACEDIM]; - double eps=getCaracteristicDimension(); - eps*=1.e-12; - BBTree myTree(&bbox[0],0,0,nbOfCells,-eps); - const int *conn=getNodalConnectivity()->getConstPointer(); - const int *connI=getNodalConnectivityIndex()->getConstPointer(); - const double *coords=getCoords()->getConstPointer(); - std::vector isFetched(nbOfCells); - for(int k=0;k::max(); bb[2*j+1]=-std::numeric_limits::max(); } - for(const int *pt=conn+connI[k]+1;pt!=conn+connI[k+1];pt++) - if(*pt>-1) - { - for(int j=0;j candidates1; - myTree.getIntersectingElems(bb,candidates1); - std::vector candidates; - for(std::vector::const_iterator iter=candidates1.begin();iter!=candidates1.end();iter++) - if(!isFetched[*iter]) - candidates.push_back(*iter); - if(areCellsEqualInPool(candidates,compType,res)) - { - int pos=resI.back(); - resI.push_back(res.size()); - for(std::vector::const_iterator it=res.begin()+pos;it!=res.end();it++) - isFetched[*it]=true; - } - isFetched[k]=true; - } - } -} - -/*! - * This method could potentially modify 'this'. This method merges cells if there are cells equal in 'this'. The comparison is specified by 'compType'. - * This method keeps the coordiantes of 'this'. - * - * @param compType input specifying the technique used to compare cells each other. - * 0 : exactly. A cell is detected to be the same if and only if the connectivity is exactly the same without permutation and types same too. This is the strongest policy. - * 1 : permutation. cell1 and cell2 are equal if and the connectivity of cell2 can be deduced by those of cell1 by direct permutation and their type equal. - * 2 : nodal. cell1 and cell2 are equal if and only if cell1 and cell2 have same type and have the same nodes constituting connectivity. This is the laziest policy. - * @return the correspondance array old to new. - */ -DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType) -{ - int spaceDim=getSpaceDimension(); - int nbOfCells=getNumberOfCells(); - std::vector commonCells; - std::vector commonCellsI; - switch(spaceDim) - { - case 3: - { - findCommonCellsBase<3>(compType,commonCells,commonCellsI); - break; - } - case 2: - { - findCommonCellsBase<2>(compType,commonCells,commonCellsI); - break; - } - case 1: - { - findCommonCellsBase<1>(compType,commonCells,commonCellsI); - break; - } - default: - throw INTERP_KERNEL::Exception("Invalid spaceDimension : must be 1, 2 or 3."); - } - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(nbOfCells,1); - int *retPtr=ret->getPointer(); - std::fill(retPtr,retPtr+nbOfCells,0); - const int nbOfTupleSmCells=commonCellsI.size()-1; - int id=-1; - std::vector cellsToKeep; - for(int i=0;i::const_iterator it=commonCells.begin()+commonCellsI[i];it!=commonCells.begin()+commonCellsI[i+1];it++) - retPtr[*it]=id; - id--; - } - id=0; - std::map m; - for(int i=0;i::const_iterator iter=m.find(val); - if(iter==m.end()) - { - m[val]=id; - retPtr[i]=id++; - cellsToKeep.push_back(i); - } - else - retPtr[i]=(*iter).second; - } - } - MEDCouplingUMesh *self=(MEDCouplingUMesh *)buildPartOfMySelf(&cellsToKeep[0],&cellsToKeep[0]+cellsToKeep.size(),true); - setConnectivity(self->getNodalConnectivity(),self->getNodalConnectivityIndex(),true); - self->decrRef(); - return ret; -} - -/*! - * @param areNodesMerged if at least two nodes have been merged. - * @return old to new node correspondance. - */ -DataArrayInt *MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) -{ - DataArrayInt *ret=buildPermArrayForMergeNode(-1,precision,areNodesMerged,newNbOfNodes); - if(areNodesMerged) - renumberNodes(ret->getConstPointer(),newNbOfNodes); - return ret; -} - -/*! - * This method tries to use 'other' coords and use it for 'this'. If no exception was thrown after the call of this method : - * this->_coords==other->_coords. If not a exception is thrown this remains unchanged. - */ -void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) -{ - DataArrayDouble *coords=other.getCoords(); - if(!coords) - throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in other !"); - if(!_coords) - throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in this whereas there is any in other !"); - int otherNbOfNodes=other.getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr newCoords=mergeNodesArray(&other,this); - _coords->incrRef(); - MEDCouplingAutoRefCountObjectPtr oldCoords=_coords; - setCoords(newCoords); - bool areNodesMerged; - int newNbOfNodes; - MEDCouplingAutoRefCountObjectPtr da=buildPermArrayForMergeNode(otherNbOfNodes,epsilon,areNodesMerged,newNbOfNodes); - if(!areNodesMerged) - { - setCoords(oldCoords); - throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute fails : no nodes are mergeable with specified given epsilon !"); - } - int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+otherNbOfNodes); - const int *pt=std::find_if(da->getConstPointer()+otherNbOfNodes,da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),maxId)); - if(pt!=da->getConstPointer()+da->getNbOfElems()) - { - setCoords(oldCoords); - throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute fails : some nodes in this are not in other !"); - } - setCoords(oldCoords); - renumberNodesInConn(da->getConstPointer()+otherNbOfNodes); - setCoords(coords); -} - -/*! - * build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [begin,end). - * @param begin begin of array containing the cell ids to keep. - * @param end end of array of cell ids to keep. \b WARNING end param is \b not included ! Idem STL standard definitions. - * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see zipCoords) - */ -MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const -{ - if(getMeshDimension()!=-1) - { - MEDCouplingUMesh *ret=buildPartOfMySelfKeepCoords(begin,end); - if(!keepCoords) - ret->zipCoords(); - return ret; - } - else - { - if(end-begin!=1) - throw INTERP_KERNEL::Exception("-1D mesh has only one cell !"); - if(begin[0]!=0) - throw INTERP_KERNEL::Exception("-1D mesh has only one cell : 0 !"); - incrRef(); - return (MEDCouplingUMesh *)this; - } -} - -DataArrayInt *MEDCouplingUMesh::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const -{ - std::vector cellIdsKept; - fillCellIdsToKeepFromNodeIds(partBg,partEnd,true,cellIdsKept); - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(cellIdsKept.size(),1); - std::copy(cellIdsKept.begin(),cellIdsKept.end(),ret->getPointer()); - return ret; -} - -/*! - * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end'). - * The resulting cell ids are stored at the end of the 'cellIdsKept' parameter. - * Parameter 'fullyIn' specifies if a cell that has part of its nodes in ids array is kept or not. - * If 'fullyIn' is true only cells whose ids are \b fully contained in ['begin','end') tab will be kept. - * - * @param begin input start of array of node ids. - * @param end input end of array of node ids. - * @param fullyIn input that specifies if all node ids must be in ['begin','end') array to consider cell to be in. - * @param cellIdsKept in/out array where all candidate cell ids are put at the end. - */ -void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, std::vector& cellIdsKept) const -{ - std::set fastFinder(begin,end); - int nbOfCells=getNumberOfCells(); - const int *conn=getNodalConnectivity()->getConstPointer(); - const int *connIndex=getNodalConnectivityIndex()->getConstPointer(); - for(int i=0;i connOfCell(conn+connIndex[i]+1,conn+connIndex[i+1]); - connOfCell.erase(-1);//polyhedron separator - int refLgth=std::min(connOfCell.size(),fastFinder.size()); - std::set locMerge; - std::insert_iterator< std::set > it(locMerge,locMerge.begin()); - std::set_intersection(connOfCell.begin(),connOfCell.end(),fastFinder.begin(),fastFinder.end(),it); - if(((int)locMerge.size()==refLgth && fullyIn) || (locMerge.size()!=0 && !fullyIn)) - cellIdsKept.push_back(i); - } -} - -/*! - * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end'). - * The return newly allocated mesh will share the same coordinates as 'this'. - * Parameter 'fullyIn' specifies if a cell that has part of its nodes in ids array is kept or not. - * If 'fullyIn' is true only cells whose ids are \b fully contained in ['begin','end') tab will be kept. - */ -MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const -{ - std::vector cellIdsKept; - fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept); - return buildPartOfMySelf(&cellIdsKept[0],&cellIdsKept[0]+cellIdsKept.size(),true); -} - -/*! - * Contrary to MEDCouplingUMesh::buildPartOfMySelfNode method this method builds a mesh with a meshDimension equal to - * this->getMeshDimension()-1. The return newly allocated mesh will share the same coordinates as 'this'. - * Parameter 'fullyIn' specifies if a face that has part of its nodes in ids array is kept or not. - * If 'fullyIn' is true only faces whose ids are \b fully contained in ['begin','end') tab will be kept. - */ -MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const -{ - DataArrayInt *desc,*descIndx,*revDesc,*revDescIndx; - desc=DataArrayInt::New(); descIndx=DataArrayInt::New(); revDesc=DataArrayInt::New(); revDescIndx=DataArrayInt::New(); - MEDCouplingUMesh *subMesh=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - desc->decrRef(); descIndx->decrRef(); revDesc->decrRef(); revDescIndx->decrRef(); - MEDCouplingUMesh *ret=(MEDCouplingUMesh *)subMesh->buildPartOfMySelfNode(begin,end,fullyIn); - subMesh->decrRef(); - return ret; -} - -/*! - * This method returns a mesh with meshDim=this->getMeshDimension()-1. - * This returned mesh contains cells that are linked with one and only one cell of this. - * @param keepCoords specifies if zipCoords is called on returned mesh before being returned. - * @return mesh with ref counter equal to 1. - */ -MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const -{ - DataArrayInt *desc=DataArrayInt::New(); - DataArrayInt *descIndx=DataArrayInt::New(); - DataArrayInt *revDesc=DataArrayInt::New(); - DataArrayInt *revDescIndx=DataArrayInt::New(); - // - MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - revDesc->decrRef(); - desc->decrRef(); - descIndx->decrRef(); - int nbOfCells=meshDM1->getNumberOfCells(); - const int *revDescIndxC=revDescIndx->getConstPointer(); - std::vector boundaryCells; - for(int i=0;idecrRef(); - MEDCouplingPointSet *ret=meshDM1->buildPartOfMySelf(&boundaryCells[0],&boundaryCells[0]+boundaryCells.size(),keepCoords); - meshDM1->decrRef(); - return ret; -} - -/*! - * This methods returns set of nodes lying on the boundary of this. - */ -void MEDCouplingUMesh::findBoundaryNodes(std::vector& nodes) const -{ - DataArrayInt *desc=DataArrayInt::New(); - DataArrayInt *descIndx=DataArrayInt::New(); - DataArrayInt *revDesc=DataArrayInt::New(); - DataArrayInt *revDescIndx=DataArrayInt::New(); - // - MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - revDesc->decrRef(); - desc->decrRef(); - descIndx->decrRef(); - std::set ret; - int nbOfCells=meshDM1->getNumberOfCells(); - const int *revDescIndxC=revDescIndx->getConstPointer(); - std::vector boundaryCells; - for(int i=0;idecrRef(); - const int *conn=meshDM1->getNodalConnectivity()->getConstPointer(); - const int *connIndx=meshDM1->getNodalConnectivityIndex()->getConstPointer(); - for(std::vector::const_iterator iter=boundaryCells.begin();iter!=boundaryCells.end();iter++) - for(int k=connIndx[*iter]+1;kdecrRef(); -} - -/* - * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes. - * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) - * This value is asked because often known by the caller of this method. - * This method, contrary to MEDCouplingMesh::renumberCells does NOT conserve the number of nodes before and after. - * - * @param newNodeNumbers array specifying the new numbering. - * @param newNbOfNodes the new number of nodes. - */ -void MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) -{ - MEDCouplingPointSet::renumberNodes(newNodeNumbers,newNbOfNodes); - renumberNodesInConn(newNodeNumbers); -} - -/*! - * This method renumbers nodes in connectivity only without any reference with coords. - * Use it with care ! - */ -void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbers) -{ - int *conn=getNodalConnectivity()->getPointer(); - const int *connIndex=getNodalConnectivityIndex()->getConstPointer(); - int nbOfCells=getNumberOfCells(); - for(int i=0;i=0)//avoid polyhedron separator - { - node=newNodeNumbers[node]; - } - } - _nodal_connec->declareAsNew(); - updateTime(); -} - -/*! - * This method renumbers cells of 'this' using the array specified by [old2NewBg;old2NewBg+getNumberOfCells()) - * - * Contrary to MEDCouplingPointSet::renumberNodes, this method makes a permutation without any fuse of cell. - * After the call of this method the number of cells remains the same as before. - * - * If 'check' equals true the method will check that any elements in [old2NewBg;old2NewEnd) is unique ; if not - * an INTERP_KERNEL::Exception will be thrown. When 'check' equals true [old2NewBg;old2NewEnd) is not expected to - * be strictly in [0;this->getNumberOfCells()). - * - * If 'check' equals false the method will not check the content of [old2NewBg;old2NewEnd). - * To avoid any throw of SIGSEGV when 'check' equals false, the elements in [old2NewBg;old2NewEnd) should be unique and - * should be contained in[0;this->getNumberOfCells()). - */ -void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - int nbCells=getNumberOfCells(); - const int *array=old2NewBg; - if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells); - // - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - DataArrayInt *newConn=DataArrayInt::New(); - newConn->alloc(_nodal_connec->getNumberOfTuples(),_nodal_connec->getNumberOfComponents()); - newConn->copyStringInfoFrom(*_nodal_connec); - DataArrayInt *newConnI=DataArrayInt::New(); - newConnI->alloc(_nodal_connec_index->getNumberOfTuples(),_nodal_connec_index->getNumberOfComponents()); - newConnI->copyStringInfoFrom(*_nodal_connec_index); - // - int *newC=newConn->getPointer(); - int *newCI=newConnI->getPointer(); - int loc=0; - newCI[0]=loc; - for(int i=0;idecrRef(); - newConnI->decrRef(); - if(check) - delete [] (int *)array; -} - -/*! - * Given a boundary box 'bbox' returns elements 'elems' contained in this 'bbox'. - * Warning 'elems' is incremented during the call so if elems is not empty before call returned elements will be - * added in 'elems' parameter. - */ -void MEDCouplingUMesh::giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) -{ - if(getMeshDimension()==-1) - { - elems.push_back(0); - return; - } - int dim=getSpaceDimension(); - double* elem_bb=new double[2*dim]; - const int* conn = getNodalConnectivity()->getConstPointer(); - const int* conn_index= getNodalConnectivityIndex()->getConstPointer(); - const double* coords = getCoords()->getConstPointer(); - int nbOfCells=getNumberOfCells(); - for ( int ielem=0; ielem::max(); - elem_bb[i*2+1]=-std::numeric_limits::max(); - } - - for (int inode=conn_index[ielem]+1; inode=0)//avoid polyhedron separator - { - for (int idim=0; idim elem_bb[idim*2+1] ) - { - elem_bb[idim*2+1] = coords[node*dim+idim] ; - } - } - } - } - if (intersectsBoundingBox(elem_bb, bbox, dim, eps)) - { - elems.push_back(ielem); - } - } - delete [] elem_bb; -} - -/*! - * Given a boundary box 'bbox' returns elements 'elems' contained in this 'bbox'. - * Warning 'elems' is incremented during the call so if elems is not empty before call returned elements will be - * added in 'elems' parameter. - */ -void MEDCouplingUMesh::giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) -{ - if(getMeshDimension()==-1) - { - elems.push_back(0); - return; - } - int dim=getSpaceDimension(); - double* elem_bb=new double[2*dim]; - const int* conn = getNodalConnectivity()->getConstPointer(); - const int* conn_index= getNodalConnectivityIndex()->getConstPointer(); - const double* coords = getCoords()->getConstPointer(); - int nbOfCells=getNumberOfCells(); - for ( int ielem=0; ielem::max(); - elem_bb[i*2+1]=-std::numeric_limits::max(); - } - - for (int inode=conn_index[ielem]+1; inode=0)//avoid polyhedron separator - { - for (int idim=0; idim elem_bb[idim*2+1] ) - { - elem_bb[idim*2+1] = coords[node*dim+idim] ; - } - } - } - } - if (intersectsBoundingBox(bbox, elem_bb, dim, eps)) - { - elems.push_back(ielem); - } - } - delete [] elem_bb; -} - -/*! - * Returns the cell type of cell with id 'cellId'. - */ -INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(int cellId) const -{ - const int *ptI=_nodal_connec_index->getConstPointer(); - const int *pt=_nodal_connec->getConstPointer(); - return (INTERP_KERNEL::NormalizedCellType) pt[ptI[cellId]]; -} - -/*! - * Returns nb of cells having the geometric type 'type'. - */ -int MEDCouplingUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const -{ - const int *ptI=_nodal_connec_index->getConstPointer(); - const int *pt=_nodal_connec->getConstPointer(); - int nbOfCells=getNumberOfCells(); - int ret=0; - for(int i=0;i& conn) const -{ - const int *ptI=_nodal_connec_index->getConstPointer(); - const int *pt=_nodal_connec->getConstPointer(); - for(const int *w=pt+ptI[cellId]+1;w!=pt+ptI[cellId+1];w++) - if(*w>=0) - conn.push_back(*w); -} - -/*! - * Returns coordinates of node with id 'nodeId' and append it in 'coo'. - */ -void MEDCouplingUMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const -{ - const double *cooPtr=_coords->getConstPointer(); - int spaceDim=getSpaceDimension(); - coo.insert(coo.end(),cooPtr+spaceDim*nodeId,cooPtr+spaceDim*(nodeId+1)); -} - -std::string MEDCouplingUMesh::simpleRepr() const -{ - static const char msg0[]="No coordinates specified !"; - std::ostringstream ret; - ret << "Unstructured mesh with name : \"" << getName() << "\"\n"; - ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : "; - if(_coords!=0) - ret << getSpaceDimension() << "\n"; - else - ret << msg0 << "\n"; - ret << "Number of nodes : "; - if(_coords!=0) - ret << getNumberOfNodes() << "\n"; - else - ret << msg0 << "\n"; - ret << "Number of cells : "; - if(_nodal_connec!=0 && _nodal_connec_index!=0) - ret << getNumberOfCells() << "\n"; - else - ret << "No connectivity specified !" << "\n"; - ret << "Cell types present : "; - for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) - { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(*iter); - ret << cm.getRepr() << " "; - } - ret << "\n"; - return ret.str(); -} - -std::string MEDCouplingUMesh::advancedRepr() const -{ - std::ostringstream ret; - ret << simpleRepr(); - ret << "\nCoordinates array : \n___________________\n\n"; - if(_coords) - _coords->reprWithoutNameStream(ret); - else - ret << "No array set !\n"; - ret << "\n\nConnectivity arrays : \n_____________________\n\n"; - reprConnectivityOfThisLL(ret); - return ret.str(); -} -std::string MEDCouplingUMesh::reprConnectivityOfThis() const -{ - std::ostringstream ret; - reprConnectivityOfThisLL(ret); - return ret.str(); -} - -void MEDCouplingUMesh::reprConnectivityOfThisLL(std::ostringstream& stream) const -{ - if(_nodal_connec!=0 && _nodal_connec_index!=0) - { - int nbOfCells=getNumberOfCells(); - const int *c=_nodal_connec->getConstPointer(); - const int *ci=_nodal_connec_index->getConstPointer(); - for(int i=0;i(stream," ")); - stream << "\n"; - } - } - else - stream << "Connectivity not defined !\n"; -} - -int MEDCouplingUMesh::getNumberOfNodesInCell(int cellId) const -{ - const int *ptI=_nodal_connec_index->getConstPointer(); - const int *pt=_nodal_connec->getConstPointer(); - if(pt[ptI[cellId]]!=INTERP_KERNEL::NORM_POLYHED) - return ptI[cellId+1]-ptI[cellId]-1; - else - return std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to(),-1)); -} - -/*! - * Method reserved for advanced users having prepared their connectivity before. - * Arrays 'conn' and 'connIndex' will be aggregated without any copy and their counter will be incremented. - */ -void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes) -{ - DataArrayInt::setArrayIn(conn,_nodal_connec); - DataArrayInt::setArrayIn(connIndex,_nodal_connec_index); - if(isComputingTypes) - computeTypes(); - declareAsNew(); -} - -/*! - * Copy constructor. If 'deepCpy' is false 'this' is a shallow copy of other. - * If 'deeCpy' is true all arrays (coordinates and connectivities) are deeply copied. - */ -MEDCouplingUMesh::MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy):MEDCouplingPointSet(other,deepCpy),_iterator(-1),_mesh_dim(other._mesh_dim), - _nodal_connec(0),_nodal_connec_index(0), - _types(other._types) -{ - if(other._nodal_connec) - _nodal_connec=other._nodal_connec->performCpy(deepCpy); - if(other._nodal_connec_index) - _nodal_connec_index=other._nodal_connec_index->performCpy(deepCpy); -} - -MEDCouplingUMesh::~MEDCouplingUMesh() -{ - if(_nodal_connec) - _nodal_connec->decrRef(); - if(_nodal_connec_index) - _nodal_connec_index->decrRef(); -} - -/*! - * This method recomputes all cell types of 'this'. - */ -void MEDCouplingUMesh::computeTypes() -{ - if(_nodal_connec && _nodal_connec_index) - { - _types.clear(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connIndex=_nodal_connec_index->getConstPointer(); - int nbOfElem=_nodal_connec_index->getNbOfElems()-1; - for(const int *pt=connIndex;pt!=connIndex+nbOfElem;pt++) - _types.insert((INTERP_KERNEL::NormalizedCellType)conn[*pt]); - } -} - -/*! - * This method checks that all arrays are set. If yes nothing done if no an exception is thrown. - */ -void MEDCouplingUMesh::checkFullyDefined() const throw(INTERP_KERNEL::Exception) -{ - if(!_nodal_connec_index || !_nodal_connec || !_coords) - throw INTERP_KERNEL::Exception("Reverse nodal connectivity computation requires full connectivity and coordinates set in unstructured mesh."); -} - -int MEDCouplingUMesh::getNumberOfCells() const -{ - if(_nodal_connec_index) - if(_iterator==-1) - return _nodal_connec_index->getNumberOfTuples()-1; - else - return _iterator; - else - if(_mesh_dim==-1) - return 1; - else - throw INTERP_KERNEL::Exception("Unable to get number of cells because no connectivity specified !"); -} - -int MEDCouplingUMesh::getMeshDimension() const -{ - if(_mesh_dim<-1) - throw INTERP_KERNEL::Exception("No mesh dimension specified !"); - return _mesh_dim; -} - -/*! - * This method is for test reason. Normally the integer returned is not useable by user. - */ -int MEDCouplingUMesh::getMeshLength() const -{ - return _nodal_connec->getNbOfElems(); -} - -/*! - * First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process. - */ -void MEDCouplingUMesh::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const -{ - MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings); - tinyInfo.push_back(getMeshDimension()); - tinyInfo.push_back(getNumberOfCells()); - if(_nodal_connec) - tinyInfo.push_back(getMeshLength()); - else - tinyInfo.push_back(-1); -} - -/*! - * First step of unserialization process. - */ -bool MEDCouplingUMesh::isEmptyMesh(const std::vector& tinyInfo) const -{ - return tinyInfo[4]<=0; -} - -/*! - * Second step of serialization process. - * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. - */ -void MEDCouplingUMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const -{ - MEDCouplingPointSet::resizeForUnserialization(tinyInfo,a1,a2,littleStrings); - if(tinyInfo[5]!=-1) - a1->alloc(tinyInfo[5]+tinyInfo[4]+1,1); -} - -/*! - * Third and final step of serialization process. - */ -void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const -{ - MEDCouplingPointSet::serialize(a1,a2); - if(getMeshDimension()>-1) - { - a1=DataArrayInt::New(); - a1->alloc(getMeshLength()+getNumberOfCells()+1,1); - int *ptA1=a1->getPointer(); - const int *conn=getNodalConnectivity()->getConstPointer(); - const int *index=getNodalConnectivityIndex()->getConstPointer(); - ptA1=std::copy(index,index+getNumberOfCells()+1,ptA1); - std::copy(conn,conn+getMeshLength(),ptA1); - } - else - a1=0; -} - -/*! - * Second and final unserialization process. - * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. - */ -void MEDCouplingUMesh::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) -{ - MEDCouplingPointSet::unserialization(tinyInfo,a1,a2,littleStrings); - setMeshDimension(tinyInfo[3]); - if(tinyInfo[5]!=-1) - { - // Connectivity - const int *recvBuffer=a1->getConstPointer(); - DataArrayInt* myConnecIndex=DataArrayInt::New(); - myConnecIndex->alloc(tinyInfo[4]+1,1); - std::copy(recvBuffer,recvBuffer+tinyInfo[4]+1,myConnecIndex->getPointer()); - DataArrayInt* myConnec=DataArrayInt::New(); - myConnec->alloc(tinyInfo[5],1); - std::copy(recvBuffer+tinyInfo[4]+1,recvBuffer+tinyInfo[4]+1+tinyInfo[5],myConnec->getPointer()); - setConnectivity(myConnec, myConnecIndex) ; - myConnec->decrRef(); - myConnecIndex->decrRef(); - } -} - -/*! - * This is the low algorithm of buildPartOfMySelf. - * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end'). - * The return newly allocated mesh will share the same coordinates as 'this'. - */ -MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const -{ - checkFullyDefined(); - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - std::string name(getName()); - int sz=strlen(PART_OF_NAME); - if((int)name.length()>=sz) - name=name.substr(0,sz); - if(name!=PART_OF_NAME) - { - std::ostringstream stream; stream << PART_OF_NAME << getName(); - ret->setName(stream.str().c_str()); - } - else - ret->setName(getName()); - ret->_mesh_dim=_mesh_dim; - ret->setCoords(_coords); - int nbOfElemsRet=end-begin; - int *connIndexRet=new int[nbOfElemsRet+1]; - connIndexRet[0]=0; - const int *conn=_nodal_connec->getConstPointer(); - const int *connIndex=_nodal_connec_index->getConstPointer(); - int newNbring=0; - for(const int *work=begin;work!=end;work++,newNbring++) - connIndexRet[newNbring+1]=connIndexRet[newNbring]+connIndex[*work+1]-connIndex[*work]; - int *connRet=new int[connIndexRet[nbOfElemsRet]]; - int *connRetWork=connRet; - std::set types; - for(const int *work=begin;work!=end;work++) - { - types.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*work]]); - connRetWork=std::copy(conn+connIndex[*work],conn+connIndex[*work+1],connRetWork); - } - DataArrayInt *connRetArr=DataArrayInt::New(); - connRetArr->useArray(connRet,true,CPP_DEALLOC,connIndexRet[nbOfElemsRet],1); - DataArrayInt *connIndexRetArr=DataArrayInt::New(); - connIndexRetArr->useArray(connIndexRet,true,CPP_DEALLOC,nbOfElemsRet+1,1); - ret->setConnectivity(connRetArr,connIndexRetArr,false); - ret->_types=types; - connRetArr->decrRef(); - connIndexRetArr->decrRef(); - return ret; -} - -/*! - * brief returns the volumes of the cells underlying the field \a field - * - * For 2D geometries, the returned field contains the areas. - * For 3D geometries, the returned field contains the volumes. - * - * param field field on which cells the volumes are required - * return field containing the volumes, area or length depending the meshdimension. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const -{ - std::string name="MeasureOfMesh_"; - name+=getName(); - int nbelem=getNumberOfCells(); - MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS); - field->setName(name.c_str()); - DataArrayDouble* array=DataArrayDouble::New(); - array->alloc(nbelem,1); - double *area_vol=array->getPointer(); - field->setArray(array) ; - array->decrRef(); - field->setMesh(const_cast(this)); - if(getMeshDimension()!=-1) - { - int ipt; - INTERP_KERNEL::NormalizedCellType type; - int dim_space=getSpaceDimension(); - const double *coords=getCoords()->getConstPointer(); - const int *connec=getNodalConnectivity()->getConstPointer(); - const int *connec_index=getNodalConnectivityIndex()->getConstPointer(); - for(int iel=0;iel(type,connec+ipt+1,connec_index[iel+1]-ipt-1,coords,dim_space); - } - if(isAbs) - std::transform(area_vol,area_vol+nbelem,area_vol,std::ptr_fun(fabs)); - } - else - { - area_vol[0]=std::numeric_limits::max(); - } - return field; -} - -/*! - * This methods returns a field on nodes and no time. This method is usefull to check "P1*" conservative interpolators. - * This field returns the getMeasureField of the dualMesh in P1 sens of 'this'. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) const -{ - MEDCouplingFieldDouble *tmp=getMeasureField(isAbs); - std::string name="MeasureOnNodeOfMesh_"; - name+=getName(); - int nbNodes=getNumberOfNodes(); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_NODES); - double cst=1./((double)getMeshDimension()+1.); - DataArrayDouble* array=DataArrayDouble::New(); - array->alloc(nbNodes,1); - double *valsToFill=array->getPointer(); - std::fill(valsToFill,valsToFill+nbNodes,0.); - const double *values=tmp->getArray()->getConstPointer(); - DataArrayInt *da=DataArrayInt::New(); - DataArrayInt *daInd=DataArrayInt::New(); - getReverseNodalConnectivity(da,daInd); - const int *daPtr=da->getConstPointer(); - const int *daIPtr=daInd->getConstPointer(); - for(int i=0;isetMesh(this); - da->decrRef(); - daInd->decrRef(); - ret->setArray(array); - array->decrRef(); - tmp->decrRef(); - return ret; -} - -/*! - * This methods returns a vector field on cells that represents the orthogonal vector normalized of each 2D cell of this. - * This method is only callable on mesh with meshdim == 2 and spacedim==2 or 3. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const -{ - if(getMeshDimension()!=2) - throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 2 !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - DataArrayDouble *array=DataArrayDouble::New(); - int nbOfCells=getNumberOfCells(); - array->alloc(nbOfCells,3); - double *vals=array->getPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const int *conn=_nodal_connec->getConstPointer(); - const double *coords=_coords->getConstPointer(); - DataArrayDouble *loc=getBarycenterAndOwner(); - const double *locPtr=loc->getConstPointer(); - if(getSpaceDimension()==3) - { - for(int i=0;i(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals); - double n=INTERP_KERNEL::norm<3>(vals); - std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies(),1./n)); - } - } - else - { - for(int i=0;isetArray(array); - loc->decrRef(); - array->decrRef(); - ret->setMesh(this); - return ret; -} - -/*! - * This methods returns a vector newly created field on cells that represents the direction vector of each 1D cell of this. - * This method is only callable on mesh with meshdim == 1 containing only SEG2. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const -{ - if(getMeshDimension()!=1) - throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for buildDirectionVectorField !"); - if(_types.size()!=1 || *(_types.begin())!=INTERP_KERNEL::NORM_SEG2) - throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for buildDirectionVectorField !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - DataArrayDouble *array=DataArrayDouble::New(); - int nbOfCells=getNumberOfCells(); - int spaceDim=getSpaceDimension(); - array->alloc(nbOfCells,spaceDim); - double *pt=array->getPointer(); - const double *coo=getCoords()->getConstPointer(); - std::vector conn; - conn.reserve(2); - for(int i=0;i()); - } - ret->setArray(array); - array->decrRef(); - ret->setMesh(this); - return ret; -} - -/*! - * This method is only callable on mesh with meshdim == 1 containing only SEG2 and spaceDim==3. - * This method projects this on the 3D line defined by (pt,v). This methods first checks that all SEG2 are along v vector. - * @param pt reference point of the line - * @param v normalized director vector of the line - * @param eps max precision before throwing an exception - * @param res output of size this->getNumberOfCells - */ -void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps, double *res) const -{ - if(getMeshDimension()!=1) - throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for project1D !"); - if(_types.size()!=1 || *(_types.begin())!=INTERP_KERNEL::NORM_SEG2) - throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for project1D !"); - if(getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Expected a umesh with spaceDim==3 for project1D !"); - MEDCouplingFieldDouble *f=buildDirectionVectorField(); - const double *fPtr=f->getArray()->getConstPointer(); - double tmp[3]; - for(int i=0;i(tmp); - n1/=INTERP_KERNEL::norm<3>(tmp1); - if(n1>eps) - { - f->decrRef(); - throw INTERP_KERNEL::Exception("UMesh::Projection 1D failed !"); - } - } - const double *coo=getCoords()->getConstPointer(); - for(int i=0;i()); - std::transform(tmp,tmp+3,v,tmp,std::multiplies()); - res[i]=std::accumulate(tmp,tmp+3,0.); - } - f->decrRef(); -} - -/*! - * Returns a cell if any that contains the point located on 'pos' with precison eps. - * If 'pos' is outside 'this' -1 is returned. If several cells contain this point the cell with the smallest id is returned. - */ -int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) const -{ - std::vector elts; - getCellsContainingPoint(pos,eps,elts); - if(elts.empty()) - return -1; - return elts.front(); -} - -/*! - * Returns all cellIds in 'elts' of point 'pos' with eps accuracy. - */ -void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const -{ - std::vector eltsIndex; - getCellsContainingPoints(pos,1,eps,elts,eltsIndex); -} - -namespace ParaMEDMEM -{ - template - class DummyClsMCUG - { - public: - static const int MY_SPACEDIM=SPACEDIMM; - static const int MY_MESHDIM=8; - typedef int MyConnType; - static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; - // begin - // useless, but for windows compilation ... - const double* getCoordinatesPtr() const { return 0; } - const int* getConnectivityPtr() const { return 0; } - const int* getConnectivityIndexPtr() const { return 0; } - INTERP_KERNEL::NormalizedCellType getTypeOfElement(int) const { return (INTERP_KERNEL::NormalizedCellType)0; } - // end - }; -} - -template -void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints, - double eps, std::vector& elts, std::vector& eltsIndex) const -{ - std::vector bbox; - eltsIndex.resize(nbOfPoints+1); - eltsIndex[0]=0; - elts.clear(); - getBoundingBoxForBBTree(bbox); - int nbOfCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - double bb[2*SPACEDIM]; - for(int j=0;j::max(); bb[2*j+1]=-std::numeric_limits::max(); } - BBTree myTree(&bbox[0],0,0,nbOfCells,-eps); - for(int i=0;i candidates; - myTree.getIntersectingElems(bb,candidates); - for(std::vector::const_iterator iter=candidates.begin();iter!=candidates.end();iter++) - { - int sz=connI[(*iter)+1]-connI[*iter]-1; - if(INTERP_KERNEL::PointLocatorAlgos >::isElementContainsPoint(pos+i*SPACEDIM, - (INTERP_KERNEL::NormalizedCellType)conn[connI[*iter]], - coords,conn+connI[*iter]+1,sz,eps)) - { - eltsIndex[i+1]++; - elts.push_back(*iter); - } - } - } -} - -void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, - std::vector& elts, std::vector& eltsIndex) const -{ - int spaceDim=getSpaceDimension(); - int mDim=getMeshDimension(); - if(spaceDim==3) - { - if(mDim==3) - { - const double *coords=_coords->getConstPointer(); - getCellsContainingPointsAlg<3>(coords,pos,nbOfPoints,eps,elts,eltsIndex); - } - /*else if(mDim==2) - { - - }*/ - else - throw INTERP_KERNEL::Exception("For spaceDim==3 only meshDim==3 implemented for getelementscontainingpoints !"); - } - else if(spaceDim==2) - { - if(mDim==2) - { - const double *coords=_coords->getConstPointer(); - getCellsContainingPointsAlg<2>(coords,pos,nbOfPoints,eps,elts,eltsIndex); - } - else - throw INTERP_KERNEL::Exception("For spaceDim==2 only meshDim==2 implemented for getelementscontainingpoints !"); - } - - - -} - -/*! - * This method is only available for a mesh with meshDim==2 and spaceDim==2||spaceDim==3. - * This method returns a vector 'cells' where all detected butterfly cells have been added to cells. - * A 2D cell is considered to be butterfly if it exists at least one pair of distinct edges of it that intersect each other - * anywhere excepted their extremities. An INTERP_KERNEL::NORM_NORI3 could \b not be butterfly. - */ -void MEDCouplingUMesh::checkButterflyCells(std::vector& cells) const -{ - const char msg[]="Butterfly detection work only for 2D cells with spaceDim==2 or 3!"; - if(getMeshDimension()!=2) - throw INTERP_KERNEL::Exception(msg); - int spaceDim=getSpaceDimension(); - if(spaceDim!=2 && spaceDim!=3) - throw INTERP_KERNEL::Exception(msg); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - std::vector cell2DinS2; - for(int i=0;icheckFullyDefined(); - if(getMeshDimension()!=2 || getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMeshFromThis method : must be meshDim==2 and spaceDim ==3 !"); - if(mesh1D->getMeshDimension()!=1 || mesh1D->getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMeshFromThis method : must be meshDim==1 and spaceDim ==3 !"); - bool isQuad=false; - if(isPresenceOfQuadratic()) - { - if(mesh1D->isFullyQuadratic()) - isQuad=true; - else - throw INTERP_KERNEL::Exception("Invalid 2D mesh and 1D mesh because 2D mesh has quadratic cells and 1D is not fully quadratic !"); - } - zipCoords(); - int oldNbOfNodes=getNumberOfNodes(); - DataArrayDouble *newCoords=0; - switch(policy) - { - case 0: - { - newCoords=fillExtCoordsUsingTranslation(mesh1D,isQuad); - break; - } - default: - throw INTERP_KERNEL::Exception("Not implemented extrusion policy : must be in (0) !"); - } - setCoords(newCoords); - newCoords->decrRef(); - MEDCouplingUMesh *ret=buildExtrudedMeshFromThisLowLev(oldNbOfNodes,isQuad); - updateTime(); - return ret; -} - -/*! - * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMeshFromThis method. - * @param mesh1D is the input 1D mesh used for translation computation. - * @return newCoords new coords filled by this method. - */ -DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const -{ - int oldNbOfNodes=getNumberOfNodes(); - int nbOf1DCells=mesh1D->getNumberOfCells(); - DataArrayDouble *ret=DataArrayDouble::New(); - std::vector isQuads; - int nbOfLevsInVec=isQuad?2*nbOf1DCells+1:nbOf1DCells+1; - ret->alloc(oldNbOfNodes*nbOfLevsInVec,3); - double *retPtr=ret->getPointer(); - const double *coords=getCoords()->getConstPointer(); - double *work=std::copy(coords,coords+3*oldNbOfNodes,retPtr); - std::vector v; - std::vector c; - double vec[3]; - v.reserve(3); - c.reserve(6); - for(int i=0;igetNodeIdsOfCell(i,v); - c.resize(0); - mesh1D->getCoordinatesOfNode(v[isQuad?2:1],c); - mesh1D->getCoordinatesOfNode(v[0],c); - std::transform(c.begin(),c.begin()+3,c.begin()+3,vec,std::minus()); - for(int j=0;j()); - if(isQuad) - { - c.resize(0); - mesh1D->getCoordinatesOfNode(v[1],c); - mesh1D->getCoordinatesOfNode(v[0],c); - std::transform(c.begin(),c.begin()+3,c.begin()+3,vec,std::minus()); - for(int j=0;j()); - } - } - ret->copyStringInfoFrom(*getCoords()); - return ret; -} - -/*! - * This method is private because not easy to use for end user. This method is const contrary to - * MEDCouplingUMesh::buildExtrudedMeshFromThis method because this->_coords are expected to contain - * the coords sorted slice by slice. - * @param isQuad specifies presence of quadratic cells. - */ -MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThisLowLev(int nbOfNodesOf1Lev, bool isQuad) const -{ - int nbOf1DCells=getNumberOfNodes()/nbOfNodesOf1Lev-1; - int nbOf2DCells=getNumberOfCells(); - int nbOf3DCells=nbOf2DCells*nbOf1DCells; - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("Extruded",3); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - DataArrayInt *newConn=DataArrayInt::New(); - DataArrayInt *newConnI=DataArrayInt::New(); - newConnI->alloc(nbOf3DCells+1,1); - int *newConnIPtr=newConnI->getPointer(); - *newConnIPtr++=0; - std::vector newc; - for(int j=0;jalloc(newc.size()*nbOf1DCells,1); - int *newConnPtr=newConn->getPointer(); - int deltaPerLev=isQuad?2*nbOfNodesOf1Lev:nbOfNodesOf1Lev; - newConnIPtr=newConnI->getPointer(); - for(int iz=0;iz(),newConnIPtr[iz*nbOf2DCells])); - for(std::vector::const_iterator iter=newc.begin();iter!=newc.end();iter++,newConnPtr++) - { - int icell=iter-newc.begin(); - if(std::find(newConnIPtr,newConnIPtr+nbOf2DCells,icell)==newConnIPtr+nbOf2DCells) - { - if(*iter!=-1) - *newConnPtr=(*iter)+iz*deltaPerLev; - else - *newConnPtr=-1; - } - else - *newConnPtr=(*iter); - } - } - ret->setConnectivity(newConn,newConnI,true); - newConn->decrRef(); - newConnI->decrRef(); - ret->setCoords(getCoords()); - return ret; -} - -/*! - * This method returns if 'this' is constituted by only quadratic cells. - */ -bool MEDCouplingUMesh::isFullyQuadratic() const -{ - checkFullyDefined(); - bool ret=true; - int nbOfCells=getNumberOfCells(); - for(int i=0;i newConn=DataArrayInt::New(); - MEDCouplingAutoRefCountObjectPtr newConnI=DataArrayInt::New(); - newConn->alloc(getMeshLength()-delta,1); - newConnI->alloc(nbOfCells+1,1); - const int *icptr=_nodal_connec->getConstPointer(); - const int *iciptr=_nodal_connec_index->getConstPointer(); - int *ocptr=newConn->getPointer(); - int *ociptr=newConnI->getPointer(); - *ociptr=0; - _types.clear(); - for(int i=0;i& cells) const throw(INTERP_KERNEL::Exception) -{ - if(getMeshDimension()!=2 || getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid mesh to apply are2DCellsNotCorrectlyOriented on it : must be meshDim==2 and spaceDim==3 !"); - int nbOfCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); - for(int i=0;igetPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); - bool isModified=false; - for(int i=0;i tmp(connI[i+1]-connI[i]-2); - std::copy(conn+connI[i]+2,conn+connI[i+1],tmp.rbegin()); - std::copy(tmp.begin(),tmp.end(),conn+connI[i]+2); - } - } - if(isModified) - _nodal_connec->declareAsNew(); - updateTime(); -} - -/*! - * This method checks that all polyhedrons cells have correctly oriented faces. - * If not, 'cells' parameter will be appended with cellIds of incorrect cells. - * @throw when 'this' is not a mesh with meshdim==3 and spacedim==3 - */ -void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector& cells) const throw(INTERP_KERNEL::Exception) -{ - if(getMeshDimension()!=3 || getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid mesh to apply arePolyhedronsNotCorrectlyOriented on it : must be meshDim==3 and spaceDim==3 !"); - int nbOfCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); - for(int i=0;igetPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); - bool isModified=false; - for(int i=0;ideclareAsNew(); - updateTime(); -} - -/*! - * This method has a sense for meshes with spaceDim==3 and meshDim==2. - * If it is not the case an exception will be thrown. - * This method is fast because the first cell of 'this' is used to compute the plane. - * @param vec output of size at least 3 used to store the normal vector (with norm equal to Area ) of searched plane. - * @param pos output of size at least 3 used to store a point owned of searched plane. - */ -void MEDCouplingUMesh::getFastAveragePlaneOfThis(double *vec, double *pos) const throw(INTERP_KERNEL::Exception) -{ - if(getMeshDimension()!=2 || getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid mesh to apply getFastAveragePlaneOfThis on it : must be meshDim==2 and spaceDim==3 !"); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); - INTERP_KERNEL::areaVectorOfPolygon(conn+1,connI[1]-connI[0]-1,coordsPtr,vec); - std::copy(coordsPtr+3*conn[1],coordsPtr+3*conn[1]+3,pos); -} - -/*! - * The returned newly created field has to be managed by the caller. - * This method returns a field on cell with no time lying on 'this'. The meshdimension and spacedimension of this are expected to be both in [2,3]. If not an exception will be thrown. - * This method for the moment only deals with NORM_TRI3, NORM_QUAD4 and NORM_TETRA4 geometric types. - * If a cell has an another type an exception will be thrown. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const throw(INTERP_KERNEL::Exception) -{ - checkCoherency(); - int spaceDim=getSpaceDimension(); - int meshDim=getMeshDimension(); - if(spaceDim!=2 && spaceDim!=3) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getEdgeRatioField : SpaceDimension must be equal to 2 or 3 !"); - if(meshDim!=2 && meshDim!=3) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getEdgeRatioField : MeshDimension must be equal to 2 or 3 !"); - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - ret->setMesh(this); - int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); - arr->alloc(nbOfCells,1); - double *pt=arr->getPointer(); - ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); - double tmp[12]; - for(int i=0;isetName("EdgeRatio"); - ret->incrRef(); - return ret; -} - -/*! - * The returned newly created field has to be managed by the caller. - * This method returns a field on cell with no time lying on 'this'. The meshdimension and spacedimension of this are expected to be both in [2,3]. If not an exception will be thrown. - * This method for the moment only deals with NORM_TRI3, NORM_QUAD4 and NORM_TETRA4 geometric types. - * If a cell has an another type an exception will be thrown. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const throw(INTERP_KERNEL::Exception) -{ - checkCoherency(); - int spaceDim=getSpaceDimension(); - int meshDim=getMeshDimension(); - if(spaceDim!=2 && spaceDim!=3) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAspectRatioField : SpaceDimension must be equal to 2 or 3 !"); - if(meshDim!=2 && meshDim!=3) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAspectRatioField : MeshDimension must be equal to 2 or 3 !"); - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - ret->setMesh(this); - int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); - arr->alloc(nbOfCells,1); - double *pt=arr->getPointer(); - ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); - double tmp[12]; - for(int i=0;isetName("AspectRatio"); - ret->incrRef(); - return ret; -} - -/*! - * The returned newly created field has to be managed by the caller. - * This method returns a field on cell with no time lying on 'this'. The meshdimension must be equal to 2 and the spacedimension must be equal to 3. If not an exception will be thrown. - * This method for the moment only deals with NORM_QUAD4 geometric type. - * If a cell has an another type an exception will be thrown. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const throw(INTERP_KERNEL::Exception) -{ - checkCoherency(); - int spaceDim=getSpaceDimension(); - int meshDim=getMeshDimension(); - if(spaceDim!=3) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getWarpField : SpaceDimension must be equal to 3 !"); - if(meshDim!=2) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getWarpField : MeshDimension must be equal to 2 !"); - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - ret->setMesh(this); - int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); - arr->alloc(nbOfCells,1); - double *pt=arr->getPointer(); - ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); - double tmp[12]; - for(int i=0;isetName("Warp"); - ret->incrRef(); - return ret; -} - -/*! - * The returned newly created field has to be managed by the caller. - * This method returns a field on cell with no time lying on 'this'. The meshdimension must be equal to 2 and the spacedimension must be equal to 3. If not an exception will be thrown. - * This method for the moment only deals with NORM_QUAD4 geometric type. - * If a cell has an another type an exception will be thrown. - */ -MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const throw(INTERP_KERNEL::Exception) -{ - checkCoherency(); - int spaceDim=getSpaceDimension(); - int meshDim=getMeshDimension(); - if(spaceDim!=3) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getSkewField : SpaceDimension must be equal to 3 !"); - if(meshDim!=2) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getSkewField : MeshDimension must be equal to 2 !"); - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - ret->setMesh(this); - int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); - arr->alloc(nbOfCells,1); - double *pt=arr->getPointer(); - ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); - double tmp[12]; - for(int i=0;isetName("Skew"); - ret->incrRef(); - return ret; -} - -/*! - * This method aggregate the bbox of each cell and put it into bbox parameter. - * @param bbox out parameter of size 2*spacedim*nbOfcells. - */ -void MEDCouplingUMesh::getBoundingBoxForBBTree(std::vector& bbox) const -{ - int spaceDim=getSpaceDimension(); - int nbOfCells=getNumberOfCells(); - bbox.resize(2*nbOfCells*spaceDim); - for(int i=0;i::max(); - bbox[2*i+1]=-std::numeric_limits::max(); - } - const double *coordsPtr=_coords->getConstPointer(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - for(int i=0;i=0) - for(int k=0;kgetConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - std::set types; - for(const int *i=connI;i!=connI+nbOfCells;) - { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; - if(types.find(curType)!=types.end()) - return false; - types.insert(curType); - i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType)); - } - return true; -} - -/*! - * This method performs the same job as checkConsecutiveCellTypes except that the order of types sequence is analyzed to check - * that the order is specified in array defined by [orderBg,orderEnd). - */ -bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const -{ - checkFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - int lastPos=-1; - for(const int *i=connI;i!=connI+nbOfCells;) - { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; - int pos=std::distance(orderBg,std::find(orderBg,orderEnd,curType)); - if(pos<=lastPos) - return false; - lastPos=pos; - i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType)); - } - return true; -} - -/*! - * This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specfied by [orderBg,orderEnd) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation is 'this'. - * This method returns an array of size getNumberOfCells() that gives a renumber array old2New that can be used as input of MEDCouplingMesh::renumberCells. - * The mesh after this call will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs. - * The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same. - */ -DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const -{ - checkFullyDefined(); - int nbOfCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - int *tmp=new int[nbOfCells]; - int minPos=std::numeric_limits::max(); - for(const int *i=connI;i!=connI+nbOfCells;i++) - { - int pos=std::distance(orderBg,std::find(orderBg,orderEnd,(INTERP_KERNEL::NormalizedCellType)conn[*i])); - tmp[std::distance(connI,i)]=pos; - minPos=std::min(minPos,pos); - } - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(nbOfCells,1); - int *optr=ret->getPointer(); - int k=0; - while(minPos!=std::numeric_limits::max()) - { - int nextMinPos=std::numeric_limits::max(); - for(int j=0;j::max(); - } - else - nextMinPos=std::min(nextMinPos,tmp[j]); - } - minPos=nextMinPos; - } - delete [] tmp; - return ret; -} - -/*! - * This method reorganize the cells of 'this' so that the cells with same geometric types are put together. - * If checkConsecutiveCellTypes() returns true, this method do not change anything of this. - * The number of cells remains unchanged after the call of this method. - * @return the array giving the correspondance old to new. - */ -DataArrayInt *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes() -{ - checkFullyDefined(); - computeTypes(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - std::vector types; - for(const int *i=connI;i!=connI+nbOfCells && (types.size()!=_types.size());) - if(std::find(types.begin(),types.end(),(INTERP_KERNEL::NormalizedCellType)conn[*i])==types.end()) - { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; - types.push_back(curType); - for(i++;i!=connI+nbOfCells && (INTERP_KERNEL::NormalizedCellType)conn[*i]==curType;i++); - } - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(nbOfCells,1); - int *retPtr=ret->getPointer(); - std::fill(retPtr,retPtr+nbOfCells,-1); - int newCellId=0; - for(std::vector::const_iterator iter=types.begin();iter!=types.end();iter++) - { - for(const int *i=connI;i!=connI+nbOfCells;i++) - if((INTERP_KERNEL::NormalizedCellType)conn[*i]==(*iter)) - retPtr[std::distance(connI,i)]=newCellId++; - } - renumberCells(retPtr,false); - return ret; -} - -/*! - * This methods split this into as mush as untructured meshes that consecutive set of same type cells. - * So this method has typically a sense if MEDCouplingUMesh::checkConsecutiveCellTypes has a sense. - * This method makes asumption that connectivity is correctly set before calling. - */ -std::vector MEDCouplingUMesh::splitByType() const -{ - checkFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - std::vector ret; - for(const int *i=connI;i!=connI+nbOfCells;) - { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; - int beginCellId=std::distance(connI,i); - i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType)); - int endCellId=std::distance(connI,i); - int sz=endCellId-beginCellId; - int *cells=new int[sz]; - for(int j=0;jgetNumberOfTuples()getNumberOfCells(). This method makes the assumption that ids contained in 'da' - * are in [0:getNumberOfCells()) - */ -DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception) -{ - checkFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - std::set types=getAllTypes(); - int *tmp=new int[nbOfCells]; - for(std::set::const_iterator iter=types.begin();iter!=types.end();iter++) - { - int j=0; - for(const int *i=connI;i!=connI+nbOfCells;i++) - if((INTERP_KERNEL::NormalizedCellType)conn[*i]==(*iter)) - tmp[std::distance(connI,i)]=j++; - } - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(da->getNumberOfTuples(),da->getNumberOfComponents()); - ret->copyStringInfoFrom(*da); - int *retPtr=ret->getPointer(); - const int *daPtr=da->getConstPointer(); - int nbOfElems=da->getNbOfElems(); - for(int k=0;k& idsPerGeoType) const -{ - std::vector idsTokeep; - int nbOfCells=getNumberOfCells(); - int j=0; - for(int i=0;i(ret); - if(!ret2) - { - ret->decrRef(); - return 0; - } - ret2->setName(getName()); - return ret2; -} - -/*! - * Returns a newly created mesh (with ref count ==1) that contains merge of 'this' and 'other'. - */ -MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) const -{ - if(other->getType()!=UNSTRUCTURED) - throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh each other !"); - const MEDCouplingUMesh *otherC=static_cast(other); - return mergeUMeshes(this,otherC); -} - -/*! - * Returns an array with this->getNumberOfCells() tuples and this->getSpaceDimension() dimension. - * The false barycenter is computed that is to say barycenter of a cell is computed using average on each - * components of coordinates of the cell. - */ -DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const -{ - DataArrayDouble *ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - int nbOfCells=getNumberOfCells(); - ret->alloc(nbOfCells,spaceDim); - double *ptToFill=ret->getPointer(); - double *tmp=new double[spaceDim]; - const int *nodal=_nodal_connec->getConstPointer(); - const int *nodalI=_nodal_connec_index->getConstPointer(); - const double *coor=_coords->getConstPointer(); - for(int i=0;i(type,nodal+nodalI[i]+1,nodalI[i+1]-nodalI[i]-1,coor,spaceDim,ptToFill); - ptToFill+=spaceDim; - } - delete [] tmp; - return ret; -} - -/*! - * Returns a newly created mesh (with ref count ==1) that contains merge of 'mesh1' and 'other'. - * The coords of 'mesh2' are added at the end of coords of 'mesh1'. - */ -MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setName("merge"); - DataArrayDouble *pts=mergeNodesArray(mesh1,mesh2); - ret->setCoords(pts); - pts->decrRef(); - int meshDim=mesh1->getMeshDimension(); - if(meshDim!=mesh2->getMeshDimension()) - throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, mergeMeshes impossible !"); - ret->setMeshDimension(meshDim); - int delta=mesh1->getMeshLength(); - int pos=mesh1->getNumberOfCells(); - int nbOfCells2=mesh2->getNumberOfCells(); - int end=mesh1->getNumberOfCells()+nbOfCells2+1; - DataArrayInt *nodalIndex=DataArrayInt::aggregate(mesh1->getNodalConnectivityIndex(), - mesh2->getNodalConnectivityIndex(),1); - std::transform(nodalIndex->getConstPointer()+pos+1,nodalIndex->getConstPointer()+end, - nodalIndex->getPointer()+pos+1,std::bind2nd(std::plus(),delta)); - DataArrayInt *newNodal2=mesh2->getNodalConnectivity()->deepCopy(); - delta=mesh1->getNumberOfNodes(); - const int *nI2=mesh2->getNodalConnectivityIndex()->getConstPointer(); - int *pt=newNodal2->getPointer(); - for(int i=0;igetNodalConnectivity(),newNodal2,0); - newNodal2->decrRef(); - ret->setConnectivity(nodal,nodalIndex,true); - nodalIndex->decrRef(); - nodal->decrRef(); - return ret; -} - -/*! - * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim. - * 'meshes' must be a non empty vector. - */ -MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vector& meshes) -{ - if(meshes.empty()) - throw INTERP_KERNEL::Exception("meshes input parameter is expected to be non empty."); - DataArrayDouble *coords=meshes.front()->getCoords(); - int meshDim=meshes.front()->getMeshDimension(); - std::vector::const_iterator iter=meshes.begin(); - int meshLgth=0; - int meshIndexLgth=0; - for(;iter!=meshes.end();iter++) - { - if(coords!=(*iter)->getCoords()) - throw INTERP_KERNEL::Exception("meshes does not share the same coords ! Try using tryToShareSameCoords method !"); - if(meshDim!=(*iter)->getMeshDimension()) - throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, fuseUMeshesOnSameCoords impossible !"); - meshLgth+=(*iter)->getMeshLength(); - meshIndexLgth+=(*iter)->getNumberOfCells(); - } - DataArrayInt *nodal=DataArrayInt::New(); - nodal->alloc(meshLgth,1); - int *nodalPtr=nodal->getPointer(); - DataArrayInt *nodalIndex=DataArrayInt::New(); - nodalIndex->alloc(meshIndexLgth+1,1); - int *nodalIndexPtr=nodalIndex->getPointer(); - int offset=0; - for(iter=meshes.begin();iter!=meshes.end();iter++) - { - const int *nod=(*iter)->getNodalConnectivity()->getConstPointer(); - const int *index=(*iter)->getNodalConnectivityIndex()->getConstPointer(); - int nbOfCells=(*iter)->getNumberOfCells(); - int meshLgth=(*iter)->getMeshLength(); - nodalPtr=std::copy(nod,nod+meshLgth,nodalPtr); - if(iter!=meshes.begin()) - nodalIndexPtr=std::transform(index+1,index+nbOfCells+1,nodalIndexPtr,std::bind2nd(std::plus(),offset)); - else - nodalIndexPtr=std::copy(index,index+nbOfCells+1,nodalIndexPtr); - offset+=meshLgth; - } - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setName("merge"); - ret->setMeshDimension(meshDim); - ret->setConnectivity(nodal,nodalIndex,true); - ret->setCoords(coords); - nodalIndex->decrRef(); - nodal->decrRef(); - return ret; -} - -/*! - * This method fuses meshes 'meshes' and returns the fused mesh and the correspondances arrays for each mesh in 'meshes' in returned mesh. - * If a same cell is detected in several meshes in 'meshes', this cell will appear only once in returned mesh (see ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer for more details) - * - * @param meshes input non empty vector containing meshes having same coordiantes array and same mesh dimension. - * @param compType see MEDCouplingUMesh::zipConnectivityTraducer - * @param corr output vector with same size as 'meshes' parameter. corr[i] is the correspondance array of mesh meshes[i] in returned mesh. - * The arrays contained in 'corr' parameter are returned with refcounter set to one. - * To avoid memory leaks the caller have to deal with each instances of DataArrayInt contained in 'corr' parameter. - * @return The mesh lying on the same coordinates than those in meshes. All cells in 'meshes' are in returned mesh with - * @exception if meshes is a empty vector or meshes are not lying on same coordinates or meshes not have the same dimension. - */ -MEDCouplingUMesh *MEDCouplingUMesh::fuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr) -{ - //All checks are delegated to mergeUMeshesOnSameCoords - MEDCouplingUMesh *ret=mergeUMeshesOnSameCoords(meshes); - DataArrayInt *o2n=ret->zipConnectivityTraducer(compType); - corr.resize(meshes.size()); - int nbOfMeshes=meshes.size(); - int offset=0; - const int *o2nPtr=o2n->getConstPointer(); - for(int i=0;igetNumberOfCells(); - tmp->alloc(curNbOfCells,1); - std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer()); - offset+=curNbOfCells; - corr[i]=tmp; - } - o2n->decrRef(); - return ret; -} - -/*! - * This method takes in input a cell defined by its MEDcouplingUMesh connectivity [connBg,connEnd) and returns its extruded cell by inserting the result at the end of ret. - * @param nbOfNodesPerLev in parameter that specifies the number of nodes of one slice of global dataset - * @param isQuad specifies the policy of connectivity. - * @ret in/out parameter in which the result will be append - */ -void MEDCouplingUMesh::appendExtrudedCell(const int *connBg, const int *connEnd, int nbOfNodesPerLev, bool isQuad, std::vector& ret) -{ - INTERP_KERNEL::NormalizedCellType flatType=(INTERP_KERNEL::NormalizedCellType)connBg[0]; - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(flatType); - ret.push_back(cm.getExtrudedType()); - int deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev; - switch(flatType) - { - case INTERP_KERNEL::NORM_POINT0: - { - ret.push_back(connBg[1]); - ret.push_back(connBg[1]+nbOfNodesPerLev); - break; - } - case INTERP_KERNEL::NORM_SEG2: - { - int conn[4]={connBg[1],connBg[2],connBg[2]+deltaz,connBg[1]+deltaz}; - ret.insert(ret.end(),conn,conn+4); - break; - } - case INTERP_KERNEL::NORM_SEG3: - { - int conn[8]={connBg[1],connBg[3],connBg[3]+deltaz,connBg[1]+deltaz,connBg[2],connBg[3]+nbOfNodesPerLev,connBg[2]+deltaz,connBg[1]+nbOfNodesPerLev}; - ret.insert(ret.end(),conn,conn+8); - break; - } - case INTERP_KERNEL::NORM_QUAD4: - { - int conn[8]={connBg[1],connBg[2],connBg[3],connBg[4],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz,connBg[4]+deltaz}; - ret.insert(ret.end(),conn,conn+8); - break; - } - case INTERP_KERNEL::NORM_TRI3: - { - int conn[6]={connBg[1],connBg[2],connBg[3],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz}; - ret.insert(ret.end(),conn,conn+6); - break; - } - case INTERP_KERNEL::NORM_TRI6: - { - int conn[15]={connBg[1],connBg[2],connBg[3],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz,connBg[4],connBg[5],connBg[6],connBg[4]+deltaz,connBg[5]+deltaz,connBg[6]+deltaz, - connBg[1]+nbOfNodesPerLev,connBg[2]+nbOfNodesPerLev,connBg[3]+nbOfNodesPerLev}; - ret.insert(ret.end(),conn,conn+15); - break; - } - case INTERP_KERNEL::NORM_QUAD8: - { - int conn[20]={ - connBg[1],connBg[2],connBg[3],connBg[4],connBg[1]+deltaz,connBg[2]+deltaz,connBg[3]+deltaz,connBg[4]+deltaz, - connBg[5],connBg[6],connBg[7],connBg[8],connBg[5]+deltaz,connBg[6]+deltaz,connBg[7]+deltaz,connBg[8]+deltaz, - connBg[1]+nbOfNodesPerLev,connBg[2]+nbOfNodesPerLev,connBg[3]+nbOfNodesPerLev,connBg[4]+nbOfNodesPerLev - }; - ret.insert(ret.end(),conn,conn+20); - break; - } - case INTERP_KERNEL::NORM_POLYGON: - { - std::back_insert_iterator< std::vector > ii(ret); - std::copy(connBg+1,connEnd,ii); - *ii++=-1; - std::reverse_iterator rConnBg(connEnd); - std::reverse_iterator rConnEnd(connBg+1); - std::transform(rConnBg,rConnEnd,ii,std::bind2nd(std::plus(),deltaz)); - int nbOfRadFaces=std::distance(connBg+1,connEnd); - for(int i=0;i > edges; - int nbOfFaces=std::count(begin,end,-1)+1; - const int *bgFace=begin; - for(int i=0;i p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]); - if(std::find(edges.begin(),edges.end(),p1)!=edges.end()) - return false; - edges.push_back(p1); - } - bgFace=endFace+1; - } - return INTERP_KERNEL::calculateVolumeForPolyh2(begin,std::distance(begin,end),coords)>-EPS_FOR_POLYH_ORIENTATION; -} - -/*! - * This method tries to obtain a well oriented polyhedron. - * If the algorithm fails, an exception will be thrown. - */ -void MEDCouplingUMesh::tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception) -{ - std::vector > edges; - int nbOfFaces=std::count(begin,end,-1)+1; - int *bgFace=begin; - std::vector isPerm(nbOfFaces); - for(int i=0;i p1(bgFace[l],bgFace[(l+1)%nbOfEdgesInFace]); - edges.push_back(p1); - } - int *bgFace2=endFace+1; - for(int k=i+1;k p2(bgFace2[j],bgFace2[(j+1)%nbOfEdgesInFace2]); - if(std::find(edges.begin(),edges.end(),p2)!=edges.end()) - { - if(isPerm[k]) - throw INTERP_KERNEL::Exception("Fail to repare polyhedron ! Polyedron looks bad !"); - std::vector tmp(nbOfEdgesInFace2-1); - std::copy(bgFace2+1,endFace2,tmp.rbegin()); - std::copy(tmp.begin(),tmp.end(),bgFace2+1); - isPerm[k]=true; - continue; - } - } - bgFace2=endFace2+1; - } - bgFace=endFace+1; - } - if(INTERP_KERNEL::calculateVolumeForPolyh2(begin,std::distance(begin,end),coords)<-EPS_FOR_POLYH_ORIENTATION) - {//not lucky ! The first face was not correctly oriented : reorient all faces... - bgFace=begin; - for(int i=0;i tmp(nbOfEdgesInFace-1); - std::copy(bgFace+1,endFace,tmp.rbegin()); - std::copy(tmp.begin(),tmp.end(),bgFace+1); - bgFace=endFace+1; - } - } -} - -/*! - * This method put in zip format into parameter 'zipFrmt' in full interlace mode. - * This format is often asked by INTERP_KERNEL algorithms to avoid many indirections into coordinates array. - */ -void MEDCouplingUMesh::fillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt) throw(INTERP_KERNEL::Exception) -{ - double *w=zipFrmt; - if(spaceDim==3) - for(int i=0;i - -namespace ParaMEDMEM -{ - class MEDCouplingUMesh : public MEDCouplingPointSet - { - public: - MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(const char *meshName, int meshDim); - MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT void updateTime(); - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED; } - MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void setMeshDimension(int meshDim); - MEDCOUPLING_EXPORT void allocateCells(int nbOfCells); - MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell); - MEDCOUPLING_EXPORT void finishInsertingCells(); - MEDCOUPLING_EXPORT const std::set& getAllTypes() const { return _types; } - MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true); - MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const { return _nodal_connec; } - MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; } - MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; - MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT DataArrayInt *getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector& coo) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; - MEDCOUPLING_EXPORT std::string reprConnectivityOfThis() const; - MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const; - MEDCOUPLING_EXPORT int getNumberOfCells() const; - MEDCOUPLING_EXPORT int getMeshDimension() const; - MEDCOUPLING_EXPORT int getMeshLength() const; - MEDCOUPLING_EXPORT void computeTypes(); - //! size of returned tinyInfo must be always the same. - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); - //tools - MEDCOUPLING_EXPORT bool areCellsEqual(int cell1, int cell2, int compType) const; - MEDCOUPLING_EXPORT bool areCellsEqual0(int cell1, int cell2) const; - MEDCOUPLING_EXPORT bool areCellsEqual1(int cell1, int cell2) const; - MEDCOUPLING_EXPORT bool areCellsEqual2(int cell1, int cell2) const; - MEDCOUPLING_EXPORT bool areCellsFrom2MeshEqual(const MEDCouplingUMesh *other, int cellId, double prec) const; - MEDCOUPLING_EXPORT void convertToPolyTypes(const std::vector& cellIdsToConvert); - MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer(); - MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType); - MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const; - MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes); - MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const; - MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector& nodes) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const; - MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); - MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildDirectionVectorField() const; - MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const; - MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const; - MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; - MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const; - MEDCOUPLING_EXPORT void checkButterflyCells(std::vector& cells) const; - MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector& bbox) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy); - MEDCOUPLING_EXPORT bool isFullyQuadratic() const; - MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const; - MEDCOUPLING_EXPORT void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void are2DCellsNotCorrectlyOriented(const double *vec, bool polyOnly, std::vector& cells) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void orientCorrectly2DCells(const double *vec, bool polyOnly) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void arePolyhedronsNotCorrectlyOriented(std::vector& cells) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void getFastAveragePlaneOfThis(double *vec, double *pos) const throw(INTERP_KERNEL::Exception); - //Mesh quality - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception); - //utilities for MED File RW - MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const; - MEDCOUPLING_EXPORT bool checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const; - MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const; - MEDCOUPLING_EXPORT DataArrayInt *rearrange2ConsecutiveCellTypes(); - MEDCOUPLING_EXPORT std::vector splitByType() const; - MEDCOUPLING_EXPORT DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const std::vector& idsPerGeoType) const; - // - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const; - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const std::vector& meshes); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *fuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr); - MEDCOUPLING_EXPORT static bool isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords); - MEDCOUPLING_EXPORT static bool isPolyhedronWellOriented(const int *begin, const int *end, const double *coords); - MEDCOUPLING_EXPORT static void tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception); - private: - MEDCouplingUMesh(); - MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy); - ~MEDCouplingUMesh(); - void checkFullyDefined() const throw(INTERP_KERNEL::Exception); - void reprConnectivityOfThisLL(std::ostringstream& stream) const; - //tools - void renumberNodesInConn(const int *newNodeNumbers); - void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, std::vector& cellIdsKept) const; - MEDCouplingUMesh *buildExtrudedMeshFromThisLowLev(int nbOfNodesOf1Lev, bool isQuad) const; - DataArrayDouble *fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const; - template - void findCommonCellsBase(int compType, std::vector& res, std::vector& resI) const; - bool areCellsEqualInPool(const std::vector& candidates, int compType, std::vector& result) const; - MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const; - template - void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints, - double eps, std::vector& elts, std::vector& eltsIndex) const; - static void fillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt) throw(INTERP_KERNEL::Exception); - static void appendExtrudedCell(const int *connBg, const int *connEnd, int nbOfNodesPerLev, bool isQuad, std::vector& ret); - private: - //! this iterator stores current position in _nodal_connec array. - mutable int _iterator; - int _mesh_dim; - DataArrayInt *_nodal_connec; - DataArrayInt *_nodal_connec_index; - std::set _types; - private: - static const char PART_OF_NAME[]; - public: - static double EPS_FOR_POLYH_ORIENTATION; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx deleted file mode 100644 index f45cd5eba..000000000 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ /dev/null @@ -1,447 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingUMeshDesc.hxx" -#include "CellModel.hxx" -#include "MEDCouplingMemArray.hxx" - -#include - -using namespace ParaMEDMEM; - -MEDCouplingUMeshDesc::MEDCouplingUMeshDesc():_mesh_dim(-1),_desc_connec(0),_desc_connec_index(0), - _nodal_connec_face(0),_nodal_connec_face_index(0) -{ -} - -MEDCouplingUMeshDesc::~MEDCouplingUMeshDesc() -{ - if(_desc_connec) - _desc_connec->decrRef(); - if(_desc_connec_index) - _desc_connec_index->decrRef(); - if(_nodal_connec_face) - _nodal_connec_face->decrRef(); - if(_nodal_connec_face_index) - _nodal_connec_face_index->decrRef(); -} - -MEDCouplingUMeshDesc *MEDCouplingUMeshDesc::New() -{ - return new MEDCouplingUMeshDesc; -} - -MEDCouplingUMeshDesc *MEDCouplingUMeshDesc::New(const char *meshName, int meshDim) -{ - MEDCouplingUMeshDesc *ret=new MEDCouplingUMeshDesc; - ret->setName(meshName); - ret->setMeshDimension(meshDim); - return ret; -} - -/*! - * not implemented - */ -MEDCouplingMesh *MEDCouplingUMeshDesc::deepCpy() const -{ - return 0; -} - -void MEDCouplingUMeshDesc::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) - { - if(INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim) - { - std::ostringstream message; - message << "MeshDesc invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter); - throw INTERP_KERNEL::Exception(message.str().c_str()); - } - } -} - -void MEDCouplingUMeshDesc::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::checkDeepEquivalWith : not implemented yet !"); -} - -void MEDCouplingUMeshDesc::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::checkDeepEquivalOnSameNodesWith : not implemented yet !"); -} - -void MEDCouplingUMeshDesc::setMeshDimension(unsigned meshDim) -{ - _mesh_dim=meshDim; - declareAsNew(); -} - -int MEDCouplingUMeshDesc::getNumberOfCells() const -{ - if(_desc_connec_index) - return _desc_connec_index->getNumberOfTuples()-1; - else - throw INTERP_KERNEL::Exception("Unable to get number of cells because no connectivity specified !"); -} - -int MEDCouplingUMeshDesc::getNumberOfFaces() const -{ - if(_nodal_connec_face_index) - return _nodal_connec_face_index->getNumberOfTuples()-1; - else - throw INTERP_KERNEL::Exception("Unable to get number of faces because no connectivity specified !"); -} - -int MEDCouplingUMeshDesc::getCellMeshLength() const -{ - return _desc_connec->getNbOfElems(); -} - -int MEDCouplingUMeshDesc::getFaceMeshLength() const -{ - return _nodal_connec_face->getNbOfElems(); -} - -INTERP_KERNEL::NormalizedCellType MEDCouplingUMeshDesc::getTypeOfCell(int cellId) const -{ - const int *desc_connec=_desc_connec->getConstPointer(); - const int *desc_connec_index=_desc_connec_index->getConstPointer(); - return (INTERP_KERNEL::NormalizedCellType)desc_connec[desc_connec_index[cellId]+1]; -} - -int MEDCouplingUMeshDesc::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const -{ - const int *desc_connec=_desc_connec->getConstPointer(); - const int *desc_connec_index=_desc_connec_index->getConstPointer(); - int nbOfCells=getNumberOfCells(); - int ret=0; - for(int i=0;i& conn) const -{ - //not implemented yet. -} - -void MEDCouplingUMeshDesc::getCoordinatesOfNode(int nodeId, std::vector& coo) const -{ - //not implemented yet. -} - -std::string MEDCouplingUMeshDesc::simpleRepr() const -{ - std::string ret("Unstructured mesh with descending connectivity : "); - ret+=getName(); - ret+="\n"; - return ret; -} - -std::string MEDCouplingUMeshDesc::advancedRepr() const -{ - std::string ret("Unstructured mesh with descending connectivity : "); - ret+=getName(); - ret+="\n"; - return ret; -} - -void MEDCouplingUMeshDesc::setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx) -{ - DataArrayInt::setArrayIn(descConn,_desc_connec); - DataArrayInt::setArrayIn(descConnIndex,_desc_connec_index); - DataArrayInt::setArrayIn(nodalFaceConn,_nodal_connec_face); - DataArrayInt::setArrayIn(nodalFaceConnIndx,_nodal_connec_face_index); - computeTypes(); -} - -void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const -{ - MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings); - tinyInfo.push_back(getMeshDimension()); - tinyInfo.push_back(getNumberOfNodes()); - tinyInfo.push_back(getNumberOfCells()); - tinyInfo.push_back(getCellMeshLength()); - tinyInfo.push_back(getNumberOfFaces()); - tinyInfo.push_back(getFaceMeshLength()); -} - -bool MEDCouplingUMeshDesc::isEmptyMesh(const std::vector& tinyInfo) const -{ - return tinyInfo[5]<=0; -} - -void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) -{ - std::vector tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end()); - MEDCouplingPointSet::resizeForUnserialization(tinyInfoTmp,a1,a2,littleStrings); - a1->alloc(tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7]+tinyInfo[6]+1,1); -} - -void MEDCouplingUMeshDesc::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const -{ - MEDCouplingPointSet::serialize(a1,a2); - // - a1=DataArrayInt::New(); - a1->alloc(getCellMeshLength()+getNumberOfCells()+1+getFaceMeshLength()+getNumberOfFaces()+1,1); - int *ptA1=a1->getPointer(); - const int *descConn=_desc_connec->getConstPointer(); - const int *descConnIndex=_desc_connec_index->getConstPointer(); - const int *faceConn=_nodal_connec_face->getConstPointer(); - const int *faceConnIndex=_nodal_connec_face_index->getConstPointer(); - ptA1=std::copy(descConn,descConn+getCellMeshLength(),ptA1); - ptA1=std::copy(descConnIndex,descConnIndex+getNumberOfCells()+1,ptA1); - ptA1=std::copy(faceConn,faceConn+getFaceMeshLength(),ptA1); - std::copy(faceConnIndex,faceConnIndex+getNumberOfFaces()+1,ptA1); -} - -void MEDCouplingUMeshDesc::unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) -{ - std::vector tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end()); - MEDCouplingPointSet::unserialization(tinyInfoTmp,a1,a2,littleStrings); - // - const int *recvBuffer=a1->getConstPointer(); - DataArrayInt *descConn=DataArrayInt::New(); - descConn->alloc(tinyInfo[5],1); - std::copy(recvBuffer,recvBuffer+tinyInfo[5],descConn->getPointer()); - DataArrayInt *descConnIndex=DataArrayInt::New(); - descConnIndex->alloc(tinyInfo[4]+1,1); - std::copy(recvBuffer+tinyInfo[5],recvBuffer+tinyInfo[5]+tinyInfo[4]+1,descConnIndex->getPointer()); - DataArrayInt *faceConn=DataArrayInt::New(); - faceConn->alloc(tinyInfo[7],1); - std::copy(recvBuffer+tinyInfo[5]+tinyInfo[4]+1,recvBuffer+tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7],faceConn->getPointer()); - DataArrayInt *faceConnIndex=DataArrayInt::New(); - faceConnIndex->alloc(tinyInfo[6]+1,1); - std::copy(recvBuffer+tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7], - recvBuffer+tinyInfo[5]+tinyInfo[5]+1+tinyInfo[7]+tinyInfo[6]+1,faceConnIndex->getPointer()); - setConnectivity(descConn,descConnIndex,faceConn,faceConnIndex); - descConn->decrRef(); - descConnIndex->decrRef(); - faceConn->decrRef(); - faceConnIndex->decrRef(); - setMeshDimension(tinyInfo[2]); -} - -void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) -{ - int dim=getSpaceDimension(); - double* elem_bb=new double[2*dim]; - const int* conn = _desc_connec->getConstPointer(); - const int* conn_index= _desc_connec_index->getConstPointer(); - const int* face = _nodal_connec_face->getConstPointer(); - const int* face_index= _nodal_connec_face_index->getConstPointer(); - const double* coords = getCoords()->getConstPointer(); - int nbOfCells=getNumberOfCells(); - for ( int ielem=0; ielem::max(); - elem_bb[i*2+1]=-std::numeric_limits::max(); - } - - for (int jface=conn_index[ielem]+1; jface elem_bb[idim*2+1] ) - { - elem_bb[idim*2+1] = coords[node*dim+idim] ; - } - } - } - } - if (intersectsBoundingBox(elem_bb, bbox, dim, eps)) - { - elems.push_back(ielem); - } - } - delete [] elem_bb; -} - -void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector& elems) -{ - int dim=getSpaceDimension(); - double* elem_bb=new double[2*dim]; - const int* conn = _desc_connec->getConstPointer(); - const int* conn_index= _desc_connec_index->getConstPointer(); - const int* face = _nodal_connec_face->getConstPointer(); - const int* face_index= _nodal_connec_face_index->getConstPointer(); - const double* coords = getCoords()->getConstPointer(); - int nbOfCells=getNumberOfCells(); - for ( int ielem=0; ielem::max(); - elem_bb[i*2+1]=-std::numeric_limits::max(); - } - - for (int jface=conn_index[ielem]+1; jface elem_bb[idim*2+1] ) - { - elem_bb[idim*2+1] = coords[node*dim+idim] ; - } - } - } - } - if (intersectsBoundingBox(bbox, elem_bb, dim, eps)) - { - elems.push_back(ielem); - } - } - delete [] elem_bb; -} - -DataArrayInt *MEDCouplingUMeshDesc::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) -{ - //not implemented yet. - areNodesMerged=false; - return 0; -} - -void MEDCouplingUMeshDesc::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Not implemented yet !"); -} - -MEDCouplingPointSet *MEDCouplingUMeshDesc::buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const -{ - //not implemented yet. - return 0; -} - -MEDCouplingPointSet *MEDCouplingUMeshDesc::buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const -{ - //not implemented yet - return 0; -} - -MEDCouplingPointSet *MEDCouplingUMeshDesc::buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const -{ - //not implemented yet - return 0; -} - -void MEDCouplingUMeshDesc::findBoundaryNodes(std::vector& nodes) const -{ - //not implemented yet -} - -MEDCouplingPointSet *MEDCouplingUMeshDesc::buildBoundaryMesh(bool keepCoords) const -{ - //not implemented yet - return 0; -} - -void MEDCouplingUMeshDesc::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception("Available for UMesh desc but not implemented yet !"); -} - -void MEDCouplingUMeshDesc::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) -{ - MEDCouplingPointSet::renumberNodes(newNodeNumbers,newNbOfNodes); - //not implemented yet -} - -MEDCouplingFieldDouble *MEDCouplingUMeshDesc::getMeasureField(bool isAbs) const -{ - //not implemented yet. - return 0; -} - -MEDCouplingFieldDouble *MEDCouplingUMeshDesc::getMeasureFieldOnNode(bool isAbs) const -{ - //not implemented yet. - return 0; -} - -MEDCouplingFieldDouble *MEDCouplingUMeshDesc::buildOrthogonalField() const -{ - if(getMeshDimension()!=2) - throw INTERP_KERNEL::Exception("Expected a cmesh with meshDim == 2 !"); - //not implemented yet ! - return 0; -} - -DataArrayInt *MEDCouplingUMeshDesc::zipCoordsTraducer() -{ - //not implemented yet. - return 0; -} - -void MEDCouplingUMeshDesc::computeTypes() -{ - if(_desc_connec && _desc_connec_index) - { - _types.clear(); - const int *conn=_desc_connec->getConstPointer(); - const int *connIndex=_desc_connec_index->getConstPointer(); - int nbOfElem=_desc_connec_index->getNbOfElems()-1; - for(const int *pt=connIndex;pt!=connIndex+nbOfElem;pt++) - _types.insert((INTERP_KERNEL::NormalizedCellType)conn[*pt]); - } -} - -void MEDCouplingUMeshDesc::checkFullyDefined() const throw(INTERP_KERNEL::Exception) -{ - if(!_desc_connec || !_desc_connec_index || !_nodal_connec_face || !_nodal_connec_face_index || !_coords) - throw INTERP_KERNEL::Exception("full connectivity and coordinates not set in unstructured mesh."); -} - -MEDCouplingMesh *MEDCouplingUMeshDesc::mergeMyselfWith(const MEDCouplingMesh *other) const -{ - //not implemented yet. - return 0; -} - -DataArrayDouble *MEDCouplingUMeshDesc::getBarycenterAndOwner() const -{ - //not implemented yet. - return 0; -} - -int MEDCouplingUMeshDesc::getCellContainingPoint(const double *pos, double eps) const -{ - //not implemented yet. - return -1; -} diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx deleted file mode 100644 index 7c965a31c..000000000 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMEDMEM_MEDCOUPLINGUMESHDESC_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGUMESHDESC_HXX__ - -#include "MEDCouplingPointSet.hxx" -#include "MEDCoupling.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -#include - -namespace ParaMEDMEM -{ - class MEDCouplingUMeshDesc : public MEDCouplingPointSet - { - public: - MEDCOUPLING_EXPORT static MEDCouplingUMeshDesc *New(); - MEDCOUPLING_EXPORT static MEDCouplingUMeshDesc *New(const char *meshName, int meshDim); - MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const; - MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void setMeshDimension(unsigned meshDim); - MEDCOUPLING_EXPORT int getNumberOfCells() const; - MEDCOUPLING_EXPORT int getNumberOfFaces() const; - MEDCOUPLING_EXPORT int getCellMeshLength() const; - MEDCOUPLING_EXPORT int getFaceMeshLength() const; - MEDCOUPLING_EXPORT int getMeshDimension() const { return _mesh_dim; } - MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; - MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector& coo) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED_DESC; } - MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx); - //tools to overload - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings); - MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector& elems); - MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes); - MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const; - MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector& nodes) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const; - MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; - MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer(); - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const; - private: - MEDCouplingUMeshDesc(); - ~MEDCouplingUMeshDesc(); - void computeTypes(); - void checkFullyDefined() const throw(INTERP_KERNEL::Exception); - private: - unsigned _mesh_dim; - DataArrayInt *_desc_connec; - DataArrayInt *_desc_connec_index; - DataArrayInt *_nodal_connec_face; - DataArrayInt *_nodal_connec_face_index; - std::set _types; - }; -} - -#endif diff --git a/src/MEDCoupling/Makefile.am b/src/MEDCoupling/Makefile.am deleted file mode 100644 index 28553f288..000000000 --- a/src/MEDCoupling/Makefile.am +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (C) 2007-2010 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -if CPPUNIT_IS_OK - SUBDIRS = . Test -endif - -# first '.' says that this folder must be compiled before Test (MEDMEM/Test uses MEDMEM) - -lib_LTLIBRARIES = libmedcoupling.la libmedcouplingremapper.la - - -salomeinclude_HEADERS = MEDCoupling.hxx \ -MEDCouplingFieldDouble.hxx MEDCouplingMesh.hxx MEDCouplingUMesh.hxx MEDCouplingTimeLabel.hxx \ -MEDCouplingField.hxx MEDCouplingNormalizedUnstructuredMesh.hxx MEDCouplingMemArray.hxx \ -MEDCouplingNormalizedUnstructuredMesh.txx MEDCouplingMemArray.txx MEDCouplingRefCountObject.hxx \ -MEDCouplingCMesh.hxx MEDCouplingTimeDiscretization.hxx \ -MEDCouplingFieldDiscretization.hxx MEDCouplingPointSet.hxx MEDCouplingPointSet.txx \ -MEDCouplingUMeshDesc.hxx MEDCouplingNatureOfField.hxx \ -MEDCouplingNormalizedCartesianMesh.hxx MEDCouplingNormalizedCartesianMesh.txx \ -MEDCouplingRemapper.hxx MEDCouplingExtrudedMesh.hxx MEDCouplingGaussLocalization.hxx \ -MEDCouplingAutoRefCountObjectPtr.hxx - -# Libraries targets - -dist_libmedcoupling_la_SOURCES = \ - MEDCouplingField.cxx MEDCouplingFieldDouble.cxx \ - MEDCouplingUMesh.cxx MEDCouplingMemArray.cxx MEDCouplingTimeLabel.cxx \ - MEDCouplingCMesh.cxx MEDCouplingTimeDiscretization.cxx \ - MEDCouplingFieldDiscretization.cxx MEDCouplingRefCountObject.cxx \ - MEDCouplingPointSet.cxx MEDCouplingUMeshDesc.cxx \ - MEDCouplingExtrudedMesh.cxx MEDCouplingMesh.cxx MEDCouplingGaussLocalization.cxx \ - MEDCouplingNatureOfField.cxx - -libmedcoupling_la_LDFLAGS= - -libmedcoupling_la_CPPFLAGS= @CXXTMPDPTHFLAGS@ \ - -I$(srcdir) -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../INTERP_KERNEL/ExprEval - -# the geom2D library is included in the interpkernel one -libmedcoupling_la_LIBADD= ../INTERP_KERNEL/libinterpkernel.la - -dist_libmedcouplingremapper_la_SOURCES = MEDCouplingRemapper.cxx - -libmedcouplingremapper_la_CPPFLAGS = @CXXTMPDPTHFLAGS@ \ - -I$(srcdir) -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Geometric2D - -libmedcouplingremapper_la_LDFLAGS = - -libmedcouplingremapper_la_LIBADD = libmedcoupling.la - -AM_CPPFLAGS += $(libinterpkernel_la_CPPFLAGS) -LDADD= $(libinterpkernel_la_LDFLAGS) - -EXTRA_DIST += \ - MEDCouplingFieldDouble.hxx \ - MEDCouplingTimeDiscretization.hxx \ - MEDCouplingFieldDiscretization.hxx \ - MEDCouplingMesh.hxx \ - MEDCouplingUMesh.hxx \ - MEDCouplingCMesh.hxx \ - MEDCouplingTimeLabel.hxx \ - MEDCouplingField.hxx \ - MEDCouplingNormalizedUnstructuredMesh.hxx \ - MEDCouplingMemArray.hxx \ - MEDCouplingNormalizedUnstructuredMesh.txx \ - MEDCouplingMemArray.txx \ - MEDCouplingRefCountObject.hxx \ - MEDCouplingPointSet.hxx \ - MEDCouplingPointSet.txx \ - MEDCouplingUMeshDesc.hxx \ - MEDCouplingNatureOfField.hxx \ - MEDCouplingRemapper.hxx \ - MEDCouplingExtrudedMesh.hxx \ - MEDCouplingGaussLocalization.hxx diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx deleted file mode 100644 index 8382a9230..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright (C) 2007-2010 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 __MEDCOUPLINGBASICSTEST_HXX__ -#define __MEDCOUPLINGBASICSTEST_HXX__ - -#include - -#include -#include - -namespace ParaMEDMEM -{ - class MEDCouplingUMesh; - - class MEDCouplingBasicsTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE(MEDCouplingBasicsTest); - //MEDCouplingBasicsTest1.cxx - CPPUNIT_TEST( testArray ); - CPPUNIT_TEST( testArray2 ); - CPPUNIT_TEST( testArray3 ); - CPPUNIT_TEST( testMesh ); - CPPUNIT_TEST( testMeshPointsCloud ); - CPPUNIT_TEST( testMeshM1D ); - CPPUNIT_TEST( testDeepCopy ); - CPPUNIT_TEST( testRevNodal ); - CPPUNIT_TEST( testConvertToPolyTypes ); - CPPUNIT_TEST( testDescConn2D ); - CPPUNIT_TEST( testDescConn3D ); - CPPUNIT_TEST( testFindBoundaryNodes ); - CPPUNIT_TEST( testBoundaryMesh ); - CPPUNIT_TEST( testBuildPartOfMySelf ); - CPPUNIT_TEST( testBuildPartOfMySelfNode ); - CPPUNIT_TEST( testZipCoords ); - CPPUNIT_TEST( testZipConnectivity ); - CPPUNIT_TEST( testEqualMesh ); - CPPUNIT_TEST( testEqualFieldDouble ); - CPPUNIT_TEST( testNatureChecking ); - CPPUNIT_TEST( testBuildSubMeshData ); - CPPUNIT_TEST( testExtrudedMesh1 ); - CPPUNIT_TEST( testExtrudedMesh2 ); - CPPUNIT_TEST( testExtrudedMesh3 ); - CPPUNIT_TEST( testExtrudedMesh4 ); - CPPUNIT_TEST( testFindCommonNodes ); - CPPUNIT_TEST( testCheckButterflyCells ); - CPPUNIT_TEST( testMergeMesh1 ); - CPPUNIT_TEST( testMergeMeshOnSameCoords1 ); - CPPUNIT_TEST( testMergeField1 ); - CPPUNIT_TEST( testFillFromAnalytic ); - CPPUNIT_TEST( testFillFromAnalytic2 ); - CPPUNIT_TEST( testApplyFunc ); - CPPUNIT_TEST( testApplyFunc2 ); - CPPUNIT_TEST( testOperationsOnFields ); - CPPUNIT_TEST( testOperationsOnFields2 ); - CPPUNIT_TEST( testOperationsOnFields3 ); - CPPUNIT_TEST( testOperationsOnFields4 ); - CPPUNIT_TEST( testMergeNodesOnField ); - CPPUNIT_TEST( testCheckConsecutiveCellTypes ); - CPPUNIT_TEST( testRearrange2ConsecutiveCellTypes ); - CPPUNIT_TEST( testSplitByType ); - CPPUNIT_TEST( testFuseUMeshesOnSameCoords ); - CPPUNIT_TEST( testFuseUMeshesOnSameCoords2 ); - CPPUNIT_TEST( testBuildOrthogonalField ); - CPPUNIT_TEST( testGetCellsContainingPoint ); - CPPUNIT_TEST( testGetValueOn1 ); - CPPUNIT_TEST( testCMesh0 ); - CPPUNIT_TEST( testScale ); - CPPUNIT_TEST( testTryToShareSameCoords ); - CPPUNIT_TEST( testFindNodeOnPlane ); - CPPUNIT_TEST( testRenumberCells ); - CPPUNIT_TEST( testChangeSpaceDimension ); - //MEDCouplingBasicsTest2.cxx - CPPUNIT_TEST( testGaussPointField1 ); - CPPUNIT_TEST( testGaussPointNEField1 ); - CPPUNIT_TEST( testCellOrientation1 ); - CPPUNIT_TEST( testCellOrientation2 ); - CPPUNIT_TEST( testPolyhedronBarycenter ); - CPPUNIT_TEST( testNormL12Integ1D ); - CPPUNIT_TEST( testAreaBary2D ); - CPPUNIT_TEST( testAreaBary3D ); - CPPUNIT_TEST( testRenumberCellsForFields ); - CPPUNIT_TEST( testRenumberNodesForFields ); - CPPUNIT_TEST( testConvertQuadraticCellsToLinear ); - CPPUNIT_TEST( testCheckGeoEquivalWith ); - CPPUNIT_TEST( testCheckGeoEquivalWith2 ); - CPPUNIT_TEST( testCopyTinyStringsFromOnFields ); - CPPUNIT_TEST( testTryToShareSameCoordsPermute ); - CPPUNIT_TEST( testTryToShareSameCoordsPermute2 ); - CPPUNIT_TEST( testChangeUnderlyingMesh1 ); - CPPUNIT_TEST( testGetMaxValue1 ); - CPPUNIT_TEST( testSubstractInPlaceDM1 ); - CPPUNIT_TEST( testDotCrossProduct1 ); - CPPUNIT_TEST( testMinMaxFields1 ); - CPPUNIT_TEST( testApplyLin1 ); - CPPUNIT_TEST( testGetIdsInRange1 ); - CPPUNIT_TEST( testBuildSubPart1 ); - CPPUNIT_TEST( testDoublyContractedProduct1 ); - CPPUNIT_TEST( testDeterminant1 ); - CPPUNIT_TEST( testEigenValues1 ); - CPPUNIT_TEST( testEigenVectors1 ); - CPPUNIT_TEST( testInverse1 ); - CPPUNIT_TEST( testTrace1 ); - CPPUNIT_TEST( testDeviator1 ); - CPPUNIT_TEST( testMagnitude1 ); - CPPUNIT_TEST( testMaxPerTuple1 ); - CPPUNIT_TEST( testChangeNbOfComponents ); - CPPUNIT_TEST( testSortPerTuple1 ); - CPPUNIT_TEST( testIsEqualWithoutConsideringStr1 ); - CPPUNIT_TEST( testGetNodeIdsOfCell1 ); - CPPUNIT_TEST( testGetEdgeRatioField1 ); - //MEDCouplingBasicsTestInterp.cxx - CPPUNIT_TEST( test2DInterpP0P0_1 ); - CPPUNIT_TEST( test2DInterpP0P0PL_1 ); - CPPUNIT_TEST( test2DInterpP0P0PL_2 ); - CPPUNIT_TEST( test2DInterpP0P0PL_3 ); - CPPUNIT_TEST( test2DInterpP0P0PL_4 ); - CPPUNIT_TEST( test2DInterpP0P1_1 ); - CPPUNIT_TEST( test2DInterpP0P1PL_1 ); - CPPUNIT_TEST( test2DInterpP0P1PL_2 ); - CPPUNIT_TEST( test2DInterpP1P0_1 ); - CPPUNIT_TEST( test2DInterpP1P0PL_1 ); - CPPUNIT_TEST( test2DInterpP1P0PL_2 ); - CPPUNIT_TEST( test2DInterpP1P1_1 ); - CPPUNIT_TEST( test2DInterpP1P1PL_1 ); - CPPUNIT_TEST( test3DSurfInterpP0P0_1 ); - CPPUNIT_TEST( test3DSurfInterpP0P0PL_1 ); - CPPUNIT_TEST( test3DSurfInterpP0P1_1 ); - CPPUNIT_TEST( test3DSurfInterpP0P1PL_1 ); - CPPUNIT_TEST( test3DSurfInterpP1P0_1 ); - CPPUNIT_TEST( test3DSurfInterpP1P0PL_1 ); - CPPUNIT_TEST( test3DSurfInterpP1P1_1 ); - CPPUNIT_TEST( test3DSurfInterpP1P1PL_1 ); - CPPUNIT_TEST( test3DSurfInterpP0P0_2 ); - CPPUNIT_TEST( test3DSurfInterpP0P0_3 ); - - CPPUNIT_TEST( testInterpolationCC ); - CPPUNIT_TEST( testInterpolationCU1D ); - CPPUNIT_TEST( testInterpolationCU2D ); - CPPUNIT_TEST( testInterpolationCU3D ); - - CPPUNIT_TEST( test3DInterpP0P0_1 ); - CPPUNIT_TEST( test3DInterpP0P0PL_1 ); - CPPUNIT_TEST( test3DInterpP0P0PL_2 ); - CPPUNIT_TEST( test3DInterpP0P0PL_3 ); - CPPUNIT_TEST( test3DInterpP0P0PL_4 ); - CPPUNIT_TEST( test3DInterpP0P1_1 ); - CPPUNIT_TEST( test3DInterpP0P1PL_1 ); - CPPUNIT_TEST( test3DInterpP1P0_1 ); - CPPUNIT_TEST( test3DInterpP1P0PL_1 ); - CPPUNIT_TEST( test3DInterpP1P1_1 ); - CPPUNIT_TEST( test3DInterpP1P1PL_1 ); - CPPUNIT_TEST( test3DInterpP0P0Empty ); - CPPUNIT_TEST( test2DInterpP0IntegralUniform ); - CPPUNIT_TEST( test3DSurfInterpP0IntegralUniform ); - CPPUNIT_TEST( test3DInterpP0IntegralUniform ); - CPPUNIT_TEST( test2DInterpP1IntegralUniform ); - CPPUNIT_TEST( test3DInterpP1IntegralUniform ); - CPPUNIT_TEST( test2DInterpP1P0Bary_1 ); - CPPUNIT_TEST( test3DSurfInterpP1P0Bary_1 ); - CPPUNIT_TEST( test3DInterpP1P0Bary_1 ); - CPPUNIT_TEST( test3DTo1DInterpP0P0PL_1 ); - - CPPUNIT_TEST( test1DInterp_1 ); - CPPUNIT_TEST( test2DCurveInterpP0P0_1 ); - CPPUNIT_TEST( test2DCurveInterpP0P0_2 ); - CPPUNIT_TEST( test2DCurveInterpP0P1_1 ); - CPPUNIT_TEST( test2DCurveInterpP1P0_1 ); - CPPUNIT_TEST( test2DCurveInterpP1P1_1 ); - CPPUNIT_TEST_SUITE_END(); - public: - //MEDCouplingBasicsTest1.cxx - void testArray(); - void testArray2(); - void testArray3(); - void testMesh(); - void testMeshPointsCloud(); - void testMeshM1D(); - void testDeepCopy(); - void testRevNodal(); - void testConvertToPolyTypes(); - void testDescConn2D(); - void testDescConn3D(); - void testFindBoundaryNodes(); - void testBoundaryMesh(); - void testBuildPartOfMySelf(); - void testBuildPartOfMySelfNode(); - void testZipCoords(); - void testZipConnectivity(); - void testEqualMesh(); - void testEqualFieldDouble(); - void testNatureChecking(); - void testBuildSubMeshData(); - void testExtrudedMesh1(); - void testExtrudedMesh2(); - void testExtrudedMesh3(); - void testExtrudedMesh4(); - void testFindCommonNodes(); - void testCheckButterflyCells(); - void testMergeMesh1(); - void testMergeMeshOnSameCoords1(); - void testMergeField1(); - void testFillFromAnalytic(); - void testFillFromAnalytic2(); - void testApplyFunc(); - void testApplyFunc2(); - void testOperationsOnFields(); - void testOperationsOnFields2(); - void testOperationsOnFields3(); - void testOperationsOnFields4(); - void testMergeNodesOnField(); - void testCheckConsecutiveCellTypes(); - void testRearrange2ConsecutiveCellTypes(); - void testSplitByType(); - void testFuseUMeshesOnSameCoords(); - void testFuseUMeshesOnSameCoords2(); - void testBuildOrthogonalField(); - void testGetCellsContainingPoint(); - void testGetValueOn1(); - void testCMesh0(); - void testScale(); - void testTryToShareSameCoords(); - void testFindNodeOnPlane(); - void testRenumberCells(); - void testChangeSpaceDimension(); - //MEDCouplingBasicsTest2.cxx - void testGaussPointField1(); - void testGaussPointNEField1(); - void testCellOrientation1(); - void testCellOrientation2(); - void testPolyhedronBarycenter(); - void testNormL12Integ1D(); - void testAreaBary2D(); - void testAreaBary3D(); - void testRenumberCellsForFields(); - void testRenumberNodesForFields(); - void testConvertQuadraticCellsToLinear(); - void testCheckGeoEquivalWith(); - void testCheckGeoEquivalWith2(); - void testCopyTinyStringsFromOnFields(); - void testTryToShareSameCoordsPermute(); - void testTryToShareSameCoordsPermute2(); - void testChangeUnderlyingMesh1(); - void testGetMaxValue1(); - void testSubstractInPlaceDM1(); - void testDotCrossProduct1(); - void testMinMaxFields1(); - void testApplyLin1(); - void testGetIdsInRange1(); - void testBuildSubPart1(); - void testDoublyContractedProduct1(); - void testDeterminant1(); - void testEigenValues1(); - void testEigenVectors1(); - void testInverse1(); - void testTrace1(); - void testDeviator1(); - void testMagnitude1(); - void testMaxPerTuple1(); - void testChangeNbOfComponents(); - void testSortPerTuple1(); - void testIsEqualWithoutConsideringStr1(); - void testGetNodeIdsOfCell1(); - void testGetEdgeRatioField1(); - //MEDCouplingBasicsTestInterp.cxx - void test2DInterpP0P0_1(); - void test2DInterpP0P0PL_1(); - void test2DInterpP0P0PL_2(); - void test2DInterpP0P0PL_3(); - void test2DInterpP0P0PL_4(); - void test2DInterpP0P1_1(); - void test2DInterpP0P1PL_1(); - void test2DInterpP0P1PL_2(); - void test2DInterpP1P0_1(); - void test2DInterpP1P0PL_1(); - void test2DInterpP1P0PL_2(); - void test2DInterpP1P1_1(); - void test2DInterpP1P1PL_1(); - void test3DSurfInterpP0P0_1(); - void test3DSurfInterpP0P0PL_1(); - void test3DSurfInterpP0P1_1(); - void test3DSurfInterpP0P1PL_1(); - void test3DSurfInterpP1P0_1(); - void test3DSurfInterpP1P0PL_1(); - void test3DSurfInterpP1P1_1(); - void test3DSurfInterpP1P1PL_1(); - void test3DSurfInterpP0P0_2(); - void test3DSurfInterpP0P0_3(); - void test3DInterpP0P0_1(); - void test3DInterpP0P0PL_1(); - void test3DInterpP0P0PL_2(); - void test3DInterpP0P0PL_3(); - void test3DInterpP0P0PL_4(); - void test3DInterpP0P1_1(); - void test3DInterpP0P1PL_1(); - void test3DInterpP1P0_1(); - void test3DInterpP1P0PL_1(); - void test3DInterpP1P1_1(); - void test3DInterpP1P1PL_1(); - - void testInterpolationCC(); - void testInterpolationCU1D(); - void testInterpolationCU2D(); - void testInterpolationCU3D(); - - void test3DInterpP0P0Empty(); - void test2DInterpP0IntegralUniform(); - void test3DSurfInterpP0IntegralUniform(); - void test3DInterpP0IntegralUniform(); - void test2DInterpP1IntegralUniform(); - void test3DInterpP1IntegralUniform(); - void test2DInterpP1P0Bary_1(); - void test3DSurfInterpP1P0Bary_1(); - void test3DInterpP1P0Bary_1(); - void test3DTo1DInterpP0P0PL_1(); - - void test1DInterp_1(); - void test2DCurveInterpP0P0_1(); - void test2DCurveInterpP0P0_2(); - void test2DCurveInterpP0P1_1(); - void test2DCurveInterpP1P0_1(); - void test2DCurveInterpP1P1_1(); - - public: - static MEDCouplingUMesh *build3DSourceMesh_2(); - static MEDCouplingUMesh *build3DTargetMesh_2(); - static MEDCouplingUMesh *build1DTargetMesh_1(); - static MEDCouplingUMesh *build2DSourceMesh_1(); - static MEDCouplingUMesh *build2DTargetMesh_1(); - static MEDCouplingUMesh *build2DTargetMeshPerm_1(); - static MEDCouplingUMesh *build2DTargetMesh_2(); - static MEDCouplingUMesh *buildCU1DMesh_U(); - static MEDCouplingUMesh *buildCU2DMesh_U(); - static MEDCouplingUMesh *buildCU3DMesh_U(); - static MEDCouplingUMesh *build3DSurfSourceMesh_1(); - static MEDCouplingUMesh *build3DSurfSourceMesh_2(); - static MEDCouplingUMesh *build3DSurfTargetMesh_1(); - static MEDCouplingUMesh *build3DSurfTargetMeshPerm_1(); - static MEDCouplingUMesh *build3DSurfTargetMesh_2(); - static MEDCouplingUMesh *build3DSourceMesh_1(); - static MEDCouplingUMesh *build3DTargetMesh_1(); - static MEDCouplingUMesh *build2DTargetMeshMergeNode_1(); - static MEDCouplingUMesh *build3DTargetMeshMergeNode_1(); - static MEDCouplingUMesh *build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D); - static void build3DExtrudedUMesh_2(MEDCouplingUMesh *&meshN, MEDCouplingUMesh *&meshTT, MEDCouplingUMesh *&meshTF); - static MEDCouplingUMesh *build2DTargetMeshMerged_1(); - static MEDCouplingUMesh *build2DCurveMesh(double dx, double dy); - static MEDCouplingUMesh *build1DMesh(double dx); - static MEDCouplingUMesh *build1DSourceMesh_2(); - static MEDCouplingUMesh *build1DTargetMesh_2(); - static MEDCouplingUMesh *build2DCurveSourceMesh_2(); - static MEDCouplingUMesh *build2DCurveTargetMesh_2(); - static MEDCouplingUMesh *build1DTargetMesh_3(); - static MEDCouplingUMesh *build2DCurveTargetMesh_3(); - static MEDCouplingUMesh *build2DTargetMesh_3(); - static MEDCouplingUMesh *build3DTargetMesh_3(); - static MEDCouplingUMesh *build2DTargetMesh_4(); - static double sumAll(const std::vector< std::map >& matrix); - }; -} - -#endif diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx deleted file mode 100644 index 3f7adf58a..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx +++ /dev/null @@ -1,852 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingBasicsTest.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" - -#include "MEDCouplingBasicsTestData1.hxx" - -using namespace ParaMEDMEM; - -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, - 0.0, 100.0, 0.0, 0.0, 0.0, 100.0, 100.0, 200.0, 100.0, 0.0, 200.0, 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0, - 0.0, 100.0, 200.0, 100.0, 0.0, 200.0, 0.0, 0.0, 200.0, 100.0, 100.0, 200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 100.0, - 0.0, 200.0, 100.00000000833332, 100.00000000833332, 200.0, 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0, 200.0, - 0.0, 200.0, 200.0, 200.0, 0.0, 200.0, 200.0, 100.0, 200.0, 200.0, 200.0, 149.999999970343, 149.9999999874621, 49.999999881628682}; - - - int sourceConn[212]={25, 27, 13, 19, 18, 3, 20, 21, 5, 10, 17, 1, 1, 3, 0, 7, 18, 1, 0, 27, 12, 27, 13, 24, 25, 19, 16, 26, 1, 2, 6, 8, 15, 13, - 12, 5, 24, 13, 25, 27, 10, 11, 9, 6, 19, 8, 23, 1, 22, 8, 23, 19, 16, 13, 17, 1, 6, 9, 10, 8, 13, 17, 5, 15, 5, 4, 1, 12, 18, - 0, 24, 27, 19, 20, 18, 1, 7, 6, 5, 1, 4, 12, 15, 14, 25, 27, 19, 18, 1, 19, 16, 13, 20, 19, 23, 1, 27, 12, 1, 0, 6, 5, 1, 10, - 4, 5, 1, 7, 12, 27, 1, 13, 5, 15, 4, 12, 19, 16, 26, 22, 13, 5, 17, 1, 1, 3, 7, 2, 13, 5, 1, 12, 18, 1, 3, 0, 8, 23, 2, 9, 3, - 1, 18, 20, 1, 27, 19, 13, 24, 25, 18, 27, 25, 16, 19, 13, 7, 1, 2, 6, 3, 1, 20, 2, 8, 16, 17, 1, 7, 4, 0, 1, 18, 19, 1, 27, - 27, 12, 0, 24, 9, 6, 2, 8, 1, 4, 0, 12, 19, 16, 22, 8, 8, 2, 23, 1, 1, 16, 19, 8, 20, 2, 1, 23, 10, 1, 6, 8, 10, 8, 17, 1}; - - MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New(); - sourceMesh->setMeshDimension(3); - sourceMesh->allocateCells(53); - for(int i=0;i<53;i++) - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4*i); - sourceMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(28,3); - std::copy(sourceCoords,sourceCoords+84,myCoords->getPointer()); - sourceMesh->setCoords(myCoords); - myCoords->decrRef(); - return sourceMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_2() -{ - double targetCoords[24]={200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 200.0, 0.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 0.0, 200.0, 200.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200.0}; - int targetConn[20]={5, 6, 3, 0, 1, 3, 0, 5, 3, 6, 5, 7, 6, 4, 0, 5, 6, 3, 0, 2}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(3); - targetMesh->allocateCells(5); - for(int i=0;i<5;i++) - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn+4*i); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(8,3); - std::copy(targetCoords,targetCoords+24,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - 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}; - int sourceConn[6]={0,3,1,0,2,3}; - MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New("my name of mesh 2D",2); - sourceMesh->allocateCells(2); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3); - sourceMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer()); - sourceMesh->setCoords(myCoords); - myCoords->decrRef(); - return sourceMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_1() -{ - double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; - int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(5); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,2); - std::copy(targetCoords,targetCoords+18,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshPerm_1() -{ - double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; - int targetConn[18]={0,3,4,1, 1,2,4, 4,5,2, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(5); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,2); - std::copy(targetCoords,targetCoords+18,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_2() -{ - double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; - int targetConn[24]={0,3,4, 0,4,1, 1,4,2, 4,5,2, 3,6,4, 6,7,4, 4,7,5, 7,8,5 }; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(8); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,2); - std::copy(targetCoords,targetCoords+18,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU1DMesh_U() -{ - double coords[4]={ 0.0, 0.3, 0.75, 1.0 }; - int conn[2*3]={ 0,1, 1,2, 2,3 }; - MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(1); - mesh->allocateCells(3); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,1); - std::copy(coords,coords+4,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - return mesh; -} -MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU2DMesh_U() -{ - double coords[18]={0.0,0.0, 0.5,0.0, 1.0,0.0, 0.0,0.5, 0.5,0.5, 1.0,0.5, 0.0,1.0, 0.5,1.0, 1.0,1.0 }; - int conn[18]={0,1,4,3, 3,4,7,6, 4,5,8,7, 1,5,4, 1,2,5 }; - MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - mesh->allocateCells(5); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+4); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+8); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+12); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+15); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,2); - std::copy(coords,coords+18,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - return mesh; -} -MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU3DMesh_U() -{ - double coords[27*3]= - { -// 0.0,1.0,0.0 ,0.0,0.3,0.0 ,0.0,0.3,0.3 ,0.3,0.0,0.0 ,0.3,0.3,1.0 ,1.0,0.0,1.0 ,1.0,0.0,0.3 ,0.3,0.0,0.3 ,0.3,1.0,0.3 ,0.0,0.3,1.0 ,0.3,0.0,1.0 ,0.3,0.3,0.3 ,1.0,0.3,1.0 ,1.0,0.0,0.0 ,0.0,0.0,0.0 ,1.0,0.3,0.3 ,0.3,1.0,0.0 ,1.0,1.0,0.3 ,1.0,1.0,1.0 ,0.0,1.0,1.0 ,0.3,0.3,0.0 ,0.0,1.0,0.3 ,0.0,0.0,1.0 ,0.3,1.0,1.0 ,1.0,0.3,0.0 ,0.0,0.0,0.3 ,1.0,1.0,0.0 - 0.0,0.0,0.0, 0.3,0.0,0.0, 1.0,0.0,0.0, 0.0,0.3,0.0, 0.3,0.3,0.0, 1.0,0.3,0.0, 0.0,1.0,0.0, 0.3,1.0,0.0, 1.0,1.0,0.0, 0.0,0.0,0.3, 0.3,0.0,0.3, 1.0,0.0,0.3, 0.0,0.3,0.3, 0.3,0.3,0.3, 1.0,0.3,0.3, 0.0,1.0,0.3, 0.3,1.0,0.3, 1.0,1.0,0.3, 0.0,0.0,1.0, 0.3,0.0,1.0, 1.0,0.0,1.0, 0.0,0.3,1.0, 0.3,0.3,1.0, 1.0,0.3,1.0, 0.0,1.0,1.0, 0.3,1.0,1.0, 1.0,1.0,1.0, - }; - int conn[8*8]= - { -// 11,15,12,4,8,17,18,23,3,13,6,7,20,24,15,11,14,3,7,25,1,20,11,2,1,20,11,2,0,16,8,21,20,24,15,11,16,26,17,8,25,7,10,22,2,11,4,9,2,11,4,9,21,8,23,19,7,6,5,10,11,15,12,4 - 0,3,4,1,9,12,13,10, 1,4,5,2,10,13,14,11, 3,6,7,4,12,15,16,13, 4,7,8,5,13,16,17,14, 9,12,13,10,18,21,22,19, 10,13,14,11,19,22,23,20, 12,15,16,13,21,24,25,22, 13,16,17,14,22,25,26,23 - }; - MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(3); - mesh->allocateCells(8); - for(int i=0;i<8;i++) - mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(27,3); - std::copy(coords,coords+27*3,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - return mesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_1() -{ - double sourceCoords[12]={-0.3,-0.3,0.5, 0.7,-0.3,1.5, -0.3,0.7,0.5, 0.7,0.7,1.5}; - int sourceConn[6]={0,3,1,0,2,3}; - MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New(); - sourceMesh->setMeshDimension(2); - sourceMesh->allocateCells(2); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3); - sourceMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,3); - std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer()); - sourceMesh->setCoords(myCoords); - myCoords->decrRef(); - return sourceMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_2() -{ - double sourceCoords[12]={-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.}; - int sourceConn[6]={0,3,1,0,2,3}; - MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New(); - sourceMesh->setMeshDimension(2); - sourceMesh->allocateCells(2); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3); - sourceMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,3); - std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer()); - sourceMesh->setCoords(myCoords); - myCoords->decrRef(); - return sourceMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_1() -{ - double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5}; - int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(5); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,3); - std::copy(targetCoords,targetCoords+27,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -/*! - * Idem build3DSurfTargetMesh_1 except that cell id 2 is not correctly numbered. - */ -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMeshPerm_1() -{ - double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5}; - int targetConn[18]={0,3,4,1, 1,4,2, 4,2,5, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(5); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,3); - std::copy(targetCoords,targetCoords+27,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_2() -{ - double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5}; - int targetConn[24]={0,3,4, 0,4,1, 1,4,2, 4,5,2, 3,6,4, 6,7,4, 4,7,5, 7,8,5 }; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(8); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,3); - std::copy(targetCoords,targetCoords+27,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_1() -{ - double sourceCoords[27]={ 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0, - 200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0 }; - int sourceConn[48]={8,1,7,3, 6,0,8,2, 7,4,5,8, 6,8,4,7, 6,8,0,4, 6,8,7,3, 8,1,3,0, 4,1,5,8, 1,7,5,8, 0,3,8,2, 8,1,0,4, 3,6,8,2}; - MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New(); - sourceMesh->setMeshDimension(3); - sourceMesh->allocateCells(12); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+8); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+12); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+16); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+20); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+24); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+28); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+32); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+36); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+40); - sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+44); - sourceMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,3); - std::copy(sourceCoords,sourceCoords+27,myCoords->getPointer()); - sourceMesh->setCoords(myCoords); - myCoords->decrRef(); - return sourceMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_1() -{ - double targetCoords[81]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. , - 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. }; - int targetConn[64]={0,1,4,3,9,10,13,12, 1,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16, - 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(3); - targetMesh->allocateCells(12); - for(int i=0;i<8;i++) - targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(27,3); - std::copy(targetCoords,targetCoords+81,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMergeNode_1() -{ - double targetCoords[36]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,-0.3, 0.2,-0.3, 0.2,-0.3, 0.2,0.2, 0.2,0.2, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, 0.2,0.7 }; - int targetConn[18]={0,9,7,5, 4,6,2, 10,11,8, 9,14,15,7, 17,16,13,6}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(5); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(18,2); - std::copy(targetCoords,targetCoords+36,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMeshMergeNode_1() -{ - double targetCoords[93]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. , - 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200., 50.,0.,0., 50.,0.,0., 50.,0.,0., 200., 50., 200.}; - int targetConn[64]={0,29,4,3,9,10,13,12, 28,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16, - 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,30,26,25}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(3); - targetMesh->allocateCells(12); - for(int i=0;i<8;i++) - targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(31,3); - std::copy(targetCoords,targetCoords+93,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D) -{ - double coords[180]={ - 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., - 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., - 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., - 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1., - 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., - 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2., - 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., - 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.}; - - int conn[354]={ - // 0 - 0,11,1,3,15,26,16,18, 1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17, - 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21, - 11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23, - 7,12,14,13,22,27,29,28, - // 1 - 15,26,16,18,30,41,31,33, 16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32, - 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36, - 26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38, - 22,27,29,28,37,42,44,43, - // 2 - 30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47, - 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51, - 41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53, - 37,42,44,43,52,57,59,58 - }; - int conn2[28]={7,12,14,13, 11,8,7,4,2,1, 13,10,9,6, 1,6,5,3, 1,2,4,7,13,6, 0,11,1,3}; - // - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setMeshDimension(3); - ret->allocateCells(18); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+8); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+51); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+59); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+67); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+110); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+118); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+126); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+169); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+177); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+185); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+228); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+236); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+244); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+287); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+295); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+303); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+346); - // - ret->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(60,3); - std::copy(coords,coords+180,myCoords->getPointer()); - ret->setCoords(myCoords); - // - mesh2D=MEDCouplingUMesh::New(); - mesh2D->setMeshDimension(2); - mesh2D->allocateCells(6); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+4); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+10); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+14); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+18); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+24); - mesh2D->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -void MEDCouplingBasicsTest::build3DExtrudedUMesh_2(MEDCouplingUMesh *&meshN, MEDCouplingUMesh *&meshTT, MEDCouplingUMesh *&meshTF) -{ - const double coordsN[270]={ - 0, 0, 0, 0.10803000450134277, 0, 0, 0.21606000900268554, 0, 0, 0.28808000564575198, 0, 0, 0.36010002136230468, 0, 0, 0.43212001800537109, 0, 0, 0, - 0.072020001411437995, 0, 0.10803000450134277, 0.072020001411437995, 0, 0.21606000900268554, 0.072020001411437995, 0, 0.28808000564575198, 0.072020001411437995, - 0, 0.36010002136230468, 0.072020001411437995, 0, 0.43212001800537109, 0.072020001411437995, 0, 0, 0.10803000450134277, 0, 0.10803000450134277, - 0.10803000450134277, 0, 0.21606000900268554, 0.10803000450134277, 0, 0.28808000564575198, 0.10803000450134277, 0, 0.36010002136230468, 0.10803000450134277, 0, - 0.43212001800537109, 0.10803000450134277, 0, 0, 0.14404000282287599, 0, 0.10803000450134277, 0.14404000282287599, 0, 0.21606000900268554, 0.14404000282287599, 0, - 0.28808000564575198, 0.14404000282287599, 0, 0.36010002136230468, 0.14404000282287599, 0, 0.43212001800537109, 0.14404000282287599, 0, 0, 0.21606000900268554, 0, - 0.10803000450134277, 0.21606000900268554, 0, 0.21606000900268554, 0.21606000900268554, 0, 0.28808000564575198, 0.21606000900268554, 0, 0.36010002136230468, - 0.21606000900268554, 0, 0.43212001800537109, 0.21606000900268554, 0, 0, 0, 2.1364999389648438, 0.10803000450134277, 0, 2.1364999389648438, 0.21606000900268554, - 0, 2.1364999389648438, 0.28808000564575198, 0, 2.1364999389648438, 0.36010002136230468, 0, 2.1364999389648438, 0.43212001800537109, 0, 2.1364999389648438, 0, - 0.072020001411437995, 2.1364999389648438, 0.10803000450134277, 0.072020001411437995, 2.1364999389648438, 0.21606000900268554, 0.072020001411437995, - 2.1364999389648438, 0.28808000564575198, 0.072020001411437995, 2.1364999389648438, 0.36010002136230468, 0.072020001411437995, 2.1364999389648438, - 0.43212001800537109, 0.072020001411437995, 2.1364999389648438, 0, 0.10803000450134277, 2.1364999389648438, 0.10803000450134277, 0.10803000450134277, - 2.1364999389648438, 0.21606000900268554, 0.10803000450134277, 2.1364999389648438, 0.28808000564575198, 0.10803000450134277, 2.1364999389648438, - 0.36010002136230468, 0.10803000450134277, 2.1364999389648438, 0.43212001800537109, 0.10803000450134277, 2.1364999389648438, 0, 0.14404000282287599, - 2.1364999389648438, 0.10803000450134277, 0.14404000282287599, 2.1364999389648438, 0.21606000900268554, 0.14404000282287599, 2.1364999389648438, - 0.28808000564575198, 0.14404000282287599, 2.1364999389648438, 0.36010002136230468, 0.14404000282287599, 2.1364999389648438, 0.43212001800537109, - 0.14404000282287599, 2.1364999389648438, 0, 0.21606000900268554, 2.1364999389648438, 0.10803000450134277, 0.21606000900268554, 2.1364999389648438, - 0.21606000900268554, 0.21606000900268554, 2.1364999389648438, 0.28808000564575198, 0.21606000900268554, 2.1364999389648438, 0.36010002136230468, - 0.21606000900268554, 2.1364999389648438, 0.43212001800537109, 0.21606000900268554, 2.1364999389648438, 0, 0, 4.2729998779296876, 0.10803000450134277, 0, - 4.2729998779296876, 0.21606000900268554, 0, 4.2729998779296876, 0.28808000564575198, 0, 4.2729998779296876, 0.36010002136230468, 0, 4.2729998779296876, - 0.43212001800537109, 0, 4.2729998779296876, 0, 0.072020001411437995, 4.2729998779296876, 0.10803000450134277, 0.072020001411437995, 4.2729998779296876, - 0.21606000900268554, 0.072020001411437995, 4.2729998779296876, 0.28808000564575198, 0.072020001411437995, 4.2729998779296876, 0.36010002136230468, - 0.072020001411437995, 4.2729998779296876, 0.43212001800537109, 0.072020001411437995, 4.2729998779296876, 0, 0.10803000450134277, 4.2729998779296876, - 0.10803000450134277, 0.10803000450134277, 4.2729998779296876, 0.21606000900268554, 0.10803000450134277, 4.2729998779296876, 0.28808000564575198, - 0.10803000450134277, 4.2729998779296876, 0.36010002136230468, 0.10803000450134277, 4.2729998779296876, 0.43212001800537109, 0.10803000450134277, - 4.2729998779296876, 0, 0.14404000282287599, 4.2729998779296876, 0.10803000450134277, 0.14404000282287599, 4.2729998779296876, 0.21606000900268554, - 0.14404000282287599, 4.2729998779296876, 0.28808000564575198, 0.14404000282287599, 4.2729998779296876, 0.36010002136230468, 0.14404000282287599, - 4.2729998779296876, 0.43212001800537109, 0.14404000282287599, 4.2729998779296876, 0, 0.21606000900268554, 4.2729998779296876, 0.10803000450134277, - 0.21606000900268554, 4.2729998779296876, 0.21606000900268554, 0.21606000900268554, 4.2729998779296876, 0.28808000564575198, 0.21606000900268554, - 4.2729998779296876, 0.36010002136230468, 0.21606000900268554, 4.2729998779296876, 0.43212001800537109, 0.21606000900268554, 4.2729998779296876}; - const int connN[320]={ - 0, 1, 7, 6, 30, 31, 37, 36, 1, 2, 8, 7, 31, 32, 38, 37, 2, 3, 9, 8, 32, 33, 39, 38, 3, 4, 10, 9, 33, 34, 40, 39, 4, 5, 11, 10, 34, 35, 41, 40, 6, - 7, 13, 12, 36, 37, 43, 42, 7, 8, 14, 13, 37, 38, 44, 43, 8, 9, 15, 14, 38, 39, 45, 44, 9, 10, 16, 15, 39, 40, 46, 45, 10, 11, 17, 16, 40, 41, 47, - 46, 12, 13, 19, 18, 42, 43, 49, 48, 13, 14, 20, 19, 43, 44, 50, 49, 14, 15, 21, 20, 44, 45, 51, 50, 15, 16, 22, 21, 45, 46, 52, 51, 16, 17, 23, - 22, 46, 47, 53, 52, 18, 19, 25, 24, 48, 49, 55, 54, 19, 20, 26, 25, 49, 50, 56, 55, 20, 21, 27, 26, 50, 51, 57, 56, 21, 22, 28, 27, 51, 52, 58, - 57, 22, 23, 29, 28, 52, 53, 59, 58, 30, 31, 37, 36, 60, 61, 67, 66, 31, 32, 38, 37, 61, 62, 68, 67, 32, 33, 39, 38, 62, 63, 69, 68, 33, 34, 40, - 39, 63, 64, 70, 69, 34, 35, 41, 40, 64, 65, 71, 70, 36, 37, 43, 42, 66, 67, 73, 72, 37, 38, 44, 43, 67, 68, 74, 73, 38, 39, 45, 44, 68, 69, 75, - 74, 39, 40, 46, 45, 69, 70, 76, 75, 40, 41, 47, 46, 70, 71, 77, 76, 42, 43, 49, 48, 72, 73, 79, 78, 43, 44, 50, 49, 73, 74, 80, 79, 44, 45, 51, - 50, 74, 75, 81, 80, 45, 46, 52, 51, 75, 76, 82, 81, 46, 47, 53, 52, 76, 77, 83, 82, 48, 49, 55, 54, 78, 79, 85, 84, 49, 50, 56, 55, 79, 80, 86, - 85, 50, 51, 57, 56, 80, 81, 87, 86, 51, 52, 58, 57, 81, 82, 88, 87, 52, 53, 59, 58, 82, 83, 89, 88}; - meshN=MEDCouplingUMesh::New(); - meshN->setName("meshExtrudedN"); - meshN->setMeshDimension(3); - meshN->allocateCells(40); - for(int i=0;i<40;i++) - meshN->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connN+8*i); - meshN->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(90,3); - std::copy(coordsN,coordsN+270,myCoords->getPointer()); - meshN->setCoords(myCoords); - myCoords->decrRef(); - // - meshTT=MEDCouplingUMesh::New(); - meshTT->setName("meshExtrudedTT"); - meshTT->setMeshDimension(3); - meshTT->allocateCells(200); - for(int i=0;i<200;i++) - meshTT->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connITT[i+1]-connITT[i],connTT+connITT[i]); - meshTT->finishInsertingCells(); - myCoords=DataArrayDouble::New(); - myCoords->alloc(1720,3); - std::copy(coordsTT,coordsTT+5160,myCoords->getPointer()); - meshTT->setCoords(myCoords); - myCoords->decrRef(); - // - meshTF=MEDCouplingUMesh::New(); - meshTF->setName("meshExtrudedTF"); - meshTF->setMeshDimension(3); - meshTF->allocateCells(340); - for(int i=0;i<320;i++) - meshTF->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connTFH8+8*i); - for(int i=0;i<20;i++) - meshTF->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connTFPOLH_I[i+1]-connTFPOLH_I[i],connTFPOLH+connTFPOLH_I[i]); - meshTF->finishInsertingCells(); - myCoords=DataArrayDouble::New(); - myCoords->alloc(567,3); - std::copy(coordsTF,coordsTF+1701,myCoords->getPointer()); - meshTF->setCoords(myCoords); - myCoords->decrRef(); -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMerged_1() -{ - double targetCoords[26]={ - -0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, - 0.7,-0.3, 1.7,-0.3, 0.7,0.7, 1.7,0.7 - }; - int targetConn[24]={ - 0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4, - 9,12,10,9,11,12 - }; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setName("merge"); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(13,2); - std::copy(targetCoords,targetCoords+26,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveMesh(double dx, double dy) -{ - // 1d mesh: - // - // * - // / - // *---* - double targetCoords[3*2]= - { - 0.+dx,0.+dy, 1.+dx,0.+dy, 2.+dx,1.+dy - }; - int targetConn[2*2]={1,2, 0,1}; - - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("2Dcurve 1D mesh",1); - targetMesh->allocateCells(2); - for(int i=0;i<2;i++) - targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(3,2); - std::copy(targetCoords,targetCoords+3*2,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMesh(double dx) -{ - double targetCoords[4]= - { - 0.+dx, 1.+dx, 3.+dx, 4.+dx - }; - int targetConn[2*3]={1,2, 0,1, 2,3}; - - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("1D mesh",1); - targetMesh->allocateCells(3); - for(int i=0;i<3;i++) - targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,1); - std::copy(targetCoords,targetCoords+4,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build1DSourceMesh_2() -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1); - ret->allocateCells(4); - int conn[8]={0,1,2,3,1,2,3,4}; - for(int i=0;i<4;i++) - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i); - ret->finishInsertingCells(); - double coords[5]={0.3,0.7,0.9,1.0,1.12}; - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(5,1); - std::copy(coords,coords+5,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_2() -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1); - ret->allocateCells(2); - int conn[4]={1,2,0,1}; - for(int i=0;i<2;i++) - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i); - ret->finishInsertingCells(); - double coords[3]={0.5,0.75,1.2}; - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(3,1); - std::copy(coords,coords+3,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveSourceMesh_2() -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1); - ret->allocateCells(4); - int conn[8]={0,1,2,3,1,2,3,4}; - for(int i=0;i<4;i++) - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i); - ret->finishInsertingCells(); - double coords[10]={0.3,0.3,0.7,0.7,0.9,0.9,1.0,1.0,1.12,1.12}; - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(5,2); - std::copy(coords,coords+10,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_2() -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1); - ret->allocateCells(2); - int conn[4]={1,2,0,1}; - for(int i=0;i<2;i++) - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i); - ret->finishInsertingCells(); - double coords[6]={0.5,0.5,0.75,0.75,1.2,1.2}; - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(3,2); - std::copy(coords,coords+6,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_3() -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DMesh_3",1); - ret->allocateCells(4); - int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8}; - ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn); - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3); - ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5); - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8); - ret->finishInsertingCells(); - double coords[10]={0.5,1.,0.8,5.,5.21,0.5,1.1,0.7,5.,5.31}; - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(10,1); - std::copy(coords,coords+10,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_3() -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DCurveMesh_3",1); - ret->allocateCells(4); - int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8}; - ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn); - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3); - ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5); - ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8); - ret->finishInsertingCells(); - double coords[20]={0.5,0.5,1.,1.,0.8,0.8,5.,5.,5.21,5.21,0.5,0.5,1.1,1.1,0.7,0.7,5.,5.,5.31,5.31}; - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(10,2); - std::copy(coords,coords+20,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_3() -{ - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DMesh_3",2); - ret->allocateCells(10); - int conn[52]={ - 0,1,2, 0,1,3,4, 0,1,3,5,4, 0,1,2,6,7,8, 0,1,3,4,6,9,2,10, - 0,2,1, 0,4,3,1, 0,4,5,3,1, 0,2,1,8,7,6, 0,4,3,1,10,2,9,6 - }; - ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); - ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+3); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+7); - ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+12); - ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+18); - ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+26); - ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+29); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+33); - ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+38); - ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+44); - ret->finishInsertingCells(); - double coords[22]={0.,0.,1.,0.,0.5,1.,1.,1.,0.,1.,0.5,2.,0.5,0.,0.75,0.5,0.25,0.5,1.,0.5,0.,0.5}; - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(11,2); - std::copy(coords,coords+22,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - ret->checkCoherency(); - return ret; -} - -/*! - * Same as build2DTargetMesh_1 but with more nodes than needed. To check tryToShareSameCoordsPermute method. - */ -MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_4() -{ - double targetCoords[20]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; - int targetConn[18]={0,4,5,1, 1,5,3, 5,6,2, 7,8,5,4, 8,9,6,5}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(5); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(10,2); - std::copy(targetCoords,targetCoords+20,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_3() -{ - return 0; -} - -double MEDCouplingBasicsTest::sumAll(const std::vector< std::map >& matrix) -{ - double ret=0.; - for(std::vector< std::map >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++) - for(std::map::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++) - ret+=(*iter2).second; - return ret; -} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx deleted file mode 100644 index 5c34f02c8..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ /dev/null @@ -1,2402 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingBasicsTest.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingCMesh.hxx" -#include "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" - -#include -#include - -using namespace ParaMEDMEM; - -void MEDCouplingBasicsTest::testArray() -{ - int tmp1[6]={7,6,5,4,3,2}; - const int tmp2[3]={8,9,10}; - { - MemArray mem; - mem.useArray(tmp1,false,CPP_DEALLOC,6); - CPPUNIT_ASSERT(tmp1==mem.getConstPointer()); - CPPUNIT_ASSERT_THROW(mem.getPointer(),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(mem[2]=7,INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(mem.writeOnPlace(0,12,tmp2,3),INTERP_KERNEL::Exception); - mem.writeOnPlace(4,12,tmp2,3); - } - { - int *tmp3=new int[6]; - std::copy(tmp1,tmp1+6,tmp3); - MemArray mem2; - mem2.useArray(tmp3,true,CPP_DEALLOC,6); - CPPUNIT_ASSERT(tmp3==mem2.getConstPointer()); - CPPUNIT_ASSERT(tmp3==mem2.getPointer()); - CPPUNIT_ASSERT_EQUAL(5,mem2[2]); - mem2[2]=7; - CPPUNIT_ASSERT_EQUAL(7,mem2[2]); - mem2.writeOnPlace(0,12,tmp2,3); - CPPUNIT_ASSERT_EQUAL(9,mem2[2]); - CPPUNIT_ASSERT_EQUAL(12,mem2[0]); - mem2.writeOnPlace(4,12,tmp2,3); - } -} - -void MEDCouplingBasicsTest::testArray2() -{ - DataArrayDouble *arr=DataArrayDouble::New(); - arr->alloc(3,4); - double *tmp=arr->getPointer(); - const double arrRef[12]={12.,11.,10.,9.,8.,7.,6.,5.,4.,3.,2.,1.}; - std::copy(arrRef,arrRef+12,tmp); - arr->setInfoOnComponent(0,"ggg"); - arr->setInfoOnComponent(1,"hhhh"); - arr->setInfoOnComponent(2,"jj"); - arr->setInfoOnComponent(3,"kkkkkk"); - DataArrayInt *arr2=arr->convertToIntArr(); - DataArrayDouble *arr3=arr2->convertToDblArr(); - arr2->decrRef(); - CPPUNIT_ASSERT(arr->isEqual(*arr3,1e-14)); - arr3->decrRef(); - arr->decrRef(); -} - -void MEDCouplingBasicsTest::testArray3() -{ - DataArrayInt *arr1=DataArrayInt::New(); - arr1->alloc(7,2); - int *tmp=arr1->getPointer(); - const int arr1Ref[14]={0,10,1,11,2,12,3,13,4,14,5,15,6,16}; - std::copy(arr1Ref,arr1Ref+14,tmp); - CPPUNIT_ASSERT_EQUAL(7,arr1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,arr1->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(arr1Ref,arr1Ref+14,arr1->getConstPointer())); - DataArrayInt *arr2=arr1->substr(3); - CPPUNIT_ASSERT_EQUAL(4,arr2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,arr2->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(arr1Ref+6,arr1Ref+14,arr2->getConstPointer())); - arr2->decrRef(); - DataArrayInt *arr3=arr1->substr(2,5); - CPPUNIT_ASSERT_EQUAL(3,arr3->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,arr3->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(arr1Ref+4,arr1Ref+10,arr3->getConstPointer())); - arr1->decrRef(); - arr3->decrRef(); - // - DataArrayDouble *arr4=DataArrayDouble::New(); - arr4->alloc(7,2); - double *tmp2=arr4->getPointer(); - const int arr4Ref[14]={0.8,10.8,1.9,11.9,2.1,12.1,3.2,13.2,4.3,14.3,5.4,15.4,6.5,16.5}; - std::copy(arr4Ref,arr4Ref+14,tmp2); - CPPUNIT_ASSERT_EQUAL(7,arr4->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,arr4->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(arr4Ref,arr4Ref+14,arr4->getConstPointer())); - DataArrayDouble *arr5=arr4->substr(3); - CPPUNIT_ASSERT_EQUAL(4,arr5->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,arr5->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(arr4Ref+6,arr4Ref+14,arr5->getConstPointer())); - arr5->decrRef(); - DataArrayDouble *arr6=arr4->substr(2,5); - CPPUNIT_ASSERT_EQUAL(3,arr6->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,arr6->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(arr4Ref+4,arr4Ref+10,arr6->getConstPointer())); - arr4->decrRef(); - arr6->decrRef(); -} - -void MEDCouplingBasicsTest::testMesh() -{ - const int nbOfCells=6; - const int nbOfNodes=12; - - double coords[3*nbOfNodes]={ - 0.024155, 0.04183768725682622, -0.305, 0.04831000000000001, -1.015761910347357e-17, -0.305, 0.09662000000000001, -1.832979297858306e-18, - -0.305, 0.120775, 0.04183768725682623, -0.305, 0.09662000000000001, 0.08367537451365245, -0.305, 0.04831000000000001, - 0.08367537451365246, -0.305, 0.024155, 0.04183768725682622, -0.2863, 0.04831000000000001, -1.015761910347357e-17, -0.2863, - 0.09662000000000001, -1.832979297858306e-18, -0.2863, 0.120775, 0.04183768725682623, -0.2863, 0.09662000000000001, 0.08367537451365245, - -0.2863, 0.04831000000000001, 0.08367537451365246, -0.2863, }; - - int tab4[4*nbOfCells]={ - 1, 2, 8, 7, 2, 3, 9, 8, 3, 4, 10, 9, 4, 5, 11, 10, 5, 0, 6, 11, - 0, 1, 7, 6, }; - - MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - mesh->allocateCells(8); - const int *curConn=tab4; - for(int i=0;iinsertNextCell(INTERP_KERNEL::NORM_QUAD4,4,curConn); - mesh->finishInsertingCells(); - CPPUNIT_ASSERT_EQUAL(30,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh->getNumberOfCells()); - //test 0 - no copy no ownership - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->useArray(coords,false,CPP_DEALLOC,nbOfNodes,3); - mesh->setCoords(myCoords); - mesh->setCoords(myCoords); - myCoords->decrRef(); - CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh->getNumberOfCells()); - mesh->checkCoherency(); - //test 1 - no copy ownership C++ - myCoords=DataArrayDouble::New(); - double *tmp=new double[3*nbOfNodes]; - std::copy(coords,coords+3*nbOfNodes,tmp); - myCoords->useArray(tmp,true,CPP_DEALLOC,nbOfNodes,3); - mesh->setCoords(myCoords); - myCoords->decrRef(); - CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh->getNumberOfCells()); - mesh->checkCoherency(); - //test 2 - no copy ownership C - myCoords=DataArrayDouble::New(); - tmp=(double *)malloc(3*nbOfNodes*sizeof(double)); - std::copy(coords,coords+3*nbOfNodes,tmp); - myCoords->useArray(tmp,true,C_DEALLOC,nbOfNodes,3); - mesh->setCoords(myCoords); - myCoords->decrRef(); - CPPUNIT_ASSERT_EQUAL(nbOfNodes,mesh->getNumberOfNodes()); - mesh->checkCoherency(); - //test 3 - copy. - myCoords=DataArrayDouble::New(); - myCoords->alloc(nbOfNodes,3); - tmp=myCoords->getPointer(); - std::copy(coords,coords+3*nbOfNodes,tmp); - // test 3 bis deepcopy - DataArrayDouble *myCoords2=DataArrayDouble::New(); - *myCoords2=*myCoords; - myCoords2->decrRef(); - // - mesh->setCoords(myCoords); - myCoords->decrRef(); - CPPUNIT_ASSERT_EQUAL(nbOfNodes,mesh->getNumberOfNodes()); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - // test clone not recursively - MEDCouplingUMesh *mesh2=mesh->clone(false); - CPPUNIT_ASSERT(mesh2!=mesh); - mesh2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh2->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(nbOfNodes,mesh2->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,mesh2->getSpaceDimension()); - CPPUNIT_ASSERT(mesh!=mesh2); - CPPUNIT_ASSERT(mesh->getCoords()==mesh2->getCoords()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.2863,mesh2->getCoords()->getIJ(11,2),1e-14); - CPPUNIT_ASSERT(mesh->getNodalConnectivity()==mesh2->getNodalConnectivity()); - CPPUNIT_ASSERT_EQUAL(3,mesh2->getNodalConnectivity()->getIJ(7,0)); - CPPUNIT_ASSERT(mesh->getNodalConnectivityIndex()==mesh2->getNodalConnectivityIndex()); - CPPUNIT_ASSERT_EQUAL(15,mesh2->getNodalConnectivityIndex()->getIJ(3,0)); - mesh2->decrRef(); - // test clone not recursively - MEDCouplingUMesh *mesh3=mesh->clone(true); - CPPUNIT_ASSERT(mesh3!=mesh); - mesh3->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh3->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(nbOfNodes,mesh3->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,mesh3->getSpaceDimension()); - CPPUNIT_ASSERT(mesh!=mesh3); - CPPUNIT_ASSERT(mesh->getCoords()!=mesh3->getCoords()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.2863,mesh3->getCoords()->getIJ(11,2),1e-14); - CPPUNIT_ASSERT(mesh->getNodalConnectivity()!=mesh3->getNodalConnectivity()); - CPPUNIT_ASSERT_EQUAL(3,mesh3->getNodalConnectivity()->getIJ(7,0)); - CPPUNIT_ASSERT(mesh->getNodalConnectivityIndex()!=mesh3->getNodalConnectivityIndex()); - CPPUNIT_ASSERT_EQUAL(15,mesh3->getNodalConnectivityIndex()->getIJ(3,0)); - mesh3->decrRef(); - //test 4 - Field on cells - MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS); - fieldOnCells->setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(nbOfCells,9); - fieldOnCells->setArray(array); - tmp=array->getPointer(); - array->decrRef(); - std::fill(tmp,tmp+9*nbOfCells,7.); - //content of field changed -> declare it. - fieldOnCells->declareAsNew(); - fieldOnCells->checkCoherency(); - // testing clone of fields - no recursive - MEDCouplingFieldDouble *fieldOnCells2=fieldOnCells->clone(false); - CPPUNIT_ASSERT(fieldOnCells2!=fieldOnCells); - fieldOnCells2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(nbOfCells,fieldOnCells2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(9,fieldOnCells2->getNumberOfComponents()); - CPPUNIT_ASSERT(fieldOnCells2->getArray()==fieldOnCells->getArray()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,fieldOnCells2->getArray()->getIJ(3,7),1e-14); - CPPUNIT_ASSERT(fieldOnCells2->getMesh()==fieldOnCells->getMesh()); - // testing clone of fields - recursive - MEDCouplingFieldDouble *fieldOnCells3=fieldOnCells->clone(true); - CPPUNIT_ASSERT(fieldOnCells3!=fieldOnCells); - fieldOnCells3->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(nbOfCells,fieldOnCells3->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(9,fieldOnCells3->getNumberOfComponents()); - CPPUNIT_ASSERT(fieldOnCells3->getArray()!=fieldOnCells->getArray()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,fieldOnCells3->getArray()->getIJ(3,7),1e-14); - CPPUNIT_ASSERT(fieldOnCells3->getMesh()==fieldOnCells->getMesh()); - fieldOnCells2->decrRef(); - fieldOnCells3->decrRef(); - // - fieldOnCells->decrRef(); - //clean-up - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testMeshPointsCloud() -{ - double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5}; - int *targetConn=0; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(0); - targetMesh->allocateCells(8); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,3); - std::copy(targetCoords,targetCoords+27,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - // - targetMesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,targetMesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(8,targetMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(9,targetMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(0,targetMesh->getMeshDimension()); - // - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testMeshM1D() -{ - MEDCouplingUMesh *meshM1D=MEDCouplingUMesh::New(); - CPPUNIT_ASSERT_THROW(meshM1D->getMeshDimension(),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(meshM1D->getNumberOfNodes(),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(meshM1D->getNumberOfCells(),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(meshM1D->setMeshDimension(-2),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(meshM1D->setMeshDimension(-10),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(meshM1D->checkCoherency(),INTERP_KERNEL::Exception); - meshM1D->setMeshDimension(-1); - meshM1D->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(-1,meshM1D->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(1,meshM1D->getNumberOfCells()); - CPPUNIT_ASSERT_THROW(meshM1D->getNumberOfNodes(),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(meshM1D->getSpaceDimension(),INTERP_KERNEL::Exception); - MEDCouplingUMesh *cpy=meshM1D->clone(true); - CPPUNIT_ASSERT(cpy->isEqual(meshM1D,1e-12)); - cpy->decrRef(); - MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS); - fieldOnCells->setMesh(meshM1D); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(1,6); - fieldOnCells->setArray(array); - double *tmp=array->getPointer(); - array->decrRef(); - std::fill(tmp,tmp+6,7.); - fieldOnCells->checkCoherency(); - // - fieldOnCells->decrRef(); - meshM1D->decrRef(); -} - -void MEDCouplingBasicsTest::testDeepCopy() -{ - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(5,3); - std::fill(array->getPointer(),array->getPointer()+5*3,7.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,array->getIJ(3,2),1e-14); - double *tmp1=array->getPointer(); - DataArrayDouble *array2=array->deepCopy(); - double *tmp2=array2->getPointer(); - CPPUNIT_ASSERT(tmp1!=tmp2); - array->decrRef(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,array2->getIJ(3,2),1e-14); - array2->decrRef(); - // - DataArrayInt *array3=DataArrayInt::New(); - array3->alloc(5,3); - std::fill(array3->getPointer(),array3->getPointer()+5*3,17); - CPPUNIT_ASSERT_EQUAL(17,array3->getIJ(3,2)); - int *tmp3=array3->getPointer(); - DataArrayInt *array4=array3->deepCopy(); - int *tmp4=array4->getPointer(); - CPPUNIT_ASSERT(tmp3!=tmp4); - array3->decrRef(); - CPPUNIT_ASSERT_EQUAL(17,array4->getIJ(3,2)); - array4->decrRef(); -} - -void MEDCouplingBasicsTest::testRevNodal() -{ - MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - DataArrayInt *revNodal=DataArrayInt::New(); - DataArrayInt *revNodalIndx=DataArrayInt::New(); - // - mesh->getReverseNodalConnectivity(revNodal,revNodalIndx); - const int revNodalExpected[18]={0,0,1,1,2,0,3,0,1,2,3,4,2,4,3,3,4,4}; - const int revNodalIndexExpected[10]={0,1,3,5,7,12,14,15,17,18}; - CPPUNIT_ASSERT_EQUAL(18,revNodal->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(10,revNodalIndx->getNbOfElems()); - CPPUNIT_ASSERT(std::equal(revNodalExpected,revNodalExpected+18,revNodal->getPointer())); - CPPUNIT_ASSERT(std::equal(revNodalIndexExpected,revNodalIndexExpected+10,revNodalIndx->getPointer())); - // - revNodal->decrRef(); - revNodalIndx->decrRef(); - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testConvertToPolyTypes() -{ - ////// 2D - MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - // - const int elts[2]={1,3}; - std::vector eltsV(elts,elts+2); - mesh->convertToPolyTypes(eltsV); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(23,mesh->getNodalConnectivity()->getNumberOfTuples()); - const int *pt=mesh->getNodalConnectivity()->getConstPointer(); - const int expected1[23]={4, 0, 3, 4, 1, 5, 1, 4, 2, 3, 4, 5, 2, 5, 6, 7, 4, 3, 4, 7, 8, 5, 4}; - CPPUNIT_ASSERT(std::equal(expected1,expected1+23,pt)); - // - mesh->decrRef(); - ////// 3D - mesh=build3DTargetMesh_1(); - mesh->convertToPolyTypes(eltsV); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(8,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(114,mesh->getNodalConnectivity()->getNumberOfTuples()); - mesh->convertToPolyTypes(eltsV); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(8,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(114,mesh->getNodalConnectivity()->getNumberOfTuples()); - // - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testDescConn2D() -{ - MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - DataArrayInt *desc=DataArrayInt::New(); - DataArrayInt *descIndx=DataArrayInt::New(); - DataArrayInt *revDesc=DataArrayInt::New(); - DataArrayInt *revDescIndx=DataArrayInt::New(); - // - MEDCouplingUMesh *mesh2=mesh->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,mesh2->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(13,mesh2->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples()); - const int expected1[18]={0,1,2,3, 2,4,5, 6,7,4, 8,9,1,10, 11,12,6,9}; - CPPUNIT_ASSERT(std::equal(expected1,expected1+18,desc->getConstPointer())); - const int expected2[6]={0,4,7,10,14,18}; - CPPUNIT_ASSERT(std::equal(expected2,expected2+6,descIndx->getConstPointer())); - const int expected3[14]={0,1,3,5,6,8,9,11,12,13,15,16,17,18}; - CPPUNIT_ASSERT(std::equal(expected3,expected3+14,revDescIndx->getConstPointer())); - const int expected4[18]={0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4}; - CPPUNIT_ASSERT(std::equal(expected4,expected4+18,revDesc->getConstPointer())); - DataArrayInt *conn=mesh2->getNodalConnectivity(); - DataArrayInt *connIndex=mesh2->getNodalConnectivityIndex(); - const int expected5[14]={0,3,6,9,12,15,18,21,24,27,30,33,36,39}; - CPPUNIT_ASSERT(std::equal(expected5,expected5+14,connIndex->getConstPointer())); - const int expected6[39]={1, 0, 3, 1, 3, 4, 1, 4, 1, 1, 1, 0, 1, 4, 2, 1, 2, 1, 1, 4, 5, 1, 5, 2, 1, 6, 7, 1, 7, 4, 1, 3, 6, 1, 7, 8, 1, 8, 5}; - CPPUNIT_ASSERT(std::equal(expected6,expected6+39,conn->getConstPointer())); - // - desc->decrRef(); - descIndx->decrRef(); - revDesc->decrRef(); - revDescIndx->decrRef(); - mesh2->decrRef(); - // - const int elts[2]={1,3}; - std::vector eltsV(elts,elts+2); - mesh->convertToPolyTypes(eltsV); - mesh->checkCoherency(); - // - desc=DataArrayInt::New(); - descIndx=DataArrayInt::New(); - revDesc=DataArrayInt::New(); - revDescIndx=DataArrayInt::New(); - // - mesh2=mesh->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,mesh2->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(13,mesh2->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples()); - CPPUNIT_ASSERT(std::equal(expected1,expected1+18,desc->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected2,expected2+6,descIndx->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected3,expected3+14,revDescIndx->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected4,expected4+18,revDesc->getConstPointer())); - conn=mesh2->getNodalConnectivity(); - connIndex=mesh2->getNodalConnectivityIndex(); - CPPUNIT_ASSERT(std::equal(expected5,expected5+14,connIndex->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected6,expected6+39,conn->getConstPointer())); - // - desc->decrRef(); - descIndx->decrRef(); - revDesc->decrRef(); - revDescIndx->decrRef(); - mesh2->decrRef(); - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testDescConn3D() -{ - MEDCouplingUMesh *mesh=build3DTargetMesh_1(); - DataArrayInt *desc=DataArrayInt::New(); - DataArrayInt *descIndx=DataArrayInt::New(); - DataArrayInt *revDesc=DataArrayInt::New(); - DataArrayInt *revDescIndx=DataArrayInt::New(); - // - MEDCouplingUMesh *mesh2=mesh->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(2,mesh2->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(36,mesh2->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(9,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(9,descIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples()); - const int expected1[9]={0, 6, 12, 18, 24, 30, 36, 42, 48}; - const int expected2[48]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 11, 12, 4, 13, 14, 15, 16, 17, 10, 18, 19, 13, 1, 20, 21, 22, 23, 24, 7, 25, 26, 27, 28, 22, 12, 29, 23, 30, 31, 32, 17, 33, 28, 34, 35, 30}; - const int expected3[37]={0, 1, 3, 4, 6, 8, 9, 10, 12, 13, 14, 16, 17, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 32, 34, 35, 36, 37, 38, 40, 41, 43, 44, 45, 46, 47, 48}; - const int expected4[48]={0, 0, 4, 0, 0, 1, 0, 2, 0, 1, 1, 5, 1, 1, 1, 3, 2, 2, 6, 2, 3, 2, 2, 3, 3, 7, 3, 3, 4, 4, 4, 5, 4, 6, 4, 5, 5, 5, 5, 7, 6, 6, 7, 6, 6, 7, 7, 7}; - const int expected5[37]={0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180}; - const int expected6[180]={4, 0, 1, 4, 3, 4, 9, 12, 13, 10, 4, 0, 9, 10, 1, 4, 1, 10, 13, 4, 4, 4, 13, 12, 3, 4, 3, 12, 9, 0, 4, 1, 2, 5, 4, 4, 10, 13, 14, 11, 4, 1, 10, 11, 2, 4, 2, 11, 14, - 5, 4, 5, 14, 13, 4, 4, 3, 4, 7, 6, 4, 12, 15, 16, 13, 4, 4, 13, 16, 7, 4, 7, 16, 15, 6, 4, 6, 15, 12, 3, 4, 4, 5, 8, 7, 4, 13, 16, 17, 14, 4, 5, 14, 17, 8, 4, 8, - 17, 16, 7, 4, 18, 21, 22, 19, 4, 9, 18, 19, 10, 4, 10, 19, 22, 13, 4, 13, 22, 21, 12, 4, 12, 21, 18, 9, 4, 19, 22, 23, 20, 4, 10, 19, 20, 11, 4, 11, 20, 23, 14, 4, - 14, 23, 22, 13, 4, 21, 24, 25, 22, 4, 13, 22, 25, 16, 4, 16, 25, 24, 15, 4, 15, 24, 21, 12, 4, 22, 25, 26, 23, 4, 14, 23, 26, 17, 4, 17, 26, 25, 16}; - const int expected7[180]={4, 0, 1, 4, 3, 4, 9, 12, 13, 10, 4, 0, 9, 10, 1, 4, 1, 10, 13, 4, 4, 4, 13, 12, 3, 4, 3, 12, 9, 0, 5, 1, 2, 5, 4, 5, 10, 13, 14, 11, 5, 1, 10, 11, 2, 5, 2, 11, 14, - 5, 5, 5, 14, 13, 4, 4, 3, 4, 7, 6, 4, 12, 15, 16, 13, 4, 4, 13, 16, 7, 4, 7, 16, 15, 6, 4, 6, 15, 12, 3, 5, 4, 5, 8, 7, 5, 13, 16, 17, 14, 5, 5, 14, 17, 8, 5, 8, - 17, 16, 7, 4, 18, 21, 22, 19, 4, 9, 18, 19, 10, 4, 10, 19, 22, 13, 4, 13, 22, 21, 12, 4, 12, 21, 18, 9, 4, 19, 22, 23, 20, 4, 10, 19, 20, 11, 4, 11, 20, 23, 14, 4, - 14, 23, 22, 13, 4, 21, 24, 25, 22, 4, 13, 22, 25, 16, 4, 16, 25, 24, 15, 4, 15, 24, 21, 12, 4, 22, 25, 26, 23, 4, 14, 23, 26, 17, 4, 17, 26, 25, 16}; - - CPPUNIT_ASSERT(std::equal(expected1,expected1+9,descIndx->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected2,expected2+48,desc->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected3,expected3+37,revDescIndx->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected4,expected4+48,revDesc->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected5,expected5+37,mesh2->getNodalConnectivityIndex()->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected6,expected6+180,mesh2->getNodalConnectivity()->getConstPointer())); - // - desc->decrRef(); - descIndx->decrRef(); - revDesc->decrRef(); - revDescIndx->decrRef(); - mesh2->decrRef(); - // - const int elts[2]={1,3}; - std::vector eltsV(elts,elts+2); - mesh->convertToPolyTypes(eltsV); - mesh->checkCoherency(); - desc=DataArrayInt::New(); - descIndx=DataArrayInt::New(); - revDesc=DataArrayInt::New(); - revDescIndx=DataArrayInt::New(); - mesh2=mesh->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(2,mesh2->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(36,mesh2->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(9,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(9,descIndx->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples()); - CPPUNIT_ASSERT(std::equal(expected1,expected1+9,descIndx->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected2,expected2+48,desc->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected3,expected3+37,revDescIndx->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected4,expected4+48,revDesc->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected5,expected5+37,mesh2->getNodalConnectivityIndex()->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected7,expected7+180,mesh2->getNodalConnectivity()->getConstPointer())); - // - desc->decrRef(); - descIndx->decrRef(); - revDesc->decrRef(); - revDescIndx->decrRef(); - mesh2->decrRef(); - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testFindBoundaryNodes() -{ - MEDCouplingUMesh *mesh=build3DTargetMesh_1(); - std::vector boundaryNodes; - mesh->findBoundaryNodes(boundaryNodes); - CPPUNIT_ASSERT_EQUAL(26,(int)boundaryNodes.size()); - const int expected1[26]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}; - CPPUNIT_ASSERT(std::equal(expected1,expected1+26,boundaryNodes.begin())); - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testBoundaryMesh() -{ - MEDCouplingUMesh *mesh=build3DTargetMesh_1(); - MEDCouplingPointSet *mesh2=mesh->buildBoundaryMesh(false); - CPPUNIT_ASSERT_EQUAL(24,mesh2->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(26,mesh2->getNumberOfNodes()); - mesh2->decrRef(); - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testBuildPartOfMySelf() -{ - MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - mesh->setName("Toto"); - const int tab1[2]={0,4}; - const int tab2[3]={0,2,3}; - // - MEDCouplingPointSet *subMeshSimple=mesh->buildPartOfMySelf(tab1,tab1+2,true); - MEDCouplingUMesh *subMesh=dynamic_cast(subMeshSimple); - CPPUNIT_ASSERT(subMesh); - std::string name(subMesh->getName()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*mesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(mesh->getAllTypes().begin()))); - CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT(name=="PartOf_Toto"); - CPPUNIT_ASSERT(mesh->getCoords()==subMesh->getCoords()); - CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells()); - const int subConn[10]={4,0,3,4,1,4,7,8,5,4}; - const int subConnIndex[3]={0,5,10}; - CPPUNIT_ASSERT_EQUAL(10,subMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(3,subMesh->getNodalConnectivityIndex()->getNbOfElems()); - CPPUNIT_ASSERT(std::equal(subConn,subConn+10,subMesh->getNodalConnectivity()->getPointer())); - CPPUNIT_ASSERT(std::equal(subConnIndex,subConnIndex+3,subMesh->getNodalConnectivityIndex()->getPointer())); - subMesh->decrRef(); - // - subMeshSimple=mesh->buildPartOfMySelf(tab2,tab2+3,true); - subMesh=dynamic_cast(subMeshSimple); - CPPUNIT_ASSERT(subMesh); - name=subMesh->getName(); - CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(subMesh->getAllTypes().begin()))); - CPPUNIT_ASSERT(name=="PartOf_Toto"); - CPPUNIT_ASSERT(mesh->getCoords()==subMesh->getCoords()); - CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells()); - const int subConn2[14]={4,0,3,4,1,3,4,5,2,4,6,7,4,3}; - const int subConnIndex2[4]={0,5,9,14}; - CPPUNIT_ASSERT_EQUAL(14,subMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(4,subMesh->getNodalConnectivityIndex()->getNbOfElems()); - CPPUNIT_ASSERT(std::equal(subConn2,subConn2+14,subMesh->getNodalConnectivity()->getPointer())); - CPPUNIT_ASSERT(std::equal(subConnIndex2,subConnIndex2+4,subMesh->getNodalConnectivityIndex()->getPointer())); - const int tab3[3]={0,1,2}; - MEDCouplingPointSet *subMeshSimple2=subMeshSimple->buildPartOfMySelf(tab3,tab3+3,true); - subMesh->decrRef(); - name=subMeshSimple2->getName(); - CPPUNIT_ASSERT(name=="PartOf_Toto"); - subMeshSimple2->decrRef(); - // - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testBuildPartOfMySelfNode() -{ - MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - const int tab1[2]={5,7}; - MEDCouplingPointSet *subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+2,true); - MEDCouplingUMesh *subMesh=dynamic_cast(subMeshSimple); - CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(1,subMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(5,subMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(2,subMesh->getNodalConnectivityIndex()->getNbOfElems()); - const int subConn[5]={4,7,8,5,4}; - const int subConnIndex[3]={0,5}; - CPPUNIT_ASSERT(std::equal(subConn,subConn+5,subMesh->getNodalConnectivity()->getPointer())); - CPPUNIT_ASSERT(std::equal(subConnIndex,subConnIndex+2,subMesh->getNodalConnectivityIndex()->getPointer())); - CPPUNIT_ASSERT(subMesh->getCoords()==mesh->getCoords()); - subMeshSimple->decrRef(); - // - subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+2,false); - subMesh=dynamic_cast(subMeshSimple); - CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllTypes().begin())); - CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(14,subMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(4,subMesh->getNodalConnectivityIndex()->getNbOfElems()); - const int subConn2[14]={3,4,5,2,4,6,7,4,3,4,7,8,5,4}; - const int subConnIndex2[4]={0,4,9,14}; - CPPUNIT_ASSERT(std::equal(subConn2,subConn2+14,subMesh->getNodalConnectivity()->getPointer())); - CPPUNIT_ASSERT(std::equal(subConnIndex2,subConnIndex2+4,subMesh->getNodalConnectivityIndex()->getPointer())); - CPPUNIT_ASSERT(subMesh->getCoords()==mesh->getCoords()); - subMeshSimple->decrRef(); - //testing the case where length of tab2 is greater than max number of node per cell. - const int tab2[7]={0,3,2,1,4,5,6}; - subMeshSimple=mesh->buildPartOfMySelfNode(tab2,tab2+7,true); - subMesh=dynamic_cast(subMeshSimple); - CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllTypes().begin())); - CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells()); - subMeshSimple->decrRef(); - // - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testZipCoords() -{ - MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells()); - std::vector oldConn(mesh->getNodalConnectivity()->getNbOfElems()); - std::vector oldConnIndex(mesh->getNumberOfCells()+1); - std::copy(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+oldConn.size(),oldConn.begin()); - std::copy(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+mesh->getNumberOfCells()+1,oldConnIndex.begin()); - DataArrayDouble *oldCoords=mesh->getCoords(); - oldCoords->incrRef(); - mesh->zipCoords(); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells()); - CPPUNIT_ASSERT(mesh->getCoords()!=oldCoords); - CPPUNIT_ASSERT(std::equal(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+2*9,oldCoords->getPointer())); - CPPUNIT_ASSERT(std::equal(oldConn.begin(),oldConn.end(),mesh->getNodalConnectivity()->getPointer())); - CPPUNIT_ASSERT(std::equal(oldConnIndex.begin(),oldConnIndex.end(),mesh->getNodalConnectivityIndex()->getPointer())); - oldCoords->decrRef(); - // - const int tab1[2]={0,4}; - MEDCouplingPointSet *subMeshPtSet=mesh->buildPartOfMySelf(tab1,tab1+2,true); - MEDCouplingUMesh *subMesh=dynamic_cast(subMeshPtSet); - CPPUNIT_ASSERT(subMesh); - DataArrayInt *traducer=subMesh->zipCoordsTraducer(); - const int expectedTraducer[7]={0,1,3,4,5,7,8}; - CPPUNIT_ASSERT(std::equal(expectedTraducer,expectedTraducer+7,traducer->getPointer())); - traducer->decrRef(); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells()); - const int subConn[10]={4,0,2,3,1,4,5,6,4,3}; - const int subConnIndex[3]={0,5,10}; - CPPUNIT_ASSERT_EQUAL(7,subMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(10,subMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(3,subMesh->getNodalConnectivityIndex()->getNbOfElems()); - CPPUNIT_ASSERT(std::equal(subConn,subConn+10,subMesh->getNodalConnectivity()->getPointer())); - CPPUNIT_ASSERT(std::equal(subConnIndex,subConnIndex+3,subMesh->getNodalConnectivityIndex()->getPointer())); - subMesh->decrRef(); - // - subMeshPtSet=mesh->buildPartOfMySelf(tab1,tab1+2,false); - subMesh=dynamic_cast(subMeshPtSet); - CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(7,subMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(10,subMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(3,subMesh->getNodalConnectivityIndex()->getNbOfElems()); - CPPUNIT_ASSERT(std::equal(subConn,subConn+10,subMesh->getNodalConnectivity()->getPointer())); - CPPUNIT_ASSERT(std::equal(subConnIndex,subConnIndex+3,subMesh->getNodalConnectivityIndex()->getPointer())); - subMesh->decrRef(); - // - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testZipConnectivity() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - MEDCouplingUMesh *m2=build2DTargetMesh_1(); - int cells1[3]={2,3,4}; - MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); - MEDCouplingUMesh *m3=dynamic_cast(m3_1); - CPPUNIT_ASSERT(m3); - m2->decrRef(); - MEDCouplingUMesh *m4=build2DSourceMesh_1(); - MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3); - m1->decrRef(); - m3->decrRef(); - MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4); - m4->decrRef(); - m5->decrRef(); - // - bool areNodesMerged; - int newNbOfNodes; - CPPUNIT_ASSERT_EQUAL(10,m6->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(22,m6->getNumberOfNodes()); - DataArrayInt *arr=m6->mergeNodes(1e-13,areNodesMerged,newNbOfNodes); - arr->decrRef(); - CPPUNIT_ASSERT(areNodesMerged); - CPPUNIT_ASSERT_EQUAL(10,m6->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(9,m6->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(9,newNbOfNodes); - // - arr=m6->zipConnectivityTraducer(0); - CPPUNIT_ASSERT_EQUAL(7,m6->getNumberOfCells()); - arr->decrRef(); - MEDCouplingUMesh *m7=m6->clone(true); - arr=m6->zipConnectivityTraducer(0); - CPPUNIT_ASSERT(m7->isEqual(m6,1e-12)); - CPPUNIT_ASSERT_EQUAL(7,m6->getNumberOfCells()); - arr->decrRef(); - // - m7->decrRef(); - m6->decrRef(); -} - -void MEDCouplingBasicsTest::testEqualMesh() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingUMesh *mesh2=build2DTargetMesh_1(); - // - CPPUNIT_ASSERT(mesh1->isEqual(mesh1,1e-12)); - // - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12)); - double *pt=mesh2->getCoords()->getPointer(); - double tmp=pt[1]; - pt[1]=5.999; - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12)); - pt[1]=tmp; - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12)); - // - int *pt2=mesh1->getNodalConnectivity()->getPointer(); - pt2[5]++; - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12)); - pt2[5]--; - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12)); - // - pt2=mesh1->getNodalConnectivityIndex()->getPointer(); - pt2[1]++; - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12)); - pt2[1]--; - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12)); - // - std::string tmp3=mesh1->getName(); - mesh1->setName("lllll"); - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12)); - mesh1->setName(tmp3.c_str()); - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12)); - // - tmp3=mesh2->getCoords()->getInfoOnComponent(1); - mesh2->getCoords()->setInfoOnComponent(1,"kkkkkk"); - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12)); - mesh2->getCoords()->setInfoOnComponent(1,tmp3.c_str()); - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12)); - // - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDCouplingBasicsTest::testEqualFieldDouble() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingUMesh *mesh2=build2DTargetMesh_1(); - // - MEDCouplingFieldDouble *fieldOnCells1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - fieldOnCells1->setMesh(mesh1); - MEDCouplingFieldDouble *fieldOnCells2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - fieldOnCells2->setMesh(mesh2); - // - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2->decrRef(); - // - MEDCouplingFieldDouble *fieldOnNodes1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnNodes1,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnNodes1->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnNodes1->decrRef(); - // - fieldOnCells2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells1->decrRef(); - fieldOnCells1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells1->setTime(4.,6,7); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2->setTime(4.,6,7); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells1->setName("Power"); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2->setName("Power"); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - // - fieldOnCells1->setMesh(mesh1); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2->setMesh(mesh1); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - DataArrayDouble *arr=DataArrayDouble::New(); - arr->setName("popo"); - arr->alloc(mesh1->getNumberOfCells(),3); - double *pt=arr->getPointer(); - std::fill(pt,pt+mesh1->getNumberOfCells()*3,6.); - fieldOnCells1->setArray(arr); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2->setArray(arr); - arr->decrRef(); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - // - DataArrayDouble *arr2=arr->deepCopy(); - fieldOnCells2->setArray(arr2); - arr2->decrRef(); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - pt[4]=6.1; - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - pt[4]=6.; - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - arr2->setName("popo2"); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - // - arr2->setName("popo"); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - // - arr2->setInfoOnComponent(2,"jjj"); - CPPUNIT_ASSERT(!fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(!fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - arr->setInfoOnComponent(2,"jjj"); - CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); - CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); - // - fieldOnCells1->decrRef(); - fieldOnCells2->decrRef(); - // - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDCouplingBasicsTest::testNatureChecking() -{ - MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - field->setNature(Integral); - field->setNature(ConservativeVolumic); - field->setNature(IntegralGlobConstraint); - field->decrRef(); - field=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); - field->setNature(ConservativeVolumic); - CPPUNIT_ASSERT_THROW(field->setNature(Integral),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(field->setNature(IntegralGlobConstraint),INTERP_KERNEL::Exception); - field->decrRef(); -} - -void MEDCouplingBasicsTest::testBuildSubMeshData() -{ - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - //check buildSubMesh on field on cells - MEDCouplingFieldDouble *fieldCells=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - fieldCells->setMesh(targetMesh); - const int elts[3]={1,2,4}; - DataArrayInt *di; - MEDCouplingMesh *ret1=fieldCells->buildSubMeshData(elts,elts+3,di); - CPPUNIT_ASSERT_EQUAL(3,ret1->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(6,ret1->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,di->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,di->getNumberOfComponents()); - const int *toCheck=di->getConstPointer(); - CPPUNIT_ASSERT(std::equal(elts,elts+3,toCheck)); - MEDCouplingUMesh *ret1DC=dynamic_cast(ret1); - CPPUNIT_ASSERT(ret1DC); - ret1->decrRef(); - di->decrRef(); - fieldCells->decrRef(); - //check buildSubMesh on field on nodes - MEDCouplingFieldDouble *fieldNodes=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); - fieldNodes->setMesh(targetMesh); - MEDCouplingMesh *ret2=fieldNodes->buildSubMeshData(elts,elts+3,di); - MEDCouplingUMesh *ret2DC=dynamic_cast(ret2); - CPPUNIT_ASSERT(ret2DC); - CPPUNIT_ASSERT_EQUAL(3,ret2->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(6,ret2->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(6,di->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,di->getNumberOfComponents()); - toCheck=di->getConstPointer(); - const int expected[6]={1,2,4,5,7,8}; - CPPUNIT_ASSERT(std::equal(expected,expected+6,toCheck)); - ret2->decrRef(); - di->decrRef(); - fieldNodes->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testExtrudedMesh1() -{ - MEDCouplingUMesh *mesh2D=0; - MEDCouplingUMesh *mesh3D=build3DExtrudedUMesh_1(mesh2D); - MEDCouplingExtrudedMesh *ext=MEDCouplingExtrudedMesh::New(mesh3D,mesh2D,1); - CPPUNIT_ASSERT_EQUAL(18,ext->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(60,ext->getNumberOfNodes()); - DataArrayInt *ids3D=ext->getMesh3DIds(); - const int ids3DExpected[18]={5,4,3,2,1,0, 11,10,9,8,7,6, 17,16,15,14,13,12}; - CPPUNIT_ASSERT_EQUAL(18,ids3D->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,ids3D->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(ids3DExpected,ids3DExpected+18,ids3D->getConstPointer())); - MEDCouplingUMesh *mesh1D=ext->getMesh1D(); - CPPUNIT_ASSERT_EQUAL(4,mesh1D->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,mesh1D->getNumberOfCells()); - const double mesh1DExpected[12]={0.66666666666666663, 1.4583333333333333, 0, 0.66666666666666663, 1.4583333333333333, 1, 0.66666666666666663, 1.4583333333333333, 2, 0.66666666666666663, 1.4583333333333333, 3}; - DataArrayDouble *mesh1DCoords=mesh1D->getCoords(); - CPPUNIT_ASSERT_EQUAL(4,mesh1DCoords->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,mesh1DCoords->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(mesh1DExpected,mesh1DExpected+12,mesh1DCoords->getConstPointer())); - DataArrayInt *conn1D=mesh1D->getNodalConnectivity(); - CPPUNIT_ASSERT_EQUAL(9,conn1D->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,conn1D->getNumberOfComponents()); - const int conn1DExpected[9]={1,0,1,1,1,2,1,2,3}; - CPPUNIT_ASSERT(std::equal(conn1DExpected,conn1DExpected+9,conn1D->getConstPointer())); - ext->decrRef(); - mesh3D->decrRef(); - mesh2D->decrRef(); -} - -void MEDCouplingBasicsTest::testExtrudedMesh2() -{ - MEDCouplingUMesh *mN,*mTT,*mTF; - build3DExtrudedUMesh_2(mN,mTT,mTF); - // - bool b=false; - int newNbOfNodes; - DataArrayInt *da=mTT->mergeNodes(1e-12,b,newNbOfNodes); - CPPUNIT_ASSERT(b); - da->decrRef(); - std::vector n; - double pt[3]={300.,300.,0.}; - double v[3]={0.,0.,2.}; - mTT->findNodesOnPlane(pt,v,1e-12,n); - CPPUNIT_ASSERT_EQUAL(43,(int)n.size()); - MEDCouplingUMesh *mTT3dSurf=(MEDCouplingUMesh *)mTT->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); - MEDCouplingExtrudedMesh *meTT=MEDCouplingExtrudedMesh::New(mTT,mTT3dSurf,0); - CPPUNIT_ASSERT_EQUAL(200,meTT->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(10,meTT->getMesh2D()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(20,meTT->getMesh1D()->getNumberOfCells()); - mTT3dSurf->decrRef(); - // - b=false; - da=mN->mergeNodes(1e-12,b,newNbOfNodes); - da->decrRef(); - CPPUNIT_ASSERT(!b); - n.clear(); - mN->findNodesOnPlane(pt,v,1e-12,n); - CPPUNIT_ASSERT_EQUAL(30,(int)n.size()); - MEDCouplingUMesh *mN3dSurf=(MEDCouplingUMesh *)mN->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); - MEDCouplingExtrudedMesh *meN=MEDCouplingExtrudedMesh::New(mN,mN3dSurf,0); - CPPUNIT_ASSERT_EQUAL(40,meN->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(20,meN->getMesh2D()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(2,meN->getMesh1D()->getNumberOfCells()); - mN3dSurf->decrRef(); - // - b=false; - da=mTF->mergeNodes(1e-12,b,newNbOfNodes); - da->decrRef(); - CPPUNIT_ASSERT(!b); - n.clear(); - mTF->findNodesOnPlane(pt,v,1e-12,n); - CPPUNIT_ASSERT_EQUAL(27,(int)n.size()); - MEDCouplingUMesh *mTF3dSurf=(MEDCouplingUMesh *)mTF->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); - MEDCouplingExtrudedMesh *meTF=MEDCouplingExtrudedMesh::New(mTF,mTF3dSurf,0); - CPPUNIT_ASSERT_EQUAL(340,meTF->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(17,meTF->getMesh2D()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(20,meTF->getMesh1D()->getNumberOfCells()); - mTF3dSurf->decrRef(); - // - meTT->decrRef(); - meN->decrRef(); - meTF->decrRef(); - // - mN->decrRef(); - mTT->decrRef(); - mTF->decrRef(); -} - -/*! - * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method. - */ -void MEDCouplingBasicsTest::testExtrudedMesh3() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - m1->changeSpaceDimension(3); - MEDCouplingUMesh *m2=buildCU1DMesh_U(); - m2->changeSpaceDimension(3); - double center[3]={0.,0.,0.}; - double vector[3]={0,1,0}; - m2->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0); - // - MEDCouplingExtrudedMesh *m4=MEDCouplingExtrudedMesh::New(m3,m1,0); - CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(5,m4->getMesh2D()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(3,m4->getMesh1D()->getNumberOfCells()); - const int *m3DIds=m4->getMesh3DIds()->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_EQUAL(i,m3DIds[i]); - m4->decrRef(); - //some random in cells to check that extrusion alg find it correctly - const int expected1[15]={1,3,2,0,6,5,7,10,11,8,12,9,14,13,4}; - m3->renumberCells(expected1,false); - m4=MEDCouplingExtrudedMesh::New(m3,m1,0); - CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(5,m4->getMesh2D()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(3,m4->getMesh1D()->getNumberOfCells()); - m3DIds=m4->getMesh3DIds()->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],m3DIds[i]); - m4->decrRef(); - m3->decrRef(); - //play with polygons and polyedrons - std::vector cells(2); cells[0]=2; cells[1]=3; - m1->convertToPolyTypes(cells); - m3=m1->buildExtrudedMeshFromThis(m2,0); - CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_HEXA8,(int)m3->getTypeOfCell(0)); - CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_PENTA6,(int)m3->getTypeOfCell(1)); - CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_POLYHED,(int)m3->getTypeOfCell(2)); - CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_POLYHED,(int)m3->getTypeOfCell(3)); - CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_HEXA8,(int)m3->getTypeOfCell(4)); - m3->renumberCells(expected1,false); - m4=MEDCouplingExtrudedMesh::New(m3,m1,0); - CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(5,m4->getMesh2D()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(3,m4->getMesh1D()->getNumberOfCells()); - m3DIds=m4->getMesh3DIds()->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],m3DIds[i]); - m4->decrRef(); - m3->decrRef(); - // - m2->decrRef(); - m1->decrRef(); -} - -/*! - * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method, but also, MEDCouplingExtrudedMesh following methods : - * getCellContainingPoint getMeasureField getNodeIdsOfCell getCoordinateOfNode getTypeOfCell build3DUnstructuredMesh. - */ -void MEDCouplingBasicsTest::testExtrudedMesh4() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - std::vector cells(2); cells[0]=2; cells[1]=4; - m1->convertToPolyTypes(cells); - m1->changeSpaceDimension(3); - MEDCouplingUMesh *m2=buildCU1DMesh_U(); - m2->changeSpaceDimension(3); - double center[3]={0.,0.,0.}; - double vector[3]={0.,1.,0.}; - m2->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0); - const int expected1[15]= {1,3,2,0,6,5,7,10,11,8,12,9,14,13,4}; - const int rexpected1[15]={3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12}; - m3->renumberCells(expected1,false); - MEDCouplingExtrudedMesh *m4=MEDCouplingExtrudedMesh::New(m3,m1,0); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,m4->getTypeOfCell(0)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,m4->getTypeOfCell(1)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYHED,m4->getTypeOfCell(2)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PENTA6,m4->getTypeOfCell(7)); - MEDCouplingFieldDouble *f=m4->getMeasureField(true); - DataArrayDouble *arr=f->getArray(); - CPPUNIT_ASSERT_EQUAL(15,arr->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,arr->getNumberOfComponents()); - const double *arrPtr=arr->getConstPointer(); - const double expected2[15]={0.075,0.0375,0.0375,0.075,0.075, 0.1125,0.05625,0.05625,0.1125,0.1125, 0.0625,0.03125,0.03125,0.0625,0.0625}; - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[rexpected1[i]],arrPtr[i],1e-16); - f->decrRef(); - MEDCouplingUMesh *m5=m4->build3DUnstructuredMesh(); - CPPUNIT_ASSERT(m5->isEqual(m3,1e-12)); - f=m5->getMeasureField(true); - arr=f->getArray(); - arrPtr=arr->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[rexpected1[i]],arrPtr[i],1e-16); - f->decrRef(); - m5->decrRef(); - // - m4->decrRef(); - m3->decrRef(); - m2->decrRef(); - m1->decrRef(); -} - -void MEDCouplingBasicsTest::testFindCommonNodes() -{ - DataArrayInt *comm,*commI; - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - targetMesh->findCommonNodes(-1,1e-10,comm,commI); - CPPUNIT_ASSERT_EQUAL(1,commI->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(0,comm->getNumberOfTuples()); - int newNbOfNodes; - DataArrayInt *o2n=targetMesh->buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes); - CPPUNIT_ASSERT_EQUAL(27,newNbOfNodes); - CPPUNIT_ASSERT_EQUAL(27,o2n->getNumberOfTuples()); - const int o2nExp1[27]= - { - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26 - }; - CPPUNIT_ASSERT(std::equal(o2nExp1,o2nExp1+27,o2n->getConstPointer())); - o2n->decrRef(); - comm->decrRef(); - commI->decrRef(); - targetMesh->decrRef(); - // - targetMesh=build3DTargetMeshMergeNode_1(); - CPPUNIT_ASSERT_EQUAL(31,targetMesh->getNumberOfNodes()); - targetMesh->findCommonNodes(-1,1e-10,comm,commI); - CPPUNIT_ASSERT_EQUAL(3,commI->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(6,comm->getNumberOfTuples()); - const int commExpected[6]={1,27,28,29,23,30}; - const int commIExpected[3]={0,4,6}; - CPPUNIT_ASSERT(std::equal(commExpected,commExpected+6,comm->getConstPointer())); - CPPUNIT_ASSERT(std::equal(commIExpected,commIExpected+3,commI->getConstPointer())); - o2n=targetMesh->buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes); - CPPUNIT_ASSERT_EQUAL(31,o2n->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(27,newNbOfNodes); - const int o2nExp2[31]= - { - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,1,1,1,23 - }; - CPPUNIT_ASSERT(std::equal(o2nExp2,o2nExp2+31,o2n->getConstPointer())); - o2n->decrRef(); - comm->decrRef(); - commI->decrRef(); - targetMesh->decrRef(); - // - targetMesh=build3DTargetMesh_1(); - bool areNodesMerged; - unsigned int time=targetMesh->getTimeOfThis(); - o2n=targetMesh->mergeNodes(1e-10,areNodesMerged,newNbOfNodes); - targetMesh->updateTime(); - CPPUNIT_ASSERT(time==targetMesh->getTimeOfThis()); - CPPUNIT_ASSERT(!areNodesMerged); - targetMesh->decrRef(); - o2n->decrRef(); - // - targetMesh=build3DTargetMeshMergeNode_1(); - time=targetMesh->getTimeOfThis(); - o2n=targetMesh->mergeNodes(1e-10,areNodesMerged,newNbOfNodes); - targetMesh->updateTime(); - CPPUNIT_ASSERT(time!=targetMesh->getTimeOfThis()); - CPPUNIT_ASSERT(areNodesMerged); - int connExp[72]={18,0,1,4,3,9,10,13,12, 18,1,2,5,4,10,11,14,13, 18,3,4,7,6,12,13,16,15, - 18,4,5,8,7,13,14,17,16, - 18,9,10,13,12,18,19,22,21, 18,10,11,14,13,19,20,23,22, 18,12,13,16,15,21,22,25,24, - 18,13,14,17,16,22,23,26,25}; - CPPUNIT_ASSERT_EQUAL(72,targetMesh->getNodalConnectivity()->getNumberOfTuples()); - CPPUNIT_ASSERT(std::equal(connExp,connExp+72,targetMesh->getNodalConnectivity()->getConstPointer())); - CPPUNIT_ASSERT_EQUAL(27,targetMesh->getCoords()->getNumberOfTuples()); - double coordsExp[81]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , - 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., - 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , - 200., 200., 50. , 0., 0., 200., 50., 0., 200. , 200., 0., 200. - , 0., 50., 200., 50., 50., 200. , 200., 50., 200., - 0., 200., 200., 50., 200., 200. , 200., 200., 200. }; - CPPUNIT_ASSERT(std::equal(coordsExp,coordsExp+81,targetMesh->getCoords()->getConstPointer())); - targetMesh->decrRef(); - o2n->decrRef(); - //2D - targetMesh=build2DTargetMeshMergeNode_1(); - CPPUNIT_ASSERT_EQUAL(18,targetMesh->getNumberOfNodes()); - time=targetMesh->getTimeOfThis(); - o2n=targetMesh->mergeNodes(1e-10,areNodesMerged,newNbOfNodes); - CPPUNIT_ASSERT(time!=targetMesh->getTimeOfThis()); - CPPUNIT_ASSERT(areNodesMerged); - CPPUNIT_ASSERT_EQUAL(9,targetMesh->getNumberOfNodes()); - int connExp2[23]={4,0,4,3,1, 3,1,3,2, 3,3,5,2, 4,4,6,7,3, 4,7,8,5,3}; - CPPUNIT_ASSERT_EQUAL(23,targetMesh->getNodalConnectivity()->getNumberOfTuples()); - CPPUNIT_ASSERT(std::equal(connExp2,connExp2+23,targetMesh->getNodalConnectivity()->getConstPointer())); - double coordsExp2[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, 0.2,0.2, -0.3,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7}; - CPPUNIT_ASSERT_EQUAL(9,targetMesh->getCoords()->getNumberOfTuples()); - CPPUNIT_ASSERT(std::equal(coordsExp2,coordsExp2+18,targetMesh->getCoords()->getConstPointer())); - targetMesh->decrRef(); - o2n->decrRef(); -} - -void MEDCouplingBasicsTest::testCheckButterflyCells() -{ - std::vector cells; - MEDCouplingUMesh *sourceMesh=build2DTargetMesh_1(); - sourceMesh->checkButterflyCells(cells); - CPPUNIT_ASSERT(cells.empty()); - int *pt=sourceMesh->getNodalConnectivity()->getPointer(); - std::swap(pt[15],pt[16]); - sourceMesh->checkButterflyCells(cells); - CPPUNIT_ASSERT_EQUAL(1,(int)cells.size()); - CPPUNIT_ASSERT_EQUAL(3,cells[0]); - cells.clear(); - std::swap(pt[15],pt[16]); - sourceMesh->checkButterflyCells(cells); - CPPUNIT_ASSERT(cells.empty()); - sourceMesh->decrRef(); - // 3D surf - sourceMesh=build3DSurfTargetMesh_1(); - sourceMesh->checkButterflyCells(cells); - CPPUNIT_ASSERT(cells.empty()); - pt=sourceMesh->getNodalConnectivity()->getPointer(); - std::swap(pt[15],pt[16]); - sourceMesh->checkButterflyCells(cells); - CPPUNIT_ASSERT_EQUAL(1,(int)cells.size()); - CPPUNIT_ASSERT_EQUAL(3,cells[0]); - cells.clear(); - std::swap(pt[15],pt[16]); - sourceMesh->checkButterflyCells(cells); - CPPUNIT_ASSERT(cells.empty()); - sourceMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testMergeMesh1() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - MEDCouplingUMesh *m2=build2DSourceMesh_1(); - const double vec[2]={1.,0.}; - m2->translate(vec); - MEDCouplingMesh *m3=m1->mergeMyselfWith(m2); - MEDCouplingUMesh *m3C=dynamic_cast(m3); - CPPUNIT_ASSERT(m3C); - m3->checkCoherency(); - MEDCouplingUMesh *m4=build2DTargetMeshMerged_1(); - CPPUNIT_ASSERT(m3->isEqual(m4,1.e-12)); - m4->decrRef(); - bool isMerged; - int newNbOfNodes; - DataArrayInt *da=m3C->mergeNodes(1.e-12,isMerged,newNbOfNodes); - CPPUNIT_ASSERT_EQUAL(11,m3C->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(11,newNbOfNodes); - CPPUNIT_ASSERT(isMerged); - da->decrRef(); - m3->decrRef(); - m1->decrRef(); - m2->decrRef(); -} - -void MEDCouplingBasicsTest::testMergeMeshOnSameCoords1() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - MEDCouplingUMesh *m2=build2DTargetMesh_1(); - std::vector cells(5); - for(int i=0;i<5;i++) - cells[i]=i; - m2->convertToPolyTypes(cells); - m1->tryToShareSameCoords(*m2,1e-12); - MEDCouplingUMesh *m3=build2DTargetMesh_1(); - m3->tryToShareSameCoords(*m2,1e-12); - std::vector meshes; - meshes.push_back(m1); meshes.push_back(m2); meshes.push_back(m3); - MEDCouplingUMesh *m4=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes); - m4->checkCoherency(); - CPPUNIT_ASSERT(m4->getCoords()==m1->getCoords()); - CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); - const int cells1[5]={0,1,2,3,4}; - MEDCouplingPointSet *m1_1=m4->buildPartOfMySelf(cells1,cells1+5,true); - m1_1->setName(m1->getName()); - CPPUNIT_ASSERT(m1->isEqual(m1_1,1e-12)); - const int cells2[5]={5,6,7,8,9}; - MEDCouplingPointSet *m2_1=m4->buildPartOfMySelf(cells2,cells2+5,true); - m2_1->setName(m2->getName()); - CPPUNIT_ASSERT(m2->isEqual(m2_1,1e-12)); - const int cells3[5]={10,11,12,13,14}; - MEDCouplingPointSet *m3_1=m4->buildPartOfMySelf(cells3,cells3+5,true); - m3_1->setName(m3->getName()); - CPPUNIT_ASSERT(m3->isEqual(m3_1,1e-12)); - m1_1->decrRef(); m2_1->decrRef(); m3_1->decrRef(); - // - m4->decrRef(); - m1->decrRef(); - m2->decrRef(); - m3->decrRef(); -} - -void MEDCouplingBasicsTest::testMergeField1() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - MEDCouplingUMesh *m2=build2DSourceMesh_1(); - const double vec[2]={1.,0.}; - m2->translate(vec); - MEDCouplingFieldDouble *f1=m1->getMeasureField(true); - MEDCouplingFieldDouble *f2=m2->getMeasureField(true); - MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::mergeFields(f1,f2); - f3->checkCoherency(); - MEDCouplingUMesh *m4=build2DTargetMeshMerged_1(); - CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12)); - std::string name=f3->getName(); - CPPUNIT_ASSERT(name=="MeasureOfMesh_"); - CPPUNIT_ASSERT(f3->getTypeOfField()==ON_CELLS); - CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f3->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(7,f3->getNumberOfTuples()); - double values[7]={0.25,0.125,0.125,0.25,0.25,0.5,0.5}; - const double *tmp=f3->getArray()->getConstPointer(); - std::transform(tmp,tmp+7,values,values,std::minus()); - std::transform(values,values+7,values,std::ptr_fun(fabs)); - double max=*std::max_element(values,values+7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - m4->decrRef(); - f3->decrRef(); - f1->decrRef(); - f2->decrRef(); - m1->decrRef(); - m2->decrRef(); -} - -bool func1(const double *pt, double *res); -bool func2(const double *pt, double *res); -bool func3(const double *pt, double *res); -bool func4(const double *pt, double *res); - -bool func1(const double *pt, double *res) -{ - res[0]=pt[0]+pt[1]; - return true; -} - -bool func2(const double *pt, double *res) -{ - res[0]=pt[0]+pt[1]; - res[1]=2.*(pt[0]+pt[1]); - return true; -} - -bool func3(const double *pt, double *res) -{ - if(fabs(pt[0]-0.2)<1e-12) - return false; - res[0]=1./(pt[0]-0.2); - return true; -} - -void MEDCouplingBasicsTest::testFillFromAnalytic() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_CELLS,1,func1); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_CELLS); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - double values1[5]={-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9}; - const double *tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+5,values1,values1,std::minus()); - std::transform(values1,values1+5,values1,std::ptr_fun(fabs)); - double max=*std::max_element(values1,values1+5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f1->decrRef(); - // - f1=m->fillFromAnalytic(ON_NODES,1,func1); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - double values2[9]={-0.6,-0.1,0.4,-0.1,0.4,0.9,0.4,0.9,1.4}; - tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+9,values2,values2,std::minus()); - std::transform(values2,values2+9,values2,std::ptr_fun(fabs)); - max=*std::max_element(values2,values2+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f1->decrRef(); - // - f1=m->fillFromAnalytic(ON_NODES,2,func2); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - double values3[18]={-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8}; - tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+18,values3,values3,std::minus()); - std::transform(values3,values3+18,values3,std::ptr_fun(fabs)); - max=*std::max_element(values3,values3+18); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - double values4[2]; - f1->accumulate(values4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.6,values4[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.2,values4[1],1.e-12); - f1->integral(true,values4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,values4[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,values4[1],1.e-12); - f1->decrRef(); - // - CPPUNIT_ASSERT_THROW(f1=m->fillFromAnalytic(ON_NODES,1,func3),INTERP_KERNEL::Exception); - // - m->decrRef(); -} - -void MEDCouplingBasicsTest::testFillFromAnalytic2() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_CELLS,1,"y+x"); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_CELLS); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - double values1[5]={-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9}; - const double *tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+5,values1,values1,std::minus()); - std::transform(values1,values1+5,values1,std::ptr_fun(fabs)); - double max=*std::max_element(values1,values1+5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f1->decrRef(); - // - f1=m->fillFromAnalytic(ON_NODES,1,"y+2*x"); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - double values2[9]={-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1}; - tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+9,values2,values2,std::minus()); - std::transform(values2,values2+9,values2,std::ptr_fun(fabs)); - max=*std::max_element(values2,values2+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f1->decrRef(); - f1=m->fillFromAnalytic(ON_NODES,1,"2.*x+y"); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - tmp=f1->getArray()->getConstPointer(); - double values2Bis[9]={-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1}; - std::transform(tmp,tmp+9,values2Bis,values2Bis,std::minus()); - std::transform(values2,values2+9,values2Bis,std::ptr_fun(fabs)); - max=*std::max_element(values2Bis,values2Bis+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f1->decrRef(); - // - f1=m->fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+2*(x+y)*JVec"); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - double values3[18]={-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8}; - tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+18,values3,values3,std::minus()); - std::transform(values3,values3+18,values3,std::ptr_fun(fabs)); - max=*std::max_element(values3,values3+18); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - double values4[2]; - f1->accumulate(values4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.6,values4[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.2,values4[1],1.e-12); - f1->integral(true,values4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,values4[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,values4[1],1.e-12); - f1->decrRef(); - // - CPPUNIT_ASSERT_THROW(f1=m->fillFromAnalytic(ON_NODES,1,"1./(x-0.2)"),INTERP_KERNEL::Exception); - // - m->decrRef(); -} - -void MEDCouplingBasicsTest::testApplyFunc() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,2,func2); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - f1->applyFunc(1,func1); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - double values1[9]={-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2}; - const double *tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+9,values1,values1,std::minus()); - std::transform(values1,values1+9,values1,std::ptr_fun(fabs)); - double max=*std::max_element(values1,values1+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f1->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testApplyFunc2() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,2,func2); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - // - MEDCouplingFieldDouble *f2=f1->clone(true); - f2->applyFunc("abs(u)^2.4+2*u"); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - double values2[18]={-0.9065304805418678, -0.85105859001709905, -0.19601892829446504, -0.37898777756476987, - 0.91090317490482353, 2.1853504664669781, -0.19601892829446504, -0.37898777756476987, - 0.91090317490482353, 2.1853504664669781, 2.5765725275664879, 7.6987743736515295, - 0.91090317490482353, 2.1853504664669781, 2.5765725275664879, 7.6987743736515295, - 5.0423700574830965, 17.435300118916864}; - const double *tmp=f2->getArray()->getConstPointer(); - std::transform(tmp,tmp+18,values2,values2,std::minus()); - std::transform(values2,values2+18,values2,std::ptr_fun(fabs)); - double max=*std::max_element(values2,values2+18); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f2->decrRef(); - // - f1->applyFunc(1,"x+y"); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - double values1[9]={-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2}; - tmp=f1->getArray()->getConstPointer(); - std::transform(tmp,tmp+9,values1,values1,std::minus()); - std::transform(values1,values1+9,values1,std::ptr_fun(fabs)); - max=*std::max_element(values1,values1+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f1->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testOperationsOnFields() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,1,func1); - MEDCouplingFieldDouble *f2=m->fillFromAnalytic(ON_NODES,1,func1); - f1->checkCoherency(); - f2->checkCoherency(); - MEDCouplingFieldDouble *f3=(*f1)+(*f2); - f3->checkCoherency(); - CPPUNIT_ASSERT(f3->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME); - double values1[9]={-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8}; - const double *tmp=f3->getArray()->getConstPointer(); - std::transform(tmp,tmp+9,values1,values1,std::minus()); - std::transform(values1,values1+9,values1,std::ptr_fun(fabs)); - double max=*std::max_element(values1,values1+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f3->decrRef(); - // - f3=(*f1)*(*f2); - f3->checkCoherency(); - CPPUNIT_ASSERT(f3->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME); - double values2[9]={0.36,0.01,0.16,0.01,0.16,0.81,0.16,0.81,1.96}; - tmp=f3->getArray()->getConstPointer(); - std::transform(tmp,tmp+9,values2,values2,std::minus()); - std::transform(values2,values2+9,values2,std::ptr_fun(fabs)); - max=*std::max_element(values2,values2+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f3->decrRef(); - // - f3=(*f1)+(*f2); - MEDCouplingFieldDouble *f4=(*f1)-(*f3); - f4->checkCoherency(); - CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f4->getTimeDiscretization()==NO_TIME); - double values3[9]={0.6,0.1,-0.4,0.1,-0.4,-0.9,-0.4,-0.9,-1.4}; - tmp=f4->getArray()->getConstPointer(); - std::transform(tmp,tmp+9,values3,values3,std::minus()); - std::transform(values3,values3+9,values3,std::ptr_fun(fabs)); - max=*std::max_element(values3,values3+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f3->decrRef(); - f4->decrRef(); - // - f3=(*f1)+(*f2); - f4=(*f3)/(*f2); - f4->checkCoherency(); - CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f4->getTimeDiscretization()==NO_TIME); - tmp=f4->getArray()->getConstPointer(); - for(int i=0;i<9;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,tmp[i],1.e-12); - f3->decrRef(); - f4->decrRef(); - // - f4=f2->buildNewTimeReprFromThis(ONE_TIME,false); - f4->checkCoherency(); - CPPUNIT_ASSERT(f4->getArray()==f2->getArray()); - CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f4->getTimeDiscretization()==ONE_TIME); - CPPUNIT_ASSERT_THROW(f3=(*f1)+(*f4),INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *f5=f4->buildNewTimeReprFromThis(NO_TIME,false); - CPPUNIT_ASSERT(f4->getArray()==f5->getArray()); - CPPUNIT_ASSERT(f5->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f5->getTimeDiscretization()==NO_TIME); - f3=(*f1)+(*f5); - tmp=f3->getArray()->getConstPointer(); - double values4[9]={-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8}; - std::transform(tmp,tmp+9,values4,values4,std::minus()); - std::transform(values4,values4+9,values4,std::ptr_fun(fabs)); - max=*std::max_element(values4,values4+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f5->decrRef(); - f4->decrRef(); - f3->decrRef(); - // - f4=f2->buildNewTimeReprFromThis(ONE_TIME,true); - f4->checkCoherency(); - CPPUNIT_ASSERT(f4->getArray()!=f2->getArray()); - CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f4->getTimeDiscretization()==ONE_TIME); - CPPUNIT_ASSERT_THROW(f3=(*f1)+(*f4),INTERP_KERNEL::Exception); - f5=f4->buildNewTimeReprFromThis(NO_TIME,true); - CPPUNIT_ASSERT(f4->getArray()!=f5->getArray()); - CPPUNIT_ASSERT(f2->getArray()!=f5->getArray()); - CPPUNIT_ASSERT(f5->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f5->getTimeDiscretization()==NO_TIME); - f3=(*f1)+(*f5); - tmp=f3->getArray()->getConstPointer(); - double values5[9]={-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8}; - std::transform(tmp,tmp+9,values5,values5,std::minus()); - std::transform(values5,values5+9,values5,std::ptr_fun(fabs)); - max=*std::max_element(values5,values5+9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); - f5->decrRef(); - f4->decrRef(); - f3->decrRef(); - // - f1->decrRef(); - f2->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testOperationsOnFields2() -{ - MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,1,"x+y+z"); - MEDCouplingFieldDouble *f2=m->fillFromAnalytic(ON_NODES,1,"a*a+b+c*c"); - MEDCouplingFieldDouble *f3=(*f1)/(*f2); - f3->checkCoherency(); - CPPUNIT_ASSERT(f3->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME); - const double expected1[9]={-2.4999999999999991, 1.2162162162162162, 0.77868852459016391, - 0.7407407407407407, 1.129032258064516, 0.81632653061224492, - 0.86538461538461531, 1.0919540229885056, 0.84302325581395343}; - CPPUNIT_ASSERT_EQUAL(1,f3->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f3->getNumberOfTuples()); - const double *val=f3->getArray()->getConstPointer(); - for(int i=0;i<9;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],val[i],1.e-12); - f3->decrRef(); - f1->decrRef(); - f2->decrRef(); - // - f1=m->buildOrthogonalField(); - f2=m->fillFromAnalytic(ON_CELLS,1,"x"); - f3=(*f1)*(*f2); - const double expected2[15]={-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637}; - val=f3->getArray()->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],val[i],1.e-12); - f3->decrRef(); - // - f3=(*f2)*(*f1); - val=f3->getArray()->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],val[i],1.e-12); - f3->decrRef(); - // - f1->decrRef(); - f2->decrRef(); - // - m->decrRef(); -} - -void MEDCouplingBasicsTest::testOperationsOnFields3() -{ - MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,1,"x+y+z"); - MEDCouplingFieldDouble *f2=m->fillFromAnalytic(ON_NODES,1,"a*a+b+c*c"); - (*f1)/=(*f2); - f1->checkCoherency(); - CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES); - CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME); - const double expected1[9]={-2.4999999999999991, 1.2162162162162162, 0.77868852459016391, - 0.7407407407407407, 1.129032258064516, 0.81632653061224492, - 0.86538461538461531, 1.0919540229885056, 0.84302325581395343}; - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); - const double *val=f1->getArray()->getConstPointer(); - for(int i=0;i<9;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],val[i],1.e-12); - f1->decrRef(); - f2->decrRef(); - // - f1=m->buildOrthogonalField(); - f2=m->fillFromAnalytic(ON_CELLS,1,"x"); - (*f1)*=(*f2); - const double expected2[15]={-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637}; - val=f1->getArray()->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],val[i],1.e-12); - f1->decrRef(); - // - f1=m->buildOrthogonalField(); - CPPUNIT_ASSERT_THROW((*f2)*=(*f1),INTERP_KERNEL::Exception); - f1->decrRef(); - f2->decrRef(); - // - m->decrRef(); -} - -/*! - * Check of LINEAR_TIME and CONST_ON_TIME_INTERVAL policies - */ -void MEDCouplingBasicsTest::testOperationsOnFields4() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL); - f1->setMesh(m); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(nbOfCells,3); - f1->setArray(array); - CPPUNIT_ASSERT_THROW(f1->setEndArray(array),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_THROW(f1->getEndArray(),INTERP_KERNEL::Exception); - array->decrRef(); - double *tmp=array->getPointer(); - const double arr1[15]={0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.}; - const double arr2[15]={5.,15.,25.,6.,16.,26.,7.,17.,27.,8.,18.,28.,9.,19.,29.}; - std::copy(arr1,arr1+15,tmp); - f1->setStartTime(2.,0,0); - f1->setEndTime(3.,0,0); - f1->checkCoherency(); - double res[3]; - const double pos[2]={0.3,-0.2}; - f1->getValueOn(pos,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[3],res[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[4],res[1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[5],res[2],1.e-12); - std::fill(res,res+3,0.); - f1->getValueOn(pos,2.2,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[3],res[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[4],res[1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[5],res[2],1.e-12); - std::fill(res,res+3,0.); - CPPUNIT_ASSERT_THROW(f1->getValueOn(pos,3.2,res),INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); - f2->setMesh(m); - f2->setArray(f1->getArray()); - f2->setStartTime(2.,3,0); - f2->setEndTime(4.,13,0); - CPPUNIT_ASSERT_THROW(f2->checkCoherency(),INTERP_KERNEL::Exception); - DataArrayDouble *array2=DataArrayDouble::New(); - array2->alloc(nbOfCells,3); - tmp=array2->getPointer(); - std::copy(arr2,arr2+15,tmp); - f2->setEndArray(array2); - array2->decrRef(); - f2->checkCoherency(); - // - std::fill(res,res+3,0.); - f2->getValueOn(pos,3.21,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.025,res[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(14.025,res[1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.025,res[2],1.e-12); - MEDCouplingFieldDouble *f3=f2->clone(true); - CPPUNIT_ASSERT(f2->isEqual(f3,1e-12,1e-12)); - f3->getEndArray()->getPointer()[0]=5.001; - CPPUNIT_ASSERT(!f2->isEqual(f3,1e-12,1e-12)); - CPPUNIT_ASSERT(f2->isEqual(f3,1e-12,1e-2)); - f3->setStartTime(2.1,3,0); - CPPUNIT_ASSERT(!f2->isEqual(f3,1e-12,1e-2)); - f3->setStartTime(2.,3,0); - CPPUNIT_ASSERT(f2->isEqual(f3,1e-12,1e-2)); - f3->setStartTime(2.,4,0); - CPPUNIT_ASSERT(!f2->isEqual(f3,1e-12,1e-2)); - f3->setStartTime(2.,3,1); - CPPUNIT_ASSERT(!f2->isEqual(f3,1e-12,1e-2)); - f3->setStartTime(2.,3,0); - CPPUNIT_ASSERT(f2->isEqual(f3,1e-12,1e-2)); - f3->setEndTime(4.1,13,0); - CPPUNIT_ASSERT(!f2->isEqual(f3,1e-12,1e-2)); - f3->setEndTime(4.,13,0); - CPPUNIT_ASSERT(f2->isEqual(f3,1e-12,1e-2)); - f3->setEndTime(4.,14,0); - CPPUNIT_ASSERT(!f2->isEqual(f3,1e-12,1e-2)); - f3->setEndTime(4.,13,1); - CPPUNIT_ASSERT(!f2->isEqual(f3,1e-12,1e-2)); - f3->setEndTime(4.,13,0); - CPPUNIT_ASSERT(f2->isEqual(f3,1e-12,1e-2)); - f3->decrRef(); - MEDCouplingFieldDouble *f4=(*f2)+(*f2); - std::fill(res,res+3,0.); - f4->getValueOn(pos,3.21,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.05,res[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(28.05,res[1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(48.05,res[2],1.e-12); - (*f4)+=*f2; - std::fill(res,res+3,0.); - f4->getValueOn(pos,3.21,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(12.075,res[0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(42.075,res[1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(72.075,res[2],1.e-12); - f4->decrRef(); - // - f2->decrRef(); - f1->decrRef(); - m->decrRef(); -} - -bool func4(const double *pt, double *res) -{ - res[0]=pt[0]+pt[1]+pt[2]; - return true; -} - -void MEDCouplingBasicsTest::testMergeNodesOnField() -{ - double *tmp; - MEDCouplingUMesh *targetMesh=build3DTargetMeshMergeNode_1(); - MEDCouplingFieldDouble *f1=targetMesh->fillFromAnalytic(ON_NODES,1,func4); - f1->mergeNodes(1e-10); - f1->decrRef(); - targetMesh->decrRef(); - // - targetMesh=build3DTargetMeshMergeNode_1(); - f1=targetMesh->fillFromAnalytic(ON_NODES,1,func4); - tmp=f1->getArray()->getPointer(); - tmp[0]=1000.; - f1->mergeNodes(1e-10); - f1->decrRef(); - targetMesh->decrRef(); - // - targetMesh=build3DTargetMeshMergeNode_1(); - f1=targetMesh->fillFromAnalytic(ON_NODES,1,func4); - tmp=f1->getArray()->getPointer(); - tmp[1]=1000.; - CPPUNIT_ASSERT_THROW(f1->mergeNodes(1e-10),INTERP_KERNEL::Exception); - f1->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testCheckConsecutiveCellTypes() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - CPPUNIT_ASSERT(sourceMesh->checkConsecutiveCellTypes()); - const INTERP_KERNEL::NormalizedCellType order1[]={INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4}; - const INTERP_KERNEL::NormalizedCellType order2[]={INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI3}; - CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypes()); - CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypesAndOrder(order1,order1+2)); - CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypesAndOrder(order2,order2+2)); - DataArrayInt *da=targetMesh->getRenumArrForConsecutiveCellTypesSpec(order1,order1+2); - CPPUNIT_ASSERT_EQUAL(5,da->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents()); - const int expected1[5]={2,0,1,3,4}; - CPPUNIT_ASSERT(std::equal(expected1,expected1+5,da->getConstPointer())); - da->decrRef(); - da=targetMesh->getRenumArrForConsecutiveCellTypesSpec(order2,order2+2); - CPPUNIT_ASSERT_EQUAL(5,da->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents()); - const int expected2[5]={0,3,4,1,2}; - CPPUNIT_ASSERT(std::equal(expected2,expected2+5,da->getConstPointer())); - da->decrRef(); - const int renumber1[5]={4,0,1,2,3}; - targetMesh->renumberCells(renumber1,false); - CPPUNIT_ASSERT(targetMesh->checkConsecutiveCellTypes()); - CPPUNIT_ASSERT(targetMesh->checkConsecutiveCellTypesAndOrder(order1,order1+2)); - CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypesAndOrder(order2,order2+2)); - targetMesh->decrRef(); - sourceMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testRearrange2ConsecutiveCellTypes() -{ - MEDCouplingUMesh *m1_1=build2DSourceMesh_1(); - MEDCouplingUMesh *m2_1=build2DTargetMesh_1(); - DataArrayInt *arr1=m1_1->rearrange2ConsecutiveCellTypes(); - MEDCouplingUMesh *m1_2=build2DSourceMesh_1(); - CPPUNIT_ASSERT(m1_2->isEqual(m1_1,1e-12)); - const int expected1[2]={0,1}; - CPPUNIT_ASSERT_EQUAL(2,arr1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,arr1->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(expected1,expected1+2,arr1->getConstPointer())); - arr1->decrRef(); - const int expected2[5]={0,3,4,1,2}; - arr1=m2_1->rearrange2ConsecutiveCellTypes(); - CPPUNIT_ASSERT_EQUAL(5,arr1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,arr1->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(expected2,expected2+5,arr1->getConstPointer())); - MEDCouplingUMesh *m2_2=build2DTargetMesh_1(); - CPPUNIT_ASSERT_EQUAL(5,arr1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,arr1->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(expected2,expected2+5,arr1->getConstPointer())); - CPPUNIT_ASSERT(!m2_2->isEqual(m2_1,1e-12)); - m2_2->renumberCells(expected2,false); - CPPUNIT_ASSERT(m2_2->isEqual(m2_1,1e-12)); - arr1->decrRef(); - m1_1->decrRef(); - m1_2->decrRef(); - m2_1->decrRef(); - m2_2->decrRef(); -} - -void MEDCouplingBasicsTest::testSplitByType() -{ - MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); - std::vector v=m1->splitByType(); - CPPUNIT_ASSERT_EQUAL(3,(int)v.size()); - MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshesOnSameCoords(v); - m2->setName(m1->getName()); - CPPUNIT_ASSERT(m1->isEqual(m2,1.e-12)); - for(std::vector::const_iterator iter=v.begin();iter!=v.end();iter++) - (*iter)->decrRef(); - m2->decrRef(); - m1->decrRef(); -} - -void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords() -{ - std::vector meshes; - MEDCouplingUMesh *m2=build2DTargetMesh_1(); - int cells1[3]={2,3,4}; - MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); - MEDCouplingUMesh *m3=dynamic_cast(m3_1); - CPPUNIT_ASSERT(m3); - meshes.push_back(m3); - int cells2[3]={1,2,4}; - MEDCouplingPointSet *m4_1=m2->buildPartOfMySelf(cells2,cells2+3,true); - MEDCouplingUMesh *m4=dynamic_cast(m4_1); - CPPUNIT_ASSERT(m4); - meshes.push_back(m4); - int cells3[2]={1,2}; - MEDCouplingPointSet *m5_1=m2->buildPartOfMySelf(cells3,cells3+2,true); - MEDCouplingUMesh *m5=dynamic_cast(m5_1); - CPPUNIT_ASSERT(m5); - meshes.push_back(m5); - m2->decrRef(); - // - std::vector corr; - MEDCouplingUMesh *m7=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr); - CPPUNIT_ASSERT_EQUAL(4,m7->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(3,(int)corr.size()); - const int expectedVals1[3]={3,3,2}; - const int expectedVals2[3][3]={{0,1,2},{3,0,2},{3,0,111111}}; - for(int i=0;i<3;i++) - { - DataArrayInt *arr=corr[i]; - CPPUNIT_ASSERT_EQUAL(1,arr->getNumberOfComponents()); - int nbOfVals=expectedVals1[i]; - CPPUNIT_ASSERT_EQUAL(nbOfVals,arr->getNumberOfTuples()); - const int *vals=arr->getConstPointer(); - for(int j=0;j > fidsOfGroups; - DataArrayInt *arr2=DataArrayInt::makePartition(corr,m7->getNumberOfCells(),fidsOfGroups); - const int fidExp[4]={5,1,3,4}; - const int fidsGrp[3][3]={{1,3,5},{3,4,5},{4,5,23344}}; - CPPUNIT_ASSERT_EQUAL(3,(int)fidsOfGroups.size()); - CPPUNIT_ASSERT_EQUAL(1,arr2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(4,arr2->getNumberOfTuples()); - CPPUNIT_ASSERT(std::equal(fidExp,fidExp+4,arr2->getConstPointer())); - for(int i=0;i<3;i++) - { - int nbOfVals=expectedVals1[i]; - CPPUNIT_ASSERT_EQUAL(nbOfVals,(int)fidsOfGroups[i].size()); - CPPUNIT_ASSERT(std::equal(fidsOfGroups[i].begin(),fidsOfGroups[i].end(),fidsGrp[i])); - } - for(std::vector::iterator iter=corr.begin();iter!=corr.end();iter++) - (*iter)->decrRef(); - arr2->decrRef(); - m7->decrRef(); - // - m3->decrRef(); - m4->decrRef(); - m5->decrRef(); -} - -void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords2() -{ - MEDCouplingUMesh *m2; - MEDCouplingUMesh *m1=build3DExtrudedUMesh_1(m2); - m2->decrRef(); - const int part1[5]={2,3,6,4,10}; - MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part1,part1+5,true); - const int part2[4]={5,6,4,7}; - MEDCouplingUMesh *m4=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part2,part2+4,true); - std::vector meshes; - meshes.push_back(m1); - meshes.push_back(m3); - meshes.push_back(m3); - meshes.push_back(m4); - std::vector corr; - MEDCouplingUMesh *m5=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr); - CPPUNIT_ASSERT_EQUAL(18,m5->getNumberOfCells()); - std::vector::iterator it=corr.begin(); - const int exp1[4]={18,5,5,4}; - const int exp2[4][18]={ - {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}, - {2,3,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, - {2,3,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, - {5,6,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} - }; - int i=0; - for(;it!=corr.end();it++,i++) - { - int sz=(*it)->getNumberOfTuples(); - CPPUNIT_ASSERT_EQUAL(exp1[i],sz); - CPPUNIT_ASSERT(std::equal(exp2[i],exp2[i]+sz,(*it)->getConstPointer())); - } - for(it=corr.begin();it!=corr.end();it++) - (*it)->decrRef(); - m5->decrRef(); - m4->decrRef(); - m3->decrRef(); - m1->decrRef(); -} - -void MEDCouplingBasicsTest::testBuildOrthogonalField() -{ - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - MEDCouplingFieldDouble *field=targetMesh->buildOrthogonalField(); - double expected[3]={0.70710678118654746,0.,-0.70710678118654746}; - CPPUNIT_ASSERT_EQUAL(5,field->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,field->getNumberOfComponents()); - const double *vals=field->getArray()->getConstPointer(); - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[i%3],vals[i],1e-12); - field->decrRef(); - targetMesh->decrRef(); - // testing - double targetCoords[12]={0.,0.,0.,0.5,0.,0.5,1.,0.,1.,0.,1.,0.}; - int targetConn[4]={0,1,2,3}; - targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(1); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,3); - std::copy(targetCoords,targetCoords+12,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - field=targetMesh->buildOrthogonalField(); - CPPUNIT_ASSERT_EQUAL(1,field->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,field->getNumberOfComponents()); - vals=field->getArray()->getConstPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.70710678118654746,vals[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,vals[1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.70710678118654746,vals[2],1e-12); - field->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testGetCellsContainingPoint() -{ - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - double pos[12]={0.,0.,0.4,0.4,0.,0.4,0.1,0.1,0.25,0.,0.65,0.}; - std::vector t1,t2; - //2D basic - targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2); - CPPUNIT_ASSERT_EQUAL(6,(int)t1.size()); - CPPUNIT_ASSERT_EQUAL(7,(int)t2.size()); - const int expectedValues1[6]={0,4,3,0,1,2}; - const int expectedValues2[7]={0,1,2,3,4,5,6}; - CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues1)); - CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2)); - //2D with no help of bounding box. - double center[2]={0.2,0.2}; - MEDCouplingPointSet::rotate2DAlg(center,0.78539816339744830962,6,pos); - targetMesh->rotate(center,0,0.78539816339744830962); - t1.clear(); t2.clear(); - targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2); - CPPUNIT_ASSERT_EQUAL(6,(int)t1.size()); - CPPUNIT_ASSERT_EQUAL(7,(int)t2.size()); - CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues1)); - CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2)); - //2D outside - const double pos1bis[2]={-0.3303300858899107,-0.11819805153394641}; - CPPUNIT_ASSERT_EQUAL(-1,targetMesh->getCellContainingPoint(pos1bis,1e-12)); - targetMesh->decrRef(); - //test limits 2D - targetMesh=build2DTargetMesh_1(); - const double pos2[2]={0.2,-0.05}; - t1.clear(); - targetMesh->getCellsContainingPoint(pos2,1e-12,t1); - CPPUNIT_ASSERT_EQUAL(2,(int)t1.size()); - const int expectedValues3[2]={0,1}; - CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues3)); - const double pos3[2]={0.2,0.2}; - t1.clear(); - targetMesh->getCellsContainingPoint(pos3,1e-12,t1); - CPPUNIT_ASSERT_EQUAL(5,(int)t1.size()); - const int expectedValues4[5]={0,1,2,3,4}; - CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues4)); - CPPUNIT_ASSERT_EQUAL(0,targetMesh->getCellContainingPoint(pos3,1e-12)); - targetMesh->decrRef(); - //3D - targetMesh=build3DTargetMesh_1(); - const double pos4[3]={25.,25.,25.}; - CPPUNIT_ASSERT_EQUAL(0,targetMesh->getCellContainingPoint(pos4,1e-12)); - const double pos5[3]={50.,50.,50.}; - t1.clear(); - targetMesh->getCellsContainingPoint(pos5,1e-12,t1); - CPPUNIT_ASSERT_EQUAL(8,(int)t1.size()); - const int expectedValues5[8]={0,1,2,3,4,5,6,7}; - CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues5)); - const double pos6[3]={0., 50., 0.}; - t1.clear(); - targetMesh->getCellsContainingPoint(pos6,1e-12,t1); - CPPUNIT_ASSERT_EQUAL(2,(int)t1.size()); - const int expectedValues6[2]={0,2}; - CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues6)); - //3D outside - const double pos7[3]={-1.0,-1.0,0.}; - CPPUNIT_ASSERT_EQUAL(-1,targetMesh->getCellContainingPoint(pos7,1e-12)); - //3D outside 2 - const double center2[3]={0.,0.,0.}; - const double vec2[3]={0.,-1.,0.}; - targetMesh->rotate(center2,vec2,0.78539816339744830962); - const double pos8[3]={-25,25.,12.}; - CPPUNIT_ASSERT_EQUAL(-1,targetMesh->getCellContainingPoint(pos8,1e-12)); - // - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testGetValueOn1() -{ - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS); - int nbOfCells=targetMesh->getNumberOfCells(); - fieldOnCells->setMesh(targetMesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(nbOfCells,2); - fieldOnCells->setArray(array); - double *tmp=array->getPointer(); - for(int i=0;idecrRef(); - // - const double pos1[2]={0.25,0.}; - double res[2]; - fieldOnCells->getValueOn(pos1,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(18.,res[1],1e-12); - // - fieldOnCells->decrRef(); - targetMesh->decrRef(); - // - targetMesh=build2DSourceMesh_1(); - MEDCouplingFieldDouble *fieldOnNodes=MEDCouplingFieldDouble::New(ON_NODES); - int nbOfNodes=targetMesh->getNumberOfNodes(); - fieldOnNodes->setMesh(targetMesh); - array=DataArrayDouble::New(); - array->alloc(nbOfNodes,2); - fieldOnNodes->setArray(array); - tmp=array->getPointer(); - for(int i=0;idecrRef(); - // - const double pos2[2]={-0.13333333333333333,-0.13333333333333333}; - fieldOnNodes->getValueOn(pos2,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(17.5,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(27.5,res[1],1e-12); - const double pos3[2]={0.033333333333333326,0.36666666666666664}; - fieldOnNodes->getValueOn(pos3,res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(18.666666666666667,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(28.666666666666667,res[1],1e-12); - // - fieldOnNodes->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testCMesh0() -{ - MEDCouplingCMesh* mesh=MEDCouplingCMesh::New(); - DataArrayDouble* coordsX=DataArrayDouble::New(); - double arrX[4] = { -1., 1., 2., 4. }; - coordsX->useArray(arrX,false, CPP_DEALLOC,4,1); - DataArrayDouble* coordsY=DataArrayDouble::New(); - double arrY[4] = { -2., 2., 4., 8. }; - coordsY->useArray(arrY,false, CPP_DEALLOC,4,1); - DataArrayDouble* coordsZ=DataArrayDouble::New(); - double arrZ[4] = { -3., 3., 6., 12. }; - coordsZ->useArray(arrZ,false, CPP_DEALLOC,4,1); - mesh->setCoords(coordsX,coordsY,coordsZ); - coordsX->decrRef(); - coordsY->decrRef(); - coordsZ->decrRef(); - // - MEDCouplingFieldDouble *fieldOnNodes=mesh->fillFromAnalytic(ON_NODES,1,"x+y/2.+z/3."); - CPPUNIT_ASSERT_EQUAL(1,fieldOnNodes->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(64,fieldOnNodes->getNumberOfTuples()); - const double expected1[64]={-3., -1., 0., 2., -1., 1., 2., 4., 0., 2., 3., 5., 2., 4., 5., 7., -1., 1., 2., - 4., 1., 3., 4., 6., 2., 4., 5., 7., 4., 6., 7., 9., 0., 2., 3., 5., 2., 4., 5., - 7., 3., 5., 6., 8., 5., 7., 8., 10., 2., 4., 5., - 7., 4., 6., 7., 9., 5., 7., 8., 10., 7., 9., 10., 12.}; - const double *val=fieldOnNodes->getArray()->getConstPointer(); - for(int i=0;i<64;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],val[i],1e-12); - double res; - fieldOnNodes->getValueOnPos(1,3,2,&res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,res,1e-12); - fieldOnNodes->decrRef(); - // - MEDCouplingFieldDouble *fieldOnCells=mesh->fillFromAnalytic(ON_CELLS,1,"x+y/2.+z/3."); - CPPUNIT_ASSERT_EQUAL(1,fieldOnCells->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(27,fieldOnCells->getNumberOfTuples()); - val=fieldOnCells->getArray()->getConstPointer(); - const double expected2[27]={0, 1.5, 3, 1.5, 3, 4.5, 3, 4.5, 6, 1.5, 3, 4.5, 3, 4.5, - 6, 4.5, 6, 7.5, 3, 4.5, 6, 4.5, 6, 7.5, 6, 7.5, 9}; - for(int i=0;i<27;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],val[i],1e-12); - fieldOnCells->getValueOnPos(1,2,1,&res); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.,res,1e-12); - fieldOnCells->decrRef(); - // - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testScale() -{ - MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - const double pos[2]={0.2,0.2}; - mesh->scale(pos,0.5); - const double expected1[18]={-0.05,-0.05, 0.2,-0.05, 0.45,-0.05, -0.05,0.2, 0.2,0.2, 0.45,0.2, - -0.05,0.45, 0.2,0.45, 0.45,0.45}; - const double *val=mesh->getCoords()->getConstPointer(); - for(int i=0;i<18;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],val[i],1e-12); - // - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testTryToShareSameCoords() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - MEDCouplingUMesh *m2=build2DTargetMesh_1(); - CPPUNIT_ASSERT(m1->getCoords()!=m2->getCoords()); - m1->tryToShareSameCoords(*m2,1e-12); - CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords()); - m1->tryToShareSameCoords(*m2,1e-12); - CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords()); - m2->tryToShareSameCoords(*m1,1e-12); - CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords()); - m1->decrRef(); - m2->decrRef(); - // - m1=build2DTargetMesh_1(); - m2=build2DTargetMesh_2(); - CPPUNIT_ASSERT(m1->getCoords()!=m2->getCoords()); - m1->tryToShareSameCoords(*m2,1e-12); - CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords()); - m1->tryToShareSameCoords(*m2,1e-12); - CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords()); - m2->tryToShareSameCoords(*m1,1e-12); - CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords()); - m1->decrRef(); - m2->decrRef(); - // - m1=build2DTargetMesh_1(); - m2=build2DSourceMesh_1(); - CPPUNIT_ASSERT(m1->getCoords()!=m2->getCoords()); - CPPUNIT_ASSERT_THROW(m1->tryToShareSameCoords(*m2,1e-12),INTERP_KERNEL::Exception); - m1->decrRef(); - m2->decrRef(); -} - -void MEDCouplingBasicsTest::testFindNodeOnPlane() -{ - MEDCouplingUMesh *mesh=build3DTargetMesh_1(); - std::vector n; - double pt[3]={300.,300.,0.}; - double v[3]={0.,0.,2.}; - mesh->findNodesOnPlane(pt,v,1e-12,n); - CPPUNIT_ASSERT_EQUAL(9,(int)n.size()); - MEDCouplingUMesh *m3dSurf=(MEDCouplingUMesh *)mesh->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); - MEDCouplingExtrudedMesh *me=MEDCouplingExtrudedMesh::New(mesh,m3dSurf,0); - const DataArrayInt *da=me->getMesh3DIds(); - CPPUNIT_ASSERT_EQUAL(8,me->getNumberOfCells()); - const int expected[8]={0,1,2,3,4,5,6,7}; - const int *val=da->getConstPointer(); - for(int i=0;i<8;i++) - CPPUNIT_ASSERT_EQUAL(expected[i],val[i]); - me->decrRef(); - m3dSurf->decrRef(); - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testRenumberCells() -{ - MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - MEDCouplingUMesh *m2=build3DSurfTargetMesh_1(); - CPPUNIT_ASSERT(m->isEqual(m2,0)); - const int arr[5]={12,3,25,2,26}; - m->renumberCells(arr,true); - CPPUNIT_ASSERT(!m->isEqual(m2,0)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,m->getTypeOfCell(0)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(1)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,m->getTypeOfCell(2)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(3)); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,m->getTypeOfCell(4)); - const int arr2[5]={5,-1,-5,4,8}; - m->renumberCells(arr2,true); - CPPUNIT_ASSERT(m->isEqual(m2,0)); - m->decrRef(); - m2->decrRef(); -} - -void MEDCouplingBasicsTest::testChangeSpaceDimension() -{ - MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); - MEDCouplingUMesh *m2=build2DTargetMesh_1(); - // - CPPUNIT_ASSERT_EQUAL(3,m1->getSpaceDimension()); - m1->changeSpaceDimension(2); - CPPUNIT_ASSERT_EQUAL(2,m1->getSpaceDimension()); - m1->setName(m2->getName()); - CPPUNIT_ASSERT(m1->isEqual(m2,1e-12)); - m1->changeSpaceDimension(3); - CPPUNIT_ASSERT_EQUAL(3,m1->getSpaceDimension()); - const double expected[27]={-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0.}; - const double *val=m1->getCoords()->getConstPointer(); - for(int i=0;i<27;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[i],val[i],1e-14); - // - m1->decrRef(); - m2->decrRef(); -} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx deleted file mode 100644 index f636313cf..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ /dev/null @@ -1,2004 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingBasicsTest.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingCMesh.hxx" -#include "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingGaussLocalization.hxx" - -#include -#include -#include - -using namespace ParaMEDMEM; - -void MEDCouplingBasicsTest::testGaussPointField1() -{ - const double _a=0.446948490915965; - const double _b=0.091576213509771; - const double _p1=0.11169079483905; - const double _p2=0.0549758718227661; - const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. }; - const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, - 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 }; - const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 }; - std::vector _refCoo1(refCoo1,refCoo1+6); - std::vector _gsCoo1(gsCoo1,gsCoo1+12); - std::vector _wg1(wg1,wg1+6); - // - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,NO_TIME); - f->setMesh(m); - CPPUNIT_ASSERT_EQUAL(0,f->getNbOfGaussLocalization()); - f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1); - CPPUNIT_ASSERT_THROW(f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo1,_gsCoo1,_wg1),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_EQUAL(1,f->getNbOfGaussLocalization()); - const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. }; - std::vector _refCoo2(refCoo2,refCoo2+8); - _gsCoo1.resize(4); _wg1.resize(2); - f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1); - CPPUNIT_ASSERT_EQUAL(2,f->getNbOfGaussLocalization()); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(18,2); - double *ptr=array->getPointer(); - for(int i=0;i<18*2;i++) - ptr[i]=(double)(i+1); - f->setArray(array); - f->setName("MyFirstFieldOnGaussPoint"); - array->decrRef(); - f->checkCoherency(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(27.,f->getIJK(2,5,0),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(16.,f->getIJK(1,5,1),1e-14); - // - f->clearGaussLocalizations(); - CPPUNIT_ASSERT_EQUAL(0,f->getNbOfGaussLocalization()); - CPPUNIT_ASSERT_THROW(f->checkCoherency(),INTERP_KERNEL::Exception); - int ids1[4]={0,1,3,4}; - CPPUNIT_ASSERT_THROW(f->setGaussLocalizationOnCells(ids1,ids1+4,_refCoo2,_gsCoo1,_wg1),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT_EQUAL(0,f->getNbOfGaussLocalization()); - int ids2[2]={0,4}; - f->setGaussLocalizationOnCells(ids2,ids2+2,_refCoo2,_gsCoo1,_wg1); - CPPUNIT_ASSERT_EQUAL(1,f->getNbOfGaussLocalization()); - CPPUNIT_ASSERT_EQUAL(0,f->getGaussLocalizationIdOfOneCell(0)); - CPPUNIT_ASSERT_THROW(f->getGaussLocalizationIdOfOneCell(1),INTERP_KERNEL::Exception); - int ids3[2]={1,2}; - f->setGaussLocalizationOnCells(ids3,ids3+2,_refCoo1,_gsCoo1,_wg1); - CPPUNIT_ASSERT_EQUAL(2,f->getNbOfGaussLocalization()); - CPPUNIT_ASSERT_EQUAL(0,f->getGaussLocalizationIdOfOneCell(0)); - CPPUNIT_ASSERT_EQUAL(1,f->getGaussLocalizationIdOfOneCell(1)); - CPPUNIT_ASSERT_EQUAL(1,f->getGaussLocalizationIdOfOneCell(2)); - CPPUNIT_ASSERT_THROW(f->checkCoherency(),INTERP_KERNEL::Exception);//<- cell 3 has no localization - int ids4[1]={3}; - std::vector _gsCoo2(_gsCoo1); - std::vector _wg2(_wg1); - _gsCoo2[0]=0.8888777776666; _wg2[0]=0.1234567892377; - f->setGaussLocalizationOnCells(ids4,ids4+1,_refCoo2,_gsCoo2,_wg2); - CPPUNIT_ASSERT_EQUAL(3,f->getNbOfGaussLocalization()); - std::vector tmpIds; - f->getCellIdsHavingGaussLocalization(0,tmpIds); - CPPUNIT_ASSERT_EQUAL(2,(int)tmpIds.size()); - CPPUNIT_ASSERT(std::equal(ids2,ids2+2,tmpIds.begin())); - CPPUNIT_ASSERT_THROW(f->checkCoherency(),INTERP_KERNEL::Exception);//<- it's always not ok because undelying array not with the good size. - DataArrayDouble *array2=f->getArray()->substr(0,10); - f->setArray(array2); - array2->decrRef(); - f->checkCoherency();//<- here it is OK - MEDCouplingFieldDouble *f2=f->clone(true); - CPPUNIT_ASSERT(f->isEqual(f2,1e-14,1e-14)); - MEDCouplingGaussLocalization& gl1=f2->getGaussLocalization(0); - double tmp=gl1.getGaussCoord(1,1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.07*_b-1,tmp,1e-14); - gl1.setGaussCoord(1,1,0.07); - CPPUNIT_ASSERT(!f->isEqual(f2,1e-14,1e-14)); - gl1.setGaussCoord(1,1,tmp); - CPPUNIT_ASSERT(f->isEqual(f2,1e-14,1e-14)); - f->decrRef(); - f2->checkCoherency(); - // - f2->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testGaussPointNEField1() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_NE,NO_TIME); - f->setMesh(m); - f->setName("MyFirstFieldOnNE"); - f->setDescription("MyDescriptionNE"); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(18,2); - double *ptr=array->getPointer(); - for(int i=0;i<18*2;i++) - ptr[i]=(double)(i+7); - f->setArray(array); - array->decrRef(); - // - f->checkCoherency(); - MEDCouplingFieldDouble *f2=f->clone(true); - CPPUNIT_ASSERT(f->isEqual(f2,1e-14,1e-14)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,f->getIJK(2,0,0),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(18.,f->getIJK(1,1,1),1e-14); - f2->decrRef(); - // - f->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testCellOrientation1() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - double vec[3]={0.,0.,1.}; - std::vector res1; - CPPUNIT_ASSERT_THROW(m->are2DCellsNotCorrectlyOriented(vec,false,res1),INTERP_KERNEL::Exception); - m->changeSpaceDimension(3); - res1.clear(); - m->are2DCellsNotCorrectlyOriented(vec,false,res1); - CPPUNIT_ASSERT(res1.empty()); - vec[2]=-1; - m->are2DCellsNotCorrectlyOriented(vec,false,res1); - CPPUNIT_ASSERT_EQUAL(5,(int)res1.size()); - res1.clear(); - // - vec[2]=1.; - // connectivity inversion - int *conn=m->getNodalConnectivity()->getPointer(); - int tmp=conn[11]; - conn[11]=conn[12]; - conn[12]=tmp; - m->are2DCellsNotCorrectlyOriented(vec,false,res1); - CPPUNIT_ASSERT_EQUAL(1,(int)res1.size()); - CPPUNIT_ASSERT_EQUAL(2,res1[0]); - res1.clear(); - m->orientCorrectly2DCells(vec,false); - m->are2DCellsNotCorrectlyOriented(vec,false,res1); - CPPUNIT_ASSERT(res1.empty()); - MEDCouplingUMesh *m2=build2DTargetMesh_1(); - m2->changeSpaceDimension(3); - CPPUNIT_ASSERT(m->isEqual(m2,1e-12)); - m2->decrRef(); - // - m->decrRef(); -} - -void MEDCouplingBasicsTest::testCellOrientation2() -{ - MEDCouplingUMesh *m1=0; - MEDCouplingUMesh *m2=build3DExtrudedUMesh_1(m1); - m1->decrRef(); - std::vector res1; - m2->arePolyhedronsNotCorrectlyOriented(res1); - CPPUNIT_ASSERT_EQUAL(6,(int)res1.size()); - m2->orientCorrectlyPolyhedrons(); - res1.clear(); - m2->arePolyhedronsNotCorrectlyOriented(res1); - CPPUNIT_ASSERT(res1.empty()); - m2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(18,m2->getNumberOfCells()); - int cellIds[3]={0,6,12}; - std::vector cellIds2(cellIds,cellIds+3); - m2->convertToPolyTypes(cellIds2); - m2->orientCorrectlyPolyhedrons(); - res1.clear(); - m2->arePolyhedronsNotCorrectlyOriented(res1); - CPPUNIT_ASSERT(res1.empty()); - MEDCouplingFieldDouble *f2=m2->getMeasureField(false); - //Test to check global reverse in MEDCouplingUMesh::tryToCorrectPolyhedronOrientation - MEDCouplingUMesh *m3=build2DTargetMesh_1(); - double vec[3]={0.,0.,-1.};//<- important for the test - m3->changeSpaceDimension(3); - const int ids1[5]={0,1,2,3,4}; - std::vector ids2(ids1,ids1+5); - m3->convertToPolyTypes(ids2); - m3->orientCorrectly2DCells(vec,false); - MEDCouplingUMesh *m4=buildCU1DMesh_U(); - m4->changeSpaceDimension(3); - double center[3]={0.,0.,0.}; - double vector[3]={0.,1.,0.}; - m4->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m5=m3->buildExtrudedMeshFromThis(m4,0); - res1.clear(); - m5->arePolyhedronsNotCorrectlyOriented(res1); - CPPUNIT_ASSERT_EQUAL(15,(int)res1.size()); - m5->orientCorrectlyPolyhedrons(); - res1.clear(); - m5->arePolyhedronsNotCorrectlyOriented(res1); - CPPUNIT_ASSERT(res1.empty()); - MEDCouplingFieldDouble *f3=m5->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(15,f3->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f3->getNumberOfComponents()); - const double *f3Ptr=f3->getArray()->getConstPointer(); - const double expected1[15]={ - 0.075,0.0375,0.0375,0.075,0.075, - 0.1125,0.05625,0.05625,0.1125,0.1125, - 0.0625,0.03125,0.03125,0.0625,0.0625 - }; - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::abs(expected1[i]),f3Ptr[i],1e-12); - f3->decrRef(); - DataArrayDouble *f4=m5->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(15,f4->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,f4->getNumberOfComponents()); - const double *f4Ptr=f4->getConstPointer(); - const double expected2[45]={ - -0.05,-0.05,0.15, 0.3666666666666667,-0.13333333333333333,0.15, 0.53333333333333333,0.033333333333333333,0.15, -0.05,0.45,0.15, 0.45,0.45,0.15, - -0.05,-0.05,0.525, 0.3666666666666667,-0.13333333333333333,0.525, 0.53333333333333333,0.033333333333333333,0.525, -0.05,0.45,0.525, 0.45,0.45,0.525, - -0.05,-0.05,0.875, 0.3666666666666667,-0.13333333333333333,0.875, 0.53333333333333333,0.033333333333333333,0.875, -0.05,0.45,0.875, 0.45,0.45,0.875 - }; - for(int i=0;i<45;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f4Ptr[i],1e-12); - f4->decrRef(); - m5->decrRef(); - m3->decrRef(); - m4->decrRef(); - // - f2->decrRef(); - m2->decrRef(); -} - -/*! - * This test check polyhedron true barycenter computation. - */ -void MEDCouplingBasicsTest::testPolyhedronBarycenter() -{ - int connN[]={0,3,2,1, -1, 4,5,6,7, -1, 0,4,7,3, -1, 3,7,6,2, -1, 2,6,5,1, -1, 1,5,4,0}; - double coords[]={0.,0.,0., 1.,0.,0., 1.,1.,0., 0.,1.,0., 0.,0.,1., 1.,0.,1., 1.,1.,1., 0.,1.,1., 0.5, 0.5, 0.5}; - MEDCouplingUMesh *meshN=MEDCouplingUMesh::New(); - meshN->setName("ForBary"); - meshN->setMeshDimension(3); - meshN->allocateCells(4); - meshN->insertNextCell(INTERP_KERNEL::NORM_POLYHED,29,connN); - meshN->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,3); - std::copy(coords,coords+27,myCoords->getPointer()); - meshN->setCoords(myCoords); - myCoords->decrRef(); - meshN->checkCoherency(); - // - std::vector res1; - meshN->arePolyhedronsNotCorrectlyOriented(res1); - meshN->orientCorrectlyPolyhedrons(); - CPPUNIT_ASSERT(res1.empty()); - const double *ref,*daPtr; - DataArrayDouble *da=meshN->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,da->getNumberOfComponents()); - daPtr=da->getConstPointer(); - ref=meshN->getCoords()->getConstPointer()+24; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref[i],daPtr[i],1e-12); - da->decrRef(); - // - const double center[]={0.,0.,0.}; - const double vec[]={0.,2.78,0.}; - da=meshN->getBarycenterAndOwner(); - daPtr=da->getConstPointer(); - ref=meshN->getCoords()->getConstPointer()+24; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref[i],daPtr[i],1e-12); - da->decrRef(); - // - meshN->rotate(center,vec,M_PI/7.); - meshN->translate(vec); - da=meshN->getBarycenterAndOwner(); - daPtr=da->getConstPointer(); - ref=meshN->getCoords()->getConstPointer()+24; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref[i],daPtr[i],1e-12); - da->decrRef(); - // - const double center2[]={1.12,3.45,6.78}; - const double vec2[]={4.5,9.3,2.8}; - meshN->rotate(center2,vec2,M_E); - meshN->translate(vec2); - da=meshN->getBarycenterAndOwner(); - daPtr=da->getConstPointer(); - ref=meshN->getCoords()->getConstPointer()+24; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref[i],daPtr[i],1e-10); - da->decrRef(); - // - meshN->decrRef(); -} - -void MEDCouplingBasicsTest::testNormL12Integ1D() -{ - MEDCouplingUMesh *m1=build1DTargetMesh_3(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(m1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(m1->getNumberOfCells(),3); - const double arr[12]={-5.23,15.45,-25.56,6.67,-16.78,26.89,-7.91,17.23,-27.43,8.21,-18.63,28.72}; - std::copy(arr,arr+12,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - const double *ptr; - DataArrayDouble *f3=m1->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(4,f3->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f3->getNumberOfComponents()); - double expected9[4]={0.75,5.105,0.8,5.155}; - ptr=f3->getConstPointer(); - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected9[i],ptr[i],1e-12); - f3->decrRef(); - // - MEDCouplingFieldDouble *f2=m1->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(4,f2->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - double expected1[4]={0.5,0.21,-0.6,-0.31}; - ptr=f2->getArray()->getConstPointer(); - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],ptr[i],1e-12); - f2->decrRef(); - double expected2[4]={0.5,0.21,0.6,0.31}; - f2=m1->getMeasureField(true); - ptr=f2->getArray()->getConstPointer(); - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],ptr[i],1e-12); - f2->decrRef(); - //integral - double res[3]; - f1->integral(false,res); - double expected3[3]={0.9866,-0.3615,0.4217}; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],res[i],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[0],f1->integral(0,false),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[1],f1->integral(1,false),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[2],f1->integral(2,false),1e-12); - f1->integral(true,res); - double expected4[3]={-3.4152,8.7639,-14.6879}; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected4[i],res[i],1e-12); - //normL1 - f1->normL1(res); - double expected5[3]={11.3068,27.3621,43.7881}; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],res[i],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[0],f1->normL1(0),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[1],f1->normL1(1),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[2],f1->normL1(2),1e-12); - //normL2 - f1->normL2(res); - double expected7[3]={9.0252562290496776, 21.545259176904789, 34.433193070059595}; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[i],res[i],1e-9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[0],f1->normL2(0),1e-9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[1],f1->normL2(1),1e-9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[2],f1->normL2(2),1e-9); - //buildMeasureField - MEDCouplingFieldDouble *f4=f1->buildMeasureField(false); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.2,f4->accumulate(0),1e-12); - f4->decrRef(); - f4=f1->buildMeasureField(true); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.62,f4->accumulate(0),1e-12); - f4->decrRef(); - // - f1->decrRef(); - m1->decrRef(); - // Testing with 2D Curve - m1=build2DCurveTargetMesh_3(); - f2=m1->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(4,f2->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - ptr=f2->getArray()->getConstPointer(); - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2.)*expected2[i],ptr[i],1e-12); - f2->decrRef(); - f2=m1->getMeasureField(true); - CPPUNIT_ASSERT_EQUAL(4,f2->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - ptr=f2->getArray()->getConstPointer(); - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i]*sqrt(2.),ptr[i],1e-12); - f2->decrRef(); - //bary - f3=m1->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(4,f3->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f3->getNumberOfComponents()); - double expected10[8]={0.75,0.75,5.105,5.105,0.8,0.8,5.155,5.155}; - ptr=f3->getConstPointer(); - for(int i=0;i<8;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected10[i],ptr[i],1e-12); - f3->decrRef(); - // - f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(m1); - array=DataArrayDouble::New(); - array->alloc(m1->getNumberOfCells(),3); - std::copy(arr,arr+12,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->integral(false,res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2.)*expected4[i],res[i],1e-12); - f1->integral(true,res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2.)*expected4[i],res[i],1e-12); - f1->normL1(res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2.)*expected5[i],res[i],1e-12); - f1->normL2(res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(sqrt(2.))*expected7[i],res[i],1e-12); - // - f1->decrRef(); - m1->decrRef(); -} - -void MEDCouplingBasicsTest::testAreaBary2D() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_3(); - MEDCouplingFieldDouble *f1=m1->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(10,f1->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - double expected1[10]={-0.5,-1,-1.5,-0.5,-1, 0.5,1,1.5,0.5,1}; - const double *ptr=f1->getArray()->getConstPointer(); - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],ptr[i],1e-12); - f1->decrRef(); - f1=m1->getMeasureField(true); - ptr=f1->getArray()->getConstPointer(); - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::abs(expected1[i]),ptr[i],1e-12); - f1->decrRef(); - DataArrayDouble *f2=m1->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(10,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); - double expected2[20]={ - 0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5, - 0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5, - }; - ptr=f2->getConstPointer(); - for(int i=0;i<20;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],ptr[i],1e-12); - f2->decrRef(); - m1->changeSpaceDimension(3); - f1=m1->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(10,f1->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - ptr=f1->getArray()->getConstPointer(); - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::abs(expected1[i]),ptr[i],1e-12); - f1->decrRef(); - f2=m1->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(10,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,f2->getNumberOfComponents()); - ptr=f2->getConstPointer(); - double expected3[30]={ - 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0., - 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0. - }; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],ptr[i],1e-12); - f2->decrRef(); - m1->decrRef(); -} - -/*! - * This test check polyhedron true barycenter computation 2. - */ -void MEDCouplingBasicsTest::testAreaBary3D() -{ - double coords [] = { 0.241310763507 , 0.0504777305619 , 0.0682283524903 , 0.252501053866 , -0.0625176732937 , 0.137272639894 , - 0.152262663601 , 0.241816569527 , 0.133812556197 , 0.18047750211 , -0.0789949051358 , 0.339098173401 , - 0.151741971857 , 0.238885278571 , 0.137715037333 , 0.242532155481 , -0.0928169086456 , 0.0678043417367 , - 0.240941965335 , -0.015461491464 , 0.0617186345825 , 0.24127650112 , 0.0499427876717 , 0.0679634099148 , - -0.145828917428 , 0.206291632565 , 0.0310071927543 , 0.0125651775307 , 0.266262085828 , 0.105228430543 , - -0.0994066533286 , 0.233224271238 , 0.0572213839567 , -0.0951345338317 , 0.234819509426 , 0.0592126284538 , - 0.136580574205 , -0.205486212579 , 0.0572866072014 , 0.0637270784978 , -0.168886355238 , 0.446614057077 , - 0.041337157151 , -0.213402568198 , 0.372407095999 , 0.0411601970268 , -0.202387875756 , 0.411334979491 , - -0.108355701857 , 0.193636239335 , 0.204886756738 , 0.00639779029829 , 0.155296981517 , 0.252585892979 , - 0.0262473111702 , -0.112919732543 , 0.424286639249 ,-0.224103052733 , -0.139430015438 , -0.0122352295701 , - -0.0312760589481 , -0.274272003594 , 0.0323959636568 , -0.166663422532 , -0.217754445175 , 0.00392109070364 , - -0.30586619777 , -0.0475168041091 , -0.0144585228182 , -0.280881480586 , 0.135571293538 , 0.00623923647986 , - -0.25548538234 , 0.156819217766 , 0.0645277879769 , -0.131567009284 , 0.184133752309 , 0.206021802753 , - -0.196204010965 , 0.151602971681 , 0.212974777736 , -0.183713879463 , 0.0802946639531 , 0.260115662599 , - -0.244241178767 , -0.0738873389604 , 0.144590565817 , -0.155804057829 , -0.164892720025 , 0.210613950558 , - -0.170950800428 , -0.215099334026 , 0.00610122860092 , -0.30552634869 , -0.0490020791904 , -0.0132786533145 , - 0.271831011884 , 0.15105657296 , 0.0230534827908 , 0.281919192283 , 0.0898544306288 , -0.0625201489143 , - 0.260240727276 , -0.0120688706637 , -0.0532316588626 , 0.244947737722 , 0.0197984684293 , 0.0309341209233 , - 0.23439631578 , 0.229825279875 , 0.0508520585381 , 0.160921316875 , 0.265078502128 , 0.121716560626 , - -0.315088694175 , 0.0747700471918 , -0.245836615071 , -0.327728781776 , 0.0857114674649 , -0.239431905957 , - -0.308385460634 , 0.145142997084 , -0.149886828433 , 0.0488236045164 , 0.309462801914 , 0.0849169148265 , - -0.0244964803395 , 0.33145611751 , -0.0476415818061 , 0.0060567994229 , 0.32418412014 , 0.0367779543812 , - -0.0950221448063 , 0.236675326003 , 0.0572594453983 , 0.248723023186 , 0.0886648784791 , -0.176629430538 , - 0.116796984 , 0.256596599567 , -0.292863523603 , 0.118024552914 , 0.229154257843 , -0.34233232501 , - 0.217507892549 , -0.0417822335742 , -0.176771782888 , -0.224429321304 , 0.0125595300114 , -0.362064725588 , - 0.0937301100955 , -0.0500824832657 , -0.299713548444 , -0.244162220397 , 0.0383853931293 , -0.389856984411 , - -0.0281989366102 , 0.097392811563 , -0.458244577284 , -0.385010847162 , 0.10122766194 , -0.140052859922 , - -0.377936358012 , 0.110875172128 , -0.176207095463 , 0.244483045556 , -0.0991073977045 , 0.0575134372934 , - 0.262605120167 , -0.100243191645 , -0.0495620806935 , 0.240306880972 , -0.136153701579 , -0.114745281696 , - 0.215763176129 , -0.0836766059189 , -0.183249640616 , 0.237870396603 , -0.132449578286 , -0.121598854639 , - -0.0637683083097 , -0.27921020214 , -0.149112321992 , -0.0856211014977 , -0.2973233473 , -0.0446878139589 , - 0.104675342288 , -0.0625908305324 , -0.290346256534 , 0.0248264249186 , -0.247797708548 , -0.165830884019 , - 0.0719302438309 , -0.178468260473 , -0.211432157345 , 0.142871843159 , -0.208769948542 , 0.0454101128246 , - 0.167803379307 , -0.207851396623 , -0.088802726124 , 0.12868717152 , -0.230920439715 , 0.00760508389036 , - -0.0372812069535 , -0.286740286332 , 0.00963701291166 }; - - int connN [] = { /*polyhedron 0*/ - 0 , 1 , 3 , 4 , 2 , -1 , 1 , 5 , 6 , 7 , 0 , -1 , 0 , 7 , 8 , 10 , 11 , 9 , 2 , -1 , 1 , 5 , 12 , 14 , 15 , 13 , 3 , -1 , 16 , 9 , 2 , 4 , 17 , -1 - , 4 , 3 , 13 , 18 , 17 , -1 , 5 , 6 , 19 , 21 , 20 , 12 , -1 , 6 , 7 , 8 , 23 , 22 , 19 , -1 , 23 , 24 , 10 , 8 , -1 , 25 , 11 , 9 , 16 , -1 - , 24 , 26 , 25 , 11 , 10 , -1 , 12 , 14 , 20 , -1 , 27 , 28 , 29 , 15 , 13 , 18 , -1 , 14 , 15 , 29 , 30 , 21 , 20 , -1 , 26 , 27 , 18 , 17 , 16 , 25 , -1 - , 22 , 19 , 21 , 30 , 31 , -1 , 22 , 31 , 28 , 27 , 26 , 24 , 23 , -1 , 31 , 30 , 29 , 28, - /* polyhedron 1*/ - 0 , 7 , 8 , 10 , 11 , 9 , 2 , -1 , 32 , 0 , 7 , 35 , 34 , 33 , -1 , 32 , 0 , 2 , 37 , 36 , -1 , 35 , 7 , 8 , 40 , 39 , 38 , -1 - , 2 , 37 , 41 , 9 , -1 , 40 , 8 , 10 , 44 , 43 , 42 , -1 , 41 , 9 , 11 , 44 , 43 , -1 , 44 , 11 , 10 , -1 , 32 , 33 , 45 , 47 , 46 , 36 , -1 - , 33 , 34 , 48 , 45 , -1 , 35 , 34 , 48 , 50 , 49 , 38 , -1 , 41 , 43 , 42 , 46 , 36 , 37 , -1 , 38 , 39 , 51 , 49 , -1 - , 39 , 40 , 42 , 46 , 47 , 52 , 51 , -1 , 45 , 47 , 52 , 50 , 48 , -1 , 52 , 51 , 49 , 50, - /* polyhedron 2*/ - 6 , 7 , 8 , 23 , 22 , 19 , -1 , 6 , 35 , 7 , -1 , 6 , 35 , 38 , 19 , -1 , 35 , 7 , 8 , 40 , 39 , 38 , -1 , 53 , 22 , 19 , 38 , 39 , 54 , -1 - , 23 , 53 , 54 , 40 , 8 , -1 , 53 , 22 , 23 , -1 , 39 , 54 , 40, - /*polyhedron 3*/ - 35 , 34 , 48 , 50 , 49 , 38 , -1 , 6 , 35 , 34 , 56 , 55 , 5 , -1 , 6 , 35 , 38 , 19 , -1 , 34 , 56 , 57 , 59 , 58 , 48 , -1 - , 60 , 61 , 21 , 19 , 38 , 49 , -1 , 62 , 50 , 48 , 58 , -1 , 60 , 63 , 64 , 62 , 50 , 49 , -1 , 5 , 6 , 19 , 21 , 20 , 12 , -1 - , 55 , 5 , 12 , 65 , -1 , 66 , 67 , 65 , 55 , 56 , 57 , -1 , 63 , 66 , 57 , 59 , 64 , -1 , 64 , 62 , 58 , 59 , -1 - , 60 , 63 , 66 , 67 , 68 , 61 , -1 , 61 , 68 , 20 , 21 , -1 , 67 , 68 , 20 , 12 , 65}; - - double barys[]={ -0.0165220465527 , -0.0190922868195 , 0.158882733414 , - 0.0287618656076 , 0.135874379934 , -0.14601588119 , - -0.147128055553 , 0.0465995097041 , -0.049391174453 , - -0.00142506732317 , -0.0996953090351 , -0.115159183132 }; - MEDCouplingUMesh *meshN=MEDCouplingUMesh::New(); - meshN->setName("ForBary"); - meshN->setMeshDimension(3); - meshN->allocateCells(4); - meshN->insertNextCell(INTERP_KERNEL::NORM_POLYHED,113,connN); - meshN->insertNextCell(INTERP_KERNEL::NORM_POLYHED,99,connN+113); - meshN->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,connN+212); - meshN->insertNextCell(INTERP_KERNEL::NORM_POLYHED,92,connN+255); - meshN->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(69,3); - std::copy(coords,coords+207,myCoords->getPointer()); - meshN->setCoords(myCoords); - myCoords->decrRef(); - meshN->checkCoherency(); - std::vector res1; - meshN->arePolyhedronsNotCorrectlyOriented(res1); - meshN->orientCorrectlyPolyhedrons(); - res1.clear(); - meshN->arePolyhedronsNotCorrectlyOriented(res1); - CPPUNIT_ASSERT(res1.empty()); - // - DataArrayDouble *da=meshN->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(4,da->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,da->getNumberOfComponents()); - const double *daPtr=da->getConstPointer(); - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(barys[i],daPtr[i],1e-12); - da->decrRef(); - // - meshN->decrRef(); -} - -void MEDCouplingBasicsTest::testRenumberCellsForFields() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f->setMesh(m); - DataArrayDouble *arr=DataArrayDouble::New(); - int nbOfCells=m->getNumberOfCells(); - arr->alloc(nbOfCells,3); - f->setArray(arr); - arr->decrRef(); - const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.}; - std::copy(values1,values1+15,arr->getPointer()); - const int renumber1[5]={3,1,0,4,2}; - double res[3]; - const double loc[]={-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45}; - for(int j=0;j<5;j++) - { - f->getValueOn(loc+2*j,res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[i+3*j],res[i],1e-12); - } - f->renumberCells(renumber1,false); - const double *ptr=f->getArray()->getConstPointer(); - const double expected1[15]={9.,109.,10009.,8.,108.,10008.,11.,111.,10011.,7.,107.,10007.,10.,110.,10010.}; - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],ptr[i],1e-12); - //check that fields remains the same geometrically - for(int j=0;j<5;j++) - { - f->getValueOn(loc+2*j,res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[i+3*j],res[i],1e-12); - } - f->decrRef(); - //On gauss - f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,NO_TIME); - f->setMesh(m); - const double _a=0.446948490915965; - const double _b=0.091576213509771; - const double _p1=0.11169079483905; - const double _p2=0.0549758718227661; - const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. }; - const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, - 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 }; - const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 }; - std::vector _refCoo1(refCoo1,refCoo1+6); - std::vector _gsCoo1(gsCoo1,gsCoo1+12); - std::vector _wg1(wg1,wg1+6); - f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1); - const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. }; - std::vector _refCoo2(refCoo2,refCoo2+8); - _gsCoo1.resize(4); _wg1.resize(2); - f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1); - arr=DataArrayDouble::New(); - arr->alloc(18,2); - const double values2[36]={1.,1001.,2.,1002., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 31.,1031.,32.,1032., 41.,1041.,42.,1042.}; - std::copy(values2,values2+36,arr->getPointer()); - f->setArray(arr); - arr->decrRef(); - f->checkCoherency(); - MEDCouplingFieldDouble *fCpy=f->clone(true); - CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); - f->renumberCells(renumber1,false); - CPPUNIT_ASSERT(!f->isEqual(fCpy,1e-12,1e-12)); - double expected2[36]={21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 41.,1041.,42.,1042., 1.,1001.,2.,1002., 31.,1031.,32.,1032.}; - ptr=f->getArray()->getConstPointer(); - for(int i=0;i<36;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],ptr[i],1e-12); - const int renumber2[5]={2,1,4,0,3};//reverse renumber1 - f->renumberCells(renumber2,false); - CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); - fCpy->decrRef(); - f->decrRef(); - //GaussNE - f=MEDCouplingFieldDouble::New(ON_GAUSS_NE,NO_TIME); - f->setMesh(m); - arr=DataArrayDouble::New(); - arr->alloc(18,2); - const double values3[36]={1.,1001.,2.,1002.,3.,1003.,4.,1004., 11.,1011.,12.,1012.,13.,1013., 21.,1021.,22.,1022.,23.,1023., 31.,1031.,32.,1032.,33.,1033.,34.,1034., 41.,1041.,42.,1042.,43.,1043.,44.,1044.}; - std::copy(values3,values3+36,arr->getPointer()); - f->setArray(arr); - arr->decrRef(); - f->checkCoherency(); - fCpy=f->clone(true); - CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); - f->renumberCells(renumber1,false); - CPPUNIT_ASSERT(!f->isEqual(fCpy,1e-12,1e-12)); - double expected3[36]={21.,1021.,22.,1022.,23.,1023.,11.,1011.,12.,1012.,13.,1013.,41.,1041.,42.,1042.,43.,1043.,44.,1044.,1.,1001.,2.,1002.,3.,1003.,4.,1004.,31.,1031.,32.,1032.,33.,1033.,34.,1034.}; - ptr=f->getArray()->getConstPointer(); - for(int i=0;i<36;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],ptr[i],1e-12); - f->renumberCells(renumber2,false);//perform reverse operation of renumbering to check that the resulting field is equal. - CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); - fCpy->decrRef(); - f->decrRef(); - // - m->decrRef(); -} - -void MEDCouplingBasicsTest::testRenumberNodesForFields() -{ - MEDCouplingUMesh *m=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); - f->setMesh(m); - DataArrayDouble *arr=DataArrayDouble::New(); - int nbOfNodes=m->getNumberOfNodes(); - arr->alloc(nbOfNodes,3); - f->setArray(arr); - arr->decrRef(); - const double values1[27]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.}; - std::copy(values1,values1+27,arr->getPointer()); - f->checkCoherency(); - const int renumber1[9]={0,4,1,3,5,2,6,7,8}; - double res[3]; - const double loc[]={0.5432,-0.2432, 0.5478,0.1528}; - const double expected1[6]={9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124}; - for(int j=0;j<2;j++) - { - f->getValueOn(loc+2*j,res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i+3*j],res[i],1e-12); - } - MEDCouplingFieldDouble *fCpy=f->clone(true); - CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); - f->renumberNodes(renumber1); - CPPUNIT_ASSERT(!f->isEqual(fCpy,1e-12,1e-12)); - for(int j=0;j<2;j++) - { - f->getValueOn(loc+2*j,res); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i+3*j],res[i],1e-12); - } - const double expected2[27]={7.,107.,10007.,9.,109.,10009.,12.,112.,10012.,10.,110.,10010.,8.,108.,10008.,11.,111.,10011.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.}; - for(int i=0;i<27;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getArray()->getConstPointer()[i],1e-12); - const int renumber2[9]={0,2,5,3,1,4,6,7,8};//reverse of renumber2 - f->renumberNodes(renumber2); - CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); - fCpy->decrRef(); - // - m->decrRef(); - f->decrRef(); -} - -void MEDCouplingBasicsTest::testConvertQuadraticCellsToLinear() -{ - MEDCouplingUMesh *mesh=build2DTargetMesh_3(); - mesh->checkCoherency(); - const std::set& types=mesh->getAllTypes(); - CPPUNIT_ASSERT_EQUAL(5,(int)types.size()); - INTERP_KERNEL::NormalizedCellType expected1[5]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_QUAD8}; - std::set expected1Bis(expected1,expected1+5); - CPPUNIT_ASSERT(expected1Bis==types); - CPPUNIT_ASSERT(mesh->isPresenceOfQuadratic()); - CPPUNIT_ASSERT_EQUAL(62,mesh->getMeshLength()); - MEDCouplingFieldDouble *f1=mesh->getMeasureField(false); - // - mesh->convertQuadraticCellsToLinear(); - CPPUNIT_ASSERT(!mesh->isPresenceOfQuadratic()); - // - mesh->checkCoherency(); - MEDCouplingFieldDouble *f2=mesh->getMeasureField(false); - CPPUNIT_ASSERT(f1->getArray()->isEqual(*f2->getArray(),1e-12)); - CPPUNIT_ASSERT_EQUAL(48,mesh->getMeshLength()); - const std::set& types2=mesh->getAllTypes(); - CPPUNIT_ASSERT_EQUAL(3,(int)types.size()); - INTERP_KERNEL::NormalizedCellType expected2[3]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4}; - std::set expected2Bis(expected2,expected2+3); - CPPUNIT_ASSERT(expected2Bis==types2); - // - f1->decrRef(); - f2->decrRef(); - mesh->decrRef(); -} - -void MEDCouplingBasicsTest::testCheckGeoEquivalWith() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_3(); - MEDCouplingUMesh *mesh2=build2DTargetMesh_3(); - DataArrayInt *cellCor,*nodeCor; - //First test mesh1 - mesh1->checkGeoEquivalWith(mesh1,0,1e-12,cellCor,nodeCor);//deepEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh1,1,1e-12,cellCor,nodeCor);//fastEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh1,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - //Second test mesh1 and mesh2 are 2 different meshes instance - mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor);//deepEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - //Third test : cell permutation by keeping the first the middle and the last as it is. - const int renum[]={0,2,1,3,4,5,6,8,7,9}; - mesh2->renumberCells(renum,false); - CPPUNIT_ASSERT_THROW(mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor),INTERP_KERNEL::Exception);//deepEqual fails - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual do not see anything - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations - CPPUNIT_ASSERT(cellCor); - CPPUNIT_ASSERT_EQUAL(10,cellCor->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,cellCor->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(renum,renum+10,cellCor->getConstPointer())); - CPPUNIT_ASSERT(nodeCor==0); - cellCor->decrRef(); - cellCor=0; - CPPUNIT_ASSERT(nodeCor==0); - //4th test : cell and node permutation by keeping the first the middle and the last as it is. - mesh2->decrRef(); - mesh2=build2DTargetMesh_3(); - const int renum2[]={0,2,1,3,4,5,6,8,7,9,10}; - mesh2->renumberCells(renum,false); - mesh2->renumberNodes(renum2,11); - CPPUNIT_ASSERT_THROW(mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor),INTERP_KERNEL::Exception);//deepEqual fails - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual do not see anything - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations - CPPUNIT_ASSERT(cellCor); - CPPUNIT_ASSERT_EQUAL(10,cellCor->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,cellCor->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(renum,renum+10,cellCor->getConstPointer())); - CPPUNIT_ASSERT(nodeCor); - CPPUNIT_ASSERT_EQUAL(11,nodeCor->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,nodeCor->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(renum2,renum2+11,nodeCor->getConstPointer())); - cellCor->decrRef(); - cellCor=0; - nodeCor->decrRef(); - nodeCor=0; - //5th test : modification of the last cell to check fastCheck detection. - mesh2->decrRef(); - mesh2=build2DTargetMesh_3(); - const int renum3[]={0,2,1,3,4,5,6,8,9,7}; - mesh2->renumberCells(renum3,false); - mesh2->renumberNodes(renum2,11); - bool isExcep=false; - try { mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor);//deepEqual fails - } - catch(INTERP_KERNEL::Exception& e) { isExcep=true; } - CPPUNIT_ASSERT(isExcep); isExcep=false; - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - try { mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual has detected something - } - catch(INTERP_KERNEL::Exception& e) { isExcep=true; } - CPPUNIT_ASSERT(isExcep); isExcep=false; - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); - mesh2->checkGeoEquivalWith(mesh1,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations - CPPUNIT_ASSERT(cellCor); - CPPUNIT_ASSERT_EQUAL(10,cellCor->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,cellCor->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(renum3,renum3+10,cellCor->getConstPointer())); - CPPUNIT_ASSERT(nodeCor); - CPPUNIT_ASSERT_EQUAL(11,nodeCor->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,nodeCor->getNumberOfComponents()); - CPPUNIT_ASSERT(std::equal(renum2,renum2+11,nodeCor->getConstPointer())); - cellCor->decrRef(); - cellCor=0; - nodeCor->decrRef(); - nodeCor=0; - // - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDCouplingBasicsTest::testCheckGeoEquivalWith2() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_4(); - MEDCouplingUMesh *mesh2=build2DTargetMesh_1(); - DataArrayInt *cellCor,*nodeCor; - mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor); - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor!=0); - const int expected1[9]={0, 1, 3, 4, 5, 6, 7, 8, 9}; - for(int i=0;i<9;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],nodeCor->getIJ(i,0)); - nodeCor->decrRef(); - // - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDCouplingBasicsTest::testCopyTinyStringsFromOnFields() -{ - MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); - f->setMesh(m); - f->setName("a"); - f->setDescription("b"); - DataArrayDouble *a1=DataArrayDouble::New(); - a1->alloc(nbOfCells,2); - a1->fillWithZero(); - a1->setInfoOnComponent(0,"c"); - a1->setInfoOnComponent(1,"d"); - DataArrayDouble *a2=a1->deepCopy(); - a2->setInfoOnComponent(0,"e"); - a2->setInfoOnComponent(1,"f"); - f->setArray(a1); - f->setEndArray(a2); - f->setEndTime(3.,3,4); - a2->decrRef(); - a1->decrRef(); - m->setName("g"); - m->getCoords()->setInfoOnComponent(0,"h"); - m->getCoords()->setInfoOnComponent(1,"i"); - m->getCoords()->setInfoOnComponent(2,"j"); - // - f->checkCoherency(); - MEDCouplingFieldDouble *f2=f->clone(true); - CPPUNIT_ASSERT(f2->isEqual(f,1e-12,1e-12)); - f2->setName("smth"); - CPPUNIT_ASSERT(!f2->isEqual(f,1e-12,1e-12)); - f2->copyTinyStringsFrom(f); - CPPUNIT_ASSERT(f2->isEqual(f,1e-12,1e-12)); - f2->setDescription("GGG"); - CPPUNIT_ASSERT(!f2->isEqual(f,1e-12,1e-12)); - f2->copyTinyStringsFrom(f); - CPPUNIT_ASSERT(f2->isEqual(f,1e-12,1e-12)); - f2->getArray()->setInfoOnComponent(0,"mmmm"); - CPPUNIT_ASSERT(!f2->isEqual(f,1e-12,1e-12)); - f2->copyTinyStringsFrom(f); - CPPUNIT_ASSERT(f2->isEqual(f,1e-12,1e-12)); - f2->getEndArray()->setInfoOnComponent(1,"mmmm"); - CPPUNIT_ASSERT(!f2->isEqual(f,1e-12,1e-12)); - f2->copyTinyStringsFrom(f); - CPPUNIT_ASSERT(f2->isEqual(f,1e-12,1e-12)); - f2->decrRef(); - MEDCouplingUMesh *m2=m->clone(true); - CPPUNIT_ASSERT(m2->isEqual(m,1e-12)); - m2->setName("123"); - CPPUNIT_ASSERT(!m2->isEqual(m,1e-12)); - m2->copyTinyStringsFrom(m); - CPPUNIT_ASSERT(m2->isEqual(m,1e-12)); - m2->getCoords()->setInfoOnComponent(1,"eee"); - CPPUNIT_ASSERT(!m2->isEqual(m,1e-12)); - m2->copyTinyStringsFrom(m); - CPPUNIT_ASSERT(m2->isEqual(m,1e-12)); - m2->decrRef(); - // - f->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testTryToShareSameCoordsPermute() -{ - MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - MEDCouplingUMesh *m2=build3DSurfTargetMesh_1(); - CPPUNIT_ASSERT(m->getCoords()!=m2->getCoords()); - m->tryToShareSameCoordsPermute(*m2,1e-12); - CPPUNIT_ASSERT(m->getCoords()==m2->getCoords()); - CPPUNIT_ASSERT(m2->isEqual(m,1e-12)); - const int renum1[9]={1,2,0,5,8,7,4,3,6}; - m->renumberNodes(renum1,9); - CPPUNIT_ASSERT(m->getCoords()!=m2->getCoords()); - CPPUNIT_ASSERT(!m2->isEqual(m,1e-12)); - m->tryToShareSameCoordsPermute(*m2,1e-12); - CPPUNIT_ASSERT(m->getCoords()==m2->getCoords()); - CPPUNIT_ASSERT(m2->isEqual(m,1e-12)); - m2->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testTryToShareSameCoordsPermute2() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_4(); - double targetCoords[8]={-0.3,-0.3, 0.2,-0.3, -0.3,0.2, 0.2,0.2 }; - int targetConn[4]={0,2,3,1}; - MEDCouplingUMesh *m2=MEDCouplingUMesh::New(); - m2->setMeshDimension(2); - m2->allocateCells(1); - m2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - m2->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); - m2->setCoords(myCoords); - myCoords->decrRef(); - m2->checkCoherency(); - m1->checkCoherency(); - // - const double expected1[5]={0.25,0.125,0.125,0.25,0.25}; - MEDCouplingFieldDouble *f1=m1->getMeasureField(false); - MEDCouplingFieldDouble *f2=m2->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(5,f1->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f2->getArray()->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(i,0),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[0],f2->getIJ(0,0),1e-12); - f2->decrRef(); - f1->decrRef(); - CPPUNIT_ASSERT_THROW(m1->tryToShareSameCoordsPermute(*m2,1e-12),INTERP_KERNEL::Exception);// <- here in this order the sharing is impossible. - // Let's go for deeper test of tryToShareSameCoordsPermute - m2->tryToShareSameCoordsPermute(*m1,1e-12); - f1=m1->getMeasureField(false); - f2=m2->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(5,f1->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f2->getArray()->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(i,0),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[0],f2->getIJ(0,0),1e-12); - // - f2->decrRef(); - f1->decrRef(); - // - m1->decrRef(); - m2->decrRef(); -} - -void MEDCouplingBasicsTest::testChangeUnderlyingMesh1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_3(); - MEDCouplingUMesh *mesh2=build2DTargetMesh_3(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),2); - const double arr[20]={7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.}; - std::copy(arr,arr+20,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - const int renum[]={0,2,1,3,4,5,6,8,7,9}; - mesh2->renumberCells(renum,false); - CPPUNIT_ASSERT(f1->getMesh()==mesh1); - f1->changeUnderlyingMesh(mesh1,10,1e-12);// nothing done only to check that nothing done. - CPPUNIT_ASSERT(f1->getMesh()==mesh1); - f1->changeUnderlyingMesh(mesh2,10,1e-12); - CPPUNIT_ASSERT(f1->getMesh()==mesh2); - const double expected1[20]={7.,107.,9.,109.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.}; - for(int i=0;i<20;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12); - f1->decrRef(); - // - f1=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); - f1->setMesh(mesh1); - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfNodes(),2); - const double arr2[22]={7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.,17.,117.}; - std::copy(arr2,arr2+22,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - const int renum2[]={0,2,10,3,4,5,6,8,7,9,1}; - mesh2->renumberNodes(renum2,11); - CPPUNIT_ASSERT(f1->getMesh()==mesh1); - f1->changeUnderlyingMesh(mesh2,10,1e-12); - CPPUNIT_ASSERT(f1->getMesh()==mesh2); - const double expected2[22]={7.,107.,9.,109.,17.,117.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,8.,108.}; - for(int i=0;i<22;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f1->getArray()->getIJ(0,i),1e-12); - f1->decrRef(); - // - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDCouplingBasicsTest::testGetMaxValue1() -{ - MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); - f->setMesh(m); - DataArrayDouble *a1=DataArrayDouble::New(); - a1->alloc(nbOfCells,1); - const double val1[5]={3.,4.,5.,6.,7.}; - std::copy(val1,val1+5,a1->getPointer()); - DataArrayDouble *a2=DataArrayDouble::New(); - a2->alloc(nbOfCells,1); - const double val2[5]={0.,1.,2.,8.,7.}; - std::copy(val2,val2+5,a2->getPointer()); - f->setArray(a1); - f->setEndArray(a2); - f->setEndTime(3.,3,4); - f->checkCoherency(); - // - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,f->getMaxValue(),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,f->getMinValue(),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,f->getAverageValue(),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.125,f->getWeightedAverageValue(),1e-14); - a1->setIJ(0,2,9.5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.5,f->getMaxValue(),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,f->getMinValue(),1e-14); - a2->setIJ(0,0,9.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.5,f->getMaxValue(),1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,f->getMinValue(),1e-14); - // - a2->decrRef(); - a1->decrRef(); - m->decrRef(); - f->decrRef(); -} - -void MEDCouplingBasicsTest::testSubstractInPlaceDM1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_3(); - MEDCouplingUMesh *mesh2=build2DTargetMesh_3(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),2); - const double arr[20]={7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.}; - std::copy(arr,arr+20,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - CPPUNIT_ASSERT_EQUAL(10,f1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(20,f1->getNumberOfValues()); - // - const int renum[]={0,2,1,3,4,5,6,8,7,9}; - mesh2->renumberCells(renum,false); - // - MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f2->setMesh(mesh2); - array=DataArrayDouble::New(); - array->alloc(mesh2->getNumberOfCells(),2); - const double arr2[20]={7.1,107.1,9.1,109.1,8.1,108.1,10.1,110.1,11.1,111.1,12.1,112.1,13.1,113.1,15.1,115.1,14.1,114.1,16.1,116.1}; - std::copy(arr2,arr2+20,array->getPointer()); - f2->setArray(array); - array->decrRef(); - // - f1->substractInPlaceDM(f2,10,1e-12); - f1->applyFunc(1,"abs(x+y+0.2)"); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,f1->getMaxValue(),1e-14); - // - f1->decrRef(); - f2->decrRef(); - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDCouplingBasicsTest::testDotCrossProduct1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_3(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setTime(2.3,5,6); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),3); - const double arr1[30]={7.,107.,207.,8.,108.,208.,9.,109.,209.,10.,110.,210.,11.,111.,211.,12.,112.,212.,13.,113.,213.,14.,114.,214.,15.,115.,215.,16.,116.,216.}; - std::copy(arr1,arr1+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f2->setTime(7.8,4,5); - f2->setMesh(mesh1); - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),3); - const double arr2[30]={1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.,26.,27.,28.,29.,30.}; - std::copy(arr2,arr2+30,array->getPointer()); - f2->setArray(array); - array->decrRef(); - // - MEDCouplingFieldDouble *f3=f1->dot(*f2); - const double expected1[10]={842.,1820.,2816.,3830.,4862.,5912.,6980.,8066.,9170.,10292.}; - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(i,0),1e-9); - f3->decrRef(); - // - MEDCouplingFieldDouble *f4=f1->crossProduct(*f2); - const double expected2[30]={-93., 186., -93., -392., 784., -392., -691., 1382., -691., -990., 1980., -990., -1289., 2578., -1289., -1588., 3176., -1588., -1887., 3774., -1887., -2186., 4372., -2186., -2485., 4970., -2485., -2784., 5568., -2784.}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f4->getIJ(0,i),1e-9); - f4->decrRef(); - // - f2->decrRef(); - f1->decrRef(); - mesh1->decrRef(); -} - -void MEDCouplingBasicsTest::testMinMaxFields1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_3(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setTime(2.3,5,6); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),3); - const double arr1[30]={7.,107.,207.,8.,108.,208.,9.,109.,209.,10.,110.,210.,11.,111.,211.,12.,112.,212.,13.,113.,213.,14.,114.,214.,15.,115.,215.,16.,116.,216.}; - std::copy(arr1,arr1+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f2->setTime(7.8,4,5); - f2->setMesh(mesh1); - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),3); - const double arr2[30]={6.,108.,206.,9.,107.,209.,8.,110.,208.,11.,109.,211.,10.,112.,210.,13.,111.,213.,12.,114.,212.,15.,113.,215.,14.,116.,214.,17.,115.,217.}; - std::copy(arr2,arr2+30,array->getPointer()); - f2->setArray(array); - array->decrRef(); - // - MEDCouplingFieldDouble *f3=f1->max(*f2); - const double expected1[30]={7.,108.,207.,9.,108.,209.,9.,110.,209.,11.,110.,211.,11.,112.,211.,13.,112.,213.,13.,114.,213.,15.,114.,215.,15.,116.,215.,17.,116.,217.}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(0,i),1e-9); - f3->decrRef(); - // - MEDCouplingFieldDouble *f4=f1->min(*f2); - const double expected2[30]={6.,107.,206.,8.,107.,208.,8.,109.,208.,10.,109.,210.,10.,111.,210.,12.,111.,212.,12.,113.,212.,14.,113.,214.,14.,115.,214.,16.,115.,216.}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f4->getIJ(0,i),1e-9); - f4->decrRef(); - // - f2->decrRef(); - f1->decrRef(); - mesh1->decrRef(); -} - -void MEDCouplingBasicsTest::testApplyLin1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_3(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),2); - const double arr[20]={7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.}; - std::copy(arr,arr+20,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - f1->applyLin(2.,3.,0); - const double expected1[20]={17.,107.,19.,108.,21.,109.,23.,110.,25.,111.,27.,112.,29.,113.,31.,114.,33.,115.,35.,116.}; - for(int i=0;i<20;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-9); - // - const double arr2[20]={2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.}; - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),2); - std::copy(arr2,arr2+20,array->getPointer()); - f1->setEndArray(array); - array->decrRef(); - // - f1->applyLin(4.,5.,1); - // - const double expected2[20]={17.,433.,19.,437.,21.,441.,23.,445.,25.,449.,27.,453.,29.,457.,31.,461.,33.,465.,35.,469.}; - for(int i=0;i<20;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f1->getIJ(0,i),1e-9); - const double expected3[20]={2.,413.,3.,417.,4.,421.,5.,425.,6.,429.,7.,433.,8.,437.,9.,441.,10.,445.,11.,449.}; - for(int i=0;i<20;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f1->getEndArray()->getIJ(0,i),1e-9); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testGetIdsInRange1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_3(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setTime(2.3,5,6); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),1); - const double arr1[10]={2.,8.,6.,5.,11.,7.,9.,3.,10.,4.}; - std::copy(arr1,arr1+10,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - f1->checkCoherency(); - DataArrayInt *da=f1->getIdsInRange(2.9,7.1); - CPPUNIT_ASSERT_EQUAL(5,da->getNbOfElems()); - const int expected1[5]={2,3,5,7,9}; - CPPUNIT_ASSERT(std::equal(expected1,expected1+5,da->getConstPointer())); - da->decrRef(); - da=f1->getIdsInRange(8.,12.); - CPPUNIT_ASSERT_EQUAL(4,da->getNbOfElems()); - const int expected2[4]={1,4,6,8}; - CPPUNIT_ASSERT(std::equal(expected2,expected2+4,da->getConstPointer())); - da->decrRef(); - // - f1->decrRef(); - mesh1->decrRef(); -} - -void MEDCouplingBasicsTest::testBuildSubPart1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setTime(2.3,5,6); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),2); - const double arr1[10]={3.,103.,4.,104.,5.,105.,6.,106.,7.,107.}; - std::copy(arr1,arr1+10,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - const int part1[3]={2,1,4}; - MEDCouplingFieldDouble *f2=f1->buildSubPart(part1,part1+3); - CPPUNIT_ASSERT_EQUAL(3,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); - const double expected1[6]={5.,105.,4.,104.,7.,107.}; - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(f2->getIJ(0,i),expected1[i],1e-12); - CPPUNIT_ASSERT_EQUAL(3,f2->getMesh()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(6,f2->getMesh()->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getMeshDimension()); - MEDCouplingUMesh *m2C=dynamic_cast(const_cast(f2->getMesh())); - CPPUNIT_ASSERT_EQUAL(13,m2C->getMeshLength()); - const double expected2[12]={0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7}; - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],m2C->getCoords()->getIJ(0,i),1.e-12); - const double expected3[13]={3,2,3,1,3,0,2,1,4,4,5,3,2}; - CPPUNIT_ASSERT(std::equal(expected3,expected3+13,m2C->getNodalConnectivity()->getConstPointer())); - const double expected4[4]={0,4,8,13}; - CPPUNIT_ASSERT(std::equal(expected4,expected4+4,m2C->getNodalConnectivityIndex()->getConstPointer())); - f2->decrRef(); - f1->decrRef(); - // Test with field on nodes. - f1=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); - f1->setTime(2.3,5,6); - f1->setMesh(mesh1); - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfNodes(),2); - const double arr2[18]={3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.}; - std::copy(arr2,arr2+18,array->getPointer()); - f1->setArray(array); - array->decrRef(); - const int part2[4]={1,4,2,5}; - f2=f1->buildSubPart(part2,part2+4); - CPPUNIT_ASSERT_EQUAL(4,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); - const double expected5[8]={4.,104.,5.,105.,7.,107.,8.,108.}; - for(int i=0;i<8;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(f2->getIJ(0,i),expected5[i],1e-12); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(4,f2->getMesh()->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getMeshDimension()); - m2C=dynamic_cast(const_cast(f2->getMesh())); - CPPUNIT_ASSERT_EQUAL(8,m2C->getMeshLength()); - for(int i=0;i<8;i++)//8 is not an error - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],m2C->getCoords()->getIJ(0,i),1.e-12); - CPPUNIT_ASSERT(std::equal(expected3,expected3+4,m2C->getNodalConnectivity()->getConstPointer()+4)); - CPPUNIT_ASSERT(std::equal(expected3+4,expected3+8,m2C->getNodalConnectivity()->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected4,expected4+3,m2C->getNodalConnectivityIndex()->getConstPointer())); - f2->decrRef(); - //idem previous because nodes of cell#4 are not fully present in part3 - const int part3[5]={1,4,2,5,7}; - DataArrayInt *arrr=DataArrayInt::New(); - arrr->alloc(5,1); - std::copy(part3,part3+5,arrr->getPointer()); - f2=f1->buildSubPart(arrr); - arrr->decrRef(); - CPPUNIT_ASSERT_EQUAL(4,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); - for(int i=0;i<8;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(f2->getIJ(0,i),expected5[i],1e-12); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(4,f2->getMesh()->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getMeshDimension()); - m2C=dynamic_cast(const_cast(f2->getMesh())); - CPPUNIT_ASSERT_EQUAL(8,m2C->getMeshLength()); - for(int i=0;i<8;i++)//8 is not an error - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],m2C->getCoords()->getIJ(0,i),1.e-12); - CPPUNIT_ASSERT(std::equal(expected3,expected3+4,m2C->getNodalConnectivity()->getConstPointer()+4)); - CPPUNIT_ASSERT(std::equal(expected3+4,expected3+8,m2C->getNodalConnectivity()->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected4,expected4+3,m2C->getNodalConnectivityIndex()->getConstPointer())); - f2->decrRef(); - // - const int part4[6]={1,4,2,5,7,8}; - f2=f1->buildSubPart(part4,part4+6); - CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); - const double expected6[12]={4.,104.,5.,105.,7.,107.,8.,108.,10.,110.,11.,111.}; - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(f2->getIJ(0,i),expected6[i],1e-12); - CPPUNIT_ASSERT_EQUAL(3,f2->getMesh()->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(6,f2->getMesh()->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getMeshDimension()); - m2C=dynamic_cast(const_cast(f2->getMesh())); - CPPUNIT_ASSERT_EQUAL(13,m2C->getMeshLength()); - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],m2C->getCoords()->getIJ(0,i),1.e-12); - CPPUNIT_ASSERT(std::equal(expected3,expected3+4,m2C->getNodalConnectivity()->getConstPointer()+4)); - CPPUNIT_ASSERT(std::equal(expected3+4,expected3+8,m2C->getNodalConnectivity()->getConstPointer())); - CPPUNIT_ASSERT(std::equal(expected3+8,expected3+13,m2C->getNodalConnectivity()->getConstPointer()+8)); - CPPUNIT_ASSERT(std::equal(expected4,expected4+4,m2C->getNodalConnectivityIndex()->getConstPointer())); - f2->decrRef(); - // - f1->decrRef(); - mesh1->decrRef(); -} - -void MEDCouplingBasicsTest::testDoublyContractedProduct1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),6); - const double arr1[30]={7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5}; - std::copy(arr1,arr1+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->doublyContractedProduct(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(3906.56,f2->getIJ(i,0),1e-9); - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testDeterminant1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL); - f1->setTime(2.3,5,6); - f1->setEndTime(3.8,7,3); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),4); - const double arr1[20]={1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5}; - std::copy(arr1,arr1+20,array->getPointer()); - f1->setArray(array); - array->decrRef(); - //4 components - f1->checkCoherency(); - MEDCouplingFieldDouble *f2=f1->determinant(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(CONST_ON_TIME_INTERVAL,f2->getTimeDiscretization()); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfValues()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(-2.42,f2->getIJ(i,0),1e-13); - f2->decrRef(); - f1->decrRef(); - //6 components multi arrays with end array not defined - f1=MEDCouplingFieldDouble::New(ON_NODES,LINEAR_TIME); - f1->setTime(2.3,5,6); - f1->setEndTime(3.8,7,3); - f1->setMesh(mesh1); - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfNodes(),6); - const double arr2[54]={1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, - 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7}; - std::copy(arr2,arr2+54,array->getPointer()); - f1->setArray(array); - array->decrRef(); - CPPUNIT_ASSERT_THROW(f1->checkCoherency(),INTERP_KERNEL::Exception);//no end array specified ! - // - f2=f1->determinant(); - CPPUNIT_ASSERT_EQUAL(LINEAR_TIME,f2->getTimeDiscretization()); - CPPUNIT_ASSERT_EQUAL(1,f2->getArray()->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples()); - for(int i=0;i<9;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(137.335,f2->getIJ(i,0),1e-10); - f2->decrRef(); - //6 components multi arrays with end array defined - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfNodes(),6); - const double arr3[54]={7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, - 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5}; - std::copy(arr3,arr3+54,array->getPointer()); - f1->setEndArray(array); - array->decrRef(); - f1->checkCoherency(); - f2=f1->determinant(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(LINEAR_TIME,f2->getTimeDiscretization()); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples()); - int it,order; - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(it,order),1e-12); - CPPUNIT_ASSERT_EQUAL(5,it); CPPUNIT_ASSERT_EQUAL(6,order); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.8,f2->getEndTime(it,order),1e-12); - CPPUNIT_ASSERT_EQUAL(7,it); CPPUNIT_ASSERT_EQUAL(3,order); - for(int i=0;i<9;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(137.335,f2->getIJ(i,0),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1289.685,f2->getEndArray()->getIJ(i,0),1e-9); - } - f2->decrRef(); - f1->decrRef(); - //9 components - f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setTime(7.8,10,2); - f1->setMesh(mesh1); - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),9); - const double arr4[45]={1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1}; - std::copy(arr4,arr4+45,array->getPointer()); - f1->setArray(array); - array->decrRef(); - // - f1->checkCoherency(); - f2=f1->determinant(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(ONE_TIME,f2->getTimeDiscretization()); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8,f2->getTime(it,order),1e-12); - CPPUNIT_ASSERT_EQUAL(10,it); CPPUNIT_ASSERT_EQUAL(2,order); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.267,f2->getIJ(i,0),1e-13); - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testEigenValues1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),6); - const double arr1[30]={1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7}; - std::copy(arr1,arr1+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->eigenValues(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - const double expected1[3]={13.638813677891717,-4.502313844635971,-2.2364998332557486}; - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[0],f2->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[1],f2->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[2],f2->getIJ(i,2),1e-13); - } - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testEigenVectors1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),6); - const double arr1[30]={1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7}; - std::copy(arr1,arr1+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->eigenVectors(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - const double expected1[9]={ - 0.5424262364180696, 0.5351201064614425, 0.6476266283176001,//eigenvect 0 - 0.7381111277307373, 0.06458838384003074, -0.6715804522117897,//eigenvect 1 - -0.4012053603397987, 0.8423032781211455, -0.3599436712889738//eigenvect 2 - }; - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[0],f2->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[1],f2->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[2],f2->getIJ(i,2),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[3],f2->getIJ(i,3),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[4],f2->getIJ(i,4),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[5],f2->getIJ(i,5),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[6],f2->getIJ(i,6),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[7],f2->getIJ(i,7),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[8],f2->getIJ(i,8),1e-13); - } - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testInverse1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),9); - const double arr1[45]={1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1}; - std::copy(arr1,arr1+45,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->inverse(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - const double expected1[9]={-2.6538108356290113, 2.855831037649208, -1.1111111111111067, 3.461891643709813, -4.775022956841121, 2.2222222222222143, -1.1111111111111054, 2.222222222222214, -1.1111111111111072}; - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[0],f2->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[1],f2->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[2],f2->getIJ(i,2),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[3],f2->getIJ(i,3),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[4],f2->getIJ(i,4),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[5],f2->getIJ(i,5),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[6],f2->getIJ(i,6),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[7],f2->getIJ(i,7),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[8],f2->getIJ(i,8),1e-13); - } - f2->decrRef(); - // - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),6); - const double arr3[30]={7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5}; - std::copy(arr3,arr3+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - f2=f1->inverse(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - const double expected3[6]={-0.3617705098531818, -0.8678630828458127, -0.026843764174972983, 0.5539957431465833, 0.13133439560823013, -0.05301294502145887}; - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[0],f2->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[1],f2->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[2],f2->getIJ(i,2),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[3],f2->getIJ(i,3),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[4],f2->getIJ(i,4),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[5],f2->getIJ(i,5),1e-13); - } - f2->decrRef(); - // - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),4); - const double arr2[20]={1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5}; - std::copy(arr2,arr2+20,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - f2=f1->inverse(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(4,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - const double expected2[4]={-1.8595041322314059, 0.9504132231404963, 1.404958677685951, -0.49586776859504156}; - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[0],f2->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[1],f2->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[2],f2->getIJ(i,2),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[3],f2->getIJ(i,3),1e-13); - } - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testTrace1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),9); - const double arr1[45]={1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1}; - std::copy(arr1,arr1+45,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->trace(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.9,f2->getIJ(i,0),1e-13); - f2->decrRef(); - // - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),6); - const double arr3[30]={7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5}; - std::copy(arr3,arr3+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - f2=f1->trace(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(25.8,f2->getIJ(i,0),1e-13); - f2->decrRef(); - // - array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),4); - const double arr2[20]={1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5}; - std::copy(arr2,arr2+20,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - f2=f1->trace(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7,f2->getIJ(i,0),1e-13); - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testDeviator1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),6); - const double arr1[30]={1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7}; - std::copy(arr1,arr1+30,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->deviator(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - const double expected1[6]={-1.1,0.,1.1,4.5,5.6,6.7}; - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[0],f2->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[1],f2->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[2],f2->getIJ(i,2),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[3],f2->getIJ(i,3),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[4],f2->getIJ(i,4),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[5],f2->getIJ(i,5),1e-13); - } - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testMagnitude1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),5); - const double arr1[25]={1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6}; - std::copy(arr1,arr1+25,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->magnitude(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.3606219864313918,f2->getIJ(i,0),1e-13); - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testMaxPerTuple1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),5); - const double arr1[25]={1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4}; - std::copy(arr1,arr1+25,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=f1->maxPerTuple(); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(1,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.6,f2->getIJ(i,0),1e-13); - f2->decrRef(); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testChangeNbOfComponents() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),5); - const double arr1[25]={1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4}; - std::copy(arr1,arr1+25,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - f1->changeNbOfComponents(3,7.77); - f1->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - const double expected1[15]={1.2,2.3,3.4, 1.2,3.4,4.5, 3.4,4.5,5.6, 5.6,1.2,2.3, 4.5,5.6,1.2}; - for(int i=0;i<15;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-13); - f1->changeNbOfComponents(4,7.77); - f1->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(4,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - const double expected2[20]={1.2,2.3,3.4,7.77, 1.2,3.4,4.5,7.77, 3.4,4.5,5.6,7.77, 5.6,1.2,2.3,7.77, 4.5,5.6,1.2,7.77}; - for(int i=0;i<20;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f1->getIJ(0,i),1e-13); - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testSortPerTuple1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - f1->setMesh(mesh1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mesh1->getNumberOfCells(),5); - const double arr1[25]={1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4}; - std::copy(arr1,arr1+25,array->getPointer()); - f1->setArray(array); - array->decrRef(); - f1->checkCoherency(); - // - f1->sortPerTuple(true); - f1->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[0],f1->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[1],f1->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[2],f1->getIJ(i,2),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[3],f1->getIJ(i,3),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[4],f1->getIJ(i,4),1e-13); - } - // - f1->sortPerTuple(false); - f1->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - for(int i=0;i<5;i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[4],f1->getIJ(i,0),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[3],f1->getIJ(i,1),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[2],f1->getIJ(i,2),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[1],f1->getIJ(i,3),1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(arr1[0],f1->getIJ(i,4),1e-13); - } - // - mesh1->decrRef(); - f1->decrRef(); -} - -void MEDCouplingBasicsTest::testIsEqualWithoutConsideringStr1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - MEDCouplingUMesh *mesh2=build2DTargetMesh_1(); - DataArrayInt *da1,*da2; - // - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2->setName("rr"); - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh1->checkDeepEquivalWith(mesh2,2,1e-12,da1,da2); - CPPUNIT_ASSERT_THROW(mesh1->checkGeoEquivalWith(mesh2,0,1e-12,da1,da2),INTERP_KERNEL::Exception); - mesh2->setName(""); - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2->getCoords()->setInfoOnComponent(0,"tty"); - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2->getCoords()->setInfoOnComponent(0,""); - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2->getCoords()->setInfoOnComponent(1,"tty"); - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2->getCoords()->setInfoOnComponent(1,""); - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - double tmp=mesh2->getCoords()->getIJ(0,3); - mesh2->getCoords()->setIJ(0,3,9999.); - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(!mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2->getCoords()->setIJ(0,3,tmp); - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - int tmp2=mesh2->getNodalConnectivity()->getIJ(0,4); - mesh2->getNodalConnectivity()->setIJ(0,4,0); - CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(!mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2->getNodalConnectivity()->setIJ(0,4,tmp2); - CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); - CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - // - MEDCouplingFieldDouble *f1=mesh1->getMeasureField(true); - MEDCouplingFieldDouble *f2=mesh2->getMeasureField(true); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - CPPUNIT_ASSERT(f1->isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f2->setName("ftest"); - CPPUNIT_ASSERT(!f1->isEqual(f2,1e-12,1e-12)); - CPPUNIT_ASSERT(f1->isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f1->setName("ftest"); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - CPPUNIT_ASSERT(f1->isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - // - f2->getArray()->setInfoOnComponent(0,"eee"); - CPPUNIT_ASSERT(!f1->isEqual(f2,1e-12,1e-12)); - CPPUNIT_ASSERT(f1->isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f2->getArray()->setInfoOnComponent(0,""); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - CPPUNIT_ASSERT(f1->isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - // - f2->getArray()->setIJ(1,0,0.123); - CPPUNIT_ASSERT(!f1->isEqual(f2,1e-12,1e-12)); - CPPUNIT_ASSERT(!f1->isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f2->getArray()->setIJ(1,0,0.125); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - CPPUNIT_ASSERT(f1->isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - // - f1->decrRef(); - f2->decrRef(); - // - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDCouplingBasicsTest::testGetNodeIdsOfCell1() -{ - MEDCouplingUMesh *mesh1=build2DTargetMesh_1(); - std::vector nodeIds; - mesh1->getNodeIdsOfCell(1,nodeIds); - CPPUNIT_ASSERT_EQUAL(3,(int)nodeIds.size()); - CPPUNIT_ASSERT_EQUAL(1,nodeIds[0]); - CPPUNIT_ASSERT_EQUAL(4,nodeIds[1]); - CPPUNIT_ASSERT_EQUAL(2,nodeIds[2]); - std::vector coords; - mesh1->getCoordinatesOfNode(4,coords); - CPPUNIT_ASSERT_EQUAL(2,(int)coords.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.2,coords[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.2,coords[1],1e-13); - mesh1->decrRef(); -} - -void MEDCouplingBasicsTest::testGetEdgeRatioField1() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - MEDCouplingFieldDouble *f1=m1->getEdgeRatioField(); - CPPUNIT_ASSERT_EQUAL(m1->getNumberOfCells(),f1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - const double expected1[5]={1.,1.4142135623730951, 1.4142135623730951,1.,1.}; - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(i,0),1e-14); - f1->decrRef(); - m1->decrRef(); - // - m1=build3DSurfTargetMesh_1(); - f1=m1->getEdgeRatioField(); - CPPUNIT_ASSERT_EQUAL(m1->getNumberOfCells(),f1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); - const double expected2[5]={1.4142135623730951, 1.7320508075688772, 1.7320508075688772, 1.4142135623730951, 1.4142135623730951}; - for(int i=0;i<5;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f1->getIJ(i,0),1e-14); - f1->decrRef(); - m1->decrRef(); -} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx deleted file mode 100644 index 2f9cc17cf..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx +++ /dev/null @@ -1,1166 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - -int connITT[201]={0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1029, 1058, 1087, 1116, 1145, 1174, 1203, - 1232, 1261, 1290, 1319, 1348, 1377, 1406, 1435, 1464, 1493, 1522, 1551, 1580, 1609, 1638, 1667, 1696, 1725, 1754, 1783, 1812, 1841, 1870, 1899, - 1928, 1957, 1986, 2015, 2044, 2073, 2102, 2131, 2160, 2189, 2218, 2247, 2276, 2305, 2334, 2363, 2392, 2421, 2450, 2479, 2508, 2537, 2566, 2595, - 2624, 2653, 2682, 2711, 2740, 2769, 2798, 2827, 2856, 2885, 2914, 2943, 2972, 3001, 3030, 3059, 3088, 3117, 3146, 3175, 3204, 3233, 3262, 3291, - 3320, 3349, 3378, 3407, 3436, 3465, 3494, 3523, 3552, 3581, 3610, 3639, 3668, 3697, 3726, 3755, 3784, 3813, 3842, 3871, 3900, 3929, 3958, 3987, - 4016, 4045, 4074, 4103, 4132, 4161, 4190, 4219, 4248, 4277, 4306, 4335, 4364, 4393, 4422, 4451, 4480, 4509, 4538, 4567, 4596, 4625, 4654, 4683, - 4712, 4741, 4770, 4799, 4828, 4857, 4886, 4915, 4944, 4973, 5002, 5031, 5060, 5089, 5118, 5147, 5176, 5205, 5234, 5263, 5292, 5321, 5350, 5379, - 5408, 5437, 5466, 5495, 5524, 5553, 5582, 5611, 5640, 5669, 5698, 5727, 5756, 5785, 5814, 5843, 5872, 5901, 5930, 5959, 5988, 6017, 6046, 6075, - 6104, 6133, 6162, 6191, 6220}; - int connTT[6220]={0, 1, 2, 3, 4, 5, 6, -1, 0, 7, 8, 1, -1, 1, 8, 9, 2, -1, 2, 9, 10, 3, -1, 3, 10, 11, 4, -1, 4, 11, 12, 5, -1, 5, 12, 13, 6, -1, 6, 13, 7, 0, -1, 7, 13, 12, 11, 10, 9, 8, 14, 15, 16, 17, 18, 19, - 20, -1, 14, 21, 22, 15, -1, 15, 22, 23, 16, -1, 16, 23, 24, 17, -1, 17, 24, 25, 18, -1, 18, 25, 26, 19, -1, 19, 26, 27, 20, -1, 20, 27, 21, 14, -1, 21, 27, 26, 25, 24, 23, 22, 28, 29, 30, 31, 32, - 33, 34, -1, 28, 35, 36, 29, -1, 29, 36, 37, 30, -1, 30, 37, 38, 31, -1, 31, 38, 39, 32, -1, 32, 39, 40, 33, -1, 33, 40, 41, 34, -1, 34, 41, 35, 28, -1, 35, 41, 40, 39, 38, 37, 36, 42, 43, 44, 45, - 46, 47, 48, -1, 42, 49, 50, 43, -1, 43, 50, 51, 44, -1, 44, 51, 52, 45, -1, 45, 52, 53, 46, -1, 46, 53, 54, 47, -1, 47, 54, 55, 48, -1, 48, 55, 49, 42, -1, 49, 55, 54, 53, 52, 51, 50, 56, 57, 58, - 59, 60, 61, 62, -1, 56, 63, 64, 57, -1, 57, 64, 65, 58, -1, 58, 65, 66, 59, -1, 59, 66, 67, 60, -1, 60, 67, 68, 61, -1, 61, 68, 69, 62, -1, 62, 69, 63, 56, -1, 63, 69, 68, 67, 66, 65, 64, 70, 71, - 72, 73, 74, 75, 76, -1, 70, 77, 78, 71, -1, 71, 78, 79, 72, -1, 72, 79, 80, 73, -1, 73, 80, 81, 74, -1, 74, 81, 82, 75, -1, 75, 82, 83, 76, -1, 76, 83, 77, 70, -1, 77, 83, 82, 81, 80, 79, 78, 84, - 85, 86, 87, 88, 89, 90, -1, 84, 91, 92, 85, -1, 85, 92, 93, 86, -1, 86, 93, 94, 87, -1, 87, 94, 95, 88, -1, 88, 95, 96, 89, -1, 89, 96, 97, 90, -1, 90, 97, 91, 84, -1, 91, 97, 96, 95, 94, 93, 92, - 98, 99, 100, 101, 102, 103, 104, -1, 98, 105, 106, 99, -1, 99, 106, 107, 100, -1, 100, 107, 108, 101, -1, 101, 108, 109, 102, -1, 102, 109, 110, 103, -1, 103, 110, 111, 104, -1, 104, 111, 105, 98, - -1, 105, 111, 110, 109, 108, 107, 106, 112, 113, 114, 115, 116, 117, 118, -1, 112, 119, 120, 113, -1, 113, 120, 121, 114, -1, 114, 121, 122, 115, -1, 115, 122, 123, 116, -1, 116, 123, 124, 117, -1, - 117, 124, 125, 118, -1, 118, 125, 119, 112, -1, 119, 125, 124, 123, 122, 121, 120, 126, 127, 128, 129, 130, 131, 132, -1, 126, 133, 134, 127, -1, 127, 134, 135, 128, -1, 128, 135, 136, 129, -1, 129, - 136, 137, 130, -1, 130, 137, 138, 131, -1, 131, 138, 139, 132, -1, 132, 139, 133, 126, -1, 133, 139, 138, 137, 136, 135, 134, 140, 141, 142, 143, 144, 145, 146, -1, 140, 147, 148, 141, -1, 141, 148, - 149, 142, -1, 142, 149, 150, 143, -1, 143, 150, 151, 144, -1, 144, 151, 152, 145, -1, 145, 152, 153, 146, -1, 146, 153, 147, 140, -1, 147, 153, 152, 151, 150, 149, 148, 154, 155, 156, 157, 158, 159, - 160, -1, 154, 161, 162, 155, -1, 155, 162, 163, 156, -1, 156, 163, 164, 157, -1, 157, 164, 165, 158, -1, 158, 165, 166, 159, -1, 159, 166, 167, 160, -1, 160, 167, 161, 154, -1, 161, 167, 166, 165, - 164, 163, 162, 168, 169, 170, 171, 172, 173, 174, -1, 168, 175, 176, 169, -1, 169, 176, 177, 170, -1, 170, 177, 178, 171, -1, 171, 178, 179, 172, -1, 172, 179, 180, 173, -1, 173, 180, 181, 174, -1, - 174, 181, 175, 168, -1, 175, 181, 180, 179, 178, 177, 176, 182, 183, 184, 185, 186, 187, 188, -1, 182, 189, 190, 183, -1, 183, 190, 191, 184, -1, 184, 191, 192, 185, -1, 185, 192, 193, 186, -1, 186, - 193, 194, 187, -1, 187, 194, 195, 188, -1, 188, 195, 189, 182, -1, 189, 195, 194, 193, 192, 191, 190, 196, 197, 198, 199, 200, 201, 202, -1, 196, 203, 204, 197, -1, 197, 204, 205, 198, -1, 198, 205, - 206, 199, -1, 199, 206, 207, 200, -1, 200, 207, 208, 201, -1, 201, 208, 209, 202, -1, 202, 209, 203, 196, -1, 203, 209, 208, 207, 206, 205, 204, 210, 211, 212, 213, 214, 215, 216, -1, 210, 217, 218, - 211, -1, 211, 218, 219, 212, -1, 212, 219, 220, 213, -1, 213, 220, 221, 214, -1, 214, 221, 222, 215, -1, 215, 222, 223, 216, -1, 216, 223, 217, 210, -1, 217, 223, 222, 221, 220, 219, 218, 224, 225, - 226, 227, 228, 229, 230, -1, 224, 231, 232, 225, -1, 225, 232, 233, 226, -1, 226, 233, 234, 227, -1, 227, 234, 235, 228, -1, 228, 235, 236, 229, -1, 229, 236, 237, 230, -1, 230, 237, 231, 224, -1, - 231, 237, 236, 235, 234, 233, 232, 238, 239, 240, 241, 242, 243, 244, -1, 238, 245, 246, 239, -1, 239, 246, 247, 240, -1, 240, 247, 248, 241, -1, 241, 248, 249, 242, -1, 242, 249, 250, 243, -1, 243, - 250, 251, 244, -1, 244, 251, 245, 238, -1, 245, 251, 250, 249, 248, 247, 246, 252, 253, 254, 255, 256, 257, 258, -1, 252, 259, 260, 253, -1, 253, 260, 261, 254, -1, 254, 261, 262, 255, -1, 255, 262, - 263, 256, -1, 256, 263, 264, 257, -1, 257, 264, 265, 258, -1, 258, 265, 259, 252, -1, 259, 265, 264, 263, 262, 261, 260, 266, 267, 268, 269, 270, 271, 272, -1, 266, 273, 274, 267, -1, 267, 274, 275, - 268, -1, 268, 275, 276, 269, -1, 269, 276, 277, 270, -1, 270, 277, 278, 271, -1, 271, 278, 279, 272, -1, 272, 279, 273, 266, -1, 273, 279, 278, 277, 276, 275, 274, 280, 281, 282, 283, -1, 280, 284, - 285, 281, -1, 281, 285, 286, 282, -1, 282, 286, 287, 283, -1, 283, 287, 284, 280, -1, 284, 287, 286, 285, 288, 289, 290, 291, -1, 288, 292, 293, 289, -1, 289, 293, 294, 290, -1, 290, 294, 295, 291, - -1, 291, 295, 292, 288, -1, 292, 295, 294, 293, 296, 297, 298, 299, -1, 296, 300, 301, 297, -1, 297, 301, 302, 298, -1, 298, 302, 303, 299, -1, 299, 303, 300, 296, -1, 300, 303, 302, 301, 304, 305, - 306, 307, -1, 304, 308, 309, 305, -1, 305, 309, 310, 306, -1, 306, 310, 311, 307, -1, 307, 311, 308, 304, -1, 308, 311, 310, 309, 312, 313, 314, 315, -1, 312, 316, 317, 313, -1, 313, 317, 318, 314, - -1, 314, 318, 319, 315, -1, 315, 319, 316, 312, -1, 316, 319, 318, 317, 320, 321, 322, 323, -1, 320, 324, 325, 321, -1, 321, 325, 326, 322, -1, 322, 326, 327, 323, -1, 323, 327, 324, 320, -1, 324, - 327, 326, 325, 328, 329, 330, 331, -1, 328, 332, 333, 329, -1, 329, 333, 334, 330, -1, 330, 334, 335, 331, -1, 331, 335, 332, 328, -1, 332, 335, 334, 333, 336, 337, 338, 339, -1, 336, 340, 341, 337, - -1, 337, 341, 342, 338, -1, 338, 342, 343, 339, -1, 339, 343, 340, 336, -1, 340, 343, 342, 341, 344, 345, 346, 347, -1, 344, 348, 349, 345, -1, 345, 349, 350, 346, -1, 346, 350, 351, 347, -1, 347, - 351, 348, 344, -1, 348, 351, 350, 349, 352, 353, 354, 355, -1, 352, 356, 357, 353, -1, 353, 357, 358, 354, -1, 354, 358, 359, 355, -1, 355, 359, 356, 352, -1, 356, 359, 358, 357, 360, 361, 362, 363, - -1, 360, 364, 365, 361, -1, 361, 365, 366, 362, -1, 362, 366, 367, 363, -1, 363, 367, 364, 360, -1, 364, 367, 366, 365, 368, 369, 370, 371, -1, 368, 372, 373, 369, -1, 369, 373, 374, 370, -1, 370, - 374, 375, 371, -1, 371, 375, 372, 368, -1, 372, 375, 374, 373, 376, 377, 378, 379, -1, 376, 380, 381, 377, -1, 377, 381, 382, 378, -1, 378, 382, 383, 379, -1, 379, 383, 380, 376, -1, 380, 383, 382, - 381, 384, 385, 386, 387, -1, 384, 388, 389, 385, -1, 385, 389, 390, 386, -1, 386, 390, 391, 387, -1, 387, 391, 388, 384, -1, 388, 391, 390, 389, 392, 393, 394, 395, -1, 392, 396, 397, 393, -1, 393, - 397, 398, 394, -1, 394, 398, 399, 395, -1, 395, 399, 396, 392, -1, 396, 399, 398, 397, 400, 401, 402, 403, -1, 400, 404, 405, 401, -1, 401, 405, 406, 402, -1, 402, 406, 407, 403, -1, 403, 407, 404, - 400, -1, 404, 407, 406, 405, 408, 409, 410, 411, -1, 408, 412, 413, 409, -1, 409, 413, 414, 410, -1, 410, 414, 415, 411, -1, 411, 415, 412, 408, -1, 412, 415, 414, 413, 416, 417, 418, 419, -1, 416, - 420, 421, 417, -1, 417, 421, 422, 418, -1, 418, 422, 423, 419, -1, 419, 423, 420, 416, -1, 420, 423, 422, 421, 424, 425, 426, 427, -1, 424, 428, 429, 425, -1, 425, 429, 430, 426, -1, 426, 430, 431, - 427, -1, 427, 431, 428, 424, -1, 428, 431, 430, 429, 432, 433, 434, 435, -1, 432, 436, 437, 433, -1, 433, 437, 438, 434, -1, 434, 438, 439, 435, -1, 435, 439, 436, 432, -1, 436, 439, 438, 437, 440, - 441, 442, 443, -1, 440, 444, 445, 441, -1, 441, 445, 446, 442, -1, 442, 446, 447, 443, -1, 443, 447, 444, 440, -1, 444, 447, 446, 445, 448, 449, 450, 451, -1, 448, 452, 453, 449, -1, 449, 453, 454, - 450, -1, 450, 454, 455, 451, -1, 451, 455, 452, 448, -1, 452, 455, 454, 453, 456, 457, 458, 459, -1, 456, 460, 461, 457, -1, 457, 461, 462, 458, -1, 458, 462, 463, 459, -1, 459, 463, 460, 456, -1, - 460, 463, 462, 461, 464, 465, 466, 467, -1, 464, 468, 469, 465, -1, 465, 469, 470, 466, -1, 466, 470, 471, 467, -1, 467, 471, 468, 464, -1, 468, 471, 470, 469, 472, 473, 474, 475, -1, 472, 476, 477, - 473, -1, 473, 477, 478, 474, -1, 474, 478, 479, 475, -1, 475, 479, 476, 472, -1, 476, 479, 478, 477, 480, 481, 482, 483, -1, 480, 484, 485, 481, -1, 481, 485, 486, 482, -1, 482, 486, 487, 483, -1, - 483, 487, 484, 480, -1, 484, 487, 486, 485, 488, 489, 490, 491, -1, 488, 492, 493, 489, -1, 489, 493, 494, 490, -1, 490, 494, 495, 491, -1, 491, 495, 492, 488, -1, 492, 495, 494, 493, 496, 497, 498, - 499, -1, 496, 500, 501, 497, -1, 497, 501, 502, 498, -1, 498, 502, 503, 499, -1, 499, 503, 500, 496, -1, 500, 503, 502, 501, 504, 505, 506, 507, -1, 504, 508, 509, 505, -1, 505, 509, 510, 506, -1, 506, - 510, 511, 507, -1, 507, 511, 508, 504, -1, 508, 511, 510, 509, 512, 513, 514, 515, -1, 512, 516, 517, 513, -1, 513, 517, 518, 514, -1, 514, 518, 519, 515, -1, 515, 519, 516, 512, -1, 516, 519, 518, 517, - 520, 521, 522, 523, -1, 520, 524, 525, 521, -1, 521, 525, 526, 522, -1, 522, 526, 527, 523, -1, 523, 527, 524, 520, -1, 524, 527, 526, 525, 528, 529, 530, 531, -1, 528, 532, 533, 529, -1, 529, 533, - 534, 530, -1, 530, 534, 535, 531, -1, 531, 535, 532, 528, -1, 532, 535, 534, 533, 536, 537, 538, 539, -1, 536, 540, 541, 537, -1, 537, 541, 542, 538, -1, 538, 542, 543, 539, -1, 539, 543, 540, 536, - -1, 540, 543, 542, 541, 544, 545, 546, 547, -1, 544, 548, 549, 545, -1, 545, 549, 550, 546, -1, 546, 550, 551, 547, -1, 547, 551, 548, 544, -1, 548, 551, 550, 549, 552, 553, 554, 555, -1, 552, 556, - 557, 553, -1, 553, 557, 558, 554, -1, 554, 558, 559, 555, -1, 555, 559, 556, 552, -1, 556, 559, 558, 557, 560, 561, 562, 563, -1, 560, 564, 565, 561, -1, 561, 565, 566, 562, -1, 562, 566, 567, 563, - -1, 563, 567, 564, 560, -1, 564, 567, 566, 565, 568, 569, 570, 571, -1, 568, 572, 573, 569, -1, 569, 573, 574, 570, -1, 570, 574, 575, 571, -1, 571, 575, 572, 568, -1, 572, 575, 574, 573, 576, 577, - 578, 579, -1, 576, 580, 581, 577, -1, 577, 581, 582, 578, -1, 578, 582, 583, 579, -1, 579, 583, 580, 576, -1, 580, 583, 582, 581, 584, 585, 586, 587, -1, 584, 588, 589, 585, -1, 585, 589, 590, 586, - -1, 586, 590, 591, 587, -1, 587, 591, 588, 584, -1, 588, 591, 590, 589, 592, 593, 594, 595, -1, 592, 596, 597, 593, -1, 593, 597, 598, 594, -1, 594, 598, 599, 595, -1, 595, 599, 596, 592, -1, 596, - 599, 598, 597, 600, 601, 602, 603, -1, 600, 604, 605, 601, -1, 601, 605, 606, 602, -1, 602, 606, 607, 603, -1, 603, 607, 604, 600, -1, 604, 607, 606, 605, 608, 609, 610, 611, -1, 608, 612, 613, 609, - -1, 609, 613, 614, 610, -1, 610, 614, 615, 611, -1, 611, 615, 612, 608, -1, 612, 615, 614, 613, 616, 617, 618, 619, -1, 616, 620, 621, 617, -1, 617, 621, 622, 618, -1, 618, 622, 623, 619, -1, 619, - 623, 620, 616, -1, 620, 623, 622, 621, 624, 625, 626, 627, -1, 624, 628, 629, 625, -1, 625, 629, 630, 626, -1, 626, 630, 631, 627, -1, 627, 631, 628, 624, -1, 628, 631, 630, 629, 632, 633, 634, 635, - -1, 632, 636, 637, 633, -1, 633, 637, 638, 634, -1, 634, 638, 639, 635, -1, 635, 639, 636, 632, -1, 636, 639, 638, 637, 640, 641, 642, 643, -1, 640, 644, 645, 641, -1, 641, 645, 646, 642, -1, 642, - 646, 647, 643, -1, 643, 647, 644, 640, -1, 644, 647, 646, 645, 648, 649, 650, 651, -1, 648, 652, 653, 649, -1, 649, 653, 654, 650, -1, 650, 654, 655, 651, -1, 651, 655, 652, 648, -1, 652, 655, 654, - 653, 656, 657, 658, 659, -1, 656, 660, 661, 657, -1, 657, 661, 662, 658, -1, 658, 662, 663, 659, -1, 659, 663, 660, 656, -1, 660, 663, 662, 661, 664, 665, 666, 667, -1, 664, 668, 669, 665, -1, 665, - 669, 670, 666, -1, 666, 670, 671, 667, -1, 667, 671, 668, 664, -1, 668, 671, 670, 669, 672, 673, 674, 675, -1, 672, 676, 677, 673, -1, 673, 677, 678, 674, -1, 674, 678, 679, 675, -1, 675, 679, 676, - 672, -1, 676, 679, 678, 677, 680, 681, 682, 683, -1, 680, 684, 685, 681, -1, 681, 685, 686, 682, -1, 682, 686, 687, 683, -1, 683, 687, 684, 680, -1, 684, 687, 686, 685, 688, 689, 690, 691, -1, 688, - 692, 693, 689, -1, 689, 693, 694, 690, -1, 690, 694, 695, 691, -1, 691, 695, 692, 688, -1, 692, 695, 694, 693, 696, 697, 698, 699, -1, 696, 700, 701, 697, -1, 697, 701, 702, 698, -1, 698, 702, 703, - 699, -1, 699, 703, 700, 696, -1, 700, 703, 702, 701, 704, 705, 706, 707, -1, 704, 708, 709, 705, -1, 705, 709, 710, 706, -1, 706, 710, 711, 707, -1, 707, 711, 708, 704, -1, 708, 711, 710, 709, 712, - 713, 714, 715, -1, 712, 716, 717, 713, -1, 713, 717, 718, 714, -1, 714, 718, 719, 715, -1, 715, 719, 716, 712, -1, 716, 719, 718, 717, 720, 721, 722, 723, -1, 720, 724, 725, 721, -1, 721, 725, 726, - 722, -1, 722, 726, 727, 723, -1, 723, 727, 724, 720, -1, 724, 727, 726, 725, 728, 729, 730, 731, -1, 728, 732, 733, 729, -1, 729, 733, 734, 730, -1, 730, 734, 735, 731, -1, 731, 735, 732, 728, -1, - 732, 735, 734, 733, 736, 737, 738, 739, -1, 736, 740, 741, 737, -1, 737, 741, 742, 738, -1, 738, 742, 743, 739, -1, 739, 743, 740, 736, -1, 740, 743, 742, 741, 744, 745, 746, 747, -1, 744, 748, 749, - 745, -1, 745, 749, 750, 746, -1, 746, 750, 751, 747, -1, 747, 751, 748, 744, -1, 748, 751, 750, 749, 752, 753, 754, 755, -1, 752, 756, 757, 753, -1, 753, 757, 758, 754, -1, 754, 758, 759, 755, -1, - 755, 759, 756, 752, -1, 756, 759, 758, 757, 760, 761, 762, 763, -1, 760, 764, 765, 761, -1, 761, 765, 766, 762, -1, 762, 766, 767, 763, -1, 763, 767, 764, 760, -1, 764, 767, 766, 765, 768, 769, 770, - 771, -1, 768, 772, 773, 769, -1, 769, 773, 774, 770, -1, 770, 774, 775, 771, -1, 771, 775, 772, 768, -1, 772, 775, 774, 773, 776, 777, 778, 779, -1, 776, 780, 781, 777, -1, 777, 781, 782, 778, -1, - 778, 782, 783, 779, -1, 779, 783, 780, 776, -1, 780, 783, 782, 781, 784, 785, 786, 787, -1, 784, 788, 789, 785, -1, 785, 789, 790, 786, -1, 786, 790, 791, 787, -1, 787, 791, 788, 784, -1, 788, 791, - 790, 789, 792, 793, 794, 795, -1, 792, 796, 797, 793, -1, 793, 797, 798, 794, -1, 794, 798, 799, 795, -1, 795, 799, 796, 792, -1, 796, 799, 798, 797, 800, 801, 802, 803, -1, 800, 804, 805, 801, -1, - 801, 805, 806, 802, -1, 802, 806, 807, 803, -1, 803, 807, 804, 800, -1, 804, 807, 806, 805, 808, 809, 810, 811, -1, 808, 812, 813, 809, -1, 809, 813, 814, 810, -1, 810, 814, 815, 811, -1, 811, 815, - 812, 808, -1, 812, 815, 814, 813, 816, 817, 818, 819, -1, 816, 820, 821, 817, -1, 817, 821, 822, 818, -1, 818, 822, 823, 819, -1, 819, 823, 820, 816, -1, 820, 823, 822, 821, 824, 825, 826, 827, -1, - 824, 828, 829, 825, -1, 825, 829, 830, 826, -1, 826, 830, 831, 827, -1, 827, 831, 828, 824, -1, 828, 831, 830, 829, 832, 833, 834, 835, -1, 832, 836, 837, 833, -1, 833, 837, 838, 834, -1, 834, 838, - 839, 835, -1, 835, 839, 836, 832, -1, 836, 839, 838, 837, 840, 841, 842, 843, -1, 840, 844, 845, 841, -1, 841, 845, 846, 842, -1, 842, 846, 847, 843, -1, 843, 847, 844, 840, -1, 844, 847, 846, 845, - 848, 849, 850, 851, -1, 848, 852, 853, 849, -1, 849, 853, 854, 850, -1, 850, 854, 855, 851, -1, 851, 855, 852, 848, -1, 852, 855, 854, 853, 856, 857, 858, 859, -1, 856, 860, 861, 857, -1, 857, 861, - 862, 858, -1, 858, 862, 863, 859, -1, 859, 863, 860, 856, -1, 860, 863, 862, 861, 864, 865, 866, 867, -1, 864, 868, 869, 865, -1, 865, 869, 870, 866, -1, 866, 870, 871, 867, -1, 867, 871, 868, 864, - -1, 868, 871, 870, 869, 872, 873, 874, 875, -1, 872, 876, 877, 873, -1, 873, 877, 878, 874, -1, 874, 878, 879, 875, -1, 875, 879, 876, 872, -1, 876, 879, 878, 877, 880, 881, 882, 883, -1, 880, 884, - 885, 881, -1, 881, 885, 886, 882, -1, 882, 886, 887, 883, -1, 883, 887, 884, 880, -1, 884, 887, 886, 885, 888, 889, 890, 891, -1, 888, 892, 893, 889, -1, 889, 893, 894, 890, -1, 890, 894, 895, 891, - -1, 891, 895, 892, 888, -1, 892, 895, 894, 893, 896, 897, 898, 899, -1, 896, 900, 901, 897, -1, 897, 901, 902, 898, -1, 898, 902, 903, 899, -1, 899, 903, 900, 896, -1, 900, 903, 902, 901, 904, 905, - 906, 907, -1, 904, 908, 909, 905, -1, 905, 909, 910, 906, -1, 906, 910, 911, 907, -1, 907, 911, 908, 904, -1, 908, 911, 910, 909, 912, 913, 914, 915, -1, 912, 916, 917, 913, -1, 913, 917, 918, 914, - -1, 914, 918, 919, 915, -1, 915, 919, 916, 912, -1, 916, 919, 918, 917, 920, 921, 922, 923, -1, 920, 924, 925, 921, -1, 921, 925, 926, 922, -1, 922, 926, 927, 923, -1, 923, 927, 924, 920, -1, 924, - 927, 926, 925, 928, 929, 930, 931, -1, 928, 932, 933, 929, -1, 929, 933, 934, 930, -1, 930, 934, 935, 931, -1, 931, 935, 932, 928, -1, 932, 935, 934, 933, 936, 937, 938, 939, -1, 936, 940, 941, 937, - -1, 937, 941, 942, 938, -1, 938, 942, 943, 939, -1, 939, 943, 940, 936, -1, 940, 943, 942, 941, 944, 945, 946, 947, -1, 944, 948, 949, 945, -1, 945, 949, 950, 946, -1, 946, 950, 951, 947, -1, 947, - 951, 948, 944, -1, 948, 951, 950, 949, 952, 953, 954, 955, -1, 952, 956, 957, 953, -1, 953, 957, 958, 954, -1, 954, 958, 959, 955, -1, 955, 959, 956, 952, -1, 956, 959, 958, 957, 960, 961, 962, 963, - -1, 960, 964, 965, 961, -1, 961, 965, 966, 962, -1, 962, 966, 967, 963, -1, 963, 967, 964, 960, -1, 964, 967, 966, 965, 968, 969, 970, 971, -1, 968, 972, 973, 969, -1, 969, 973, 974, 970, -1, 970, - 974, 975, 971, -1, 971, 975, 972, 968, -1, 972, 975, 974, 973, 976, 977, 978, 979, -1, 976, 980, 981, 977, -1, 977, 981, 982, 978, -1, 978, 982, 983, 979, -1, 979, 983, 980, 976, -1, 980, 983, 982, - 981, 984, 985, 986, 987, -1, 984, 988, 989, 985, -1, 985, 989, 990, 986, -1, 986, 990, 991, 987, -1, 987, 991, 988, 984, -1, 988, 991, 990, 989, 992, 993, 994, 995, -1, 992, 996, 997, 993, -1, 993, - 997, 998, 994, -1, 994, 998, 999, 995, -1, 995, 999, 996, 992, -1, 996, 999, 998, 997, 1000, 1001, 1002, 1003, -1, 1000, 1004, 1005, 1001, -1, 1001, 1005, 1006, 1002, -1, 1002, 1006, 1007, 1003, - -1, 1003, 1007, 1004, 1000, -1, 1004, 1007, 1006, 1005, 1008, 1009, 1010, 1011, -1, 1008, 1012, 1013, 1009, -1, 1009, 1013, 1014, 1010, -1, 1010, 1014, 1015, 1011, -1, 1011, 1015, 1012, 1008, -1, - 1012, 1015, 1014, 1013, 1016, 1017, 1018, 1019, -1, 1016, 1020, 1021, 1017, -1, 1017, 1021, 1022, 1018, -1, 1018, 1022, 1023, 1019, -1, 1019, 1023, 1020, 1016, -1, 1020, 1023, 1022, 1021, 1024, - 1025, 1026, 1027, -1, 1024, 1028, 1029, 1025, -1, 1025, 1029, 1030, 1026, -1, 1026, 1030, 1031, 1027, -1, 1027, 1031, 1028, 1024, -1, 1028, 1031, 1030, 1029, 1032, 1033, 1034, 1035, -1, 1032, - 1036, 1037, 1033, -1, 1033, 1037, 1038, 1034, -1, 1034, 1038, 1039, 1035, -1, 1035, 1039, 1036, 1032, -1, 1036, 1039, 1038, 1037, 1040, 1041, 1042, 1043, -1, 1040, 1044, 1045, 1041, -1, 1041, - 1045, 1046, 1042, -1, 1042, 1046, 1047, 1043, -1, 1043, 1047, 1044, 1040, -1, 1044, 1047, 1046, 1045, 1048, 1049, 1050, 1051, -1, 1048, 1052, 1053, 1049, -1, 1049, 1053, 1054, 1050, -1, 1050, - 1054, 1055, 1051, -1, 1051, 1055, 1052, 1048, -1, 1052, 1055, 1054, 1053, 1056, 1057, 1058, 1059, -1, 1056, 1060, 1061, 1057, -1, 1057, 1061, 1062, 1058, -1, 1058, 1062, 1063, 1059, -1, 1059, - 1063, 1060, 1056, -1, 1060, 1063, 1062, 1061, 1064, 1065, 1066, 1067, -1, 1064, 1068, 1069, 1065, -1, 1065, 1069, 1070, 1066, -1, 1066, 1070, 1071, 1067, -1, 1067, 1071, 1068, 1064, -1, 1068, - 1071, 1070, 1069, 1072, 1073, 1074, 1075, -1, 1072, 1076, 1077, 1073, -1, 1073, 1077, 1078, 1074, -1, 1074, 1078, 1079, 1075, -1, 1075, 1079, 1076, 1072, -1, 1076, 1079, 1078, 1077, 1080, 1081, - 1082, 1083, -1, 1080, 1084, 1085, 1081, -1, 1081, 1085, 1086, 1082, -1, 1082, 1086, 1087, 1083, -1, 1083, 1087, 1084, 1080, -1, 1084, 1087, 1086, 1085, 1088, 1089, 1090, 1091, -1, 1088, 1092, - 1093, 1089, -1, 1089, 1093, 1094, 1090, -1, 1090, 1094, 1095, 1091, -1, 1091, 1095, 1092, 1088, -1, 1092, 1095, 1094, 1093, 1096, 1097, 1098, 1099, -1, 1096, 1100, 1101, 1097, -1, 1097, 1101, - 1102, 1098, -1, 1098, 1102, 1103, 1099, -1, 1099, 1103, 1100, 1096, -1, 1100, 1103, 1102, 1101, 1104, 1105, 1106, 1107, -1, 1104, 1108, 1109, 1105, -1, 1105, 1109, 1110, 1106, -1, 1106, 1110, - 1111, 1107, -1, 1107, 1111, 1108, 1104, -1, 1108, 1111, 1110, 1109, 1112, 1113, 1114, 1115, -1, 1112, 1116, 1117, 1113, -1, 1113, 1117, 1118, 1114, -1, 1114, 1118, 1119, 1115, -1, 1115, 1119, - 1116, 1112, -1, 1116, 1119, 1118, 1117, 1120, 1121, 1122, 1123, -1, 1120, 1124, 1125, 1121, -1, 1121, 1125, 1126, 1122, -1, 1122, 1126, 1127, 1123, -1, 1123, 1127, 1124, 1120, -1, 1124, 1127, - 1126, 1125, 1128, 1129, 1130, 1131, -1, 1128, 1132, 1133, 1129, -1, 1129, 1133, 1134, 1130, -1, 1130, 1134, 1135, 1131, -1, 1131, 1135, 1132, 1128, -1, 1132, 1135, 1134, 1133, 1136, 1137, 1138, - 1139, -1, 1136, 1140, 1141, 1137, -1, 1137, 1141, 1142, 1138, -1, 1138, 1142, 1143, 1139, -1, 1139, 1143, 1140, 1136, -1, 1140, 1143, 1142, 1141, 1144, 1145, 1146, 1147, -1, 1144, 1148, 1149, - 1145, -1, 1145, 1149, 1150, 1146, -1, 1146, 1150, 1151, 1147, -1, 1147, 1151, 1148, 1144, -1, 1148, 1151, 1150, 1149, 1152, 1153, 1154, 1155, -1, 1152, 1156, 1157, 1153, -1, 1153, 1157, 1158, - 1154, -1, 1154, 1158, 1159, 1155, -1, 1155, 1159, 1156, 1152, -1, 1156, 1159, 1158, 1157, 1160, 1161, 1162, 1163, -1, 1160, 1164, 1165, 1161, -1, 1161, 1165, 1166, 1162, -1, 1162, 1166, 1167, - 1163, -1, 1163, 1167, 1164, 1160, -1, 1164, 1167, 1166, 1165, 1168, 1169, 1170, 1171, -1, 1168, 1172, 1173, 1169, -1, 1169, 1173, 1174, 1170, -1, 1170, 1174, 1175, 1171, -1, 1171, 1175, 1172, - 1168, -1, 1172, 1175, 1174, 1173, 1176, 1177, 1178, 1179, -1, 1176, 1180, 1181, 1177, -1, 1177, 1181, 1182, 1178, -1, 1178, 1182, 1183, 1179, -1, 1179, 1183, 1180, 1176, -1, 1180, 1183, 1182, - 1181, 1184, 1185, 1186, 1187, -1, 1184, 1188, 1189, 1185, -1, 1185, 1189, 1190, 1186, -1, 1186, 1190, 1191, 1187, -1, 1187, 1191, 1188, 1184, -1, 1188, 1191, 1190, 1189, 1192, 1193, 1194, 1195, - -1, 1192, 1196, 1197, 1193, -1, 1193, 1197, 1198, 1194, -1, 1194, 1198, 1199, 1195, -1, 1195, 1199, 1196, 1192, -1, 1196, 1199, 1198, 1197, 1200, 1201, 1202, 1203, -1, 1200, 1204, 1205, 1201, - -1, 1201, 1205, 1206, 1202, -1, 1202, 1206, 1207, 1203, -1, 1203, 1207, 1204, 1200, -1, 1204, 1207, 1206, 1205, 1208, 1209, 1210, 1211, -1, 1208, 1212, 1213, 1209, -1, 1209, 1213, 1214, 1210, - -1, 1210, 1214, 1215, 1211, -1, 1211, 1215, 1212, 1208, -1, 1212, 1215, 1214, 1213, 1216, 1217, 1218, 1219, -1, 1216, 1220, 1221, 1217, -1, 1217, 1221, 1222, 1218, -1, 1218, 1222, 1223, 1219, - -1, 1219, 1223, 1220, 1216, -1, 1220, 1223, 1222, 1221, 1224, 1225, 1226, 1227, -1, 1224, 1228, 1229, 1225, -1, 1225, 1229, 1230, 1226, -1, 1226, 1230, 1231, 1227, -1, 1227, 1231, 1228, 1224, - -1, 1228, 1231, 1230, 1229, 1232, 1233, 1234, 1235, -1, 1232, 1236, 1237, 1233, -1, 1233, 1237, 1238, 1234, -1, 1234, 1238, 1239, 1235, -1, 1235, 1239, 1236, 1232, -1, 1236, 1239, 1238, 1237, - 1240, 1241, 1242, 1243, -1, 1240, 1244, 1245, 1241, -1, 1241, 1245, 1246, 1242, -1, 1242, 1246, 1247, 1243, -1, 1243, 1247, 1244, 1240, -1, 1244, 1247, 1246, 1245, 1248, 1249, 1250, 1251, -1, - 1248, 1252, 1253, 1249, -1, 1249, 1253, 1254, 1250, -1, 1250, 1254, 1255, 1251, -1, 1251, 1255, 1252, 1248, -1, 1252, 1255, 1254, 1253, 1256, 1257, 1258, 1259, -1, 1256, 1260, 1261, 1257, -1, - 1257, 1261, 1262, 1258, -1, 1258, 1262, 1263, 1259, -1, 1259, 1263, 1260, 1256, -1, 1260, 1263, 1262, 1261, 1264, 1265, 1266, 1267, -1, 1264, 1268, 1269, 1265, -1, 1265, 1269, 1270, 1266, -1, - 1266, 1270, 1271, 1267, -1, 1267, 1271, 1268, 1264, -1, 1268, 1271, 1270, 1269, 1272, 1273, 1274, 1275, -1, 1272, 1276, 1277, 1273, -1, 1273, 1277, 1278, 1274, -1, 1274, 1278, 1279, 1275, -1, - 1275, 1279, 1276, 1272, -1, 1276, 1279, 1278, 1277, 1280, 1281, 1282, 1283, -1, 1280, 1284, 1285, 1281, -1, 1281, 1285, 1286, 1282, -1, 1282, 1286, 1287, 1283, -1, 1283, 1287, 1284, 1280, -1, - 1284, 1287, 1286, 1285, 1288, 1289, 1290, 1291, -1, 1288, 1292, 1293, 1289, -1, 1289, 1293, 1294, 1290, -1, 1290, 1294, 1295, 1291, -1, 1291, 1295, 1292, 1288, -1, 1292, 1295, 1294, 1293, 1296, - 1297, 1298, 1299, -1, 1296, 1300, 1301, 1297, -1, 1297, 1301, 1302, 1298, -1, 1298, 1302, 1303, 1299, -1, 1299, 1303, 1300, 1296, -1, 1300, 1303, 1302, 1301, 1304, 1305, 1306, 1307, -1, 1304, - 1308, 1309, 1305, -1, 1305, 1309, 1310, 1306, -1, 1306, 1310, 1311, 1307, -1, 1307, 1311, 1308, 1304, -1, 1308, 1311, 1310, 1309, 1312, 1313, 1314, 1315, -1, 1312, 1316, 1317, 1313, -1, 1313, - 1317, 1318, 1314, -1, 1314, 1318, 1319, 1315, -1, 1315, 1319, 1316, 1312, -1, 1316, 1319, 1318, 1317, 1320, 1321, 1322, 1323, -1, 1320, 1324, 1325, 1321, -1, 1321, 1325, 1326, 1322, -1, 1322, - 1326, 1327, 1323, -1, 1323, 1327, 1324, 1320, -1, 1324, 1327, 1326, 1325, 1328, 1329, 1330, 1331, -1, 1328, 1332, 1333, 1329, -1, 1329, 1333, 1334, 1330, -1, 1330, 1334, 1335, 1331, -1, 1331, - 1335, 1332, 1328, -1, 1332, 1335, 1334, 1333, 1336, 1337, 1338, 1339, -1, 1336, 1340, 1341, 1337, -1, 1337, 1341, 1342, 1338, -1, 1338, 1342, 1343, 1339, -1, 1339, 1343, 1340, 1336, -1, 1340, - 1343, 1342, 1341, 1344, 1345, 1346, 1347, -1, 1344, 1348, 1349, 1345, -1, 1345, 1349, 1350, 1346, -1, 1346, 1350, 1351, 1347, -1, 1347, 1351, 1348, 1344, -1, 1348, 1351, 1350, 1349, 1352, 1353, - 1354, 1355, -1, 1352, 1356, 1357, 1353, -1, 1353, 1357, 1358, 1354, -1, 1354, 1358, 1359, 1355, -1, 1355, 1359, 1356, 1352, -1, 1356, 1359, 1358, 1357, 1360, 1361, 1362, 1363, -1, 1360, 1364, - 1365, 1361, -1, 1361, 1365, 1366, 1362, -1, 1362, 1366, 1367, 1363, -1, 1363, 1367, 1364, 1360, -1, 1364, 1367, 1366, 1365, 1368, 1369, 1370, 1371, -1, 1368, 1372, 1373, 1369, -1, 1369, 1373, - 1374, 1370, -1, 1370, 1374, 1375, 1371, -1, 1371, 1375, 1372, 1368, -1, 1372, 1375, 1374, 1373, 1376, 1377, 1378, 1379, -1, 1376, 1380, 1381, 1377, -1, 1377, 1381, 1382, 1378, -1, 1378, 1382, - 1383, 1379, -1, 1379, 1383, 1380, 1376, -1, 1380, 1383, 1382, 1381, 1384, 1385, 1386, 1387, -1, 1384, 1388, 1389, 1385, -1, 1385, 1389, 1390, 1386, -1, 1386, 1390, 1391, 1387, -1, 1387, 1391, - 1388, 1384, -1, 1388, 1391, 1390, 1389, 1392, 1393, 1394, 1395, -1, 1392, 1396, 1397, 1393, -1, 1393, 1397, 1398, 1394, -1, 1394, 1398, 1399, 1395, -1, 1395, 1399, 1396, 1392, -1, 1396, 1399, - 1398, 1397, 1400, 1401, 1402, 1403, -1, 1400, 1404, 1405, 1401, -1, 1401, 1405, 1406, 1402, -1, 1402, 1406, 1407, 1403, -1, 1403, 1407, 1404, 1400, -1, 1404, 1407, 1406, 1405, 1408, 1409, - 1410, 1411, -1, 1408, 1412, 1413, 1409, -1, 1409, 1413, 1414, 1410, -1, 1410, 1414, 1415, 1411, -1, 1411, 1415, 1412, 1408, -1, 1412, 1415, 1414, 1413, 1416, 1417, 1418, 1419, -1, 1416, - 1420, 1421, 1417, -1, 1417, 1421, 1422, 1418, -1, 1418, 1422, 1423, 1419, -1, 1419, 1423, 1420, 1416, -1, 1420, 1423, 1422, 1421, 1424, 1425, 1426, 1427, -1, 1424, 1428, 1429, 1425, -1, - 1425, 1429, 1430, 1426, -1, 1426, 1430, 1431, 1427, -1, 1427, 1431, 1428, 1424, -1, 1428, 1431, 1430, 1429, 1432, 1433, 1434, 1435, -1, 1432, 1436, 1437, 1433, -1, 1433, 1437, 1438, 1434, - -1, 1434, 1438, 1439, 1435, -1, 1435, 1439, 1436, 1432, -1, 1436, 1439, 1438, 1437, 1440, 1441, 1442, 1443, -1, 1440, 1444, 1445, 1441, -1, 1441, 1445, 1446, 1442, -1, 1442, 1446, 1447, 1443, - -1, 1443, 1447, 1444, 1440, -1, 1444, 1447, 1446, 1445, 1448, 1449, 1450, 1451, -1, 1448, 1452, 1453, 1449, -1, 1449, 1453, 1454, 1450, -1, 1450, 1454, 1455, 1451, -1, 1451, 1455, 1452, 1448, - -1, 1452, 1455, 1454, 1453, 1456, 1457, 1458, 1459, -1, 1456, 1460, 1461, 1457, -1, 1457, 1461, 1462, 1458, -1, 1458, 1462, 1463, 1459, -1, 1459, 1463, 1460, 1456, -1, 1460, 1463, 1462, 1461, - 1464, 1465, 1466, 1467, -1, 1464, 1468, 1469, 1465, -1, 1465, 1469, 1470, 1466, -1, 1466, 1470, 1471, 1467, -1, 1467, 1471, 1468, 1464, -1, 1468, 1471, 1470, 1469, 1472, 1473, 1474, 1475, -1, - 1472, 1476, 1477, 1473, -1, 1473, 1477, 1478, 1474, -1, 1474, 1478, 1479, 1475, -1, 1475, 1479, 1476, 1472, -1, 1476, 1479, 1478, 1477, 1480, 1481, 1482, 1483, -1, 1480, 1484, 1485, 1481, -1, - 1481, 1485, 1486, 1482, -1, 1482, 1486, 1487, 1483, -1, 1483, 1487, 1484, 1480, -1, 1484, 1487, 1486, 1485, 1488, 1489, 1490, 1491, -1, 1488, 1492, 1493, 1489, -1, 1489, 1493, 1494, 1490, -1, - 1490, 1494, 1495, 1491, -1, 1491, 1495, 1492, 1488, -1, 1492, 1495, 1494, 1493, 1496, 1497, 1498, 1499, -1, 1496, 1500, 1501, 1497, -1, 1497, 1501, 1502, 1498, -1, 1498, 1502, 1503, 1499, -1, - 1499, 1503, 1500, 1496, -1, 1500, 1503, 1502, 1501, 1504, 1505, 1506, 1507, -1, 1504, 1508, 1509, 1505, -1, 1505, 1509, 1510, 1506, -1, 1506, 1510, 1511, 1507, -1, 1507, 1511, 1508, 1504, -1, - 1508, 1511, 1510, 1509, 1512, 1513, 1514, 1515, -1, 1512, 1516, 1517, 1513, -1, 1513, 1517, 1518, 1514, -1, 1514, 1518, 1519, 1515, -1, 1515, 1519, 1516, 1512, -1, 1516, 1519, 1518, 1517, 1520, - 1521, 1522, 1523, -1, 1520, 1524, 1525, 1521, -1, 1521, 1525, 1526, 1522, -1, 1522, 1526, 1527, 1523, -1, 1523, 1527, 1524, 1520, -1, 1524, 1527, 1526, 1525, 1528, 1529, 1530, 1531, -1, 1528, 1532, - 1533, 1529, -1, 1529, 1533, 1534, 1530, -1, 1530, 1534, 1535, 1531, -1, 1531, 1535, 1532, 1528, -1, 1532, 1535, 1534, 1533, 1536, 1537, 1538, 1539, -1, 1536, 1540, 1541, 1537, -1, 1537, 1541, 1542, - 1538, -1, 1538, 1542, 1543, 1539, -1, 1539, 1543, 1540, 1536, -1, 1540, 1543, 1542, 1541, 1544, 1545, 1546, 1547, -1, 1544, 1548, 1549, 1545, -1, 1545, 1549, 1550, 1546, -1, 1546, 1550, 1551, 1547, - -1, 1547, 1551, 1548, 1544, -1, 1548, 1551, 1550, 1549, 1552, 1553, 1554, 1555, -1, 1552, 1556, 1557, 1553, -1, 1553, 1557, 1558, 1554, -1, 1554, 1558, 1559, 1555, -1, 1555, 1559, 1556, 1552, -1, 1556, - 1559, 1558, 1557, 1560, 1561, 1562, 1563, -1, 1560, 1564, 1565, 1561, -1, 1561, 1565, 1566, 1562, -1, 1562, 1566, 1567, 1563, -1, 1563, 1567, 1564, 1560, -1, 1564, 1567, 1566, 1565, 1568, 1569, 1570, 1571, - -1, 1568, 1572, 1573, 1569, -1, 1569, 1573, 1574, 1570, -1, 1570, 1574, 1575, 1571, -1, 1571, 1575, 1572, 1568, -1, 1572, 1575, 1574, 1573, 1576, 1577, 1578, 1579, -1, 1576, 1580, 1581, 1577, -1, - 1577, 1581, 1582, 1578, -1, 1578, 1582, 1583, 1579, -1, 1579, 1583, 1580, 1576, -1, 1580, 1583, 1582, 1581, 1584, 1585, 1586, 1587, -1, 1584, 1588, 1589, 1585, -1, 1585, 1589, 1590, 1586, -1, - 1586, 1590, 1591, 1587, -1, 1587, 1591, 1588, 1584, -1, 1588, 1591, 1590, 1589, 1592, 1593, 1594, 1595, -1, 1592, 1596, 1597, 1593, -1, 1593, 1597, 1598, 1594, -1, 1594, 1598, 1599, 1595, -1, - 1595, 1599, 1596, 1592, -1, 1596, 1599, 1598, 1597, 1600, 1601, 1602, 1603, -1, 1600, 1604, 1605, 1601, -1, 1601, 1605, 1606, 1602, -1, 1602, 1606, 1607, 1603, -1, 1603, 1607, 1604, 1600, -1, - 1604, 1607, 1606, 1605, 1608, 1609, 1610, 1611, -1, 1608, 1612, 1613, 1609, -1, 1609, 1613, 1614, 1610, -1, 1610, 1614, 1615, 1611, -1, 1611, 1615, 1612, 1608, -1, 1612, 1615, 1614, 1613, 1616, - 1617, 1618, 1619, -1, 1616, 1620, 1621, 1617, -1, 1617, 1621, 1622, 1618, -1, 1618, 1622, 1623, 1619, -1, 1619, 1623, 1620, 1616, -1, 1620, 1623, 1622, 1621, 1624, 1625, 1626, 1627, -1, 1624, - 1628, 1629, 1625, -1, 1625, 1629, 1630, 1626, -1, 1626, 1630, 1631, 1627, -1, 1627, 1631, 1628, 1624, -1, 1628, 1631, 1630, 1629, 1632, 1633, 1634, 1635, -1, 1632, 1636, 1637, 1633, -1, 1633, - 1637, 1638, 1634, -1, 1634, 1638, 1639, 1635, -1, 1635, 1639, 1636, 1632, -1, 1636, 1639, 1638, 1637, 1640, 1641, 1642, 1643, -1, 1640, 1644, 1645, 1641, -1, 1641, 1645, 1646, 1642, -1, 1642, - 1646, 1647, 1643, -1, 1643, 1647, 1644, 1640, -1, 1644, 1647, 1646, 1645, 1648, 1649, 1650, 1651, -1, 1648, 1652, 1653, 1649, -1, 1649, 1653, 1654, 1650, -1, 1650, 1654, 1655, 1651, -1, 1651, - 1655, 1652, 1648, -1, 1652, 1655, 1654, 1653, 1656, 1657, 1658, 1659, -1, 1656, 1660, 1661, 1657, -1, 1657, 1661, 1662, 1658, -1, 1658, 1662, 1663, 1659, -1, 1659, 1663, 1660, 1656, -1, 1660, - 1663, 1662, 1661, 1664, 1665, 1666, 1667, -1, 1664, 1668, 1669, 1665, -1, 1665, 1669, 1670, 1666, -1, 1666, 1670, 1671, 1667, -1, 1667, 1671, 1668, 1664, -1, 1668, 1671, 1670, 1669, 1672, 1673, - 1674, 1675, -1, 1672, 1676, 1677, 1673, -1, 1673, 1677, 1678, 1674, -1, 1674, 1678, 1679, 1675, -1, 1675, 1679, 1676, 1672, -1, 1676, 1679, 1678, 1677, 1680, 1681, 1682, 1683, -1, 1680, 1684, - 1685, 1681, -1, 1681, 1685, 1686, 1682, -1, 1682, 1686, 1687, 1683, -1, 1683, 1687, 1684, 1680, -1, 1684, 1687, 1686, 1685, 1688, 1689, 1690, 1691, -1, 1688, 1692, 1693, 1689, -1, 1689, 1693, - 1694, 1690, -1, 1690, 1694, 1695, 1691, -1, 1691, 1695, 1692, 1688, -1, 1692, 1695, 1694, 1693, 1696, 1697, 1698, 1699, -1, 1696, 1700, 1701, 1697, -1, 1697, 1701, 1702, 1698, -1, 1698, 1702, - 1703, 1699, -1, 1699, 1703, 1700, 1696, -1, 1700, 1703, 1702, 1701, 1704, 1705, 1706, 1707, -1, 1704, 1708, 1709, 1705, -1, 1705, 1709, 1710, 1706, -1, 1706, 1710, 1711, 1707, -1, 1707, 1711, - 1708, 1704, -1, 1708, 1711, 1710, 1709, 1712, 1713, 1714, 1715, -1, 1712, 1716, 1717, 1713, -1, 1713, 1717, 1718, 1714, -1, 1714, 1718, 1719, 1715, -1, 1715, 1719, 1716, 1712, -1, 1716, 1719, 1718, 1717}; - -double coordsTT[5160]={ - 0.0054015000000000044, 0.0054015000000000053, 0, 0.2106585, 0.0054015000000000053, 0, 0.2106585, 0.039611, 0, 0.2106585, 0.10803, 0, 0.2106585, - 0.17644899999999999, 0, 0.2106585, 0.2106585, 0, 0.0054015000000000044, 0.2106585, 0, 0.0054015000000000044, 0.0054015000000000053, 0.21364999999999998, - 0.2106585, 0.0054015000000000053, 0.21364999999999998, 0.2106585, 0.039611, 0.21364999999999998, 0.2106585, 0.10803, 0.21364999999999998, 0.2106585, - 0.17644899999999999, 0.21364999999999998, 0.2106585, 0.2106585, 0.21364999999999998, 0.0054015000000000044, 0.2106585, 0.21364999999999998, - 0.0054015000000000044, 0.0054015000000000053, 0.21364999999999998, 0.2106585, 0.0054015000000000053, 0.21364999999999998, 0.2106585, 0.039611, - 0.21364999999999998, 0.2106585, 0.10803, 0.21364999999999998, 0.2106585, 0.17644899999999999, 0.21364999999999998, 0.2106585, 0.2106585, 0.21364999999999998, - 0.0054015000000000044, 0.2106585, 0.21364999999999998, 0.0054015000000000044, 0.0054015000000000053, 0.42729999999999996, 0.2106585, 0.0054015000000000053, - 0.42729999999999996, 0.2106585, 0.039611, 0.42729999999999996, 0.2106585, 0.10803, 0.42729999999999996, 0.2106585, 0.17644899999999999, 0.42729999999999996, - 0.2106585, 0.2106585, 0.42729999999999996, 0.0054015000000000044, 0.2106585, 0.42729999999999996, 0.0054015000000000044, 0.0054015000000000053, - 0.42729999999999996, 0.2106585, 0.0054015000000000053, 0.42729999999999996, 0.2106585, 0.039611, 0.42729999999999996, 0.2106585, 0.10803, 0.42729999999999996, - 0.2106585, 0.17644899999999999, 0.42729999999999996, 0.2106585, 0.2106585, 0.42729999999999996, 0.0054015000000000044, 0.2106585, 0.42729999999999996, - 0.0054015000000000044, 0.0054015000000000053, 0.64094999999999991, 0.2106585, 0.0054015000000000053, 0.64094999999999991, 0.2106585, 0.039611, - 0.64094999999999991, 0.2106585, 0.10803, 0.64094999999999991, 0.2106585, 0.17644899999999999, 0.64094999999999991, 0.2106585, 0.2106585, 0.64094999999999991, - 0.0054015000000000044, 0.2106585, 0.64094999999999991, 0.0054015000000000044, 0.0054015000000000053, 0.64094999999999991, 0.2106585, 0.0054015000000000053, - 0.64094999999999991, 0.2106585, 0.039611, 0.64094999999999991, 0.2106585, 0.10803, 0.64094999999999991, 0.2106585, 0.17644899999999999, 0.64094999999999991, - 0.2106585, 0.2106585, 0.64094999999999991, 0.0054015000000000044, 0.2106585, 0.64094999999999991, 0.0054015000000000044, 0.0054015000000000053, - 0.85459999999999992, 0.2106585, 0.0054015000000000053, 0.85459999999999992, 0.2106585, 0.039611, 0.85459999999999992, 0.2106585, 0.10803, 0.85459999999999992, - 0.2106585, 0.17644899999999999, 0.85459999999999992, 0.2106585, 0.2106585, 0.85459999999999992, 0.0054015000000000044, 0.2106585, 0.85459999999999992, - 0.0054015000000000044, 0.0054015000000000053, 0.85459999999999992, 0.2106585, 0.0054015000000000053, 0.85459999999999992, 0.2106585, 0.039611, - 0.85459999999999992, 0.2106585, 0.10803, 0.85459999999999992, 0.2106585, 0.17644899999999999, 0.85459999999999992, 0.2106585, 0.2106585, 0.85459999999999992, - 0.0054015000000000044, 0.2106585, 0.85459999999999992, 0.0054015000000000044, 0.0054015000000000053, 1.0682499999999999, 0.2106585, 0.0054015000000000053, - 1.0682499999999999, 0.2106585, 0.039611, 1.0682499999999999, 0.2106585, 0.10803, - 1.0682499999999999, 0.2106585, 0.17644899999999999, 1.0682499999999999, 0.2106585, 0.2106585, 1.0682499999999999, 0.0054015000000000044, 0.2106585, - 1.0682499999999999, 0.0054015000000000044, 0.0054015000000000053, 1.0682499999999999, 0.2106585, 0.0054015000000000053, 1.0682499999999999, 0.2106585, 0.039611, - 1.0682499999999999, 0.2106585, 0.10803, 1.0682499999999999, 0.2106585, 0.17644899999999999, 1.0682499999999999, 0.2106585, 0.2106585, 1.0682499999999999, - 0.0054015000000000044, 0.2106585, 1.0682499999999999, 0.0054015000000000044, 0.0054015000000000053, 1.2818999999999998, 0.2106585, 0.0054015000000000053, - 1.2818999999999998, 0.2106585, 0.039611, 1.2818999999999998, 0.2106585, 0.10803, 1.2818999999999998, 0.2106585, 0.17644899999999999, 1.2818999999999998, - 0.2106585, 0.2106585, 1.2818999999999998, 0.0054015000000000044, 0.2106585, 1.2818999999999998, 0.0054015000000000044, 0.0054015000000000053, 1.2818999999999998, - 0.2106585, 0.0054015000000000053, 1.2818999999999998, 0.2106585, 0.039611, 1.2818999999999998, 0.2106585, 0.10803, 1.2818999999999998, 0.2106585, - 0.17644899999999999, 1.2818999999999998, 0.2106585, 0.2106585, 1.2818999999999998, 0.0054015000000000044, 0.2106585, 1.2818999999999998, 0.0054015000000000044, - 0.0054015000000000053, 1.4955499999999999, 0.2106585, 0.0054015000000000053, 1.4955499999999999, 0.2106585, 0.039611, 1.4955499999999999, 0.2106585, 0.10803, - 1.4955499999999999, 0.2106585, 0.17644899999999999, 1.4955499999999999, 0.2106585, 0.2106585, 1.4955499999999999, 0.0054015000000000044, 0.2106585, - 1.4955499999999999, 0.0054015000000000044, 0.0054015000000000053, 1.4955499999999999, 0.2106585, 0.0054015000000000053, 1.4955499999999999, 0.2106585, 0.039611, - 1.4955499999999999, 0.2106585, 0.10803, 1.4955499999999999, 0.2106585, 0.17644899999999999, 1.4955499999999999, 0.2106585, 0.2106585, 1.4955499999999999, - 0.0054015000000000044, 0.2106585, 1.4955499999999999, 0.0054015000000000044, 0.0054015000000000053, 1.7091999999999998, 0.2106585, 0.0054015000000000053, - 1.7091999999999998, 0.2106585, 0.039611, 1.7091999999999998, 0.2106585, 0.10803, 1.7091999999999998, 0.2106585, 0.17644899999999999, 1.7091999999999998, - 0.2106585, 0.2106585, 1.7091999999999998, 0.0054015000000000044, 0.2106585, 1.7091999999999998, 0.0054015000000000044, 0.0054015000000000053, 1.7091999999999998, - 0.2106585, 0.0054015000000000053, 1.7091999999999998, 0.2106585, 0.039611, 1.7091999999999998, 0.2106585, 0.10803, 1.7091999999999998, 0.2106585, - 0.17644899999999999, 1.7091999999999998, 0.2106585, 0.2106585, 1.7091999999999998, 0.0054015000000000044, 0.2106585, 1.7091999999999998, 0.0054015000000000044, - 0.0054015000000000053, 1.9228499999999997, 0.2106585, 0.0054015000000000053, 1.9228499999999997, 0.2106585, 0.039611, 1.9228499999999997, 0.2106585, 0.10803, - 1.9228499999999997, 0.2106585, 0.17644899999999999, 1.9228499999999997, 0.2106585, 0.2106585, 1.9228499999999997, 0.0054015000000000044, 0.2106585, - 1.9228499999999997, 0.0054015000000000044, 0.0054015000000000053, 1.9228499999999997, 0.2106585, 0.0054015000000000053, 1.9228499999999997, 0.2106585, 0.039611, - 1.9228499999999997, 0.2106585, 0.10803, 1.9228499999999997, 0.2106585, 0.17644899999999999, 1.9228499999999997, 0.2106585, 0.2106585, 1.9228499999999997, - 0.0054015000000000044, 0.2106585, 1.9228499999999997, 0.0054015000000000044, - 0.0054015000000000053, 2.1364999999999998, 0.2106585, 0.0054015000000000053, 2.1364999999999998, 0.2106585, 0.039611, 2.1364999999999998, 0.2106585, - 0.10803, 2.1364999999999998, 0.2106585, 0.17644899999999999, 2.1364999999999998, 0.2106585, 0.2106585, 2.1364999999999998, 0.0054015000000000044, 0.2106585, - 2.1364999999999998, 0.0054015000000000044, 0.0054015000000000053, 2.1364999999999998, 0.2106585, 0.0054015000000000053, 2.1364999999999998, 0.2106585, 0.039611, - 2.1364999999999998, 0.2106585, 0.10803, 2.1364999999999998, 0.2106585, 0.17644899999999999, 2.1364999999999998, 0.2106585, 0.2106585, 2.1364999999999998, - 0.0054015000000000044, 0.2106585, 2.1364999999999998, 0.0054015000000000044, 0.0054015000000000053, 2.3501499999999997, 0.2106585, 0.0054015000000000053, - 2.3501499999999997, 0.2106585, 0.039611, 2.3501499999999997, 0.2106585, 0.10803, 2.3501499999999997, 0.2106585, 0.17644899999999999, 2.3501499999999997, - 0.2106585, 0.2106585, 2.3501499999999997, 0.0054015000000000044, 0.2106585, 2.3501499999999997, 0.0054015000000000044, 0.0054015000000000053, 2.3501499999999997, - 0.2106585, 0.0054015000000000053, 2.3501499999999997, 0.2106585, 0.039611, 2.3501499999999997, 0.2106585, 0.10803, 2.3501499999999997, 0.2106585, - 0.17644899999999999, 2.3501499999999997, 0.2106585, 0.2106585, 2.3501499999999997, 0.0054015000000000044, 0.2106585, 2.3501499999999997, 0.0054015000000000044, - 0.0054015000000000053, 2.5637999999999996, 0.2106585, 0.0054015000000000053, 2.5637999999999996, 0.2106585, 0.039611, 2.5637999999999996, 0.2106585, 0.10803, - 2.5637999999999996, 0.2106585, 0.17644899999999999, 2.5637999999999996, 0.2106585, 0.2106585, 2.5637999999999996, 0.0054015000000000044, 0.2106585, - 2.5637999999999996, 0.0054015000000000044, 0.0054015000000000053, 2.5637999999999996, 0.2106585, 0.0054015000000000053, 2.5637999999999996, 0.2106585, 0.039611, - 2.5637999999999996, 0.2106585, 0.10803, 2.5637999999999996, 0.2106585, 0.17644899999999999, 2.5637999999999996, 0.2106585, 0.2106585, 2.5637999999999996, - 0.0054015000000000044, 0.2106585, 2.5637999999999996, 0.0054015000000000044, 0.0054015000000000053, 2.7774499999999995, 0.2106585, 0.0054015000000000053, - 2.7774499999999995, 0.2106585, 0.039611, 2.7774499999999995, 0.2106585, 0.10803, 2.7774499999999995, 0.2106585, 0.17644899999999999, 2.7774499999999995, - 0.2106585, 0.2106585, 2.7774499999999995, 0.0054015000000000044, 0.2106585, 2.7774499999999995, 0.0054015000000000044, 0.0054015000000000053, 2.7774499999999995, - 0.2106585, 0.0054015000000000053, 2.7774499999999995, 0.2106585, 0.039611, 2.7774499999999995, 0.2106585, 0.10803, 2.7774499999999995, 0.2106585, - 0.17644899999999999, 2.7774499999999995, 0.2106585, 0.2106585, 2.7774499999999995, 0.0054015000000000044, 0.2106585, 2.7774499999999995, 0.0054015000000000044, - 0.0054015000000000053, 2.9910999999999999, 0.2106585, 0.0054015000000000053, 2.9910999999999999, 0.2106585, 0.039611, 2.9910999999999999, 0.2106585, 0.10803, - 2.9910999999999999, 0.2106585, 0.17644899999999999, 2.9910999999999999, 0.2106585, 0.2106585, 2.9910999999999999, 0.0054015000000000044, 0.2106585, - 2.9910999999999999, 0.0054015000000000044, 0.0054015000000000053, 2.9910999999999999, 0.2106585, 0.0054015000000000053, 2.9910999999999999, 0.2106585, 0.039611, - 2.9910999999999999, 0.2106585, 0.10803, 2.9910999999999999, - 0.2106585, 0.17644899999999999, 2.9910999999999999, 0.2106585, 0.2106585, 2.9910999999999999, 0.0054015000000000044, 0.2106585, 2.9910999999999999, - 0.0054015000000000044, 0.0054015000000000053, 3.2047499999999998, 0.2106585, 0.0054015000000000053, 3.2047499999999998, 0.2106585, 0.039611, 3.2047499999999998, - 0.2106585, 0.10803, 3.2047499999999998, 0.2106585, 0.17644899999999999, 3.2047499999999998, 0.2106585, 0.2106585, 3.2047499999999998, 0.0054015000000000044, - 0.2106585, 3.2047499999999998, 0.0054015000000000044, 0.0054015000000000053, 3.2047499999999998, 0.2106585, 0.0054015000000000053, 3.2047499999999998, 0.2106585, - 0.039611, 3.2047499999999998, 0.2106585, 0.10803, 3.2047499999999998, 0.2106585, 0.17644899999999999, 3.2047499999999998, 0.2106585, 0.2106585, - 3.2047499999999998, 0.0054015000000000044, 0.2106585, 3.2047499999999998, 0.0054015000000000044, 0.0054015000000000053, 3.4183999999999997, 0.2106585, - 0.0054015000000000053, 3.4183999999999997, 0.2106585, 0.039611, 3.4183999999999997, 0.2106585, 0.10803, 3.4183999999999997, 0.2106585, 0.17644899999999999, - 3.4183999999999997, 0.2106585, 0.2106585, 3.4183999999999997, 0.0054015000000000044, 0.2106585, 3.4183999999999997, 0.0054015000000000044, 0.0054015000000000053, - 3.4183999999999997, 0.2106585, 0.0054015000000000053, 3.4183999999999997, 0.2106585, 0.039611, 3.4183999999999997, 0.2106585, 0.10803, 3.4183999999999997, - 0.2106585, 0.17644899999999999, 3.4183999999999997, 0.2106585, 0.2106585, 3.4183999999999997, 0.0054015000000000044, 0.2106585, 3.4183999999999997, - 0.0054015000000000044, 0.0054015000000000053, 3.6320499999999996, 0.2106585, 0.0054015000000000053, 3.6320499999999996, 0.2106585, 0.039611, 3.6320499999999996, - 0.2106585, 0.10803, 3.6320499999999996, 0.2106585, 0.17644899999999999, 3.6320499999999996, 0.2106585, 0.2106585, 3.6320499999999996, 0.0054015000000000044, - 0.2106585, 3.6320499999999996, 0.0054015000000000044, 0.0054015000000000053, 3.6320499999999996, 0.2106585, 0.0054015000000000053, 3.6320499999999996, 0.2106585, - 0.039611, 3.6320499999999996, 0.2106585, 0.10803, 3.6320499999999996, 0.2106585, 0.17644899999999999, 3.6320499999999996, 0.2106585, 0.2106585, - 3.6320499999999996, 0.0054015000000000044, 0.2106585, 3.6320499999999996, 0.0054015000000000044, 0.0054015000000000053, 3.8456999999999995, 0.2106585, - 0.0054015000000000053, 3.8456999999999995, 0.2106585, 0.039611, 3.8456999999999995, 0.2106585, 0.10803, 3.8456999999999995, 0.2106585, 0.17644899999999999, - 3.8456999999999995, 0.2106585, 0.2106585, 3.8456999999999995, 0.0054015000000000044, 0.2106585, 3.8456999999999995, 0.0054015000000000044, 0.0054015000000000053, - 3.8456999999999995, 0.2106585, 0.0054015000000000053, 3.8456999999999995, 0.2106585, 0.039611, 3.8456999999999995, 0.2106585, 0.10803, 3.8456999999999995, - 0.2106585, 0.17644899999999999, 3.8456999999999995, 0.2106585, 0.2106585, 3.8456999999999995, 0.0054015000000000044, 0.2106585, 3.8456999999999995, - 0.0054015000000000044, 0.0054015000000000053, 4.0593499999999993, 0.2106585, 0.0054015000000000053, 4.0593499999999993, 0.2106585, 0.039611, 4.0593499999999993, - 0.2106585, 0.10803, 4.0593499999999993, 0.2106585, 0.17644899999999999, 4.0593499999999993, 0.2106585, 0.2106585, 4.0593499999999993, 0.0054015000000000044, - 0.2106585, 4.0593499999999993, 0.0054015000000000044, 0.0054015000000000053, - 4.0593499999999993, 0.2106585, 0.0054015000000000053, 4.0593499999999993, 0.2106585, 0.039611, 4.0593499999999993, 0.2106585, 0.10803, 4.0593499999999993, - 0.2106585, 0.17644899999999999, 4.0593499999999993, 0.2106585, 0.2106585, 4.0593499999999993, 0.0054015000000000044, 0.2106585, 4.0593499999999993, - 0.0054015000000000044, 0.0054015000000000053, 4.2729999999999997, 0.2106585, 0.0054015000000000053, 4.2729999999999997, 0.2106585, 0.039611, 4.2729999999999997, - 0.2106585, 0.10803, 4.2729999999999997, 0.2106585, 0.17644899999999999, 4.2729999999999997, 0.2106585, 0.2106585, 4.2729999999999997, 0.0054015000000000044, - 0.2106585, 4.2729999999999997, 0.24197569714517145, 0.025915697145171439, 0, 0.26483839536511933, 0.025915697145171439, 0, 0.26483839536511933, - 0.048778395365119298, 0, 0.24197569714517145, 0.048778395365119298, 0, 0.24197569714517145, 0.025915697145171439, 0.21364999999999998, 0.26483839536511933, - 0.025915697145171439, 0.21364999999999998, 0.26483839536511933, 0.048778395365119298, 0.21364999999999998, 0.24197569714517145, 0.048778395365119298, - 0.21364999999999998, 0.24197569714517145, 0.025915697145171439, 0.21364999999999998, 0.26483839536511933, 0.025915697145171439, 0.21364999999999998, - 0.26483839536511933, 0.048778395365119298, 0.21364999999999998, 0.24197569714517145, 0.048778395365119298, 0.21364999999999998, 0.24197569714517145, - 0.025915697145171439, 0.42729999999999996, 0.26483839536511933, 0.025915697145171439, 0.42729999999999996, 0.26483839536511933, 0.048778395365119298, - 0.42729999999999996, 0.24197569714517145, 0.048778395365119298, 0.42729999999999996, 0.24197569714517145, 0.025915697145171439, 0.42729999999999996, - 0.26483839536511933, 0.025915697145171439, 0.42729999999999996, 0.26483839536511933, 0.048778395365119298, 0.42729999999999996, 0.24197569714517145, - 0.048778395365119298, 0.42729999999999996, 0.24197569714517145, 0.025915697145171439, 0.64094999999999991, 0.26483839536511933, 0.025915697145171439, - 0.64094999999999991, 0.26483839536511933, 0.048778395365119298, 0.64094999999999991, 0.24197569714517145, 0.048778395365119298, 0.64094999999999991, - 0.24197569714517145, 0.025915697145171439, 0.64094999999999991, 0.26483839536511933, 0.025915697145171439, 0.64094999999999991, 0.26483839536511933, - 0.048778395365119298, 0.64094999999999991, 0.24197569714517145, 0.048778395365119298, 0.64094999999999991, 0.24197569714517145, 0.025915697145171439, - 0.85459999999999992, 0.26483839536511933, 0.025915697145171439, 0.85459999999999992, 0.26483839536511933, 0.048778395365119298, 0.85459999999999992, - 0.24197569714517145, 0.048778395365119298, 0.85459999999999992, 0.24197569714517145, 0.025915697145171439, 0.85459999999999992, 0.26483839536511933, - 0.025915697145171439, 0.85459999999999992, 0.26483839536511933, 0.048778395365119298, 0.85459999999999992, 0.24197569714517145, 0.048778395365119298, - 0.85459999999999992, 0.24197569714517145, 0.025915697145171439, 1.0682499999999999, 0.26483839536511933, 0.025915697145171439, 1.0682499999999999, - 0.26483839536511933, 0.048778395365119298, 1.0682499999999999, 0.24197569714517145, 0.048778395365119298, 1.0682499999999999, 0.24197569714517145, - 0.025915697145171439, 1.0682499999999999, 0.26483839536511933, 0.025915697145171439, 1.0682499999999999, 0.26483839536511933, 0.048778395365119298, - 1.0682499999999999, 0.24197569714517145, 0.048778395365119298, 1.0682499999999999, 0.24197569714517145, 0.025915697145171439, 1.2818999999999998, - 0.26483839536511933, 0.025915697145171439, 1.2818999999999998, 0.26483839536511933, 0.048778395365119298, 1.2818999999999998, 0.24197569714517145, - 0.048778395365119298, 1.2818999999999998, 0.24197569714517145, 0.025915697145171439, 1.2818999999999998, 0.26483839536511933, 0.025915697145171439, - 1.2818999999999998, 0.26483839536511933, 0.048778395365119298, 1.2818999999999998, 0.24197569714517145, 0.048778395365119298, 1.2818999999999998, - 0.24197569714517145, 0.025915697145171439, 1.4955499999999999, 0.26483839536511933,0.025915697145171439, 1.4955499999999999, 0.26483839536511933, - 0.048778395365119298, 1.4955499999999999, 0.24197569714517145, 0.048778395365119298, - 1.4955499999999999, 0.24197569714517145, 0.025915697145171439, 1.4955499999999999, 0.26483839536511933, 0.025915697145171439, 1.4955499999999999, - 0.26483839536511933, 0.048778395365119298, 1.4955499999999999, 0.24197569714517145, 0.048778395365119298, 1.4955499999999999, 0.24197569714517145, - 0.025915697145171439, 1.7091999999999998, 0.26483839536511933, 0.025915697145171439, 1.7091999999999998, 0.26483839536511933, 0.048778395365119298, - 1.7091999999999998, 0.24197569714517145, 0.048778395365119298, 1.7091999999999998, 0.24197569714517145, 0.025915697145171439, 1.7091999999999998, - 0.26483839536511933, 0.025915697145171439, 1.7091999999999998, 0.26483839536511933, 0.048778395365119298, 1.7091999999999998, 0.24197569714517145, - 0.048778395365119298, 1.7091999999999998, 0.24197569714517145, 0.025915697145171439, 1.9228499999999997, 0.26483839536511933, 0.025915697145171439, - 1.9228499999999997, 0.26483839536511933, 0.048778395365119298, 1.9228499999999997, 0.24197569714517145, 0.048778395365119298, 1.9228499999999997, - 0.24197569714517145, 0.025915697145171439, 1.9228499999999997, 0.26483839536511933, 0.025915697145171439, 1.9228499999999997, 0.26483839536511933, - 0.048778395365119298, 1.9228499999999997, 0.24197569714517145, 0.048778395365119298, 1.9228499999999997, 0.24197569714517145, 0.025915697145171439, - 2.1364999999999998, 0.26483839536511933, 0.025915697145171439, 2.1364999999999998, 0.26483839536511933, 0.048778395365119298, 2.1364999999999998, - 0.24197569714517145, 0.048778395365119298, 2.1364999999999998, 0.24197569714517145, 0.025915697145171439, 2.1364999999999998, 0.26483839536511933, - 0.025915697145171439, 2.1364999999999998, 0.26483839536511933, 0.048778395365119298, 2.1364999999999998, 0.24197569714517145, 0.048778395365119298, - 2.1364999999999998, 0.24197569714517145, 0.025915697145171439, 2.3501499999999997, 0.26483839536511933, 0.025915697145171439, 2.3501499999999997, - 0.26483839536511933, 0.048778395365119298, 2.3501499999999997, 0.24197569714517145, 0.048778395365119298, 2.3501499999999997, 0.24197569714517145, - 0.025915697145171439, 2.3501499999999997, 0.26483839536511933, 0.025915697145171439, 2.3501499999999997, 0.26483839536511933, 0.048778395365119298, - 2.3501499999999997, 0.24197569714517145, 0.048778395365119298, 2.3501499999999997, 0.24197569714517145, 0.025915697145171439, 2.5637999999999996, - 0.26483839536511933, 0.025915697145171439, 2.5637999999999996, 0.26483839536511933, 0.048778395365119298, 2.5637999999999996, 0.24197569714517145, - 0.048778395365119298, 2.5637999999999996, 0.24197569714517145, 0.025915697145171439, 2.5637999999999996, 0.26483839536511933, 0.025915697145171439, - 2.5637999999999996, 0.26483839536511933, 0.048778395365119298, 2.5637999999999996, 0.24197569714517145, 0.048778395365119298, 2.5637999999999996, - 0.24197569714517145, 0.025915697145171439, 2.7774499999999995, 0.26483839536511933, 0.025915697145171439, 2.7774499999999995, 0.26483839536511933, - 0.048778395365119298, 2.7774499999999995, 0.24197569714517145, 0.048778395365119298, 2.7774499999999995, 0.24197569714517145, 0.025915697145171439, - 2.7774499999999995, 0.26483839536511933, 0.025915697145171439, 2.7774499999999995, 0.26483839536511933, 0.048778395365119298, 2.7774499999999995, - 0.24197569714517145, 0.048778395365119298, 2.7774499999999995, 0.24197569714517145, 0.025915697145171439, 2.9910999999999999, 0.26483839536511933, - 0.025915697145171439, 2.9910999999999999, 0.26483839536511933, 0.048778395365119298, 2.9910999999999999, 0.24197569714517145, 0.048778395365119298, - 2.9910999999999999, 0.24197569714517145, 0.025915697145171439, 2.9910999999999999, 0.26483839536511933, 0.025915697145171439, 2.9910999999999999, - 0.26483839536511933, 0.048778395365119298, 2.9910999999999999, 0.24197569714517145, 0.048778395365119298, 2.9910999999999999, 0.24197569714517145, - 0.025915697145171439, 3.2047499999999998, 0.26483839536511933, 0.025915697145171439, 3.2047499999999998, 0.26483839536511933, 0.048778395365119298, - 3.2047499999999998, 0.24197569714517145, 0.048778395365119298, 3.2047499999999998, - 0.24197569714517145, 0.025915697145171439, 3.2047499999999998, 0.26483839536511933, 0.025915697145171439, 3.2047499999999998, 0.26483839536511933, - 0.048778395365119298, 3.2047499999999998, 0.24197569714517145, 0.048778395365119298, 3.2047499999999998, 0.24197569714517145, 0.025915697145171439, - 3.4183999999999997, 0.26483839536511933, 0.025915697145171439, 3.4183999999999997, 0.26483839536511933, 0.048778395365119298, 3.4183999999999997, - 0.24197569714517145, 0.048778395365119298, 3.4183999999999997, 0.24197569714517145, 0.025915697145171439, 3.4183999999999997, 0.26483839536511933, - 0.025915697145171439, 3.4183999999999997, 0.26483839536511933, 0.048778395365119298, 3.4183999999999997, 0.24197569714517145, 0.048778395365119298, - 3.4183999999999997, 0.24197569714517145, 0.025915697145171439, 3.6320499999999996, 0.26483839536511933, 0.025915697145171439, 3.6320499999999996, - 0.26483839536511933, 0.048778395365119298, 3.6320499999999996, 0.24197569714517145, 0.048778395365119298, 3.6320499999999996, 0.24197569714517145, - 0.025915697145171439, 3.6320499999999996, 0.26483839536511933, 0.025915697145171439, 3.6320499999999996, 0.26483839536511933, 0.048778395365119298, - 3.6320499999999996, 0.24197569714517145, 0.048778395365119298, 3.6320499999999996, 0.24197569714517145, 0.025915697145171439, 3.8456999999999995, - 0.26483839536511933, 0.025915697145171439, 3.8456999999999995, 0.26483839536511933, 0.048778395365119298, 3.8456999999999995, 0.24197569714517145, - 0.048778395365119298, 3.8456999999999995, 0.24197569714517145, 0.025915697145171439, 3.8456999999999995, 0.26483839536511933, 0.025915697145171439, - 3.8456999999999995, 0.26483839536511933, 0.048778395365119298, 3.8456999999999995, 0.24197569714517145, 0.048778395365119298, 3.8456999999999995, - 0.24197569714517145, 0.025915697145171439, 4.0593499999999993, 0.26483839536511933, 0.025915697145171439, 4.0593499999999993, 0.26483839536511933, - 0.048778395365119298, 4.0593499999999993, 0.24197569714517145, 0.048778395365119298, 4.0593499999999993, 0.24197569714517145, 0.025915697145171439, - 4.0593499999999993, 0.26483839536511933, 0.025915697145171439, 4.0593499999999993, 0.26483839536511933, 0.048778395365119298, 4.0593499999999993, - 0.24197569714517145, 0.048778395365119298, 4.0593499999999993, 0.24197569714517145, 0.025915697145171439, 4.2729999999999997, 0.26483839536511933, - 0.025915697145171439, 4.2729999999999997, 0.26483839536511933, 0.048778395365119298, 4.2729999999999997, 0.24197569714517145, 0.048778395365119298, - 4.2729999999999997, 0.31132160463488068, 0.029625802317440348, 0, 0.3368583953651193, 0.029625802317440348, 0, 0.3368583953651193, 0.046104302854828562, 0, - 0.31132160463488068, 0.046104302854828562, 0, 0.31132160463488068, 0.029625802317440348, 0.21364999999999998, 0.3368583953651193, 0.029625802317440348, - 0.21364999999999998, 0.3368583953651193, 0.046104302854828562, 0.21364999999999998, 0.31132160463488068, 0.046104302854828562, 0.21364999999999998, - 0.31132160463488068, 0.029625802317440348, 0.21364999999999998, 0.3368583953651193, 0.029625802317440348, 0.21364999999999998, 0.3368583953651193, - 0.046104302854828562, 0.21364999999999998, 0.31132160463488068, 0.046104302854828562, 0.21364999999999998, 0.31132160463488068, 0.029625802317440348, - 0.42729999999999996, 0.3368583953651193, 0.029625802317440348, 0.42729999999999996, 0.3368583953651193, 0.046104302854828562, 0.42729999999999996, - 0.31132160463488068, 0.046104302854828562, 0.42729999999999996, 0.31132160463488068, 0.029625802317440348, 0.42729999999999996, 0.3368583953651193, - 0.029625802317440348, 0.42729999999999996, 0.3368583953651193, 0.046104302854828562, 0.42729999999999996, 0.31132160463488068, 0.046104302854828562, - 0.42729999999999996, 0.31132160463488068, 0.029625802317440348, 0.64094999999999991, 0.3368583953651193, 0.029625802317440348, 0.64094999999999991, - 0.3368583953651193, 0.046104302854828562, 0.64094999999999991, 0.31132160463488068, 0.046104302854828562, 0.64094999999999991, 0.31132160463488068, - 0.029625802317440348, 0.64094999999999991, 0.3368583953651193, 0.029625802317440348, 0.64094999999999991, 0.3368583953651193, 0.046104302854828562, - 0.64094999999999991, 0.31132160463488068, 0.046104302854828562, 0.64094999999999991, 0.31132160463488068, 0.029625802317440348, 0.85459999999999992, - 0.3368583953651193, 0.029625802317440348, 0.85459999999999992, 0.3368583953651193, 0.046104302854828562, 0.85459999999999992, 0.31132160463488068, - 0.046104302854828562, 0.85459999999999992, 0.31132160463488068, 0.029625802317440348, 0.85459999999999992, 0.3368583953651193, 0.029625802317440348, - 0.85459999999999992, 0.3368583953651193, 0.046104302854828562, 0.85459999999999992, 0.31132160463488068, 0.046104302854828562, 0.85459999999999992, - 0.31132160463488068, 0.029625802317440348, 1.0682499999999999, 0.3368583953651193, 0.029625802317440348, 1.0682499999999999, 0.3368583953651193, - 0.046104302854828562, 1.0682499999999999, 0.31132160463488068, 0.046104302854828562, 1.0682499999999999, 0.31132160463488068, 0.029625802317440348, - 1.0682499999999999, 0.3368583953651193, 0.029625802317440348, 1.0682499999999999, 0.3368583953651193, 0.046104302854828562, 1.0682499999999999, - 0.31132160463488068, 0.046104302854828562, 1.0682499999999999, 0.31132160463488068, 0.029625802317440348, 1.2818999999999998, 0.3368583953651193, - 0.029625802317440348, 1.2818999999999998, 0.3368583953651193, 0.046104302854828562, 1.2818999999999998, 0.31132160463488068, 0.046104302854828562, - 1.2818999999999998, 0.31132160463488068, 0.029625802317440348, 1.2818999999999998, 0.3368583953651193, 0.029625802317440348, 1.2818999999999998, - 0.3368583953651193, 0.046104302854828562, 1.2818999999999998, 0.31132160463488068, 0.046104302854828562, 1.2818999999999998, 0.31132160463488068, - 0.029625802317440348, 1.4955499999999999, 0.3368583953651193, 0.029625802317440348, 1.4955499999999999, 0.3368583953651193, 0.046104302854828562, - 1.4955499999999999, 0.31132160463488068, 0.046104302854828562, 1.4955499999999999, 0.31132160463488068, 0.029625802317440348, 1.4955499999999999, - 0.3368583953651193, 0.029625802317440348, 1.4955499999999999, 0.3368583953651193, 0.046104302854828562, 1.4955499999999999, 0.31132160463488068, - 0.046104302854828562, 1.4955499999999999, 0.31132160463488068, 0.029625802317440348, 1.7091999999999998, 0.3368583953651193, 0.029625802317440348, - 1.7091999999999998, 0.3368583953651193, 0.046104302854828562, 1.7091999999999998, 0.31132160463488068, 0.046104302854828562, 1.7091999999999998, - 0.31132160463488068, 0.029625802317440348, 1.7091999999999998, 0.3368583953651193, 0.029625802317440348, 1.7091999999999998, 0.3368583953651193, - 0.046104302854828562, 1.7091999999999998, 0.31132160463488068, 0.046104302854828562, 1.7091999999999998, 0.31132160463488068, 0.029625802317440348, - 1.9228499999999997, 0.3368583953651193, 0.029625802317440348, 1.9228499999999997, 0.3368583953651193, 0.046104302854828562, 1.9228499999999997, - 0.31132160463488068, 0.046104302854828562, 1.9228499999999997, 0.31132160463488068, 0.029625802317440348, 1.9228499999999997, 0.3368583953651193, - 0.029625802317440348, 1.9228499999999997, 0.3368583953651193, 0.046104302854828562, 1.9228499999999997, 0.31132160463488068, 0.046104302854828562, - 1.9228499999999997, 0.31132160463488068, 0.029625802317440348, 2.1364999999999998, 0.3368583953651193, 0.029625802317440348, 2.1364999999999998, - 0.3368583953651193, 0.046104302854828562, 2.1364999999999998, 0.31132160463488068, 0.046104302854828562, 2.1364999999999998, 0.31132160463488068, - 0.029625802317440348, 2.1364999999999998, 0.3368583953651193, 0.029625802317440348, 2.1364999999999998, 0.3368583953651193, 0.046104302854828562, - 2.1364999999999998, 0.31132160463488068, 0.046104302854828562, 2.1364999999999998, 0.31132160463488068, 0.029625802317440348, 2.3501499999999997, - 0.3368583953651193, 0.029625802317440348, 2.3501499999999997, 0.3368583953651193, 0.046104302854828562, 2.3501499999999997, 0.31132160463488068, - 0.046104302854828562, 2.3501499999999997, 0.31132160463488068, 0.029625802317440348, 2.3501499999999997, 0.3368583953651193, 0.029625802317440348, - 2.3501499999999997, 0.3368583953651193, 0.046104302854828562, 2.3501499999999997, 0.31132160463488068, 0.046104302854828562, 2.3501499999999997, - 0.31132160463488068, 0.029625802317440348, 2.5637999999999996, 0.3368583953651193, - 0.029625802317440348, 2.5637999999999996, 0.3368583953651193, 0.046104302854828562, 2.5637999999999996, 0.31132160463488068, 0.046104302854828562, - 2.5637999999999996, 0.31132160463488068, 0.029625802317440348, 2.5637999999999996, 0.3368583953651193, 0.029625802317440348, 2.5637999999999996, - 0.3368583953651193, 0.046104302854828562, 2.5637999999999996, 0.31132160463488068, 0.046104302854828562, 2.5637999999999996, 0.31132160463488068, - 0.029625802317440348, 2.7774499999999995, 0.3368583953651193, 0.029625802317440348, 2.7774499999999995, 0.3368583953651193, 0.046104302854828562, - 2.7774499999999995, 0.31132160463488068, 0.046104302854828562, 2.7774499999999995, 0.31132160463488068, 0.029625802317440348, 2.7774499999999995, - 0.3368583953651193, 0.029625802317440348, 2.7774499999999995, 0.3368583953651193, 0.046104302854828562, 2.7774499999999995, 0.31132160463488068, - 0.046104302854828562, 2.7774499999999995, 0.31132160463488068, 0.029625802317440348, 2.9910999999999999, 0.3368583953651193, 0.029625802317440348, - 2.9910999999999999, 0.3368583953651193, 0.046104302854828562, 2.9910999999999999, 0.31132160463488068, 0.046104302854828562, 2.9910999999999999, - 0.31132160463488068, 0.029625802317440348, 2.9910999999999999, 0.3368583953651193, 0.029625802317440348, 2.9910999999999999, 0.3368583953651193, - 0.046104302854828562, 2.9910999999999999, 0.31132160463488068, 0.046104302854828562, 2.9910999999999999, 0.31132160463488068, 0.029625802317440348, - 3.2047499999999998, 0.3368583953651193, 0.029625802317440348, 3.2047499999999998, 0.3368583953651193, 0.046104302854828562, 3.2047499999999998, - 0.31132160463488068, 0.046104302854828562, 3.2047499999999998, 0.31132160463488068, 0.029625802317440348, 3.2047499999999998, 0.3368583953651193, - 0.029625802317440348, 3.2047499999999998, 0.3368583953651193, 0.046104302854828562, 3.2047499999999998, 0.31132160463488068, 0.046104302854828562, - 3.2047499999999998, 0.31132160463488068, 0.029625802317440348, 3.4183999999999997, 0.3368583953651193, 0.029625802317440348, 3.4183999999999997, - 0.3368583953651193, 0.046104302854828562, 3.4183999999999997, 0.31132160463488068, 0.046104302854828562, 3.4183999999999997, 0.31132160463488068, - 0.029625802317440348, 3.4183999999999997, 0.3368583953651193, 0.029625802317440348, 3.4183999999999997, 0.3368583953651193, 0.046104302854828562, - 3.4183999999999997, 0.31132160463488068, 0.046104302854828562, 3.4183999999999997, 0.31132160463488068, 0.029625802317440348, 3.6320499999999996, - 0.3368583953651193, 0.029625802317440348, 3.6320499999999996, 0.3368583953651193, 0.046104302854828562, 3.6320499999999996, 0.31132160463488068, - 0.046104302854828562, 3.6320499999999996, 0.31132160463488068, 0.029625802317440348, 3.6320499999999996, 0.3368583953651193, 0.029625802317440348, - 3.6320499999999996, 0.3368583953651193, 0.046104302854828562, 3.6320499999999996, 0.31132160463488068, 0.046104302854828562, 3.6320499999999996, - 0.31132160463488068, 0.029625802317440348, 3.8456999999999995, 0.3368583953651193, 0.029625802317440348, 3.8456999999999995, 0.3368583953651193, - 0.046104302854828562, 3.8456999999999995, 0.31132160463488068, 0.046104302854828562, 3.8456999999999995, 0.31132160463488068, 0.029625802317440348, - 3.8456999999999995, 0.3368583953651193, 0.029625802317440348, 3.8456999999999995, 0.3368583953651193, 0.046104302854828562, 3.8456999999999995, - 0.31132160463488068, 0.046104302854828562, 3.8456999999999995, 0.31132160463488068, 0.029625802317440348, 4.0593499999999993, 0.3368583953651193, - 0.029625802317440348, 4.0593499999999993, 0.3368583953651193, 0.046104302854828562, 4.0593499999999993, 0.31132160463488068, 0.046104302854828562, - 4.0593499999999993, 0.31132160463488068, 0.029625802317440348, 4.0593499999999993, 0.3368583953651193, 0.029625802317440348, 4.0593499999999993, - 0.3368583953651193, 0.046104302854828562, 4.0593499999999993, 0.31132160463488068, 0.046104302854828562, 4.0593499999999993, 0.31132160463488068, - 0.029625802317440348, 4.2729999999999997, 0.3368583953651193, 0.029625802317440348, 4.2729999999999997, 0.3368583953651193, 0.046104302854828562, - 4.2729999999999997, 0.31132160463488068, 0.046104302854828562, 4.2729999999999997, - 0.38334160463488065, 0.025915697145171453, 0, 0.40620430285482856, 0.025915697145171453, 0, 0.40620430285482856, 0.048778395365119291, 0, - 0.38334160463488065, 0.048778395365119291, 0, 0.38334160463488065, 0.025915697145171453, 0.21364999999999998, 0.40620430285482856, 0.025915697145171453, - 0.21364999999999998, 0.40620430285482856, 0.048778395365119291, 0.21364999999999998, 0.38334160463488065, 0.048778395365119291, 0.21364999999999998, - 0.38334160463488065, 0.025915697145171453, 0.21364999999999998, 0.40620430285482856, 0.025915697145171453, 0.21364999999999998, 0.40620430285482856, - 0.048778395365119291, 0.21364999999999998, 0.38334160463488065, 0.048778395365119291, 0.21364999999999998, 0.38334160463488065, 0.025915697145171453, - 0.42729999999999996, 0.40620430285482856, 0.025915697145171453, 0.42729999999999996, 0.40620430285482856, 0.048778395365119291, 0.42729999999999996, - 0.38334160463488065, 0.048778395365119291, 0.42729999999999996, 0.38334160463488065, 0.025915697145171453, 0.42729999999999996, 0.40620430285482856, - 0.025915697145171453, 0.42729999999999996, 0.40620430285482856, 0.048778395365119291, 0.42729999999999996, 0.38334160463488065, 0.048778395365119291, - 0.42729999999999996, 0.38334160463488065, 0.025915697145171453, 0.64094999999999991, 0.40620430285482856, 0.025915697145171453, 0.64094999999999991, - 0.40620430285482856, 0.048778395365119291, 0.64094999999999991, 0.38334160463488065, 0.048778395365119291, 0.64094999999999991, 0.38334160463488065, - 0.025915697145171453, 0.64094999999999991, 0.40620430285482856, 0.025915697145171453, 0.64094999999999991, 0.40620430285482856, 0.048778395365119291, - 0.64094999999999991, 0.38334160463488065, 0.048778395365119291, 0.64094999999999991, 0.38334160463488065, 0.025915697145171453, 0.85459999999999992, - 0.40620430285482856, 0.025915697145171453, 0.85459999999999992, 0.40620430285482856, 0.048778395365119291, 0.85459999999999992, 0.38334160463488065, - 0.048778395365119291, 0.85459999999999992, 0.38334160463488065, 0.025915697145171453, 0.85459999999999992, 0.40620430285482856, 0.025915697145171453, - 0.85459999999999992, 0.40620430285482856, 0.048778395365119291, 0.85459999999999992, 0.38334160463488065, 0.048778395365119291, 0.85459999999999992, - 0.38334160463488065, 0.025915697145171453, 1.0682499999999999, 0.40620430285482856, 0.025915697145171453, 1.0682499999999999, 0.40620430285482856, - 0.048778395365119291, 1.0682499999999999, 0.38334160463488065, 0.048778395365119291, 1.0682499999999999, 0.38334160463488065, 0.025915697145171453, - 1.0682499999999999, 0.40620430285482856, 0.025915697145171453, 1.0682499999999999, 0.40620430285482856, 0.048778395365119291, 1.0682499999999999, - 0.38334160463488065, 0.048778395365119291, 1.0682499999999999, 0.38334160463488065, 0.025915697145171453, 1.2818999999999998, 0.40620430285482856, - 0.025915697145171453, 1.2818999999999998, 0.40620430285482856, 0.048778395365119291, 1.2818999999999998, 0.38334160463488065, 0.048778395365119291, - 1.2818999999999998, 0.38334160463488065, 0.025915697145171453, 1.2818999999999998, 0.40620430285482856, 0.025915697145171453, 1.2818999999999998, - 0.40620430285482856, 0.048778395365119291, 1.2818999999999998, 0.38334160463488065, 0.048778395365119291, 1.2818999999999998, 0.38334160463488065, - 0.025915697145171453, 1.4955499999999999, 0.40620430285482856, 0.025915697145171453, 1.4955499999999999, 0.40620430285482856, 0.048778395365119291, - 1.4955499999999999, 0.38334160463488065, 0.048778395365119291, 1.4955499999999999, 0.38334160463488065, 0.025915697145171453, 1.4955499999999999, - 0.40620430285482856, 0.025915697145171453, 1.4955499999999999, 0.40620430285482856, 0.048778395365119291, 1.4955499999999999, 0.38334160463488065, - 0.048778395365119291, 1.4955499999999999, 0.38334160463488065, 0.025915697145171453, 1.7091999999999998, 0.40620430285482856, 0.025915697145171453, - 1.7091999999999998, 0.40620430285482856, 0.048778395365119291, 1.7091999999999998, 0.38334160463488065, 0.048778395365119291, 1.7091999999999998, - 0.38334160463488065, 0.025915697145171453, 1.7091999999999998, 0.40620430285482856, 0.025915697145171453, 1.7091999999999998, 0.40620430285482856, - 0.048778395365119291, - 1.7091999999999998, 0.38334160463488065, 0.048778395365119291, 1.7091999999999998, 0.38334160463488065, 0.025915697145171453, 1.9228499999999997, - 0.40620430285482856, 0.025915697145171453, 1.9228499999999997, 0.40620430285482856, 0.048778395365119291, 1.9228499999999997, 0.38334160463488065, - 0.048778395365119291, 1.9228499999999997, 0.38334160463488065, 0.025915697145171453, 1.9228499999999997, 0.40620430285482856, 0.025915697145171453, - 1.9228499999999997, 0.40620430285482856, 0.048778395365119291, 1.9228499999999997, 0.38334160463488065, 0.048778395365119291, 1.9228499999999997, - 0.38334160463488065, 0.025915697145171453, 2.1364999999999998, 0.40620430285482856, 0.025915697145171453, 2.1364999999999998, 0.40620430285482856, - 0.048778395365119291, 2.1364999999999998, 0.38334160463488065, 0.048778395365119291, 2.1364999999999998, 0.38334160463488065, 0.025915697145171453, - 2.1364999999999998, 0.40620430285482856, 0.025915697145171453, 2.1364999999999998, 0.40620430285482856, 0.048778395365119291, 2.1364999999999998, - 0.38334160463488065, 0.048778395365119291, 2.1364999999999998, 0.38334160463488065, 0.025915697145171453, 2.3501499999999997, 0.40620430285482856, - 0.025915697145171453, 2.3501499999999997, 0.40620430285482856, 0.048778395365119291, 2.3501499999999997, 0.38334160463488065, 0.048778395365119291, - 2.3501499999999997, 0.38334160463488065, 0.025915697145171453, 2.3501499999999997, 0.40620430285482856, 0.025915697145171453, 2.3501499999999997, - 0.40620430285482856, 0.048778395365119291, 2.3501499999999997, 0.38334160463488065, 0.048778395365119291, 2.3501499999999997, 0.38334160463488065, - 0.025915697145171453, 2.5637999999999996, 0.40620430285482856, 0.025915697145171453, 2.5637999999999996, 0.40620430285482856, 0.048778395365119291, - 2.5637999999999996, 0.38334160463488065, 0.048778395365119291, 2.5637999999999996, 0.38334160463488065, 0.025915697145171453, 2.5637999999999996, - 0.40620430285482856, 0.025915697145171453, 2.5637999999999996, 0.40620430285482856, 0.048778395365119291, 2.5637999999999996, 0.38334160463488065, - 0.048778395365119291, 2.5637999999999996, 0.38334160463488065, 0.025915697145171453, 2.7774499999999995, 0.40620430285482856, 0.025915697145171453, - 2.7774499999999995, 0.40620430285482856, 0.048778395365119291, 2.7774499999999995, 0.38334160463488065, 0.048778395365119291, 2.7774499999999995, - 0.38334160463488065, 0.025915697145171453, 2.7774499999999995, 0.40620430285482856, 0.025915697145171453, 2.7774499999999995, 0.40620430285482856, - 0.048778395365119291, 2.7774499999999995, 0.38334160463488065, 0.048778395365119291, 2.7774499999999995, 0.38334160463488065, 0.025915697145171453, - 2.9910999999999999, 0.40620430285482856, 0.025915697145171453, 2.9910999999999999, 0.40620430285482856, 0.048778395365119291, 2.9910999999999999, - 0.38334160463488065, 0.048778395365119291, 2.9910999999999999, 0.38334160463488065, 0.025915697145171453, 2.9910999999999999, 0.40620430285482856, - 0.025915697145171453, 2.9910999999999999, 0.40620430285482856, 0.048778395365119291, 2.9910999999999999, 0.38334160463488065, 0.048778395365119291, - 2.9910999999999999, 0.38334160463488065, 0.025915697145171453, 3.2047499999999998, 0.40620430285482856, 0.025915697145171453, 3.2047499999999998, - 0.40620430285482856, 0.048778395365119291, 3.2047499999999998, 0.38334160463488065, 0.048778395365119291, 3.2047499999999998, 0.38334160463488065, - 0.025915697145171453, 3.2047499999999998, 0.40620430285482856, 0.025915697145171453, 3.2047499999999998, 0.40620430285482856, 0.048778395365119291, - 3.2047499999999998, 0.38334160463488065, 0.048778395365119291, 3.2047499999999998, 0.38334160463488065, 0.025915697145171453, 3.4183999999999997, - 0.40620430285482856, 0.025915697145171453, 3.4183999999999997, 0.40620430285482856, 0.048778395365119291, 3.4183999999999997, 0.38334160463488065, - 0.048778395365119291, 3.4183999999999997, 0.38334160463488065, 0.025915697145171453, 3.4183999999999997, 0.40620430285482856, 0.025915697145171453, - 3.4183999999999997, 0.40620430285482856, 0.048778395365119291, 3.4183999999999997, 0.38334160463488065, 0.048778395365119291, 3.4183999999999997, - 0.38334160463488065, 0.025915697145171453, 3.6320499999999996, 0.40620430285482856, - 0.025915697145171453, 3.6320499999999996, 0.40620430285482856, 0.048778395365119291, 3.6320499999999996, 0.38334160463488065, 0.048778395365119291, - 3.6320499999999996, 0.38334160463488065, 0.025915697145171453, 3.6320499999999996, 0.40620430285482856, 0.025915697145171453, 3.6320499999999996, - 0.40620430285482856, 0.048778395365119291, 3.6320499999999996, 0.38334160463488065, 0.048778395365119291, 3.6320499999999996, 0.38334160463488065, - 0.025915697145171453, 3.8456999999999995, 0.40620430285482856, 0.025915697145171453, 3.8456999999999995, 0.40620430285482856, 0.048778395365119291, - 3.8456999999999995, 0.38334160463488065, 0.048778395365119291, 3.8456999999999995, 0.38334160463488065, 0.025915697145171453, 3.8456999999999995, - 0.40620430285482856, 0.025915697145171453, 3.8456999999999995, 0.40620430285482856, 0.048778395365119291, 3.8456999999999995, 0.38334160463488065, - 0.048778395365119291, 3.8456999999999995, 0.38334160463488065, 0.025915697145171453, 4.0593499999999993, 0.40620430285482856, 0.025915697145171453, - 4.0593499999999993, 0.40620430285482856, 0.048778395365119291, 4.0593499999999993, 0.38334160463488065, 0.048778395365119291, 4.0593499999999993, - 0.38334160463488065, 0.025915697145171453, 4.0593499999999993, 0.40620430285482856, 0.025915697145171453, 4.0593499999999993, 0.40620430285482856, - 0.048778395365119291, 4.0593499999999993, 0.38334160463488065, 0.048778395365119291, 4.0593499999999993, 0.38334160463488065, 0.025915697145171453, - 4.2729999999999997, 0.40620430285482856, 0.025915697145171453, 4.2729999999999997, 0.40620430285482856, 0.048778395365119291, 4.2729999999999997, - 0.38334160463488065, 0.048778395365119291, 4.2729999999999997, 0.24568580231744036, 0.095261604634880703, 0, 0.26216430285482856, 0.095261604634880703, 0, - 0.26216430285482856, 0.1207983953651193, 0, 0.24568580231744036, 0.1207983953651193, 0, 0.24568580231744036, 0.095261604634880703, 0.21364999999999998, - 0.26216430285482856, 0.095261604634880703, 0.21364999999999998, 0.26216430285482856, 0.1207983953651193, 0.21364999999999998, 0.24568580231744036, - 0.1207983953651193, 0.21364999999999998, 0.24568580231744036, 0.095261604634880703, 0.21364999999999998, 0.26216430285482856, 0.095261604634880703, - 0.21364999999999998, 0.26216430285482856, 0.1207983953651193, 0.21364999999999998, 0.24568580231744036, 0.1207983953651193, 0.21364999999999998, - 0.24568580231744036, 0.095261604634880703, 0.42729999999999996, 0.26216430285482856, 0.095261604634880703, 0.42729999999999996, 0.26216430285482856, - 0.1207983953651193, 0.42729999999999996, 0.24568580231744036, 0.1207983953651193, 0.42729999999999996, 0.24568580231744036, 0.095261604634880703, - 0.42729999999999996, 0.26216430285482856, 0.095261604634880703, 0.42729999999999996, 0.26216430285482856, 0.1207983953651193, 0.42729999999999996, - 0.24568580231744036, 0.1207983953651193, 0.42729999999999996, 0.24568580231744036, 0.095261604634880703, 0.64094999999999991, 0.26216430285482856, - 0.095261604634880703, 0.64094999999999991, 0.26216430285482856, 0.1207983953651193, 0.64094999999999991, 0.24568580231744036, 0.1207983953651193, - 0.64094999999999991, 0.24568580231744036, 0.095261604634880703, 0.64094999999999991, 0.26216430285482856, 0.095261604634880703, 0.64094999999999991, - 0.26216430285482856, 0.1207983953651193, 0.64094999999999991, 0.24568580231744036, 0.1207983953651193, 0.64094999999999991, 0.24568580231744036, - 0.095261604634880703, 0.85459999999999992, 0.26216430285482856, 0.095261604634880703, 0.85459999999999992, 0.26216430285482856, 0.1207983953651193, - 0.85459999999999992, 0.24568580231744036, 0.1207983953651193, 0.85459999999999992, 0.24568580231744036, 0.095261604634880703, 0.85459999999999992, - 0.26216430285482856, 0.095261604634880703, 0.85459999999999992, 0.26216430285482856, 0.1207983953651193, 0.85459999999999992, 0.24568580231744036, - 0.1207983953651193, 0.85459999999999992, 0.24568580231744036, 0.095261604634880703, 1.0682499999999999, 0.26216430285482856, 0.095261604634880703, - 1.0682499999999999, 0.26216430285482856, 0.1207983953651193, 1.0682499999999999, 0.24568580231744036, 0.1207983953651193, 1.0682499999999999, - 0.24568580231744036, 0.095261604634880703, 1.0682499999999999, 0.26216430285482856, 0.095261604634880703, 1.0682499999999999, 0.26216430285482856, - 0.1207983953651193, 1.0682499999999999, 0.24568580231744036, 0.1207983953651193, 1.0682499999999999, 0.24568580231744036, 0.095261604634880703, - 1.2818999999999998, 0.26216430285482856, 0.095261604634880703, 1.2818999999999998, 0.26216430285482856, 0.1207983953651193, 1.2818999999999998, - 0.24568580231744036, 0.1207983953651193, 1.2818999999999998, 0.24568580231744036, 0.095261604634880703, 1.2818999999999998, 0.26216430285482856, - 0.095261604634880703, 1.2818999999999998, 0.26216430285482856, 0.1207983953651193, 1.2818999999999998, 0.24568580231744036, 0.1207983953651193, - 1.2818999999999998, 0.24568580231744036, 0.095261604634880703, 1.4955499999999999, 0.26216430285482856, 0.095261604634880703, 1.4955499999999999, - 0.26216430285482856, 0.1207983953651193, 1.4955499999999999, 0.24568580231744036, 0.1207983953651193, 1.4955499999999999, 0.24568580231744036, - 0.095261604634880703, 1.4955499999999999, 0.26216430285482856, 0.095261604634880703, 1.4955499999999999, 0.26216430285482856, 0.1207983953651193, - 1.4955499999999999, 0.24568580231744036, 0.1207983953651193, 1.4955499999999999, 0.24568580231744036, 0.095261604634880703, 1.7091999999999998, - 0.26216430285482856, 0.095261604634880703, 1.7091999999999998, 0.26216430285482856, 0.1207983953651193, 1.7091999999999998, 0.24568580231744036, - 0.1207983953651193, 1.7091999999999998, 0.24568580231744036, 0.095261604634880703, 1.7091999999999998, 0.26216430285482856, 0.095261604634880703, - 1.7091999999999998, 0.26216430285482856, 0.1207983953651193, 1.7091999999999998, 0.24568580231744036, 0.1207983953651193, 1.7091999999999998, - 0.24568580231744036, 0.095261604634880703, 1.9228499999999997, 0.26216430285482856, 0.095261604634880703, 1.9228499999999997, 0.26216430285482856, - 0.1207983953651193, 1.9228499999999997, 0.24568580231744036, 0.1207983953651193, 1.9228499999999997, 0.24568580231744036, 0.095261604634880703, - 1.9228499999999997, 0.26216430285482856, 0.095261604634880703, 1.9228499999999997, 0.26216430285482856, 0.1207983953651193, 1.9228499999999997, - 0.24568580231744036, 0.1207983953651193, 1.9228499999999997, 0.24568580231744036, 0.095261604634880703, 2.1364999999999998, 0.26216430285482856, - 0.095261604634880703, 2.1364999999999998, 0.26216430285482856, 0.1207983953651193, 2.1364999999999998, 0.24568580231744036, 0.1207983953651193, - 2.1364999999999998, 0.24568580231744036, 0.095261604634880703, 2.1364999999999998, 0.26216430285482856, 0.095261604634880703, 2.1364999999999998, - 0.26216430285482856, 0.1207983953651193, 2.1364999999999998, 0.24568580231744036, 0.1207983953651193, 2.1364999999999998, 0.24568580231744036, - 0.095261604634880703, 2.3501499999999997, 0.26216430285482856, 0.095261604634880703, 2.3501499999999997, 0.26216430285482856, 0.1207983953651193, - 2.3501499999999997, 0.24568580231744036, 0.1207983953651193, 2.3501499999999997, 0.24568580231744036, 0.095261604634880703, 2.3501499999999997, - 0.26216430285482856, 0.095261604634880703, 2.3501499999999997, 0.26216430285482856, 0.1207983953651193, 2.3501499999999997, 0.24568580231744036, - 0.1207983953651193, 2.3501499999999997, 0.24568580231744036, 0.095261604634880703, 2.5637999999999996, 0.26216430285482856, 0.095261604634880703, - 2.5637999999999996, 0.26216430285482856, 0.1207983953651193, 2.5637999999999996, 0.24568580231744036, 0.1207983953651193, 2.5637999999999996, - 0.24568580231744036, 0.095261604634880703, 2.5637999999999996, 0.26216430285482856, 0.095261604634880703, 2.5637999999999996, 0.26216430285482856, - 0.1207983953651193, 2.5637999999999996, 0.24568580231744036, 0.1207983953651193, 2.5637999999999996, 0.24568580231744036, 0.095261604634880703, - 2.7774499999999995, 0.26216430285482856, 0.095261604634880703, 2.7774499999999995, 0.26216430285482856, 0.1207983953651193, 2.7774499999999995, - 0.24568580231744036, 0.1207983953651193, 2.7774499999999995, 0.24568580231744036, 0.095261604634880703, 2.7774499999999995, 0.26216430285482856, - 0.095261604634880703, 2.7774499999999995, 0.26216430285482856, 0.1207983953651193, - 2.7774499999999995, 0.24568580231744036, 0.1207983953651193, 2.7774499999999995, 0.24568580231744036, 0.095261604634880703, 2.9910999999999999, - 0.26216430285482856, 0.095261604634880703, 2.9910999999999999, 0.26216430285482856, 0.1207983953651193, 2.9910999999999999, 0.24568580231744036, - 0.1207983953651193, 2.9910999999999999, 0.24568580231744036, 0.095261604634880703, 2.9910999999999999, 0.26216430285482856, 0.095261604634880703, - 2.9910999999999999, 0.26216430285482856, 0.1207983953651193, 2.9910999999999999, 0.24568580231744036, 0.1207983953651193, 2.9910999999999999, - 0.24568580231744036, 0.095261604634880703, 3.2047499999999998, 0.26216430285482856, 0.095261604634880703, 3.2047499999999998, 0.26216430285482856, - 0.1207983953651193, 3.2047499999999998, 0.24568580231744036, 0.1207983953651193, 3.2047499999999998, 0.24568580231744036, 0.095261604634880703, - 3.2047499999999998, 0.26216430285482856, 0.095261604634880703, 3.2047499999999998, 0.26216430285482856, 0.1207983953651193, 3.2047499999999998, - 0.24568580231744036, 0.1207983953651193, 3.2047499999999998, 0.24568580231744036, 0.095261604634880703, 3.4183999999999997, 0.26216430285482856, - 0.095261604634880703, 3.4183999999999997, 0.26216430285482856, 0.1207983953651193, 3.4183999999999997, 0.24568580231744036, 0.1207983953651193, - 3.4183999999999997, 0.24568580231744036, 0.095261604634880703, 3.4183999999999997, 0.26216430285482856, 0.095261604634880703, 3.4183999999999997, - 0.26216430285482856, 0.1207983953651193, 3.4183999999999997, 0.24568580231744036, 0.1207983953651193, 3.4183999999999997, 0.24568580231744036, - 0.095261604634880703, 3.6320499999999996, 0.26216430285482856, 0.095261604634880703, 3.6320499999999996, 0.26216430285482856, 0.1207983953651193, - 3.6320499999999996, 0.24568580231744036, 0.1207983953651193, 3.6320499999999996, 0.24568580231744036, 0.095261604634880703, 3.6320499999999996, - 0.26216430285482856, 0.095261604634880703, 3.6320499999999996, 0.26216430285482856, 0.1207983953651193, 3.6320499999999996, 0.24568580231744036, - 0.1207983953651193, 3.6320499999999996, 0.24568580231744036, 0.095261604634880703, 3.8456999999999995, 0.26216430285482856, 0.095261604634880703, - 3.8456999999999995, 0.26216430285482856, 0.1207983953651193, 3.8456999999999995, 0.24568580231744036, 0.1207983953651193, 3.8456999999999995, - 0.24568580231744036, 0.095261604634880703, 3.8456999999999995, 0.26216430285482856, 0.095261604634880703, 3.8456999999999995, 0.26216430285482856, - 0.1207983953651193, 3.8456999999999995, 0.24568580231744036, 0.1207983953651193, 3.8456999999999995, 0.24568580231744036, 0.095261604634880703, - 4.0593499999999993, 0.26216430285482856, 0.095261604634880703, 4.0593499999999993, 0.26216430285482856, 0.1207983953651193, 4.0593499999999993, - 0.24568580231744036, 0.1207983953651193, 4.0593499999999993, 0.24568580231744036, 0.095261604634880703, 4.0593499999999993, 0.26216430285482856, - 0.095261604634880703, 4.0593499999999993, 0.26216430285482856, 0.1207983953651193, 4.0593499999999993, 0.24568580231744036, 0.1207983953651193, - 4.0593499999999993, 0.24568580231744036, 0.095261604634880703, 4.2729999999999997, 0.26216430285482856, 0.095261604634880703, 4.2729999999999997, - 0.26216430285482856, 0.1207983953651193, 4.2729999999999997, 0.24568580231744036, 0.1207983953651193, 4.2729999999999997, 0.31399569714517145, - 0.097935697145171446, 0, 0.33418430285482853, 0.097935697145171446, 0, 0.33418430285482853, 0.11812430285482856, 0, 0.31399569714517145, 0.11812430285482856, 0, - 0.31399569714517145, 0.097935697145171446, 0.21364999999999998, 0.33418430285482853, 0.097935697145171446, 0.21364999999999998, 0.33418430285482853, - 0.11812430285482856, 0.21364999999999998, 0.31399569714517145, 0.11812430285482856, 0.21364999999999998, 0.31399569714517145, 0.097935697145171446, - 0.21364999999999998, 0.33418430285482853, 0.097935697145171446, 0.21364999999999998, 0.33418430285482853, 0.11812430285482856, 0.21364999999999998, - 0.31399569714517145, 0.11812430285482856, 0.21364999999999998, 0.31399569714517145, 0.097935697145171446, 0.42729999999999996, 0.33418430285482853, - 0.097935697145171446, 0.42729999999999996, 0.33418430285482853, 0.11812430285482856, 0.42729999999999996, 0.31399569714517145, 0.11812430285482856, - 0.42729999999999996, 0.31399569714517145, 0.097935697145171446, 0.42729999999999996, 0.33418430285482853, 0.097935697145171446, 0.42729999999999996, - 0.33418430285482853, 0.11812430285482856, 0.42729999999999996, 0.31399569714517145, 0.11812430285482856, 0.42729999999999996, 0.31399569714517145, - 0.097935697145171446, 0.64094999999999991, 0.33418430285482853, 0.097935697145171446, 0.64094999999999991, 0.33418430285482853, 0.11812430285482856, - 0.64094999999999991, 0.31399569714517145, 0.11812430285482856, 0.64094999999999991, 0.31399569714517145, 0.097935697145171446, 0.64094999999999991, - 0.33418430285482853, 0.097935697145171446, 0.64094999999999991, 0.33418430285482853, 0.11812430285482856, 0.64094999999999991, 0.31399569714517145, - 0.11812430285482856, 0.64094999999999991, 0.31399569714517145, 0.097935697145171446, 0.85459999999999992, 0.33418430285482853, 0.097935697145171446, - 0.85459999999999992, 0.33418430285482853, 0.11812430285482856, 0.85459999999999992, 0.31399569714517145, 0.11812430285482856, 0.85459999999999992, - 0.31399569714517145, 0.097935697145171446, 0.85459999999999992, 0.33418430285482853, 0.097935697145171446, 0.85459999999999992, 0.33418430285482853, - 0.11812430285482856, 0.85459999999999992, 0.31399569714517145, 0.11812430285482856, 0.85459999999999992, 0.31399569714517145, 0.097935697145171446, - 1.0682499999999999, 0.33418430285482853, 0.097935697145171446, 1.0682499999999999, 0.33418430285482853, 0.11812430285482856, 1.0682499999999999, - 0.31399569714517145, 0.11812430285482856, 1.0682499999999999, 0.31399569714517145, 0.097935697145171446, 1.0682499999999999, 0.33418430285482853, - 0.097935697145171446, 1.0682499999999999, 0.33418430285482853, 0.11812430285482856, 1.0682499999999999, 0.31399569714517145, 0.11812430285482856, - 1.0682499999999999, 0.31399569714517145, 0.097935697145171446, 1.2818999999999998, 0.33418430285482853, 0.097935697145171446, 1.2818999999999998, - 0.33418430285482853, 0.11812430285482856, 1.2818999999999998, 0.31399569714517145, 0.11812430285482856, 1.2818999999999998, 0.31399569714517145, - 0.097935697145171446, 1.2818999999999998, 0.33418430285482853, 0.097935697145171446, 1.2818999999999998, 0.33418430285482853, 0.11812430285482856, - 1.2818999999999998, 0.31399569714517145, 0.11812430285482856, 1.2818999999999998, 0.31399569714517145, 0.097935697145171446, 1.4955499999999999, - 0.33418430285482853, 0.097935697145171446, 1.4955499999999999, 0.33418430285482853, 0.11812430285482856, 1.4955499999999999, 0.31399569714517145, - 0.11812430285482856, 1.4955499999999999, 0.31399569714517145, 0.097935697145171446, 1.4955499999999999, 0.33418430285482853, 0.097935697145171446, - 1.4955499999999999, 0.33418430285482853, 0.11812430285482856, 1.4955499999999999, 0.31399569714517145, 0.11812430285482856, 1.4955499999999999, - 0.31399569714517145, 0.097935697145171446, 1.7091999999999998, 0.33418430285482853, 0.097935697145171446, 1.7091999999999998, 0.33418430285482853, - 0.11812430285482856, 1.7091999999999998, 0.31399569714517145, 0.11812430285482856, 1.7091999999999998, 0.31399569714517145, 0.097935697145171446, - 1.7091999999999998, 0.33418430285482853, 0.097935697145171446, 1.7091999999999998, 0.33418430285482853, 0.11812430285482856, 1.7091999999999998, - 0.31399569714517145, 0.11812430285482856, 1.7091999999999998, 0.31399569714517145, 0.097935697145171446, 1.9228499999999997, 0.33418430285482853, - 0.097935697145171446, 1.9228499999999997, 0.33418430285482853, 0.11812430285482856, 1.9228499999999997, 0.31399569714517145, 0.11812430285482856, - 1.9228499999999997, 0.31399569714517145, 0.097935697145171446, 1.9228499999999997, 0.33418430285482853, 0.097935697145171446, 1.9228499999999997, - 0.33418430285482853, 0.11812430285482856, 1.9228499999999997, 0.31399569714517145, 0.11812430285482856, 1.9228499999999997, 0.31399569714517145, - 0.097935697145171446, 2.1364999999999998, 0.33418430285482853, 0.097935697145171446, 2.1364999999999998, 0.33418430285482853, 0.11812430285482856, - 2.1364999999999998, 0.31399569714517145, 0.11812430285482856, 2.1364999999999998, - 0.31399569714517145, 0.097935697145171446, 2.1364999999999998, 0.33418430285482853, 0.097935697145171446, 2.1364999999999998, 0.33418430285482853, - 0.11812430285482856, 2.1364999999999998, 0.31399569714517145, 0.11812430285482856, 2.1364999999999998, 0.31399569714517145, 0.097935697145171446, - 2.3501499999999997, 0.33418430285482853, 0.097935697145171446, 2.3501499999999997, 0.33418430285482853, 0.11812430285482856, 2.3501499999999997, - 0.31399569714517145, 0.11812430285482856, 2.3501499999999997, 0.31399569714517145, 0.097935697145171446, 2.3501499999999997, 0.33418430285482853, - 0.097935697145171446, 2.3501499999999997, 0.33418430285482853, 0.11812430285482856, 2.3501499999999997, 0.31399569714517145, 0.11812430285482856, - 2.3501499999999997, 0.31399569714517145, 0.097935697145171446, 2.5637999999999996, 0.33418430285482853, 0.097935697145171446, 2.5637999999999996, - 0.33418430285482853, 0.11812430285482856, 2.5637999999999996, 0.31399569714517145, 0.11812430285482856, 2.5637999999999996, 0.31399569714517145, - 0.097935697145171446, 2.5637999999999996, 0.33418430285482853, 0.097935697145171446, 2.5637999999999996, 0.33418430285482853, 0.11812430285482856, - 2.5637999999999996, 0.31399569714517145, 0.11812430285482856, 2.5637999999999996, 0.31399569714517145, 0.097935697145171446, 2.7774499999999995, - 0.33418430285482853, 0.097935697145171446, 2.7774499999999995, 0.33418430285482853, 0.11812430285482856, 2.7774499999999995, 0.31399569714517145, - 0.11812430285482856, 2.7774499999999995, 0.31399569714517145, 0.097935697145171446, 2.7774499999999995, 0.33418430285482853, 0.097935697145171446, - 2.7774499999999995, 0.33418430285482853, 0.11812430285482856, 2.7774499999999995, 0.31399569714517145, 0.11812430285482856, 2.7774499999999995, - 0.31399569714517145, 0.097935697145171446, 2.9910999999999999, 0.33418430285482853, 0.097935697145171446, 2.9910999999999999, 0.33418430285482853, - 0.11812430285482856, 2.9910999999999999, 0.31399569714517145, 0.11812430285482856, 2.9910999999999999, 0.31399569714517145, 0.097935697145171446, - 2.9910999999999999, 0.33418430285482853, 0.097935697145171446, 2.9910999999999999, 0.33418430285482853, 0.11812430285482856, 2.9910999999999999, - 0.31399569714517145, 0.11812430285482856, 2.9910999999999999, 0.31399569714517145, 0.097935697145171446, 3.2047499999999998, 0.33418430285482853, - 0.097935697145171446, 3.2047499999999998, 0.33418430285482853, 0.11812430285482856, 3.2047499999999998, 0.31399569714517145, 0.11812430285482856, - 3.2047499999999998, 0.31399569714517145, 0.097935697145171446, 3.2047499999999998, 0.33418430285482853, 0.097935697145171446, 3.2047499999999998, - 0.33418430285482853, 0.11812430285482856, 3.2047499999999998, 0.31399569714517145, 0.11812430285482856, 3.2047499999999998, 0.31399569714517145, - 0.097935697145171446, 3.4183999999999997, 0.33418430285482853, 0.097935697145171446, 3.4183999999999997, 0.33418430285482853, 0.11812430285482856, - 3.4183999999999997, 0.31399569714517145, 0.11812430285482856, 3.4183999999999997, 0.31399569714517145, 0.097935697145171446, 3.4183999999999997, - 0.33418430285482853, 0.097935697145171446, 3.4183999999999997, 0.33418430285482853, 0.11812430285482856, 3.4183999999999997, 0.31399569714517145, - 0.11812430285482856, 3.4183999999999997, 0.31399569714517145, 0.097935697145171446, 3.6320499999999996, 0.33418430285482853, 0.097935697145171446, - 3.6320499999999996, 0.33418430285482853, 0.11812430285482856, 3.6320499999999996, 0.31399569714517145, 0.11812430285482856, 3.6320499999999996, - 0.31399569714517145, 0.097935697145171446, 3.6320499999999996, 0.33418430285482853, 0.097935697145171446, 3.6320499999999996, 0.33418430285482853, - 0.11812430285482856, 3.6320499999999996, 0.31399569714517145, 0.11812430285482856, 3.6320499999999996, 0.31399569714517145, 0.097935697145171446, - 3.8456999999999995, 0.33418430285482853, 0.097935697145171446, 3.8456999999999995, 0.33418430285482853, 0.11812430285482856, 3.8456999999999995, - 0.31399569714517145, 0.11812430285482856, 3.8456999999999995, 0.31399569714517145, 0.097935697145171446, 3.8456999999999995, 0.33418430285482853, - 0.097935697145171446, 3.8456999999999995, 0.33418430285482853, 0.11812430285482856, - 3.8456999999999995, 0.31399569714517145, 0.11812430285482856, 3.8456999999999995, 0.31399569714517145, 0.097935697145171446, 4.0593499999999993, - 0.33418430285482853, 0.097935697145171446, 4.0593499999999993, 0.33418430285482853, 0.11812430285482856, 4.0593499999999993, 0.31399569714517145, - 0.11812430285482856, 4.0593499999999993, 0.31399569714517145, 0.097935697145171446, 4.0593499999999993, 0.33418430285482853, 0.097935697145171446, - 4.0593499999999993, 0.33418430285482853, 0.11812430285482856, 4.0593499999999993, 0.31399569714517145, 0.11812430285482856, 4.0593499999999993, - 0.31399569714517145, 0.097935697145171446, 4.2729999999999997, 0.33418430285482853, 0.097935697145171446, 4.2729999999999997, 0.33418430285482853, - 0.11812430285482856, 4.2729999999999997, 0.31399569714517145, 0.11812430285482856, 4.2729999999999997, 0.38601569714517142, 0.095261604634880703, 0, - 0.40249419768255962, 0.095261604634880703, 0, 0.40249419768255962, 0.1207983953651193, 0, 0.38601569714517142, 0.1207983953651193, 0, 0.38601569714517142, - 0.095261604634880703, 0.21364999999999998, 0.40249419768255962, 0.095261604634880703, 0.21364999999999998, 0.40249419768255962, 0.1207983953651193, - 0.21364999999999998, 0.38601569714517142, 0.1207983953651193, 0.21364999999999998, 0.38601569714517142, 0.095261604634880703, 0.21364999999999998, - 0.40249419768255962, 0.095261604634880703, 0.21364999999999998, 0.40249419768255962, 0.1207983953651193, 0.21364999999999998, 0.38601569714517142, - 0.1207983953651193, 0.21364999999999998, 0.38601569714517142, 0.095261604634880703, 0.42729999999999996, 0.40249419768255962, 0.095261604634880703, - 0.42729999999999996, 0.40249419768255962, 0.1207983953651193, 0.42729999999999996, 0.38601569714517142, 0.1207983953651193, 0.42729999999999996, - 0.38601569714517142, 0.095261604634880703, 0.42729999999999996, 0.40249419768255962, 0.095261604634880703, 0.42729999999999996, 0.40249419768255962, - 0.1207983953651193, 0.42729999999999996, 0.38601569714517142, 0.1207983953651193, 0.42729999999999996, 0.38601569714517142, 0.095261604634880703, - 0.64094999999999991, 0.40249419768255962, 0.095261604634880703, 0.64094999999999991, 0.40249419768255962, 0.1207983953651193, 0.64094999999999991, - 0.38601569714517142, 0.1207983953651193, 0.64094999999999991, 0.38601569714517142, 0.095261604634880703, 0.64094999999999991, 0.40249419768255962, - 0.095261604634880703, 0.64094999999999991, 0.40249419768255962, 0.1207983953651193, 0.64094999999999991, 0.38601569714517142, 0.1207983953651193, - 0.64094999999999991, 0.38601569714517142, 0.095261604634880703, 0.85459999999999992, 0.40249419768255962, 0.095261604634880703, 0.85459999999999992, - 0.40249419768255962, 0.1207983953651193, 0.85459999999999992, 0.38601569714517142, 0.1207983953651193, 0.85459999999999992, 0.38601569714517142, - 0.095261604634880703, 0.85459999999999992, 0.40249419768255962, 0.095261604634880703, 0.85459999999999992, 0.40249419768255962, 0.1207983953651193, - 0.85459999999999992, 0.38601569714517142, 0.1207983953651193, 0.85459999999999992, 0.38601569714517142, 0.095261604634880703, 1.0682499999999999, - 0.40249419768255962, 0.095261604634880703, 1.0682499999999999, 0.40249419768255962, 0.1207983953651193, 1.0682499999999999, 0.38601569714517142, - 0.1207983953651193, 1.0682499999999999, 0.38601569714517142, 0.095261604634880703, 1.0682499999999999, 0.40249419768255962, 0.095261604634880703, - 1.0682499999999999, 0.40249419768255962, 0.1207983953651193, 1.0682499999999999, 0.38601569714517142, 0.1207983953651193, 1.0682499999999999, - 0.38601569714517142, 0.095261604634880703, 1.2818999999999998, 0.40249419768255962, 0.095261604634880703, 1.2818999999999998, 0.40249419768255962, - 0.1207983953651193, 1.2818999999999998, 0.38601569714517142, 0.1207983953651193, 1.2818999999999998, 0.38601569714517142, 0.095261604634880703, - 1.2818999999999998, 0.40249419768255962, 0.095261604634880703, 1.2818999999999998, 0.40249419768255962, 0.1207983953651193, 1.2818999999999998, - 0.38601569714517142, 0.1207983953651193, 1.2818999999999998, 0.38601569714517142, 0.095261604634880703, 1.4955499999999999, 0.40249419768255962, - 0.095261604634880703, 1.4955499999999999, 0.40249419768255962, 0.1207983953651193, 1.4955499999999999, 0.38601569714517142, 0.1207983953651193, - 1.4955499999999999, 0.38601569714517142, 0.095261604634880703, 1.4955499999999999, 0.40249419768255962, 0.095261604634880703, 1.4955499999999999, - 0.40249419768255962, 0.1207983953651193, 1.4955499999999999, 0.38601569714517142, 0.1207983953651193, 1.4955499999999999, 0.38601569714517142, - 0.095261604634880703, 1.7091999999999998, 0.40249419768255962, 0.095261604634880703, 1.7091999999999998, 0.40249419768255962, 0.1207983953651193, - 1.7091999999999998, 0.38601569714517142, 0.1207983953651193, 1.7091999999999998, 0.38601569714517142, 0.095261604634880703, 1.7091999999999998, - 0.40249419768255962, 0.095261604634880703, 1.7091999999999998, 0.40249419768255962, 0.1207983953651193, 1.7091999999999998, 0.38601569714517142, - 0.1207983953651193, 1.7091999999999998, 0.38601569714517142, 0.095261604634880703, 1.9228499999999997, 0.40249419768255962, 0.095261604634880703, - 1.9228499999999997, 0.40249419768255962, 0.1207983953651193, 1.9228499999999997, 0.38601569714517142, 0.1207983953651193, 1.9228499999999997, - 0.38601569714517142, 0.095261604634880703, 1.9228499999999997, 0.40249419768255962, 0.095261604634880703, 1.9228499999999997, 0.40249419768255962, - 0.1207983953651193, 1.9228499999999997, 0.38601569714517142, 0.1207983953651193, 1.9228499999999997, 0.38601569714517142, 0.095261604634880703, - 2.1364999999999998, 0.40249419768255962, 0.095261604634880703, 2.1364999999999998, 0.40249419768255962, 0.1207983953651193, 2.1364999999999998, - 0.38601569714517142, 0.1207983953651193, 2.1364999999999998, 0.38601569714517142, 0.095261604634880703, 2.1364999999999998, 0.40249419768255962, - 0.095261604634880703, 2.1364999999999998, 0.40249419768255962, 0.1207983953651193, 2.1364999999999998, 0.38601569714517142, 0.1207983953651193, - 2.1364999999999998, 0.38601569714517142, 0.095261604634880703, 2.3501499999999997, 0.40249419768255962, 0.095261604634880703, 2.3501499999999997, - 0.40249419768255962, 0.1207983953651193, 2.3501499999999997, 0.38601569714517142, 0.1207983953651193, 2.3501499999999997, 0.38601569714517142, - 0.095261604634880703, 2.3501499999999997, 0.40249419768255962, 0.095261604634880703, 2.3501499999999997, 0.40249419768255962, 0.1207983953651193, - 2.3501499999999997, 0.38601569714517142, 0.1207983953651193, 2.3501499999999997, 0.38601569714517142, 0.095261604634880703, 2.5637999999999996, - 0.40249419768255962, 0.095261604634880703, 2.5637999999999996, 0.40249419768255962, 0.1207983953651193, 2.5637999999999996, 0.38601569714517142, - 0.1207983953651193, 2.5637999999999996, 0.38601569714517142, 0.095261604634880703, 2.5637999999999996, 0.40249419768255962, 0.095261604634880703, - 2.5637999999999996, 0.40249419768255962, 0.1207983953651193, 2.5637999999999996, 0.38601569714517142, 0.1207983953651193, 2.5637999999999996, - 0.38601569714517142, 0.095261604634880703, 2.7774499999999995, 0.40249419768255962, 0.095261604634880703, 2.7774499999999995, 0.40249419768255962, - 0.1207983953651193, 2.7774499999999995, 0.38601569714517142, 0.1207983953651193, 2.7774499999999995, 0.38601569714517142, 0.095261604634880703, - 2.7774499999999995, 0.40249419768255962, 0.095261604634880703, 2.7774499999999995, 0.40249419768255962, 0.1207983953651193, 2.7774499999999995, - 0.38601569714517142, 0.1207983953651193, 2.7774499999999995, 0.38601569714517142, 0.095261604634880703, 2.9910999999999999, 0.40249419768255962, - 0.095261604634880703, 2.9910999999999999, 0.40249419768255962, 0.1207983953651193, 2.9910999999999999, 0.38601569714517142, 0.1207983953651193, - 2.9910999999999999, 0.38601569714517142, 0.095261604634880703, 2.9910999999999999, 0.40249419768255962, 0.095261604634880703, 2.9910999999999999, - 0.40249419768255962, 0.1207983953651193, 2.9910999999999999, 0.38601569714517142, 0.1207983953651193, 2.9910999999999999, 0.38601569714517142, - 0.095261604634880703, 3.2047499999999998, 0.40249419768255962, 0.095261604634880703, 3.2047499999999998, 0.40249419768255962, 0.1207983953651193, - 3.2047499999999998, 0.38601569714517142, 0.1207983953651193, 3.2047499999999998, - 0.38601569714517142, 0.095261604634880703, 3.2047499999999998, 0.40249419768255962, 0.095261604634880703, 3.2047499999999998, 0.40249419768255962, - 0.1207983953651193, 3.2047499999999998, 0.38601569714517142, 0.1207983953651193, 3.2047499999999998, 0.38601569714517142, 0.095261604634880703, - 3.4183999999999997, 0.40249419768255962, 0.095261604634880703, 3.4183999999999997, 0.40249419768255962, 0.1207983953651193, 3.4183999999999997, - 0.38601569714517142, 0.1207983953651193, 3.4183999999999997, 0.38601569714517142, 0.095261604634880703, 3.4183999999999997, 0.40249419768255962, - 0.095261604634880703, 3.4183999999999997, 0.40249419768255962, 0.1207983953651193, 3.4183999999999997, 0.38601569714517142, 0.1207983953651193, - 3.4183999999999997, 0.38601569714517142, 0.095261604634880703, 3.6320499999999996, 0.40249419768255962, 0.095261604634880703, 3.6320499999999996, - 0.40249419768255962, 0.1207983953651193, 3.6320499999999996, 0.38601569714517142, 0.1207983953651193, 3.6320499999999996, 0.38601569714517142, - 0.095261604634880703, 3.6320499999999996, 0.40249419768255962, 0.095261604634880703, 3.6320499999999996, 0.40249419768255962, 0.1207983953651193, - 3.6320499999999996, 0.38601569714517142, 0.1207983953651193, 3.6320499999999996, 0.38601569714517142, 0.095261604634880703, 3.8456999999999995, - 0.40249419768255962, 0.095261604634880703, 3.8456999999999995, 0.40249419768255962, 0.1207983953651193, 3.8456999999999995, 0.38601569714517142, - 0.1207983953651193, 3.8456999999999995, 0.38601569714517142, 0.095261604634880703, 3.8456999999999995, 0.40249419768255962, 0.095261604634880703, - 3.8456999999999995, 0.40249419768255962, 0.1207983953651193, 3.8456999999999995, 0.38601569714517142, 0.1207983953651193, 3.8456999999999995, - 0.38601569714517142, 0.095261604634880703, 4.0593499999999993, 0.40249419768255962, 0.095261604634880703, 4.0593499999999993, 0.40249419768255962, - 0.1207983953651193, 4.0593499999999993, 0.38601569714517142, 0.1207983953651193, 4.0593499999999993, 0.38601569714517142, 0.095261604634880703, - 4.0593499999999993, 0.40249419768255962, 0.095261604634880703, 4.0593499999999993, 0.40249419768255962, 0.1207983953651193, 4.0593499999999993, - 0.38601569714517142, 0.1207983953651193, 4.0593499999999993, 0.38601569714517142, 0.095261604634880703, 4.2729999999999997, 0.40249419768255962, - 0.095261604634880703, 4.2729999999999997, 0.40249419768255962, 0.1207983953651193, 4.2729999999999997, 0.38601569714517142, 0.1207983953651193, - 4.2729999999999997, 0.24197569714517148, 0.16728160463488068, 0, 0.26483839536511933, 0.16728160463488068, 0, 0.26483839536511933, 0.19014430285482856, 0, - 0.24197569714517148, 0.19014430285482856, 0, 0.24197569714517148, 0.16728160463488068, 0.21364999999999998, 0.26483839536511933, 0.16728160463488068, - 0.21364999999999998, 0.26483839536511933, 0.19014430285482856, 0.21364999999999998, 0.24197569714517148, 0.19014430285482856, 0.21364999999999998, - 0.24197569714517148, 0.16728160463488068, 0.21364999999999998, 0.26483839536511933, 0.16728160463488068, 0.21364999999999998, 0.26483839536511933, - 0.19014430285482856, 0.21364999999999998, 0.24197569714517148, 0.19014430285482856, 0.21364999999999998, 0.24197569714517148, 0.16728160463488068, - 0.42729999999999996, 0.26483839536511933, 0.16728160463488068, 0.42729999999999996, 0.26483839536511933, 0.19014430285482856, 0.42729999999999996, - 0.24197569714517148, 0.19014430285482856, 0.42729999999999996, 0.24197569714517148, 0.16728160463488068, 0.42729999999999996, 0.26483839536511933, - 0.16728160463488068, 0.42729999999999996, 0.26483839536511933, 0.19014430285482856, 0.42729999999999996, 0.24197569714517148, 0.19014430285482856, - 0.42729999999999996, 0.24197569714517148, 0.16728160463488068, 0.64094999999999991, 0.26483839536511933, 0.16728160463488068, 0.64094999999999991, - 0.26483839536511933, 0.19014430285482856, 0.64094999999999991, 0.24197569714517148, 0.19014430285482856, 0.64094999999999991, 0.24197569714517148, - 0.16728160463488068, 0.64094999999999991, 0.26483839536511933, 0.16728160463488068, 0.64094999999999991, 0.26483839536511933, 0.19014430285482856, - 0.64094999999999991, 0.24197569714517148, 0.19014430285482856, 0.64094999999999991, 0.24197569714517148, 0.16728160463488068, 0.85459999999999992, - 0.26483839536511933, 0.16728160463488068, 0.85459999999999992, 0.26483839536511933, 0.19014430285482856, 0.85459999999999992, 0.24197569714517148, - 0.19014430285482856, 0.85459999999999992, 0.24197569714517148, 0.16728160463488068, 0.85459999999999992, 0.26483839536511933, 0.16728160463488068, - 0.85459999999999992, 0.26483839536511933, 0.19014430285482856, 0.85459999999999992, 0.24197569714517148, 0.19014430285482856, 0.85459999999999992, - 0.24197569714517148, 0.16728160463488068, 1.0682499999999999, 0.26483839536511933, 0.16728160463488068, 1.0682499999999999, 0.26483839536511933, - 0.19014430285482856, 1.0682499999999999, 0.24197569714517148, 0.19014430285482856, 1.0682499999999999, 0.24197569714517148, 0.16728160463488068, - 1.0682499999999999, 0.26483839536511933, 0.16728160463488068, 1.0682499999999999, 0.26483839536511933, 0.19014430285482856, 1.0682499999999999, - 0.24197569714517148, 0.19014430285482856, 1.0682499999999999, 0.24197569714517148, 0.16728160463488068, 1.2818999999999998, 0.26483839536511933, - 0.16728160463488068, 1.2818999999999998, 0.26483839536511933, 0.19014430285482856, 1.2818999999999998, 0.24197569714517148, 0.19014430285482856, - 1.2818999999999998, 0.24197569714517148, 0.16728160463488068, 1.2818999999999998, 0.26483839536511933, 0.16728160463488068, 1.2818999999999998, - 0.26483839536511933, 0.19014430285482856, 1.2818999999999998, 0.24197569714517148, 0.19014430285482856, 1.2818999999999998, 0.24197569714517148, - 0.16728160463488068, 1.4955499999999999, 0.26483839536511933, 0.16728160463488068, 1.4955499999999999, 0.26483839536511933, 0.19014430285482856, - 1.4955499999999999, 0.24197569714517148, 0.19014430285482856, 1.4955499999999999, 0.24197569714517148, 0.16728160463488068, 1.4955499999999999, - 0.26483839536511933, 0.16728160463488068, 1.4955499999999999, 0.26483839536511933, 0.19014430285482856, 1.4955499999999999, 0.24197569714517148, - 0.19014430285482856, 1.4955499999999999, 0.24197569714517148, 0.16728160463488068, 1.7091999999999998, 0.26483839536511933, 0.16728160463488068, - 1.7091999999999998, 0.26483839536511933, 0.19014430285482856, 1.7091999999999998, 0.24197569714517148, 0.19014430285482856, 1.7091999999999998, - 0.24197569714517148, 0.16728160463488068, 1.7091999999999998, 0.26483839536511933, 0.16728160463488068, 1.7091999999999998, 0.26483839536511933, - 0.19014430285482856, 1.7091999999999998, 0.24197569714517148, 0.19014430285482856, 1.7091999999999998, 0.24197569714517148, 0.16728160463488068, - 1.9228499999999997, 0.26483839536511933, 0.16728160463488068, 1.9228499999999997, 0.26483839536511933, 0.19014430285482856, 1.9228499999999997, - 0.24197569714517148, 0.19014430285482856, 1.9228499999999997, 0.24197569714517148, 0.16728160463488068, 1.9228499999999997, 0.26483839536511933, - 0.16728160463488068, 1.9228499999999997, 0.26483839536511933, 0.19014430285482856, 1.9228499999999997, 0.24197569714517148, 0.19014430285482856, - 1.9228499999999997, 0.24197569714517148, 0.16728160463488068, 2.1364999999999998, 0.26483839536511933, 0.16728160463488068, 2.1364999999999998, - 0.26483839536511933, 0.19014430285482856, 2.1364999999999998, 0.24197569714517148, 0.19014430285482856, 2.1364999999999998, 0.24197569714517148, - 0.16728160463488068, 2.1364999999999998, 0.26483839536511933, 0.16728160463488068, 2.1364999999999998, 0.26483839536511933, 0.19014430285482856, - 2.1364999999999998, 0.24197569714517148, 0.19014430285482856, 2.1364999999999998, 0.24197569714517148, 0.16728160463488068, 2.3501499999999997, - 0.26483839536511933, 0.16728160463488068, 2.3501499999999997, 0.26483839536511933, 0.19014430285482856, 2.3501499999999997, 0.24197569714517148, - 0.19014430285482856, 2.3501499999999997, 0.24197569714517148, 0.16728160463488068, 2.3501499999999997, 0.26483839536511933, 0.16728160463488068, - 2.3501499999999997, 0.26483839536511933, 0.19014430285482856, 2.3501499999999997, 0.24197569714517148, 0.19014430285482856, 2.3501499999999997, - 0.24197569714517148, 0.16728160463488068, 2.5637999999999996, 0.26483839536511933, - 0.16728160463488068, 2.5637999999999996, 0.26483839536511933, 0.19014430285482856, 2.5637999999999996, 0.24197569714517148, 0.19014430285482856, - 2.5637999999999996, 0.24197569714517148, 0.16728160463488068, 2.5637999999999996, 0.26483839536511933, 0.16728160463488068, 2.5637999999999996, - 0.26483839536511933, 0.19014430285482856, 2.5637999999999996, 0.24197569714517148, 0.19014430285482856, 2.5637999999999996, 0.24197569714517148, - 0.16728160463488068, 2.7774499999999995, 0.26483839536511933, 0.16728160463488068, 2.7774499999999995, 0.26483839536511933, 0.19014430285482856, - 2.7774499999999995, 0.24197569714517148, 0.19014430285482856, 2.7774499999999995, 0.24197569714517148, 0.16728160463488068, 2.7774499999999995, - 0.26483839536511933, 0.16728160463488068, 2.7774499999999995, 0.26483839536511933, 0.19014430285482856, 2.7774499999999995, 0.24197569714517148, - 0.19014430285482856, 2.7774499999999995, 0.24197569714517148, 0.16728160463488068, 2.9910999999999999, 0.26483839536511933, 0.16728160463488068, - 2.9910999999999999, 0.26483839536511933, 0.19014430285482856, 2.9910999999999999, 0.24197569714517148, 0.19014430285482856, 2.9910999999999999, - 0.24197569714517148, 0.16728160463488068, 2.9910999999999999, 0.26483839536511933, 0.16728160463488068, 2.9910999999999999, 0.26483839536511933, - 0.19014430285482856, 2.9910999999999999, 0.24197569714517148, 0.19014430285482856, 2.9910999999999999, 0.24197569714517148, 0.16728160463488068, - 3.2047499999999998, 0.26483839536511933, 0.16728160463488068, 3.2047499999999998, 0.26483839536511933, 0.19014430285482856, 3.2047499999999998, - 0.24197569714517148, 0.19014430285482856, 3.2047499999999998, 0.24197569714517148, 0.16728160463488068, 3.2047499999999998, 0.26483839536511933, - 0.16728160463488068, 3.2047499999999998, 0.26483839536511933, 0.19014430285482856, 3.2047499999999998, 0.24197569714517148, 0.19014430285482856, - 3.2047499999999998, 0.24197569714517148, 0.16728160463488068, 3.4183999999999997, 0.26483839536511933, 0.16728160463488068, 3.4183999999999997, - 0.26483839536511933, 0.19014430285482856, 3.4183999999999997, 0.24197569714517148, 0.19014430285482856, 3.4183999999999997, 0.24197569714517148, - 0.16728160463488068, 3.4183999999999997, 0.26483839536511933, 0.16728160463488068, 3.4183999999999997, 0.26483839536511933, 0.19014430285482856, - 3.4183999999999997, 0.24197569714517148, 0.19014430285482856, 3.4183999999999997, 0.24197569714517148, 0.16728160463488068, 3.6320499999999996, - 0.26483839536511933, 0.16728160463488068, 3.6320499999999996, 0.26483839536511933, 0.19014430285482856, 3.6320499999999996, 0.24197569714517148, - 0.19014430285482856, 3.6320499999999996, 0.24197569714517148, 0.16728160463488068, 3.6320499999999996, 0.26483839536511933, 0.16728160463488068, - 3.6320499999999996, 0.26483839536511933, 0.19014430285482856, 3.6320499999999996, 0.24197569714517148, 0.19014430285482856, 3.6320499999999996, - 0.24197569714517148, 0.16728160463488068, 3.8456999999999995, 0.26483839536511933, 0.16728160463488068, 3.8456999999999995, 0.26483839536511933, - 0.19014430285482856, 3.8456999999999995, 0.24197569714517148, 0.19014430285482856, 3.8456999999999995, 0.24197569714517148, 0.16728160463488068, - 3.8456999999999995, 0.26483839536511933, 0.16728160463488068, 3.8456999999999995, 0.26483839536511933, 0.19014430285482856, 3.8456999999999995, - 0.24197569714517148, 0.19014430285482856, 3.8456999999999995, 0.24197569714517148, 0.16728160463488068, 4.0593499999999993, 0.26483839536511933, - 0.16728160463488068, 4.0593499999999993, 0.26483839536511933, 0.19014430285482856, 4.0593499999999993, 0.24197569714517148, 0.19014430285482856, - 4.0593499999999993, 0.24197569714517148, 0.16728160463488068, 4.0593499999999993, 0.26483839536511933, 0.16728160463488068, 4.0593499999999993, - 0.26483839536511933, 0.19014430285482856, 4.0593499999999993, 0.24197569714517148, 0.19014430285482856, 4.0593499999999993, 0.24197569714517148, - 0.16728160463488068, 4.2729999999999997, 0.26483839536511933, 0.16728160463488068, 4.2729999999999997, 0.26483839536511933, 0.19014430285482856, - 4.2729999999999997, 0.24197569714517148, 0.19014430285482856, 4.2729999999999997, - 0.31132160463488068, 0.16995569714517142, 0, 0.3368583953651193, 0.16995569714517142, 0, 0.3368583953651193, 0.18643419768255964, 0, 0.31132160463488068, - 0.18643419768255964, 0, 0.31132160463488068, 0.16995569714517142, 0.21364999999999998, 0.3368583953651193, 0.16995569714517142, 0.21364999999999998, - 0.3368583953651193, 0.18643419768255964, 0.21364999999999998, 0.31132160463488068, 0.18643419768255964, 0.21364999999999998, 0.31132160463488068, - 0.16995569714517142, 0.21364999999999998, 0.3368583953651193, 0.16995569714517142, 0.21364999999999998, 0.3368583953651193, 0.18643419768255964, - 0.21364999999999998, 0.31132160463488068, 0.18643419768255964, 0.21364999999999998, 0.31132160463488068, 0.16995569714517142, 0.42729999999999996, - 0.3368583953651193, 0.16995569714517142, 0.42729999999999996, 0.3368583953651193, 0.18643419768255964, 0.42729999999999996, 0.31132160463488068, - 0.18643419768255964, 0.42729999999999996, 0.31132160463488068, 0.16995569714517142, 0.42729999999999996, 0.3368583953651193, 0.16995569714517142, - 0.42729999999999996, 0.3368583953651193, 0.18643419768255964, 0.42729999999999996, 0.31132160463488068, 0.18643419768255964, 0.42729999999999996, - 0.31132160463488068, 0.16995569714517142, 0.64094999999999991, 0.3368583953651193, 0.16995569714517142, 0.64094999999999991, 0.3368583953651193, - 0.18643419768255964, 0.64094999999999991, 0.31132160463488068, 0.18643419768255964, 0.64094999999999991, 0.31132160463488068, 0.16995569714517142, - 0.64094999999999991, 0.3368583953651193, 0.16995569714517142, 0.64094999999999991, 0.3368583953651193, 0.18643419768255964, 0.64094999999999991, - 0.31132160463488068, 0.18643419768255964, 0.64094999999999991, 0.31132160463488068, 0.16995569714517142, 0.85459999999999992, 0.3368583953651193, - 0.16995569714517142, 0.85459999999999992, 0.3368583953651193, 0.18643419768255964, 0.85459999999999992, 0.31132160463488068, 0.18643419768255964, - 0.85459999999999992, 0.31132160463488068, 0.16995569714517142, 0.85459999999999992, 0.3368583953651193, 0.16995569714517142, 0.85459999999999992, - 0.3368583953651193, 0.18643419768255964, 0.85459999999999992, 0.31132160463488068, 0.18643419768255964, 0.85459999999999992, 0.31132160463488068, - 0.16995569714517142, 1.0682499999999999, 0.3368583953651193, 0.16995569714517142, 1.0682499999999999, 0.3368583953651193, 0.18643419768255964, - 1.0682499999999999, 0.31132160463488068, 0.18643419768255964, 1.0682499999999999, 0.31132160463488068, 0.16995569714517142, 1.0682499999999999, - 0.3368583953651193, 0.16995569714517142, 1.0682499999999999, 0.3368583953651193, 0.18643419768255964, 1.0682499999999999, 0.31132160463488068, - 0.18643419768255964, 1.0682499999999999, 0.31132160463488068, 0.16995569714517142, 1.2818999999999998, 0.3368583953651193, 0.16995569714517142, - 1.2818999999999998, 0.3368583953651193, 0.18643419768255964, 1.2818999999999998, 0.31132160463488068, 0.18643419768255964, 1.2818999999999998, - 0.31132160463488068, 0.16995569714517142, 1.2818999999999998, 0.3368583953651193, 0.16995569714517142, 1.2818999999999998, 0.3368583953651193, - 0.18643419768255964, 1.2818999999999998, 0.31132160463488068, 0.18643419768255964, 1.2818999999999998, 0.31132160463488068, 0.16995569714517142, - 1.4955499999999999, 0.3368583953651193, 0.16995569714517142, 1.4955499999999999, 0.3368583953651193, 0.18643419768255964, 1.4955499999999999, - 0.31132160463488068, 0.18643419768255964, 1.4955499999999999, 0.31132160463488068, 0.16995569714517142, 1.4955499999999999, 0.3368583953651193, - 0.16995569714517142, 1.4955499999999999, 0.3368583953651193, 0.18643419768255964, 1.4955499999999999, 0.31132160463488068, 0.18643419768255964, - 1.4955499999999999, 0.31132160463488068, 0.16995569714517142, 1.7091999999999998, 0.3368583953651193, 0.16995569714517142, 1.7091999999999998, - 0.3368583953651193, 0.18643419768255964, 1.7091999999999998, 0.31132160463488068, 0.18643419768255964, 1.7091999999999998, 0.31132160463488068, - 0.16995569714517142, 1.7091999999999998, 0.3368583953651193, 0.16995569714517142, 1.7091999999999998, 0.3368583953651193, 0.18643419768255964, - 1.7091999999999998, 0.31132160463488068, 0.18643419768255964, 1.7091999999999998, 0.31132160463488068, 0.16995569714517142, 1.9228499999999997, - 0.3368583953651193, 0.16995569714517142, 1.9228499999999997, 0.3368583953651193, 0.18643419768255964, 1.9228499999999997, 0.31132160463488068, - 0.18643419768255964, 1.9228499999999997, 0.31132160463488068, 0.16995569714517142, 1.9228499999999997, 0.3368583953651193, 0.16995569714517142, - 1.9228499999999997, 0.3368583953651193, 0.18643419768255964, 1.9228499999999997, 0.31132160463488068, 0.18643419768255964, 1.9228499999999997, - 0.31132160463488068, 0.16995569714517142, 2.1364999999999998, 0.3368583953651193, 0.16995569714517142, 2.1364999999999998, 0.3368583953651193, - 0.18643419768255964, 2.1364999999999998, 0.31132160463488068, 0.18643419768255964, 2.1364999999999998, 0.31132160463488068, 0.16995569714517142, - 2.1364999999999998, 0.3368583953651193, 0.16995569714517142, 2.1364999999999998, 0.3368583953651193, 0.18643419768255964, 2.1364999999999998, - 0.31132160463488068, 0.18643419768255964, 2.1364999999999998, 0.31132160463488068, 0.16995569714517142, 2.3501499999999997, 0.3368583953651193, - 0.16995569714517142, 2.3501499999999997, 0.3368583953651193, 0.18643419768255964, 2.3501499999999997, 0.31132160463488068, 0.18643419768255964, - 2.3501499999999997, 0.31132160463488068, 0.16995569714517142, 2.3501499999999997, 0.3368583953651193, 0.16995569714517142, 2.3501499999999997, - 0.3368583953651193, 0.18643419768255964, 2.3501499999999997, 0.31132160463488068, 0.18643419768255964, 2.3501499999999997, 0.31132160463488068, - 0.16995569714517142, 2.5637999999999996, 0.3368583953651193, 0.16995569714517142, 2.5637999999999996, 0.3368583953651193, 0.18643419768255964, - 2.5637999999999996, 0.31132160463488068, 0.18643419768255964, 2.5637999999999996, 0.31132160463488068, 0.16995569714517142, 2.5637999999999996, - 0.3368583953651193, 0.16995569714517142, 2.5637999999999996, 0.3368583953651193, 0.18643419768255964, 2.5637999999999996, 0.31132160463488068, - 0.18643419768255964, 2.5637999999999996, 0.31132160463488068, 0.16995569714517142, 2.7774499999999995, 0.3368583953651193, 0.16995569714517142, - 2.7774499999999995, 0.3368583953651193, 0.18643419768255964, 2.7774499999999995, 0.31132160463488068, 0.18643419768255964, 2.7774499999999995, - 0.31132160463488068, 0.16995569714517142, 2.7774499999999995, 0.3368583953651193, 0.16995569714517142, 2.7774499999999995, 0.3368583953651193, - 0.18643419768255964, 2.7774499999999995, 0.31132160463488068, 0.18643419768255964, 2.7774499999999995, 0.31132160463488068, 0.16995569714517142, - 2.9910999999999999, 0.3368583953651193, 0.16995569714517142, 2.9910999999999999, 0.3368583953651193, 0.18643419768255964, 2.9910999999999999, - 0.31132160463488068, 0.18643419768255964, 2.9910999999999999, 0.31132160463488068, 0.16995569714517142, 2.9910999999999999, 0.3368583953651193, - 0.16995569714517142, 2.9910999999999999, 0.3368583953651193, 0.18643419768255964, 2.9910999999999999, 0.31132160463488068, 0.18643419768255964, - 2.9910999999999999, 0.31132160463488068, 0.16995569714517142, 3.2047499999999998, 0.3368583953651193, 0.16995569714517142, 3.2047499999999998, - 0.3368583953651193, 0.18643419768255964, 3.2047499999999998, 0.31132160463488068, 0.18643419768255964, 3.2047499999999998, 0.31132160463488068, - 0.16995569714517142, 3.2047499999999998, 0.3368583953651193, 0.16995569714517142, 3.2047499999999998, 0.3368583953651193, 0.18643419768255964, - 3.2047499999999998, 0.31132160463488068, 0.18643419768255964, 3.2047499999999998, 0.31132160463488068, 0.16995569714517142, 3.4183999999999997, - 0.3368583953651193, 0.16995569714517142, 3.4183999999999997, 0.3368583953651193, 0.18643419768255964, 3.4183999999999997, 0.31132160463488068, - 0.18643419768255964, 3.4183999999999997, 0.31132160463488068, 0.16995569714517142, 3.4183999999999997, 0.3368583953651193, 0.16995569714517142, - 3.4183999999999997, 0.3368583953651193, 0.18643419768255964, 3.4183999999999997, 0.31132160463488068, 0.18643419768255964, 3.4183999999999997, - 0.31132160463488068, 0.16995569714517142, 3.6320499999999996, 0.3368583953651193, - 0.16995569714517142, 3.6320499999999996, 0.3368583953651193, 0.18643419768255964, 3.6320499999999996, 0.31132160463488068, 0.18643419768255964, - 3.6320499999999996, 0.31132160463488068, 0.16995569714517142, 3.6320499999999996, 0.3368583953651193, 0.16995569714517142, 3.6320499999999996, - 0.3368583953651193, 0.18643419768255964, 3.6320499999999996, 0.31132160463488068, 0.18643419768255964, 3.6320499999999996, 0.31132160463488068, - 0.16995569714517142, 3.8456999999999995, 0.3368583953651193, 0.16995569714517142, 3.8456999999999995, 0.3368583953651193, 0.18643419768255964, - 3.8456999999999995, 0.31132160463488068, 0.18643419768255964, 3.8456999999999995, 0.31132160463488068, 0.16995569714517142, 3.8456999999999995, - 0.3368583953651193, 0.16995569714517142, 3.8456999999999995, 0.3368583953651193, 0.18643419768255964, 3.8456999999999995, 0.31132160463488068, - 0.18643419768255964, 3.8456999999999995, 0.31132160463488068, 0.16995569714517142, 4.0593499999999993, 0.3368583953651193, 0.16995569714517142, - 4.0593499999999993, 0.3368583953651193, 0.18643419768255964, 4.0593499999999993, 0.31132160463488068, 0.18643419768255964, 4.0593499999999993, - 0.31132160463488068, 0.16995569714517142, 4.0593499999999993, 0.3368583953651193, 0.16995569714517142, 4.0593499999999993, 0.3368583953651193, - 0.18643419768255964, 4.0593499999999993, 0.31132160463488068, 0.18643419768255964, 4.0593499999999993, 0.31132160463488068, 0.16995569714517142, - 4.2729999999999997, 0.3368583953651193, 0.16995569714517142, 4.2729999999999997, 0.3368583953651193, 0.18643419768255964, 4.2729999999999997, - 0.31132160463488068, 0.18643419768255964, 4.2729999999999997, 0.38334160463488065, 0.1672816046348807, 0, 0.40620430285482856, 0.1672816046348807, 0, - 0.40620430285482856, 0.19014430285482853, 0, 0.38334160463488065, 0.19014430285482853, 0, 0.38334160463488065, 0.1672816046348807, 0.21364999999999998, - 0.40620430285482856, 0.1672816046348807, 0.21364999999999998, 0.40620430285482856, 0.19014430285482853, 0.21364999999999998, 0.38334160463488065, - 0.19014430285482853, 0.21364999999999998, 0.38334160463488065, 0.1672816046348807, 0.21364999999999998, 0.40620430285482856, 0.1672816046348807, - 0.21364999999999998, 0.40620430285482856, 0.19014430285482853, 0.21364999999999998, 0.38334160463488065, 0.19014430285482853, 0.21364999999999998, - 0.38334160463488065, 0.1672816046348807, 0.42729999999999996, 0.40620430285482856, 0.1672816046348807, 0.42729999999999996, 0.40620430285482856, - 0.19014430285482853, 0.42729999999999996, 0.38334160463488065, 0.19014430285482853, 0.42729999999999996, 0.38334160463488065, 0.1672816046348807, - 0.42729999999999996, 0.40620430285482856, 0.1672816046348807, 0.42729999999999996, 0.40620430285482856, 0.19014430285482853, 0.42729999999999996, - 0.38334160463488065, 0.19014430285482853, 0.42729999999999996, 0.38334160463488065, 0.1672816046348807, 0.64094999999999991, 0.40620430285482856, - 0.1672816046348807, 0.64094999999999991, 0.40620430285482856, 0.19014430285482853, 0.64094999999999991, 0.38334160463488065, 0.19014430285482853, - 0.64094999999999991, 0.38334160463488065, 0.1672816046348807, 0.64094999999999991, 0.40620430285482856, 0.1672816046348807, 0.64094999999999991, - 0.40620430285482856, 0.19014430285482853, 0.64094999999999991, 0.38334160463488065, 0.19014430285482853, 0.64094999999999991, 0.38334160463488065, - 0.1672816046348807, 0.85459999999999992, 0.40620430285482856, 0.1672816046348807, 0.85459999999999992, 0.40620430285482856, 0.19014430285482853, - 0.85459999999999992, 0.38334160463488065, 0.19014430285482853, 0.85459999999999992, 0.38334160463488065, 0.1672816046348807, 0.85459999999999992, - 0.40620430285482856, 0.1672816046348807, 0.85459999999999992, 0.40620430285482856, 0.19014430285482853, 0.85459999999999992, 0.38334160463488065, - 0.19014430285482853, 0.85459999999999992, 0.38334160463488065, 0.1672816046348807, 1.0682499999999999, 0.40620430285482856, 0.1672816046348807, - 1.0682499999999999, 0.40620430285482856, 0.19014430285482853, 1.0682499999999999, 0.38334160463488065, 0.19014430285482853, 1.0682499999999999, - 0.38334160463488065, 0.1672816046348807, 1.0682499999999999, 0.40620430285482856, 0.1672816046348807, 1.0682499999999999, 0.40620430285482856, - 0.19014430285482853, 1.0682499999999999, 0.38334160463488065, 0.19014430285482853, 1.0682499999999999, 0.38334160463488065, 0.1672816046348807, - 1.2818999999999998, 0.40620430285482856, 0.1672816046348807, 1.2818999999999998, 0.40620430285482856, 0.19014430285482853, 1.2818999999999998, - 0.38334160463488065, 0.19014430285482853, 1.2818999999999998, 0.38334160463488065, 0.1672816046348807, 1.2818999999999998, 0.40620430285482856, - 0.1672816046348807, 1.2818999999999998, 0.40620430285482856, 0.19014430285482853, 1.2818999999999998, 0.38334160463488065, 0.19014430285482853, - 1.2818999999999998, 0.38334160463488065, 0.1672816046348807, 1.4955499999999999, 0.40620430285482856, 0.1672816046348807, 1.4955499999999999, - 0.40620430285482856, 0.19014430285482853, 1.4955499999999999, 0.38334160463488065, 0.19014430285482853, 1.4955499999999999, 0.38334160463488065, - 0.1672816046348807, 1.4955499999999999, 0.40620430285482856, 0.1672816046348807, 1.4955499999999999, 0.40620430285482856, 0.19014430285482853, - 1.4955499999999999, 0.38334160463488065, 0.19014430285482853, 1.4955499999999999, 0.38334160463488065, 0.1672816046348807, 1.7091999999999998, - 0.40620430285482856, 0.1672816046348807, 1.7091999999999998, 0.40620430285482856, 0.19014430285482853, 1.7091999999999998, 0.38334160463488065, - 0.19014430285482853, 1.7091999999999998, 0.38334160463488065, 0.1672816046348807, 1.7091999999999998, 0.40620430285482856, 0.1672816046348807, - 1.7091999999999998, 0.40620430285482856, 0.19014430285482853, 1.7091999999999998, 0.38334160463488065, 0.19014430285482853, 1.7091999999999998, - 0.38334160463488065, 0.1672816046348807, 1.9228499999999997, 0.40620430285482856, 0.1672816046348807, 1.9228499999999997, 0.40620430285482856, - 0.19014430285482853, 1.9228499999999997, 0.38334160463488065, 0.19014430285482853, 1.9228499999999997, 0.38334160463488065, 0.1672816046348807, - 1.9228499999999997, 0.40620430285482856, 0.1672816046348807, 1.9228499999999997, 0.40620430285482856, 0.19014430285482853, 1.9228499999999997, - 0.38334160463488065, 0.19014430285482853, 1.9228499999999997, 0.38334160463488065, 0.1672816046348807, 2.1364999999999998, 0.40620430285482856, - 0.1672816046348807, 2.1364999999999998, 0.40620430285482856, 0.19014430285482853, 2.1364999999999998, 0.38334160463488065, 0.19014430285482853, - 2.1364999999999998, 0.38334160463488065, 0.1672816046348807, 2.1364999999999998, 0.40620430285482856, 0.1672816046348807, 2.1364999999999998, - 0.40620430285482856, 0.19014430285482853, 2.1364999999999998, 0.38334160463488065, 0.19014430285482853, 2.1364999999999998, 0.38334160463488065, - 0.1672816046348807, 2.3501499999999997, 0.40620430285482856, 0.1672816046348807, 2.3501499999999997, 0.40620430285482856, 0.19014430285482853, - 2.3501499999999997, 0.38334160463488065, 0.19014430285482853, 2.3501499999999997, 0.38334160463488065, 0.1672816046348807, 2.3501499999999997, - 0.40620430285482856, 0.1672816046348807, 2.3501499999999997, 0.40620430285482856, 0.19014430285482853, 2.3501499999999997, 0.38334160463488065, - 0.19014430285482853, 2.3501499999999997, 0.38334160463488065, 0.1672816046348807, 2.5637999999999996, 0.40620430285482856, 0.1672816046348807, - 2.5637999999999996, 0.40620430285482856, 0.19014430285482853, 2.5637999999999996, 0.38334160463488065, 0.19014430285482853, 2.5637999999999996, - 0.38334160463488065, 0.1672816046348807, 2.5637999999999996, 0.40620430285482856, 0.1672816046348807, 2.5637999999999996, 0.40620430285482856, - 0.19014430285482853, 2.5637999999999996, 0.38334160463488065, 0.19014430285482853, 2.5637999999999996, 0.38334160463488065, 0.1672816046348807, - 2.7774499999999995, 0.40620430285482856, 0.1672816046348807, 2.7774499999999995, 0.40620430285482856, 0.19014430285482853, 2.7774499999999995, - 0.38334160463488065, 0.19014430285482853, 2.7774499999999995, 0.38334160463488065, 0.1672816046348807, 2.7774499999999995, 0.40620430285482856, - 0.1672816046348807, 2.7774499999999995, 0.40620430285482856, 0.19014430285482853, - 2.7774499999999995, 0.38334160463488065, 0.19014430285482853, 2.7774499999999995, 0.38334160463488065, 0.1672816046348807, 2.9910999999999999, - 0.40620430285482856, 0.1672816046348807, 2.9910999999999999, 0.40620430285482856, 0.19014430285482853, 2.9910999999999999, 0.38334160463488065, - 0.19014430285482853, 2.9910999999999999, 0.38334160463488065, 0.1672816046348807, 2.9910999999999999, 0.40620430285482856, 0.1672816046348807, - 2.9910999999999999, 0.40620430285482856, 0.19014430285482853, 2.9910999999999999, 0.38334160463488065, 0.19014430285482853, 2.9910999999999999, - 0.38334160463488065, 0.1672816046348807, 3.2047499999999998, 0.40620430285482856, 0.1672816046348807, 3.2047499999999998, 0.40620430285482856, - 0.19014430285482853, 3.2047499999999998, 0.38334160463488065, 0.19014430285482853, 3.2047499999999998, 0.38334160463488065, 0.1672816046348807, - 3.2047499999999998, 0.40620430285482856, 0.1672816046348807, 3.2047499999999998, 0.40620430285482856, 0.19014430285482853, 3.2047499999999998, - 0.38334160463488065, 0.19014430285482853, 3.2047499999999998, 0.38334160463488065, 0.1672816046348807, 3.4183999999999997, 0.40620430285482856, - 0.1672816046348807, 3.4183999999999997, 0.40620430285482856, 0.19014430285482853, 3.4183999999999997, 0.38334160463488065, 0.19014430285482853, - 3.4183999999999997, 0.38334160463488065, 0.1672816046348807, 3.4183999999999997, 0.40620430285482856, 0.1672816046348807, 3.4183999999999997, - 0.40620430285482856, 0.19014430285482853, 3.4183999999999997, 0.38334160463488065, 0.19014430285482853, 3.4183999999999997, 0.38334160463488065, - 0.1672816046348807, 3.6320499999999996, 0.40620430285482856, 0.1672816046348807, 3.6320499999999996, 0.40620430285482856, 0.19014430285482853, - 3.6320499999999996, 0.38334160463488065, 0.19014430285482853, 3.6320499999999996, 0.38334160463488065, 0.1672816046348807, 3.6320499999999996, - 0.40620430285482856, 0.1672816046348807, 3.6320499999999996, 0.40620430285482856, 0.19014430285482853, 3.6320499999999996, 0.38334160463488065, - 0.19014430285482853, 3.6320499999999996, 0.38334160463488065, 0.1672816046348807, 3.8456999999999995, 0.40620430285482856, 0.1672816046348807, - 3.8456999999999995, 0.40620430285482856, 0.19014430285482853, 3.8456999999999995, 0.38334160463488065, 0.19014430285482853, 3.8456999999999995, - 0.38334160463488065, 0.1672816046348807, 3.8456999999999995, 0.40620430285482856, 0.1672816046348807, 3.8456999999999995, 0.40620430285482856, - 0.19014430285482853, 3.8456999999999995, 0.38334160463488065, 0.19014430285482853, 3.8456999999999995, 0.38334160463488065, 0.1672816046348807, - 4.0593499999999993, 0.40620430285482856, 0.1672816046348807, 4.0593499999999993, 0.40620430285482856, 0.19014430285482853, 4.0593499999999993, - 0.38334160463488065, 0.19014430285482853, 4.0593499999999993, 0.38334160463488065, 0.1672816046348807, 4.0593499999999993, 0.40620430285482856, - 0.1672816046348807, 4.0593499999999993, 0.40620430285482856, 0.19014430285482853, 4.0593499999999993, 0.38334160463488065, 0.19014430285482853, - 4.0593499999999993, 0.38334160463488065, 0.1672816046348807, 4.2729999999999997, 0.40620430285482856, 0.1672816046348807, 4.2729999999999997, - 0.40620430285482856, 0.19014430285482853, 4.2729999999999997, 0.38334160463488065, 0.19014430285482853, 4.2729999999999997 - }; - - -const int connTFH8[2560]={ - 1, 2, 7, 6, 28, 29, 34, 33, 2, 3, 8, 7, 29, 30, 35, 34, 3, 4, 9, 8, 30, 31, 36, 35, 4, 5, 10, 9, 31, 32, 37, 36, 6, 7, 12, 11, 33, 34, 39, 38, 7, 8, 13, 12, 34, 35, 40, 39, - 8, 9, 14, 13, 35, 36, 41, 40, 9, 10, 15, 14, 36, 37, 42, 41, 11, 12, 17, 16, 38, 39, 44, 43, 12, 13, 18, 17, 39, 40, 45, 44, 13, 14, 19, 18, 40, 41, 46, 45, 14, 15, 20, 19, - 41, 42, 47, 46, 16, 17, 21, 26, 43, 44, 48, 53, 17, 18, 22, 21, 44, 45, 49, 48, 18, 19, 23, 22, 45, 46, 50, 49, 19, 20, 24, 23, 46, 47, 51, 50, 28, 29, 34, 33, 55, 56, 61, 60, - 29, 30, 35, 34, 56, 57, 62, 61, 30, 31, 36, 35, 57, 58, 63, 62, 31, 32, 37, 36, 58, 59, 64, 63, 33, 34, 39, 38, 60, 61, 66, 65, 34, 35, 40, 39, 61, 62, 67, 66, 35, 36, 41, 40, - 62, 63, 68, 67, 36, 37, 42, 41, 63, 64, 69, 68, 38, 39, 44, 43, 65, 66, 71, 70, 39, 40, 45, 44, 66, 67, 72, 71, 40, 41, 46, 45, 67, 68, 73, 72, 41, 42, 47, 46, 68, 69, 74, 73, - 43, 44, 48, 53, 70, 71, 75, 80, 44, 45, 49, 48, 71, 72, 76, 75, 45, 46, 50, 49, 72, 73, 77, 76, 46, 47, 51, 50, 73, 74, 78, 77, 55, 56, 61, 60, 82, 83, 88, 87, 56, 57, 62, 61, - 83, 84, 89, 88, 57, 58, 63, 62, 84, 85, 90, 89, 58, 59, 64, 63, 85, 86, 91, 90, 60, 61, 66, 65, 87, 88, 93, 92, 61, 62, 67, 66, 88, 89, 94, 93, 62, 63, 68, 67, 89, 90, 95, 94, - 63, 64, 69, 68, 90, 91, 96, 95, 65, 66, 71, 70, 92, 93, 98, 97, 66, 67, 72, 71, 93, 94, 99, 98, 67, 68, 73, 72, 94, 95, 100, 99, 68, 69, 74, 73, 95, 96, 101, 100, 70, 71, 75, - 80, 97, 98, 102, 107, 71, 72, 76, 75, 98, 99, 103, 102, 72, 73, 77, 76, 99, 100, 104, 103, 73, 74, 78, 77, 100, 101, 105, 104, 82, 83, 88, 87, 109, 110, 115, 114, 83, 84, 89, - 88, 110, 111, 116, 115, 84, 85, 90, 89, 111, 112, 117, 116, 85, 86, 91, 90, 112, 113, 118, 117, 87, 88, 93, 92, 114, 115, 120, 119, 88, 89, 94, 93, 115, 116, 121, 120, 89, 90, - 95, 94, 116, 117, 122, 121, 90, 91, 96, 95, 117, 118, 123, 122, 92, 93, 98, 97, 119, 120, 125, 124, 93, 94, 99, 98, 120, 121, 126, 125, 94, 95, 100, 99, 121, 122, 127, 126, 95, - 96, 101, 100, 122, 123, 128, 127, 97, 98, 102, 107, 124, 125, 129, 134, 98, 99, 103, 102, 125, 126, 130, 129, 99, 100, 104, 103, 126, 127, 131, 130, 100, 101, 105, 104, 127, 128, - 132, 131, 109, 110, 115, 114, 136, 137, 142, 141, 110, 111, 116, 115, 137, 138, 143, 142, 111, 112, 117, 116, 138, 139, 144, 143, 112, 113, 118, 117, 139, 140, 145, 144, 114, 115, - 120, 119, 141, 142, 147, 146, 115, 116, 121, 120, 142, 143, 148, 147, 116, 117, 122, 121, 143, 144, 149, 148, 117, 118, 123, 122, 144, 145, 150, 149, 119, 120, 125, 124, 146, 147, - 152, 151, 120, 121, 126, 125, 147, 148, 153, 152, 121, 122, 127, 126, 148, 149, 154, 153, 122, 123, 128, 127, 149, 150, 155, 154, 124, 125, 129, 134, 151, 152, 156, 161, 125, 126, 130, - 129, 152, 153, 157, 156, 126, 127, 131, 130, 153, 154, 158, 157, 127, 128, 132, 131, 154, 155, 159, 158, 136, 137, 142, 141, 163, 164, 169, 168, 137, 138, 143, 142, 164, 165, 170, 169, 138, 139, 144, 143, 165, 166, 171, 170, 139, - 140, 145, 144, 166, 167, 172, 171, 141, 142, 147, 146, 168, 169, 174, 173, 142, 143, 148, 147, 169, 170, 175, 174, 143, 144, 149, 148, 170, 171, 176, 175, 144, 145, 150, 149, 171, 172, 177, 176, 146, 147, 152, 151, 173, 174, 179, - 178, 147, 148, 153, 152, 174, 175, 180, 179, 148, 149, 154, 153, 175, 176, 181, 180, 149, 150, 155, 154, 176, 177, 182, 181, 151, 152, 156, 161, 178, 179, 183, 188, 152, 153, 157, 156, 179, 180, 184, 183, 153, 154, 158, 157, 180, - 181, 185, 184, 154, 155, 159, 158, 181, 182, 186, 185, 163, 164, 169, 168, 190, 191, 196, 195, 164, 165, 170, 169, 191, 192, 197, 196, 165, 166, 171, 170, 192, 193, 198, 197, 166, 167, 172, 171, 193, 194, 199, 198, 168, 169, 174, - 173, 195, 196, 201, 200, 169, 170, 175, 174, 196, 197, 202, 201, 170, 171, 176, 175, 197, 198, 203, 202, 171, 172, 177, 176, 198, 199, 204, 203, 173, 174, 179, 178, 200, 201, 206, 205, 174, 175, 180, 179, 201, 202, 207, 206, 175, - 176, 181, 180, 202, 203, 208, 207, 176, 177, 182, 181, 203, 204, 209, 208, 178, 179, 183, 188, 205, 206, 210, 215, 179, 180, 184, 183, 206, 207, 211, 210, 180, 181, 185, 184, 207, 208, 212, 211, 181, 182, 186, 185, 208, 209, 213, - 212, 190, 191, 196, 195, 217, 218, 223, 222, 191, 192, 197, 196, 218, 219, 224, 223, 192, 193, 198, 197, 219, 220, 225, 224, 193, 194, 199, 198, 220, 221, 226, 225, 195, 196, 201, 200, 222, 223, 228, 227, 196, 197, 202, 201, 223, - 224, 229, 228, 197, 198, 203, 202, 224, 225, 230, 229, 198, 199, 204, 203, 225, 226, 231, 230, 200, 201, 206, 205, 227, 228, 233, 232, 201, 202, 207, 206, 228, 229, 234, 233, 202, 203, 208, 207, 229, 230, 235, 234, 203, 204, 209, - 208, 230, 231, 236, 235, 205, 206, 210, 215, 232, 233, 237, 242, 206, 207, 211, 210, 233, 234, 238, 237, 207, 208, 212, 211, 234, 235, 239, 238, 208, 209, 213, 212, 235, 236, 240, 239, 217, 218, 223, 222, 244, 245, 250, 249, 218, - 219, 224, 223, 245, 246, 251, 250, 219, 220, 225, 224, 246, 247, 252, 251, 220, 221, 226, 225, 247, 248, 253, 252, 222, 223, 228, 227, 249, 250, 255, 254, 223, 224, 229, 228, 250, 251, 256, 255, 224, 225, 230, 229, 251, 252, 257, - 256, 225, 226, 231, 230, 252, 253, 258, 257, 227, 228, 233, 232, 254, 255, 260, 259, 228, 229, 234, 233, 255, 256, 261, 260, 229, 230, 235, 234, 256, 257, 262, 261, 230, 231, 236, 235, 257, 258, 263, 262, 232, 233, 237, 242, 259, - 260, 264, 269, 233, 234, 238, 237, 260, 261, 265, 264, 234, 235, 239, 238, 261, 262, 266, 265, 235, 236, 240, 239, 262, 263, 267, 266, 244, 245, 250, 249, 271, 272, 277, 276, 245, 246, 251, 250, 272, 273, 278, 277, 246, 247, 252, - 251, 273, 274, 279, 278, 247, 248, 253, 252, 274, 275, 280, 279, 249, 250, 255, 254, 276, 277, 282, 281, 250, 251, 256, 255, 277, 278, 283, 282, 251, 252, 257, 256, 278, 279, 284, 283, 252, 253, 258, 257, 279, 280, 285, 284, 254, - 255, 260, 259, 281, 282, 287, 286, 255, 256, 261, 260, 282, 283, 288, 287, 256, 257, 262, 261, 283, 284, 289, 288, 257, 258, 263, 262, 284, 285, 290, 289, 259, 260, 264, 269, 286, 287, 291, 296, 260, 261, 265, 264, 287, 288, 292, - 291, 261, 262, 266, 265, 288, 289, 293, 292, 262, 263, 267, 266, 289, 290, 294, 293, 271, 272, 277, 276, 298, 299, 304, 303, 272, 273, 278, 277, 299, 300, 305, 304, 273, 274, 279, 278, 300, 301, 306, 305, 274, 275, 280, 279, 301, - 302, 307, 306, 276, 277, 282, 281, 303, 304, 309, 308, 277, 278, 283, 282, 304, 305, 310, 309, 278, 279, 284, 283, 305, 306, 311, 310, 279, 280, 285, 284, 306, 307, 312, 311, 281, 282, 287, 286, 308, 309, 314, 313, 282, 283, 288, - 287, 309, 310, 315, 314, 283, 284, 289, 288, 310, 311, 316, 315, 284, 285, 290, 289, 311, 312, 317, 316, 286, 287, 291, 296, 313, 314, 318, 323, 287, 288, 292, 291, 314, 315, 319, 318, 288, 289, 293, 292, 315, 316, 320, 319, 289, - 290, 294, 293, 316, 317, 321, 320, 298, 299, 304, 303, 325, 326, 331, 330, 299, 300, 305, 304, 326, 327, 332, 331, 300, 301, 306, 305, 327, 328, 333, 332, 301, 302, 307, 306, 328, 329, 334, 333, 303, 304, 309, 308, 330, 331, 336, - 335, 304, 305, 310, 309, 331, 332, 337, 336, 305, 306, 311, 310, 332, 333, 338, 337, 306, 307, 312, 311, 333, 334, 339, 338, 308, 309, 314, 313, 335, 336, 341, 340, 309, 310, 315, 314, 336, 337, 342, 341, 310, 311, 316, 315, 337, - 338, 343, 342, 311, 312, 317, 316, 338, 339, 344, 343, 313, 314, 318, 323, 340, 341, 345, 350, 314, 315, 319, 318, 341, 342, 346, 345, 315, 316, 320, 319, 342, 343, 347, 346, 316, 317, 321, 320, 343, 344, 348, 347, 325, 326, 331, - 330, 352, 353, 358, 357, 326, 327, 332, 331, 353, 354, 359, 358, 327, 328, 333, 332, 354, 355, 360, 359, 328, 329, 334, 333, 355, 356, 361, 360, 330, 331, 336, 335, 357, 358, 363, 362, 331, 332, 337, 336, 358, 359, 364, 363, 332, - 333, 338, 337, 359, 360, 365, 364, 333, 334, 339, 338, 360, 361, 366, 365, 335, 336, 341, 340, 362, 363, 368, 367, 336, 337, 342, 341, 363, 364, 369, 368, 337, 338, 343, 342, 364, 365, 370, 369, 338, 339, 344, 343, 365, 366, 371, - 370, 340, 341, 345, 350, 367, 368, 372, 377, 341, 342, 346, 345, 368, 369, 373, 372, 342, 343, 347, 346, 369, 370, 374, 373, 343, 344, 348, 347, 370, 371, 375, 374, 352, 353, 358, 357, 379, 380, 385, 384, 353, 354, 359, 358, 380, - 381, 386, 385, 354, 355, 360, 359, 381, 382, 387, 386, 355, 356, 361, 360, 382, 383, 388, 387, 357, 358, 363, 362, 384, 385, 390, 389, 358, 359, 364, 363, 385, 386, 391, 390, 359, 360, 365, 364, 386, 387, 392, 391, 360, 361, 366, - 365, 387, 388, 393, 392, 362, 363, 368, 367, 389, 390, 395, 394, 363, 364, 369, 368, 390, 391, 396, 395, 364, 365, 370, 369, 391, 392, 397, 396, 365, 366, 371, 370, 392, 393, 398, 397, 367, 368, 372, 377, 394, 395, 399, 404, 368, - 369, 373, 372, 395, 396, 400, 399, 369, 370, 374, 373, 396, 397, 401, 400, 370, 371, 375, 374, 397, 398, 402, 401, 379, 380, 385, 384, 406, 407, 412, 411, 380, 381, 386, 385, 407, 408, 413, 412, 381, 382, 387, 386, 408, 409, 414, - 413, 382, 383, 388, 387, 409, 410, 415, 414, 384, 385, 390, 389, 411, 412, 417, 416, 385, 386, 391, 390, 412, 413, 418, 417, 386, 387, 392, 391, 413, 414, 419, 418, 387, 388, 393, 392, 414, 415, 420, 419, 389, 390, 395, 394, 416, - 417, 422, 421, 390, 391, 396, 395, 417, 418, 423, 422, 391, 392, 397, 396, 418, 419, 424, 423, 392, 393, 398, 397, 419, 420, 425, 424, 394, 395, 399, 404, 421, 422, 426, 431, 395, 396, 400, 399, 422, 423, 427, 426, 396, 397, 401, - 400, 423, 424, 428, 427, 397, 398, 402, 401, 424, 425, 429, 428, 406, 407, 412, 411, 433, 434, 439, 438, 407, 408, 413, 412, 434, 435, 440, 439, 408, 409, 414, 413, 435, 436, 441, 440, 409, 410, 415, 414, 436, 437, 442, 441, 411, - 412, 417, 416, 438, 439, 444, 443, 412, 413, 418, 417, 439, 440, 445, 444, 413, 414, 419, 418, 440, 441, 446, 445, 414, 415, 420, 419, 441, 442, 447, 446, 416, 417, 422, 421, 443, 444, 449, 448, 417, 418, 423, 422, 444, 445, 450, - 449, 418, 419, 424, 423, 445, 446, 451, 450, 419, 420, 425, 424, 446, 447, 452, 451, 421, 422, 426, 431, 448, 449, 453, 458, 422, 423, 427, 426, 449, 450, 454, 453, 423, 424, 428, 427, 450, 451, 455, 454, 424, 425, 429, 428, 451, - 452, 456, 455, 433, 434, 439, 438, 460, 461, 466, 465, 434, 435, 440, 439, 461, 462, 467, 466, 435, 436, 441, 440, 462, 463, 468, 467, 436, 437, 442, 441, 463, 464, 469, 468, 438, 439, 444, 443, 465, 466, 471, 470, 439, 440, 445, - 444, 466, 467, 472, 471, 440, 441, 446, 445, 467, 468, 473, 472, 441, 442, 447, 446, 468, 469, 474, 473, 443, 444, 449, 448, 470, 471, 476, 475, 444, 445, 450, 449, 471, 472, 477, 476, 445, 446, 451, 450, 472, 473, 478, 477, 446, - 447, 452, 451, 473, 474, 479, 478, 448, 449, 453, 458, 475, 476, 480, 485, 449, 450, 454, 453, 476, 477, 481, 480, 450, 451, 455, 454, 477, 478, 482, 481, 451, 452, 456, 455, 478, 479, 483, 482, 460, 461, 466, 465, 487, 488, 493, - 492, 461, 462, 467, 466, 488, 489, 494, 493, 462, 463, 468, 467, 489, 490, 495, 494, 463, 464, 469, 468, 490, 491, 496, 495, 465, 466, 471, 470, 492, 493, 498, 497, 466, 467, 472, 471, 493, 494, 499, 498, 467, 468, 473, 472, 494, - 495, 500, 499, 468, 469, 474, 473, 495, 496, 501, 500, 470, 471, 476, 475, 497, 498, 503, 502, 471, 472, 477, 476, 498, 499, 504, 503, 472, 473, 478, 477, 499, 500, 505, 504, 473, 474, 479, 478, 500, 501, 506, 505, 475, 476, 480, - 485, 502, 503, 507, 512, 476, 477, 481, 480, 503, 504, 508, 507, 477, 478, 482, 481, 504, 505, 509, 508, 478, 479, 483, 482, 505, 506, 510, 509, 487, 488, 493, 492, 514, 515, 520, 519, 488, 489, 494, 493, 515, 516, 521, 520, 489, - 490, 495, 494, 516, 517, 522, 521, 490, 491, 496, 495, 517, 518, 523, 522, 492, 493, 498, 497, 519, 520, 525, 524, 493, 494, 499, 498, 520, 521, 526, 525, 494, 495, 500, 499, 521, 522, 527, 526, 495, 496, 501, 500, 522, 523, 528, - 527, 497, 498, 503, 502, 524, 525, 530, 529, 498, 499, 504, 503, 525, 526, 531, 530, 499, 500, 505, 504, 526, 527, 532, 531, 500, 501, 506, 505, 527, 528, 533, 532, 502, 503, 507, 512, 529, 530, 534, 539, 503, 504, 508, 507, 530, - 531, 535, 534, 504, 505, 509, 508, 531, 532, 536, 535, 505, 506, 510, 509, 532, 533, 537, 536, 514, 515, 520, 519, 541, 542, 547, 546, 515, 516, 521, 520, 542, 543, 548, 547, 516, 517, 522, 521, 543, 544, 549, 548, 517, 518, 523, - 522, 544, 545, 550, 549, 519, 520, 525, 524, 546, 547, 552, 551, 520, 521, 526, 525, 547, 548, 553, 552, 521, 522, 527, 526, 548, 549, 554, 553, 522, 523, 528, 527, 549, 550, 555, 554, 524, 525, 530, 529, 551, 552, 557, 556, 525, - 526, 531, 530, 552, 553, 558, 557, 526, 527, 532, 531, 553, 554, 559, 558, 527, 528, 533, 532, 554, 555, 560, 559, 529, 530, 534, 539, 556, 557, 561, 566, 530, 531, 535, 534, 557, 558, 562, 561, 531, 532, 536, 535, 558, 559, 563, - 562, 532, 533, 537, 536, 559, 560, 564, 563}; - -const int connTFPOLH[1000]={ - 0, 25, 26, 16, 11, 6, 1, -1, 27, 28, 33, 38, 43, 53, 52, -1, 0, 1, 28, 27, -1, 1, 6, 33, 28, -1, 6, 11, 38, 33, -1, 11, 16, 43, 38, -1, 16, 26, 53, 43, -1, 26, 25, 52, 53, -1, 25, 0, 27, 52, 27, 52, 53, 43, 38, 33, 28, -1, 54, 55, - 60, 65, 70, 80, 79, -1, 27, 28, 55, 54, -1, 28, 33, 60, 55, -1, 33, 38, 65, 60, -1, 38, 43, 70, 65, -1, 43, 53, 80, 70, -1, 53, 52, 79, 80, -1, 52, 27, 54, 79, 54, 79, 80, 70, 65, 60, 55, -1, 81, 82, 87, 92, 97, 107, 106, -1, 54, - 55, 82, 81, -1, 55, 60, 87, 82, -1, 60, 65, 92, 87, -1, 65, 70, 97, 92, -1, 70, 80, 107, 97, -1, 80, 79, 106, 107, -1, 79, 54, 81, 106, 81, 106, 107, 97, 92, 87, 82, -1, 108, 109, 114, 119, 124, 134, 133, -1, 81, 82, 109, 108, -1, - 82, 87, 114, 109, -1, 87, 92, 119, 114, -1, 92, 97, 124, 119, -1, 97, 107, 134, 124, -1, 107, 106, 133, 134, -1, 106, 81, 108, 133, 108, 133, 134, 124, 119, 114, 109, -1, 135, 136, 141, 146, 151, 161, 160, -1, 108, 109, 136, 135, - -1, 109, 114, 141, 136, -1, 114, 119, 146, 141, -1, 119, 124, 151, 146, -1, 124, 134, 161, 151, -1, 134, 133, 160, 161, -1, 133, 108, 135, 160, 135, 160, 161, 151, 146, 141, 136, -1, 162, 163, 168, 173, 178, 188, 187, -1, 135, 136, - 163, 162, -1, 136, 141, 168, 163, -1, 141, 146, 173, 168, -1, 146, 151, 178, 173, -1, 151, 161, 188, 178, -1, 161, 160, 187, 188, -1, 160, 135, 162, 187, 162, 187, 188, 178, 173, 168, 163, -1, 189, 190, 195, 200, 205, 215, 214, -1, - 162, 163, 190, 189, -1, 163, 168, 195, 190, -1, 168, 173, 200, 195, -1, 173, 178, 205, 200, -1, 178, 188, 215, 205, -1, 188, 187, 214, 215, -1, 187, 162, 189, 214, 189, 214, 215, 205, 200, 195, 190, -1, 216, 217, 222, 227, 232, 242, - 241, -1, 189, 190, 217, 216, -1, 190, 195, 222, 217, -1, 195, 200, 227, 222, -1, 200, 205, 232, 227, -1, 205, 215, 242, 232, -1, 215, 214, 241, 242, -1, 214, 189, 216, 241, 216, 241, 242, 232, 227, 222, 217, -1, 243, 244, 249, 254, -259, 269, 268, -1, 216, 217, 244, 243, -1, 217, 222, 249, 244, -1, 222, 227, 254, 249, -1, 227, 232, 259, 254, -1, 232, 242, 269, 259, -1, 242, 241, 268, 269, -1, 241, 216, 243, 268, 243, 268, 269, 259, 254, 249, 244, -1, 270, 271, 276, - 281, 286, 296, 295, -1, 243, 244, 271, 270, -1, 244, 249, 276, 271, -1, 249, 254, 281, 276, -1, 254, 259, 286, 281, -1, 259, 269, 296, 286, -1, 269, 268, 295, 296, -1, 268, 243, 270, 295, 270, 295, 296, 286, 281, 276, 271, -1, 297, 298, - 303, 308, 313, 323, 322, -1, 270, 271, 298, 297, -1, 271, 276, 303, 298, -1, 276, 281, 308, 303, -1, 281, 286, 313, 308, -1, 286, 296, 323, 313, -1, 296, 295, 322, 323, -1, 295, 270, 297, 322, 297, 322, 323, 313, 308, 303, 298, -1, 324, - 325, 330, 335, 340, 350, 349, -1, 297, 298, 325, 324, -1, 298, 303, 330, 325, -1, 303, 308, 335, 330, -1, 308, 313, 340, 335, -1, 313, 323, 350, 340, -1, 323, 322, 349, 350, -1, 322, 297, 324, 349, 324, 349, 350, 340, 335, 330, 325, -1, - 351, 352, 357, 362, 367, 377, 376, -1, 324, 325, 352, 351, -1, 325, 330, 357, 352, -1, 330, 335, 362, 357, -1, 335, 340, 367, 362, -1, 340, 350, 377, 367, -1, 350, 349, 376, 377, -1, 349, 324, 351, 376, 351, 376, 377, 367, 362, 357, 352, - -1, 378, 379, 384, 389, 394, 404, 403, -1, 351, 352, 379, 378, -1, 352, 357, 384, 379, -1, 357, 362, 389, 384, -1, 362, 367, 394, 389, -1, 367, 377, 404, 394, -1, 377, 376, 403, 404, -1, 376, 351, 378, 403, 378, 403, 404, 394, 389, 384, - 379, -1, 405, 406, 411, 416, 421, 431, 430, -1, 378, 379, 406, 405, -1, 379, 384, 411, 406, -1, 384, 389, 416, 411, -1, 389, 394, 421, 416, -1, 394, 404, 431, 421, -1, 404, 403, 430, 431, -1, 403, 378, 405, 430, 405, 430, 431, 421, 416, - 411, 406, -1, 432, 433, 438, 443, 448, 458, 457, -1, 405, 406, 433, 432, -1, 406, 411, 438, 433, -1, 411, 416, 443, 438, -1, 416, 421, 448, 443, -1, 421, 431, 458, 448, -1, 431, 430, 457, 458, -1, 430, 405, 432, 457, 432, 457, 458, 448, - 443, 438, 433, -1, 459, 460, 465, 470, 475, 485, 484, -1, 432, 433, 460, 459, -1, 433, 438, 465, 460, -1, 438, 443, 470, 465, -1, 443, 448, 475, 470, -1, 448, 458, 485, 475, -1, 458, 457, 484, 485, -1, 457, 432, 459, 484, 459, 484, 485, - 475, 470, 465, 460, -1, 486, 487, 492, 497, 502, 512, 511, -1, 459, 460, 487, 486, -1, 460, 465, 492, 487, -1, 465, 470, 497, 492, -1, 470, 475, 502, 497, -1, 475, 485, 512, 502, -1, 485, 484, 511, 512, -1, 484, 459, 486, 511, 486, 511, - 512, 502, 497, 492, 487, -1, 513, 514, 519, 524, 529, 539, 538, -1, 486, 487, 514, 513, -1, 487, 492, 519, 514, -1, 492, 497, 524, 519, -1, 497, 502, 529, 524, -1, 502, 512, 539, 529, -1, 512, 511, 538, 539, -1, 511, 486, 513, 538, 513, - 538, 539, 529, 524, 519, 514, -1, 540, 541, 546, 551, 556, 566, 565, -1, 513, 514, 541, 540, -1, 514, 519, 546, 541, -1, 519, 524, 551, 546, -1, 524, 529, 556, 551, -1, 529, 539, 566, 556, -1, 539, 538, 565, 566, -1, 538, 513, 540, 565 -}; - -const double coordsTF[1701]={ - 0, 0, 0, 0.21606, 0, 0, 0.25207000000000002, 0, 0, 0.32408999999999999, 0, 0, 0.39610999999999996, 0, 0, 0.43212, 0, 0, 0.21606, 0.03601, 0, - 0.25207000000000002, 0.03601, 0, 0.32408999999999999, 0.03601, 0, 0.39610999999999996, 0.03601, 0, 0.43212, 0.03601, 0, 0.21606, 0.10803, 0, 0.25207000000000002, - 0.10803, 0, 0.32408999999999999, 0.10803, 0, 0.39610999999999996, 0.10803, 0, 0.43212, 0.10803, 0, 0.21606, 0.18004999999999999, 0, 0.25207000000000002, - 0.18004999999999999, 0, 0.32408999999999999, 0.18004999999999999, 0, 0.39610999999999996, 0.18004999999999999, 0, 0.43212, 0.18004999999999999, 0, - 0.25207000000000002, 0.21605999999999997, 0, 0.32408999999999999, 0.21605999999999997, 0, 0.39610999999999996, 0.21605999999999997, 0, 0.43212, - 0.21605999999999997, 0, 0, 0.21606, 0, 0.21606, 0.21606, 0, 0, 0, 0.21364999999999998, 0.21606, 0, 0.21364999999999998, 0.25207000000000002, 0, - 0.21364999999999998, 0.32408999999999999, 0, 0.21364999999999998, 0.39610999999999996, 0, 0.21364999999999998, 0.43212, 0, 0.21364999999999998, 0.21606, 0.03601, - 0.21364999999999998, 0.25207000000000002, 0.03601, 0.21364999999999998, 0.32408999999999999, 0.03601, 0.21364999999999998, 0.39610999999999996, 0.03601, - 0.21364999999999998, 0.43212, 0.03601, 0.21364999999999998, 0.21606, 0.10803, 0.21364999999999998, 0.25207000000000002, 0.10803, 0.21364999999999998, - 0.32408999999999999, 0.10803, 0.21364999999999998, 0.39610999999999996, 0.10803, 0.21364999999999998, 0.43212, 0.10803, 0.21364999999999998, 0.21606, - 0.18004999999999999, 0.21364999999999998, 0.25207000000000002, 0.18004999999999999, 0.21364999999999998, 0.32408999999999999, 0.18004999999999999, - 0.21364999999999998, 0.39610999999999996, 0.18004999999999999, 0.21364999999999998, 0.43212, 0.18004999999999999, 0.21364999999999998, 0.25207000000000002, - 0.21605999999999997, 0.21364999999999998, 0.32408999999999999, 0.21605999999999997, 0.21364999999999998, 0.39610999999999996, 0.21605999999999997, - 0.21364999999999998, 0.43212, 0.21605999999999997, 0.21364999999999998, 0, 0.21606, 0.21364999999999998, 0.21606, 0.21606, 0.21364999999999998, 0, 0, - 0.42729999999999996, 0.21606, 0, 0.42729999999999996, 0.25207000000000002, 0, 0.42729999999999996, 0.32408999999999999, 0, 0.42729999999999996, - 0.39610999999999996, 0, 0.42729999999999996, 0.43212, 0, 0.42729999999999996, 0.21606, 0.03601, 0.42729999999999996, 0.25207000000000002, 0.03601, - 0.42729999999999996, 0.32408999999999999, 0.03601, 0.42729999999999996, 0.39610999999999996, 0.03601, 0.42729999999999996, 0.43212, 0.03601, 0.42729999999999996, - 0.21606, 0.10803, 0.42729999999999996, 0.25207000000000002, 0.10803,0.42729999999999996, 0.32408999999999999, 0.10803, 0.42729999999999996, 0.39610999999999996, 0.10803, 0.42729999999999996, 0.43212, 0.10803, - 0.42729999999999996, 0.21606, 0.18004999999999999, 0.42729999999999996, 0.25207000000000002, 0.18004999999999999, 0.42729999999999996, 0.32408999999999999, - 0.18004999999999999, 0.42729999999999996, 0.39610999999999996, 0.18004999999999999, 0.42729999999999996, 0.43212, 0.18004999999999999, 0.42729999999999996, - 0.25207000000000002, 0.21605999999999997, 0.42729999999999996, 0.32408999999999999, 0.21605999999999997, 0.42729999999999996, 0.39610999999999996, - 0.21605999999999997, 0.42729999999999996, 0.43212, 0.21605999999999997, 0.42729999999999996, 0, 0.21606, 0.42729999999999996, 0.21606, 0.21606, - 0.42729999999999996, 0, 0, 0.64094999999999991, 0.21606, 0, 0.64094999999999991, 0.25207000000000002, 0, 0.64094999999999991, 0.32408999999999999, 0, - 0.64094999999999991, 0.39610999999999996, 0, 0.64094999999999991, 0.43212, 0, 0.64094999999999991, 0.21606, 0.03601, 0.64094999999999991, 0.25207000000000002, - 0.03601, 0.64094999999999991, 0.32408999999999999, 0.03601, 0.64094999999999991, 0.39610999999999996, 0.03601, 0.64094999999999991, 0.43212, 0.03601, - 0.64094999999999991, 0.21606, 0.10803, 0.64094999999999991, 0.25207000000000002, 0.10803, 0.64094999999999991, 0.32408999999999999, 0.10803, 0.64094999999999991, - 0.39610999999999996, 0.10803, 0.64094999999999991, 0.43212, 0.10803, 0.64094999999999991, 0.21606, 0.18004999999999999, 0.64094999999999991, 0.25207000000000002, - 0.18004999999999999, 0.64094999999999991, 0.32408999999999999, 0.18004999999999999, 0.64094999999999991, 0.39610999999999996, 0.18004999999999999, - 0.64094999999999991, 0.43212, 0.18004999999999999, 0.64094999999999991, 0.25207000000000002, 0.21605999999999997, 0.64094999999999991, 0.32408999999999999, - 0.21605999999999997, 0.64094999999999991, 0.39610999999999996, 0.21605999999999997, 0.64094999999999991, 0.43212, 0.21605999999999997, 0.64094999999999991, 0, - 0.21606, 0.64094999999999991, 0.21606, 0.21606, 0.64094999999999991, 0, 0, 0.85459999999999992, 0.21606, 0, 0.85459999999999992, 0.25207000000000002, 0, - 0.85459999999999992, 0.32408999999999999, 0, 0.85459999999999992, 0.39610999999999996, 0, 0.85459999999999992, 0.43212, 0, 0.85459999999999992, 0.21606, 0.03601, - 0.85459999999999992, 0.25207000000000002, 0.03601, 0.85459999999999992, 0.32408999999999999, 0.03601, 0.85459999999999992, 0.39610999999999996, 0.03601, - 0.85459999999999992, 0.43212, 0.03601, 0.85459999999999992, 0.21606, 0.10803, 0.85459999999999992, 0.25207000000000002, 0.10803, 0.85459999999999992, - 0.32408999999999999, 0.10803, 0.85459999999999992, 0.39610999999999996, 0.10803, 0.85459999999999992, 0.43212, 0.10803, 0.85459999999999992, 0.21606, - 0.18004999999999999, 0.85459999999999992, 0.25207000000000002, 0.18004999999999999, 0.85459999999999992, 0.32408999999999999, 0.18004999999999999, - 0.85459999999999992, 0.39610999999999996, 0.18004999999999999, 0.85459999999999992, 0.43212, 0.18004999999999999, 0.85459999999999992, 0.25207000000000002, - 0.21605999999999997, 0.85459999999999992, 0.32408999999999999, 0.21605999999999997, 0.85459999999999992, 0.39610999999999996, 0.21605999999999997, - 0.85459999999999992, 0.43212, 0.21605999999999997, 0.85459999999999992, 0,0.21606, 0.85459999999999992, 0.21606, 0.21606, 0.85459999999999992, 0, 0, 1.0682499999999999, 0.21606, 0, 1.0682499999999999, 0.25207000000000002, 0, - 1.0682499999999999, 0.32408999999999999, 0, 1.0682499999999999, 0.39610999999999996, 0, 1.0682499999999999, 0.43212, 0, 1.0682499999999999, 0.21606, 0.03601, - 1.0682499999999999, 0.25207000000000002, 0.03601, 1.0682499999999999, 0.32408999999999999, 0.03601, 1.0682499999999999, 0.39610999999999996, 0.03601, - 1.0682499999999999, 0.43212, 0.03601, 1.0682499999999999, 0.21606, 0.10803, 1.0682499999999999, 0.25207000000000002, 0.10803, 1.0682499999999999, - 0.32408999999999999, 0.10803, 1.0682499999999999, 0.39610999999999996, 0.10803, 1.0682499999999999, 0.43212, 0.10803, 1.0682499999999999, 0.21606, - 0.18004999999999999, 1.0682499999999999, 0.25207000000000002, 0.18004999999999999, 1.0682499999999999, 0.32408999999999999, 0.18004999999999999, - 1.0682499999999999, 0.39610999999999996, 0.18004999999999999, 1.0682499999999999, 0.43212, 0.18004999999999999, 1.0682499999999999, 0.25207000000000002, - 0.21605999999999997, 1.0682499999999999, 0.32408999999999999, 0.21605999999999997, 1.0682499999999999, 0.39610999999999996, 0.21605999999999997, - 1.0682499999999999, 0.43212, 0.21605999999999997, 1.0682499999999999, 0, 0.21606, 1.0682499999999999, 0.21606, 0.21606, 1.0682499999999999, 0, 0, - 1.2818999999999998, 0.21606, 0, 1.2818999999999998, 0.25207000000000002, 0, 1.2818999999999998, 0.32408999999999999, 0, 1.2818999999999998, 0.39610999999999996, - 0, 1.2818999999999998, 0.43212, 0, 1.2818999999999998, 0.21606, 0.03601, 1.2818999999999998, 0.25207000000000002, 0.03601, 1.2818999999999998, - 0.32408999999999999, 0.03601, 1.2818999999999998, 0.39610999999999996, 0.03601, 1.2818999999999998, 0.43212, 0.03601, 1.2818999999999998, 0.21606, 0.10803, - 1.2818999999999998, 0.25207000000000002, 0.10803, 1.2818999999999998, 0.32408999999999999, 0.10803, 1.2818999999999998, 0.39610999999999996, 0.10803, - 1.2818999999999998, 0.43212, 0.10803, 1.2818999999999998, 0.21606, 0.18004999999999999, 1.2818999999999998, 0.25207000000000002, 0.18004999999999999, - 1.2818999999999998, 0.32408999999999999, 0.18004999999999999, 1.2818999999999998, 0.39610999999999996, 0.18004999999999999, 1.2818999999999998, 0.43212, - 0.18004999999999999, 1.2818999999999998, 0.25207000000000002, 0.21605999999999997, 1.2818999999999998, 0.32408999999999999, 0.21605999999999997, - 1.2818999999999998, 0.39610999999999996, 0.21605999999999997, 1.2818999999999998, 0.43212, 0.21605999999999997, 1.2818999999999998, 0, 0.21606, - 1.2818999999999998, 0.21606, 0.21606, 1.2818999999999998, 0, 0, 1.4955499999999999, 0.21606, 0, 1.4955499999999999, 0.25207000000000002, 0, 1.4955499999999999, - 0.32408999999999999, 0, 1.4955499999999999, 0.39610999999999996, 0, 1.4955499999999999, 0.43212, 0, 1.4955499999999999, 0.21606, 0.03601, 1.4955499999999999, - 0.25207000000000002, 0.03601, 1.4955499999999999, 0.32408999999999999, 0.03601, 1.4955499999999999, 0.39610999999999996, 0.03601, 1.4955499999999999, 0.43212, - 0.03601, 1.4955499999999999,0.21606, 0.10803, 1.4955499999999999, 0.25207000000000002, 0.10803, 1.4955499999999999, 0.32408999999999999, 0.10803, 1.4955499999999999, - 0.39610999999999996, 0.10803, 1.4955499999999999, 0.43212, 0.10803, 1.4955499999999999, 0.21606, 0.18004999999999999, 1.4955499999999999, 0.25207000000000002, - 0.18004999999999999, 1.4955499999999999, 0.32408999999999999, 0.18004999999999999, 1.4955499999999999, 0.39610999999999996, 0.18004999999999999, - 1.4955499999999999, 0.43212, 0.18004999999999999, 1.4955499999999999, 0.25207000000000002, 0.21605999999999997, 1.4955499999999999, 0.32408999999999999, - 0.21605999999999997, 1.4955499999999999, 0.39610999999999996, 0.21605999999999997, 1.4955499999999999, 0.43212, 0.21605999999999997, 1.4955499999999999, 0, - 0.21606, 1.4955499999999999, 0.21606, 0.21606, 1.4955499999999999, 0, 0, 1.7091999999999998, 0.21606, 0, 1.7091999999999998, 0.25207000000000002, 0, - 1.7091999999999998, 0.32408999999999999, 0, 1.7091999999999998, 0.39610999999999996, 0, 1.7091999999999998, 0.43212, 0, 1.7091999999999998, 0.21606, 0.03601, - 1.7091999999999998, 0.25207000000000002, 0.03601, 1.7091999999999998, 0.32408999999999999, 0.03601, 1.7091999999999998, 0.39610999999999996, 0.03601, - 1.7091999999999998, 0.43212, 0.03601, 1.7091999999999998, 0.21606, 0.10803, 1.7091999999999998, 0.25207000000000002, 0.10803, 1.7091999999999998, - 0.32408999999999999, 0.10803, 1.7091999999999998, 0.39610999999999996, 0.10803, 1.7091999999999998, 0.43212, 0.10803, 1.7091999999999998, 0.21606, - 0.18004999999999999, 1.7091999999999998, 0.25207000000000002, 0.18004999999999999, 1.7091999999999998, 0.32408999999999999, 0.18004999999999999, - 1.7091999999999998, 0.39610999999999996, 0.18004999999999999, 1.7091999999999998, 0.43212, 0.18004999999999999, 1.7091999999999998, 0.25207000000000002, - 0.21605999999999997, 1.7091999999999998, 0.32408999999999999, 0.21605999999999997, 1.7091999999999998, 0.39610999999999996, 0.21605999999999997, - 1.7091999999999998, 0.43212, 0.21605999999999997, 1.7091999999999998, 0, 0.21606, 1.7091999999999998, 0.21606, 0.21606, 1.7091999999999998, 0, 0, - 1.9228499999999997, 0.21606, 0, 1.9228499999999997, 0.25207000000000002, 0, 1.9228499999999997, 0.32408999999999999, 0, 1.9228499999999997, 0.39610999999999996, - 0, 1.9228499999999997, 0.43212, 0, 1.9228499999999997, 0.21606, 0.03601, 1.9228499999999997, 0.25207000000000002, 0.03601, 1.9228499999999997, - 0.32408999999999999, 0.03601, 1.9228499999999997, 0.39610999999999996, 0.03601, 1.9228499999999997, 0.43212, 0.03601, 1.9228499999999997, 0.21606, 0.10803, - 1.9228499999999997, 0.25207000000000002, 0.10803, 1.9228499999999997, 0.32408999999999999, 0.10803, 1.9228499999999997, 0.39610999999999996, 0.10803, - 1.9228499999999997, 0.43212, 0.10803, 1.9228499999999997, 0.21606, 0.18004999999999999, 1.9228499999999997, 0.25207000000000002, 0.18004999999999999, - 1.9228499999999997, 0.32408999999999999, 0.18004999999999999, 1.9228499999999997, 0.39610999999999996, 0.18004999999999999, 1.9228499999999997, 0.43212, - 0.18004999999999999, 1.9228499999999997, 0.25207000000000002, 0.21605999999999997, 1.9228499999999997, 0.32408999999999999, 0.21605999999999997, - 1.9228499999999997, 0.39610999999999996, 0.21605999999999997,1.9228499999999997, 0.43212, 0.21605999999999997, 1.9228499999999997, 0, 0.21606, 1.9228499999999997, 0.21606, 0.21606, 1.9228499999999997, 0, 0, - 2.1364999999999998, 0.21606, 0, 2.1364999999999998, 0.25207000000000002, 0, 2.1364999999999998, 0.32408999999999999, 0, 2.1364999999999998, 0.39610999999999996, - 0, 2.1364999999999998, 0.43212, 0, 2.1364999999999998, 0.21606, 0.03601, 2.1364999999999998, 0.25207000000000002, 0.03601, 2.1364999999999998, - 0.32408999999999999, 0.03601, 2.1364999999999998, 0.39610999999999996, 0.03601, 2.1364999999999998, 0.43212, 0.03601, 2.1364999999999998, 0.21606, 0.10803, - 2.1364999999999998, 0.25207000000000002, 0.10803, 2.1364999999999998, 0.32408999999999999, 0.10803, 2.1364999999999998, 0.39610999999999996, 0.10803, - 2.1364999999999998, 0.43212, 0.10803, 2.1364999999999998, 0.21606, 0.18004999999999999, 2.1364999999999998, 0.25207000000000002, 0.18004999999999999, - 2.1364999999999998, 0.32408999999999999, 0.18004999999999999, 2.1364999999999998, 0.39610999999999996, 0.18004999999999999, 2.1364999999999998, 0.43212, - 0.18004999999999999, 2.1364999999999998, 0.25207000000000002, 0.21605999999999997, 2.1364999999999998, 0.32408999999999999, 0.21605999999999997, - 2.1364999999999998, 0.39610999999999996, 0.21605999999999997, 2.1364999999999998, 0.43212, 0.21605999999999997, 2.1364999999999998, 0, 0.21606, - 2.1364999999999998, 0.21606, 0.21606, 2.1364999999999998, 0, 0, 2.3501499999999997, 0.21606, 0, 2.3501499999999997, 0.25207000000000002, 0, 2.3501499999999997, - 0.32408999999999999, 0, 2.3501499999999997, 0.39610999999999996, 0, 2.3501499999999997, 0.43212, 0, 2.3501499999999997, 0.21606, 0.03601, 2.3501499999999997, - 0.25207000000000002, 0.03601, 2.3501499999999997, 0.32408999999999999, 0.03601, 2.3501499999999997, 0.39610999999999996, 0.03601, 2.3501499999999997, 0.43212, - 0.03601, 2.3501499999999997, 0.21606, 0.10803, 2.3501499999999997, 0.25207000000000002, 0.10803, 2.3501499999999997, 0.32408999999999999, 0.10803, - 2.3501499999999997, 0.39610999999999996, 0.10803, 2.3501499999999997, 0.43212, 0.10803, 2.3501499999999997, 0.21606, 0.18004999999999999, 2.3501499999999997, - 0.25207000000000002, 0.18004999999999999, 2.3501499999999997, 0.32408999999999999, 0.18004999999999999, 2.3501499999999997, 0.39610999999999996, - 0.18004999999999999, 2.3501499999999997, 0.43212, 0.18004999999999999, 2.3501499999999997, 0.25207000000000002, 0.21605999999999997, 2.3501499999999997, - 0.32408999999999999, 0.21605999999999997, 2.3501499999999997, 0.39610999999999996, 0.21605999999999997, 2.3501499999999997, 0.43212, 0.21605999999999997, - 2.3501499999999997, 0, 0.21606, 2.3501499999999997, 0.21606, 0.21606, 2.3501499999999997, 0, 0, 2.5637999999999996, 0.21606, 0, 2.5637999999999996, - 0.25207000000000002, 0, 2.5637999999999996, 0.32408999999999999, 0, 2.5637999999999996, 0.39610999999999996, 0, 2.5637999999999996, 0.43212, 0, - 2.5637999999999996, 0.21606, 0.03601, 2.5637999999999996, 0.25207000000000002, 0.03601, 2.5637999999999996, 0.32408999999999999, 0.03601, 2.5637999999999996, - 0.39610999999999996,0.03601, 2.5637999999999996, 0.43212, 0.03601, 2.5637999999999996, 0.21606, 0.10803, 2.5637999999999996, 0.25207000000000002, 0.10803, 2.5637999999999996, - 0.32408999999999999, 0.10803, 2.5637999999999996, 0.39610999999999996, 0.10803, 2.5637999999999996, 0.43212, 0.10803, 2.5637999999999996, 0.21606, - 0.18004999999999999, 2.5637999999999996, 0.25207000000000002, 0.18004999999999999, 2.5637999999999996, 0.32408999999999999, 0.18004999999999999, - 2.5637999999999996, 0.39610999999999996, 0.18004999999999999, 2.5637999999999996, 0.43212, 0.18004999999999999, 2.5637999999999996, 0.25207000000000002, - 0.21605999999999997, 2.5637999999999996, 0.32408999999999999, 0.21605999999999997, 2.5637999999999996, 0.39610999999999996, 0.21605999999999997, - 2.5637999999999996, 0.43212, 0.21605999999999997, 2.5637999999999996, 0, 0.21606, 2.5637999999999996, 0.21606, 0.21606, 2.5637999999999996, 0, 0, - 2.7774499999999995, 0.21606, 0, 2.7774499999999995, 0.25207000000000002, 0, 2.7774499999999995, 0.32408999999999999, 0, 2.7774499999999995, 0.39610999999999996, - 0, 2.7774499999999995, 0.43212, 0, 2.7774499999999995, 0.21606, 0.03601, 2.7774499999999995, 0.25207000000000002, 0.03601, 2.7774499999999995, - 0.32408999999999999, 0.03601, 2.7774499999999995, 0.39610999999999996, 0.03601, 2.7774499999999995, 0.43212, 0.03601, 2.7774499999999995, 0.21606, 0.10803, - 2.7774499999999995, 0.25207000000000002, 0.10803, 2.7774499999999995, 0.32408999999999999, 0.10803, 2.7774499999999995, 0.39610999999999996, 0.10803, - 2.7774499999999995, 0.43212, 0.10803, 2.7774499999999995, 0.21606, 0.18004999999999999, 2.7774499999999995, 0.25207000000000002, 0.18004999999999999, - 2.7774499999999995, 0.32408999999999999, 0.18004999999999999, 2.7774499999999995, 0.39610999999999996, 0.18004999999999999, 2.7774499999999995, 0.43212, - 0.18004999999999999, 2.7774499999999995, 0.25207000000000002, 0.21605999999999997, 2.7774499999999995, 0.32408999999999999, 0.21605999999999997, - 2.7774499999999995, 0.39610999999999996, 0.21605999999999997, 2.7774499999999995, 0.43212, 0.21605999999999997, 2.7774499999999995, 0, 0.21606, - 2.7774499999999995, 0.21606, 0.21606, 2.7774499999999995, 0, 0, 2.9910999999999999, 0.21606, 0, 2.9910999999999999, 0.25207000000000002, 0, 2.9910999999999999, - 0.32408999999999999, 0, 2.9910999999999999, 0.39610999999999996, 0, 2.9910999999999999, 0.43212, 0, 2.9910999999999999, 0.21606, 0.03601, 2.9910999999999999, - 0.25207000000000002, 0.03601, 2.9910999999999999, 0.32408999999999999, 0.03601, 2.9910999999999999, 0.39610999999999996, 0.03601, 2.9910999999999999, 0.43212, - 0.03601, 2.9910999999999999, 0.21606, 0.10803, 2.9910999999999999, 0.25207000000000002, 0.10803, 2.9910999999999999, 0.32408999999999999, 0.10803, - 2.9910999999999999, 0.39610999999999996, 0.10803, 2.9910999999999999, 0.43212, 0.10803, 2.9910999999999999, 0.21606, 0.18004999999999999, 2.9910999999999999, - 0.25207000000000002, 0.18004999999999999, 2.9910999999999999, 0.32408999999999999, 0.18004999999999999, 2.9910999999999999, 0.39610999999999996, - 0.18004999999999999, 2.9910999999999999, 0.43212, 0.18004999999999999, 2.9910999999999999, 0.25207000000000002, 0.21605999999999997, 2.9910999999999999, - 0.32408999999999999, 0.21605999999999997, 2.9910999999999999, 0.39610999999999996, 0.21605999999999997, 2.9910999999999999, 0.43212, 0.21605999999999997, - 2.9910999999999999, 0, 0.21606, 2.9910999999999999, 0.21606, 0.21606, 2.9910999999999999, 0, 0, 3.2047499999999998, 0.21606, 0, 3.2047499999999998, - 0.25207000000000002, 0, 3.2047499999999998, 0.32408999999999999, 0, 3.2047499999999998, 0.39610999999999996, 0, 3.2047499999999998, 0.43212, 0, - 3.2047499999999998, 0.21606, 0.03601, 3.2047499999999998, 0.25207000000000002, 0.03601, 3.2047499999999998, 0.32408999999999999, 0.03601, 3.2047499999999998, - 0.39610999999999996, 0.03601, 3.2047499999999998, 0.43212, 0.03601, 3.2047499999999998, 0.21606, 0.10803, 3.2047499999999998, 0.25207000000000002, 0.10803, - 3.2047499999999998, 0.32408999999999999, 0.10803, 3.2047499999999998, 0.39610999999999996, 0.10803, 3.2047499999999998, 0.43212, 0.10803, 3.2047499999999998, - 0.21606, 0.18004999999999999, 3.2047499999999998, 0.25207000000000002, 0.18004999999999999, 3.2047499999999998, 0.32408999999999999, 0.18004999999999999, - 3.2047499999999998, 0.39610999999999996, 0.18004999999999999, 3.2047499999999998, 0.43212, 0.18004999999999999, 3.2047499999999998, 0.25207000000000002, - 0.21605999999999997, 3.2047499999999998, 0.32408999999999999, 0.21605999999999997, 3.2047499999999998, 0.39610999999999996, 0.21605999999999997, - 3.2047499999999998, 0.43212, 0.21605999999999997, 3.2047499999999998, 0, 0.21606, 3.2047499999999998, 0.21606, 0.21606, 3.2047499999999998, 0, 0, - 3.4183999999999997, 0.21606, 0, 3.4183999999999997, 0.25207000000000002, 0, 3.4183999999999997, 0.32408999999999999, 0, 3.4183999999999997, 0.39610999999999996, - 0, 3.4183999999999997, 0.43212, 0, 3.4183999999999997, 0.21606, 0.03601, 3.4183999999999997, 0.25207000000000002, 0.03601, 3.4183999999999997, - 0.32408999999999999, 0.03601, 3.4183999999999997, 0.39610999999999996, 0.03601, 3.4183999999999997, 0.43212, 0.03601, 3.4183999999999997, 0.21606, 0.10803, - 3.4183999999999997, 0.25207000000000002, 0.10803, 3.4183999999999997, 0.32408999999999999, 0.10803, 3.4183999999999997, 0.39610999999999996, 0.10803, - 3.4183999999999997, 0.43212, 0.10803, 3.4183999999999997, 0.21606, 0.18004999999999999, 3.4183999999999997, 0.25207000000000002, 0.18004999999999999, - 3.4183999999999997, 0.32408999999999999, 0.18004999999999999, 3.4183999999999997, 0.39610999999999996, 0.18004999999999999, 3.4183999999999997, 0.43212, - 0.18004999999999999, 3.4183999999999997, 0.25207000000000002, 0.21605999999999997, 3.4183999999999997, 0.32408999999999999, 0.21605999999999997, - 3.4183999999999997, 0.39610999999999996, 0.21605999999999997, 3.4183999999999997, 0.43212, 0.21605999999999997, 3.4183999999999997, 0, 0.21606, - 3.4183999999999997, 0.21606, 0.21606, 3.4183999999999997, 0, 0, 3.6320499999999996, 0.21606, 0, 3.6320499999999996, 0.25207000000000002, 0, 3.6320499999999996, - 0.32408999999999999, 0, 3.6320499999999996, 0.39610999999999996, 0, 3.6320499999999996, 0.43212, 0, 3.6320499999999996, 0.21606, 0.03601, 3.6320499999999996, - 0.25207000000000002, 0.03601, 3.6320499999999996, 0.32408999999999999, 0.03601, 3.6320499999999996, 0.39610999999999996, 0.03601, 3.6320499999999996, 0.43212, 0.03601, - 3.6320499999999996, 0.21606, 0.10803, 3.6320499999999996, 0.25207000000000002, 0.10803, 3.6320499999999996, 0.32408999999999999, 0.10803, 3.6320499999999996, - 0.39610999999999996, 0.10803, 3.6320499999999996, 0.43212, 0.10803, 3.6320499999999996, 0.21606, 0.18004999999999999, 3.6320499999999996, 0.25207000000000002, - 0.18004999999999999, 3.6320499999999996, 0.32408999999999999, 0.18004999999999999, 3.6320499999999996, 0.39610999999999996, 0.18004999999999999, - 3.6320499999999996, 0.43212, 0.18004999999999999, 3.6320499999999996, 0.25207000000000002, 0.21605999999999997, 3.6320499999999996, 0.32408999999999999, - 0.21605999999999997, 3.6320499999999996, 0.39610999999999996, 0.21605999999999997, 3.6320499999999996, 0.43212, 0.21605999999999997, 3.6320499999999996, 0, - 0.21606, 3.6320499999999996, 0.21606, 0.21606, 3.6320499999999996, 0, 0, 3.8456999999999995, 0.21606, 0, 3.8456999999999995, 0.25207000000000002, 0, - 3.8456999999999995, 0.32408999999999999, 0, 3.8456999999999995, 0.39610999999999996, 0, 3.8456999999999995, 0.43212, 0, 3.8456999999999995, 0.21606, 0.03601, - 3.8456999999999995, 0.25207000000000002, 0.03601, 3.8456999999999995, 0.32408999999999999, 0.03601, 3.8456999999999995, 0.39610999999999996, 0.03601, - 3.8456999999999995, 0.43212, 0.03601, 3.8456999999999995, 0.21606, 0.10803, 3.8456999999999995, 0.25207000000000002, 0.10803, 3.8456999999999995, - 0.32408999999999999, 0.10803, 3.8456999999999995, 0.39610999999999996, 0.10803, 3.8456999999999995, 0.43212, 0.10803, 3.8456999999999995, 0.21606, - 0.18004999999999999, 3.8456999999999995, 0.25207000000000002, 0.18004999999999999, 3.8456999999999995, 0.32408999999999999, 0.18004999999999999, - 3.8456999999999995, 0.39610999999999996, 0.18004999999999999, 3.8456999999999995, 0.43212, 0.18004999999999999, 3.8456999999999995, 0.25207000000000002, - 0.21605999999999997, 3.8456999999999995, 0.32408999999999999, 0.21605999999999997, 3.8456999999999995, 0.39610999999999996, 0.21605999999999997, - 3.8456999999999995, 0.43212, 0.21605999999999997, 3.8456999999999995, 0, 0.21606, 3.8456999999999995, 0.21606, 0.21606, 3.8456999999999995, 0, 0, - 4.0593499999999993, 0.21606, 0, 4.0593499999999993, 0.25207000000000002, 0, 4.0593499999999993, 0.32408999999999999, 0, 4.0593499999999993, 0.39610999999999996, - 0, 4.0593499999999993, 0.43212, 0, 4.0593499999999993, 0.21606, 0.03601, 4.0593499999999993, 0.25207000000000002, 0.03601, 4.0593499999999993, - 0.32408999999999999, 0.03601, 4.0593499999999993, 0.39610999999999996, 0.03601, 4.0593499999999993, 0.43212, 0.03601, 4.0593499999999993, 0.21606, 0.10803, - 4.0593499999999993, 0.25207000000000002, 0.10803, 4.0593499999999993, 0.32408999999999999, 0.10803, 4.0593499999999993, 0.39610999999999996, 0.10803, - 4.0593499999999993, 0.43212, 0.10803, 4.0593499999999993, 0.21606, 0.18004999999999999, 4.0593499999999993, 0.25207000000000002, 0.18004999999999999, - 4.0593499999999993, 0.32408999999999999, 0.18004999999999999, 4.0593499999999993, 0.39610999999999996, 0.18004999999999999, 4.0593499999999993, 0.43212, - 0.18004999999999999, 4.0593499999999993, 0.25207000000000002, 0.21605999999999997, 4.0593499999999993, 0.32408999999999999, 0.21605999999999997, - 4.0593499999999993, 0.39610999999999996, 0.21605999999999997, 4.0593499999999993, 0.43212, 0.21605999999999997, 4.0593499999999993, 0, 0.21606, - 4.0593499999999993, 0.21606, 0.21606, 4.0593499999999993, 0, 0, 4.2729999999999997, 0.21606, 0, 4.2729999999999997, 0.25207000000000002, 0, 4.2729999999999997, - 0.32408999999999999, 0, 4.2729999999999997, 0.39610999999999996, 0, 4.2729999999999997, 0.43212, 0, 4.2729999999999997, 0.21606, 0.03601, 4.2729999999999997, - 0.25207000000000002, 0.03601, 4.2729999999999997, 0.32408999999999999, 0.03601, 4.2729999999999997, 0.39610999999999996, 0.03601, 4.2729999999999997, 0.43212, - 0.03601, 4.2729999999999997, 0.21606, 0.10803, 4.2729999999999997, 0.25207000000000002, 0.10803, 4.2729999999999997, 0.32408999999999999, 0.10803, - 4.2729999999999997, 0.39610999999999996, 0.10803, 4.2729999999999997, 0.43212, 0.10803, 4.2729999999999997, 0.21606, 0.18004999999999999, 4.2729999999999997, - 0.25207000000000002, 0.18004999999999999, 4.2729999999999997, 0.32408999999999999, 0.18004999999999999, 4.2729999999999997, 0.39610999999999996, - 0.18004999999999999, 4.2729999999999997, 0.43212, 0.18004999999999999, 4.2729999999999997, 0.25207000000000002, 0.21605999999999997, 4.2729999999999997, - 0.32408999999999999, 0.21605999999999997, 4.2729999999999997, 0.39610999999999996, 0.21605999999999997, 4.2729999999999997, 0.43212, 0.21605999999999997, - 4.2729999999999997, 0, 0.21606, 4.2729999999999997, 0.21606, 0.21606, 4.2729999999999997 -}; - -const int connTFPOLH_I[21]={0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000}; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx deleted file mode 100644 index b60b3e066..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx +++ /dev/null @@ -1,2213 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingBasicsTest.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" -#include "Interpolation2D.txx" -#include "Interpolation3DSurf.txx" -#include "Interpolation3D.txx" -#include "InterpolationCC.txx" -#include "InterpolationCU.txx" -#include "Interpolation2DCurve.txx" -#include "Interpolation1D.txx" - -#include "MEDCouplingNormalizedUnstructuredMesh.txx" -#include "MEDCouplingNormalizedCartesianMesh.txx" - -#include -#include - -using namespace ParaMEDMEM; - -void MEDCouplingBasicsTest::test2DInterpP0P0_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<3;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0P0PL_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - // - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - // - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0P0PL_2() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - std::vector cellsIds(targetMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - targetMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - // - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - // - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0P0PL_3() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - std::vector cellsIds(sourceMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - sourceMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - // - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - // - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0P0PL_4() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - std::vector cellsIds(sourceMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - sourceMesh->convertToPolyTypes(cellsIds); - cellsIds.resize(targetMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - targetMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - // - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - // - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0P1_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[5][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[6][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0P1PL_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0P1PL_2() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - std::vector cellsIds(sourceMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - sourceMesh->convertToPolyTypes(cellsIds); - // - cellsIds.resize(targetMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - targetMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP1P0_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP1P0PL_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP1P0PL_2() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - std::vectorcellsIds(targetMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - targetMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP1P1_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_2(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[0][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[1][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[1][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[2][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[3][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668,res[3][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666,res[4][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999,res[4][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[5][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333,res[5][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333,res[6][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667,res[7][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331,res[7][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668,res[8][3],1.e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP1P1PL_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP0P0_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP0P0PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP0P1_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[5][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[6][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP0P1PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP1P0_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667*sqrt(2.),res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP1P0PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP1P1_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_2(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[0][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[1][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[1][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[2][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[3][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668*sqrt(2.),res[3][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666*sqrt(2.),res[4][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999*sqrt(2.),res[4][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[5][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333*sqrt(2.),res[5][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333*sqrt(2.),res[6][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667*sqrt(2.),res[7][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331*sqrt(2.),res[7][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668*sqrt(2.),res[8][3],1.e-12); - res.clear(); - } - // - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP1P1PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12); - res.clear(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP0P0_2() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMeshPerm_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation); - { - myInterpolator.setOrientation(2); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - { - myInterpolator.setOrientation(0); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125*sqrt(2.),res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - { - myInterpolator.setOrientation(1); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.875*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - { - myInterpolator.setOrientation(-1); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -/*! - * Test of precision option implemented by Fabien that represents distance of "barycenter" to the other cell. - */ -void MEDCouplingBasicsTest::test3DSurfInterpP0P0_3() -{ - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - std::vector > res; - double vecTrans[3]={0.,0.,1.e-10}; - double vec[3]={0.,-1.,0.}; - double pt[3]={-0.3,-0.3,5.e-11}; - const int N=32; - const double deltaA=M_PI/N; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation); - myInterpolator.setMaxDistance3DSurfIntersect(1e-9); - for(int i=0;irotate(pt,vec,i*deltaA); - MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2(); - targetMesh->translate(vecTrans); - targetMesh->rotate(pt,vec,i*deltaA); - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(2,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - sourceMesh->decrRef(); - targetMesh->decrRef(); - } - // - myInterpolator.setMaxDistance3DSurfIntersect(1e-11); - for(int i=0;irotate(pt,vec,i*deltaA); - MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2(); - targetMesh->translate(vecTrans); - targetMesh->rotate(pt,vec,i*deltaA); - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(2,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12); - sourceMesh->decrRef(); - targetMesh->decrRef(); - } - // - res.clear(); - myInterpolator.setMaxDistance3DSurfIntersect(-1.);//unactivate fabien lookup - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2(); - MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2(); - targetMesh->translate(vecTrans); - myInterpolator.setBoundingBoxAdjustment(1e-11); - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper0(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper0(targetMesh); - myInterpolator.interpolateMeshes(sourceWrapper0,targetWrapper0,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(2,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // - res.clear(); - sourceMesh=build3DSurfSourceMesh_2(); - targetMesh=build3DSurfSourceMesh_2(); - targetMesh->translate(vecTrans); - myInterpolator.setBoundingBoxAdjustment(1e-9); - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper1(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper1(targetMesh); - myInterpolator.interpolateMeshes(sourceWrapper1,targetWrapper1,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(2,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - sourceMesh->decrRef(); - targetMesh->decrRef(); - //keeping the same bbox adj == 1.e-11 but trying rotation - res.clear(); - sourceMesh=build3DSurfSourceMesh_2(); - sourceMesh->rotate(pt,vec,M_PI/4.); - targetMesh=build3DSurfSourceMesh_2(); - targetMesh->translate(vecTrans); - targetMesh->rotate(pt,vec,M_PI/4.); - myInterpolator.setBoundingBoxAdjustment(1e-11); - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper2(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper2(targetMesh); - myInterpolator.interpolateMeshes(sourceWrapper2,targetWrapper2,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(2,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P0_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P0PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > 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[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P0PL_2() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - std::vector cellsIds(targetMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - targetMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > 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[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P0PL_3() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - std::vector cellsIds(sourceMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - sourceMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > 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[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P0PL_4() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - std::vector cellsIds(sourceMesh->getNumberOfCells()); - for(int i=0;igetNumberOfCells();i++) - cellsIds[i]=i; - sourceMesh->convertToPolyTypes(cellsIds); - cellsIds.resize(targetMesh->getNumberOfCells()); - for(int j=0;jgetNumberOfCells();j++) - cellsIds[j]=j; - targetMesh->convertToPolyTypes(cellsIds); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > 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[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P1_1() -{ - MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSourceMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P1PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSourceMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP1P0_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP1P0PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP1P1_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_2(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - double res3D[8][28]= {{124999.999883775978, 245370.370390364464, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203703.703634892299, 187500.000094145857, 0.0, 0.0, 4629.6296266718, 0.0, 215277.777751402784, 209722.222322299582, 0.0, 0.0, 0.0, 0.0, 104166.666590829205, 121296.296368812196, 0.0, 250000.000003472145}, - {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 120370.370368827047, 0.0, 0.0, 38888.888897777797, 0.0, 0.0, 45370.3703701697596, 0.0, 0.0, 45370.3703701697596, 83333.3333263888926, 0.0}, - {0.0, 0.0, 0.0, 97222.2222222221753, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 97222.2222222221608, 0.0, 97222.2222222222044, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {0.0, 277777.777787084982, 199074.074074073927, 0.0, 0.0, 0.0, 4629.62962962962774, 0.0, 321759.259254934732, 83333.3333333333139, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4629.62962667180363, 0.0, 0.0, 251388.88888319055, 194444.444454861077, 0.0, 79629.6296194135939, 250000.000003472145, 0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0, 85185.1851851851534, 4629.62962962962774, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518511, 0.0, 41666.6666666666642, 83333.3333333333285, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {0.0, 324074.07407629228, 0.0, 0.0, 0.0, 247685.185185184964, 6481.48148148147993, 0.0, 173611.11111196311, 0.0, 164814.814814814832, 0.0, 4629.62962962962865, 208333.33333418527, 0.0, 83333.3333333333285, 203703.703697273799, 249999.999999999767, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {125000.000000000015, 423611.111111110775, 134259.259259259241, 194444.444444444351, 164814.814814814745, 164351.851851851825, 203703.703703703592, 249999.999999999825, 0.0, 0.0, 0.0, 0.0, 6481.48148148147902, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518453, 0.0, 4629.62962962962956, 83333.3333333333139, 85185.1851851851825, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; - int i=0; - double sum = 0; - //cout.precision(18); - for(std::vector >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++) - { - //cout<< "res3D[" <::const_iterator iter2=(*iter1).find(j); - if(iter2!=(*iter1).end()) - { - //cout<< iter2->second<< ", "; - sum += iter2->second; - CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5); - } - else - { - //cout << "0.0, "; - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14); - } - } - //cout << "}" << endl; - } - //cout << "Sum = " << sum << endl; - CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5); - //clean-up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP1P1PL_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_2(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20.,res[0][24],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[1][26],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][21],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[3][23],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][14],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[5][17],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[6][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(97.,sumAll(res),1e-12); - //clean-up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0P0Empty() -{ - MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New(); - sourceMesh->setMeshDimension(2); - sourceMesh->allocateCells(0); - sourceMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(0,0); - sourceMesh->setCoords(myCoords); - myCoords->decrRef(); - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(0); - targetMesh->finishInsertingCells(); - myCoords=DataArrayDouble::New(); - myCoords->alloc(0,2); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::testInterpolationCC() -{ - double arr1[3] = { 0/2., 1/2., 2/2. }; - double arr2[4] = { 0/3, 1/3., 2/3., 3/3. }; - MEDCouplingCMesh* mesh[2]; - for ( int i = 0; i < 2; ++i ) - { - const double* arr = i ? arr1 : arr2; - const int nb_coord = i ? 3 : 4; - DataArrayDouble* coords = DataArrayDouble::New(); - coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, nb_coord, 1 ); - - mesh[i] = MEDCouplingCMesh::New(); - mesh[i]->setCoords( coords, coords, coords ); - coords->decrRef(); - } - MEDCouplingNormalizedCartesianMesh<3> targetWrapper(mesh[1]); - MEDCouplingNormalizedCartesianMesh<3> sourceWrapper(mesh[0]); - CPPUNIT_ASSERT_EQUAL( 27,int( sourceWrapper.getNumberOfElements())); - CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(0))); - CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(1))); - CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(2))); - CPPUNIT_ASSERT_THROW( sourceWrapper.nbCellsAlongAxis(3), INTERP_KERNEL::Exception); - - INTERP_KERNEL::InterpolationCC myInterpolator; - std::vector > res; - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - - CPPUNIT_ASSERT_EQUAL(8,int( res.size())); - CPPUNIT_ASSERT_EQUAL(8,int( res[0].size())); - const double precis = 1e-7; - std::set vals; - double sum = 0; - for ( int i = 0; i < (int)res.size(); ++i ) - for ( std::map::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v) - { - sum += s_v->second; - double vvv; -#ifdef WNT - double vv = s_v->second / precis; - if(vv>=0.0) - { - vvv = floor(vv+0.5); - } - else - { - vvv = ceil(vv-0.5); - } -#else - vvv = round( s_v->second / precis ); -#endif - vals.insert( precis * vvv ); - } - //cout << "tgt: " << i << " src: " << s_v->first << " - w: " << s_v->second << endl; - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, sum, precis ); - - std::set::iterator v = vals.begin(); - CPPUNIT_ASSERT_EQUAL( 4, int( vals.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00462963, *v++, precis ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00925926, *v++, precis ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.01851850, *v++, precis ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703700, *v++, precis ); - - mesh[0]->decrRef(); - mesh[1]->decrRef(); -} - -void MEDCouplingBasicsTest::testInterpolationCU1D() -{ - MEDCouplingCMesh* meshC = MEDCouplingCMesh::New(); - DataArrayDouble* coords = DataArrayDouble::New(); - double arr[4] = { -1/3., 1/3., 2/3., 4/3. }; - coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 ); - meshC->setCoords( coords ); - coords->decrRef(); - - MEDCouplingUMesh * meshU = buildCU1DMesh_U(); - - MEDCouplingNormalizedCartesianMesh<1> sourceWrapper(meshC); - MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(meshU); - INTERP_KERNEL::InterpolationCU myInterpolator; - std::vector > res; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - -// std::cout.precision(18); -// for ( int i = 0; i < (int)res.size(); ++i ) -// for ( std::map::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v) -// { -// std::cout << "CPPUNIT_ASSERT_DOUBLES_EQUAL( "<second<<" ,res["<first<<"],precis);"<decrRef(); - meshU->decrRef(); -} - -void MEDCouplingBasicsTest::testInterpolationCU2D() -{ - MEDCouplingCMesh* meshC = MEDCouplingCMesh::New(); - DataArrayDouble* coords = DataArrayDouble::New(); - double arr[4] = { -1/3., 1/3., 2/3., 4/3. }; - coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 ); - meshC->setCoords( coords, coords ); - coords->decrRef(); - - MEDCouplingUMesh * meshU = buildCU2DMesh_U(); - - MEDCouplingNormalizedCartesianMesh<2> sourceWrapper(meshC); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(meshU); - INTERP_KERNEL::InterpolationCU myInterpolator; - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - - const double precis = 1e-7; - double sum = sumAll(res); - CPPUNIT_ASSERT_EQUAL(5,int( res.size())); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[0][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[0][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[1][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[1][6],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][7],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[2][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][5],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][7],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[2][8],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[3][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[3][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][5],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0972222 ,res[4][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][5],precis); - - std::vector > resRev; - myInterpolator.interpolateMeshesRev(targetWrapper,sourceWrapper,resRev,"P0P0"); - - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][0] ,resRev[0][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][1] ,resRev[1][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][1] ,resRev[1][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][1] ,resRev[1][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][2] ,resRev[2][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][2] ,resRev[2][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][3] ,resRev[3][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][3] ,resRev[3][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][4] ,resRev[4][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][4] ,resRev[4][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][4] ,resRev[4][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][4] ,resRev[4][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][5] ,resRev[5][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][5] ,resRev[5][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][5] ,resRev[5][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][6] ,resRev[6][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][7] ,resRev[7][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][7] ,resRev[7][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][8] ,resRev[8][2],precis); - - meshC->decrRef(); - meshU->decrRef(); -} - -void MEDCouplingBasicsTest::testInterpolationCU3D() -{ - MEDCouplingCMesh* meshC = MEDCouplingCMesh::New(); - DataArrayDouble* coords = DataArrayDouble::New(); - double arr[4] = { -1/3., 1/3., 2/3., 4/3. }; - coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 ); - meshC->setCoords( coords, coords, coords ); - coords->decrRef(); - - MEDCouplingUMesh * meshU = buildCU3DMesh_U(); - - MEDCouplingNormalizedCartesianMesh<3> sourceWrapper(meshC); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(meshU); - INTERP_KERNEL::InterpolationCU myInterpolator; - std::vector > res; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - - double sum = sumAll(res); - CPPUNIT_ASSERT_EQUAL(8,int( res.size())); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02700000000000 ,res[0][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[1][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[1][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[1][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00300000000000 ,res[2][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][6],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[3][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][5],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][6],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][7],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][8],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[4][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[4][9],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[4][18],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[5][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][9],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][10],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][11],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][18],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][19],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][20],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[6][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][6],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][9],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][12],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][15],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][18],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][21],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][24],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.7037037037e-05 ,res[7][0],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][1],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][2],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][3],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][4],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][5],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][6],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][7],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][8],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][9],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][10],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][11],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][12],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][13],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][14],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][15],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][16],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][17],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][18],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][19],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][20],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][21],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][22],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][23],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][24],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][25],precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][26],precis); - - - meshC->decrRef(); - meshU->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP0IntegralUniform() -{ - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - CPPUNIT_ASSERT_EQUAL(5,myInterpolator.toIntegralUniform(targetWrapper,res,"P0")); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - res.clear(); - CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0")); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - res.clear(); - targetMesh->decrRef(); - // - targetMesh=build2DTargetMeshPerm_1(); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper2(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator2; - CPPUNIT_ASSERT(myInterpolator2.getMeasureAbsStatus()); - CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0")); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - res.clear(); - myInterpolator2.setMeasureAbsStatus(false); - CPPUNIT_ASSERT(!myInterpolator2.getMeasureAbsStatus()); - CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0")); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,sumAll(res),1e-12); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP0IntegralUniform() -{ - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - std::vector > res; - CPPUNIT_ASSERT_EQUAL(5,myInterpolator.toIntegralUniform(targetWrapper,res,"P0")); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12); - res.clear(); - CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0")); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP0IntegralUniform() -{ - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - INTERP_KERNEL::Interpolation3D myInterpolator; - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - std::vector > res; - CPPUNIT_ASSERT_EQUAL(8,myInterpolator.toIntegralUniform(targetWrapper,res,"P0")); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][1],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][2],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][3],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][4],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][5],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][6],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[0][7],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6); - res.clear(); - CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0")); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[1][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[2][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[3][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[4][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[5][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[6][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[7][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6); - res.clear(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP1IntegralUniform() -{ - MEDCouplingUMesh *targetMesh=build2DSourceMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - std::vector > res; - CPPUNIT_ASSERT_EQUAL(4,myInterpolator.toIntegralUniform(targetWrapper,res,"P1")); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][3],1e-12); - res.clear(); - CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1")); - CPPUNIT_ASSERT_EQUAL(4,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[3][0],1e-12); - res.clear(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DInterpP1IntegralUniform() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(sourceMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - std::vector > res; - CPPUNIT_ASSERT_EQUAL(9,myInterpolator.toIntegralUniform(targetWrapper,res,"P1")); - CPPUNIT_ASSERT_EQUAL(1,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][1],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][2],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][3],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][4],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][5],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][6],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][7],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[0][8],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6); - res.clear(); - CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1")); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[1][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[2][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[3][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[4][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[5][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[8][0],1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6); - sourceMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DInterpP1P0Bary_1() -{ - MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2D myInterpolator; - myInterpolator.setP1P0BaryMethod(true); - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[1][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test3DSurfInterpP1P0Bary_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); - // - MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3DSurf myInterpolator; - myInterpolator.setP1P0BaryMethod(true); - std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) - { - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669*sqrt(2.),res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[1][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12); - res.clear(); - } - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -#include -void MEDCouplingBasicsTest::test3DInterpP1P0Bary_1() -{ - MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2(); - MEDCouplingUMesh *targetMesh=build3DTargetMesh_2(); - // - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - myInterpolator.setP1P0BaryMethod(true); - std::vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - - double res3D[5][28]={{104166.66658918398, 885416.666685817763, 135416.666666666541, 36458.3333333335031, 31249.9999999999018, 145833.333333333256, 41666.6666666667516, 124999.999999999971, 177083.333326388849, 0.0, 31249.9999999999636, 0.0, 41666.666620792399, 159722.22229009436, 0.0, 0.0, 41666.6666631944681, 125000, 43499.2283723790752, 164351.851924000395, 36458.3333372396883, 0.0, 0.0, 125000.000001736029, 34722.2221800900952, 13599.5370788455439, 0.0, 167438.27159690368}, - {0.0, 41666.6664479170649, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 125000.000161457952, 0.0, 0.0, 0.0, 0.0, 111111.11112005508, 0.0, 0.0, 291666.666656249959, 41666.6666666666933, 6944.4444415638809, 270833.333520485845, 0.0, 0.0, 124999.999989583303, 41666.6665798612958, 20833.3333186342825, 145833.333354303701, 83333.3333263888198, 27777.7777501651799}, - {0.0, 93750.0000000000728, 125000.000000000058, 0.0, 0.0, 72916.666666666526, 291666.666666666628, 41666.6666666667152, 197916.66666666657, 166666.666666666802, 218750.000000000116, 41666.6666666665697, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666861, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0}, - {72916.6666484848247, 82465.2777799315081, 0.0, 0.0, 217447.916666666686, 197916.666666666802, 0.0, 41666.6666666666715, 0.0, 0.0, 0.0, 0.0, 290364.583310396119, 125000.000018181803, 41666.6666666666351, 166666.666666666599, 0.0, 41666.6666666665551, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 27777.7777734705051, 0.0, 0.0, 27777.7778028684952}, - {72916.6666461071727, 172309.027782170655, 70312.5000000000437, 253906.250000000029, 0.0, 0.0, 0.0, 41666.666666666657, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 258246.527775988478, 71180.5555571812583, 253906.250006944378, 41666.6666666666861, 0.0, 41666.6666649305407, 20833.3333186342534, 6944.44445267237552, 0.0, 27777.7777953707919}}; - - double sum = 0; - int i=0; - for(std::vector >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++) - { - for(int j=0;j<28;j++) - { - std::map::const_iterator iter2=(*iter1).find(j); - if(iter2!=(*iter1).end()) - { - sum += iter2->second; - CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5); - } - else - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14); - } - } - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5); - //clean up - sourceMesh->decrRef(); - 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; - std::vector > 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(); -} - -void MEDCouplingBasicsTest::test1DInterp_1() -{ - // c1 c0 c2 - pay attention to cell order! - // S: o---o------o---o - // T: o---o------o---o - // n0 n1 n2 n3 - // - // ---+---+------+---+---> X - // 0. 1. 3. 4. - MEDCouplingUMesh *sourceMesh=build1DMesh(0); - MEDCouplingUMesh *targetMesh=build1DMesh(0.5); - // - MEDCouplingNormalizedUnstructuredMesh<1,1> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation1D myInterpolator; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - - // P0P0 - std::vector > res; - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis); - - // P1P0 - res.clear(); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis); - - // P0P1 - res.clear(); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - - CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[1][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis); - - // P1P1 - res.clear(); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis); - - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DCurveInterpP0P0_1() -{ - // coincident meshes - MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0); - MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0); - // - MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2DCurve myInterpolator; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - std::vector > res; - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - - CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( sqrt(2.),res[0][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.+sqrt(2.), sumAll(res), precis); - - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DCurveInterpP0P0_2() -{ - // equal meshes shifted one from another along X by 0.5 - MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0.5,0); - MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0); - // - MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2DCurve myInterpolator; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - myInterpolator.setMedianPlane(1.);// median line on target - std::vector > res; - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - - double tolInters = myInterpolator.getBoundingBoxAdjustmentAbs() * sqrt(2.); - CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0,res[0][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( tolInters,res[0][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5+tolInters, sumAll(res), precis); - - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DCurveInterpP0P1_1() -{ - // coincident meshes - MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0); - MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0); - // - MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2DCurve myInterpolator; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - std::vector > res; - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - - const double len1 = 1., len0 = sqrt(2.); - CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[1][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis); - - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DCurveInterpP1P0_1() -{ - // coincident meshes - MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0); - MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0); - // - MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2DCurve myInterpolator; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - std::vector > res; - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - - const double len1 = 1., len0 = sqrt(2.); - CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis); - - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingBasicsTest::test2DCurveInterpP1P1_1() -{ - // coincident meshes - MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0); - MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0); - // - MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation2DCurve myInterpolator; - const double precis = 1e-13; - myInterpolator.setPrecision(precis); - std::vector > res; - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); - - const double len1 = 1., len0 = sqrt(2.); - CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][0], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*(len0+len1), res[1][1], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][2], precis); - CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis); - - sourceMesh->decrRef(); - targetMesh->decrRef(); -} diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx deleted file mode 100644 index 1050f75ce..000000000 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx +++ /dev/null @@ -1,1100 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDCouplingRemapperTest.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingRemapper.hxx" - -#include "MEDCouplingBasicsTest.hxx" - -#include -#include - -using namespace ParaMEDMEM; - -void MEDCouplingRemapperTest::test2DInterpP0P0_1() -{ - MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=MEDCouplingBasicsTest::build2DTargetMesh_1(); - // - MEDCouplingRemapper remapper; - remapper.setPrecision(1e-12); - remapper.setIntersectionType(INTERP_KERNEL::Triangulation); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - - MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - double *ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - MEDCouplingFieldDouble *trgfield=remapper.transferField(srcField,4.57); - const double *values=trgfield->getArray()->getConstPointer(); - const double valuesExpected[5]={7.5 ,7. ,7.,8.,7.5}; - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(IntegralGlobConstraint); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected2[5]={3.75 ,1.75 ,1.75,4.,3.75}; - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(ConservativeVolumic); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(IntegralGlobConstraint); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(Integral); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(RevIntegral); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->decrRef(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingRemapperTest::test2DInterpP0P0R_1() -{ - MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=MEDCouplingBasicsTest::build2DTargetMesh_1(); - // - MEDCouplingRemapper remapper; - remapper.setPrecision(1e-12); - remapper.setIntersectionType(INTERP_KERNEL::Triangulation); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - - MEDCouplingFieldDouble *targetField=MEDCouplingFieldDouble::New(ON_CELLS); - targetField->setNature(ConservativeVolumic); - targetField->setMesh(sourceMesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(targetMesh->getNumberOfCells(),1); - targetField->setArray(array); - double *ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - // - MEDCouplingFieldDouble *srcfield=remapper.reverseTransferField(targetField,4.57); - const double *values=srcfield->getArray()->getConstPointer(); - const double valuesExpected[2]={8.75 ,9.5}; - CPPUNIT_ASSERT_EQUAL(2,srcfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,srcfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); - srcfield->decrRef(); - // - targetField->setNature(IntegralGlobConstraint); - srcfield=remapper.reverseTransferField(targetField,4.57); - values=srcfield->getArray()->getConstPointer(); - const double valuesExpected2[2]={26., 19.}; - CPPUNIT_ASSERT_EQUAL(2,srcfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,srcfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - srcfield->decrRef(); - // - targetField->decrRef(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingRemapperTest::test1DInterp_1() -{ - MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build1DSourceMesh_2(); - MEDCouplingUMesh *targetMesh=MEDCouplingBasicsTest::build1DTargetMesh_2(); - // - MEDCouplingRemapper remapper; - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - double *ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - // - MEDCouplingFieldDouble *trgfield=remapper.transferField(srcField,4.57); - const double *values=trgfield->getArray()->getConstPointer(); - const double valuesExpected1[2]={9.0540540540540526,7.4}; - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected1[i0],values[i0],1e-12); - trgfield->decrRef(); - const double valuesExpected2[2]={24.75,5.75}; - srcField->setNature(Integral); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgfield->decrRef(); - // - const double valuesExpected3[2]={24.75,9.25}; - srcField->setNature(IntegralGlobConstraint); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected3[i0],values[i0],1e-12); - trgfield->decrRef(); - // - const double valuesExpected4[2]={7.4444444444444446,7.4}; - srcField->setNature(RevIntegral); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected4[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - //2D Curve - sourceMesh=MEDCouplingBasicsTest::build2DCurveSourceMesh_2(); - targetMesh=MEDCouplingBasicsTest::build2DCurveTargetMesh_2(); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - // - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected1[i0],values[i0],1e-12); - trgfield->decrRef(); - srcField->setNature(Integral); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(IntegralGlobConstraint); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected3[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(RevIntegral); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected4[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingRemapperTest::test2DInterpMultiMethods() -{ - MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=MEDCouplingBasicsTest::build2DTargetMesh_1(); - // - MEDCouplingRemapper remapper; - remapper.setPrecision(1e-12); - remapper.setIntersectionType(INTERP_KERNEL::Triangulation); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - - MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - double *ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - MEDCouplingFieldDouble *trgfield=remapper.transferField(srcField,4.57); - const double *values=trgfield->getArray()->getConstPointer(); - const double valuesExpected[5]={7.5 ,7. ,7.,8.,7.5}; - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); - trgfield->decrRef(); - srcField->decrRef(); - // - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P1P0")); - srcField=MEDCouplingFieldDouble::New(ON_NODES); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfNodes(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfNodes();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected2[5]={7.,7.666666666666667,8.6666666666666661,8.8333333333333339,10.}; - CPPUNIT_ASSERT_EQUAL(5,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgfield->decrRef(); - srcField->decrRef(); - // - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(targetMesh,sourceMesh,"P0P1")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(targetMesh); - array=DataArrayDouble::New(); - array->alloc(targetMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected3[4]={7.5,8.5,10.,10.625}; - CPPUNIT_ASSERT_EQUAL(4,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<4;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected3[i0],values[i0],1e-12); - trgfield->decrRef(); - srcField->decrRef(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); - // - sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); - targetMesh=MEDCouplingBasicsTest::build2DTargetMesh_2(); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P1P1")); - srcField=MEDCouplingFieldDouble::New(ON_NODES); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfNodes(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfNodes();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected4[9]={ 7.,7.35,8.,7.7,8.2857142857142865, - 9.5333333333333332,9.,9.7666666666666657,10.}; - CPPUNIT_ASSERT_EQUAL(9,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<9;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected4[i0],values[i0],1e-12); - trgfield->decrRef(); - srcField->decrRef(); - //clean up - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingRemapperTest::testMultiDimCombi() -{ - // ------------- 2D - MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=MEDCouplingBasicsTest::build2DTargetMesh_1(); - // - MEDCouplingRemapper remapper; - remapper.setPrecision(1e-12); - remapper.setIntersectionType(INTERP_KERNEL::Triangulation); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - double *ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - MEDCouplingFieldDouble *trgField=remapper.transferField(srcField,4.57); - const double *values=trgField->getArray()->getConstPointer(); - const double valuesExpected[5]={7.5 ,7. ,7.,8.,7.5}; - CPPUNIT_ASSERT_EQUAL(5,trgField->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgField->getArray()->getNumberOfComponents()); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); - trgField->decrRef(); - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // ------------- 3D Surf - sourceMesh=MEDCouplingBasicsTest::build3DSurfSourceMesh_1(); - targetMesh=MEDCouplingBasicsTest::build3DSurfTargetMesh_1(); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+8); - array->decrRef(); - trgField=remapper.transferField(srcField,4.57); - CPPUNIT_ASSERT_EQUAL(5,trgField->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgField->getArray()->getNumberOfComponents()); - const double valuesExpected2[5]={8.5,8.,8.,9.,8.5}; - values=trgField->getArray()->getConstPointer(); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgField->decrRef(); - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // ------------- 3D - sourceMesh=MEDCouplingBasicsTest::build3DSourceMesh_1(); - targetMesh=MEDCouplingBasicsTest::build3DTargetMesh_1(); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgField=remapper.transferField(srcField,4.57); - CPPUNIT_ASSERT_EQUAL(8,trgField->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgField->getArray()->getNumberOfComponents()); - const double valuesExpected3[8]={13.166666666666668, 13.888888888888888, 10.722222222222223, 10.870370370370372, - 14.555555555555555, 13.888888888888889, 14.444444444444443, 11.72222222222222}; - values=trgField->getArray()->getConstPointer(); - for(int i0=0;i0<8;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected3[i0],values[i0],1e-12); - trgField->decrRef(); - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // ------------- 3D -> 1D - sourceMesh=MEDCouplingBasicsTest::build3DTargetMesh_1(); - targetMesh=MEDCouplingBasicsTest::build1DTargetMesh_1(); - remapper.setIntersectionType(INTERP_KERNEL::PointLocator); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgField=remapper.transferField(srcField,4.57); - CPPUNIT_ASSERT_EQUAL(8,trgField->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgField->getArray()->getNumberOfComponents()); - const double valuesExpected4[8]={7.,11.,8.,12.,9.,13.,10.,14.}; - values=trgField->getArray()->getConstPointer(); - for(int i0=0;i0<8;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected4[i0],values[i0],1e-12); - trgField->decrRef(); - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // ------------- 1D -> 3D - sourceMesh=MEDCouplingBasicsTest::build1DTargetMesh_1(); - targetMesh=MEDCouplingBasicsTest::build3DTargetMesh_1(); - remapper.setIntersectionType(INTERP_KERNEL::PointLocator); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgField=remapper.transferField(srcField,4.57); - CPPUNIT_ASSERT_EQUAL(8,trgField->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgField->getArray()->getNumberOfComponents()); - const double valuesExpected5[8]={7.,9.,11.,13.,8.,10.,12.,14.}; - values=trgField->getArray()->getConstPointer(); - for(int i0=0;i0<8;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected5[i0],values[i0],1e-12); - trgField->decrRef(); - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // ------------- 2D -> 1D - sourceMesh=MEDCouplingBasicsTest::build2DTargetMesh_1(); - targetMesh=build1DTargetMesh_2(); - remapper.setIntersectionType(INTERP_KERNEL::PointLocator); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgField=remapper.transferField(srcField,4.57); - const double valuesExpected8[5]={9.,8.,11.,7.,11.}; - values=trgField->getArray()->getConstPointer(); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected8[i0],values[i0],1e-12); - trgField->decrRef(); - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // ------------- 1D -> 2D - sourceMesh=build1DTargetMesh_2(); - targetMesh=MEDCouplingBasicsTest::build2DTargetMesh_1(); - remapper.setIntersectionType(INTERP_KERNEL::PointLocator); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgField=remapper.transferField(srcField,4.57); - const double valuesExpected9[5]={10.,8.,7.,4.57,10.}; - values=trgField->getArray()->getConstPointer(); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected9[i0],values[i0],1e-12); - trgField->decrRef(); - srcField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); - // ------------- 2D -> -1D - sourceMesh=MEDCouplingBasicsTest::build2DTargetMesh_1(); - targetMesh=MEDCouplingUMesh::New("an example of -1 D mesh",-1); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - trgField=remapper.transferField(srcField,4.57); - values=trgField->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(1,trgField->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgField->getNumberOfComponents()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,values[0],1e-14); - srcField->decrRef(); - srcField=remapper.reverseTransferField(trgField,4.220173); - CPPUNIT_ASSERT_EQUAL(5,srcField->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,srcField->getNumberOfComponents()); - values=srcField->getArray()->getConstPointer(); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,values[i0],1e-14); - srcField->decrRef(); - trgField->setNature(Integral); - srcField=remapper.reverseTransferField(trgField,4.220173); - CPPUNIT_ASSERT_EQUAL(5,srcField->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,srcField->getNumberOfComponents()); - values=srcField->getArray()->getConstPointer(); - const double valuesExpected6[5]={2.28125,1.140625,1.140625,2.28125,2.28125}; - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected6[i0],values[i0],1e-14); - srcField->decrRef(); - trgField->decrRef(); - // ------------- -1D -> 2D - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(targetMesh,sourceMesh,"P0P0")); - trgField=MEDCouplingFieldDouble::New(ON_CELLS); - trgField->setNature(ConservativeVolumic); - trgField->setMesh(targetMesh); - array=DataArrayDouble::New(); - array->alloc(targetMesh->getNumberOfCells(),1); - trgField->setArray(array); - ptr=array->getPointer(); - ptr[0]=7.; - array->decrRef(); - srcField=remapper.transferField(trgField,4.221073); - values=srcField->getArray()->getConstPointer(); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,values[i0],1e-14); - srcField->decrRef(); - trgField->setNature(IntegralGlobConstraint); - srcField=remapper.transferField(trgField,4.221073); - values=srcField->getArray()->getConstPointer(); - const double valuesExpected7[5]={1.75,0.875,0.875,1.75,1.75}; - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected7[i0],values[i0],1e-14); - srcField->decrRef(); - trgField->setNature(Integral); - srcField=remapper.transferField(trgField,4.221073); - values=srcField->getArray()->getConstPointer(); - for(int i0=0;i0<5;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected7[i0],values[i0],1e-14); - // - srcField->decrRef(); - trgField->decrRef(); - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingRemapperTest::testNatureOfField() -{ - MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); - MEDCouplingUMesh *targetMesh=build2DTargetMesh_3(); - // - MEDCouplingRemapper remapper; - remapper.setPrecision(1e-12); - remapper.setIntersectionType(INTERP_KERNEL::Triangulation); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - double *ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - MEDCouplingFieldDouble *trgfield=remapper.transferField(srcField,4.220173); - const double *values=trgfield->getArray()->getConstPointer(); - const double valuesExpected[4]={7.75, 7.0625, 4.220173,8.0}; - CPPUNIT_ASSERT_EQUAL(4,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<4;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(IntegralGlobConstraint); - trgfield=remapper.transferField(srcField,4.220173); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected2[4]={2.8374999999999999, 7.3624999999999998, 4.220173, 4.7999999999999998}; - CPPUNIT_ASSERT_EQUAL(4,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<4;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(Integral); - trgfield=remapper.transferField(srcField,4.220173); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected3[4]={1.24, 4.5199999999999996, 4.220173, 1.9199999999999999}; - CPPUNIT_ASSERT_EQUAL(4,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<4;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected3[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(RevIntegral); - trgfield=remapper.transferField(srcField,4.220173); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected9[4]={2.48, 3.766666666666666, 4.220173, 1.9199999999999999}; - CPPUNIT_ASSERT_EQUAL(4,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<4;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected9[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->decrRef(); - // REVERSE *********** - trgfield=MEDCouplingFieldDouble::New(ON_CELLS); - trgfield->setNature(ConservativeVolumic); - trgfield->setMesh(targetMesh); - array=DataArrayDouble::New(); - array->alloc(targetMesh->getNumberOfCells(),1); - trgfield->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - srcField=remapper.reverseTransferField(trgfield,4.220173); - values=srcField->getArray()->getConstPointer(); - const double valuesExpected4[2]={7.9375, 8.9}; - CPPUNIT_ASSERT_EQUAL(2,srcField->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,srcField->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected4[i0],values[i0],1e-12); - srcField->decrRef(); - // - trgfield->decrRef(); - // - sourceMesh->decrRef(); - targetMesh->decrRef(); - // REVERSE ALL - sourceMesh=build2DTargetMesh_3(); - targetMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); - // - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); - srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(ConservativeVolumic); - srcField->setMesh(sourceMesh); - array=DataArrayDouble::New(); - array->alloc(sourceMesh->getNumberOfCells(),1); - srcField->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - trgfield=remapper.transferField(srcField,4.220173); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected5[2]={7.9375, 8.9}; - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected5[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(IntegralGlobConstraint); - trgfield=remapper.transferField(srcField,4.220173); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected6[4]={9.25, 15.75}; - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected6[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(Integral); - trgfield=remapper.transferField(srcField,4.220173); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected7[2]={4.56, 4.3466666666666667}; - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected7[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->setNature(RevIntegral); - trgfield=remapper.transferField(srcField,4.220173); - values=trgfield->getArray()->getConstPointer(); - const double valuesExpected10[2]={5.08, 3.56}; - CPPUNIT_ASSERT_EQUAL(2,trgfield->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); - for(int i0=0;i0<2;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected10[i0],values[i0],1e-12); - trgfield->decrRef(); - // - srcField->decrRef(); - // REVERSE *********** - trgfield=MEDCouplingFieldDouble::New(ON_CELLS); - trgfield->setNature(ConservativeVolumic); - trgfield->setMesh(targetMesh); - array=DataArrayDouble::New(); - array->alloc(targetMesh->getNumberOfCells(),1); - trgfield->setArray(array); - ptr=array->getPointer(); - for(int i=0;igetNumberOfCells();i++) - ptr[i]=(double)(i+7); - array->decrRef(); - srcField=remapper.reverseTransferField(trgfield,4.220173); - values=srcField->getArray()->getConstPointer(); - const double valuesExpected8[4]={7.75, 7.0625,4.220173, 8.0}; - CPPUNIT_ASSERT_EQUAL(4,srcField->getArray()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,srcField->getArray()->getNumberOfComponents()); - for(int i0=0;i0<4;i0++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected8[i0],values[i0],1e-12); - srcField->decrRef(); - // - trgfield->decrRef(); - // - sourceMesh->decrRef(); - targetMesh->decrRef(); -} - -void MEDCouplingRemapperTest::testExtruded() -{ - MEDCouplingUMesh *mesh2DS=0; - MEDCouplingUMesh *mesh3DS=build3DExtrudedUMesh_1(mesh2DS); - MEDCouplingExtrudedMesh *extS=MEDCouplingExtrudedMesh::New(mesh3DS,mesh2DS,1); - mesh3DS->decrRef(); - mesh2DS->decrRef(); - MEDCouplingUMesh *mesh2DT=0; - MEDCouplingUMesh *mesh3DT=build3DExtrudedUMesh_1(mesh2DT); - MEDCouplingExtrudedMesh *extT=MEDCouplingExtrudedMesh::New(mesh3DT,mesh2DT,1); - // - // - mesh3DT->decrRef(); - mesh2DT->decrRef(); - // - extS->decrRef(); - extT->decrRef(); -} - -void MEDCouplingRemapperTest::testExtruded2() -{ - MEDCouplingUMesh *meshN,*meshTT,*meshTF; - MEDCouplingBasicsTest::build3DExtrudedUMesh_2(meshN,meshTT,meshTF); - std::vector n; - double pt[3]={300.,300.,0.}; - double v[3]={0.,0.,2.}; - meshN->findNodesOnPlane(pt,v,1e-12,n); - MEDCouplingUMesh *meshN2D=(MEDCouplingUMesh *)meshN->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); - n.clear(); - bool b=false; - int newNbOfNodes; - DataArrayInt *da=meshTT->mergeNodes(1e-12,b,newNbOfNodes); - CPPUNIT_ASSERT(b); - da->decrRef(); - meshTT->findNodesOnPlane(pt,v,1e-12,n); - MEDCouplingUMesh *meshTT2D=(MEDCouplingUMesh *)meshTT->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); - n.clear(); - meshTF->findNodesOnPlane(pt,v,1e-12,n); - MEDCouplingUMesh *meshTF2D=(MEDCouplingUMesh *)meshTF->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); - n.clear(); - // - MEDCouplingExtrudedMesh *meshNE=MEDCouplingExtrudedMesh::New(meshN,meshN2D,0); - MEDCouplingExtrudedMesh *meshTTE=MEDCouplingExtrudedMesh::New(meshTT,meshTT2D,0); - MEDCouplingExtrudedMesh *meshTFE=MEDCouplingExtrudedMesh::New(meshTF,meshTF2D,0); - // - MEDCouplingRemapper remapper; - remapper.setPrecision(1e-12); - remapper.setIntersectionType(INTERP_KERNEL::Geometric2D); - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(meshNE,meshTTE,"P0P0")); - MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS); - srcField->setNature(IntegralGlobConstraint); - srcField->setMesh(meshNE); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(meshNE->getNumberOfCells(),1); - srcField->setArray(array); - double vals1[40]={ - 1000.,1000.,1020.,1030.,1040.,1000.,1000.,1070.,1080.,1090.,1000.,1000.,1120.,1130.,1140.,1000.,1000.,1170.,1180.,1190., - 2000.,2000.,2020.,2030.,2040.,2000.,2000.,2070.,2080.,2090.,2000.,2000.,2120.,2130.,2140.,2000.,2000.,2170.,2180.,2190., - }; - CPPUNIT_ASSERT_EQUAL((int)(sizeof(vals1)/sizeof(double)),meshNE->getNumberOfCells()); - std::copy(vals1,vals1+meshNE->getNumberOfCells(),array->getPointer()); - array->decrRef(); - MEDCouplingFieldDouble *trgField=remapper.transferField(srcField,4.220173); - double expected1[200]={ - 800.,800.,800.,800.,800.,800.,800.,800.,800.,800.,1600.,1600.,1600.,1600.,1600.,1600.,1600.,1600.,1600.,1600., - 102.,102.,102.,102.,102.,102.,102.,102.,102.,102.,202.,202.,202.,202.,202.,202.,202.,202.,202.,202., - 103.,103.,103.,103.,103.,103.,103.,103.,103.,103.,203.,203.,203.,203.,203.,203.,203.,203.,203.,203., - 104.,104.,104.,104.,104.,104.,104.,104.,104.,104.,204.,204.,204.,204.,204.,204.,204.,204.,204.,204., - 219.,219.,219.,219.,219.,219.,219.,219.,219.,219.,419.,419.,419.,419.,419.,419.,419.,419.,419.,419., - 221.,221.,221.,221.,221.,221.,221.,221.,221.,221.,421.,421.,421.,421.,421.,421.,421.,421.,421.,421., - 223.,223.,223.,223.,223.,223.,223.,223.,223.,223.,423.,423.,423.,423.,423.,423.,423.,423.,423.,423., - 117.,117.,117.,117.,117.,117.,117.,117.,117.,117.,217.,217.,217.,217.,217.,217.,217.,217.,217.,217., - 118.,118.,118.,118.,118.,118.,118.,118.,118.,118.,218.,218.,218.,218.,218.,218.,218.,218.,218.,218., - 119.,119.,119.,119.,119.,119.,119.,119.,119.,119.,219.,219.,219.,219.,219.,219.,219.,219.,219.,219. - }; - for(int i=0;i<200;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],trgField->getArray()->getConstPointer()[i],1e-3);//1e-3 precision due to non coincidence in 1D mesh - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::accumulate(expected1,expected1+200,0.),std::accumulate(vals1,vals1+40,0.),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::accumulate(expected1,expected1+200,0.),std::accumulate(trgField->getArray()->getConstPointer(),trgField->getArray()->getConstPointer()+200,0.),1e-10); - trgField->decrRef(); - // - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(meshNE,meshTFE,"P0P0")); - trgField=remapper.transferField(srcField,4.220173); - double expected2[340]={25.5, 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, 26., 79., 158.75, - 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, - 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, - 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, - 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, - 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, - 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, 29.75, 25.5, 51.25, 51.75, 26., 79., 158.75, 160.25, 80.5, 85.25, 171.25, 172.75, 86.75, 29.25, 58.75, 59.25, - 29.75, 50.5, 101.25, 101.75, 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, 51., 154., - 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, - 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, - 101.25, 101.75, 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, 51., 154., 308.75, 310.25, - 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, - 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, - 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 50.5, 101.25, 101.75, 51., 154., 308.75, 310.25, 155.5, 160.25, 321.25, - 322.75, 161.75, 54.25, 108.75, 109.25, 54.75, 800., 800., 800., 800., 800., 800., 800., 800., 800., 800., 1600., 1600., 1600., 1600., 1600., 1600., 1600., - 1600., 1600., 1600.}; - for(int i=0;i<340;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],trgField->getArray()->getConstPointer()[i],1e-3);//1e-3 precision due to non coincidence in 1D mesh - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::accumulate(expected2,expected2+340,0.),std::accumulate(vals1,vals1+40,0.),1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::accumulate(expected2,expected2+340,0.),std::accumulate(trgField->getArray()->getConstPointer(),trgField->getArray()->getConstPointer()+340,0.),1e-10); - trgField->decrRef(); - srcField->decrRef(); - // - double vals2[200]={ - 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1700., 1800., 1900., 2000, - 101., 201., 301., 401., 501., 601., 701., 801., 901., 1001., 1101., 1201., 1301., 1401., 1501., 1601., 1701., 1801., 1901., 2001, - 102., 202., 302., 402., 502., 602., 702., 802., 902., 1002., 1102., 1202., 1302., 1402., 1502., 1602., 1702., 1802., 1902., 2002, - 103., 203., 303., 403., 503., 603., 703., 803., 903., 1003., 1103., 1203., 1303., 1403., 1503., 1603., 1703., 1803., 1903., 2003, - 104., 204., 304., 404., 504., 604., 704., 804., 904., 1004., 1104., 1204., 1304., 1404., 1504., 1604., 1704., 1804., 1904., 2004, - 105., 205., 305., 405., 505., 605., 705., 805., 905., 1005., 1105., 1205., 1305., 1405., 1505., 1605., 1705., 1805., 1905., 2005, - 106., 206., 306., 406., 506., 606., 706., 806., 906., 1006., 1106., 1206., 1306., 1406., 1506., 1606., 1706., 1806., 1906., 2006, - 107., 207., 307., 407., 507., 607., 707., 807., 907., 1007., 1107., 1207., 1307., 1407., 1507., 1607., 1707., 1807., 1907., 2007, - 108., 208., 308., 408., 508., 608., 708., 808., 908., 1008., 1108., 1208., 1308., 1408., 1508., 1608., 1708., 1808., 1908., 2008, - 109., 209., 309., 409., 509., 609., 709., 809., 909., 1009., 1109., 1209., 1309., 1409., 1509., 1609., 1709., 1809., 1909., 2009. - }; - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(meshNE,meshTTE,"P0P0")); - trgField=MEDCouplingFieldDouble::New(ON_CELLS); - trgField->setNature(ConservativeVolumic); - trgField->setMesh(meshTTE); - array=DataArrayDouble::New(); - array->alloc(meshTTE->getNumberOfCells(),1); - trgField->setArray(array); - std::copy(vals2,vals2+meshTTE->getNumberOfCells(),array->getPointer()); - array->decrRef(); - srcField=remapper.reverseTransferField(trgField,4.220173); - double expected3[40]={ - 550.,550.,551.,552.,553.,550.,550.,554.,555.,556.,550.,550.,554.,555.,556.,550.,550.,557.,558.,559., - 1550.,1550.,1551.,1552.,1553.,1550.,1550.,1554.,1555.,1556.,1550.,1550.,1554.,1555.,1556.,1550.,1550.,1557.,1558.,1559. - }; - for(int i=0;i<40;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],srcField->getArray()->getConstPointer()[i],1e-3);//1e-3 precision due to non coincidence in 1D mesh - srcField->decrRef(); - trgField->decrRef(); - // - double vals3[340]={ - 100., 101., 102., 103., 104., 105., 106., 107., 108., 109., 110., 111., 112., 113., 114., 115., - 200., 201., 202., 203., 204., 205., 206., 207., 208., 209., 210., 211., 212., 213., 214., 215., - 300., 301., 302., 303., 304., 305., 306., 307., 308., 309., 310., 311., 312., 313., 314., 315., - 400., 401., 402., 403., 404., 405., 406., 407., 408., 409., 410., 411., 412., 413., 414., 415., - 500., 501., 502., 503., 504., 505., 506., 507., 508., 509., 510., 511., 512., 513., 514., 515., - 600., 601., 602., 603., 604., 605., 606., 607., 608., 609., 610., 611., 612., 613., 614., 615., - 700., 701., 702., 703., 704., 705., 706., 707., 708., 709., 710., 711., 712., 713., 714., 715., - 800., 801., 802., 803., 804., 805., 806., 807., 808., 809., 810., 811., 812., 813., 814., 815., - 900., 901., 902., 903., 904., 905., 906., 907., 908., 909., 910., 911., 912., 913., 914., 915., - 1000., 1001., 1002., 1003., 1004., 1005., 1006., 1007., 1008., 1009., 1010., 1011., 1012., 1013., 1014., 1015., - 1100., 1101., 1102., 1103., 1104., 1105., 1106., 1107., 1108., 1109., 1110., 1111., 1112., 1113., 1114., 1115., - 1200., 1201., 1202., 1203., 1204., 1205., 1206., 1207., 1208., 1209., 1210., 1211., 1212., 1213., 1214., 1215., - 1300., 1301., 1302., 1303., 1304., 1305., 1306., 1307., 1308., 1309., 1310., 1311., 1312., 1313., 1314., 1315., - 1400., 1401., 1402., 1403., 1404., 1405., 1406., 1407., 1408., 1409., 1410., 1411., 1412., 1413., 1414., 1415., - 1500., 1501., 1502., 1503., 1504., 1505., 1506., 1507., 1508., 1509., 1510., 1511., 1512., 1513., 1514., 1515., - 1600., 1601., 1602., 1603., 1604., 1605., 1606., 1607., 1608., 1609., 1610., 1611., 1612., 1613., 1614., 1615., - 1700., 1701., 1702., 1703., 1704., 1705., 1706., 1707., 1708., 1709., 1710., 1711., 1712., 1713., 1714., 1715., - 1800., 1801., 1802., 1803., 1804., 1805., 1806., 1807., 1808., 1809., 1810., 1811., 1812., 1813., 1814., 1815., - 1900., 1901., 1902., 1903., 1904., 1905., 1906., 1907., 1908., 1909., 1910., 1911., 1912., 1913., 1914., 1915., - 2000., 2001., 2002., 2003., 2004., 2005., 2006., 2007., 2008., 2009., 2010., 2011., 2012., 2013., 2014., 2015., - 116.,216.,316.,416.,516.,616.,716.,816.,916.,1016.,1116.,1216.,1316.,1416.,1516.,1616.,1716.,1816.,1916.,2016. - }; - CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(meshNE,meshTFE,"P0P0")); - trgField=MEDCouplingFieldDouble::New(ON_CELLS); - trgField->setNature(ConservativeVolumic); - trgField->setMesh(meshTFE); - array=DataArrayDouble::New(); - array->alloc(meshTFE->getNumberOfCells(),1); - trgField->setArray(array); - std::copy(vals3,vals3+meshTFE->getNumberOfCells(),array->getPointer()); - array->decrRef(); - srcField=remapper.reverseTransferField(trgField,4.220173); - double expected4[40]={ - 566.,566.,552.5,553.5,554.5,566.,566.,554.5,555.5,556.5,566.,566.,558.5,559.5,560.5,566.,566.,560.5,561.5,562.5, - 1566.,1566.,1552.5,1553.5,1554.5,1566.,1566.,1554.5,1555.5,1556.5,1566.,1566.,1558.5,1559.5,1560.5,1566.,1566.,1560.5,1561.5,1562.5 - }; - for(int i=0;i<40;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected4[i],srcField->getArray()->getConstPointer()[i],1e-3);//1e-3 precision due to non coincidence in 1D mesh - srcField->decrRef(); - trgField->decrRef(); - // - meshN2D->decrRef(); - meshTT2D->decrRef(); - meshTF2D->decrRef(); - meshNE->decrRef(); - meshTTE->decrRef(); - meshTFE->decrRef(); - meshN->decrRef(); - meshTT->decrRef(); - meshTF->decrRef(); -} - -MEDCouplingUMesh *MEDCouplingRemapperTest::build1DTargetMesh_2() -{ - double targetCoords[20]={ - 0.59,0.09, 0.69,0.19, 0.21,-0.29,0.31,-0.19, 0.45,0.25,0.65,0.45, - -0.2,-0.2,0.11,0.11, 0.25,0.25, 0.45,0.45 - }; - int targetConn[10]={0,1, 2,3, 4,5, 6,7, 8,9}; - - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("my name of mesh 1D 2",1); - targetMesh->allocateCells(5); - for(int i=0;i<5;i++) - targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(10,2); - std::copy(targetCoords,targetCoords+20,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingRemapperTest::build2DTargetMesh_3() -{ - double targetCoords[20]={-0.6,-0.4, -0.1,-0.4, 1.1,-0.4, 2.1,-0.4, - -0.6,0.1, -0.1,0.1, 1.1,0.1, 2.1,0.1, - -0.6,1.1, -0.1,1.1}; - int targetConn[16]={0,4,5,1, 1,5,6,2, 2,6,7,3, 4,8,9,5}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(4); - for(int i=0;i<4;i++) - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+4*i); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(10,2); - std::copy(targetCoords,targetCoords+20,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDCouplingRemapperTest::build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D) -{ - double coords[180]={ - 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., - 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., - 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., - 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1., - 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., - 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2., - 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., - 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.}; - - int conn[354]={ - // 0 - 0,11,1,3,15,26,16,18, 1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17, - 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21, - 11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23, - 7,12,14,13,22,27,29,28, - // 1 - 15,26,16,18,30,41,31,33, 16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32, - 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36, - 26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38, - 22,27,29,28,37,42,44,43, - // 2 - 30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47, - 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51, - 41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53, - 37,42,44,43,52,57,59,58 - }; - int conn2[28]={7,12,14,13, 11,8,7,4,2,1, 13,10,9,6, 1,6,5,3, 1,2,4,7,13,6, 0,11,1,3}; - // - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setMeshDimension(3); - ret->allocateCells(18); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+8); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+51); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+59); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+67); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+110); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+118); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+126); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+169); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+177); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+185); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+228); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+236); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+244); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+287); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+295); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+303); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+346); - // - ret->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(60,3); - std::copy(coords,coords+180,myCoords->getPointer()); - ret->setCoords(myCoords); - // - mesh2D=MEDCouplingUMesh::New(); - mesh2D->setMeshDimension(2); - mesh2D->allocateCells(6); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+4); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+10); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+14); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+18); - mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+24); - mesh2D->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx deleted file mode 100644 index 2b45b4b06..000000000 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2010 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 __MEDCOUPLINGREMAPPERTEST_HXX__ -#define __MEDCOUPLINGREMAPPERTEST_HXX__ - -#include - -#include -#include - -namespace ParaMEDMEM -{ - class MEDCouplingUMesh; - - class MEDCouplingRemapperTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE(MEDCouplingRemapperTest); - CPPUNIT_TEST( test2DInterpP0P0_1 ); - CPPUNIT_TEST( test2DInterpP0P0R_1 ); - CPPUNIT_TEST( test1DInterp_1 ); - CPPUNIT_TEST( test2DInterpMultiMethods ); - CPPUNIT_TEST( testMultiDimCombi ); - CPPUNIT_TEST( testNatureOfField ); - CPPUNIT_TEST( testExtruded ); - CPPUNIT_TEST( testExtruded2 ); - CPPUNIT_TEST_SUITE_END(); - public: - void test2DInterpP0P0_1(); - void test2DInterpP0P0R_1(); - void test1DInterp_1(); - void test2DInterpMultiMethods(); - void testMultiDimCombi(); - void testNatureOfField(); - void testExtruded(); - void testExtruded2(); - private: - static MEDCouplingUMesh *build1DTargetMesh_2(); - static MEDCouplingUMesh *build2DTargetMesh_3(); - static MEDCouplingUMesh *build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D); - }; -} - -#endif diff --git a/src/MEDCoupling/Test/Makefile.am b/src/MEDCoupling/Test/Makefile.am deleted file mode 100755 index bab460971..000000000 --- a/src/MEDCoupling/Test/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2007-2010 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -bin_PROGRAMS= TestMEDCoupling TestMEDCouplingRemapper - -TestMEDCoupling_CPPFLAGS=@CPPUNIT_INCLUDES@ @PTHREAD_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../../INTERP_KERNEL/Bases -I$(srcdir)/../../INTERP_KERNELTest -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Geometric2D - -TestMEDCoupling_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcoupling.la ../../INTERP_KERNEL/libinterpkernel.la - -dist_TestMEDCoupling_SOURCES = TestMEDCoupling.cxx MEDCouplingBasicsTest.hxx MEDCouplingBasicsTest0.cxx MEDCouplingBasicsTest1.cxx \ - MEDCouplingBasicsTest2.cxx MEDCouplingBasicsTestInterp.cxx MEDCouplingBasicsTestData1.hxx - -TestMEDCouplingRemapper_CPPFLAGS=@CPPUNIT_INCLUDES@ @PTHREAD_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../../INTERP_KERNEL/Bases -I$(srcdir)/../../INTERP_KERNELTest -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Geometric2D - -TestMEDCouplingRemapper_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcouplingremapper.la ../../INTERP_KERNEL/libinterpkernel.la - -dist_TestMEDCouplingRemapper_SOURCES = TestMEDCouplingRemapper.cxx MEDCouplingRemapperTest.hxx MEDCouplingRemapperTest.cxx MEDCouplingBasicsTest0.cxx - -UNIT_TEST_PROG = TestMEDCoupling TestMEDCouplingRemapper - -check : tests - -CLEANFILES = \ - UnitTestsResult - \ No newline at end of file diff --git a/src/MEDCoupling/Test/TestMEDCoupling.cxx b/src/MEDCoupling/Test/TestMEDCoupling.cxx deleted file mode 100644 index 84813ca08..000000000 --- a/src/MEDCoupling/Test/TestMEDCoupling.cxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2007-2010 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 "CppUnitTest.hxx" -#include "MEDCouplingBasicsTest.hxx" - -CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest ); - -#include "BasicMainTest.hxx" diff --git a/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx b/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx deleted file mode 100644 index 80b233001..000000000 --- a/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2007-2010 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 "CppUnitTest.hxx" -#include "MEDCouplingRemapperTest.hxx" - -CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingRemapperTest ); - -#include "BasicMainTest.hxx" diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py deleted file mode 100644 index 53cd9f4df..000000000 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ /dev/null @@ -1,3407 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libMEDCoupling_Swig import * -import unittest -from math import pi,e,sqrt -from MEDCouplingDataForTest import MEDCouplingDataForTest - -class MEDCouplingBasicsTest(unittest.TestCase): - def testArray2(self): - arr=DataArrayDouble.New() - arr.setValues([12.,11.,10.,9.,8.,7.,6.,5.,4.,3.,2.,1.],3,4) - arr.setInfoOnComponent(0,"ggg"); - arr.setInfoOnComponent(1,"hhhh"); - arr.setInfoOnComponent(2,"jj"); - arr.setInfoOnComponent(3,"kkkkkk"); - arr2=arr.convertToIntArr(); - arr3=arr2.convertToDblArr(); - self.assertTrue(arr.isEqual(arr3,1e-14)) - pass - - def testArray3(self): - arr1=DataArrayInt.New(); - arr1Ref=[0,10,1,11,2,12,3,13,4,14,5,15,6,16] - arr1.setValues(arr1Ref,7,2); - self.assertEqual(7,arr1.getNumberOfTuples()); - self.assertEqual(2,arr1.getNumberOfComponents()); - self.assertEqual(arr1Ref,list(arr1.getValues())); - arr2=arr1.substr(3); - self.assertEqual(4,arr2.getNumberOfTuples()); - self.assertEqual(2,arr2.getNumberOfComponents()); - self.assertEqual(arr1Ref[6:],list(arr2.getValues())); - arr3=arr1.substr(2,5); - self.assertEqual(3,arr3.getNumberOfTuples()); - self.assertEqual(2,arr3.getNumberOfComponents()); - self.assertEqual(arr1Ref[4:10],list(arr3.getValues())); - # - arr4=DataArrayDouble.New(); - arr4Ref=[0.8,10.8,1.9,11.9,2.1,12.1,3.2,13.2,4.3,14.3,5.4,15.4,6.5,16.5] - arr4.setValues(arr4Ref,7,2); - self.assertEqual(7,arr4.getNumberOfTuples()); - self.assertEqual(2,arr4.getNumberOfComponents()); - tmp=arr4.getValues() - for i in xrange(14): - self.assertTrue(abs(arr4Ref[i]-tmp[i])<1e-14); - pass - arr5=arr4.substr(3); - self.assertEqual(4,arr5.getNumberOfTuples()); - self.assertEqual(2,arr5.getNumberOfComponents()); - tmp=arr5.getValues() - for i in xrange(8): - self.assertTrue(abs(arr4Ref[6+i]-tmp[i])<1e-14); - pass - arr6=arr4.substr(2,5); - self.assertEqual(3,arr6.getNumberOfTuples()); - self.assertEqual(2,arr6.getNumberOfComponents()); - tmp=arr6.getValues() - for i in xrange(6): - self.assertTrue(abs(arr4Ref[4+i]-tmp[i])<1e-14); - pass - pass - - def testMesh(self): - tab4=[1, 2, 8, 7, 2, 3, 9, 8, 3, - 4, 10, 9, 4, 5, 11, 10, 5, - 0, 6, 11, 0, 1, 7, 6 ] - nbOfNodes=12 - nbOfCells=6 - coords=[ 0.024155, 0.04183768725682622, -0.305, 0.04831000000000001, -1.015761910347357e-17, - -0.305, 0.09662000000000001, -1.832979297858306e-18, -0.305, 0.120775, 0.04183768725682623, - -0.305, 0.09662000000000001, 0.08367537451365245, -0.305, 0.04831000000000001, 0.08367537451365246, - -0.305, 0.024155, 0.04183768725682622, -0.2863, 0.04831000000000001, -1.015761910347357e-17, -0.2863, - 0.09662000000000001, -1.832979297858306e-18, -0.2863, 0.120775, 0.04183768725682623, -0.2863, 0.09662000000000001, - 0.08367537451365245, -0.2863, 0.04831000000000001, 0.08367537451365246, -0.2863 ] - mesh=MEDCouplingUMesh.New() - mesh.setMeshDimension(2) - mesh.allocateCells(8); - mesh.setName("mesh1") - self.assertTrue(mesh.getName()=="mesh1") - for i in range(nbOfCells): - mesh.insertNextCell(NORM_QUAD4,4,tab4[4*i:4*(i+1)]); - pass - mesh.finishInsertingCells() - self.assertTrue(mesh.getNumberOfCells()==nbOfCells) - self.assertTrue(mesh.getNodalConnectivity().getNbOfElems()==30) - self.assertTrue(mesh.getNodalConnectivityIndex().getNbOfElems()==nbOfCells+1) - myCoords=DataArrayDouble.New() - myCoords.setValues(coords,nbOfNodes,3); - self.assertTrue(myCoords.getIJ(3,2)==-0.305) - mesh.setCoords(myCoords); - mesh.checkCoherency(); - self.assertTrue(mesh.getAllTypes()==[4]) - myFalseConn=DataArrayInt.New() - myFalseConn.setValues(tab4,6,4) - self.assertTrue(myFalseConn.getIJ(1,1)==3) - # - field=MEDCouplingFieldDouble.New(ON_CELLS) - field.setMesh(mesh) - field.setNature(Integral) - myCoords=DataArrayDouble.New() - sampleTab=[] - for i in range(nbOfCells*9): - sampleTab.append(float(i)) - myCoords.setValues(sampleTab,nbOfCells,9); - field.setArray(myCoords) - self.assertTrue(3==mesh.getSpaceDimension()) - field.checkCoherency() - mesh2=mesh.clone(False) - mesh3=mesh.clone(True) - mesh3=0 - mesh2=0 - ## deep full recursively copy of field -> both field and mesh underneath copied - field2=field.clone(True) - field2.setMesh(field.getMesh().clone(True)) - mesh3=mesh.clone(True) - field3=mesh3.fillFromAnalytic(ON_CELLS,2,"x*IVec+(y+z)*JVec") - field3.applyFunc("u*u*u+cos(u)") - pass - def testMeshPointsCloud(self): - targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, - -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(0); - targetMesh.allocateCells(8); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,9,3); - targetMesh.setCoords(myCoords); - self.assertEqual(targetMesh.getSpaceDimension(),3) - self.assertEqual(targetMesh.getNumberOfCells(),8) - self.assertEqual(targetMesh.getNumberOfNodes(),9) - self.assertEqual(targetMesh.getMeshDimension(),0) - pass - def testMeshM1D(self): - meshM1D=MEDCouplingUMesh.New(); - self.assertRaises(Exception,meshM1D.getMeshDimension); - self.assertRaises(Exception,meshM1D.getNumberOfNodes); - self.assertRaises(Exception,meshM1D.getNumberOfCells); - self.assertRaises(Exception,meshM1D.setMeshDimension,-2) - self.assertRaises(Exception,meshM1D.setMeshDimension,-10) - meshM1D.setMeshDimension(-1); - meshM1D.checkCoherency(); - self.assertEqual(meshM1D.getMeshDimension(),-1); - self.assertEqual(meshM1D.getNumberOfCells(),1); - self.assertRaises(Exception,meshM1D.getNumberOfNodes); - self.assertRaises(Exception,meshM1D.getSpaceDimension); - cpy=meshM1D.clone(True); - self.assertTrue(cpy.isEqual(meshM1D,1e-12)); - fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS); - fieldOnCells.setMesh(meshM1D); - array=DataArrayDouble.New(); - array.setValues(6*[7.],1,6); - fieldOnCells.setArray(array); - fieldOnCells.checkCoherency(); - pass - def testDeepCopy(self): - array=DataArrayDouble.New(); - array.setValues(5*3*[7.],5,3); - self.assertEqual(array.getIJ(3,2),7.); - array2=array.deepCopy(); - self.assertEqual(array2.getIJ(3,2),7.) - # - array3=DataArrayInt.New(); - array3.setValues(5*3*[17],5,3); - self.assertEqual(array3.getIJ(3,2),17); - array4=array3.deepCopy(); - self.assertEqual(array4.getIJ(3,2),17); - pass - def testRevNodal(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_1() - revNodal=DataArrayInt.New(); - revNodalIndx=DataArrayInt.New(); - mesh.getReverseNodalConnectivity(revNodal,revNodalIndx); - revNodalExpected=[0,0,1,1,2,0,3,0,1,2,3,4,2,4,3,3,4,4]; - revNodalIndexExpected=[0,1,3,5,7,12,14,15,17,18]; - self.assertEqual(revNodal.getNbOfElems(),18) - self.assertEqual(revNodalIndx.getNbOfElems(),10) - self.assertEqual(list(revNodal.getValues()),revNodalExpected) - self.assertEqual(list(revNodalIndx.getValues()),revNodalIndexExpected) - pass - def testConvertToPolyTypes(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - elts=[1,3]; - mesh.convertToPolyTypes(elts); - mesh.checkCoherency(); - self.assertEqual(5,mesh.getNumberOfCells()); - self.assertEqual(23,mesh.getNodalConnectivity().getNumberOfTuples()); - expected1=[4, 0, 3, 4, 1, 5, 1, 4, 2, 3, 4, 5, 2, 5, 6, 7, 4, 3, 4, 7, 8, 5, 4] - self.assertEqual(expected1,list(mesh.getNodalConnectivity().getValues())); - # - mesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - mesh.convertToPolyTypes(elts); - mesh.checkCoherency(); - self.assertEqual(8,mesh.getNumberOfCells()); - self.assertEqual(114,mesh.getNodalConnectivity().getNumberOfTuples()); - mesh.convertToPolyTypes(elts); - mesh.checkCoherency(); - self.assertEqual(8,mesh.getNumberOfCells()); - self.assertEqual(114,mesh.getNodalConnectivity().getNumberOfTuples()); - pass - def testDescConn2D(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - desc=DataArrayInt.New(); - descIndx=DataArrayInt.New(); - revDesc=DataArrayInt.New(); - revDescIndx=DataArrayInt.New(); - mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2.checkCoherency(); - self.assertEqual(1,mesh2.getMeshDimension()); - self.assertEqual(13,mesh2.getNumberOfCells()); - self.assertEqual(14,revDescIndx.getNbOfElems()); self.assertEqual(14,revDescIndx.getNumberOfTuples()); - self.assertEqual(6,descIndx.getNbOfElems()); self.assertEqual(6,descIndx.getNumberOfTuples()); - self.assertEqual(18,desc.getNbOfElems()); self.assertEqual(18,desc.getNumberOfTuples()); - self.assertEqual(18,revDesc.getNbOfElems()); self.assertEqual(18,revDesc.getNumberOfTuples()); - expected1=[0,1,2,3, 2,4,5, 6,7,4, 8,9,1,10, 11,12,6,9]; - self.assertEqual(expected1,list(desc.getValues())); - expected2=[0,4,7,10,14,18]; - self.assertEqual(expected2,list(descIndx.getValues())); - expected3=[0,1,3,5,6,8,9,11,12,13,15,16,17,18]; - self.assertEqual(expected3,list(revDescIndx.getValues())); - expected4=[0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4]; - self.assertEqual(expected4,list(revDesc.getValues())); - conn=mesh2.getNodalConnectivity(); - connIndex=mesh2.getNodalConnectivityIndex(); - expected5=[0,3,6,9,12,15,18,21,24,27,30,33,36,39]; - self.assertEqual(expected5,list(connIndex.getValues())); - expected6=[1, 0, 3, 1, 3, 4, 1, 4, 1, 1, 1, 0, 1, 4, 2, 1, 2, 1, 1, 4, 5, 1, 5, 2, 1, 6, 7, 1, 7, 4, 1, 3, 6, 1, 7, 8, 1, 8, 5]; - self.assertEqual(expected6,list(conn.getValues())); - # - eltsV=[1,3]; - mesh.convertToPolyTypes(eltsV); - mesh.checkCoherency(); - # - desc=DataArrayInt.New(); - descIndx=DataArrayInt.New(); - revDesc=DataArrayInt.New(); - revDescIndx=DataArrayInt.New(); - # - mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2.checkCoherency(); - self.assertEqual(1,mesh2.getMeshDimension()); - self.assertEqual(13,mesh2.getNumberOfCells()); - self.assertEqual(14,revDescIndx.getNbOfElems()); self.assertEqual(14,revDescIndx.getNumberOfTuples()); - self.assertEqual(6,descIndx.getNbOfElems()); self.assertEqual(6,descIndx.getNumberOfTuples()); - self.assertEqual(18,desc.getNbOfElems()); self.assertEqual(18,desc.getNumberOfTuples()); - self.assertEqual(18,revDesc.getNbOfElems()); self.assertEqual(18,revDesc.getNumberOfTuples()); - self.assertEqual(expected1,list(desc.getValues())); - self.assertEqual(expected2,list(descIndx.getValues())); - self.assertEqual(expected3,list(revDescIndx.getValues())); - self.assertEqual(expected4,list(revDesc.getValues())); - conn=mesh2.getNodalConnectivity(); - connIndex=mesh2.getNodalConnectivityIndex(); - self.assertEqual(expected5,list(connIndex.getValues())); - self.assertEqual(expected6,list(conn.getValues())); - pass - def testDescConn3D(self): - mesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - desc=DataArrayInt.New(); - descIndx=DataArrayInt.New(); - revDesc=DataArrayInt.New(); - revDescIndx=DataArrayInt.New(); - # - mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2.checkCoherency(); - self.assertEqual(2,mesh2.getMeshDimension()); - self.assertEqual(36,mesh2.getNumberOfCells()); - self.assertEqual(37,revDescIndx.getNbOfElems()); self.assertEqual(37,revDescIndx.getNumberOfTuples()); - self.assertEqual(9,descIndx.getNbOfElems()); self.assertEqual(9,descIndx.getNumberOfTuples()); - self.assertEqual(48,desc.getNbOfElems()); self.assertEqual(48,desc.getNumberOfTuples()); - self.assertEqual(48,revDesc.getNbOfElems()); self.assertEqual(48,revDesc.getNumberOfTuples()); - expected1=[0, 6, 12, 18, 24, 30, 36, 42, 48] - expected2=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 11, 12, 4, 13, 14, 15, 16, 17, 10, 18, 19, 13, 1, 20, 21, 22, 23, 24, 7, 25, 26, 27, 28, 22, 12, 29, 23, 30, 31, 32, 17, 33, 28, 34, 35, 30] - expected3=[0, 1, 3, 4, 6, 8, 9, 10, 12, 13, 14, 16, 17, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 32, 34, 35, 36, 37, 38, 40, 41, 43, 44, 45, 46, 47, 48] - expected4=[0, 0, 4, 0, 0, 1, 0, 2, 0, 1, 1, 5, 1, 1, 1, 3, 2, 2, 6, 2, 3, 2, 2, 3, 3, 7, 3, 3, 4, 4, 4, 5, 4, 6, 4, 5, 5, 5, 5, 7, 6, 6, 7, 6, 6, 7, 7, 7] - expected5=[0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180] - expected6=[4, 0, 1, 4, 3, 4, 9, 12, 13, 10, 4, 0, 9, 10, 1, 4, 1, 10, 13, 4, 4, 4, 13, 12, 3, 4, 3, 12, 9, 0, 4, 1, 2, 5, 4, 4, 10, 13, 14, 11, 4, 1, 10, 11, 2, 4, 2, 11, 14, - 5, 4, 5, 14, 13, 4, 4, 3, 4, 7, 6, 4, 12, 15, 16, 13, 4, 4, 13, 16, 7, 4, 7, 16, 15, 6, 4, 6, 15, 12, 3, 4, 4, 5, 8, 7, 4, 13, 16, 17, 14, 4, 5, 14, 17, 8, 4, 8, - 17, 16, 7, 4, 18, 21, 22, 19, 4, 9, 18, 19, 10, 4, 10, 19, 22, 13, 4, 13, 22, 21, 12, 4, 12, 21, 18, 9, 4, 19, 22, 23, 20, 4, 10, 19, 20, 11, 4, 11, 20, 23, 14, 4, - 14, 23, 22, 13, 4, 21, 24, 25, 22, 4, 13, 22, 25, 16, 4, 16, 25, 24, 15, 4, 15, 24, 21, 12, 4, 22, 25, 26, 23, 4, 14, 23, 26, 17, 4, 17, 26, 25, 16] - expected7=[4, 0, 1, 4, 3, 4, 9, 12, 13, 10, 4, 0, 9, 10, 1, 4, 1, 10, 13, 4, 4, 4, 13, 12, 3, 4, 3, 12, 9, 0, 5, 1, 2, 5, 4, 5, 10, 13, 14, 11, 5, 1, 10, 11, 2, 5, 2, 11, 14, - 5, 5, 5, 14, 13, 4, 4, 3, 4, 7, 6, 4, 12, 15, 16, 13, 4, 4, 13, 16, 7, 4, 7, 16, 15, 6, 4, 6, 15, 12, 3, 5, 4, 5, 8, 7, 5, 13, 16, 17, 14, 5, 5, 14, 17, 8, 5, 8, - 17, 16, 7, 4, 18, 21, 22, 19, 4, 9, 18, 19, 10, 4, 10, 19, 22, 13, 4, 13, 22, 21, 12, 4, 12, 21, 18, 9, 4, 19, 22, 23, 20, 4, 10, 19, 20, 11, 4, 11, 20, 23, 14, 4, - 14, 23, 22, 13, 4, 21, 24, 25, 22, 4, 13, 22, 25, 16, 4, 16, 25, 24, 15, 4, 15, 24, 21, 12, 4, 22, 25, 26, 23, 4, 14, 23, 26, 17, 4, 17, 26, 25, 16] - - self.assertEqual(expected1,list(descIndx.getValues())); - self.assertEqual(expected2,list(desc.getValues())); - self.assertEqual(expected3,list(revDescIndx.getValues())); - self.assertEqual(expected4,list(revDesc.getValues())); - self.assertEqual(expected5,list(mesh2.getNodalConnectivityIndex().getValues())); - self.assertEqual(expected6,list(mesh2.getNodalConnectivity().getValues())); - # - eltsV=[1,3] - mesh.convertToPolyTypes(eltsV); - mesh.checkCoherency(); - desc=DataArrayInt.New(); - descIndx=DataArrayInt.New(); - revDesc=DataArrayInt.New(); - revDescIndx=DataArrayInt.New(); - mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - mesh2.checkCoherency(); - self.assertEqual(2,mesh2.getMeshDimension()); - self.assertEqual(36,mesh2.getNumberOfCells()); - self.assertEqual(37,revDescIndx.getNbOfElems()); self.assertEqual(37,revDescIndx.getNumberOfTuples()); - self.assertEqual(9,descIndx.getNbOfElems()); self.assertEqual(9,descIndx.getNumberOfTuples()); - self.assertEqual(48,desc.getNbOfElems()); self.assertEqual(48,desc.getNumberOfTuples()); - self.assertEqual(48,revDesc.getNbOfElems()); self.assertEqual(48,revDesc.getNumberOfTuples()); - self.assertEqual(expected1,list(descIndx.getValues())); - self.assertEqual(expected2,list(desc.getValues())); - self.assertEqual(expected3,list(revDescIndx.getValues())); - self.assertEqual(expected4,list(revDesc.getValues())); - self.assertEqual(expected5,list(mesh2.getNodalConnectivityIndex().getValues())); - self.assertEqual(expected7,list(mesh2.getNodalConnectivity().getValues())); - pass - def testFindBoundaryNodes(self): - mesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - boundaryNodes=mesh.findBoundaryNodes(); - expected1=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]; - self.assertEqual(expected1,list(boundaryNodes)); - pass - def testBoundaryMesh(self): - mesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - mesh2=mesh.buildBoundaryMesh(False); - self.assertEqual(24,mesh2.getNumberOfCells()); - self.assertEqual(26,mesh2.getNumberOfNodes()); - pass - def testBuildPartOfMySelf(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - mesh.setName("Toto"); - tab1=[0,4] - tab2=[0,2,3] - # - subMesh=mesh.buildPartOfMySelf(tab1,True); - self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - name=subMesh.getName(); - self.assertEqual(2,len(mesh.getAllTypes())); - self.assertEqual(NORM_TRI3,mesh.getAllTypes()[0]); - self.assertEqual(NORM_QUAD4,mesh.getAllTypes()[1]); - self.assertEqual(1,len(subMesh.getAllTypes())); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); - self.assertEqual(name,"PartOf_Toto"); - self.assertEqual(2,subMesh.getNumberOfCells()); - subConn=[4,0,3,4,1,4,7,8,5,4]; - subConnIndex=[0,5,10]; - self.assertEqual(10,subMesh.getNodalConnectivity().getNbOfElems()); - self.assertEqual(3,subMesh.getNodalConnectivityIndex().getNbOfElems()); - self.assertEqual(subConn[0:10],list(subMesh.getNodalConnectivity().getValues())); - self.assertEqual(subConnIndex[0:3],list(subMesh.getNodalConnectivityIndex().getValues())); - # - subMesh=mesh.buildPartOfMySelf(tab2[0:3],True); - self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)); - name=subMesh.getName(); - self.assertEqual(2,len(subMesh.getAllTypes())); - self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]); - self.assertEqual(name,"PartOf_Toto"); - self.assertEqual(3,subMesh.getNumberOfCells()); - subConn2=[4,0,3,4,1,3,4,5,2,4,6,7,4,3] - subConnIndex2=[0,5,9,14] - self.assertEqual(14,subMesh.getNodalConnectivity().getNbOfElems()); - self.assertEqual(4,subMesh.getNodalConnectivityIndex().getNbOfElems()); - self.assertEqual(subConn2[0:14],list(subMesh.getNodalConnectivity().getValues())); - self.assertEqual(subConnIndex2[0:4],list(subMesh.getNodalConnectivityIndex().getValues())); - subMesh=subMesh.buildPartOfMySelf(range(3),True); - self.assertEqual("PartOf_Toto",subMesh.getName()); - pass - def testBuildPartOfMySelfNode(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - tab1=[5,7] - subMesh=mesh.buildPartOfMySelfNode(tab1[0:2],True); - self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - self.assertEqual(1,len(subMesh.getAllTypes())); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); - self.assertEqual(1,subMesh.getNumberOfCells()); - self.assertEqual(5,subMesh.getNodalConnectivity().getNbOfElems()); - self.assertEqual(2,subMesh.getNodalConnectivityIndex().getNbOfElems()); - subConn=[4,7,8,5,4] - subConnIndex=[0,5] - self.assertEqual(subConn[0:5],list(subMesh.getNodalConnectivity().getValues())); - self.assertEqual(subConnIndex[0:2],list(subMesh.getNodalConnectivityIndex().getValues())); - # - subMesh=mesh.buildPartOfMySelfNode(tab1[0:2],False); - self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - self.assertEqual(2,len(subMesh.getAllTypes())); - self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]); - self.assertEqual(3,subMesh.getNumberOfCells()); - self.assertEqual(14,subMesh.getNodalConnectivity().getNbOfElems()); - self.assertEqual(4,subMesh.getNodalConnectivityIndex().getNbOfElems()); - subConn2=[3,4,5,2,4,6,7,4,3,4,7,8,5,4] - subConnIndex2=[0,4,9,14] - self.assertEqual(subConn2[0:14],list(subMesh.getNodalConnectivity().getValues())); - self.assertEqual(subConnIndex2[0:4],list(subMesh.getNodalConnectivityIndex().getValues())); - #testing the case where length of tab2 is greater than max number of node per cell. - tab2=[0,3,2,1,4,5,6] - subMesh=mesh.buildPartOfMySelfNode(tab2[0:7],True); - self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - self.assertEqual(2,len(subMesh.getAllTypes())); - self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]); - self.assertEqual(3,subMesh.getNumberOfCells()); - pass - def testZipCoords(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - self.assertEqual(2,len(mesh.getAllTypes())); - self.assertEqual(2,mesh.getSpaceDimension()); - self.assertEqual(9,mesh.getNumberOfNodes()); - self.assertEqual(5,mesh.getNumberOfCells()); - oldConn=mesh.getNodalConnectivity().getValues()[0:mesh.getNodalConnectivity().getNbOfElems()]; - oldConnIndex=mesh.getNodalConnectivityIndex().getValues()[0:mesh.getNumberOfCells()+1] - oldCoords=mesh.getCoords(); - mesh.zipCoords(); - self.assertEqual(2,len(mesh.getAllTypes())); - self.assertEqual(2,mesh.getSpaceDimension()); - self.assertEqual(9,mesh.getNumberOfNodes()); - self.assertEqual(5,mesh.getNumberOfCells()); - self.assertEqual(mesh.getCoords().getValues()[0:2*9],oldCoords.getValues()); - self.assertEqual(list(oldConn),list(mesh.getNodalConnectivity().getValues())); - self.assertEqual(list(oldConnIndex),list(mesh.getNodalConnectivityIndex().getValues())); - # - tab1=[0,4] - subMesh=mesh.buildPartOfMySelf(tab1,True); - self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - traducer=subMesh.zipCoordsTraducer(); - expectedTraducer=[0,1,3,4,5,7,8] - self.assertEqual(expectedTraducer,list(traducer.getValues())); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); - self.assertEqual(2,subMesh.getNumberOfCells()); - subConn=[4,0,2,3,1,4,5,6,4,3] - subConnIndex=[0,5,10] - self.assertEqual(7,subMesh.getNumberOfNodes()); - self.assertEqual(10,subMesh.getNodalConnectivity().getNbOfElems()); - self.assertEqual(3,subMesh.getNodalConnectivityIndex().getNbOfElems()); - self.assertEqual(subConn,list(subMesh.getNodalConnectivity().getValues())); - self.assertEqual(subConnIndex,list(subMesh.getNodalConnectivityIndex().getValues())); - # - subMesh=mesh.buildPartOfMySelf(tab1,False); - self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); - self.assertEqual(2,subMesh.getNumberOfCells()); - self.assertEqual(7,subMesh.getNumberOfNodes()); - self.assertEqual(10,subMesh.getNodalConnectivity().getNbOfElems()); - self.assertEqual(3,subMesh.getNodalConnectivityIndex().getNbOfElems()); - self.assertEqual(subConn,list(subMesh.getNodalConnectivity().getValues())); - self.assertEqual(subConnIndex,list(subMesh.getNodalConnectivityIndex().getValues())); - pass - def testZipConnectivity(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - cells1=[2,3,4] - m3=m2.buildPartOfMySelf(cells1,True); - self.assertTrue(isinstance(m3,MEDCouplingUMesh)) - m4=MEDCouplingDataForTest.build2DSourceMesh_1(); - m5=MEDCouplingUMesh.mergeUMeshes(m1,m3); - m6=MEDCouplingUMesh.mergeUMeshes(m5,m4); - # - self.assertEqual(10,m6.getNumberOfCells()); - self.assertEqual(22,m6.getNumberOfNodes()); - (arr,areNodesMerged,newNbOfNodes)=m6.mergeNodes(1e-13); - self.assertTrue(areNodesMerged); - self.assertEqual(10,m6.getNumberOfCells()); - self.assertEqual(9,m6.getNumberOfNodes()); - # - arr=m6.zipConnectivityTraducer(0); - self.assertEqual(7,m6.getNumberOfCells()); - m7=m6.clone(True); - arr=m6.zipConnectivityTraducer(0); - self.assertTrue(m7.isEqual(m6,1e-12)); - self.assertEqual(7,m6.getNumberOfCells()); - pass - def testEqualMesh(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - mesh2=MEDCouplingDataForTest.build2DTargetMesh_1(); - # - self.assertTrue(mesh1.isEqual(mesh1,1e-12)); - # - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh2.isEqual(mesh1,1e-12)); - pt=mesh2.getCoords().getValues(); - tmp=pt[1] - mesh2.getCoords().setIJ(0,1,5.999); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(not mesh2.isEqual(mesh1,1e-12)); - mesh2.getCoords().setIJ(0,1,tmp); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh2.isEqual(mesh1,1e-12)); - # - pt2=mesh1.getNodalConnectivity().getValues(); - mesh1.getNodalConnectivity().setIJ(5,0,int(pt2[5])+1); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(not mesh2.isEqual(mesh1,1e-12)); - mesh1.getNodalConnectivity().setIJ(5,0,int(pt2[5])); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh2.isEqual(mesh1,1e-12)); - # - pt2=mesh1.getNodalConnectivityIndex().getValues(); - mesh1.getNodalConnectivityIndex().setIJ(1,0,int(pt2[1]+1)); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(not mesh2.isEqual(mesh1,1e-12)); - mesh1.getNodalConnectivityIndex().setIJ(1,0,int(pt2[1])); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh2.isEqual(mesh1,1e-12)); - # - tmp3=mesh1.getName(); - mesh1.setName("lllll"); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(not mesh2.isEqual(mesh1,1e-12)); - mesh1.setName(tmp3); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh2.isEqual(mesh1,1e-12)); - # - tmp3=mesh2.getCoords().getInfoOnComponent(1); - mesh2.getCoords().setInfoOnComponent(1,"kkkkkk"); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(not mesh2.isEqual(mesh1,1e-12)); - mesh2.getCoords().setInfoOnComponent(1,tmp3); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh2.isEqual(mesh1,1e-12)); - pass - def testEqualFieldDouble(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - mesh2=MEDCouplingDataForTest.build2DTargetMesh_1(); - # - fieldOnCells1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - fieldOnCells1.setMesh(mesh1); - fieldOnCells2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - fieldOnCells2.setMesh(mesh2); - # - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - # - fieldOnNodes1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnNodes1,1e-12,1e-15)); - self.assertTrue(not fieldOnNodes1.isEqual(fieldOnCells1,1e-12,1e-15)); - # - fieldOnCells2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells1.setTime(4.,6,7); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2.setTime(4.,6,7); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells1.setName("Power"); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2.setName("Power"); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - # - fieldOnCells1.setMesh(mesh1); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2.setMesh(mesh1); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - arr=DataArrayDouble.New(); - arr.setName("popo"); - arr.setValues(mesh1.getNumberOfCells()*3*[6.],mesh1.getNumberOfCells(),3); - fieldOnCells1.setArray(arr); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - fieldOnCells2.setArray(arr); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - # - arr2=arr.deepCopy(); - fieldOnCells2.setArray(arr2); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - arr.setIJ(1,2,6.1); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - arr.setIJ(1,2,6.); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - arr2.setName("popo2"); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - # - arr2.setName("popo"); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - # - arr2.setInfoOnComponent(2,"jjj"); - self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - arr.setInfoOnComponent(2,"jjj"); - self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); - self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); - pass - - def testNatureChecking(self): - field=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - field.setNature(Integral); - field.setNature(ConservativeVolumic); - field.setNature(IntegralGlobConstraint); - field=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); - field.setNature(ConservativeVolumic); - self.assertRaises(Exception,field.setNature,Integral); - self.assertRaises(Exception,field.setNature,IntegralGlobConstraint); - pass - - def testBuildSubMeshData(self): - targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1() - #check buildSubMesh on field on cells - fieldCells=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - fieldCells.setMesh(targetMesh); - elts=[1,2,4] - ret1,di=fieldCells.buildSubMeshData(elts); - self.assertTrue(isinstance(ret1,MEDCouplingUMesh)) - self.assertEqual(3,ret1.getNumberOfCells()); - self.assertEqual(6,ret1.getNumberOfNodes()); - self.assertEqual(3,di.getNumberOfTuples()); - self.assertEqual(1,di.getNumberOfComponents()); - toCheck=di.getValues(); - self.assertTrue(elts,toCheck); - #check buildSubMesh on field on nodes - fieldNodes=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); - fieldNodes.setMesh(targetMesh); - ret2,di=fieldNodes.buildSubMeshData(elts); - self.assertTrue(isinstance(ret2,MEDCouplingUMesh)) - self.assertEqual(3,ret2.getNumberOfCells()); - self.assertEqual(6,ret2.getNumberOfNodes()); - self.assertEqual(6,di.getNumberOfTuples()); - self.assertEqual(1,di.getNumberOfComponents()); - toCheck=di.getValues(); - expected=[1,2,4,5,7,8] - self.assertEqual(expected,list(toCheck)); - pass - def testExtrudedMesh1(self): - mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1(); - ext=MEDCouplingExtrudedMesh.New(mesh3D,mesh2D,1); - self.assertEqual(18,ext.getNumberOfCells()); - self.assertEqual(60,ext.getNumberOfNodes()); - ids3D=ext.getMesh3DIds(); - ids3DExpected=[5,4,3,2,1,0, 11,10,9,8,7,6, 17,16,15,14,13,12] - self.assertEqual(18,ids3D.getNumberOfTuples()); - self.assertEqual(1,ids3D.getNumberOfComponents()); - self.assertEqual(ids3DExpected,list(ids3D.getValues())); - mesh1D=ext.getMesh1D(); - self.assertEqual(4,mesh1D.getNumberOfNodes()); - self.assertEqual(3,mesh1D.getNumberOfCells()); - mesh1DExpected=[0.66666666666666663, 1.4583333333333333, 0, 0.66666666666666663, - 1.4583333333333333, 1, 0.66666666666666663, 1.4583333333333333, - 2, 0.66666666666666663, 1.4583333333333333, 3] - mesh1DCoords=mesh1D.getCoords(); - self.assertEqual(4,mesh1DCoords.getNumberOfTuples()); - self.assertEqual(3,mesh1DCoords.getNumberOfComponents()); - self.assertEqual(mesh1DExpected,mesh1DCoords.getValues()); - conn1D=mesh1D.getNodalConnectivity(); - self.assertEqual(9,conn1D.getNumberOfTuples()); - self.assertEqual(1,conn1D.getNumberOfComponents()); - conn1DExpected=[1,0,1,1,1,2,1,2,3] - self.assertEqual(conn1DExpected,list(conn1D.getValues())); - pass - - def testExtrudedMesh3(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m1.changeSpaceDimension(3); - m2=MEDCouplingDataForTest.buildCU1DMesh_U(); - m2.changeSpaceDimension(3); - center=[0.,0.,0.] - vector=[0.,1.,0.] - m2.rotate(center,vector,-pi/2.); - m3=m1.buildExtrudedMeshFromThis(m2,0); - # - m4=MEDCouplingExtrudedMesh.New(m3,m1,0); - self.assertEqual(15,m4.getNumberOfCells()); - self.assertEqual(5,m4.getMesh2D().getNumberOfCells()); - self.assertEqual(3,m4.getMesh1D().getNumberOfCells()); - m3DIds=m4.getMesh3DIds().getValues(); - self.assertEqual(range(15),list(m3DIds)); - #some random in cells to check that extrusion alg find it correctly - expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4] - m3.renumberCells(expected1,False); - m4=MEDCouplingExtrudedMesh.New(m3,m1,0); - self.assertEqual(15,m4.getNumberOfCells()); - self.assertEqual(5,m4.getMesh2D().getNumberOfCells()); - self.assertEqual(3,m4.getMesh1D().getNumberOfCells()); - m3DIds=m4.getMesh3DIds().getValues(); - self.assertEqual(expected1,list(m3DIds)); - #play with polygons and polyedrons - cells=[2,3] - m1.convertToPolyTypes(cells); - m3=m1.buildExtrudedMeshFromThis(m2,0); - self.assertEqual(NORM_HEXA8,m3.getTypeOfCell(0)); - self.assertEqual(NORM_PENTA6,m3.getTypeOfCell(1)); - self.assertEqual(NORM_POLYHED,m3.getTypeOfCell(2)); - self.assertEqual(NORM_POLYHED,m3.getTypeOfCell(3)); - self.assertEqual(NORM_HEXA8,m3.getTypeOfCell(4)); - m3.renumberCells(expected1,False); - m4=MEDCouplingExtrudedMesh.New(m3,m1,0); - self.assertEqual(15,m4.getNumberOfCells()); - self.assertEqual(5,m4.getMesh2D().getNumberOfCells()); - self.assertEqual(3,m4.getMesh1D().getNumberOfCells()); - m3DIds=m4.getMesh3DIds().getValues(); - self.assertEqual(expected1,list(m3DIds)); - pass - - def testExtrudedMesh4(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - cells=[2,4]; - m1.convertToPolyTypes(cells); - m1.changeSpaceDimension(3); - m2=MEDCouplingDataForTest.buildCU1DMesh_U(); - m2.changeSpaceDimension(3); - center=[0.,0.,0.] - vector=[0.,1.,0.] - m2.rotate(center,vector,-pi/2.); - m3=m1.buildExtrudedMeshFromThis(m2,0); - expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4] - rexpected1=[3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12] - m3.renumberCells(expected1,False); - m4=MEDCouplingExtrudedMesh.New(m3,m1,0); - self.assertEqual(NORM_HEXA8,m4.getTypeOfCell(0)); - self.assertEqual(NORM_HEXA8,m4.getTypeOfCell(1)); - self.assertEqual(NORM_POLYHED,m4.getTypeOfCell(2)); - self.assertEqual(NORM_PENTA6,m4.getTypeOfCell(7)); - f=m4.getMeasureField(True); - arr=f.getArray(); - self.assertEqual(15,arr.getNumberOfTuples()); - self.assertEqual(1,arr.getNumberOfComponents()); - arrPtr=arr.getValues(); - expected2=[0.075,0.0375,0.0375,0.075,0.075, - 0.1125,0.05625,0.05625,0.1125,0.1125, - 0.0625,0.03125,0.03125,0.0625,0.0625] - for i in xrange(15): - self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],16); - pass - m5=m4.build3DUnstructuredMesh(); - self.assertTrue(m5.isEqual(m3,1e-12)); - f=m5.getMeasureField(True); - arr=f.getArray(); - arrPtr=arr.getValues(); - for i in xrange(15): - self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],15); - pass - pass - - def testFindCommonNodes(self): - targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - comm,commI=targetMesh.findCommonNodes(-1,1e-10); - self.assertEqual(1,commI.getNumberOfTuples()); - self.assertEqual(0,comm.getNumberOfTuples()); - o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI); - self.assertEqual(27,newNbOfNodes); - self.assertEqual(27,o2n.getNumberOfTuples()); - o2nExp1=range(27) - self.assertEqual(o2nExp1,list(o2n.getValues())); - # - targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); - self.assertEqual(31,targetMesh.getNumberOfNodes()); - comm,commI=targetMesh.findCommonNodes(-1,1e-10); - self.assertEqual(3,commI.getNumberOfTuples()); - self.assertEqual(6,comm.getNumberOfTuples()); - commExpected=[1,27,28,29,23,30] - commIExpected=[0,4,6] - self.assertEqual(commExpected,list(comm.getValues())); - self.assertEqual(commIExpected,list(commI.getValues())); - o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI); - self.assertEqual(31,o2n.getNumberOfTuples()); - self.assertEqual(27,newNbOfNodes); - o2nExp2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,26,1,1,1,23] - self.assertEqual(o2nExp2,list(o2n.getValues())); - # - targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - time=targetMesh.getTimeOfThis(); - o2n,areNodesMerged,newNbOfNodes=targetMesh.mergeNodes(1e-10); - targetMesh.updateTime(); - self.assertEqual(time,targetMesh.getTimeOfThis()); - self.assertTrue(not areNodesMerged); - # - targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); - time=targetMesh.getTimeOfThis(); - o2n,areNodesMerged,newNbOfNodes=targetMesh.mergeNodes(1e-10); - targetMesh.updateTime(); - self.assertTrue(time!=targetMesh.getTimeOfThis()); - self.assertTrue(areNodesMerged); - connExp=[18,0,1,4,3,9,10,13,12, 18,1,2,5,4,10,11,14,13, 18,3,4,7,6,12,13,16,15, - 18,4,5,8,7,13,14,17,16, - 18,9,10,13,12,18,19,22,21, 18,10,11,14,13,19,20,23,22, 18,12,13,16,15,21,22,25,24, - 18,13,14,17,16,22,23,26,25] - self.assertEqual(72,targetMesh.getNodalConnectivity().getNumberOfTuples()); - self.assertEqual(connExp,list(targetMesh.getNodalConnectivity().getValues())); - self.assertEqual(27,targetMesh.getCoords().getNumberOfTuples()); - coordsExp=[ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , - 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., - 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , - 200., 200., 50. , 0., 0., 200., 50., 0., 200. , 200., 0., 200. - , 0., 50., 200., 50., 50., 200. , 200., 50., 200., - 0., 200., 200., 50., 200., 200. , 200., 200., 200. ] - self.assertEqual(coordsExp,targetMesh.getCoords().getValues()); - # 2D - targetMesh=MEDCouplingDataForTest.build2DTargetMeshMergeNode_1(); - self.assertEqual(18,targetMesh.getNumberOfNodes()); - time=targetMesh.getTimeOfThis(); - o2n,areNodesMerged,newNbOfNodes=targetMesh.mergeNodes(1e-10); - self.assertTrue(time!=targetMesh.getTimeOfThis()); - self.assertTrue(areNodesMerged); - self.assertEqual(9,targetMesh.getNumberOfNodes()); - connExp2=[4,0,4,3,1, 3,1,3,2, 3,3,5,2, 4,4,6,7,3, 4,7,8,5,3] - self.assertEqual(23,targetMesh.getNodalConnectivity().getNumberOfTuples()); - self.assertEqual(connExp2,list(targetMesh.getNodalConnectivity().getValues())); - coordsExp2=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, 0.2,0.2, -0.3,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7] - self.assertEqual(9,targetMesh.getCoords().getNumberOfTuples()); - self.assertEqual(coordsExp2,targetMesh.getCoords().getValues()); - pass - - def testCheckButterflyCells(self): - sourceMesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - cells=sourceMesh.checkButterflyCells(); - self.assertEqual(0,len(cells)); - conn=sourceMesh.getNodalConnectivity() - tmp=conn.getIJ(15,0) - conn.setIJ(15,0,conn.getIJ(16,0)) - conn.setIJ(16,0,tmp) - cells=sourceMesh.checkButterflyCells(); - self.assertEqual(1,len(cells)); - self.assertEqual(3,cells[0]); - tmp=conn.getIJ(15,0) - conn.setIJ(15,0,conn.getIJ(16,0)) - conn.setIJ(16,0,tmp) - cells=sourceMesh.checkButterflyCells(); - self.assertEqual(0,len(cells)); - # 3D surf - sourceMesh=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - cells=sourceMesh.checkButterflyCells(); - self.assertEqual(0,len(cells)); - conn=sourceMesh.getNodalConnectivity() - tmp=conn.getIJ(15,0) - conn.setIJ(15,0,conn.getIJ(16,0)) - conn.setIJ(16,0,tmp) - cells=sourceMesh.checkButterflyCells(); - self.assertEqual(1,len(cells)); - self.assertEqual(3,cells[0]); - tmp=conn.getIJ(15,0) - conn.setIJ(15,0,conn.getIJ(16,0)) - conn.setIJ(16,0,tmp) - cells=sourceMesh.checkButterflyCells(); - self.assertEqual(0,len(cells)); - pass - - def testMergeMesh1(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DSourceMesh_1(); - vec=[1.,0.] - m2.translate(vec); - m3=m1.mergeMyselfWith(m2); - self.assertTrue(isinstance(m3,MEDCouplingUMesh)); - m3.checkCoherency(); - m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1(); - self.assertTrue(m3.isEqual(m4,1.e-12)); - da,isMerged,newNbOfNodes=m3.mergeNodes(1.e-12); - self.assertEqual(11,m3.getNumberOfNodes()); - self.assertTrue(isMerged); - pass - - def testMergeMeshOnSameCoords1(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - cells=range(5); - m2.convertToPolyTypes(cells); - m1.tryToShareSameCoords(m2,1e-12); - m3=MEDCouplingDataForTest.build2DTargetMesh_1(); - m3.tryToShareSameCoords(m2,1e-12); - meshes=[m1,m2,m3] - m4=MEDCouplingUMesh.mergeUMeshesOnSameCoords(meshes); - m4.checkCoherency(); - self.assertEqual(15,m4.getNumberOfCells()); - cells1=[0,1,2,3,4] - m1_1=m4.buildPartOfMySelf(cells1,True); - m1_1.setName(m1.getName()); - self.assertTrue(m1.isEqual(m1_1,1e-12)); - cells2=[5,6,7,8,9] - m2_1=m4.buildPartOfMySelf(cells2,True); - m2_1.setName(m2.getName()); - self.assertTrue(m2.isEqual(m2_1,1e-12)); - cells3=[10,11,12,13,14] - m3_1=m4.buildPartOfMySelf(cells3,True); - m3_1.setName(m3.getName()); - self.assertTrue(m3.isEqual(m3_1,1e-12)); - pass - - def testMergeField1(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DSourceMesh_1(); - vec=[1.,0.] - m2.translate(vec); - f1=m1.getMeasureField(True); - f2=m2.getMeasureField(True); - f3=MEDCouplingFieldDouble.mergeFields(f1,f2); - f3.checkCoherency(); - m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1(); - self.assertTrue(f3.getMesh().isEqual(m4,1.e-12)); - name=f3.getName(); - self.assertEqual(name,"MeasureOfMesh_"); - self.assertEqual(f3.getTypeOfField(),ON_CELLS); - self.assertEqual(f3.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f3.getNumberOfComponents()); - self.assertEqual(7,f3.getNumberOfTuples()); - values=[0.25,0.125,0.125,0.25,0.25,0.5,0.5] - tmp=f3.getArray().getValues(); - self.assertEqual(len(values),len(tmp)) - for i in xrange(7): - self.assertTrue(abs(values[i]-tmp[i])<1e-12) - pass - pass - - def testFillFromAnalytic(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=m.fillFromAnalytic(ON_CELLS,1,"x+y"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_CELLS); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(5,f1.getNumberOfTuples()); - values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9] - tmp=f1.getArray().getValues(); - self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) - pass - # - f1=m.fillFromAnalytic(ON_NODES,1,"x+y"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - values2=[-0.6,-0.1,0.4,-0.1,0.4,0.9,0.4,0.9,1.4] - tmp=f1.getArray().getValues(); - self.assertEqual(len(values2),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values2[i])<1.e-12) - pass - # - f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+(2*(x+y))*JVec"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(2,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8] - tmp=f1.getArray().getValues(); - self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values3[i])<1.e-12) - pass - values4=f1.accumulate(); - self.assertTrue(abs(3.6-values4[0])<1.e-12); - self.assertTrue(abs(7.2-values4[1])<1.e-12); - values4=f1.integral(True); - self.assertTrue(abs(0.5-values4[0])<1.e-12); - self.assertTrue(abs(1.-values4[1])<1.e-12); - # - self.assertRaises(Exception,m.fillFromAnalytic,ON_NODES,1,"1./(x-0.2)"); - pass - - def testFillFromAnalytic2(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=m.fillFromAnalytic(ON_CELLS,1,"y+x"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_CELLS); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(5,f1.getNumberOfTuples()); - values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9] - tmp=f1.getArray().getValues(); - self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(values1)): - self.assertTrue(abs(values1[i]-tmp[i])<1.e-12); - pass - # - f1=m.fillFromAnalytic(ON_NODES,1,"y+2*x"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - values2=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1] - tmp=f1.getArray().getValues(); - self.assertEqual(len(values2),len(tmp)) - for i in xrange(len(values2)): - self.assertTrue(abs(values2[i]-tmp[i])<1.e-12); - pass - f1=m.fillFromAnalytic(ON_NODES,1,"2.*x+y"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - tmp=f1.getArray().getValues(); - values2Bis=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1] - self.assertEqual(len(values2Bis),len(tmp)) - for i in xrange(len(values2Bis)): - self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12); - pass - # - f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+2*(x+y)*JVec"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(2,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8] - tmp=f1.getArray().getValues(); - self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(values3)): - self.assertTrue(abs(values3[i]-tmp[i])<1.e-12); - pass - values4=f1.accumulate(); - self.assertTrue(abs(3.6-values4[0])<1.e-12); - self.assertTrue(abs(7.2-values4[1])<1.e-12); - values4=f1.integral(True); - self.assertTrue(abs(0.5-values4[0])<1.e-12); - self.assertTrue(abs(1.-values4[1])<1.e-12); - pass - - def testApplyFunc(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+(2*(x+y))*JVec"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(2,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - f1.applyFunc(1,"x+y"); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2] - tmp=f1.getArray().getValues(); - self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) - pass - pass - - def testApplyFunc2(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+2*(x+y)*JVec"); - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(2,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - # - f2=f1.clone(True); - f2.applyFunc("abs(u)^2.4+2*u"); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(2,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - values2=[-0.9065304805418678, -0.85105859001709905, -0.19601892829446504, -0.37898777756476987, - 0.91090317490482353, 2.1853504664669781, -0.19601892829446504, -0.37898777756476987, - 0.91090317490482353, 2.1853504664669781, 2.5765725275664879, 7.6987743736515295, - 0.91090317490482353, 2.1853504664669781, 2.5765725275664879, 7.6987743736515295, - 5.0423700574830965, 17.435300118916864] - tmp=f2.getArray().getValues(); - self.assertEqual(len(tmp),len(values2)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values2[i])<1.e-12) - pass - # - f1.applyFunc(1,"x+y"); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2] - tmp=f1.getArray().getValues(); - self.assertEqual(len(tmp),len(values1)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) - pass - pass - - def testOperationsOnFields(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=m.fillFromAnalytic(ON_NODES,1,"x+y"); - f2=m.fillFromAnalytic(ON_NODES,1,"x+y"); - f1.checkCoherency(); - f2.checkCoherency(); - f3=f1+f2; - f3.checkCoherency(); - self.assertEqual(f3.getTypeOfField(),ON_NODES); - self.assertEqual(f3.getTimeDiscretization(),NO_TIME); - values1=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8] - tmp=f3.getArray().getValues(); - self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) - pass - # - f3=f1*f2; - f3.checkCoherency(); - self.assertEqual(f3.getTypeOfField(),ON_NODES); - self.assertEqual(f3.getTimeDiscretization(),NO_TIME); - values2=[0.36,0.01,0.16,0.01,0.16,0.81,0.16,0.81,1.96] - tmp=f3.getArray().getValues(); - self.assertEqual(len(values2),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values2[i])<1.e-12) - pass - # - f3=f1+f2; - f4=f1-f3; - f4.checkCoherency(); - self.assertEqual(f4.getTypeOfField(),ON_NODES); - self.assertEqual(f4.getTimeDiscretization(),NO_TIME); - values3=[0.6,0.1,-0.4,0.1,-0.4,-0.9,-0.4,-0.9,-1.4] - tmp=f4.getArray().getValues(); - self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values3[i])<1.e-12) - pass - # - f3=f1+f2; - f4=f3/f2; - f4.checkCoherency(); - self.assertEqual(f4.getTypeOfField(),ON_NODES); - self.assertEqual(f4.getTimeDiscretization(),NO_TIME); - tmp=f4.getArray().getValues(); - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-2.)<1.e-12) - pass - # - f4=f2.buildNewTimeReprFromThis(ONE_TIME,False); - f4.checkCoherency(); - self.assertEqual(f4.getTypeOfField(),ON_NODES); - self.assertEqual(f4.getTimeDiscretization(),ONE_TIME); - self.assertRaises(Exception,f1.__add__,f4); - f5=f4.buildNewTimeReprFromThis(NO_TIME,False); - self.assertEqual(f5.getTypeOfField(),ON_NODES); - self.assertEqual(f5.getTimeDiscretization(),NO_TIME); - f3=f1+f5; - tmp=f3.getArray().getValues(); - values4=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8] - self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values4[i])<1.e-12) - pass - # - f4=f2.buildNewTimeReprFromThis(ONE_TIME,True); - f4.checkCoherency(); - self.assertEqual(f4.getTypeOfField(),ON_NODES); - self.assertEqual(f4.getTimeDiscretization(),ONE_TIME); - self.assertRaises(Exception,f1.__add__,f4); - f5=f4.buildNewTimeReprFromThis(NO_TIME,True); - self.assertEqual(f5.getTypeOfField(),ON_NODES); - self.assertEqual(f5.getTimeDiscretization(),NO_TIME); - f3=f1+f5; - tmp=f3.getArray().getValues(); - values5=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8] - self.assertEqual(len(values5),len(tmp)) - for i in xrange(len(tmp)): - self.assertTrue(abs(tmp[i]-values5[i])<1.e-12) - pass - pass - - def testOperationsOnFields2(self): - m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - f1=m.fillFromAnalytic(ON_NODES,1,"x+y+z"); - f2=m.fillFromAnalytic(ON_NODES,1,"a*a+b+c*c"); - f3=f1/f2; - f3.checkCoherency(); - self.assertEqual(f3.getTypeOfField(),ON_NODES); - self.assertEqual(f3.getTimeDiscretization(),NO_TIME); - expected1=[-2.4999999999999991, 1.2162162162162162, 0.77868852459016391, - 0.7407407407407407, 1.129032258064516, 0.81632653061224492, - 0.86538461538461531, 1.0919540229885056, 0.84302325581395343] - self.assertEqual(1,f3.getNumberOfComponents()); - self.assertEqual(9,f3.getNumberOfTuples()); - val=f3.getArray().getValues(); - for i in xrange(9): - self.assertTrue(abs(expected1[i]-val[i])<1.e-12); - # - f1=m.buildOrthogonalField(); - f2=m.fillFromAnalytic(ON_CELLS,1,"x"); - f3=f1*f2; - expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637] - val=f3.getArray().getValues(); - for i in xrange(15): - self.assertTrue(abs(expected2[i]-val[i])<1.e-12); - pass - # - f3=f2*f1; - val=f3.getArray().getValues(); - for i in xrange(15): - self.assertTrue(abs(expected2[i]-val[i])<1.e-12); - pass - pass - - def testOperationsOnFields3(self): - m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - f1=m.fillFromAnalytic(ON_NODES,1,"x+y+z"); - f2=m.fillFromAnalytic(ON_NODES,1,"a*a+b+c*c"); - f1/=f2 - f1.checkCoherency(); - self.assertEqual(f1.getTypeOfField(),ON_NODES); - self.assertEqual(f1.getTimeDiscretization(),NO_TIME); - expected1=[-2.4999999999999991, 1.2162162162162162, 0.77868852459016391, - 0.7407407407407407, 1.129032258064516, 0.81632653061224492, - 0.86538461538461531, 1.0919540229885056, 0.84302325581395343] - self.assertEqual(1,f1.getNumberOfComponents()); - self.assertEqual(9,f1.getNumberOfTuples()); - val=f1.getArray().getValues(); - for i in xrange(9): - self.assertTrue(abs(expected1[i]-val[i])<1.e-12); - pass - # - f1=m.buildOrthogonalField(); - f2=m.fillFromAnalytic(ON_CELLS,1,"x"); - f1*=f2 - expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637] - val=f1.getArray().getValues(); - for i in xrange(15): - self.assertTrue(abs(expected2[i]-val[i])<1.e-12); - pass - # - f1=m.buildOrthogonalField(); - # to avoid valgrind leaks - # self.assertRaises(Exception,f2.__imul__,f1); - pass - - def testOperationsOnFields4(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - nbOfCells=m.getNumberOfCells(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); - f1.setMesh(m); - array=DataArrayDouble.New(); - f1.setArray(array); - self.assertRaises(Exception,f1.setEndArray,array); - self.assertRaises(Exception,f1.getEndArray); - arr1=[0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.] - arr2=[5.,15.,25.,6.,16.,26.,7.,17.,27.,8.,18.,28.,9.,19.,29.] - array.setValues(arr1,nbOfCells,3); - f1.setStartTime(2.,0,0); - f1.setEndTime(3.,0,0); - f1.checkCoherency(); - pos=[0.3,-0.2] - res=f1.getValueOn(pos); - self.assertTrue(abs(arr1[3]-res[0])<1.e-12); - self.assertTrue(abs(arr1[4]-res[1])<1.e-12); - self.assertTrue(abs(arr1[5]-res[2])<1.e-12); - res=None - res=f1.getValueOn(pos,2.2); - self.assertTrue(abs(arr1[3]-res[0])<1.e-12); - self.assertTrue(abs(arr1[4]-res[1])<1.e-12); - self.assertTrue(abs(arr1[5]-res[2])<1.e-12); - res=None - self.assertRaises(Exception,f1.getValueOn,pos,3.2) - f2=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); - f2.setMesh(m); - f2.setArray(f1.getArray()); - f2.setStartTime(2.,3,0); - f2.setEndTime(4.,13,0); - self.assertRaises(Exception,f2.checkCoherency) - array2=DataArrayDouble.New(); - array2.setValues(arr2,nbOfCells,3); - f2.setEndArray(array2); - f2.checkCoherency(); - # - res=None - res=f2.getValueOn(pos,3.21); - self.assertTrue(abs(4.025-res[0])<1.e-12); - self.assertTrue(abs(14.025-res[1])<1.e-12); - self.assertTrue(abs(24.025-res[2])<1.e-12); - f3=f2.clone(True); - self.assertTrue(f2.isEqual(f3,1e-12,1e-12)); - f3.getEndArray().setIJ(0,0,5.001); - self.assertTrue(not f2.isEqual(f3,1e-12,1e-12)); - self.assertTrue(f2.isEqual(f3,1e-12,1e-2)); - f3.setStartTime(2.1,3,0); - self.assertTrue(not f2.isEqual(f3,1e-12,1e-2)); - f3.setStartTime(2.,3,0); - self.assertTrue(f2.isEqual(f3,1e-12,1e-2)); - f3.setStartTime(2.,4,0); - self.assertTrue(not f2.isEqual(f3,1e-12,1e-2)); - f3.setStartTime(2.,3,1); - self.assertTrue(not f2.isEqual(f3,1e-12,1e-2)); - f3.setStartTime(2.,3,0); - self.assertTrue(f2.isEqual(f3,1e-12,1e-2)); - f3.setEndTime(4.1,13,0); - self.assertTrue(not f2.isEqual(f3,1e-12,1e-2)); - f3.setEndTime(4.,13,0); - self.assertTrue(f2.isEqual(f3,1e-12,1e-2)); - f3.setEndTime(4.,14,0); - self.assertTrue(not f2.isEqual(f3,1e-12,1e-2)); - f3.setEndTime(4.,13,1); - self.assertTrue(not f2.isEqual(f3,1e-12,1e-2)); - f3.setEndTime(4.,13,0); - self.assertTrue(f2.isEqual(f3,1e-12,1e-2)); - f4=f2+f2 - res=None - res=f4.getValueOn(pos,3.21); - self.assertTrue(abs(8.05-res[0])<1.e-12); - self.assertTrue(abs(28.05-res[1])<1.e-12); - self.assertTrue(abs(48.05-res[2])<1.e-12); - f4+=f2; - res=None - res=f4.getValueOn(pos,3.21); - self.assertTrue(abs(12.075-res[0])<1.e-12); - self.assertTrue(abs(42.075-res[1])<1.e-12); - self.assertTrue(abs(72.075-res[2])<1.e-12); - pass - - def testMergeNodesOnField(self): - targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); - f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z"); - f1.mergeNodes(1e-10); - # - targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); - f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z"); - tmp=f1.getArray() - tmp.setIJ(0,0,1000.); - f1.mergeNodes(1e-10); - # - targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); - f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z"); - tmp=f1.getArray() - tmp.setIJ(1,0,1000.); - self.assertRaises(Exception,f1.mergeNodes,1.e-10) - pass - - def testCheckConsecutiveCellTypes(self): - sourceMesh=MEDCouplingDataForTest.build2DSourceMesh_1(); - targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - self.assertTrue(sourceMesh.checkConsecutiveCellTypes()); - order1=[NORM_TRI3,NORM_QUAD4] - order2=[NORM_QUAD4,NORM_TRI3] - self.assertTrue(not targetMesh.checkConsecutiveCellTypes()); - self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order1)); - self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order2)); - da=targetMesh.getRenumArrForConsecutiveCellTypesSpec(order1); - self.assertEqual(5,da.getNumberOfTuples()); - self.assertEqual(1,da.getNumberOfComponents()); - expected1=[2,0,1,3,4] - self.assertTrue(expected1==list(da.getValues())); - da=targetMesh.getRenumArrForConsecutiveCellTypesSpec(order2); - self.assertEqual(5,da.getNumberOfTuples()); - self.assertEqual(1,da.getNumberOfComponents()); - expected2=[0,3,4,1,2] - self.assertTrue(expected2==list(da.getValues())); - renumber1=[4,0,1,2,3] - targetMesh.renumberCells(renumber1,False); - self.assertTrue(targetMesh.checkConsecutiveCellTypes()); - self.assertTrue(targetMesh.checkConsecutiveCellTypesAndOrder(order1)); - self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order2)); - pass - - def testRearrange2ConsecutiveCellTypes(self): - m1_1=MEDCouplingDataForTest.build2DSourceMesh_1(); - m2_1=MEDCouplingDataForTest.build2DTargetMesh_1(); - arr1=m1_1.rearrange2ConsecutiveCellTypes(); - m1_2=MEDCouplingDataForTest.build2DSourceMesh_1(); - self.assertTrue(m1_2.isEqual(m1_1,1e-12)); - expected1=[0,1] - self.assertEqual(2,arr1.getNumberOfTuples()); - self.assertEqual(1,arr1.getNumberOfComponents()); - self.assertTrue(expected1,arr1.getValues()); - expected2=[0,3,4,1,2] - arr1=m2_1.rearrange2ConsecutiveCellTypes(); - self.assertEqual(5,arr1.getNumberOfTuples()); - self.assertEqual(1,arr1.getNumberOfComponents()); - self.assertEqual(expected2,list(arr1.getValues())); - m2_2=MEDCouplingDataForTest.build2DTargetMesh_1(); - self.assertEqual(5,arr1.getNumberOfTuples()); - self.assertEqual(1,arr1.getNumberOfComponents()); - self.assertEqual(expected2,list(arr1.getValues())); - self.assertTrue(not m2_2.isEqual(m2_1,1e-12)); - m2_2.renumberCells(expected2,False); - self.assertTrue(m2_2.isEqual(m2_1,1e-12)); - pass - - def testSplitByType(self): - m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - v=m1.splitByType(); - self.assertEqual(3,len(v)); - m2=MEDCouplingUMesh.mergeUMeshesOnSameCoords(v); - m2.setName(m1.getName()); - self.assertTrue(m1.isEqual(m2,1.e-12)); - pass - - def testFuseUMeshesOnSameCoords(self): - m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - cells1=[2,3,4] - m3=m2.buildPartOfMySelf(cells1,True); - self.assertTrue(isinstance(m3,MEDCouplingUMesh)) - cells2=[1,2,4] - m4=m2.buildPartOfMySelf(cells2,True); - self.assertTrue(isinstance(m4,MEDCouplingUMesh)) - cells3=[1,2] - m5=m2.buildPartOfMySelf(cells3,True); - self.assertTrue(isinstance(m5,MEDCouplingUMesh)) - meshes=[m3,m4,m5] - # - m7,corr=MEDCouplingUMesh.fuseUMeshesOnSameCoords(meshes,0); - self.assertEqual(4,m7.getNumberOfCells()); - self.assertEqual(3,len(corr)); - expectedVals1=[3,3,2] - expectedVals2=[[0,1,2],[3,0,2],[3,0]] - for i in xrange(3): - arr=corr[i]; - self.assertEqual(1,arr.getNumberOfComponents()); - nbOfVals=expectedVals1[i]; - self.assertEqual(nbOfVals,arr.getNumberOfTuples()); - vals=arr.getValues(); - self.assertEqual(expectedVals2[i],list(vals)); - pass - arr2,fidsOfGroups=DataArrayInt.makePartition(corr,m7.getNumberOfCells()); - fidExp=[5,1,3,4] - fidsGrp=[[1,3,5],[3,4,5],[4,5]] - self.assertEqual(3,len(fidsOfGroups)); - self.assertEqual(1,arr2.getNumberOfComponents()); - self.assertEqual(4,arr2.getNumberOfTuples()); - self.assertEqual(fidExp,list(arr2.getValues())); - for i in xrange(3): - nbOfVals=expectedVals1[i]; - self.assertEqual(list(fidsOfGroups[i]),fidsGrp[i]); - pass - pass - - def testFuseUMeshesOnSameCoords2(self): - m1,m2=MEDCouplingDataForTest.build3DExtrudedUMesh_1(); - part1=[2,3,6,4,10] - m3=m1.buildPartOfMySelf(part1,True); - part2=[5,6,4,7] - m4=m1.buildPartOfMySelf(part2,True); - meshes=[m1,m3,m3,m4] - m5,corr=MEDCouplingUMesh.fuseUMeshesOnSameCoords(meshes,0); - self.assertEqual(18,m5.getNumberOfCells()); - exp2=[ - [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17], - [2,3,6,4,10], - [2,3,6,4,10], - [5,6,4,7]] - i=0; - for it in corr: - self.assertEqual(exp2[i],list(it.getValues())); - i+=1 - pass - pass - - def testBuildOrthogonalField(self): - targetMesh=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - field=targetMesh.buildOrthogonalField(); - expected=[0.70710678118654746,0.,-0.70710678118654746] - self.assertEqual(5,field.getNumberOfTuples()); - self.assertEqual(3,field.getNumberOfComponents()); - vals=field.getArray().getValues(); - for i in xrange(15): - self.assertTrue(abs(expected[i%3]-vals[i])<1e-12); - # testing - targetCoords=[0.,0.,0.,0.5,0.,0.5,1.,0.,1.,0.,1.,0.] - targetConn=[0,1,2,3] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(1); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,4,3); - targetMesh.setCoords(myCoords); - field=targetMesh.buildOrthogonalField(); - self.assertEqual(1,field.getNumberOfTuples()); - self.assertEqual(3,field.getNumberOfComponents()); - vals=field.getArray().getValues(); - self.assertTrue(abs(-0.70710678118654746-vals[0])<1e-12); - self.assertTrue(abs(0.-vals[1])<1e-12); - self.assertTrue(abs(0.70710678118654746-vals[2])<1e-12); - pass - - def testGetCellsContainingPoint(self): - targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - pos=[0.,0.,0.4,0.4,0.,0.4,0.1,0.1,0.25,0.,0.65,0.] - #2D basic - t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12); - self.assertEqual(6,len(t1)); - self.assertEqual(7,len(t2)); - expectedValues1=[0,4,3,0,1,2] - expectedValues2=[0,1,2,3,4,5,6] - self.assertEqual(list(t1),expectedValues1); - self.assertEqual(list(t2),expectedValues2); - #2D with no help of bounding box. - center=[0.2,0.2] - MEDCouplingPointSet.rotate2DAlg(center,0.78539816339744830962,6,pos); - targetMesh.rotate(center,[],0.78539816339744830962); - t1=None - t2=None - t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12); - self.assertEqual(6,len(t1)); - self.assertEqual(7,len(t2)); - self.assertEqual(list(t1),expectedValues1); - self.assertEqual(list(t2),expectedValues2); - #2D outside - pos1bis=[-0.3303300858899107,-0.11819805153394641] - self.assertEqual(-1,targetMesh.getCellContainingPoint(pos1bis,1e-12)); - #test limits 2D - targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - pos2=[0.2,-0.05] - t1=None - t1=targetMesh.getCellsContainingPoint(pos2,1e-12) - self.assertEqual(2,len(t1)); - expectedValues3=[0,1] - self.assertEqual(list(t1),expectedValues3); - pos3=[0.2,0.2] - t1=None - t1=targetMesh.getCellsContainingPoint(pos3,1e-12); - self.assertEqual(5,len(t1)); - expectedValues4=[0,1,2,3,4] - self.assertEqual(list(t1),expectedValues4); - self.assertEqual(0,targetMesh.getCellContainingPoint(pos3,1e-12)); - #3D - targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - pos4=[25.,25.,25.] - self.assertEqual(0,targetMesh.getCellContainingPoint(pos4,1e-12)); - pos5=[50.,50.,50.] - t1=None - t1=targetMesh.getCellsContainingPoint(pos5,1e-12); - self.assertEqual(8,len(t1)); - expectedValues5=[0,1,2,3,4,5,6,7] - self.assertEqual(list(t1),expectedValues5); - pos6=[0., 50., 0.] - t1=None - t1=targetMesh.getCellsContainingPoint(pos6,1e-12); - self.assertEqual(2,len(t1)); - expectedValues6=[0,2] - self.assertEqual(list(t1),expectedValues6); - #3D outside - pos7=[-1.0,-1.0,0.] - self.assertEqual(-1,targetMesh.getCellContainingPoint(pos7,1e-12)); - #3D outside 2 - center2=[0.,0.,0.] - vec2=[0.,-1.,0.] - targetMesh.rotate(center2,vec2,0.78539816339744830962); - pos8=[-25.,25.,12.] - self.assertEqual(-1,targetMesh.getCellContainingPoint(pos8,1e-12)); - pass - - def testGetValueOn1(self): - targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS); - nbOfCells=targetMesh.getNumberOfCells(); - fieldOnCells.setMesh(targetMesh); - array=DataArrayDouble.New(); - tmp=2*nbOfCells*[None] - for i in xrange(nbOfCells): - tmp[2*i]=7.+float(i); - tmp[2*i+1]=17.+float(i) - pass - array.setValues(tmp,nbOfCells,2); - fieldOnCells.setArray(array); - # - pos1=[0.25,0.] - res=fieldOnCells.getValueOn(pos1); - self.assertEqual(2,len(res)) - self.assertTrue(abs(8.-res[0])<1e-12); - self.assertTrue(abs(18.-res[1])<1e-12); - # - # - targetMesh=MEDCouplingDataForTest.build2DSourceMesh_1(); - fieldOnNodes=MEDCouplingFieldDouble.New(ON_NODES); - nbOfNodes=targetMesh.getNumberOfNodes(); - fieldOnNodes.setMesh(targetMesh); - array=DataArrayDouble.New(); - tmp=2*nbOfNodes*[None] - for i in xrange(nbOfNodes): - tmp[2*i]=17.+float(i); - tmp[2*i+1]=27.+float(i) - pass - array.setValues(tmp,nbOfNodes,2); - fieldOnNodes.setArray(array); - # - pos2=[-0.13333333333333333,-0.13333333333333333] - res=None - res=fieldOnNodes.getValueOn(pos2); - self.assertEqual(2,len(res)) - self.assertTrue(abs(17.5-res[0])<1e-12); - self.assertTrue(abs(27.5-res[1])<1e-12); - pos3=[0.033333333333333326,0.36666666666666664] - res=None - res=fieldOnNodes.getValueOn(pos3); - self.assertEqual(2,len(res)) - self.assertTrue(abs(18.666666666666667-res[0])<1e-12); - self.assertTrue(abs(28.666666666666667-res[1])<1e-12); - pass - - def testCMesh0(self): - mesh=MEDCouplingCMesh.New(); - coordsX=DataArrayDouble.New(); - arrX=[ -1., 1., 2., 4. ] - coordsX.setValues(arrX,4,1); - coordsY=DataArrayDouble.New(); - arrY=[ -2., 2., 4., 8. ] - coordsY.setValues(arrY,4,1); - coordsZ=DataArrayDouble.New(); - arrZ=[ -3., 3., 6., 12. ] - coordsZ.setValues(arrZ,4,1); - mesh.setCoords(coordsX,coordsY,coordsZ); - pass - - def testScale(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - pos=[0.2,0.2] - mesh.scale(pos,0.5); - expected1=[-0.05,-0.05, 0.2,-0.05, 0.45,-0.05, -0.05,0.2, 0.2,0.2, 0.45,0.2, - -0.05,0.45, 0.2,0.45, 0.45,0.45] - val=mesh.getCoords().getValues(); - self.assertEqual(18,len(val)) - for i in xrange(18): - self.assertTrue(abs(expected1[i]-val[i])<1e-12); - pass - pass - - def testTryToShareSameCoords(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - #self.assertEqual(m1.getCoords()!=m2.getCoords()); - m1.tryToShareSameCoords(m2,1e-12); - #self.assertEqual(m1.getCoords()==m2.getCoords()); - m1.tryToShareSameCoords(m2,1e-12); - #self.assertEqual(m1.getCoords()==m2.getCoords()); - m2.tryToShareSameCoords(m1,1e-12); - #self.assertEqual(m1.getCoords()==m2.getCoords()); - # - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DTargetMesh_2(); - #self.assertEqual(m1.getCoords()!=m2.getCoords()); - m1.tryToShareSameCoords(m2,1e-12); - #self.assertEqual(m1.getCoords()==m2.getCoords()); - m1.tryToShareSameCoords(m2,1e-12); - #self.assertEqual(m1.getCoords()==m2.getCoords()); - m2.tryToShareSameCoords(m1,1e-12); - #self.assertEqual(m1.getCoords()==m2.getCoords()); - # - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DSourceMesh_1(); - #self.assertEqual(m1.getCoords()!=m2.getCoords()); - self.assertRaises(Exception,m1.tryToShareSameCoords,m2,1e-12) - pass - - def testFindNodeOnPlane(self): - mesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - pt=[300.,300.,0.] - v=[0.,0.,2.] - n=mesh.findNodesOnPlane(pt,v,1e-12); - self.assertEqual(9,len(n)); - m3dSurf=mesh.buildFacePartOfMySelfNode(n,True); - self.assertTrue(isinstance(m3dSurf,MEDCouplingUMesh)) - me=MEDCouplingExtrudedMesh.New(mesh,m3dSurf,0); - da=me.getMesh3DIds(); - self.assertEqual(8,me.getNumberOfCells()); - expected=[0,1,2,3,4,5,6,7] - val=da.getValues(); - self.assertEqual(expected,list(val)); - pass - - def testRenumberCells(self): - m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - self.assertTrue(m.isEqual(m2,0)); - arr=[12,3,25,2,26] - m.renumberCells(arr,True); - self.assertTrue(not m.isEqual(m2,0)); - self.assertEqual(NORM_QUAD4,m.getTypeOfCell(0)); - self.assertEqual(NORM_TRI3,m.getTypeOfCell(1)); - self.assertEqual(NORM_QUAD4,m.getTypeOfCell(2)); - self.assertEqual(NORM_TRI3,m.getTypeOfCell(3)); - self.assertEqual(NORM_QUAD4,m.getTypeOfCell(4)); - arr2=[5,-1,-5,4,8] - m.renumberCells(arr2,True); - self.assertTrue(m.isEqual(m2,0)); - pass - - def testChangeSpaceDimension(self): - m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - # - self.assertEqual(3,m1.getSpaceDimension()); - m1.changeSpaceDimension(2); - self.assertEqual(2,m1.getSpaceDimension()); - m1.setName(m2.getName()); - self.assertTrue(m1.isEqual(m2,1e-12)); - m1.changeSpaceDimension(3); - self.assertEqual(3,m1.getSpaceDimension()); - expected=[-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0.] - val=m1.getCoords().getValues(); - for i in xrange(27): - self.assertTrue(abs(expected[i]-val[i])<1e-14); - pass - pass - - def testGaussPointField1(self): - _a=0.446948490915965; - _b=0.091576213509771; - _p1=0.11169079483905; - _p2=0.0549758718227661; - refCoo1=[ 0.,0., 1.,0., 0.,1. ] - gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, - 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ] - wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ] - _refCoo1=refCoo1 - _gsCoo1=gsCoo1 - _wg1=wg1 - # - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,NO_TIME); - f.setMesh(m); - self.assertEqual(0,f.getNbOfGaussLocalization()); - f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1); - self.assertRaises(Exception,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1) - self.assertEqual(1,f.getNbOfGaussLocalization()); - refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ] - _refCoo2=refCoo2 - _gsCoo1=_gsCoo1[0:4] - _wg1=_wg1[0:2] - f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo2,_gsCoo1,_wg1); - self.assertEqual(2,f.getNbOfGaussLocalization()); - array=DataArrayDouble.New(); - ptr=18*2*[None] - for i in xrange(18*2): - ptr[i]=float(i+1) - array.setValues(ptr,18,2); - ptr=array.getPointer(); - f.setArray(array); - f.setName("MyFirstFieldOnGaussPoint"); - f.checkCoherency(); - self.assertAlmostEqual(27.,f.getIJK(2,5,0),14); - self.assertAlmostEqual(16.,f.getIJK(1,5,1),14); - # - f.clearGaussLocalizations(); - self.assertEqual(0,f.getNbOfGaussLocalization()); - self.assertRaises(Exception,f.checkCoherency); - ids1=[0,1,3,4] - self.assertRaises(Exception,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1); - self.assertEqual(0,f.getNbOfGaussLocalization()); - ids2=[0,4] - f.setGaussLocalizationOnCells(ids2,_refCoo2,_gsCoo1,_wg1); - self.assertEqual(1,f.getNbOfGaussLocalization()); - self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0)); - self.assertRaises(Exception,f.getGaussLocalizationIdOfOneCell,1); - ids3=[1,2] - f.setGaussLocalizationOnCells(ids3,_refCoo1,_gsCoo1,_wg1); - self.assertEqual(2,f.getNbOfGaussLocalization()); - self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0)); - self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(1)); - self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(2)); - self.assertRaises(Exception,f.checkCoherency);#<- cell 3 has no localization - ids4=[3] - _gsCoo2=_gsCoo1; - _wg2=_wg1; - _gsCoo2[0]=0.8888777776666; - _wg2[0]=0.1234567892377; - f.setGaussLocalizationOnCells(ids4,_refCoo2,_gsCoo2,_wg2); - self.assertEqual(3,f.getNbOfGaussLocalization()); - tmpIds=f.getCellIdsHavingGaussLocalization(0); - self.assertEqual(ids2,list(tmpIds)); - self.assertRaises(Exception,f.checkCoherency);#<- it's always not ok because undelying array not with the good size. - array2=f.getArray().substr(0,10); - f.setArray(array2); - f.checkCoherency();#<- here it is OK - f2=f.clone(True); - self.assertTrue(f.isEqual(f2,1e-14,1e-14)); - gl1=f2.getGaussLocalization(0); - tmp=gl1.getGaussCoord(1,1); - self.assertAlmostEqual(2.07*_b-1,tmp,14); - gl1.setGaussCoord(1,1,0.07); - self.assertTrue(not f.isEqual(f2,1e-14,1e-14)); - gl1.setGaussCoord(1,1,tmp); - self.assertTrue(f.isEqual(f2,1e-14,1e-14)); - f2.checkCoherency(); - pass - - def testGaussPointNEField1(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,NO_TIME); - f.setMesh(m); - f.setName("MyFirstFieldOnNE"); - f.setDescription("MyDescriptionNE"); - array=DataArrayDouble.New(); - tmp=18*2*[None] - for i in xrange(18*2): - tmp[i]=float(i+7) - pass - array.setValues(tmp,18,2); - ptr=array.getPointer(); - f.setArray(array); - # - f.checkCoherency(); - f2=f.clone(True); - self.assertTrue(f.isEqual(f2,1e-14,1e-14)); - self.assertAlmostEqual(21.,f.getIJK(2,0,0),14); - self.assertAlmostEqual(18.,f.getIJK(1,1,1),14); - pass - - def testCellOrientation1(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - vec=[0.,0.,1.] - self.assertRaises(Exception,m.are2DCellsNotCorrectlyOriented,vec,False); - m.changeSpaceDimension(3); - res1=m.are2DCellsNotCorrectlyOriented(vec,False); - self.assertTrue(len(res1)==0); - vec[2]=-1.; - res1=m.are2DCellsNotCorrectlyOriented(vec,False); - self.assertEqual(5,len(res1)); - # - vec[2]=1.; - # connectivity inversion - conn=m.getNodalConnectivity().getValues(); - tmp=conn[11]; - conn[11]=conn[12]; - conn[12]=tmp; - m.getNodalConnectivity().setValues(conn,len(conn),1) - res1=m.are2DCellsNotCorrectlyOriented(vec,False); - self.assertEqual(1,len(res1)); - self.assertEqual(2,res1[0]); - m.orientCorrectly2DCells(vec,False); - res1=m.are2DCellsNotCorrectlyOriented(vec,False); - self.assertTrue(len(res1)==0); - m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - m2.changeSpaceDimension(3); - self.assertTrue(m.isEqual(m2,1e-12)); - pass - - def testCellOrientation2(self): - m2,m1=MEDCouplingDataForTest.build3DExtrudedUMesh_1(); - res1=m2.arePolyhedronsNotCorrectlyOriented(); - self.assertEqual(6,len(res1)); - m2.orientCorrectlyPolyhedrons(); - res1=m2.arePolyhedronsNotCorrectlyOriented(); - self.assertTrue(len(res1)==0); - m2.checkCoherency(); - self.assertEqual(18,m2.getNumberOfCells()); - cellIds2=[0,6,12] - m2.convertToPolyTypes(cellIds2); - m2.orientCorrectlyPolyhedrons(); - res1=m2.arePolyhedronsNotCorrectlyOriented(); - self.assertTrue(len(res1)==0); - f2=m2.getMeasureField(False); - f2Ptr=f2.getArray().getValues(); - #Test to check global reverse in MEDCouplingUMesh::tryToCorrectPolyhedronOrientation - m3=MEDCouplingDataForTest.build2DTargetMesh_1(); - vec=[0.,0.,-1.] - m3.changeSpaceDimension(3); - ids2=[0,1,2,3,4] - m3.convertToPolyTypes(ids2); - m3.orientCorrectly2DCells(vec,False); - m4=MEDCouplingDataForTest.buildCU1DMesh_U(); - m4.changeSpaceDimension(3); - center=[0.,0.,0.] - vector=[0.,1.,0.] - m4.rotate(center,vector,-pi/2.); - m5=m3.buildExtrudedMeshFromThis(m4,0); - res1=m5.arePolyhedronsNotCorrectlyOriented(); - self.assertEqual(15,len(res1)); - m5.orientCorrectlyPolyhedrons(); - res1=m5.arePolyhedronsNotCorrectlyOriented(); - self.assertTrue(len(res1)==0); - f3=m5.getMeasureField(False); - self.assertEqual(15,f3.getArray().getNumberOfTuples()); - self.assertEqual(1,f3.getNumberOfComponents()); - f3Ptr=f3.getArray().getValues(); - expected1=[0.075,0.0375,0.0375,0.075,0.075, 0.1125,0.05625,0.05625,0.1125,0.1125, 0.0625,0.03125,0.03125,0.0625,0.0625]; - for i in xrange(15): - self.assertTrue(abs(expected1[i]-f3Ptr[i])<1e-12); - pass - f4=m5.getBarycenterAndOwner(); - self.assertEqual(15,f4.getNumberOfTuples()); - self.assertEqual(3,f4.getNumberOfComponents()); - f4Ptr=f4.getValues(); - expected2=[-0.05,-0.05,0.15, 0.3666666666666667,-0.13333333333333333,0.15, 0.53333333333333333,0.033333333333333333,0.15, -0.05,0.45,0.15, 0.45,0.45,0.15,-0.05,-0.05,0.525, 0.3666666666666667,-0.13333333333333333,0.525, 0.53333333333333333,0.033333333333333333,0.525, -0.05,0.45,0.525, 0.45,0.45,0.525,-0.05,-0.05,0.875, 0.3666666666666667,-0.13333333333333333,0.875, 0.53333333333333333,0.033333333333333333,0.875, -0.05,0.45,0.875, 0.45,0.45,0.875]; - for i in xrange(45): - self.assertTrue(abs(expected2[i]-f4Ptr[i])<1e-12); - pass - pass - - def testPolyhedronBarycenter(self): - connN=[0,3,2,1, -1, 4,5,6,7, -1, 0,4,7,3, -1, 3,7,6,2, -1, 2,6,5,1, -1, 1,5,4,0]; - coords=[0.,0.,0., 1.,0.,0., 1.,1.,0., 0.,1.,0., 0.,0.,1., 1.,0.,1., 1.,1.,1., 0.,1.,1., 0.5, 0.5, 0.5]; - meshN=MEDCouplingUMesh.New(); - meshN.setName("ForBary"); - meshN.setMeshDimension(3); - meshN.allocateCells(4); - meshN.insertNextCell(NORM_POLYHED,29,connN[0:29]) - meshN.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,9,3); - meshN.setCoords(myCoords); - meshN.checkCoherency(); - # - res1=meshN.arePolyhedronsNotCorrectlyOriented(); - meshN.orientCorrectlyPolyhedrons(); - self.assertTrue(len(res1)==0); - da=meshN.getBarycenterAndOwner(); - self.assertEqual(1,da.getNumberOfTuples()); - self.assertEqual(3,da.getNumberOfComponents()); - daPtr=da.getValues(); - ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): - self.assertTrue(abs(ref[i]-daPtr[i])<1e-12); - pass - # - center=[0.,0.,0.] - vec=[0.,2.78,0.] - da=meshN.getBarycenterAndOwner(); - daPtr=da.getValues(); - ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): - self.assertTrue(abs(ref[i]-daPtr[i])<1e-12); - pass - # - meshN.rotate(center,vec,pi/7.); - meshN.translate(vec); - da=meshN.getBarycenterAndOwner(); - daPtr=da.getValues(); - ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): - self.assertTrue(abs(ref[i]-daPtr[i])<1e-12); - pass - # - center2=[1.12,3.45,6.78] - vec2=[4.5,9.3,2.8] - meshN.rotate(center2,vec2,e); - meshN.translate(vec2); - da=meshN.getBarycenterAndOwner(); - daPtr=da.getValues(); - ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): - self.assertTrue(abs(ref[i]-daPtr[i])<1e-10); - pass - pass - - def testNormL12Integ1D(self): - m1=MEDCouplingDataForTest.build1DTargetMesh_3(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(m1); - array=DataArrayDouble.New(); - arr=[-5.23,15.45,-25.56,6.67,-16.78,26.89,-7.91,17.23,-27.43,8.21,-18.63,28.72] - array.setValues(arr,m1.getNumberOfCells(),3); - f1.setArray(array); - # - f3=m1.getBarycenterAndOwner(); - self.assertEqual(4,f3.getNumberOfTuples()); - self.assertEqual(1,f3.getNumberOfComponents()); - expected9=[0.75,5.105,0.8,5.155] - ptr=f3.getValues(); - for i in xrange(4): - self.assertTrue(abs(expected9[i]-ptr[i])<1e-12); - pass - # - f2=m1.getMeasureField(False); - self.assertEqual(4,f2.getArray().getNumberOfTuples()); - self.assertEqual(1,f2.getNumberOfComponents()); - expected1=[0.5,0.21,-0.6,-0.31] - ptr=f2.getArray().getValues(); - for i in xrange(4): - self.assertTrue(abs(expected1[i]-ptr[i])<1e-12); - pass - expected2=[0.5,0.21,0.6,0.31] - f2=m1.getMeasureField(True); - ptr=f2.getArray().getValues(); - for i in xrange(4): - self.assertTrue(abs(expected2[i]-ptr[i])<1e-12); - pass - #integral - res=f1.integral(False); - expected3=[0.9866,-0.3615,0.4217] - for i in xrange(3): - self.assertTrue(abs(expected3[i]-res[i])<1e-12); - pass - self.assertTrue(abs(expected3[0]-f1.integral(0,False))<1e-12); - self.assertTrue(abs(expected3[1]-f1.integral(1,False))<1e-12); - self.assertTrue(abs(expected3[2]-f1.integral(2,False))<1e-12); - res=f1.integral(True); - expected4=[-3.4152,8.7639,-14.6879] - for i in xrange(3): - self.assertTrue(abs(expected4[i]-res[i])<1e-12); - pass - #normL1 - res=f1.normL1(); - expected5=[11.3068,27.3621,43.7881] - for i in xrange(3): - self.assertTrue(abs(expected5[i]-res[i])<1e-12); - pass - self.assertTrue(abs(expected5[0]-f1.normL1(0))<1e-12); - self.assertTrue(abs(expected5[1]-f1.normL1(1))<1e-12); - self.assertTrue(abs(expected5[2]-f1.normL1(2))<1e-12); - #normL2 - res=f1.normL2(); - expected7=[9.0252562290496776, 21.545259176904789, 34.433193070059595] - for i in xrange(3): - self.assertTrue(abs(expected7[i]-res[i])<1e-9); - pass - self.assertTrue(abs(expected7[0]-f1.normL2(0))<1e-9); - self.assertTrue(abs(expected7[1]-f1.normL2(1))<1e-9); - self.assertTrue(abs(expected7[2]-f1.normL2(2))<1e-9); - #buildMeasureField - f4=f1.buildMeasureField(False); - self.assertTrue(abs(-0.2-f4.accumulate(0))<1e-12); - f4=f1.buildMeasureField(True); - self.assertTrue(abs(1.62-f4.accumulate(0))<1e-12); - # Testing with 2D Curve - m1=MEDCouplingDataForTest.build2DCurveTargetMesh_3(); - f2=m1.getMeasureField(False); - self.assertEqual(4,f2.getArray().getNumberOfTuples()); - self.assertEqual(1,f2.getNumberOfComponents()); - ptr=f2.getArray().getValues(); - for i in xrange(4): - self.assertTrue(abs(sqrt(2.)*expected2[i]-ptr[i])<1e-12); - pass - f2=m1.getMeasureField(True); - self.assertEqual(4,f2.getArray().getNumberOfTuples()); - self.assertEqual(1,f2.getNumberOfComponents()); - ptr=f2.getArray().getValues(); - for i in xrange(4): - self.assertTrue(abs(expected2[i]*sqrt(2.)-ptr[i])<1e-12); - pass - #bary - f3=m1.getBarycenterAndOwner(); - self.assertEqual(4,f3.getNumberOfTuples()); - self.assertEqual(2,f3.getNumberOfComponents()); - expected10=[0.75,0.75,5.105,5.105,0.8,0.8,5.155,5.155] - ptr=f3.getValues(); - for i in xrange(8): - self.assertTrue(abs(expected10[i]-ptr[i])<1e-12); - pass - # - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(m1); - array=DataArrayDouble.New(); - array.setValues(arr,m1.getNumberOfCells(),3); - f1.setArray(array); - res=f1.integral(False); - for i in xrange(3): - self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12); - pass - res=f1.integral(True); - for i in xrange(3): - self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12); - pass - res=f1.normL1(); - for i in xrange(3): - self.assertTrue(abs(sqrt(2.)*expected5[i]-res[i])<1e-12); - pass - res=f1.normL2(); - for i in xrange(3): - self.assertTrue(abs(sqrt(sqrt(2.))*expected7[i]-res[i])<1e-12); - pass - pass - - def testAreaBary2D(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_3(); - f1=m1.getMeasureField(False); - self.assertEqual(10,f1.getArray().getNumberOfTuples()); - self.assertEqual(1,f1.getNumberOfComponents()); - expected1=[-0.5,-1,-1.5,-0.5,-1, 0.5,1,1.5,0.5,1] - ptr=f1.getArray().getValues(); - for i in xrange(10): - self.assertTrue(abs(expected1[i]-ptr[i])<1e-12); - pass - f1=m1.getMeasureField(True); - ptr=f1.getArray().getValues(); - for i in xrange(10): - self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12); - pass - f2=m1.getBarycenterAndOwner(); - self.assertEqual(10,f2.getNumberOfTuples()); - self.assertEqual(2,f2.getNumberOfComponents()); - expected2=[0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5,0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5] - ptr=f2.getValues(); - for i in xrange(20): - self.assertTrue(abs(expected2[i]-ptr[i])<1e-12); - pass - m1.changeSpaceDimension(3); - f1=m1.getMeasureField(False); - self.assertEqual(10,f1.getArray().getNumberOfTuples()); - self.assertEqual(1,f1.getNumberOfComponents()); - ptr=f1.getArray().getValues(); - for i in xrange(10): - self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12); - pass - f2=m1.getBarycenterAndOwner(); - self.assertEqual(10,f2.getNumberOfTuples()); - self.assertEqual(3,f2.getNumberOfComponents()); - ptr=f2.getValues(); - expected3=[0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0., 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0.] - for i in xrange(30): - self.assertTrue(abs(expected3[i]-ptr[i])<1e-12); - pass - pass - - def testAreaBary3D(self): - coords=[ 0.241310763507 , 0.0504777305619 , 0.0682283524903 , 0.252501053866 , -0.0625176732937 , 0.137272639894 , - 0.152262663601 , 0.241816569527 , 0.133812556197 , 0.18047750211 , -0.0789949051358 , 0.339098173401 , - 0.151741971857 , 0.238885278571 , 0.137715037333 , 0.242532155481 , -0.0928169086456 , 0.0678043417367 , - 0.240941965335 , -0.015461491464 , 0.0617186345825 , 0.24127650112 , 0.0499427876717 , 0.0679634099148 , - -0.145828917428 , 0.206291632565 , 0.0310071927543 , 0.0125651775307 , 0.266262085828 , 0.105228430543 , - -0.0994066533286 , 0.233224271238 , 0.0572213839567 , -0.0951345338317 , 0.234819509426 , 0.0592126284538 , - 0.136580574205 , -0.205486212579 , 0.0572866072014 , 0.0637270784978 , -0.168886355238 , 0.446614057077 , - 0.041337157151 , -0.213402568198 , 0.372407095999 , 0.0411601970268 , -0.202387875756 , 0.411334979491 , - -0.108355701857 , 0.193636239335 , 0.204886756738 , 0.00639779029829 , 0.155296981517 , 0.252585892979 , - 0.0262473111702 , -0.112919732543 , 0.424286639249 ,-0.224103052733 , -0.139430015438 , -0.0122352295701 , - -0.0312760589481 , -0.274272003594 , 0.0323959636568 , -0.166663422532 , -0.217754445175 , 0.00392109070364 , - -0.30586619777 , -0.0475168041091 , -0.0144585228182 , -0.280881480586 , 0.135571293538 , 0.00623923647986 , - -0.25548538234 , 0.156819217766 , 0.0645277879769 , -0.131567009284 , 0.184133752309 , 0.206021802753 , - -0.196204010965 , 0.151602971681 , 0.212974777736 , -0.183713879463 , 0.0802946639531 , 0.260115662599 , - -0.244241178767 , -0.0738873389604 , 0.144590565817 , -0.155804057829 , -0.164892720025 , 0.210613950558 , - -0.170950800428 , -0.215099334026 , 0.00610122860092 , -0.30552634869 , -0.0490020791904 , -0.0132786533145 , - 0.271831011884 , 0.15105657296 , 0.0230534827908 , 0.281919192283 , 0.0898544306288 , -0.0625201489143 , - 0.260240727276 , -0.0120688706637 , -0.0532316588626 , 0.244947737722 , 0.0197984684293 , 0.0309341209233 , - 0.23439631578 , 0.229825279875 , 0.0508520585381 , 0.160921316875 , 0.265078502128 , 0.121716560626 , - -0.315088694175 , 0.0747700471918 , -0.245836615071 , -0.327728781776 , 0.0857114674649 , -0.239431905957 , - -0.308385460634 , 0.145142997084 , -0.149886828433 , 0.0488236045164 , 0.309462801914 , 0.0849169148265 , - -0.0244964803395 , 0.33145611751 , -0.0476415818061 , 0.0060567994229 , 0.32418412014 , 0.0367779543812 , - -0.0950221448063 , 0.236675326003 , 0.0572594453983 , 0.248723023186 , 0.0886648784791 , -0.176629430538 , - 0.116796984 , 0.256596599567 , -0.292863523603 , 0.118024552914 , 0.229154257843 , -0.34233232501 , - 0.217507892549 , -0.0417822335742 , -0.176771782888 , -0.224429321304 , 0.0125595300114 , -0.362064725588 , - 0.0937301100955 , -0.0500824832657 , -0.299713548444 , -0.244162220397 , 0.0383853931293 , -0.389856984411 , - -0.0281989366102 , 0.097392811563 , -0.458244577284 , -0.385010847162 , 0.10122766194 , -0.140052859922 , - -0.377936358012 , 0.110875172128 , -0.176207095463 , 0.244483045556 , -0.0991073977045 , 0.0575134372934 , - 0.262605120167 , -0.100243191645 , -0.0495620806935 , 0.240306880972 , -0.136153701579 , -0.114745281696 , - 0.215763176129 , -0.0836766059189 , -0.183249640616 , 0.237870396603 , -0.132449578286 , -0.121598854639 , - -0.0637683083097 , -0.27921020214 , -0.149112321992 , -0.0856211014977 , -0.2973233473 , -0.0446878139589 , - 0.104675342288 , -0.0625908305324 , -0.290346256534 , 0.0248264249186 , -0.247797708548 , -0.165830884019 , - 0.0719302438309 , -0.178468260473 , -0.211432157345 , 0.142871843159 , -0.208769948542 , 0.0454101128246 , - 0.167803379307 , -0.207851396623 , -0.088802726124 , 0.12868717152 , -0.230920439715 , 0.00760508389036 , - -0.0372812069535 , -0.286740286332 , 0.00963701291166 ] - - connN = [ #polyhedron 0 - 0 , 1 , 3 , 4 , 2 , -1 , 1 , 5 , 6 , 7 , 0 , -1 , 0 , 7 , 8 , 10 , 11 , 9 , 2 , -1 , 1 , 5 , 12 , 14 , 15 , 13 , 3 , -1 , 16 , 9 , 2 , 4 , 17 , -1 - , 4 , 3 , 13 , 18 , 17 , -1 , 5 , 6 , 19 , 21 , 20 , 12 , -1 , 6 , 7 , 8 , 23 , 22 , 19 , -1 , 23 , 24 , 10 , 8 , -1 , 25 , 11 , 9 , 16 , -1 - , 24 , 26 , 25 , 11 , 10 , -1 , 12 , 14 , 20 , -1 , 27 , 28 , 29 , 15 , 13 , 18 , -1 , 14 , 15 , 29 , 30 , 21 , 20 , -1 , 26 , 27 , 18 , 17 , 16 , 25 , -1 - , 22 , 19 , 21 , 30 , 31 , -1 , 22 , 31 , 28 , 27 , 26 , 24 , 23 , -1 , 31 , 30 , 29 , 28, - # polyhedron 1 - 0 , 7 , 8 , 10 , 11 , 9 , 2 , -1 , 32 , 0 , 7 , 35 , 34 , 33 , -1 , 32 , 0 , 2 , 37 , 36 , -1 , 35 , 7 , 8 , 40 , 39 , 38 , -1 - , 2 , 37 , 41 , 9 , -1 , 40 , 8 , 10 , 44 , 43 , 42 , -1 , 41 , 9 , 11 , 44 , 43 , -1 , 44 , 11 , 10 , -1 , 32 , 33 , 45 , 47 , 46 , 36 , -1 - , 33 , 34 , 48 , 45 , -1 , 35 , 34 , 48 , 50 , 49 , 38 , -1 , 41 , 43 , 42 , 46 , 36 , 37 , -1 , 38 , 39 , 51 , 49 , -1 - , 39 , 40 , 42 , 46 , 47 , 52 , 51 , -1 , 45 , 47 , 52 , 50 , 48 , -1 , 52 , 51 , 49 , 50, - # polyhedron 2 - 6 , 7 , 8 , 23 , 22 , 19 , -1 , 6 , 35 , 7 , -1 , 6 , 35 , 38 , 19 , -1 , 35 , 7 , 8 , 40 , 39 , 38 , -1 , 53 , 22 , 19 , 38 , 39 , 54 , -1 - , 23 , 53 , 54 , 40 , 8 , -1 , 53 , 22 , 23 , -1 , 39 , 54 , 40, - # polyhedron 3 - 35 , 34 , 48 , 50 , 49 , 38 , -1 , 6 , 35 , 34 , 56 , 55 , 5 , -1 , 6 , 35 , 38 , 19 , -1 , 34 , 56 , 57 , 59 , 58 , 48 , -1 - , 60 , 61 , 21 , 19 , 38 , 49 , -1 , 62 , 50 , 48 , 58 , -1 , 60 , 63 , 64 , 62 , 50 , 49 , -1 , 5 , 6 , 19 , 21 , 20 , 12 , -1 - , 55 , 5 , 12 , 65 , -1 , 66 , 67 , 65 , 55 , 56 , 57 , -1 , 63 , 66 , 57 , 59 , 64 , -1 , 64 , 62 , 58 , 59 , -1 - , 60 , 63 , 66 , 67 , 68 , 61 , -1 , 61 , 68 , 20 , 21 , -1 , 67 , 68 , 20 , 12 , 65] - - barys = [ -0.0165220465527 , -0.0190922868195 , 0.158882733414 , - 0.0287618656076 , 0.135874379934 , -0.14601588119 , - -0.147128055553 , 0.0465995097041 , -0.049391174453 , - -0.00142506732317 , -0.0996953090351 , -0.115159183132 ] - meshN=MEDCouplingUMesh.New(); - meshN.setName("ForBary"); - meshN.setMeshDimension(3); - meshN.allocateCells(4); - meshN.insertNextCell(NORM_POLYHED,113,connN); - meshN.insertNextCell(NORM_POLYHED,99,connN[113:]); - meshN.insertNextCell(NORM_POLYHED,43,connN[212:]); - meshN.insertNextCell(NORM_POLYHED,92,connN[255:]); - meshN.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,69,3); - meshN.setCoords(myCoords); - meshN.checkCoherency(); - res1=meshN.arePolyhedronsNotCorrectlyOriented(); - meshN.orientCorrectlyPolyhedrons(); - res1=meshN.arePolyhedronsNotCorrectlyOriented(); - self.assertTrue(len(res1)==0); - # - da=meshN.getBarycenterAndOwner(); - self.assertEqual(4,da.getNumberOfTuples()); - self.assertEqual(3,da.getNumberOfComponents()); - daPtr=da.getValues(); - for i in xrange(12): - self.assertTrue(abs(barys[i]-daPtr[i])<1e-12); - pass - pass - - def testRenumberCellsForFields(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f.setMesh(m); - arr=DataArrayDouble.New(); - nbOfCells=m.getNumberOfCells(); - values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.] - arr.setValues(values1,nbOfCells,3); - f.setArray(arr); - renumber1=[3,1,0,4,2] - loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45] - for j in xrange(5): - res=f.getValueOn(loc[2*j:2*j+2]); - for i in xrange(3): - self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12); - pass - pass - f.renumberCells(renumber1,False); - ptr=f.getArray().getValues(); - expected1=[9.,109.,10009.,8.,108.,10008.,11.,111.,10011.,7.,107.,10007.,10.,110.,10010.] - for i in xrange(15): - self.assertTrue(abs(expected1[i]-ptr[i])<1e-12); - pass - #check that fields remains the same geometrically - for j in xrange(5): - res=f.getValueOn(loc[2*j:2*(j+1)]); - for i in xrange(3): - self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12); - pass - pass - #On gauss - f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,NO_TIME); - f.setMesh(m); - _a=0.446948490915965; - _b=0.091576213509771; - _p1=0.11169079483905; - _p2=0.0549758718227661; - refCoo1=[ 0.,0., 1.,0., 0.,1. ] - gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ]; - wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ] - _refCoo1=refCoo1[0:6]; - _gsCoo1=gsCoo1[0:12]; - _wg1=wg1[0:6]; - f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1); - refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ] - _refCoo2=refCoo2[0:8]; - _gsCoo1=_gsCoo1[0:4] - _wg1=_wg1[0:2] - f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo2,_gsCoo1,_wg1); - arr=DataArrayDouble.New(); - values2=[1.,1001.,2.,1002., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 31.,1031.,32.,1032., 41.,1041.,42.,1042.] - arr.setValues(values2,18,2); - f.setArray(arr); - f.checkCoherency(); - fCpy=f.clone(True); - self.assertTrue(f.isEqual(fCpy,1e-12,1e-12)); - f.renumberCells(renumber1,False); - self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12)); - expected2=[21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 41.,1041.,42.,1042., 1.,1001.,2.,1002., 31.,1031.,32.,1032.] - ptr=f.getArray().getValues(); - for i in xrange(36): - self.assertTrue(abs(expected2[i]-ptr[i])<1e-12); - pass - renumber2=[2,1,4,0,3] - f.renumberCells(renumber2,False); - self.assertTrue(f.isEqual(fCpy,1e-12,1e-12)); - #GaussNE - f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,NO_TIME); - f.setMesh(m); - arr=DataArrayDouble.New(); - values3=[1.,1001.,2.,1002.,3.,1003.,4.,1004., 11.,1011.,12.,1012.,13.,1013., 21.,1021.,22.,1022.,23.,1023., 31.,1031.,32.,1032.,33.,1033.,34.,1034., 41.,1041.,42.,1042.,43.,1043.,44.,1044.] - arr.setValues(values3,18,2); - f.setArray(arr); - f.checkCoherency(); - fCpy=f.clone(True); - self.assertTrue(f.isEqual(fCpy,1e-12,1e-12)); - f.renumberCells(renumber1,False); - self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12)); - expected3=[21.,1021.,22.,1022.,23.,1023.,11.,1011.,12.,1012.,13.,1013.,41.,1041.,42.,1042.,43.,1043.,44.,1044.,1.,1001.,2.,1002.,3.,1003.,4.,1004.,31.,1031.,32.,1032.,33.,1033.,34.,1034.] - ptr=f.getArray().getValues(); - for i in xrange(36): - self.assertTrue(abs(expected3[i]-ptr[i])<1e-12); - pass - f.renumberCells(renumber2,False);#perform reverse operation of renumbering to check that the resulting field is equal. - self.assertTrue(f.isEqual(fCpy,1e-12,1e-12)); - # - pass - - def testRenumberNodesForFields(self): - m=MEDCouplingDataForTest.build2DTargetMesh_1(); - f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); - f.setMesh(m); - arr=DataArrayDouble.New(); - nbOfNodes=m.getNumberOfNodes(); - values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.] - arr.setValues(values1,nbOfNodes,3); - f.setArray(arr); - f.checkCoherency(); - renumber1=[0,4,1,3,5,2,6,7,8] - loc=[0.5432,-0.2432, 0.5478,0.1528] - expected1=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124] - for j in xrange(2): - res=f.getValueOn(loc[2*j:2*j+2]); - for i in xrange(3): - self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12); - pass - pass - fCpy=f.clone(True); - self.assertTrue(f.isEqual(fCpy,1e-12,1e-12)); - f.renumberNodes(renumber1); - self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12)); - for j in xrange(2): - res=f.getValueOn(loc[2*j:2*j+2]); - for i in xrange(3): - self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12); - pass - pass - expected2=[7.,107.,10007.,9.,109.,10009.,12.,112.,10012.,10.,110.,10010.,8.,108.,10008.,11.,111.,10011.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.] - for i in xrange(27): - self.assertTrue(abs(expected2[i]-f.getArray().getValues()[i])<1e-12); - pass - renumber2=[0,2,5,3,1,4,6,7,8] - f.renumberNodes(renumber2); - self.assertTrue(f.isEqual(fCpy,1e-12,1e-12)); - pass - - def testConvertQuadraticCellsToLinear(self): - mesh=MEDCouplingDataForTest.build2DTargetMesh_3(); - mesh.checkCoherency(); - types=mesh.getAllTypes(); - types.sort() - self.assertEqual(5,len(types)); - expected1=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4, NORM_TRI6, NORM_QUAD8] - expected1.sort() - self.assertTrue(expected1==types); - self.assertTrue(mesh.isPresenceOfQuadratic()); - self.assertEqual(62,mesh.getMeshLength()); - f1=mesh.getMeasureField(False); - # - mesh.convertQuadraticCellsToLinear(); - self.assertTrue(not mesh.isPresenceOfQuadratic()); - # - mesh.checkCoherency(); - f2=mesh.getMeasureField(False); - self.assertTrue(f1.getArray().isEqual(f2.getArray(),1e-12)); - self.assertEqual(48,mesh.getMeshLength()); - types2=mesh.getAllTypes(); - types2.sort() - self.assertEqual(3,len(types2)); - expected2=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4] - expected2.sort() - self.assertTrue(expected2==types2); - pass - - def testCheckGeoEquivalWith(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_3(); - mesh2=MEDCouplingDataForTest.build2DTargetMesh_3(); - #First test mesh1 - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh1,0,1e-12);#deepEqual - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh1,1,1e-12);#fastEqual - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh1,10,1e-12);#deepEqual with geo permutations - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - #Second test mesh1 and mesh2 are 2 different meshes instance - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,0,1e-12);#deepEqual - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12);#deepEqual with geo permutations - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - #Third test : cell permutation by keeping the first the middle and the last as it is. - renum=[0,2,1,3,4,5,6,8,7,9] - mesh2.renumberCells(renum,False); - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12);#deepEqual with geo permutations - self.assertTrue(cellCor); - self.assertEqual(10,cellCor.getNumberOfTuples()); - self.assertEqual(1,cellCor.getNumberOfComponents()); - self.assertEqual(renum,list(cellCor.getValues())) - self.assertTrue(nodeCor==None); - cellCor=0; - self.assertTrue(nodeCor==None); - #4th test : cell and node permutation by keeping the first the middle and the last as it is. - mesh2=MEDCouplingDataForTest.build2DTargetMesh_3(); - renum2=[0,2,1,3,4,5,6,8,7,9,10] - mesh2.renumberCells(renum,False); - mesh2.renumberNodes(renum2,11); - cellCor=None - nodeCor=None - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12);#deepEqual with geo permutations - self.assertTrue(cellCor); - self.assertEqual(10,cellCor.getNumberOfTuples()); - self.assertEqual(1,cellCor.getNumberOfComponents()); - self.assertEqual(renum,list(cellCor.getValues())) - self.assertTrue(nodeCor); - self.assertEqual(11,nodeCor.getNumberOfTuples()); - self.assertEqual(1,nodeCor.getNumberOfComponents()); - self.assertEqual(renum2,list(nodeCor.getValues())) - cellCor=0; - nodeCor=0; - #5th test : modification of the last cell to check fastCheck detection. - mesh2=MEDCouplingDataForTest.build2DTargetMesh_3(); - renum3=[0,2,1,3,4,5,6,8,9,7] - mesh2.renumberCells(renum3,False); - mesh2.renumberNodes(renum2,11); - cellCor=None - nodeCor=None - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12) - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,1,1e-12) - self.assertTrue(cellCor==None); - self.assertTrue(nodeCor==None); - cellCor,nodeCor=mesh2.checkGeoEquivalWith(mesh1,10,1e-12);#deepEqual with geo permutations - self.assertTrue(cellCor!=None); - self.assertEqual(10,cellCor.getNumberOfTuples()); - self.assertEqual(1,cellCor.getNumberOfComponents()); - self.assertEqual(renum3,list(cellCor.getValues())) - self.assertTrue(nodeCor!=None); - self.assertEqual(11,nodeCor.getNumberOfTuples()); - self.assertEqual(1,nodeCor.getNumberOfComponents()); - self.assertEqual(renum2,list(nodeCor.getValues())); - pass - - def testCheckGeoEquivalWith2(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_4(); - mesh2=MEDCouplingDataForTest.build2DTargetMesh_1(); - cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12); - self.assertEqual(None,cellCor); - self.assertNotEqual(None,nodeCor); - expected1=[0, 1, 3, 4, 5, 6, 7, 8, 9] - for i in xrange(9): - self.assertEqual(expected1[i],nodeCor.getIJ(i,0)); - pass - pass - - def testCopyTinyStringsFromOnFields(self): - m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - nbOfCells=m.getNumberOfCells(); - f=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); - f.setMesh(m); - f.setName("a"); - f.setDescription("b"); - a1=DataArrayDouble.New(); - a1.alloc(nbOfCells,2); - a1.fillWithZero(); - a1.setInfoOnComponent(0,"c"); - a1.setInfoOnComponent(1,"d"); - a2=a1.deepCopy(); - a2.setInfoOnComponent(0,"e"); - a2.setInfoOnComponent(1,"f"); - f.setArray(a1); - f.setEndArray(a2); - f.setEndTime(3.,3,4); - m.setName("g"); - m.getCoords().setInfoOnComponent(0,"h"); - m.getCoords().setInfoOnComponent(1,"i"); - m.getCoords().setInfoOnComponent(2,"j"); - # - f.checkCoherency(); - f2=f.clone(True); - self.assertTrue(f2.isEqual(f,1e-12,1e-12)); - f2.setName("smth"); - self.assertTrue(not f2.isEqual(f,1e-12,1e-12)); - f2.copyTinyStringsFrom(f); - self.assertTrue(f2.isEqual(f,1e-12,1e-12)); - f2.setDescription("GGG"); - self.assertTrue(not f2.isEqual(f,1e-12,1e-12)); - f2.copyTinyStringsFrom(f); - self.assertTrue(f2.isEqual(f,1e-12,1e-12)); - f2.getArray().setInfoOnComponent(0,"mmmm"); - self.assertTrue(not f2.isEqual(f,1e-12,1e-12)); - f2.copyTinyStringsFrom(f); - self.assertTrue(f2.isEqual(f,1e-12,1e-12)); - f2.getEndArray().setInfoOnComponent(1,"mmmm"); - self.assertTrue(not f2.isEqual(f,1e-12,1e-12)); - f2.copyTinyStringsFrom(f); - self.assertTrue(f2.isEqual(f,1e-12,1e-12)); - m2=m.clone(True); - self.assertTrue(m2.isEqual(m,1e-12)); - m2.setName("123"); - self.assertTrue(not m2.isEqual(m,1e-12)); - m2.copyTinyStringsFrom(m); - self.assertTrue(m2.isEqual(m,1e-12)); - m2.getCoords().setInfoOnComponent(1,"eee"); - self.assertTrue(not m2.isEqual(m,1e-12)); - m2.copyTinyStringsFrom(m); - self.assertTrue(m2.isEqual(m,1e-12)); - pass - - def testTryToShareSameCoordsPermute(self): - m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - #self.assertTrue(m.getCoords()!=m2.getCoords()); - m.tryToShareSameCoordsPermute(m2,1e-12); - #self.assertTrue(m.getCoords()==m2.getCoords()); - self.assertTrue(m2.isEqual(m,1e-12)); - renum1=[1,2,0,5,8,7,4,3,6] - m.renumberNodes(renum1,9); - #self.assertTrue(m.getCoords()!=m2.getCoords()); - self.assertTrue(not m2.isEqual(m,1e-12)); - m.tryToShareSameCoordsPermute(m2,1e-12); - #self.assertTrue(m.getCoords()==m2.getCoords()); - self.assertTrue(m2.isEqual(m,1e-12)); - pass - - def testTryToShareSameCoordsPermute2(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_4(); - targetCoords=[-0.3,-0.3, 0.2,-0.3, -0.3,0.2, 0.2,0.2 ] - targetConn=[0,2,3,1] - m2=MEDCouplingUMesh.New(); - m2.setMeshDimension(2); - m2.allocateCells(1); - m2.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) - m2.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,4,2); - m2.setCoords(myCoords); - m2.checkCoherency(); - m1.checkCoherency(); - # - expected1=[0.25,0.125,0.125,0.25,0.25] - f1=m1.getMeasureField(False); - f2=m2.getMeasureField(False); - self.assertEqual(5,f1.getArray().getNumberOfTuples()); - self.assertEqual(1,f2.getArray().getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12); - pass - self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12); - self.assertRaises(Exception,m1.tryToShareSameCoordsPermute,m2,1e-12);# <- here in this order the sharing is impossible. - # Let's go for deeper test of tryToShareSameCoordsPermute - m2.tryToShareSameCoordsPermute(m1,1e-12); - f1=m1.getMeasureField(False); - f2=m2.getMeasureField(False); - self.assertEqual(5,f1.getArray().getNumberOfTuples()); - self.assertEqual(1,f2.getArray().getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12); - pass - self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12); - pass - - def testChangeUnderlyingMesh1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_3(); - mesh2=MEDCouplingDataForTest.build2DTargetMesh_3(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr=[7., 107., 8., 108., 9., 109., 10., 110., 11., 111., 12., 112., 13., 113., 14., 114., 15., 115., 16., 116.] - array.setValues(arr,mesh1.getNumberOfCells(),2); - f1.setArray(array); - # - renum=[0,2,1,3,4,5,6,8,7,9] - mesh2.renumberCells(renum,False); - #self.assertTrue(f1.getMesh()==mesh1); - f1.changeUnderlyingMesh(mesh1,10,1e-12);# nothing done only to check that nothing done. - #self.assertTrue(f1.getMesh()==mesh1); - f1.changeUnderlyingMesh(mesh2,10,1e-12); - #self.assertTrue(f1.getMesh()==mesh2); - expected1=[7.,107.,9.,109.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.] - for i in xrange(20): - self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); - pass - # - f1=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr2=[7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.,17.,117.] - array.setValues(arr2,mesh1.getNumberOfNodes(),2); - f1.setArray(array); - # - renum2=[0,2,10,3,4,5,6,8,7,9,1] - mesh2.renumberNodes(renum2,11); - #self.assertTrue(f1.getMesh()==mesh1); - f1.changeUnderlyingMesh(mesh2,10,1e-12); - #self.assertTrue(f1.getMesh()==mesh2); - expected2=[7.,107.,9.,109.,17.,117.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,8.,108.] - for i in xrange(22): - self.assertAlmostEqual(expected2[i],f1.getArray().getIJ(0,i),12); - pass - pass - - def testGetMaxValue1(self): - m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - nbOfCells=m.getNumberOfCells(); - f=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); - f.setMesh(m); - a1=DataArrayDouble.New(); - val1=[3.,4.,5.,6.,7.] - a1.setValues(val1,nbOfCells,1); - a2=DataArrayDouble.New(); - val2=[0.,1.,2.,8.,7.] - a2.setValues(val2,nbOfCells,1); - f.setArray(a1); - f.setEndArray(a2); - f.setEndTime(3.,3,4); - f.checkCoherency(); - # - self.assertAlmostEqual(8.,f.getMaxValue(),14); - self.assertAlmostEqual(0.,f.getMinValue(),14); - self.assertAlmostEqual(5.,f.getAverageValue(),14); - self.assertAlmostEqual(5.125,f.getWeightedAverageValue(),14); - a1.setIJ(0,2,9.5); - self.assertAlmostEqual(9.5,f.getMaxValue(),14); - self.assertAlmostEqual(0.,f.getMinValue(),14); - a2.setIJ(0,0,9.); - self.assertAlmostEqual(9.5,f.getMaxValue(),14); - self.assertAlmostEqual(1.,f.getMinValue(),14); - pass - - def testSubstractInPlaceDM1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_3(); - mesh2=MEDCouplingDataForTest.build2DTargetMesh_3(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr=[7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.] - array.setValues(arr,mesh1.getNumberOfCells(),2); - f1.setArray(array); - # - self.assertEqual(10,f1.getNumberOfTuples()); - self.assertEqual(2,f1.getNumberOfComponents()); - self.assertEqual(20,f1.getNumberOfValues()); - # - renum=[0,2,1,3,4,5,6,8,7,9] - mesh2.renumberCells(renum,False); - # - f2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f2.setMesh(mesh2); - array=DataArrayDouble.New(); - arr2=[7.1,107.1,9.1,109.1,8.1,108.1,10.1,110.1,11.1,111.1,12.1,112.1,13.1,113.1,15.1,115.1,14.1,114.1,16.1,116.1] - array.setValues(arr2,mesh2.getNumberOfCells(),2); - f2.setArray(array); - # - f1.substractInPlaceDM(f2,10,1e-12); - f1.applyFunc(1,"abs(x+y+0.2)"); - self.assertAlmostEqual(0.,f1.getMaxValue(),13); - pass - - def testDotCrossProduct1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_3(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setTime(2.3,5,6); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[7.,107.,207.,8.,108.,208.,9.,109.,209.,10.,110.,210.,11.,111.,211.,12.,112.,212.,13.,113.,213.,14.,114.,214.,15.,115.,215.,16.,116.,216.] - array.setValues(arr1,mesh1.getNumberOfCells(),3); - f1.setArray(array); - f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f2.setTime(7.8,4,5); - f2.setMesh(mesh1); - array=DataArrayDouble.New(); - arr2=[1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.,26.,27.,28.,29.,30.] - array.setValues(arr2,mesh1.getNumberOfCells(),3); - f2.setArray(array); - # - f3=f1.dot(f2); - expected1=[842.,1820.,2816.,3830.,4862.,5912.,6980.,8066.,9170.,10292.] - for i in xrange(10): - self.assertAlmostEqual(expected1[i],f3.getIJ(i,0),9); - pass - # - f4=f1.crossProduct(f2); - expected2=[-93., 186., -93., -392., 784., -392., -691., 1382., -691., -990., 1980., -990., -1289., 2578., -1289., -1588., 3176., -1588., -1887., 3774., -1887., -2186., 4372., -2186., -2485., 4970., -2485., -2784., 5568., -2784.] - for i in xrange(30): - self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9); - pass - pass - - def testMinMaxFields1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_3(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setTime(2.3,5,6); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[7.,107.,207.,8.,108.,208.,9.,109.,209.,10.,110.,210.,11.,111.,211.,12.,112.,212.,13.,113.,213.,14.,114.,214.,15.,115.,215.,16.,116.,216.] - array.setValues(arr1,mesh1.getNumberOfCells(),3); - f1.setArray(array); - f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f2.setTime(7.8,4,5); - f2.setMesh(mesh1); - array=DataArrayDouble.New(); - arr2=[6.,108.,206.,9.,107.,209.,8.,110.,208.,11.,109.,211.,10.,112.,210.,13.,111.,213.,12.,114.,212.,15.,113.,215.,14.,116.,214.,17.,115.,217.] - array.setValues(arr2,mesh1.getNumberOfCells(),3); - f2.setArray(array); - # - f3=f1.max(f2); - expected1=[7.,108.,207.,9.,108.,209.,9.,110.,209.,11.,110.,211.,11.,112.,211.,13.,112.,213.,13.,114.,213.,15.,114.,215.,15.,116.,215.,17.,116.,217.] - for i in xrange(30): - self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),9); - pass - # - f4=f1.min(f2); - expected2=[6.,107.,206.,8.,107.,208.,8.,109.,208.,10.,109.,210.,10.,111.,210.,12.,111.,212.,12.,113.,212.,14.,113.,214.,14.,115.,214.,16.,115.,216.] - for i in xrange(30): - self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9); - pass - # - pass - - def testApplyLin1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_3(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr=[7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.] - array.setValues(arr,mesh1.getNumberOfCells(),2); - f1.setArray(array); - # - f1.applyLin(2.,3.,0); - expected1=[17.,107.,19.,108.,21.,109.,23.,110.,25.,111.,27.,112.,29.,113.,31.,114.,33.,115.,35.,116.] - for i in xrange(20): - self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),9); - pass - # - arr2=[2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.] - array=DataArrayDouble.New(); - array.setValues(arr2,mesh1.getNumberOfCells(),2); - f1.setEndArray(array); - # - f1.applyLin(4.,5.,1); - # - expected2=[17.,433.,19.,437.,21.,441.,23.,445.,25.,449.,27.,453.,29.,457.,31.,461.,33.,465.,35.,469.] - for i in xrange(20): - self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),9); - pass - expected3=[2.,413.,3.,417.,4.,421.,5.,425.,6.,429.,7.,433.,8.,437.,9.,441.,10.,445.,11.,449.] - for i in xrange(20): - self.assertAlmostEqual(expected3[i],f1.getEndArray().getIJ(0,i),9); - pass - # - pass - - def testGetIdsInRange1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_3(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setTime(2.3,5,6); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[2.,8.,6.,5.,11.,7.,9.,3.,10.,4.] - array.setValues(arr1,mesh1.getNumberOfCells(),1); - f1.setArray(array); - # - f1.checkCoherency(); - da=f1.getIdsInRange(2.9,7.1); - self.failUnlessEqual(5,da.getNbOfElems()); - expected1=[2,3,5,7,9] - self.failUnlessEqual(expected1,list(da.getValues())); - da=f1.getIdsInRange(8.,12.); - self.failUnlessEqual(4,da.getNbOfElems()); - expected2=[1,4,6,8] - self.failUnlessEqual(expected2,list(da.getValues())); - # - pass - - def testBuildSubPart1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setTime(2.3,5,6); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[3.,103.,4.,104.,5.,105.,6.,106.,7.,107.] - array.setValues(arr1,mesh1.getNumberOfCells(),2); - f1.setArray(array); - # - part1=[2,1,4] - f2=f1.buildSubPart(part1); - self.failUnlessEqual(3,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); - expected1=[5.,105.,4.,104.,7.,107.] - for i in xrange(6): - self.assertAlmostEqual(f2.getIJ(0,i),expected1[i],12); - pass - self.failUnlessEqual(3,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); - m2C=f2.getMesh(); - self.failUnlessEqual(13,m2C.getMeshLength()); - expected2=[0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7] - for i in xrange(12): - self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); - pass - expected3=[3,2,3,1,3,0,2,1,4,4,5,3,2] - self.failUnlessEqual(expected3,list(m2C.getNodalConnectivity().getValues())); - expected4=[0,4,8,13] - self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues())); - # Test with field on nodes. - f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME); - f1.setTime(2.3,5,6); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr2=[3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.] - array.setValues(arr2,mesh1.getNumberOfNodes(),2); - f1.setArray(array); - part2=[1,4,2,5] - f2=f1.buildSubPart(part2); - self.failUnlessEqual(4,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); - expected5=[4.,104.,5.,105.,7.,107.,8.,108.] - for i in xrange(8): - self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12); - pass - self.failUnlessEqual(2,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); - m2C=f2.getMesh(); - self.failUnlessEqual(8,m2C.getMeshLength()); - for i in xrange(8):#8 is not an error - self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); - pass - self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:]); - self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]); - self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues())); - #idem previous because nodes of cell#4 are not fully present in part3 - part3=[1,4,2,5,7] - arrr=DataArrayInt.New(); - arrr.setValues(part3,5,1); - f2=f1.buildSubPart(arrr); - self.failUnlessEqual(4,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); - for i in xrange(8): - self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12); - pass - self.failUnlessEqual(2,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); - m2C=f2.getMesh(); - self.failUnlessEqual(8,m2C.getMeshLength()); - for i in xrange(8):#8 is not an error - self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); - pass - self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:8]); - self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]); - self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues())); - # - part4=[1,4,2,5,7,8] - f2=f1.buildSubPart(part4); - self.failUnlessEqual(6,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); - expected6=[4.,104.,5.,105.,7.,107.,8.,108.,10.,110.,11.,111.] - for i in xrange(12): - self.assertAlmostEqual(f2.getIJ(0,i),expected6[i],12); - pass - self.failUnlessEqual(3,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); - m2C=f2.getMesh(); - self.failUnlessEqual(13,m2C.getMeshLength()); - for i in xrange(12): - self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); - pass - self.failUnlessEqual(expected3[0:4],list(m2C.getNodalConnectivity().getValues())[4:8]); - self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[0:4]); - self.failUnlessEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13]); - self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues())); - pass - - def testDoublyContractedProduct1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] - array.setValues(arr1,mesh1.getNumberOfCells(),6); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.doublyContractedProduct(); - f2.checkCoherency(); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(3906.56,f2.getIJ(i,0),9); - pass - # - pass - - def testDeterminant1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); - f1.setTime(2.3,5,6); - f1.setEndTime(3.8,7,3); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5] - array.setValues(arr1,mesh1.getNumberOfCells(),4); - f1.setArray(array); - #4 components - f1.checkCoherency(); - f2=f1.determinant(); - f2.checkCoherency(); - self.assertEqual(CONST_ON_TIME_INTERVAL,f2.getTimeDiscretization()); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfValues()); - for i in xrange(5): - self.assertAlmostEqual(-2.42,f2.getIJ(i,0),13); - pass - #6 components multi arrays with end array not defined - f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME); - f1.setTime(2.3,5,6); - f1.setEndTime(3.8,7,3); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr2=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, - 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] - array.setValues(arr2,mesh1.getNumberOfNodes(),6); - f1.setArray(array); - self.assertRaises(Exception,f1.checkCoherency);#no end array specified ! - # - f2=f1.determinant(); - self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization()); - self.assertEqual(1,f2.getArray().getNumberOfComponents()); - self.assertEqual(9,f2.getNumberOfTuples()); - for i in xrange(9): - self.assertAlmostEqual(137.335,f2.getIJ(i,0),10); - pass - #6 components multi arrays with end array defined - array=DataArrayDouble.New(); - arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, - 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] - array.setValues(arr3,mesh1.getNumberOfNodes(),6); - f1.setEndArray(array); - f1.checkCoherency(); - f2=f1.determinant(); - f2.checkCoherency(); - self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization()); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(9,f2.getNumberOfTuples()); - time2,it,order=f2.getTime() - self.assertAlmostEqual(2.3,time2,12); - self.assertEqual(5,it); - self.assertEqual(6,order); - time2,it,order=f2.getEndTime() - self.assertAlmostEqual(3.8,time2,12); - self.assertEqual(7,it); - self.assertEqual(3,order); - for i in xrange(9): - self.assertAlmostEqual(137.335,f2.getIJ(i,0),10); - self.assertAlmostEqual(1289.685,f2.getEndArray().getIJ(i,0),9); - pass - #9 components - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setTime(7.8,10,2); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr4=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1] - array.setValues(arr4,mesh1.getNumberOfCells(),9); - f1.setArray(array); - # - f1.checkCoherency(); - f2=f1.determinant(); - f2.checkCoherency(); - self.assertEqual(ONE_TIME,f2.getTimeDiscretization()); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - time2,it,order=f2.getTime() - self.assertAlmostEqual(7.8,time2,12); - self.assertEqual(10,it); - self.assertEqual(2,order); - for i in xrange(5): - self.assertAlmostEqual(3.267,f2.getIJ(i,0),13); - pass - pass - - def testEigenValues1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] - array.setValues(arr1,mesh1.getNumberOfCells(),6); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.eigenValues(); - f2.checkCoherency(); - self.assertEqual(3,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - expected1=[13.638813677891717,-4.502313844635971,-2.2364998332557486] - for i in xrange(5): - self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); - self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); - self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); - pass - pass - - def testEigenVectors1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] - array.setValues(arr1,mesh1.getNumberOfCells(),6); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.eigenVectors(); - f2.checkCoherency(); - self.assertEqual(9,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - expected1=[0.5424262364180696, 0.5351201064614425, 0.6476266283176001,#eigenvect 0 - 0.7381111277307373, 0.06458838384003074, -0.6715804522117897,#eigenvect 1 - -0.4012053603397987, 0.8423032781211455, -0.3599436712889738#eigenvect 2 - ] - for i in xrange(5): - self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); - self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); - self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); - self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13); - self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13); - self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13); - self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13); - self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13); - self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13); - pass - # - pass - - def testInverse1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1] - array.setValues(arr1,mesh1.getNumberOfCells(),9); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.inverse(); - f2.checkCoherency(); - self.assertEqual(9,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - expected1=[-2.6538108356290113, 2.855831037649208, -1.1111111111111067, 3.461891643709813, -4.775022956841121, 2.2222222222222143, -1.1111111111111054, 2.222222222222214, -1.1111111111111072] - for i in xrange(5): - self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); - self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); - self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); - self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13); - self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13); - self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13); - self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13); - self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13); - self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13); - pass - # - array=DataArrayDouble.New(); - arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] - array.setValues(arr3,mesh1.getNumberOfCells(),6); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.inverse(); - f2.checkCoherency(); - self.assertEqual(6,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - expected3=[-0.3617705098531818, -0.8678630828458127, -0.026843764174972983, 0.5539957431465833, 0.13133439560823013, -0.05301294502145887] - for i in xrange(5): - self.assertAlmostEqual(expected3[0],f2.getIJ(i,0),13); - self.assertAlmostEqual(expected3[1],f2.getIJ(i,1),13); - self.assertAlmostEqual(expected3[2],f2.getIJ(i,2),13); - self.assertAlmostEqual(expected3[3],f2.getIJ(i,3),13); - self.assertAlmostEqual(expected3[4],f2.getIJ(i,4),13); - self.assertAlmostEqual(expected3[5],f2.getIJ(i,5),13); - pass - # - array=DataArrayDouble.New(); - arr2=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5] - array.setValues(arr2,mesh1.getNumberOfCells(),4); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.inverse(); - f2.checkCoherency(); - self.assertEqual(4,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - expected2=[-1.8595041322314059, 0.9504132231404963, 1.404958677685951, -0.49586776859504156] - for i in xrange(5): - self.assertAlmostEqual(expected2[0],f2.getIJ(i,0),13); - self.assertAlmostEqual(expected2[1],f2.getIJ(i,1),13); - self.assertAlmostEqual(expected2[2],f2.getIJ(i,2),13); - self.assertAlmostEqual(expected2[3],f2.getIJ(i,3),13); - pass - # - pass - - def testTrace1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1] - array.setValues(arr1,mesh1.getNumberOfCells(),9); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.trace(); - f2.checkCoherency(); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(15.9,f2.getIJ(i,0),13); - pass - # - array=DataArrayDouble.New(); - arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] - array.setValues(arr3,mesh1.getNumberOfCells(),6); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.trace(); - f2.checkCoherency(); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(25.8,f2.getIJ(i,0),13); - pass - # - array=DataArrayDouble.New(); - arr2=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5] - array.setValues(arr2,mesh1.getNumberOfCells(),4); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.trace(); - f2.checkCoherency(); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(5.7,f2.getIJ(i,0),13); - pass - # - pass - - def testDeviator1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] - array.setValues(arr1,mesh1.getNumberOfCells(),6); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.deviator(); - f2.checkCoherency(); - self.assertEqual(6,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - expected1=[-1.1,0.,1.1,4.5,5.6,6.7] - for i in xrange(5): - self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); - self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); - self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); - self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13); - self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13); - self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13); - pass - # - pass - - def testMagnitude1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6] - array.setValues(arr1,mesh1.getNumberOfCells(),5); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.magnitude(); - f2.checkCoherency(); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(8.3606219864313918,f2.getIJ(i,0),13); - pass - # - pass - - def testMaxPerTuple1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4] - array.setValues(arr1,mesh1.getNumberOfCells(),5); - f1.setArray(array); - f1.checkCoherency(); - # - f2=f1.maxPerTuple(); - f2.checkCoherency(); - self.assertEqual(1,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(5.6,f2.getIJ(i,0),13); - pass - # - pass - - def testChangeNbOfComponents(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4] - array.setValues(arr1,mesh1.getNumberOfCells(),5); - f1.setArray(array); - f1.checkCoherency(); - # - f1.changeNbOfComponents(3,7.77); - f1.checkCoherency(); - self.assertEqual(3,f1.getNumberOfComponents()); - self.assertEqual(5,f1.getNumberOfTuples()); - expected1=[1.2,2.3,3.4, 1.2,3.4,4.5, 3.4,4.5,5.6, 5.6,1.2,2.3, 4.5,5.6,1.2] - for i in xrange(15): - self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),13); - pass - f1.changeNbOfComponents(4,7.77); - f1.checkCoherency(); - self.assertEqual(4,f1.getNumberOfComponents()); - self.assertEqual(5,f1.getNumberOfTuples()); - expected2=[1.2,2.3,3.4,7.77, 1.2,3.4,4.5,7.77, 3.4,4.5,5.6,7.77, 5.6,1.2,2.3,7.77, 4.5,5.6,1.2,7.77] - for i in xrange(20): - self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),13); - pass - # - pass - - def testSortPerTuple1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); - f1.setMesh(mesh1); - array=DataArrayDouble.New(); - arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4] - array.setValues(arr1,mesh1.getNumberOfCells(),5); - f1.setArray(array); - f1.checkCoherency(); - # - f1.sortPerTuple(True); - f1.checkCoherency(); - self.assertEqual(5,f1.getNumberOfComponents()); - self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(arr1[0],f1.getIJ(i,0),13); - self.assertAlmostEqual(arr1[1],f1.getIJ(i,1),13); - self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13); - self.assertAlmostEqual(arr1[3],f1.getIJ(i,3),13); - self.assertAlmostEqual(arr1[4],f1.getIJ(i,4),13); - pass - # - f1.sortPerTuple(False); - f1.checkCoherency(); - self.assertEqual(5,f1.getNumberOfComponents()); - self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): - self.assertAlmostEqual(arr1[4],f1.getIJ(i,0),13); - self.assertAlmostEqual(arr1[3],f1.getIJ(i,1),13); - self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13); - self.assertAlmostEqual(arr1[1],f1.getIJ(i,3),13); - self.assertAlmostEqual(arr1[0],f1.getIJ(i,4),13); - pass - # - pass - - def testIsEqualWithoutConsideringStr1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - mesh2=MEDCouplingDataForTest.build2DTargetMesh_1(); - # - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2.setName("rr"); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - da1,da2=mesh1.checkGeoEquivalWith(mesh2,2,1e-12); - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12); - mesh2.setName(""); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2.getCoords().setInfoOnComponent(0,"tty"); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2.getCoords().setInfoOnComponent(0,""); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2.getCoords().setInfoOnComponent(1,"tty"); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2.getCoords().setInfoOnComponent(1,""); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - tmp=mesh2.getCoords().getIJ(0,3); - mesh2.getCoords().setIJ(0,3,9999.); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(not mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2.getCoords().setIJ(0,3,tmp); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - tmp2=mesh2.getNodalConnectivity().getIJ(0,4); - mesh2.getNodalConnectivity().setIJ(0,4,0); - self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(not mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - mesh2.getNodalConnectivity().setIJ(0,4,tmp2); - self.assertTrue(mesh1.isEqual(mesh2,1e-12)); - self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); - # - f1=mesh1.getMeasureField(True); - f2=mesh2.getMeasureField(True); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f2.setName("ftest"); - self.assertTrue(not f1.isEqual(f2,1e-12,1e-12)); - self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f1.setName("ftest"); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - # - f2.getArray().setInfoOnComponent(0,"eee"); - self.assertTrue(not f1.isEqual(f2,1e-12,1e-12)); - self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f2.getArray().setInfoOnComponent(0,""); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - # - f2.getArray().setIJ(1,0,0.123); - self.assertTrue(not f1.isEqual(f2,1e-12,1e-12)); - self.assertTrue(not f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - f2.getArray().setIJ(1,0,0.125); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12)); - # - pass - def testGetNodeIdsOfCell1(self): - mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); - li=mesh1.getNodeIdsOfCell(1) - expected1=[1, 4, 2] - self.assertEqual(expected1,list(li)) - li=mesh1.getCoordinatesOfNode(4) - self.assertEqual(2,len(li)) - self.assertAlmostEqual(0.2,li[0],13); - self.assertAlmostEqual(0.2,li[1],13); - li=mesh1.getCoords().getValuesAsTuple() - self.assertEqual(9,len(li)) - li2=mesh1.getNodalConnectivityIndex().getValuesAsTuple() - self.assertEqual(6,len(li2)) - pass - - def testGetEdgeRatioField1(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - f1=m1.getEdgeRatioField(); - self.assertEqual(m1.getNumberOfCells(),f1.getNumberOfTuples()); - self.assertEqual(5,f1.getNumberOfTuples()); - self.assertEqual(1,f1.getNumberOfComponents()); - expected1=[1.,1.4142135623730951, 1.4142135623730951,1.,1.] - for i in xrange(5): - self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),14); - pass - # - m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); - f1=m1.getEdgeRatioField(); - self.assertEqual(m1.getNumberOfCells(),f1.getNumberOfTuples()); - self.assertEqual(5,f1.getNumberOfTuples()); - self.assertEqual(1,f1.getNumberOfComponents()); - expected2=[1.4142135623730951, 1.7320508075688772, 1.7320508075688772, 1.4142135623730951, 1.4142135623730951] - for i in xrange(5): - self.assertAlmostEqual(expected2[i],f1.getIJ(i,0),14); - pass - pass - - def setUp(self): - pass - pass - -unittest.main() diff --git a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py deleted file mode 100644 index d152e2a4b..000000000 --- a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py +++ /dev/null @@ -1,338 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libMEDCoupling_Swig import * - -class MEDCouplingDataForTest: - def build2DTargetMesh_1(cls): - targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]; - targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]; - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(5); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]); - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,9,2); - targetMesh.setCoords(myCoords); - return targetMesh; - def build2DSourceMesh_1(cls): - sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7] - sourceConn=[0,3,1,0,2,3] - sourceMesh=MEDCouplingUMesh.New("my name of mesh 2D",2); - sourceMesh.allocateCells(2); - sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[0:3]); - sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[3:6]); - sourceMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(sourceCoords,4,2); - sourceMesh.setCoords(myCoords); - return sourceMesh; - - def build3DTargetMesh_1(cls): - targetCoords=[ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. , - 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. ]; - targetConn=[0,1,4,3,9,10,13,12, 1,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16, - 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25]; - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(3); - targetMesh.allocateCells(12); - for i in xrange(8): - targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*i+8]); - pass - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,27,3); - targetMesh.setCoords(myCoords); - return targetMesh - - def build3DSurfTargetMesh_1(self): - targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5] - targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(5); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,9,3); - targetMesh.setCoords(myCoords); - return targetMesh; - - def build3DExtrudedUMesh_1(self): - coords=[ - 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., - 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., - 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., - 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1., - 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., - 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2., - 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., - 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.] - - conn=[ - # 0 - 0,11,1,3,15,26,16,18, 1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17, - 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21, - 11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23, - 7,12,14,13,22,27,29,28, - # 1 - 15,26,16,18,30,41,31,33, 16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32, - 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36, - 26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38, - 22,27,29,28,37,42,44,43, - # 2 - 30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47, - 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51, - 41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53, - 37,42,44,43,52,57,59,58] - conn2=[7,12,14,13, 11,8,7,4,2,1, 13,10,9,6, 1,6,5,3, 1,2,4,7,13,6, 0,11,1,3] - # - ret=MEDCouplingUMesh.New(); - ret.setMeshDimension(3); - ret.allocateCells(18); - # - ret.insertNextCell(NORM_HEXA8,8,conn[0:8]); - ret.insertNextCell(NORM_POLYHED,43,conn[8:51]); - ret.insertNextCell(NORM_HEXA8,8,conn[51:59]); - ret.insertNextCell(NORM_HEXA8,8,conn[59:67]); - ret.insertNextCell(NORM_POLYHED,43,conn[67:110]); - ret.insertNextCell(NORM_HEXA8,8,conn[110:118]); - # - ret.insertNextCell(NORM_HEXA8,8,conn[118:126]); - ret.insertNextCell(NORM_POLYHED,43,conn[126:169]); - ret.insertNextCell(NORM_HEXA8,8,conn[169:177]); - ret.insertNextCell(NORM_HEXA8,8,conn[177:185]); - ret.insertNextCell(NORM_POLYHED,43,conn[185:228]); - ret.insertNextCell(NORM_HEXA8,8,conn[228:236]); - # - ret.insertNextCell(NORM_HEXA8,8,conn[236:244]); - ret.insertNextCell(NORM_POLYHED,43,conn[244:287]); - ret.insertNextCell(NORM_HEXA8,8,conn[287:295]); - ret.insertNextCell(NORM_HEXA8,8,conn[295:303]); - ret.insertNextCell(NORM_POLYHED,43,conn[303:346]); - ret.insertNextCell(NORM_HEXA8,8,conn[346:354]); - # - ret.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,60,3); - ret.setCoords(myCoords); - # - mesh2D=MEDCouplingUMesh.New(); - mesh2D.setMeshDimension(2); - mesh2D.allocateCells(6); - mesh2D.insertNextCell(NORM_QUAD4,4,conn2[0:4]); - mesh2D.insertNextCell(NORM_POLYGON,6,conn2[4:10]); - mesh2D.insertNextCell(NORM_QUAD4,4,conn2[10:14]); - mesh2D.insertNextCell(NORM_QUAD4,4,conn2[14:18]); - mesh2D.insertNextCell(NORM_POLYGON,6,conn2[18:24]); - mesh2D.insertNextCell(NORM_QUAD4,4,conn2[24:28]); - mesh2D.setCoords(myCoords); - return ret,mesh2D - - def buildCU1DMesh_U(self): - coords=[ 0.0, 0.3, 0.75, 1.0 ] - conn=[ 0,1, 1,2, 2,3 ] - mesh=MEDCouplingUMesh.New(); - mesh.setMeshDimension(1); - mesh.allocateCells(3); - mesh.insertNextCell(NORM_SEG2,2,conn[0:2]); - mesh.insertNextCell(NORM_SEG2,2,conn[2:4]); - mesh.insertNextCell(NORM_SEG2,2,conn[4:6]); - mesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,4,1); - mesh.setCoords(myCoords); - return mesh; - - def build2DTargetMeshMergeNode_1(self): - targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,-0.3, 0.2,-0.3, 0.2,-0.3, 0.2,0.2, 0.2,0.2, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, 0.2,0.7 ] - targetConn=[0,9,7,5, 4,6,2, 10,11,8, 9,14,15,7, 17,16,13,6] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(5); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]); - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,18,2); - targetMesh.setCoords(myCoords); - return targetMesh; - - def build3DTargetMeshMergeNode_1(self): - targetCoords=[ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. , - 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200., 50.,0.,0., 50.,0.,0., 50.,0.,0., 200., 50., 200.] - targetConn=[0,29,4,3,9,10,13,12, 28,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16, - 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,30,26,25] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(3); - targetMesh.allocateCells(12); - for i in xrange(8): - targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*(i+1)]); - pass - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,31,3); - targetMesh.setCoords(myCoords); - return targetMesh; - - def build2DTargetMeshMerged_1(self): - targetCoords=[ - -0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, - 0.7,-0.3, 1.7,-0.3, 0.7,0.7, 1.7,0.7 - ] - targetConn=[ - 0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4, - 9,12,10,9,11,12 - ] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setName("merge"); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(10); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[18:21]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[21:24]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,13,2); - targetMesh.setCoords(myCoords); - return targetMesh; - - def build2DTargetMesh_2(cls): - targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ] - targetConn=[0,3,4, 0,4,1, 1,4,2, 4,5,2, 3,6,4, 6,7,4, 4,7,5, 7,8,5 ] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(8); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[6:9]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[9:12]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[12:15]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[15:18]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[18:21]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[21:24]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,9,2); - targetMesh.setCoords(myCoords); - return targetMesh; - - def build1DTargetMesh_3(cls): - ret=MEDCouplingUMesh.New("1DMesh_3",1); - ret.allocateCells(4); - conn=[0,1,2, 3,4, 6,5,7 ,9,8] - ret.insertNextCell(NORM_SEG3,3,conn[0:3]) - ret.insertNextCell(NORM_SEG2,2,conn[3:5]) - ret.insertNextCell(NORM_SEG3,3,conn[5:8]) - ret.insertNextCell(NORM_SEG2,2,conn[8:10]) - ret.finishInsertingCells(); - coords=[0.5,1.,0.8,5.,5.21,0.5,1.1,0.7,5.,5.31] - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,10,1); - ret.setCoords(myCoords); - return ret; - - def build2DCurveTargetMesh_3(cls): - ret=MEDCouplingUMesh.New("2DCurveMesh_3",1); - ret.allocateCells(4); - conn=[0,1,2, 3,4, 6,5,7 ,9,8] - ret.insertNextCell(NORM_SEG3,3,conn[0:3]) - ret.insertNextCell(NORM_SEG2,2,conn[3:5]) - ret.insertNextCell(NORM_SEG3,3,conn[5:8]) - ret.insertNextCell(NORM_SEG2,2,conn[8:10]) - ret.finishInsertingCells(); - coords=[0.5,0.5,1.,1.,0.8,0.8,5.,5.,5.21,5.21,0.5,0.5,1.1,1.1,0.7,0.7,5.,5.,5.31,5.31] - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,10,2); - ret.setCoords(myCoords); - return ret; - - def build2DTargetMesh_3(cls): - ret=MEDCouplingUMesh.New("2DMesh_3",2); - ret.allocateCells(10); - conn=[0,1,2, 0,1,3,4, 0,1,3,5,4, 0,1,2,6,7,8, 0,1,3,4,6,9,2,10, 0,2,1, 0,4,3,1, 0,4,5,3,1, 0,2,1,8,7,6, 0,4,3,1,10,2,9,6] - ret.insertNextCell(NORM_TRI3,3,conn[0:3]) - ret.insertNextCell(NORM_QUAD4,4,conn[3:7]) - ret.insertNextCell(NORM_POLYGON,5,conn[7:12]) - ret.insertNextCell(NORM_TRI6,6,conn[12:18]) - ret.insertNextCell(NORM_QUAD8,8,conn[18:26]) - ret.insertNextCell(NORM_TRI3,3,conn[26:29]) - ret.insertNextCell(NORM_QUAD4,4,conn[29:33]) - ret.insertNextCell(NORM_POLYGON,5,conn[33:38]) - ret.insertNextCell(NORM_TRI6,6,conn[38:44]) - ret.insertNextCell(NORM_QUAD8,8,conn[44:52]) - ret.finishInsertingCells(); - coords=[0.,0.,1.,0.,0.5,1.,1.,1.,0.,1.,0.5,2.,0.5,0.,0.75,0.5,0.25,0.5,1.,0.5,0.,0.5] - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,11,2); - ret.setCoords(myCoords); - ret.checkCoherency(); - return ret; - - def build2DTargetMesh_4(cls): - targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ] - targetConn=[0,4,5,1, 1,5,3, 5,6,2, 7,8,5,4, 8,9,6,5] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(5); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,10,2); - targetMesh.setCoords(myCoords); - return targetMesh; - - build2DTargetMesh_1=classmethod(build2DTargetMesh_1) - build2DSourceMesh_1=classmethod(build2DSourceMesh_1) - build3DTargetMesh_1=classmethod(build3DTargetMesh_1) - build3DSurfTargetMesh_1=classmethod(build3DSurfTargetMesh_1) - build3DExtrudedUMesh_1=classmethod(build3DExtrudedUMesh_1) - buildCU1DMesh_U=classmethod(buildCU1DMesh_U) - build2DTargetMeshMergeNode_1=classmethod(build2DTargetMeshMergeNode_1) - build3DTargetMeshMergeNode_1=classmethod(build3DTargetMeshMergeNode_1) - build2DTargetMeshMerged_1=classmethod(build2DTargetMeshMerged_1) - build2DTargetMesh_2=classmethod(build2DTargetMesh_2) - build1DTargetMesh_3=classmethod(build1DTargetMesh_3) - build2DCurveTargetMesh_3=classmethod(build2DCurveTargetMesh_3) - build2DTargetMesh_3=classmethod(build2DTargetMesh_3) - build2DTargetMesh_4=classmethod(build2DTargetMesh_4) - pass diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py deleted file mode 100644 index 4be38ae90..000000000 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ /dev/null @@ -1,86 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libMEDCouplingRemapper_Swig import * -from math import * -import unittest - -class MEDCouplingBasicsTest(unittest.TestCase): - def testRemapper1(self): - sourceMesh=self.build2DSourceMesh_1(); - targetMesh=self.build2DTargetMesh_1(); - remapper=MEDCouplingRemapper() - remapper.setPrecision(1e-12); - remapper.setIntersectionType(Triangulation); - self.failUnless(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1); - srcField=MEDCouplingFieldDouble.New(ON_CELLS); - srcField.setNature(ConservativeVolumic); - srcField.setMesh(sourceMesh); - array=DataArrayDouble.New(); - ptr=sourceMesh.getNumberOfCells()*[None] - for i in xrange(sourceMesh.getNumberOfCells()): - ptr[i]=float(i+7) - pass - array.setValues(ptr,sourceMesh.getNumberOfCells(),1); - srcField.setArray(array); - trgfield=remapper.transferField(srcField,4.57); - values=trgfield.getArray().getValues(); - valuesExpected=[7.5 ,7. ,7.,8.,7.5]; - for i in xrange(targetMesh.getNumberOfCells()): - self.failUnless(abs(values[i]-valuesExpected[i])<1e-12); - pass - self.failUnless(1==trgfield.getArray().getNumberOfComponents()); - pass - - def build2DSourceMesh_1(self): - sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7] - sourceConn=[0,3,1,0,2,3] - sourceMesh=MEDCouplingUMesh.New("my name of mesh 2D",2) - sourceMesh.allocateCells(2); - sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[0:3]); - sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[3:6]); - sourceMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(sourceCoords,4,2); - sourceMesh.setCoords(myCoords); - return sourceMesh; - - def build2DTargetMesh_1(self): - targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ] - targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(5); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]); - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]); - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,9,2); - targetMesh.setCoords(myCoords); - return targetMesh; - - def setUp(self): - pass - pass - -unittest.main() diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i deleted file mode 100644 index b5d9b2a29..000000000 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - -#ifdef WITH_NUMPY2 -#include -#endif - -static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner) -{ - PyObject *ret; - if(dynamic_cast(mesh)) - ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner); - if(dynamic_cast(mesh)) - ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingExtrudedMesh,owner); - return ret; -} - -static PyObject *convertIntArrToPyList(const int *ptr, int size) -{ -#ifndef WITH_NUMPY2 - PyObject *ret=PyList_New(size); - for(int i=0;i(tmp)); -#endif -} - -static PyObject *convertIntArrToPyList2(const std::vector& v) -{ -#ifndef WITH_NUMPY2 - int size=v.size(); - PyObject *ret=PyList_New(size); - for(int i=0;i& arr) -{ - if(PyList_Check(pyLi)) - { - int size=PyList_Size(pyLi); - arr.resize(size); - for(int i=0;i& v) -{ - int size=v.size(); - PyObject *ret=PyList_New(size); - for(int i=0;i& v) -{ - if(PyList_Check(ms)) - { - int size=PyList_Size(ms); - v.resize(size); - for(int i=0;i(argp); - v[i]=arg; - } - } - else - { - PyErr_SetString(PyExc_TypeError,"convertPyObjToVecUMeshes : not a list"); - PyErr_Print(); - } -} - -void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector& v) -{ - if(PyList_Check(ms)) - { - int size=PyList_Size(ms); - v.resize(size); - for(int i=0;i(argp); - v[i]=arg; - } - } - else - { - PyErr_SetString(PyExc_TypeError,"convertPyObjToVecDataArrayInt : not a list"); - PyErr_Print(); - } -} diff --git a/src/MEDCoupling_Swig/Makefile.am b/src/MEDCoupling_Swig/Makefile.am deleted file mode 100644 index fd14551f1..000000000 --- a/src/MEDCoupling_Swig/Makefile.am +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (C) 2007-2010 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 -# - -# MED MEDCoupling_Swig : binding of C++ implementation and Python -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES = _libMEDCoupling_Swig.la _libMEDCouplingRemapper_Swig.la - -salomeinclude_HEADERS = \ - libMEDCoupling_Swig.i libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i - -BUILT_SOURCES = libMEDCoupling_SwigWRAP.cxx libMEDCouplingRemapper_SwigWRAP.cxx - -SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../INTERP_KERNEL - -dist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_Swig.i MEDCouplingTypemaps.i -nodist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_SwigWRAP.cxx -libMEDCoupling_Swig.py: libMEDCoupling_SwigWRAP.cxx - -libMEDCoupling_SwigWRAP.cxx: libMEDCoupling_Swig.i MEDCouplingTypemaps.i - $(SWIG) $(SWIG_FLAGS) -o $@ $< - -_libMEDCoupling_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \ - @CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases - -_libMEDCoupling_Swig_la_LDFLAGS = -module $(PYTHON_LIBS) \ - ../MEDCoupling/libmedcoupling.la ../INTERP_KERNEL/libinterpkernel.la - -dist__libMEDCouplingRemapper_Swig_la_SOURCES = libMEDCouplingRemapper_Swig.i -nodist__libMEDCouplingRemapper_Swig_la_SOURCES = libMEDCouplingRemapper_SwigWRAP.cxx -libMEDCouplingRemapper_Swig.py: libMEDCouplingRemapper_SwigWRAP.cxx - -libMEDCouplingRemapper_SwigWRAP.cxx: libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i - $(SWIG) $(SWIG_FLAGS) -o $@ $< - -_libMEDCouplingRemapper_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \ - @CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases - -_libMEDCouplingRemapper_Swig_la_LDFLAGS = -module $(PYTHON_LIBS) \ - ../MEDCoupling/libmedcouplingremapper.la ../INTERP_KERNEL/libinterpkernel.la - -CLEANFILES = libMEDCoupling_SwigWRAP.cxx libMEDCoupling_Swig.py libMEDCouplingRemapper_SwigWRAP.cxx libMEDCouplingRemapper_Swig.py - -dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py libMEDCoupling_Swig.py libMEDCouplingRemapper_Swig.py MEDCouplingDataForTest.py - -UNIT_TEST_PROG = MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py - -#check : tests diff --git a/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i b/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i deleted file mode 100644 index b46f81984..000000000 --- a/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - -%module libMEDCouplingRemapper_Swig - -#define MEDCOUPLING_EXPORT -#define INTERPKERNEL_EXPORT -#define MEDCOUPLINGREMAPPER_EXPORT - -%{ -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingField.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingRemapper.hxx" - -using namespace ParaMEDMEM; -using namespace INTERP_KERNEL; -%} - -%newobject ParaMEDMEM::MEDCouplingRemapper::transferField; -%newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField; - -%include "libMEDCoupling_Swig.i" -%include "InterpolationOptions.hxx" -%include "MEDCouplingRemapper.hxx" diff --git a/src/MEDCoupling_Swig/libMEDCoupling_Swig.i b/src/MEDCoupling_Swig/libMEDCoupling_Swig.i deleted file mode 100644 index 48a7115d9..000000000 --- a/src/MEDCoupling_Swig/libMEDCoupling_Swig.i +++ /dev/null @@ -1,1139 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - -%module libMEDCoupling_Swig - -#define MEDCOUPLING_EXPORT - -%include std_vector.i -%include std_string.i - -%{ -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingCMesh.hxx" -#include "MEDCouplingField.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingGaussLocalization.hxx" -#include "MEDCouplingTypemaps.i" - -using namespace ParaMEDMEM; -using namespace INTERP_KERNEL; -%} - -%template(ivec) std::vector; -%template(dvec) std::vector; -%template(svec) std::vector; - -%typemap(out) ParaMEDMEM::MEDCouplingMesh* -{ - $result=convertMesh($1,$owner); -} - -%typemap(out) ParaMEDMEM::MEDCouplingPointSet* -{ - $result=convertMesh($1,$owner); -} - -#ifdef WITH_NUMPY2 -%init %{ import_array(); %} -#endif - -%feature("autodoc", "1"); -%feature("docstring"); - -%newobject ParaMEDMEM::DataArrayDouble::New; -%newobject ParaMEDMEM::DataArrayInt::New; -%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr; -%newobject ParaMEDMEM::DataArrayInt::convertToDblArr; -%newobject ParaMEDMEM::MEDCouplingUMesh::New; -%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::New; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::mergeFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::determinant; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenValues; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenVectors; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::inverse; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::trace; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::deviator; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::dotFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProductFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProduct; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::max; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::minFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::min; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::getIdsInRange; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator+; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator-; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator*; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator/; -%newobject ParaMEDMEM::MEDCouplingUMesh::clone; -%newobject ParaMEDMEM::DataArrayDouble::deepCopy; -%newobject ParaMEDMEM::DataArrayDouble::performCpy; -%newobject ParaMEDMEM::DataArrayInt::deepCopy; -%newobject ParaMEDMEM::DataArrayInt::performCpy; -%newobject ParaMEDMEM::DataArrayInt::substr; -%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents; -%newobject ParaMEDMEM::DataArrayInt::selectByTupleId; -%newobject ParaMEDMEM::DataArrayDouble::aggregate; -%newobject ParaMEDMEM::DataArrayDouble::dot; -%newobject ParaMEDMEM::DataArrayDouble::crossProduct; -%newobject ParaMEDMEM::DataArrayDouble::add; -%newobject ParaMEDMEM::DataArrayDouble::substract; -%newobject ParaMEDMEM::DataArrayDouble::multiply; -%newobject ParaMEDMEM::DataArrayDouble::divide; -%newobject ParaMEDMEM::DataArrayDouble::substr; -%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents; -%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange; -%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId; -%newobject ParaMEDMEM::DataArrayDouble::applyFunc; -%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct; -%newobject ParaMEDMEM::DataArrayDouble::determinant; -%newobject ParaMEDMEM::DataArrayDouble::eigenValues; -%newobject ParaMEDMEM::DataArrayDouble::eigenVectors; -%newobject ParaMEDMEM::DataArrayDouble::inverse; -%newobject ParaMEDMEM::DataArrayDouble::trace; -%newobject ParaMEDMEM::DataArrayDouble::deviator; -%newobject ParaMEDMEM::DataArrayDouble::magnitude; -%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis; -%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner; -%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner; -%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField; -%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds; -%newobject ParaMEDMEM::MEDCouplingMesh::buildPart; -%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith; -%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic; -%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer; -%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity; -%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh; -%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMeshFromThis; -%newobject ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt; -%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes; -%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType; -%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField; -%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New; -%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh; -%newobject ParaMEDMEM::MEDCouplingCMesh::New; -%feature("unref") DataArrayDouble "$this->decrRef();" -%feature("unref") MEDCouplingPointSet "$this->decrRef();" -%feature("unref") MEDCouplingMesh "$this->decrRef();" -%feature("unref") MEDCouplingUMesh "$this->decrRef();" -%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();" -%feature("unref") MEDCouplingCMesh "$this->decrRef();" -%feature("unref") DataArrayInt "$this->decrRef();" -%feature("unref") MEDCouplingField "$this->decrRef();" -%feature("unref") MEDCouplingFieldDouble "$this->decrRef();" - -%ignore ParaMEDMEM::TimeLabel::operator=; -%ignore ParaMEDMEM::MemArray::operator=; -%ignore ParaMEDMEM::MemArray::operator[]; -%ignore ParaMEDMEM::MEDCouplingPointSet::getCoords(); -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo; -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo; -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues; -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo; -%rename (Exception) InterpKernelException; -%nodefaultctor; - -namespace INTERP_KERNEL -{ - class Exception - { - public: - Exception(const char* what); - ~Exception() throw (); - const char *what() const throw (); - }; -} - -%include "MEDCouplingTimeLabel.hxx" -%include "MEDCouplingRefCountObject.hxx" - -namespace ParaMEDMEM -{ - typedef enum - { - UNSTRUCTURED = 5, - UNSTRUCTURED_DESC = 6, - CARTESIAN = 7, - EXTRUDED = 8 - } MEDCouplingMeshType; - - class DataArrayInt; - class DataArrayDouble; - class MEDCouplingFieldDouble; - - class MEDCouplingMesh : public RefCountObject, public TimeLabel - { - public: - void setName(const char *name) { _name=name; } - const char *getName() const { return _name.c_str(); } - virtual MEDCouplingMeshType getType() const = 0; - bool isStructured() const; - virtual bool isEqual(const MEDCouplingMesh *other, double prec) const; - virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0; - virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); - virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0; - virtual DataArrayDouble *getCoordinatesAndOwner() const = 0; - virtual DataArrayDouble *getBarycenterAndOwner() const = 0; - virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0; - virtual std::string simpleRepr() const = 0; - virtual std::string advancedRepr() const = 0; - // tools - virtual void getBoundingBox(double *bbox) const = 0; - virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0; - virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0; - virtual int getCellContainingPoint(const double *pos, double eps) const = 0; - virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0; - virtual void rotate(const double *center, const double *vector, double angle) = 0; - virtual void translate(const double *vector) = 0; - virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0; - virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const; - static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2); - %extend - { - std::string __str__() const - { - return self->simpleRepr(); - } - - void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - self->renumberCells(tmp,check); - delete [] tmp; - } - - PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *cellCor, *nodeCor; - self->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor); - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(cellCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, cellCor?SWIG_POINTER_OWN | 0:0 )); - PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(nodeCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, nodeCor?SWIG_POINTER_OWN | 0:0 )); - return res; - } - DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - DataArrayInt *ret=self->getCellIdsFullyIncludedInNodeIds(tmp,tmp+size); - delete [] tmp; - return ret; - } - PyObject *getNodeIdsOfCell(int cellId) const - { - std::vector conn; - self->getNodeIdsOfCell(cellId,conn); - return convertIntArrToPyList2(conn); - } - - PyObject *getCoordinatesOfNode(int nodeId) const - { - std::vector coo; - self->getCoordinatesOfNode(nodeId,coo); - return convertDblArrToPyList2(coo); - } - - void scale(PyObject *point, double factor) - { - int sz; - double *p=convertPyToNewDblArr2(point,&sz); - self->scale(p,factor); - delete [] p; - } - } - }; -} - -%include "MEDCouplingMemArray.hxx" -%include "NormalizedUnstructuredMesh.hxx" -%include "MEDCouplingNatureOfField.hxx" -%include "MEDCouplingTimeDiscretization.hxx" -%include "MEDCouplingGaussLocalization.hxx" - -namespace ParaMEDMEM -{ - class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh - { - public: - void updateTime(); - void setCoords(DataArrayDouble *coords); - DataArrayDouble *getCoordinatesAndOwner() const; - bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const; - void getBoundingBox(double *bbox) const; - void zipCoords(); - double getCaracteristicDimension() const; - void translate(const double *vector); - void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception); - void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); - virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0; - static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2); - static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type); - virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0; - virtual MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0; - virtual MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0; - virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0; - virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); - virtual bool isEmptyMesh(const std::vector& tinyInfo) const = 0; - //! size of returned tinyInfo must be always the same. - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) = 0; - virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) = 0; - virtual DataArrayInt *zipCoordsTraducer() = 0; - %extend - { - std::string __str__() const - { - return self->simpleRepr(); - } - - PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const - { - int newNbOfNodes; - DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes); - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes)); - return res; - } - - PyObject *findCommonNodes(int limitNodeId, double prec) const - { - DataArrayInt *comm, *commIndex; - self->findCommonNodes(limitNodeId,prec,comm,commIndex); - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return res; - } - - PyObject *getCoords() const - { - DataArrayDouble *ret1=self->getCoords(); - ret1->incrRef(); - return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0); - } - PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+size,keepCoords); - delete [] tmp; - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,tmp+size,fullyIn); - delete [] tmp; - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,tmp+size,fullyIn); - delete [] tmp; - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *findBoundaryNodes() const - { - std::vector nodes; - self->findBoundaryNodes(nodes); - return convertIntArrToPyList2(nodes); - } - void rotate(PyObject *center, PyObject *vector, double alpha) - { - int sz; - double *c=convertPyToNewDblArr2(center,&sz); - if(!c) - return ; - double *v=convertPyToNewDblArr2(vector,&sz); - if(!v) - { delete [] c; return ; } - self->rotate(c,v,alpha); - delete [] c; - delete [] v; - } - void translate(PyObject *vector) - { - int sz; - double *v=convertPyToNewDblArr2(vector,&sz); - self->translate(v); - delete [] v; - } - void renumberNodes(PyObject *li, int newNbOfNodes) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - self->renumberNodes(tmp,newNbOfNodes); - delete [] tmp; - } - PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception) - { - std::vector nodes; - int sz; - double *p=convertPyToNewDblArr2(pt,&sz); - double *v=convertPyToNewDblArr2(vec,&sz); - self->findNodesOnPlane(p,v,eps,nodes); - delete [] v; - delete [] p; - return convertIntArrToPyList2(nodes); - } - static void rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) - { - int sz; - double *c=convertPyToNewDblArr2(center,&sz); - double *coo=convertPyToNewDblArr2(coords,&sz); - ParaMEDMEM::MEDCouplingPointSet::rotate2DAlg(c,angle,nbNodes,coo); - for(int i=0;isimpleRepr(); - } - - int getCellContainingPoint(PyObject *p, double eps) const - { - int sz; - double *pos=convertPyToNewDblArr2(p,&sz); - int ret=self->getCellContainingPoint(pos,eps); - delete [] pos; - return ret; - } - void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) - { - int sz; - int *tmp=convertPyToNewIntArr2(li,&sz); - self->insertNextCell(type,size,tmp); - delete [] tmp; - } - PyObject *getAllTypes() const - { - std::set result=self->getAllTypes(); - std::set::const_iterator iL=result.begin(); - PyObject *res = PyList_New(result.size()); - for (int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); - return res; - } - PyObject *mergeNodes(double precision) - { - bool ret1; - int ret2; - DataArrayInt *ret0=self->mergeNodes(precision,ret1,ret2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_From_bool(ret1)); - PyList_SetItem(res,2,SWIG_From_int(ret2)); - return res; - } - PyObject *checkButterflyCells() - { - std::vector cells; - self->checkButterflyCells(cells); - return convertIntArrToPyList2(cells); - } - - PyObject *splitByType() const - { - std::vector ms=self->splitByType(); - int sz=ms.size(); - PyObject *ret = PyList_New(sz); - for(int i=0;i idsPerGeoType; - convertPyToNewIntArr3(ids,idsPerGeoType); - MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,idsPerGeoType); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ); - } - - bool checkConsecutiveCellTypesAndOrder(PyObject *li) const - { - int sz; - INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz); - bool ret=self->checkConsecutiveCellTypesAndOrder(order,order+sz); - delete [] order; - return ret; - } - - DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const - { - int sz; - INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz); - DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,order+sz); - delete [] order; - return ret; - } - - PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const - { - int sz; - double *pos=convertPyToNewDblArr2(p,&sz); - std::vector elts,eltsIndex; - self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex); - delete [] pos; - PyObject *ret=PyList_New(2); - PyList_SetItem(ret,0,convertIntArrToPyList2(elts)); - PyList_SetItem(ret,1,convertIntArrToPyList2(eltsIndex)); - return ret; - } - - PyObject *getCellsContainingPoint(PyObject *p, double eps) const - { - int sz; - double *pos=convertPyToNewDblArr2(p,&sz); - std::vector elts; - self->getCellsContainingPoint(pos,eps,elts); - delete [] pos; - return convertIntArrToPyList2(elts); - } - - static PyObject *mergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception) - { - std::vector meshes; - if(PyList_Check(ms)) - { - int sz=PyList_Size(ms); - meshes.resize(sz); - for(int i=0;i(arg); - } - } - else - { - PyErr_SetString(PyExc_TypeError,"mergeUMeshesOnSameCoords : not a list as first parameter"); - PyErr_Print(); - return 0; - } - MEDCouplingUMesh *ret=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - - static PyObject *fuseUMeshesOnSameCoords(PyObject *ms, int compType) - { - int sz; - std::vector meshes; - convertPyObjToVecUMeshes(ms,meshes); - std::vector corr; - MEDCouplingUMesh *um=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,compType,corr); - sz=corr.size(); - PyObject *ret1=PyList_New(sz); - for(int i=0;i cells; - int sz; - double *v=convertPyToNewDblArr2(vec,&sz); - try - { - self->are2DCellsNotCorrectlyOriented(v,polyOnly,cells); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] v; - throw e; - } - delete [] v; - return convertIntArrToPyList2(cells); - } - - void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception) - { - int sz; - double *v=convertPyToNewDblArr2(vec,&sz); - try - { - self->orientCorrectly2DCells(v,polyOnly); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] v; - throw e; - } - delete [] v; - } - - PyObject *arePolyhedronsNotCorrectlyOriented() const throw(INTERP_KERNEL::Exception) - { - std::vector cells; - self->arePolyhedronsNotCorrectlyOriented(cells); - return convertIntArrToPyList2(cells); - } - - PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception) - { - double vec[3]; - double pos[3]; - self->getFastAveragePlaneOfThis(vec,pos); - double vals[6]; - std::copy(vec,vec+3,vals); - std::copy(pos,pos+3,vals+3); - return convertDblArrToPyListOfTuple(vals,3,2); - } - } - void convertToPolyTypes(const std::vector& cellIdsToConvert); - MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy); - static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); - }; - - class MEDCouplingExtrudedMesh : public ParaMEDMEM::MEDCouplingMesh - { - public: - static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); - MEDCouplingUMesh *build3DUnstructuredMesh() const; - %extend { - std::string __str__() const - { - return self->simpleRepr(); - } - PyObject *getMesh2D() const - { - MEDCouplingUMesh *ret=self->getMesh2D(); - ret->incrRef(); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *getMesh1D() const - { - MEDCouplingUMesh *ret=self->getMesh1D(); - ret->incrRef(); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *getMesh3DIds() const - { - DataArrayInt *ret=self->getMesh3DIds(); - ret->incrRef(); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - } - }; - - class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingMesh - { - public: - static MEDCouplingCMesh *New(); - void setCoords(DataArrayDouble *coordsX, - DataArrayDouble *coordsY=0, - DataArrayDouble *coordsZ=0); - void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); - %extend { - std::string __str__() const - { - return self->simpleRepr(); - } - } - }; -} - -%extend ParaMEDMEM::DataArrayDouble - { - std::string __str__() const - { - return self->repr(); - } - - void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) - { - int sz; - double *tmp=convertPyToNewDblArr2(li,&sz); - self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); - } - - PyObject *getValues() - { - const double *vals=self->getPointer(); - return convertDblArrToPyList(vals,self->getNbOfElems()); - } - - PyObject *getValuesAsTuple() - { - const double *vals=self->getPointer(); - int nbOfComp=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); - return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); - } - }; - -%extend ParaMEDMEM::DataArrayInt - { - std::string __str__() const - { - return self->repr(); - } - - void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); - } - - PyObject *getValues() - { - const int *vals=self->getPointer(); - return convertIntArrToPyList(vals,self->getNbOfElems()); - } - - PyObject *getValuesAsTuple() - { - const int *vals=self->getPointer(); - int nbOfComp=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); - return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); - } - - static PyObject *makePartition(PyObject *gps, int newNb) - { - std::vector groups; - std::vector< std::vector > fidsOfGroups; - convertPyObjToVecDataArrayInt(gps,groups); - ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::makePartition(groups,newNb,fidsOfGroups); - PyObject *ret = PyList_New(2); - PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - int sz=fidsOfGroups.size(); - PyObject *ret1 = PyList_New(sz); - for(int i=0;i& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - void clearGaussLocalizations(); - MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception); - int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception); - int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); - const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); - %extend { - PyObject *getMesh() const - { - MEDCouplingMesh *ret1=(MEDCouplingMesh *)self->getMesh(); - ret1->incrRef(); - return convertMesh(ret1, SWIG_POINTER_OWN | 0 ); - } - - PyObject *buildSubMeshData(PyObject *li) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - DataArrayInt *ret1; - MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1); - delete [] tmp; - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0)); - return res; - } - void setGaussLocalizationOnCells(PyObject *li, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - try - { - self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - } - PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - self->getCellIdsHavingGaussLocalization(locId,tmp); - return convertIntArrToPyList2(tmp); - } - } - }; - - class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField - { - public: - static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME); - void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); - std::string simpleRepr() const; - std::string advancedRepr() const; - MEDCouplingFieldDouble *clone(bool recDeepCpy) const; - MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const; - MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const; - TypeOfTimeDiscretization getTimeDiscretization() const; - void checkCoherency() const throw(INTERP_KERNEL::Exception); - double getIJ(int tupleId, int compoId) const; - double getIJK(int cellId, int nodeIdInCell, int compoId) const; - void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception); - void setEndArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception); - void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); - void setStartTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); - void setEndTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getArray() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception); - void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception); - int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); - int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); - int getNumberOfValues() const throw(INTERP_KERNEL::Exception); - NatureOfField getNature() const { return _nature; } - void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); - void updateTime(); - void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); - void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); - bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception); - void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception); - void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); - void applyFunc(const char *func) throw(INTERP_KERNEL::Exception); - void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception); - void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception); - double accumulate(int compId) const throw(INTERP_KERNEL::Exception); - double getMaxValue() const throw(INTERP_KERNEL::Exception); - double getMinValue() const throw(INTERP_KERNEL::Exception); - double getAverageValue() const throw(INTERP_KERNEL::Exception); - double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception); - double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception); - double normL1(int compId) const throw(INTERP_KERNEL::Exception); - double normL2(int compId) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const; - static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const; - static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const; - static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const; - MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - %extend { - std::string __str__() const - { - return self->simpleRepr(); - } - PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception) - { - int sz; - double *spaceLoc=convertPyToNewDblArr2(sl,&sz); - sz=self->getNumberOfComponents(); - double *res=new double[sz]; - try - { - self->getValueOn(spaceLoc,res); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] spaceLoc; - delete [] res; - throw e; - } - delete [] spaceLoc; - PyObject *ret=convertDblArrToPyList(res,sz); - delete [] res; - return ret; - } - PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception) - { - int sz; - double *spaceLoc=convertPyToNewDblArr2(sl,&sz); - sz=self->getNumberOfComponents(); - double *res=new double[sz]; - try - { - self->getValueOn(spaceLoc,time,res); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] spaceLoc; - delete [] res; - throw e; - } - delete [] spaceLoc; - PyObject *ret=convertDblArrToPyList(res,sz); - delete [] res; - return ret; - } - void setValues(PyObject *li) - { - if(self->getArray()!=0) - { - int sz; - double *tmp=convertPyToNewDblArr2(li,&sz); - int nbTuples=self->getArray()->getNumberOfTuples(); - int nbOfCompo=self->getArray()->getNumberOfComponents(); - self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo); - } - else - PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind"); - } - PyObject *getTime() - { - int tmp1,tmp2; - double tmp0=self->getTime(tmp1,tmp2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_From_double(tmp0)); - PyList_SetItem(res,1,SWIG_From_int(tmp1)); - PyList_SetItem(res,2,SWIG_From_int(tmp2)); - return res; - } - - PyObject *getStartTime() - { - int tmp1,tmp2; - double tmp0=self->getStartTime(tmp1,tmp2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_From_double(tmp0)); - PyList_SetItem(res,1,SWIG_From_int(tmp1)); - PyList_SetItem(res,2,SWIG_From_int(tmp2)); - return res; - } - - PyObject *getEndTime() - { - int tmp1,tmp2; - double tmp0=self->getEndTime(tmp1,tmp2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_From_double(tmp0)); - PyList_SetItem(res,1,SWIG_From_int(tmp1)); - PyList_SetItem(res,2,SWIG_From_int(tmp2)); - return res; - } - PyObject *accumulate() const - { - int sz=self->getNumberOfTuples(); - double *tmp=new double[sz]; - self->accumulate(tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - PyObject *integral(bool isWAbs) const - { - int sz=self->getNumberOfTuples(); - double *tmp=new double[sz]; - self->integral(isWAbs,tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - PyObject *normL1() const throw(INTERP_KERNEL::Exception) - { - int sz=self->getNumberOfTuples(); - double *tmp=new double[sz]; - self->normL1(tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - PyObject *normL2() const throw(INTERP_KERNEL::Exception) - { - int sz=self->getNumberOfTuples(); - double *tmp=new double[sz]; - self->normL2(tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - - void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - try - { - self->renumberCells(tmp,check); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - } - void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - try - { - self->renumberNodes(tmp); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - } - - MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingFieldDouble *ret=0; - try - { - ret=self->buildSubPart(tmp,tmp+size); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - return ret; - } - } - }; -} diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx deleted file mode 100644 index d7ecf682a..000000000 --- a/src/MEDLoader/MEDLoader.cxx +++ /dev/null @@ -1,2656 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDLoader.hxx" -#include "MEDLoaderBase.hxx" -#include "CellModel.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingGaussLocalization.hxx" - -extern "C" -{ -#include "med.h" - med_err MEDfieldComputingStepInfo(const med_idt fid, - const char * const fieldname, - const int csit, - med_int * const numdt, - med_int * const numit, - med_float * const dt); - - med_err MEDmeshEntityFamilyNumberRd(const med_idt fid, - const char* const meshname, - const med_int numdt, - const med_int numit, - const med_entity_type entitype, - const med_geometry_type geotype, - med_int * const number); - - med_err MEDmeshEntityNumberRd(const med_idt fid, - const char* const meshname, - const med_int numdt, - const med_int numit, - const med_entity_type entitype, - const med_geometry_type geotype, - med_int * const number); - - med_err MEDfieldCr( const med_idt fid, - const char * const fieldname, - const med_field_type fieldtype, - const med_int nbofcomponent, - const char * const componentname, - const char * const componentunit, - const char * const dtunit, - const char * const meshname); -} - -#include -#include -#include -#include -#include -#include -#include - -med_geometry_type typmai[MED_NOF_CELL_PREDEFINED_TYPES+2] = { MED_POINT1, - MED_SEG2, - MED_SEG3, - MED_TRIA3, - MED_TRIA6, - MED_QUAD4, - MED_QUAD8, - MED_TETRA4, - MED_TETRA10, - MED_HEXA8, - MED_HEXA20, - MED_PENTA6, - MED_PENTA15, - MED_PYRA5, - MED_PYRA13, - MED_POLYGONE, - MED_POLYEDRE }; - -med_geometry_type typmainoeud[1] = { MED_NONE }; - -INTERP_KERNEL::NormalizedCellType typmai2[MED_NOF_CELL_PREDEFINED_TYPES+2] = { INTERP_KERNEL::NORM_POINT0, - INTERP_KERNEL::NORM_SEG2, - INTERP_KERNEL::NORM_SEG3, - INTERP_KERNEL::NORM_TRI3, - INTERP_KERNEL::NORM_TRI6, - INTERP_KERNEL::NORM_QUAD4, - INTERP_KERNEL::NORM_QUAD8, - INTERP_KERNEL::NORM_TETRA4, - INTERP_KERNEL::NORM_TETRA10, - INTERP_KERNEL::NORM_HEXA8, - INTERP_KERNEL::NORM_HEXA20, - INTERP_KERNEL::NORM_PENTA6, - INTERP_KERNEL::NORM_PENTA15, - INTERP_KERNEL::NORM_PYRA5, - INTERP_KERNEL::NORM_PYRA13, - INTERP_KERNEL::NORM_POLYGON, - INTERP_KERNEL::NORM_POLYHED }; - -med_geometry_type typmai3[32] = { MED_POINT1,//0 - MED_SEG2,//1 - MED_SEG3,//2 - MED_TRIA3,//3 - MED_QUAD4,//4 - MED_POLYGONE,//5 - MED_TRIA6,//6 - MED_NONE,//7 - MED_QUAD8,//8 - MED_NONE,//9 - MED_NONE,//10 - MED_NONE,//11 - MED_NONE,//12 - MED_NONE,//13 - MED_TETRA4,//14 - MED_PYRA5,//15 - MED_PENTA6,//16 - MED_NONE,//17 - MED_HEXA8,//18 - MED_NONE,//19 - MED_TETRA10,//20 - MED_NONE,//21 - MED_NONE,//22 - MED_PYRA13,//23 - MED_NONE,//24 - MED_PENTA15,//25 - MED_NONE,//26 - MED_NONE,//27 - MED_NONE,//28 - MED_NONE,//29 - MED_HEXA20,//30 - MED_POLYEDRE//31 -}; - -double MEDLoader::_EPS_FOR_NODE_COMP=1.e-12; - -int MEDLoader::_COMP_FOR_CELL=0; - -int MEDLoader::_TOO_LONG_STR=0; - -using namespace ParaMEDMEM; - -namespace MEDLoaderNS -{ - class FieldPerTypeCopier - { - public: - FieldPerTypeCopier(double *ptr):_ptr(ptr) { } - void operator()(const MEDLoader::MEDFieldDoublePerCellType& elt) { _ptr=std::copy(elt.getArray(),elt.getArray()+elt.getNbOfValues(),_ptr); } - private: - double *_ptr; - }; - - class ConnReaderML - { - public: - ConnReaderML(const int *c, int val):_conn(c),_val(val) { } - bool operator() (const int& pos) { return _conn[pos]!=_val; } - private: - const int *_conn; - int _val; - }; - - std::vector getMeshNamesFid(med_idt fid); - void readFieldDoubleDataInMedFile(const char *fileName, const char *meshName, const char *fieldName, - int iteration, int order, ParaMEDMEM::TypeOfField typeOfOutField, - std::list& field, - double& time, std::vector& infos); - std::vector getIdsFromFamilies(const char *fileName, const char *meshName, const std::vector& fams); - std::vector getIdsFromGroups(const char *fileName, const char *meshName, const std::vector& grps); - med_int getIdFromMeshName(med_idt fid, const char *meshName, std::string& trueMeshName) throw(INTERP_KERNEL::Exception); - void dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity); - int readUMeshDimFromFile(const char *fileName, const char *meshName, std::vector& possibilities); - void readUMeshDataInMedFile(med_idt fid, med_int meshId, DataArrayDouble *&coords, std::list& conn); - int buildMEDSubConnectivityOfOneType(const std::vector& conn, const std::vector& connIndex, const std::vector& families, INTERP_KERNEL::NormalizedCellType type, - std::vector& conn4MEDFile, std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile, - std::vector& fam4MEDFile, std::vector& renumber); - MEDCouplingUMesh *readUMeshFromFileLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& ids, - const std::vector& typesToKeep, unsigned& meshDimExtract, int *&cellRenum) throw(INTERP_KERNEL::Exception); - void tradMEDFileCoreFrmt2MEDCouplingUMesh(const std::list& medConnFrmt, - const std::vector& familiesToKeep, - DataArrayInt* &conn, - DataArrayInt* &connIndex, - int *&cellRenum); - ParaMEDMEM::DataArrayDouble *buildArrayFromRawData(const std::list& fieldPerType, - const std::vector& infos); - int buildMEDSubConnectivityOfOneTypesPolyg(const std::vector& conn, const std::vector& connIndex, const std::vector& families, - std::vector& conn4MEDFile, std::vector& connIndex4MEDFile, std::vector& fam4MEDFile, std::vector& renumber); - int buildMEDSubConnectivityOfOneTypesPolyh(const std::vector&conn, const std::vector& connIndex, const std::vector& families, - std::vector& conn4MEDFile, std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile, - std::vector& fam4MEDFile, std::vector& renumber); - int buildMEDSubConnectivityOfOneTypeStaticTypes(const std::vector& conn, const std::vector& connIndex, const std::vector& families, - INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile, std::vector& fam4MEDFile, std::vector& renumber); - ParaMEDMEM::MEDCouplingFieldDouble *readFieldDoubleLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order, - ParaMEDMEM::TypeOfField typeOfOutField); - ParaMEDMEM::MEDCouplingFieldDouble *readFieldDoubleLev2(const char *fileName, ParaMEDMEM::TypeOfField typeOfOutField, unsigned meshDim, const int *renumCell, const ParaMEDMEM::MEDCouplingUMesh *mesh, - const std::vector& infos, const char *fieldName, int iteration, int order, double time, - std::list& fieldPerCellType); - med_idt appendFieldSimpleAtt(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, med_int& numdt, med_int& numo, med_float& dt); - void appendFieldDirectly(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f); - void appendNodeProfileField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *thisMeshNodeIds); - void appendCellProfileField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *thisMeshCellIds); - void prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *cellIds, std::list& split); - void fillGaussDataOnField(const char *fileName, const std::list& data, MEDCouplingFieldDouble *f); - void writeUMeshesDirectly(const char *fileName, const std::vector& mesh, const std::vector& families, bool forceFromScratch, bool &isRenumbering); - void writeUMeshesPartitionDirectly(const char *fileName, const char *meshName, const std::vector& meshes, bool forceFromScratch); - void writeFieldAndMeshDirectly(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool forceFromScratch); - void writeFieldTryingToFitExistingMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f); -} - -/*! - * This method sets the epsilon value used for node comparison when trying to buid a profile for a field on node/cell on an already written mesh. - */ -void MEDLoader::setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception) -{ - _EPS_FOR_NODE_COMP=val; -} - -/*! - * This method sets the policy comparison when trying to fit the already written mesh on a field. The semantic of the policy is specified in MEDCouplingUMesh::zipConnectivityTraducer. - */ -void MEDLoader::setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception) -{ - _COMP_FOR_CELL=val; -} - -/*! - * This method set the behaviour of MEDLoader when a too long string is seen in datastructure before copy it in MED file. - * By default (0) an exception is thrown. If equal to 1 a warning is emitted in std_err but no exception is thrown. - */ -void MEDLoader::setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception) -{ - _TOO_LONG_STR=val; -} - -/*! - * @param lgth is the size of fam tab. For classical types conn is size of 'lgth'*number_of_nodes_in_type. - * @param index is optionnal only for polys. Set it to 0 if it is not the case. - * @param connLgth is the size of conn in the case of poly. Unsued if it is not the case. - */ -MEDLoader::MEDConnOfOneElemType::MEDConnOfOneElemType(INTERP_KERNEL::NormalizedCellType type, int *conn, int *index, int *fam, int lgth, int connLgth):_lgth(lgth),_fam(fam), - _conn(conn),_index(index), - _global(0),_conn_lgth(connLgth), - _type(type) -{ -} - -void MEDLoader::MEDConnOfOneElemType::setGlobal(int *global) -{ - if(_global!=global) - { - if(_global) - delete [] _global; - _global=global; - } -} - -void MEDLoader::MEDConnOfOneElemType::releaseArray() -{ - delete [] _fam; - delete [] _conn; - delete [] _index; - delete [] _global; -} - -MEDLoader::MEDFieldDoublePerCellType::MEDFieldDoublePerCellType(INTERP_KERNEL::NormalizedCellType type, double *values, int ncomp, int ntuple, - const int *cellIdPerType, const char *locName):_ntuple(ntuple),_ncomp(ncomp),_values(values),_type(type) -{ - if(cellIdPerType) - _cell_id_per_type.insert(_cell_id_per_type.end(),cellIdPerType,cellIdPerType+ntuple); - if(locName) - _loc_name=locName; -} - -void MEDLoader::MEDFieldDoublePerCellType::releaseArray() -{ - delete [] _values; -} - -std::vector MEDLoaderNS::getMeshNamesFid(med_idt fid) -{ - med_mesh_type type_maillage; - char maillage_description[MED_COMMENT_SIZE+1]; - char dtunit[MED_COMMENT_SIZE+1]; - med_int space_dim; - med_int mesh_dim; - char nommaa[MED_NAME_SIZE+1]; - med_axis_type axistype; - med_sorting_type stype; - med_int n=MEDnMesh(fid); - std::vector ret(n); - for(int i=0;i& data, MEDCouplingFieldDouble *f) -{ - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - char locName[MED_NAME_SIZE+1]; - int nloc=MEDnLocalization(fid); - med_geometry_type typeGeo; - for(std::list::const_iterator iter=data.begin();iter!=data.end();iter++) - { - const std::string& loc=(*iter).getLocName(); - int idLoc=1; - int nbOfGaussPt=-1; - med_int spaceDim; - for(;idLoc<=nloc;idLoc++) - { - MEDlocalizationInfo(fid,idLoc,locName,&typeGeo,&spaceDim,&nbOfGaussPt); - if(loc==locName) - break; - } - int dim=(int)INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension(); - int nbPtPerCell=(int)INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getNumberOfNodes(); - std::vector refcoo(nbPtPerCell*dim),gscoo(nbOfGaussPt*dim),w(nbOfGaussPt); - MEDlocalizationRd(fid,(*iter).getLocName().c_str(),MED_FULL_INTERLACE,&refcoo[0],&gscoo[0],&w[0]); - f->setGaussLocalizationOnType((*iter).getType(),refcoo,gscoo,w); - } - MEDfileClose(fid); -} - -void MEDLoader::CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception) -{ - int status=MEDLoaderBase::getStatusOfFile(fileName); - std::ostringstream oss; - oss << " File : \"" << fileName << "\""; - switch(status) - { - case MEDLoaderBase::DIR_LOCKED: - { - oss << " has been detected as unreadable : impossible to read anything !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - case MEDLoaderBase::NOT_EXIST: - { - oss << " has been detected as NOT EXISTING : impossible to read anything !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - case MEDLoaderBase::EXIST_WRONLY: - { - oss << " has been detected as WRITE ONLY : impossible to read anything !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } - int fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - if(fid<0) - { - oss << " has been detected as unreadable by MED file : impossible to read anything !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - oss << " has been detected readable but "; - int major,minor,release; - MEDfileNumVersionRd(fid,&major,&minor,&release); - if(major<2 || (major==2 && minor<2)) - { - oss << "version of MED file is < 2.2 : impossible to read anything !"; - MEDfileClose(fid); - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - MEDfileClose(fid); -} - -std::vector MEDLoader::GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - std::vector ret=MEDLoaderNS::getMeshNamesFid(fid); - MEDfileClose(fid); - return ret; -} - -std::vector MEDLoader::GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nfam=MEDnFamily(fid,meshName); - std::vector ret(nfam); - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - for(int i=0;i MEDLoader::GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nfam=MEDnFamily(fid,meshName); - std::vector ret; - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - for(int i=0;i MEDLoader::GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - //med_int nbpdtnor=0,pflsize,*pflval,lnsize; - med_int numdt=0,numo=0; - med_float dt=0.0; - //char pflname[MED_NAME_SIZE+1]=""; - //char locname[MED_NAME_SIZE+1]=""; - char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_bool localmesh; - // - for(int i=0;i0) - { - bool found=false; - for(int i=0;i0) - { - ret.push_back(ON_NODES); - found=true; - } - } - } - bool found=false; - for(int j=0;j0) - { - MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValue(fid,nomcha,numdt,numo,MED_CELL,typmai[j]); - if(nbOfVal>0) - { - found=true; - ret.push_back(ON_CELLS); - } - } - } - } - } - } - delete [] maa_ass; - delete [] nomcha; - MEDfileClose(fid); - return ret; -} - -std::vector MEDLoader::GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - //med_int nbpdtnor=0,pflsize,*pflval,lnsize; - med_int numdt=0,numo=0; - med_float dt=0.0; - //char pflname[MED_NAME_SIZE+1]=""; - //char locname[MED_NAME_SIZE+1]=""; - char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_bool localmesh; - // - for(int i=0;i0) - { - for(int i=0;i0) - { - found=true; - ret.push_back(curFieldName); - } - } - } - // - for(int j=0;j0) - { - MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValue(fid,nomcha,numdt,numo,MED_CELL,typmai[j]); - if(nbOfVal>0) - { - found=true; - ret.push_back(curFieldName); - } - } - } - } - } - delete [] maa_ass; - delete [] nomcha; - MEDfileClose(fid); - return ret; -} - -std::vector MEDLoader::GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - switch(type) - { - case ON_CELLS: - return GetCellFieldNamesOnMesh(fileName,meshName); - case ON_NODES: - return GetNodeFieldNamesOnMesh(fileName,meshName); - default: - throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES or ON_CELLS !"); - } -} - -std::vector MEDLoader::GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - //med_int nbpdtnor=0,pflsize,*pflval,lnsize; - med_int numdt=0,numo=0; - med_float dt=0.0; - //char pflname[MED_NAME_SIZE+1]=""; - //char locname[MED_NAME_SIZE+1]=""; - char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); - char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_bool localmesh; - med_int nbPdt; - // - for(int i=0;i0) - { - MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValue(fid,nomcha,numdt,numo,MED_CELL,typmai[j]); - if(nbOfVal>0) - { - found=true; - ret.push_back(curFieldName); - } - } - } - } - } - delete [] maa_ass; - delete [] dt_unit; - delete [] nomcha; - MEDfileClose(fid); - return ret; -} - -std::vector MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - med_int numdt=0,numo=0; - med_float dt=0.0; - char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); - char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_bool localmesh; - // - for(int i=0;i0) - { - MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValue(fid,nomcha,numdt,numo,MED_NODE,MED_NONE); - if(curMeshName==meshName && nbOfVal>0) - { - found=true; - ret.push_back(curFieldName); - } - } - } - delete [] maa_ass; - delete [] dt_unit; - delete [] nomcha; - MEDfileClose(fid); - return ret; -} - -std::vector< std::pair > MEDLoader::GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - switch(type) - { - case ON_CELLS: - return GetCellFieldIterations(fileName,meshName,fieldName); - case ON_NODES: - return GetNodeFieldIterations(fileName,meshName,fieldName); - default: - throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES or ON_CELLS !"); - } -} - -std::vector< std::pair > MEDLoader::GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::string meshNameCpp(meshName); - std::vector< std::pair > ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - med_int numdt=0,numo=0; - med_float dt=0.0; - char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); - char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_bool localmesh; - // - for(int i=0;i0) - { - found=true; - ret.push_back(std::make_pair(numdt,numo)); - } - } - } - } - } - delete [] maa_ass; - delete [] dt_unit; - delete [] nomcha; - MEDfileClose(fid); - return ret; -} - -std::vector< std::pair > MEDLoader::GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::string meshNameCpp(meshName); - std::vector< std::pair > ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - med_int numdt=0,numo=0; - med_float dt=0.0; - char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); - char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_bool localmesh; - // - for(int i=0;i0) - { - ret.push_back(std::make_pair(numdt,numo)); - } - } - } - } - delete [] maa_ass; - delete [] dt_unit; - delete [] nomcha; - MEDfileClose(fid); - return ret; -} - -/*! - * This method reads all the content of a field 'fieldName' at a time specified by (iteration,order) lying on a mesh 'meshName' with a specified type 'TypeOfOutField' - * The returned values are strored in 'field' (sorted by type of cell), time corresponding to field, and 'infos' to load properly little strings. - * The principle of this method is to put into 'field' only data that fulfills \b perfectly request. - */ -void MEDLoaderNS::readFieldDoubleDataInMedFile(const char *fileName, const char *meshName, const char *fieldName, - int iteration, int order, ParaMEDMEM::TypeOfField typeOfOutField, - std::list& field, - double& time, std::vector& infos) -{ - time=0.; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - char nomcha[MED_NAME_SIZE+1]=""; - char pflname [MED_NAME_SIZE+1]=""; - char locname [MED_NAME_SIZE+1]=""; - std::map tabEnt; - std::map tabType; - std::map tabTypeLgth; - med_bool localmesh; - tabEnt[ON_CELLS]=MED_CELL; - tabType[ON_CELLS]=typmai; - tabTypeLgth[ON_CELLS]=MED_NBR_GEOMETRIE_MAILLE+2; - tabEnt[ON_NODES]=MED_NODE; - tabType[ON_NODES]=typmainoeud; - tabTypeLgth[ON_NODES]=1; - tabEnt[ON_GAUSS_PT]=MED_CELL; - tabType[ON_GAUSS_PT]=typmai; - tabTypeLgth[ON_GAUSS_PT]=MED_NBR_GEOMETRIE_MAILLE+2; - tabEnt[ON_GAUSS_NE]=MED_NODE_ELEMENT; - tabType[ON_GAUSS_NE]=typmai; - tabTypeLgth[ON_GAUSS_NE]=MED_NBR_GEOMETRIE_MAILLE+2; - // - for(int i=0;i meshes=getMeshNamesFid(fid); - if(meshes.empty()) - throw INTERP_KERNEL::Exception("No mesh in file"); - std::vector::iterator iter=std::find(meshes.begin(),meshes.end(),meshNameStr); - if(iter==meshes.end()) - { - std::ostringstream os2; - os2 << "MeshName '" << meshName << "' not in file : meshes available : "; - std::copy(meshes.begin(),meshes.end(),std::ostream_iterator(os2," ")); - throw INTERP_KERNEL::Exception(os2.str().c_str()); - } - trueMeshName=meshName; - return iter-meshes.begin()+1; -} - -/*! - * This methods allows to merger all entities and to considerate only cell types. - */ -void MEDLoaderNS::dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity) -{ - if(nbOfElemCell>=nbOfElemFace) - { - whichEntity=MED_CELL; - nbOfElem=nbOfElemCell; - } - else - { - whichEntity=MED_CELL; - nbOfElem=nbOfElemFace; - } -} - -/*! - * This method returns a first quick overview of mesh with name 'meshName' into the file 'fileName'. - * @param possibilities the relativeToMeshDim authorized to returned maxdim. This vector is systematically cleared at the begin of this method. - * @return the maximal mesh dimension of specified mesh. If nothing found -1 is returned. - */ -int MEDLoaderNS::readUMeshDimFromFile(const char *fileName, const char *meshName, std::vector& possibilities) -{ - possibilities.clear(); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - int ret; - std::set poss; - char nommaa[MED_NAME_SIZE+1]; - char maillage_description[MED_COMMENT_SIZE+1]; - med_mesh_type type_maillage; - med_int Sdim,Mdim; - std::string trueMeshName; - med_int meshId=getIdFromMeshName(fid,meshName,trueMeshName); - char *dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); - med_sorting_type sortingType; - med_int nstep; - med_axis_type axisType; - int naxis=MEDmeshnAxis(fid,meshId); - char *axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); - char *axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); - MEDmeshInfo(fid,meshId,nommaa,&Sdim,&Mdim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit); - // limitation - if(nstep!=1) - { - throw INTERP_KERNEL::Exception("multisteps on mesh not managed yet !"); - } - med_int numdt,numit; - med_float dt; - MEDmeshComputationStepInfo(fid,nommaa,1,&numdt,&numit,&dt); - // endlimitation - delete [] dt_unit; - delete [] axisname; - delete [] axisunit; - for(int i=0;i0) - { - INTERP_KERNEL::NormalizedCellType type=typmai2[i]; - int curDim=(int)INTERP_KERNEL::CellModel::getCellModel(type).getDimension(); - poss.insert(curDim); - } - } - MEDfileClose(fid); - if(!poss.empty()) - { - ret=*poss.rbegin(); - for(std::set::const_reverse_iterator it=poss.rbegin();it!=poss.rend();it++) - possibilities.push_back(*it-ret); - } - else - ret=-2; - return ret; -} - -void MEDLoaderNS::readUMeshDataInMedFile(med_idt fid, med_int meshId, DataArrayDouble *&coords, std::list& conn) -{ - char nommaa[MED_NAME_SIZE+1]; - char maillage_description[MED_COMMENT_SIZE+1]; - med_mesh_type type_maillage; - med_int Mdim; - med_int Sdim; - char *dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); - med_sorting_type sortingType; - med_int nstep; - med_axis_type axisType; - med_int numdt,numit; - med_float dt; - med_bool changement,transformation; - // endlimitation - Sdim=MEDmeshnAxis(fid,1); - char *comp=MEDLoaderBase::buildEmptyString(Sdim*MED_SNAME_SIZE); - char *unit=MEDLoaderBase::buildEmptyString(Sdim*MED_SNAME_SIZE); - MEDmeshInfo(fid,meshId,nommaa,&Sdim,&Mdim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,comp,unit); - delete [] dt_unit; - MEDmeshComputationStepInfo(fid,nommaa,1,&numdt,&numit,&dt); - int spaceDim=std::max((int)Mdim,(int)Sdim); - int nCoords=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation); - // limitation - if(nstep!=1) - { - throw INTERP_KERNEL::Exception("multisteps on mesh not managed yet !"); - } - coords=DataArrayDouble::New(); - coords->alloc(nCoords,spaceDim); - double *coordsPtr=coords->getPointer(); - MEDmeshNodeCoordinateRd(fid,nommaa,numdt,numit,MED_FULL_INTERLACE,coordsPtr); - for(int i=0;isetInfoOnComponent(i,info.c_str()); - } - delete [] comp; - delete [] unit; - for(int i=0;i0) - { - int *connTab=new int[(curMedType%100)*curNbOfElem]; - int *fam=new int[curNbOfElem]; - MEDLoader::MEDConnOfOneElemType elem(typmai2[i],connTab,0,fam,curNbOfElem,-1); - char *noms=new char[MED_SNAME_SIZE*curNbOfElem+1]; - med_bool withname=MED_FALSE,withnumber=MED_FALSE,withfam=MED_FALSE; - int *globArr=new int[curNbOfElem]; - MEDmeshElementRd(fid,nommaa,numdt,numit,whichEntity,curMedType,MED_NODAL,MED_FULL_INTERLACE,connTab,&withname,noms,&withnumber,globArr,&withfam,fam); - if(!withfam) - std::fill(fam,fam+curNbOfElem,0); - delete [] noms; - //trying to read global numbering - if(withnumber) - elem.setGlobal(globArr); - else - delete [] globArr; - //limitation manage withfam==false - conn.push_back(elem); - } - } - int curNbOfPolyElem; - int curNbOfPolyElemM=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYGON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1; - int curNbOfPolyElemF=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYGON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1;//limitation - med_entity_type whichPolyEntity; - MEDLoaderNS::dispatchElems(curNbOfPolyElemM,curNbOfPolyElemF,curNbOfPolyElem,whichPolyEntity); - if(curNbOfPolyElem>0) - { - med_int arraySize=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYGON,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation); - int *index=new int[curNbOfPolyElem+1]; - int *locConn=new int[arraySize]; - int *fam=new int[curNbOfPolyElem]; - int *globArr=new int[curNbOfPolyElem]; - MEDLoader::MEDConnOfOneElemType elem(INTERP_KERNEL::NORM_POLYGON,locConn,index,fam,curNbOfPolyElem,arraySize); - MEDmeshPolygonRd(fid,nommaa,numdt,numit,MED_CELL,MED_NODAL,index,locConn); - if(MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYGON,fam)!=0) - std::fill(fam,fam+curNbOfPolyElem,0); - if(MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYGON,globArr)==0) - elem.setGlobal(globArr); - else - delete [] globArr; - conn.push_back(elem); - } - curNbOfPolyElem=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,MED_INDEX_FACE,MED_NODAL,&changement,&transformation)-1; - if(curNbOfPolyElem>0) - { - med_int indexFaceLgth,connFaceLgth; - indexFaceLgth=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation); - connFaceLgth=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation); - int *index=new int[curNbOfPolyElem+1]; - int *indexFace=new int[indexFaceLgth]; - int *locConn=new int[connFaceLgth]; - int *fam=new int[curNbOfPolyElem]; - int *globArr=new int[curNbOfPolyElem]; - MEDmeshPolyhedronRd(fid,nommaa,numdt,numit,MED_CELL,MED_NODAL,index,indexFace,locConn); - if(MEDmeshnEntity(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,MED_FAMILY_NUMBER,MED_NO_CMODE,&changement,&transformation)==0) - //if(MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,fam)!=0) - std::fill(fam,fam+curNbOfPolyElem,0); - else - MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,fam); - int arraySize=connFaceLgth; - for(int i=0;i - unsigned calculateHighestMeshDim(const std::list& conn) - { - unsigned ret=0; - for(typename std::list::const_iterator iter=conn.begin();iter!=conn.end();iter++) - { - unsigned curDim=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension(); - if(ret - void keepSpecifiedMeshDim(typename std::list& conn, unsigned meshDim) - { - for(typename std::list::iterator iter=conn.begin();iter!=conn.end();) - { - unsigned curDim=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension(); - if(curDim!=meshDim) - { - (*iter).releaseArray(); - iter=conn.erase(iter); - } - else - iter++; - } - } - - template - void keepTypes(typename std::list& conn, const std::vector& typesToKeep) - { - if(!typesToKeep.empty()) - { - for(typename std::list::iterator iter=conn.begin();iter!=conn.end();) - { - INTERP_KERNEL::NormalizedCellType curType=(*iter).getType(); - if(std::find(typesToKeep.begin(),typesToKeep.end(),curType)==typesToKeep.end()) - { - (*iter).releaseArray(); - iter=conn.erase(iter); - } - else - iter++; - } - } - } -} - -class FieldPerTypeAccumulator -{ -public: - int operator()(int res, const MEDLoader::MEDFieldDoublePerCellType& elt) { return res+elt.getNbOfTuple(); } -}; - -ParaMEDMEM::DataArrayDouble *MEDLoaderNS::buildArrayFromRawData(const std::list& fieldPerType, - const std::vector& infos) -{ - ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New(); - int totalNbOfTuple=std::accumulate(fieldPerType.begin(),fieldPerType.end(),0,FieldPerTypeAccumulator()); - int nbOfComp=(*fieldPerType.begin()).getNbComp(); - double *ptr=new double[nbOfComp*totalNbOfTuple]; - ret->useArray(ptr,true,ParaMEDMEM::CPP_DEALLOC,totalNbOfTuple,nbOfComp); - std::for_each(fieldPerType.begin(),fieldPerType.end(),FieldPerTypeCopier(ptr)); - for(int i=0;isetInfoOnComponent(i,infos[i].c_str()); - return ret; -} - -class PolyCounterForFams -{ -public: - PolyCounterForFams(int id, const int *index):_id(id),_index(index),_count(0),_sigma(0) { } - void operator()(int val) { if(val==_id) _sigma+=_index[_count+1]-_index[_count]; _count++; } - int getSigma() const { return _sigma; } -private: - int _id; - const int *_index; - int _count; - int _sigma; -}; - -/*! - * This method fills unstructured connectivity using basic MED file format 'medConnFrmt'. - * If in each elements of 'medConnFrmt' a renumbering cell array is found the aggregate array 'cellRenum' is returned. - */ -void MEDLoaderNS::tradMEDFileCoreFrmt2MEDCouplingUMesh(const std::list& medConnFrmt, - const std::vector& familiesToKeep, - DataArrayInt* &conn, - DataArrayInt* &connIndex, - int *&cellRenum) -{ - bool keepAll=familiesToKeep.empty(); - if(medConnFrmt.empty()) - { - conn=0; - connIndex=0; - cellRenum=0; - return ; - } - std::list::const_iterator iter=medConnFrmt.begin(); - int totalNbOfCells=0; - int totalNbOfMedConn=0; - bool renumber=true; - cellRenum=0; - for(;iter!=medConnFrmt.end();iter++) - { - if((*iter).getGlobal()==0) - renumber=false; - const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()); - if(keepAll) - totalNbOfCells+=(*iter).getLength(); - else - for(std::vector::const_iterator iter2=familiesToKeep.begin();iter2!=familiesToKeep.end();iter2++) - totalNbOfCells+=std::count((*iter).getFam(),(*iter).getFam()+(*iter).getLength(),*iter2); - if(!cellMod.isDynamic()) - if(keepAll) - totalNbOfMedConn+=(*iter).getLength()*cellMod.getNumberOfNodes(); - else - for(std::vector::const_iterator iter2=familiesToKeep.begin();iter2!=familiesToKeep.end();iter2++) - totalNbOfMedConn+=std::count((*iter).getFam(),(*iter).getFam()+(*iter).getLength(),*iter2)*cellMod.getNumberOfNodes(); - else - if(keepAll) - totalNbOfMedConn+=(*iter).getConnLength(); - else - for(std::vector::const_iterator iter2=familiesToKeep.begin();iter2!=familiesToKeep.end();iter2++) - { - PolyCounterForFams res=std::for_each((*iter).getFam(),(*iter).getFam()+(*iter).getLength(),PolyCounterForFams(*iter2,(*iter).getIndex())); - totalNbOfMedConn+=res.getSigma(); - } - } - connIndex=DataArrayInt::New(); - conn=DataArrayInt::New(); - connIndex->alloc(totalNbOfCells+1,1); - int *connIdxPtr=connIndex->getPointer(); - int connFillId=0; - conn->alloc(totalNbOfMedConn+totalNbOfCells,1); - int *connPtr=conn->getPointer(); - if(renumber) - cellRenum=new int[totalNbOfCells]; - int *renumW=cellRenum; - for(iter=medConnFrmt.begin();iter!=medConnFrmt.end();iter++) - { - INTERP_KERNEL::NormalizedCellType type=(*iter).getType(); - const int *sourceConn=(*iter).getArray(); - const int *sourceIndex=(*iter).getIndex(); - const int *globalNum=(*iter).getGlobal(); - const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel(type); - int nbOfCellsInCurType; - int nbOfNodesIn1Cell=cellMod.getNumberOfNodes(); - nbOfCellsInCurType=(*iter).getLength(); - bool isDyn=cellMod.isDynamic(); - int *tmpConnPtr; - for(int i=0;i(),1)); - else - tmpConnPtr=std::transform(sourceConn,sourceConn+sourceIndex[i+1]-sourceIndex[i],connPtr,std::bind2nd(std::minus(),1)); - connIdxPtr++; - nbOfNodesIn1Cell=tmpConnPtr-connPtr; - connFillId+=nbOfNodesIn1Cell+1; - connPtr=tmpConnPtr; - } - else if(std::find(familiesToKeep.begin(),familiesToKeep.end(),(*iter).getFam()[i])!=familiesToKeep.end()) - {//duplication of next 3 lines needed. - *connIdxPtr=connFillId; - *connPtr++=type; - if(renumber) - *renumW++=globalNum[i]; - if(!isDyn) - tmpConnPtr=std::transform(sourceConn,sourceConn+nbOfNodesIn1Cell,connPtr,std::bind2nd(std::minus(),1)); - else//The duplication of code is motivated by the line underneath. - tmpConnPtr=std::transform((*iter).getArray()+sourceIndex[i]-1,(*iter).getArray()+sourceIndex[i+1]-1,connPtr,std::bind2nd(std::minus(),1)); - connIdxPtr++; - nbOfNodesIn1Cell=tmpConnPtr-connPtr; - connFillId+=nbOfNodesIn1Cell+1; - connPtr=tmpConnPtr; - } - sourceConn+=nbOfNodesIn1Cell; - } - *connIdxPtr=connFillId; - } -} - -namespace MEDLoaderNS -{ - template - void releaseMEDFileCoreFrmt(typename std::list& medConnFrmt) - { - for(typename std::list::iterator iter=medConnFrmt.begin();iter!=medConnFrmt.end();iter++) - (*iter).releaseArray(); - medConnFrmt.clear(); - } -} - -/*! - * This method builds a sub set of connectivity for a given type 'type'. \b WARNING connV,connVIndex and familiesV must have same size ! - * @param connV input containing connectivity with MEDCoupling format. - * @param connVIndex input containing connectivity index in MEDCoupling format. - * @param familiesV input that may be equal to 0. This specifies an array specifying cell family foreach cell. - * @param type input specifying which cell types will be extracted in conn4MEDFile. - * @param conn4MEDFile output containing the connectivity directly understandable by MEDFile; conn4MEDFile has to be empty before this method called. - * @param connIndex4MEDFile output containing index connectivity understandable by MEDFile; only used by polygons and polyhedrons (it is face nodal connec). - * @param connIndexRk24MEDFile output containing index of rank 2 understandable by MEDFile; only used by polyhedrons. - * @param fam4MEDFile output containing family number of cells whose type is 'type'. This output is updated only if 'families' is different than 0. - * @return nb of elements extracted. - */ -int MEDLoaderNS::buildMEDSubConnectivityOfOneTypeStaticTypes(const std::vector& connV, const std::vector& connVIndex, const std::vector& familiesV, - INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile, std::vector& fam4MEDFile, std::vector& renumber) -{ - int ret=0; - int nbOfMeshes=connV.size(); - int renumOffset=0; - for(int i=0;igetNbOfElems()-1; - const int *connPtr=conn->getConstPointer(); - const int *connIdxPtr=connIndex->getConstPointer(); - const int *famPtr=0; - if(families) - famPtr=families->getConstPointer(); - for(int i=0;i(),1)); - return ret; -} - -int MEDLoaderNS::buildMEDSubConnectivityOfOneTypesPolyg(const std::vector&connV, const std::vector& connVIndex, const std::vector& familiesV, - std::vector& conn4MEDFile, std::vector& connIndex4MEDFile, std::vector& fam4MEDFile, std::vector& renumber) -{ - int ret=0; - int nbOfMeshes=connV.size(); - connIndex4MEDFile.push_back(1); - int renumOffset=0; - for(int i=0;igetNbOfElems()-1; - const int *connPtr=conn->getConstPointer(); - const int *connIdxPtr=connIndex->getConstPointer(); - const int *famPtr=0; - if(families) - famPtr=families->getConstPointer(); - for(int i=0;i(),1)); - return ret; -} - -int MEDLoaderNS::buildMEDSubConnectivityOfOneTypesPolyh(const std::vector& connV, const std::vector& connVIndex, const std::vector& familiesV, - std::vector& conn4MEDFile, std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile, - std::vector& fam4MEDFile, std::vector& renumber) -{ - int ret=0; - int nbOfMeshes=connV.size(); - connIndexRk24MEDFile.push_back(1); - connIndex4MEDFile.push_back(1); - int renumOffset=0; - for(int i=0;igetNbOfElems()-1; - const int *connPtr=conn->getConstPointer(); - const int *connIdxPtr=connIndex->getConstPointer(); - const int *famPtr=0; - if(families) - famPtr=families->getConstPointer(); - for(int i=0;i(),1)); - return ret; -} - -/*! - * This method builds a sub set of connectivity for a given type 'type'. - * @param conn input containing connectivity with MEDCoupling format. - * @param connIndex input containing connectivity index in MEDCoupling format. - * @param families input containing, if any, the family number of each cells - * @param type input specifying which cell types will be extracted in conn4MEDFile. - * @param conn4MEDFile output containing the connectivity directly understandable by MEDFile; conn4MEDFile has to be empty before this method called. - * @param connIndex4MEDFile output containing index connectivity understandable by MEDFile; only used by polygons and polyhedrons (it is face nodal connec). - * @param connIndexRk24MEDFile output containing index of rank 2 understandable by MEDFile; only used by polyhedrons. - * @param fam4MEDFile output containing families id of cells whose type is 'type'. - * @return nb of elements extracted. - */ -int MEDLoaderNS::buildMEDSubConnectivityOfOneType(const std::vector& conn, const std::vector& connIndex, const std::vector& families, - INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile, - std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile, std::vector& fam4MEDFile, std::vector& renumber) -{ - - const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel(type); - if(!cellMod.isDynamic()) - return buildMEDSubConnectivityOfOneTypeStaticTypes(conn,connIndex,families,type,conn4MEDFile,fam4MEDFile,renumber); - else - { - if(type==INTERP_KERNEL::NORM_POLYGON) - return buildMEDSubConnectivityOfOneTypesPolyg(conn,connIndex,families,conn4MEDFile,connIndex4MEDFile,fam4MEDFile,renumber); - else - return buildMEDSubConnectivityOfOneTypesPolyh(conn,connIndex,families,conn4MEDFile,connIndex4MEDFile,connIndexRk24MEDFile,fam4MEDFile,renumber); - } -} - -/*! - * @param ids is a in vector containing families ids whose cells have to be kept. If empty all cells are kept. - * @param typesToKeep is a in vector that indicates which types to keep after dimension filtering. - * @param meshDimExtract out parameter that gives the mesh dimension. - * @param cellRenum out parameter that specifies the renumbering (if !=0) of cells in file. - */ -MEDCouplingUMesh *MEDLoaderNS::readUMeshFromFileLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& ids, - const std::vector& typesToKeep, unsigned& meshDimExtract, int *&cellRenum) throw(INTERP_KERNEL::Exception) -{ - //Extraction data from MED file. - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - std::string trueMeshName; - med_int mid=getIdFromMeshName(fid,meshName,trueMeshName); - DataArrayDouble *coords=0; - std::list conn; - readUMeshDataInMedFile(fid,mid,coords,conn); - meshDimExtract=MEDLoaderNS::calculateHighestMeshDim(conn); - meshDimExtract=meshDimExtract+meshDimRelToMax; - MEDLoaderNS::keepSpecifiedMeshDim(conn,meshDimExtract); - MEDLoaderNS::keepTypes(conn,typesToKeep); - MEDfileClose(fid); - //Put data in returned data structure. - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setName(trueMeshName.c_str()); - ret->setMeshDimension(meshDimExtract); - // - ret->setCoords(coords); - coords->decrRef(); - // - DataArrayInt *connArr,*connIndexArr; - tradMEDFileCoreFrmt2MEDCouplingUMesh(conn,ids,connArr,connIndexArr,cellRenum); - ret->setConnectivity(connArr,connIndexArr); - //clean-up - if(connArr) - connArr->decrRef(); - if(connIndexArr) - connIndexArr->decrRef(); - releaseMEDFileCoreFrmt(conn); - return ret; -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoaderNS::readFieldDoubleLev2(const char *fileName, ParaMEDMEM::TypeOfField typeOfOutField, unsigned meshDim, const int *cellRenum, const ParaMEDMEM::MEDCouplingUMesh *mesh, - const std::vector& infos, const char *fieldName, int iteration, int order, double time, - std::list& fieldPerCellType) -{ - if(typeOfOutField==ON_CELLS || typeOfOutField==ON_GAUSS_PT || typeOfOutField==ON_GAUSS_NE) - MEDLoaderNS::keepSpecifiedMeshDim(fieldPerCellType,meshDim); - //for profiles - ParaMEDMEM::MEDCouplingUMesh *newMesh=0; - std::string mName(mesh->getName()); - for(std::list::const_iterator iter=fieldPerCellType.begin();iter!=fieldPerCellType.end();iter++) - { - const std::vector& cellIds=(*iter).getCellIdPerType(); - if(!cellIds.empty()) - { - std::vector ci(cellIds.size()); - std::transform(cellIds.begin(),cellIds.end(),ci.begin(),std::bind2nd(std::plus(),-1)); - ParaMEDMEM::MEDCouplingUMesh *mesh2; - if(typeOfOutField==ON_CELLS) - { - if(newMesh) - mesh2=newMesh->keepSpecifiedCells((*iter).getType(),ci); - else - mesh2=mesh->keepSpecifiedCells((*iter).getType(),ci); - } - else if(typeOfOutField==ON_NODES) - { - DataArrayInt *da=0,*da2=0; - if(newMesh) - { - da=newMesh->getCellIdsFullyIncludedInNodeIds(&ci[0],&ci[ci.size()]); - mesh2=dynamic_cast(newMesh->buildPartAndReduceNodes(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems(),da2)); - } - else - { - da=mesh->getCellIdsFullyIncludedInNodeIds(&ci[0],&ci[ci.size()]); - mesh2=dynamic_cast(mesh->buildPartAndReduceNodes(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems(),da2)); - } - if(da) - da->decrRef(); - if(da2) - da2->decrRef(); - } - if(newMesh) - newMesh->decrRef(); - newMesh=mesh2; - } - } - // - ParaMEDMEM::MEDCouplingFieldDouble *ret=ParaMEDMEM::MEDCouplingFieldDouble::New(typeOfOutField,ONE_TIME); - ret->setName(fieldName); - ret->setTime(time,iteration,order); - if(newMesh) - { - newMesh->setName(mName.c_str());//retrieving mesh name to avoid renaming due to mesh restriction in case of profile. - ret->setMesh(newMesh); - newMesh->decrRef(); - } - else - ret->setMesh(mesh); - ParaMEDMEM::DataArrayDouble *arr=buildArrayFromRawData(fieldPerCellType,infos); - ret->setArray(arr); - arr->decrRef(); - // - if(typeOfOutField==ON_GAUSS_PT) - fillGaussDataOnField(fileName,fieldPerCellType,ret); - if(cellRenum) - ret->renumberCellsWithoutMesh(cellRenum,true); - return ret; -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoaderNS::readFieldDoubleLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order, - ParaMEDMEM::TypeOfField typeOfOutField) -{ - std::list fieldPerCellType; - double time; - std::vector infos; - readFieldDoubleDataInMedFile(fileName,meshName,fieldName,iteration,order,typeOfOutField,fieldPerCellType,time,infos); - std::vector familiesToKeep; - std::vector typesToKeep; - if(typeOfOutField==ON_CELLS || typeOfOutField==ON_GAUSS_PT || typeOfOutField==ON_GAUSS_NE) - for(std::list::const_iterator iter=fieldPerCellType.begin();iter!=fieldPerCellType.end();iter++) - typesToKeep.push_back((*iter).getType()); - unsigned meshDim; - int *cellRenum; - ParaMEDMEM::MEDCouplingUMesh *mesh=readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); - ParaMEDMEM::MEDCouplingFieldDouble *ret=readFieldDoubleLev2(fileName,typeOfOutField,meshDim,cellRenum,mesh,infos,fieldName,iteration,order,time,fieldPerCellType); - if(cellRenum) - mesh->renumberCells(cellRenum,true); - mesh->decrRef(); - //clean-up - delete [] cellRenum; - releaseMEDFileCoreFrmt(fieldPerCellType); - return ret; -} - -MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector familiesToKeep; - std::vector typesToKeep; - unsigned meshDim; - int *cellRenum; - ParaMEDMEM::MEDCouplingUMesh *ret=MEDLoaderNS::readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); - if(cellRenum) - { - ret->renumberCells(cellRenum,true); - delete [] cellRenum; - } - return ret; -} - -ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, int meshDimRelToMax) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector familiesToKeep; - std::vector typesToKeep; - unsigned meshDim; - int *cellRenum; - ParaMEDMEM::MEDCouplingUMesh *ret=MEDLoaderNS::readUMeshFromFileLev1(fileName,0,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); - if(cellRenum) - { - ret->renumberCells(cellRenum,true); - delete [] cellRenum; - } - return ret; -} - -int MEDLoader::ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector poss; - return MEDLoaderNS::readUMeshDimFromFile(fileName,meshName,poss); -} - -ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& fams) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector familiesToKeep=MEDLoaderNS::getIdsFromFamilies(fileName,meshName,fams); - std::vector typesToKeep; - unsigned meshDim; - int *cellRenum; - ParaMEDMEM::MEDCouplingUMesh *ret=MEDLoaderNS::readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); - if(fams.size()==1) - ret->setName(fams.back().c_str()); - if(cellRenum) - { - ret->renumberCells(cellRenum,true); - delete [] cellRenum; - } - return ret; -} - -ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& grps) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector familiesToKeep=MEDLoaderNS::getIdsFromGroups(fileName,meshName,grps); - std::vector typesToKeep; - unsigned meshDim; - int *cellRenum; - ParaMEDMEM::MEDCouplingUMesh *ret=MEDLoaderNS::readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); - if(grps.size()==1) - ret->setName(grps.back().c_str()); - if(cellRenum) - { - ret->renumberCells(cellRenum,true); - delete [] cellRenum; - } - return ret; -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - switch(type) - { - case ON_CELLS: - return ReadFieldCell(fileName,meshName,meshDimRelToMax,fieldName,iteration,order); - case ON_NODES: - return ReadFieldNode(fileName,meshName,meshDimRelToMax,fieldName,iteration,order); - case ON_GAUSS_PT: - return ReadFieldGauss(fileName,meshName,meshDimRelToMax,fieldName,iteration,order); - case ON_GAUSS_NE: - return ReadFieldGaussNE(fileName,meshName,meshDimRelToMax,fieldName,iteration,order); - default: - throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES, ON_CELLS, ON_GAUSS_PT or ON_GAUSS_NE !"); - } -} - -std::vector MEDLoader::ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) -{ - CheckFileForRead(fileName); - std::vector ret(its.size()); - if(its.empty()) - return ret; - //Retrieving mesh of rank 0 and field on rank 0 too. - std::list fieldPerCellType; - double time; - std::vector infos; - MEDLoaderNS::readFieldDoubleDataInMedFile(fileName,meshName,fieldName,its[0].first,its[0].second,type,fieldPerCellType,time,infos); - std::vector familiesToKeep; - std::vector typesToKeep; - if(type==ON_CELLS || type==ON_GAUSS_PT || type==ON_GAUSS_NE) - for(std::list::const_iterator iter=fieldPerCellType.begin();iter!=fieldPerCellType.end();iter++) - typesToKeep.push_back((*iter).getType()); - unsigned meshDim; - int *cellRenum; - ParaMEDMEM::MEDCouplingUMesh *m1=MEDLoaderNS::readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); - ret[0]=MEDLoaderNS::readFieldDoubleLev2(fileName,type,meshDim,cellRenum,m1,infos,fieldName,its[0].first,its[0].second,time,fieldPerCellType); - if(cellRenum) - m1->renumberCells(cellRenum,true); - MEDLoaderNS::releaseMEDFileCoreFrmt(fieldPerCellType); - // - for(int itId=1;itId<(int)its.size();itId++) - { - std::list fieldPerCellType; - double time; - std::vector infos; - MEDLoaderNS::readFieldDoubleDataInMedFile(fileName,meshName,fieldName,its[itId].first,its[itId].second,type,fieldPerCellType,time,infos); - std::vector familiesToKeep; - std::vector typesToKeep; - if(type==ON_CELLS || type==ON_GAUSS_PT || type==ON_GAUSS_NE) - for(std::list::const_iterator iter=fieldPerCellType.begin();iter!=fieldPerCellType.end();iter++) - typesToKeep.push_back((*iter).getType()); - ret[itId]=MEDLoaderNS::readFieldDoubleLev2(fileName,type,meshDim,cellRenum,m1,infos,fieldName,its[itId].first,its[itId].second,time,fieldPerCellType); - //clean-up - MEDLoaderNS::releaseMEDFileCoreFrmt(fieldPerCellType); - } - m1->decrRef(); - delete [] cellRenum; - return ret; -} - -std::vector MEDLoader::ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) -{ - return ReadFieldsOnSameMesh(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,its); -} - -std::vector MEDLoader::ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) -{ - return ReadFieldsOnSameMesh(ON_NODES,fileName,meshName,meshDimRelToMax,fieldName,its); -} - -std::vector MEDLoader::ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) -{ - return ReadFieldsOnSameMesh(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,its); -} - -std::vector MEDLoader::ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) -{ - return ReadFieldsOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its); -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) -{ - return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_CELLS); -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) -{ - return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_NODES); -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) -{ - return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_GAUSS_PT); -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) -{ - return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_GAUSS_NE); -} - -/*! - * @param families input parameter that specifies the field on int on each cells of 'mesh'. - * @param isRenumbering output parameter that specifies if a renumbering of mesh has been needed. - */ -void MEDLoaderNS::writeUMeshesDirectly(const char *fileName, const std::vector& mesh, const std::vector& families, bool forceFromScratch, bool &isRenumbering) -{ - med_idt fid=MEDfileOpen(fileName,forceFromScratch?MED_ACC_CREAT:MED_ACC_RDWR); - std::string meshName(mesh[0]->getName()); - if(meshName=="") - { - MEDfileClose(fid); - throw INTERP_KERNEL::Exception("MEDCouplingMesh must have a not null name !"); - } - isRenumbering=false; - bool isFamilies=true; - std::vector conn; - std::vector connIndex; - std::set allTypes; - for(std::vector::const_iterator iter=mesh.begin();iter!=mesh.end();iter++) - { - isRenumbering|=!(*iter)->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2); - isFamilies&=(families[std::distance(mesh.begin(),iter)]!=0); - conn.push_back((*iter)->getNodalConnectivity()); - connIndex.push_back((*iter)->getNodalConnectivityIndex()); - const std::set& curTypes=(*iter)->getAllTypes(); - allTypes.insert(curTypes.begin(),curTypes.end()); - } - char *maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); - MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_NAME_SIZE,maa,MEDLoader::_TOO_LONG_STR); - MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_COMMENT_SIZE,desc,MEDLoader::_TOO_LONG_STR); - const int spaceDim=mesh[0]->getSpaceDimension(); - const int meshDim=mesh[0]->getMeshDimension(); - DataArrayDouble *arr=mesh[0]->getCoords(); - char *comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); - char *unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); - for(int i=0;igetInfoOnComponent(i); - std::string c,u; - MEDLoaderBase::splitIntoNameAndUnit(info,c,u); - MEDLoaderBase::safeStrCpy(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,MEDLoader::_TOO_LONG_STR);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo - MEDLoaderBase::safeStrCpy(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,MEDLoader::_TOO_LONG_STR);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo - } - MEDmeshCr(fid,maa,spaceDim,meshDim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MED_CARTESIAN,comp,unit); - for(std::vector::const_iterator iter=mesh.begin();iter!=mesh.end();iter++) - { - for(int i=0;i medConn; - std::vector medConnIndex; - std::vector medConnIndex2; - std::vector fam; - std::vector renumber; - int nbOfElt=MEDLoaderNS::buildMEDSubConnectivityOfOneType(conn,connIndex,families,curType,medConn,medConnIndex,medConnIndex2,fam,renumber); - if(curMedType!=MED_POLYGONE && curMedType!=MED_POLYEDRE) - MEDmeshElementConnectivityWr(fid,maa,-1,-1,0.,MED_CELL,curMedType,MED_NODAL,MED_FULL_INTERLACE,nbOfElt,&medConn[0]); - else - { - if(curMedType==MED_POLYGON) - MEDmeshPolygonWr(fid,maa,-1,-1,0.,MED_CELL,MED_NODAL,medConnIndex.size(),&medConnIndex[0],&medConn[0]); - if(curMedType==MED_POLYHEDRON) - { - MEDmeshPolyhedronWr(fid,maa,-1,-1,0.,MED_CELL,MED_NODAL,medConnIndex2.size(),&medConnIndex2[0],medConnIndex.size(),&medConnIndex[0], - &medConn[0]); - } - } - if(isFamilies) - MEDmeshEntityFamilyNumberWr(fid,maa,-1,-1,MED_CELL,curMedType,nbOfElt,&fam[0]); - if(isRenumbering) - MEDmeshEntityNumberWr(fid,maa,-1,-1,MED_CELL,curMedType,nbOfElt,&renumber[0]); - } - } - } - char familyName[MED_NAME_SIZE+1]; - std::fill(familyName,familyName+MED_NAME_SIZE+1,'\0'); - const char DftFamilyName[]="DftFamily"; - std::copy(DftFamilyName,DftFamilyName+sizeof(DftFamilyName),familyName); - MEDfamilyCr(fid,maa,familyName,0,0,0); - - MEDmeshNodeCoordinateWr(fid,maa,-1,-1,0.,MED_FULL_INTERLACE,mesh[0]->getNumberOfNodes(),arr->getPointer()); - delete [] comp; - delete [] unit; - delete [] maa; - delete [] desc; - MEDfileClose(fid); -} - -/*! - * In this method meshes are assumed to shared the same coords. - * This method makes the assumption that 'meshes' is not empty, no check on that is done (responsability of the caller) - */ -void MEDLoaderNS::writeUMeshesPartitionDirectly(const char *fileName, const char *meshName, const std::vector& meshes, bool forceFromScratch) -{ - std::string meshNameCpp(meshName); - char *maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(meshName,MED_NAME_SIZE,maa,MEDLoader::_TOO_LONG_STR); - if(meshNameCpp=="") - throw INTERP_KERNEL::Exception("writeUMeshesPartitionDirectly : Invalid meshName : Must be different from \"\" !"); - std::vector< DataArrayInt * > corr; - MEDCouplingUMesh *m=ParaMEDMEM::MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr); - m->setName(meshName); - std::vector< std::vector > fidsOfGroups; - DataArrayInt *arr2=DataArrayInt::makePartition(corr,m->getNumberOfCells(),fidsOfGroups); - for(std::vector< DataArrayInt * >::iterator it=corr.begin();it!=corr.end();it++) - (*it)->decrRef(); - bool isRenumbering; - std::vector mv(1); mv[0]=m; - std::vector famv(1); famv[0]=arr2; - writeUMeshesDirectly(fileName,mv,famv,forceFromScratch,isRenumbering); - // families creation - std::set familyIds; - for(std::vector< std::vector >::const_iterator it1=fidsOfGroups.begin();it1!=fidsOfGroups.end();it1++) - for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) - familyIds.insert(*it2); - std::vector< std::vector > gidsOfFamilies(familyIds.size()); - int fid=0; - for(std::set::const_iterator it=familyIds.begin();it!=familyIds.end();it++,fid++) - { - int gid=0; - for(std::vector< std::vector >::const_iterator it1=fidsOfGroups.begin();it1!=fidsOfGroups.end();it1++,gid++) - for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) - if(*it2==*it) - gidsOfFamilies[fid].push_back(gid); - } - fid=0; - med_idt fid2=MEDfileOpen(fileName,MED_ACC_RDWR); - for(std::set::const_iterator it=familyIds.begin();it!=familyIds.end();it++,fid++) - { - int ngro=gidsOfFamilies[fid].size(); - char *groName=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE*ngro); - for(int i=0;igetName(),MED_LNAME_SIZE-1,groName+i*MED_LNAME_SIZE,MEDLoader::_TOO_LONG_STR);//MED_LNAME_SIZE-1 to avoid to write '\0' on next compo - std::ostringstream oss; oss << "Family_" << *it; - char *famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(oss.str().c_str(),MED_NAME_SIZE,famName,MEDLoader::_TOO_LONG_STR); - MEDfamilyCr(fid2,maa,famName,*it,ngro,groName); - delete [] famName; - delete [] groName; - } - MEDfileClose(fid2); - // end families creation - delete [] maa; - arr2->decrRef(); - m->decrRef(); -} - -/*! - * This method makes the assumption that f->getMesh() nodes are fully included in already written mesh in 'fileName'. - * @param thisMeshNodeIds points to a tab of size f->getMesh()->getNumberOfNodes() that says for a node i in f->getMesh() that its id is thisMeshNodeIds[i] is already written mesh. - */ -void MEDLoaderNS::appendNodeProfileField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *thisMeshNodeIds) -{ - med_int numdt,numo; - med_float dt; - char *nommaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(f->getMesh()->getName(),MED_NAME_SIZE,nommaa,MEDLoader::_TOO_LONG_STR); - med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); - int nbOfNodes=f->getMesh()->getNumberOfNodes(); - const double *pt=f->getArray()->getConstPointer(); - int *profile=new int[nbOfNodes]; - std::ostringstream oss; oss << "Pfln" << f->getName(); - char *profileName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(oss.str().c_str(),MED_NAME_SIZE,profileName,MEDLoader::_TOO_LONG_STR); - std::transform(thisMeshNodeIds,thisMeshNodeIds+nbOfNodes,profile,std::bind2nd(std::plus(),1)); - MEDprofileWr(fid,profileName,nbOfNodes,profile); - delete [] profile; - MEDfieldValueWithProfileWr(fid,f->getName(),numdt,numo,dt,MED_NODE,MED_NONE,MED_COMPACT_PFLMODE,profileName,MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,nbOfNodes,(const unsigned char*)pt); - delete [] profileName; - delete [] nommaa; - MEDfileClose(fid); -} - -/*! - * This method makes the assumption that f->getMesh() cells are fully included in already written mesh in 'fileName'. - * @param thisMeshCellIdsPerType points to a tab of size f->getMesh()->getNumberOfCells() that says for a cell i in f->getMesh() that its id is thisMeshCellIds[i] of corresponding type is already written mesh. - */ -void MEDLoaderNS::appendCellProfileField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *thisMeshCellIdsPerType) -{ - med_int numdt,numo; - med_float dt; - int nbComp=f->getNumberOfComponents(); - med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); - std::list split; - prepareCellFieldDoubleForWriting(f,thisMeshCellIdsPerType,split); - const double *pt=f->getArray()->getConstPointer(); - int number=0; - for(std::list::const_iterator iter=split.begin();iter!=split.end();iter++) - { - char *nommaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(f->getMesh()->getName(),MED_NAME_SIZE,nommaa,MEDLoader::_TOO_LONG_STR); - char *profileName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - std::ostringstream oss; oss << "Pfl" << f->getName() << "_" << number++; - MEDLoaderBase::safeStrCpy(oss.str().c_str(),MED_NAME_SIZE,profileName,MEDLoader::_TOO_LONG_STR); - const std::vector& ids=(*iter).getCellIdPerType(); - int *profile=new int [ids.size()]; - std::transform(ids.begin(),ids.end(),profile,std::bind2nd(std::plus(),1)); - MEDprofileWr(fid,profileName,ids.size(),profile); - delete [] profile; - MEDfieldValueWithProfileWr(fid,f->getName(),numdt,numo,dt,MED_CELL,typmai3[(int)(*iter).getType()],MED_COMPACT_PFLMODE,profileName, - MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,(*iter).getNbOfTuple(),(const unsigned char*)pt); - delete [] profileName; - delete [] nommaa; - pt+=(*iter).getNbOfTuple()*nbComp; - } - MEDfileClose(fid); -} - -/*! - * This method performs the classical job for fields before any values setting. - */ -med_idt MEDLoaderNS::appendFieldSimpleAtt(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, med_int& numdt, med_int& numo, med_float& dt) -{ - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDWR); - int nbComp=f->getNumberOfComponents(); - char *comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE); - char *unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE); - for(int i=0;igetArray()->getInfoOnComponent(i); - std::string c,u; - MEDLoaderBase::splitIntoNameAndUnit(info,c,u); - MEDLoaderBase::safeStrCpy(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,MEDLoader::_TOO_LONG_STR); - MEDLoaderBase::safeStrCpy(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,MEDLoader::_TOO_LONG_STR); - } - char *dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); - char *maaname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *fname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(f->getName(),MED_NAME_SIZE,fname,MEDLoader::_TOO_LONG_STR); - MEDLoaderBase::safeStrCpy(f->getMesh()->getName(),MED_NAME_SIZE,maaname,MEDLoader::_TOO_LONG_STR); - MEDfieldCr(fid,fname,MED_FLOAT64,nbComp,comp,unit,dt_unit,maaname); - delete [] fname; - delete [] maaname; - delete [] dt_unit; - ParaMEDMEM::TypeOfTimeDiscretization td=f->getTimeDiscretization(); - if(td==ParaMEDMEM::NO_TIME) - { - numdt=MED_NO_DT; numo=MED_NO_IT; dt=0.0; - } - else if(td==ParaMEDMEM::ONE_TIME) - { - int tmp1,tmp2; - double tmp0=f->getTime(tmp1,tmp2); - numdt=(med_int)tmp1; numo=(med_int)tmp2; - dt=(med_float)tmp0; - } - delete [] comp; - delete [] unit; - return fid; -} - -void MEDLoaderNS::appendFieldDirectly(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f2) -{ - med_int numdt,numo; - med_float dt; - //renumbering - const ParaMEDMEM::MEDCouplingFieldDouble *f=f2; - const MEDCouplingMesh *mesh=f->getMesh(); - const MEDCouplingUMesh *meshC=dynamic_cast(mesh); - if(!meshC) - throw INTERP_KERNEL::Exception("Not implemented yet for not unstructured mesh !"); - bool renum=!meshC->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2); - if(renum) - { - ParaMEDMEM::MEDCouplingFieldDouble *f3=f2->clone(true); - DataArrayInt *da=meshC->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2); - f3->renumberCells(da->getConstPointer(),false); - da->decrRef(); - f=f3; - } - //end renumbering - int nbComp=f->getNumberOfComponents(); - med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); - const double *pt=f->getArray()->getConstPointer(); - char *nommaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(f->getMesh()->getName(),MED_NAME_SIZE,nommaa,MEDLoader::_TOO_LONG_STR); - switch(f->getTypeOfField()) - { - case ParaMEDMEM::ON_CELLS: - { - std::list split; - prepareCellFieldDoubleForWriting(f,0,split); - for(std::list::const_iterator iter=split.begin();iter!=split.end();iter++) - { - MEDfieldValueWithProfileWr(fid,f->getName(),numdt,numo,dt,MED_CELL,typmai3[(int)(*iter).getType()],MED_COMPACT_PFLMODE, - MED_ALLENTITIES_PROFILE,MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,(*iter).getNbOfTuple(),(const unsigned char*)pt); - pt+=(*iter).getNbOfTuple()*nbComp; - } - break; - } - case ParaMEDMEM::ON_NODES: - { - int nbOfTuples=f->getArray()->getNumberOfTuples(); - MEDfieldValueWithProfileWr(fid,f->getName(),numdt,numo,dt,MED_NODE,MED_NONE,MED_COMPACT_PFLMODE, - MED_ALLENTITIES_PROFILE,MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,nbOfTuples,(const unsigned char*)pt); - break; - } - case ParaMEDMEM::ON_GAUSS_PT: - { - std::list split; - prepareCellFieldDoubleForWriting(f,0,split); - int idGp=0; - for(std::list::const_iterator iter=split.begin();iter!=split.end();iter++) - { - char *nomGauss=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - std::ostringstream oss; oss << "GP_" << f->getName() << idGp++; - MEDLoaderBase::safeStrCpy(oss.str().c_str(),MED_NAME_SIZE,nomGauss,MEDLoader::_TOO_LONG_STR); - int id=f->getGaussLocalizationIdOfOneType((*iter).getType()); - const MEDCouplingGaussLocalization& gl=f->getGaussLocalization(id); - MEDlocalizationWr(fid,nomGauss,typmai3[(int)(*iter).getType()],mesh->getMeshDimension(),&gl.getRefCoords()[0],MED_FULL_INTERLACE, - gl.getNumberOfGaussPt(),&gl.getGaussCoords()[0],&gl.getWeights()[0]); - int nbOfEntity=f->getMesh()->getNumberOfCellsWithType((*iter).getType()); - int nbOfValues=gl.getNumberOfGaussPt()*nbOfEntity; - char *fieldname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy(f->getName(),MED_NAME_SIZE,fieldname,MEDLoader::_TOO_LONG_STR); - MEDfieldValueWithProfileWr(fid,fieldname,numdt,numo,dt,MED_CELL,typmai3[(int)(*iter).getType()],MED_COMPACT_PFLMODE, - MED_ALLENTITIES_PROFILE,nomGauss,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,nbOfEntity,(const unsigned char*)pt); - delete [] fieldname; - delete [] nomGauss; - pt+=nbOfValues*nbComp; - } - break; - } - case ParaMEDMEM::ON_GAUSS_NE: - { - std::list split; - prepareCellFieldDoubleForWriting(f,0,split); - for(std::list::const_iterator iter=split.begin();iter!=split.end();iter++) - { - int nbPtPerCell=(int)INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getNumberOfNodes(); - int nbOfEntity=f->getMesh()->getNumberOfCellsWithType((*iter).getType()); - int nbOfValues=nbPtPerCell*nbOfEntity; - MEDfieldValueWithProfileWr(fid,f->getName(),numdt,numo,dt,MED_NODE_ELEMENT,typmai3[(int)(*iter).getType()],MED_COMPACT_PFLMODE, - MED_ALLENTITIES_PROFILE,MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,nbOfEntity,(const unsigned char*)pt); - pt+=nbOfValues*nbComp; - } - break; - } - default: - throw INTERP_KERNEL::Exception("Not managed this type of FIELD !"); - } - delete [] nommaa; - MEDfileClose(fid); - if(renum) - ((ParaMEDMEM::MEDCouplingFieldDouble *)f)->decrRef(); -} - -/*! - * This method splits field 'f' into types to be ready for writing. - * @param cellIdsPerType this parameter can be 0 if not in profile mode. If it is != 0 this array is of size f->getMesh()->getNumberOfCells(). - */ -void MEDLoaderNS::prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *cellIdsPerType, std::list& split) -{ - int nbComp=f->getNumberOfComponents(); - const MEDCouplingMesh *mesh=f->getMesh(); - const MEDCouplingUMesh *meshC=dynamic_cast(mesh); - if(!meshC) - throw INTERP_KERNEL::Exception("Not implemented yet for not unstructured mesh !"); - if(!meshC->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2)) - throw INTERP_KERNEL::Exception("Unstructuded mesh has not consecutive cell types !"); - const int *connI=meshC->getNodalConnectivityIndex()->getConstPointer(); - const int *conn=meshC->getNodalConnectivity()->getConstPointer(); - int nbOfCells=meshC->getNumberOfCells(); - INTERP_KERNEL::NormalizedCellType curType; - const int *wCellIdsPT=cellIdsPerType; - for(const int *pt=connI;pt!=connI+nbOfCells;) - { - curType=(INTERP_KERNEL::NormalizedCellType)conn[*pt]; - const int *pt2=std::find_if(pt+1,connI+nbOfCells,ConnReaderML(conn,(int)curType)); - if(!cellIdsPerType) - split.push_back(MEDLoader::MEDFieldDoublePerCellType(curType,0,nbComp,pt2-pt,0,0)); - else - { - split.push_back(MEDLoader::MEDFieldDoublePerCellType(curType,0,nbComp,pt2-pt,wCellIdsPT,0)); - wCellIdsPT+=std::distance(pt,pt2); - } - pt=pt2; - } -} - -void MEDLoaderNS::writeFieldAndMeshDirectly(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool forceFromScratch) -{ - f->checkCoherency(); - std::string meshName(f->getMesh()->getName()); - if(meshName.empty()) - throw INTERP_KERNEL::Exception("Trying to write a mesh (f->getMesh()) with no name ! MED file format needs a not empty mesh name !"); - std::string fieldName(f->getName()); - if(fieldName.empty()) - throw INTERP_KERNEL::Exception("Trying to write a field with no name ! MED file format needs a not empty field name !"); - MEDCouplingUMesh *mesh=dynamic_cast((MEDCouplingMesh *)f->getMesh()); - if(mesh) - { - bool isRenumbering; - std::vector meshV(1); meshV[0]=mesh; - std::vector famV(1); famV[0]=0; - writeUMeshesDirectly(fileName,meshV,famV,forceFromScratch,isRenumbering); - if(isRenumbering) - { - ParaMEDMEM::MEDCouplingFieldDouble *f2=f->clone(true); - DataArrayInt *da=mesh->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2); - f2->renumberCells(da->getConstPointer(),false); - da->decrRef(); - appendFieldDirectly(fileName,f2); - f2->decrRef(); - } - else - appendFieldDirectly(fileName,f); - return ; - } - throw INTERP_KERNEL::Exception("The mesh underlying field is not unstructured ! Only unstructured mesh supported for writting now !"); -} - -/*! - * When called this method expectes that file 'fileName' is already existing and has a mesh with name equal to - * f->getMesh()->getName(). If not the behaviour of this method is not warranted. - * This method reads the corresponding mesh into the file and try to fit it with f->getMesh(). - * If it appears that f->getMesh() equals exactly mesh into the file - */ -void MEDLoaderNS::writeFieldTryingToFitExistingMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) -{ - std::vector poss; - int mDimInFile=MEDLoaderNS::readUMeshDimFromFile(fileName,f->getMesh()->getName(),poss); - int mdim=f->getMesh()->getMeshDimension(); - int f2=mdim-mDimInFile; - if(std::find(poss.begin(),poss.end(),f2)==poss.end()) - { - std::ostringstream oss; oss << "Trying to fit with the existing \"" << f->getMesh()->getName() << "mesh in file \"" << fileName; - oss << "\" but meshdimension does not match !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - MEDCouplingUMesh *m=MEDLoader::ReadUMeshFromFile(fileName,f->getMesh()->getName(),f2); - MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshes(m,(MEDCouplingUMesh *)f->getMesh()); - bool areNodesMerged; - int newNbOfNodes; - DataArrayInt *da=m2->mergeNodes(MEDLoader::_EPS_FOR_NODE_COMP,areNodesMerged,newNbOfNodes); - if(!areNodesMerged || newNbOfNodes!=m->getNumberOfNodes()) - { - da->decrRef(); - m2->decrRef(); - m->decrRef(); - std::ostringstream oss; oss << "Nodes in already written mesh \"" << f->getMesh()->getName() << "\" in file \"" << fileName << "\" does not fit coordinates of unstructured grid f->getMesh() !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - switch(f->getTypeOfField()) - { - case ParaMEDMEM::ON_CELLS: - { - da->decrRef(); - DataArrayInt *da2=m2->zipConnectivityTraducer(MEDLoader::_COMP_FOR_CELL); - if(m2->getNumberOfCells()!=m->getNumberOfCells()) - { - da2->decrRef(); - m2->decrRef(); - m->decrRef(); - std::ostringstream oss1; oss1 << "Cells in already written mesh \"" << f->getMesh()->getName() << "\" in file \"" << fileName << "\" does not fit connectivity of unstructured grid f->getMesh() !"; - throw INTERP_KERNEL::Exception(oss1.str().c_str()); - } - da=m2->convertCellArrayPerGeoType(da2); - DataArrayInt *da3=da->substr(m2->getNumberOfCells()); - da2->decrRef(); - da2=m2->convertCellArrayPerGeoType(da3); - da3->decrRef(); - appendCellProfileField(fileName,f,da2->getConstPointer()); - da2->decrRef(); - break; - } - case ParaMEDMEM::ON_NODES: - { - appendNodeProfileField(fileName,f,da->getConstPointer()+m->getNumberOfNodes()); - break; - } - default: - { - da->decrRef(); - m2->decrRef(); - m->decrRef(); - throw INTERP_KERNEL::Exception("Not implemented other profile fitting from already written mesh for fields than on NODES and on CELLS."); - } - } - da->decrRef(); - m2->decrRef(); - m->decrRef(); -} - -void MEDLoader::WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception) -{ - std::string meshName(mesh->getName()); - if(meshName.empty()) - throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name !"); - int status=MEDLoaderBase::getStatusOfFile(fileName); - bool isRenumbering; - if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - std::vector meshV(1); meshV[0]=mesh; - std::vector famV(1); famV[0]=0; - if(writeFromScratch) - { - MEDLoaderNS::writeUMeshesDirectly(fileName,meshV,famV,true,isRenumbering); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeUMeshesDirectly(fileName,meshV,famV,true,isRenumbering); - return; - } - else - { - std::vector meshNames=GetMeshNames(fileName); - if(std::find(meshNames.begin(),meshNames.end(),meshName)==meshNames.end()) - MEDLoaderNS::writeUMeshesDirectly(fileName,meshV,famV,false,isRenumbering); - else - { - std::ostringstream oss; oss << "File \'" << fileName << "\' already exists and has already a mesh called \""; - oss << meshName << "\" !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } -} - -void MEDLoader::WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception) -{ - std::string meshName(mesh->getName()); - if(meshName.empty()) - throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name !"); - int status=MEDLoaderBase::getStatusOfFile(fileName); - bool isRenumbering; - if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - std::vector meshV(1); meshV[0]=mesh; - std::vector famV(1); famV[0]=0; - if(writeFromScratch) - { - MEDLoaderNS::writeUMeshesDirectly(fileName,meshV,famV,true,isRenumbering); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeUMeshesDirectly(fileName,meshV,famV,true,isRenumbering); - return; - } - else - MEDLoaderNS::writeUMeshesDirectly(fileName,meshV,famV,false,isRenumbering); -} - -void MEDLoader::WriteUMeshesPartition(const char *fileName, const char *meshNameC, const std::vector& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception) -{ - std::string meshName(meshNameC); - if(meshName.empty()) - throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name : change 2nd parameter !"); - int status=MEDLoaderBase::getStatusOfFile(fileName); - if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - if(meshes.empty()) - throw INTERP_KERNEL::Exception("List of meshes must be not empty !"); - DataArrayDouble *coords=meshes.front()->getCoords(); - for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) - if(coords!=(*iter)->getCoords()) - throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !"); - std::set tmp; - for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) - { - if(tmp.find((*iter)->getName())==tmp.end()) - tmp.insert((*iter)->getName()); - else - throw INTERP_KERNEL::Exception("The names of meshes must be different each other !"); - } - tmp.clear(); - if(writeFromScratch) - { - MEDLoaderNS::writeUMeshesPartitionDirectly(fileName,meshNameC,meshes,true); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeUMeshesPartitionDirectly(fileName,meshNameC,meshes,true); - return; - } - else - { - std::vector meshNames=GetMeshNames(fileName); - if(std::find(meshNames.begin(),meshNames.end(),meshName)==meshNames.end()) - MEDLoaderNS::writeUMeshesPartitionDirectly(fileName,meshNameC,meshes,false); - else - { - std::ostringstream oss; oss << "File \'" << fileName << "\' already exists and has already a mesh called \""; - oss << meshName << "\" !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } -} - -void MEDLoader::WriteUMeshesPartitionDep(const char *fileName, const char *meshNameC, const std::vector& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception) -{ - std::string meshName(meshNameC); - if(meshName.empty()) - throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name : change 2nd parameter !"); - int status=MEDLoaderBase::getStatusOfFile(fileName); - if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - if(meshes.empty()) - throw INTERP_KERNEL::Exception("List of meshes must be not empty !"); - DataArrayDouble *coords=meshes.front()->getCoords(); - for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) - if(coords!=(*iter)->getCoords()) - throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !"); - std::set tmp; - for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) - { - if(tmp.find((*iter)->getName())==tmp.end()) - tmp.insert((*iter)->getName()); - else - throw INTERP_KERNEL::Exception("The names of meshes must be different each other !"); - } - tmp.clear(); - if(writeFromScratch) - { - MEDLoaderNS::writeUMeshesPartitionDirectly(fileName,meshNameC,meshes,true); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeUMeshesPartitionDirectly(fileName,meshNameC,meshes,true); - return; - } - else - { - MEDLoaderNS::writeUMeshesPartitionDirectly(fileName,meshNameC,meshes,false); - } -} - -void MEDLoader::WriteUMeshes(const char *fileName, const std::vector& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception) -{ - int status=MEDLoaderBase::getStatusOfFile(fileName); - if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - if(meshes.empty()) - throw INTERP_KERNEL::Exception("List of meshes must be not empty !"); - std::string meshName(meshes[0]->getName()); - if(meshName.empty()) - throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name : change name of first element of 2nd parameter !"); - DataArrayDouble *coords=meshes.front()->getCoords(); - for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) - if(coords!=(*iter)->getCoords()) - throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !"); - std::set tmp; - for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) - { - if(tmp.find((*iter)->getMeshDimension())==tmp.end()) - tmp.insert((*iter)->getMeshDimension()); - else - throw INTERP_KERNEL::Exception("The mesh dimension of meshes must be different each other !"); - } - tmp.clear(); - bool isRenumbering; - std::vector families(meshes.size()); - if(writeFromScratch) - { - MEDLoaderNS::writeUMeshesDirectly(fileName,meshes,families,true,isRenumbering); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeUMeshesDirectly(fileName,meshes,families,true,isRenumbering); - return; - } - else - { - MEDLoaderNS::writeUMeshesDirectly(fileName,meshes,families,false,isRenumbering); - return; - } -} - -void MEDLoader::WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception) -{ - int status=MEDLoaderBase::getStatusOfFile(fileName); - if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - if(writeFromScratch) - { - MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,true); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,true); - return ; - } - else - { - std::vector meshNames=GetMeshNames(fileName); - std::string fileNameCpp(f->getMesh()->getName()); - if(std::find(meshNames.begin(),meshNames.end(),fileNameCpp)==meshNames.end()) - MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,false); - else - MEDLoaderNS::writeFieldTryingToFitExistingMesh(fileName,f); - } -} - -void MEDLoader::WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception) -{ - int status=MEDLoaderBase::getStatusOfFile(fileName); - if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - if(writeFromScratch) - { - MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,true); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,true); - return ; - } - else - MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,false); -} - -void MEDLoader::WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception) -{ - f->checkCoherency(); - int status=MEDLoaderBase::getStatusOfFile(fileName); - if(status!=MEDLoaderBase::EXIST_RW) - { - std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions or not exists !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - MEDLoaderNS::appendFieldDirectly(fileName,f); -} diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx deleted file mode 100644 index 48d95e6c5..000000000 --- a/src/MEDLoader/MEDLoader.hxx +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2007-2010 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 __MEDLOADER_HXX__ -#define __MEDLOADER_HXX__ - -#include "MEDLoaderDefines.hxx" -#include "InterpKernelException.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class DataArrayInt; - class MEDCouplingUMesh; - class MEDCouplingFieldDouble; -} - -class MEDLOADER_EXPORT MEDLoader -{ - public: - class MEDConnOfOneElemType - { - public: - MEDConnOfOneElemType(INTERP_KERNEL::NormalizedCellType type, int *conn, int *index, int *fam, int lgth, int connLgth); - INTERP_KERNEL::NormalizedCellType getType() const { return _type; } - int getLength() const { return _lgth; } - int getConnLength() const { return _conn_lgth; } - int *getArray() const { return _conn; } - int *getIndex() const { return _index; } - int *getFam() const { return _fam; } - void setGlobal(int *global); - const int *getGlobal() const { return _global; } - void releaseArray(); - private: - int _lgth; - int *_fam; - int *_conn; - int *_index; - int *_global; - int _conn_lgth; - INTERP_KERNEL::NormalizedCellType _type; - }; - - class MEDFieldDoublePerCellType - { - public: - MEDFieldDoublePerCellType(INTERP_KERNEL::NormalizedCellType type, double *values, int ncomp, int ntuple, const int *cellIdPerType, const char *locName); - INTERP_KERNEL::NormalizedCellType getType() const { return _type; } - int getNbComp() const { return _ncomp; } - int getNbOfTuple() const { return _ntuple; } - int getNbOfValues() const { return _ncomp*_ntuple; } - double *getArray() const { return _values; } - const std::string& getLocName() const { return _loc_name; } - const std::vector& getCellIdPerType() const { return _cell_id_per_type; } - void releaseArray(); - private: - int _ntuple; - int _ncomp; - double *_values; - std::string _loc_name; - std::vector _cell_id_per_type; - INTERP_KERNEL::NormalizedCellType _type; - }; - // - static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception); - static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception); - static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception); - static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector< std::pair > GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception); - static std::vector< std::pair > GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception); - static std::vector< std::pair > GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& fams) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& grps) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); - static int ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static std::vector ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception); - static std::vector ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception); - static std::vector ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception); - static std::vector ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception); - static std::vector ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, const std::vector& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteUMeshes(const char *fileName, const std::vector& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); - private: - MEDLoader(); - public: - static double _EPS_FOR_NODE_COMP; - static int _COMP_FOR_CELL; - static int _TOO_LONG_STR; -}; - -#endif diff --git a/src/MEDLoader/MEDLoaderBase.cxx b/src/MEDLoader/MEDLoaderBase.cxx deleted file mode 100644 index 057c2869d..000000000 --- a/src/MEDLoader/MEDLoaderBase.cxx +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDLoaderBase.hxx" -#include "InterpKernelException.hxx" - -#include -#include -#include -#include - -const char MEDLoaderBase::WHITE_SPACES[]=" \n"; - -int MEDLoaderBase::getStatusOfFile(const char *fileName) -{ - std::ifstream ifs; - ifs.open(fileName); - unsigned int res=0; - if((ifs.rdstate() & std::ifstream::failbit)!=0) - { - res+=1; - ifs.close(); - } - std::ofstream ofs(fileName,std::ios_base::app); - if((ofs.rdstate() & std::ofstream::failbit)!=0) - { - ofs.close(); - res+=2; - } - switch(res) - { - case 0: - return EXIST_RW; - case 1: - { - std::ifstream ifs2; - ifs2.open(fileName); - if((ifs2.rdstate() & std::ifstream::failbit)!=0) - return EXIST_WRONLY; - else - return NOT_EXIST; - } - case 2: - return EXIST_RDONLY; - case 3: - return DIR_LOCKED; - default: - throw INTERP_KERNEL::Exception("Internal error !"); - } -} - -char *MEDLoaderBase::buildEmptyString(int lgth) -{ - char *ret=new char[lgth+1]; - std::fill(ret,ret+lgth,' '); - ret[lgth]='\0'; - return ret; -} - -std::string MEDLoaderBase::buildUnionUnit(const char *name, int nameLgth, const char *unit, int unitLgth) -{ - std::string ret(buildStringFromFortran(name,nameLgth)); - std::string unitCpp(buildStringFromFortran(unit,unitLgth)); - if(unitCpp[0]=='\0') - return ret; - ret+=" ("; - ret+=unitCpp; - ret+=")"; - return ret; -} - -void MEDLoaderBase::splitIntoNameAndUnit(const std::string& s, std::string& name, std::string& unit) -{ - std::string::size_type f1=s.find_first_of('('); - std::string::size_type f2=s.find_last_of(')'); - if(f1!=std::string::npos && f2!=std::string::npos) - { - if(f1maxLgth) - { - if(behaviour==0 || behaviour>1) - { - std::ostringstream oss; oss << "A string : \"" << src << "\" has been detected to be too long for MED File ( > " << maxLgth << ") !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - else if(behaviour==1) - { - std::string s=zipString(src,maxLgth); - std::cerr << "A string : \"" << src << "\" has been detected to be too long for MED File ( > " << maxLgth << ") : "; - std::cerr << "zipping to : " << s << "\n"; - strcpy(dest,s.c_str()); - return ; - } - } - strcpy(dest,src); -} - -std::string MEDLoaderBase::buildStringFromFortran(const char *expr, int lgth) -{ - std::string ret(expr,lgth); - std::string whiteSpaces(WHITE_SPACES); - std::size_t lgthReal=strlen(ret.c_str()); - std::string ret2=ret.substr(0,lgthReal); - std::size_t found=ret2.find_last_not_of(whiteSpaces); - if (found!=std::string::npos) - ret2.erase(found+1); - else - ret2.clear();//ret is all whitespace - return ret2; -} - -/*! - * This method given the target size to respect 'sizeToRespect' tries to reduce size of 'src' string. - * This method uses several soft methods to do its job. But if it fails a simple cut of string will be performed. - */ -std::string MEDLoaderBase::zipString(const char *src, int sizeToRespect) -{ - std::string s(src); - strip(s); - if((int)s.length()<=sizeToRespect) - return s; - s=src; - zipEqualConsChar(s,3); - if((int)s.length()<=sizeToRespect) - return s; - s=src; - zipEqualConsChar(s,2); - if((int)s.length()<=sizeToRespect) - return s; - s=src; - return s.substr(0,sizeToRespect); -} - -/*! - * This method see if there is in 's' more than 'minConsSmChar' consecutive same character. - * If yes, the group will be zipped using only one character for this group. - * If no such group is found, s remains unchanged. - */ -void MEDLoaderBase::zipEqualConsChar(std::string& s, int minConsSmChar) -{ - for(std::string::iterator it=s.begin();it!=s.end();it++) - { - char tmp=*it; - int sz=1; - for(std::string::iterator it2=it+1;it2!=s.end() && *it2==tmp;it2++) - sz++; - if(sz>=minConsSmChar) - s.erase(it+1,it+sz); - } -} - diff --git a/src/MEDLoader/MEDLoaderBase.hxx b/src/MEDLoader/MEDLoaderBase.hxx deleted file mode 100644 index 09e0c5850..000000000 --- a/src/MEDLoader/MEDLoaderBase.hxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2007-2010 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 __MEDLOADERBASE_HXX__ -#define __MEDLOADERBASE_HXX__ - -#include "MEDLoaderDefines.hxx" -#include "InterpKernelException.hxx" - -#include - -class MEDLOADER_EXPORT MEDLoaderBase -{ -public: - static int getStatusOfFile(const char *fileName); - static char *buildEmptyString(int lgth); - static std::string buildUnionUnit(const char *name, int nameLgth, const char *unit, int unitLgth); - static void splitIntoNameAndUnit(const std::string& s, std::string& name, std::string& unit); - static void strip(std::string& s); - static void safeStrCpy(const char *src, int maxLgth, char *dest, int behaviour) throw(INTERP_KERNEL::Exception); - static std::string buildStringFromFortran(const char *expr, int lgth); - static void zipEqualConsChar(std::string& s, int minConsSmChar); - static std::string zipString(const char *src, int sizeToRespect); -public: - static const int EXIST_RW=0; - static const int NOT_EXIST=1; - static const int EXIST_RDONLY=2; - static const int EXIST_WRONLY=3; - static const int DIR_LOCKED=4; - static const char WHITE_SPACES[]; -}; - -#endif diff --git a/src/MEDLoader/MEDLoaderDefines.hxx b/src/MEDLoader/MEDLoaderDefines.hxx deleted file mode 100644 index 656caa4d5..000000000 --- a/src/MEDLoader/MEDLoaderDefines.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2007-2010 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 __MEDLOADERDEFINES_HXX__ -#define __MEDLOADERDEFINES_HXX__ - -#ifdef WIN32 -# if defined medloader_EXPORTS -# define MEDLOADER_EXPORT __declspec(dllexport) -# else -# define MEDLOADER_EXPORT __declspec(dllimport) -# endif -#else -# define MEDLOADER_EXPORT -#endif - -#endif diff --git a/src/MEDLoader/MEDLoaderTypemaps.i b/src/MEDLoader/MEDLoaderTypemaps.i deleted file mode 100644 index 94811c36d..000000000 --- a/src/MEDLoader/MEDLoaderTypemaps.i +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2007-2010 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 - -static std::vector > convertTimePairIdsFromPy(PyObject *pyLi) -{ - std::vector > ret; - if(PyList_Check(pyLi)) - { - int size=PyList_Size(pyLi); - ret.resize(size); - for(int i=0;i p; - int size2=PyTuple_Size(o); - if(size2!=2) - { - const char msg[]="tuples in list must be of size 2 (dt,it) !"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - PyObject *o0=PyTuple_GetItem(o,0); - if(PyInt_Check(o0)) - p.first=(int)PyInt_AS_LONG(o0); - else - { - const char msg[]="First elem of tuples in list must be integer : dt !"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - PyObject *o1=PyTuple_GetItem(o,1); - if(PyInt_Check(o1)) - p.second=(int)PyInt_AS_LONG(o1); - else - { - const char msg[]="Second elem of tuples in list must be integer : dt !"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - ret[i]=p; - } - else - { - const char msg[]="list must contain tuples only"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - return ret; - } - } - } - else - { - ret.clear(); - const char msg[]="convertTimePairIdsFromPy : not a list"; - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - return ret; -} - -static PyObject *convertFieldDoubleVecToPy(const std::vector& li) -{ - int sz=li.size(); - PyObject *ret=PyList_New(sz); - for(int i=0;i convertFieldDoubleVecFromPy(PyObject *pyLi) -{ - std::vector ret; - if(PyList_Check(pyLi)) - { - int size=PyList_Size(pyLi); - ret.resize(size); - for(int i=0;i(argp); - ret[i]=arg; - } - } - else - { - ret.clear(); - const char msg[]="convertFieldDoubleVecFromPy : not a list"; - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - return ret; -} diff --git a/src/MEDLoader/Makefile.am b/src/MEDLoader/Makefile.am deleted file mode 100755 index 3a2fbb760..000000000 --- a/src/MEDLoader/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (C) 2007-2010 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -MEDLOADER_SUBDIRS = - -if !MED_ENABLE_MICROMED - MEDLOADER_SUBDIRS += . Swig -if CPPUNIT_IS_OK - MEDLOADER_SUBDIRS += Test -endif -endif - -SUBDIRS = $(MEDLOADER_SUBDIRS) - -#DIST_SUBDIRS = Swig - -lib_LTLIBRARIES = libmedloader.la - -salomeinclude_HEADERS= \ -MEDLoaderDefines.hxx \ -MEDLoader.hxx MEDLoaderBase.hxx - -dist_libmedloader_la_SOURCES= \ -MEDLoader.cxx MEDLoaderBase.cxx - -libmedloader_la_CPPFLAGS= $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../MEDCoupling - -libmedloader_la_LDFLAGS= ../MEDCoupling/libmedcoupling.la \ -../INTERP_KERNEL/libinterpkernel.la $(MED2_LIBS) $(HDF5_LIBS) diff --git a/src/MEDLoader/Swig/MEDLoaderDataForTest.py b/src/MEDLoader/Swig/MEDLoaderDataForTest.py deleted file mode 100644 index 2ec4ac837..000000000 --- a/src/MEDLoader/Swig/MEDLoaderDataForTest.py +++ /dev/null @@ -1,304 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libMEDLoader_Swig import * -from math import pi,e,sqrt - -class MEDLoaderDataForTest: - def build1DMesh_1(cls): - coords=[ 0.0, 0.3, 0.75, 1.0, 1.4, 1.3 ] - conn=[ 0,1, 1,2, 2,3 , 3,4,5] - mesh=MEDCouplingUMesh.New(); - mesh.setName("1DMesh_1"); - mesh.setMeshDimension(1); - mesh.allocateCells(4); - mesh.insertNextCell(NORM_SEG2,2,conn[0:2]) - mesh.insertNextCell(NORM_SEG2,2,conn[2:4]) - mesh.insertNextCell(NORM_SEG2,2,conn[4:6]) - mesh.insertNextCell(NORM_SEG3,3,conn[6:9]) - mesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,6,1); - myCoords.setInfoOnComponent(0,"tototototototot (m*m*m*m*m*m*m*m)"); - mesh.setCoords(myCoords); - return mesh; - - def build2DCurveMesh_1(cls): - coords=[ 0.0,0.0, 0.3,0.3, 0.75,0.75, 1.0,1.0, 1.4,1.4, 1.3,1.3 ] - conn=[ 0,1, 1,2, 2,3 , 3,4,5] - mesh=MEDCouplingUMesh.New(); - mesh.setName("2DCurveMesh_1"); - mesh.setMeshDimension(1); - mesh.allocateCells(4); - mesh.insertNextCell(NORM_SEG2,2,conn[0:2]) - mesh.insertNextCell(NORM_SEG2,2,conn[2:4]) - mesh.insertNextCell(NORM_SEG2,2,conn[4:6]) - mesh.insertNextCell(NORM_SEG3,3,conn[6:9]) - mesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,6,2); - mesh.setCoords(myCoords); - return mesh; - - def build2DMesh_1(cls): - targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, - -0.05,0.95, 0.2,1.2, 0.45,0.95] - targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(6); - targetMesh.setName("2DMesh_1"); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6]) - targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20]) - targetMesh.insertNextCell(NORM_POLYGON,4,targetConn[20:24]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,12,2); - myCoords.setInfoOnComponent(0,"tototototototot (m)"); - myCoords.setInfoOnComponent(1,"energie (kW)"); - targetMesh.setCoords(myCoords) - return targetMesh; - - def build2DMesh_2(cls): - targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, - -0.05,0.95, 0.2,1.2, 0.45,0.95] - targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(5); - targetMesh.setName("2DMesh_2"); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6]) - targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,12,2); - myCoords.setInfoOnComponent(0,"toto (m)"); - myCoords.setInfoOnComponent(1,"energie (kW)"); - targetMesh.setCoords(myCoords); - return targetMesh; - - def build3DMesh_1(cls): - coords=[0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., - 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., - 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., - 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1., - 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., - 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2., - 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., - 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.] - conn=[ - # 0 - 0,11,1,3,15,26,16,18, 1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17, - 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21, - 11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23, - 7,12,14,13,22,27,29,28, - # 1 - 15,26,16,18,30,41,31,33, 16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32, - 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36, - 26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38, - 22,27,29,28,37,42,44,43, - # 2 - 30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47, - 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51, - 41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53, - 37,42,44,43,52,57,59,58] - # - ret=MEDCouplingUMesh.New(); - ret.setName("3DMesh_1"); - ret.setMeshDimension(3); - ret.allocateCells(18); - # - ret.insertNextCell(NORM_HEXA8,8,conn[0:8]) - ret.insertNextCell(NORM_HEXA8,8,conn[51:59]) - ret.insertNextCell(NORM_HEXA8,8,conn[59:67]) - ret.insertNextCell(NORM_HEXA8,8,conn[110:118]) - # - ret.insertNextCell(NORM_HEXA8,8,conn[118:126]) - ret.insertNextCell(NORM_HEXA8,8,conn[169:177]) - ret.insertNextCell(NORM_HEXA8,8,conn[177:185]) - ret.insertNextCell(NORM_HEXA8,8,conn[228:236]) - # - ret.insertNextCell(NORM_HEXA8,8,conn[236:244]) - ret.insertNextCell(NORM_HEXA8,8,conn[287:295]) - ret.insertNextCell(NORM_HEXA8,8,conn[295:303]) - ret.insertNextCell(NORM_HEXA8,8,conn[346:354]) - # - ret.insertNextCell(NORM_POLYHED,43,conn[8:51]) - ret.insertNextCell(NORM_POLYHED,43,conn[67:110]) - ret.insertNextCell(NORM_POLYHED,43,conn[126:169]) - ret.insertNextCell(NORM_POLYHED,43,conn[185:228]) - ret.insertNextCell(NORM_POLYHED,43,conn[244:287]) - ret.insertNextCell(NORM_POLYHED,43,conn[303:346]) - # - ret.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(coords,60,3); - myCoords.setInfoOnComponent(0,"titi (m)"); - myCoords.setInfoOnComponent(1,"density power (MW/m^3)"); - myCoords.setInfoOnComponent(2,"t (kW)"); - ret.setCoords(myCoords); - return ret; - - def build3DSurfMesh_1(cls): - targetCoords=[-0.3,-0.3,-0.3, 0.2,-0.3,-0.3, 0.7,-0.3,-0.3, -0.3,0.2,-0.3, 0.2,0.2,-0.3, 0.7,0.2,-0.3, -0.3,0.7,-0.3, 0.2,0.7,-0.3, 0.7,0.7,-0.3 - ,-0.05,0.95,-0.3, 0.2,1.2,-0.3, 0.45,0.95,-0.3] - targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4] - targetMesh=MEDCouplingUMesh.New(); - targetMesh.setMeshDimension(2); - targetMesh.allocateCells(6); - targetMesh.setName("3DSurfMesh_1"); - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3]) - targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6]) - targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16]) - targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20]) - targetMesh.insertNextCell(NORM_POLYGON,4,targetConn[20:24]) - targetMesh.finishInsertingCells(); - myCoords=DataArrayDouble.New(); - myCoords.setValues(targetCoords,12,3); - myCoords.setInfoOnComponent(0,"toto (m)"); - myCoords.setInfoOnComponent(2,"ff (km)");#component 1 is not set for test - targetMesh.setCoords(myCoords); - return targetMesh; - - def build3DMesh_2(cls): - m3dsurfBase=MEDLoaderDataForTest.build3DSurfMesh_1(); - numbers=[0,1,3,4,5] - m3dsurf=m3dsurfBase.buildPartOfMySelf(numbers,False); - m1dBase=MEDLoaderDataForTest.build1DMesh_1(); - numbers2=[0,1,2,3] - m1d=m1dBase.buildPartOfMySelf(numbers2,False); - m1d.changeSpaceDimension(3); - vec=[0.,1.,0.] - pt=[0.,0.,0.] - m1d.rotate(pt,vec,-pi/2.); - ret=m3dsurf.buildExtrudedMeshFromThis(m1d,0); - return ret; - - def buildVecFieldOnCells_1(cls): - mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); - nbOfCells=mesh.getNumberOfCells(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setName("VectorFieldOnCells"); - f1.setMesh(mesh); - array=DataArrayDouble.New(); - arr1=[0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.] - array.setValues(arr1,nbOfCells,3); - array.setInfoOnComponent(0,"power (MW/m^3)"); - array.setInfoOnComponent(1,"density (g/cm^3)"); - array.setInfoOnComponent(2,"temperature (K)"); - f1.setArray(array); - tmp=array.getPointer(); - f1.setTime(2.,0,1); - f1.checkCoherency(); - return f1; - - def buildVecFieldOnNodes_1(cls): - mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); - nbOfNodes=mesh.getNumberOfNodes(); - f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME); - f1.setName("VectorFieldOnNodes"); - f1.setMesh(mesh); - array=DataArrayDouble.New(); - f1.setArray(array); - arr1=[70.,80.,90.,71.,81.,91.,72.,82.,92.,73.,83.,93.,74.,84.,94.,75.,85.,95., - 1000.,10010.,10020.,1001.,10011.,10021.,1002.,10012.,10022.,1003.,10013.,10023.,1004.,10014.,10024.,1005.,10015.,10025.] - array.setValues(arr1,nbOfNodes,3); - array.setInfoOnComponent(0,"power (MW/m^3)"); - array.setInfoOnComponent(1,"density (g/cm^3)"); - array.setInfoOnComponent(2,"temperature (K)"); - f1.setTime(2.12,2,3); - f1.checkCoherency(); - return f1; - - def buildVecFieldOnGauss_1(cls): - _a=0.446948490915965; - _b=0.091576213509771; - _p1=0.11169079483905; - _p2=0.0549758718227661; - refCoo1=[ 0.,0., 1.,0., 0.,1. ] - gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, - 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ]; - wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ] - _refCoo1=refCoo1; - _gsCoo1=gsCoo1; - _wg1=wg1; - m=MEDLoaderDataForTest.build2DMesh_2(); - f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME); - f.setTime(3.14,1,5); - f.setMesh(m); - f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1); - refCoo2=[-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 ] - _refCoo2=refCoo2; - _gsCoo1=_gsCoo1[0:6]; - _wg1=_wg1[0:3]; - f.setGaussLocalizationOnType(NORM_TRI6,_refCoo2,_gsCoo1,_wg1); - refCoo3=[ 0.,0., 1.,0., 1.,1., 0.,1. ] - _refCoo3=refCoo3; - _gsCoo1=_gsCoo1[0:4]; - _wg1=_wg1[0:2]; - f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo3,_gsCoo1,_wg1); - array=DataArrayDouble.New(); - array.alloc(19,2); - ptr=array.getPointer(); - for i in xrange(19*2): - array.setIJ(0,i,float(i+7)); - pass - f.setArray(array); - f.setName("MyFirstFieldOnGaussPoint"); - array.setInfoOnComponent(0,"power (MW/m^3)"); - array.setInfoOnComponent(1,"density"); - f.checkCoherency(); - return f; - - def buildVecFieldOnGaussNE_1(cls): - m=MEDLoaderDataForTest.build2DMesh_2(); - f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME); - f.setTime(3.14,1,5); - f.setMesh(m); - array=DataArrayDouble.New(); - array.alloc(20,2); - for i in xrange(2*20): - array.setIJ(0,i,float(i+8)); - f.setArray(array); - array.setInfoOnComponent(0,"power (W)"); - array.setInfoOnComponent(1,"temperature"); - f.setName("MyFieldOnGaussNE"); - f.checkCoherency(); - return f; - - build1DMesh_1=classmethod(build1DMesh_1) - build2DCurveMesh_1=classmethod(build2DCurveMesh_1) - build2DMesh_1=classmethod(build2DMesh_1) - build2DMesh_2=classmethod(build2DMesh_2) - build3DMesh_1=classmethod(build3DMesh_1) - build3DSurfMesh_1=classmethod(build3DSurfMesh_1) - build3DMesh_2=classmethod(build3DMesh_2) - buildVecFieldOnCells_1=classmethod(buildVecFieldOnCells_1) - buildVecFieldOnNodes_1=classmethod(buildVecFieldOnNodes_1) - buildVecFieldOnGauss_1=classmethod(buildVecFieldOnGauss_1) - buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1) - pass diff --git a/src/MEDLoader/Swig/MEDLoaderTest.py b/src/MEDLoader/Swig/MEDLoaderTest.py deleted file mode 100644 index edb73067c..000000000 --- a/src/MEDLoader/Swig/MEDLoaderTest.py +++ /dev/null @@ -1,439 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libMEDLoader_Swig import * -import unittest -from math import pi,e,sqrt -from MEDLoaderDataForTest import MEDLoaderDataForTest - -class MEDLoaderTest(unittest.TestCase): - def testMesh1DRW(self): - mesh=MEDLoaderDataForTest.build1DMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMesh("Pyfile1.med",mesh,True); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile1.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh2DCurveRW(self): - mesh=MEDLoaderDataForTest.build2DCurveMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMesh("Pyfile2.med",mesh,True); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile2.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh2DRW(self): - mesh=MEDLoaderDataForTest.build2DMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMesh("Pyfile3.med",mesh,True); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh3DSurfRW(self): - mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMesh("Pyfile4.med",mesh,True); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh3DRW(self): - mesh=MEDLoaderDataForTest.build3DMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMesh("Pyfile5.med",mesh,True); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testFieldRW1(self): - f1=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - MEDLoader.WriteField("Pyfile6.med",f1,True); - f2=MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - # - f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - MEDLoader.WriteField("Pyfile7.med",f1,True); - f2=MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - pass - - def testFieldRW2(self): - fileName="Pyfile8.med"; - VAL1=12345.67890314; - VAL2=-1111111111111.; - f1=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - MEDLoader.WriteField(fileName,f1,True); - f1.setTime(10.,8,9); - f1.getArray().setIJ(0,0,VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(10.14,18,19); - f1.getArray().setIJ(0,0,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - #retrieving time steps... - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9); - f1.setTime(10.,8,9); - f1.getArray().setIJ(0,0,VAL1); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1); - f3=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - self.assertTrue(f3.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19); - f1.setTime(10.14,18,19); - f1.getArray().setIJ(0,0,VAL2); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - #test of throw on invalid (dt,it) - self.assertRaises(Exception,MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19); - #ON NODES - f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - fileName2="Pyfile9.med"; - MEDLoader.WriteField(fileName2,f1,True); - f1.setTime(110.,108,109); - tmp=f1.getArray().getPointer(); - f1.getArray().setIJ(0,3,VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1); - f1.setTime(210.,208,209); - f1.getArray().setIJ(0,3,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1); - f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109); - f1.setTime(110.,108,109); - f1.getArray().setIJ(0,3,VAL1); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3); - f3=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - self.assertTrue(f3.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209); - f1.setTime(210.,208,209); - f1.getArray().setIJ(0,3,VAL2); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - pass - - # - # Multi field in a same file, but this field has several - # - def testFieldRW3(self): - fileName="Pyfile11.med"; - VAL1=12345.67890314; - VAL2=-1111111111111.; - name1="AField"; - name3="AMesh1"; - f1=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - f1.getMesh().setName(name3); - f1.setName(name1); - f1.setTime(10.,8,9); - tmp=f1.getArray().getPointer(); - f1.getArray().setIJ(0,0,VAL1); - MEDLoader.WriteField(fileName,f1,True); - f1.setTime(10.14,18,19); - f1.getArray().setIJ(0,0,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.getMesh().setName(name3); - f1.setTime(10.55,28,29); - f1.getArray().setIJ(0,0,3*VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(10.66,38,39); - f1.getArray().setIJ(0,0,3*VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(10.77,48,49); - f1.getArray().setIJ(0,0,4*VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - #ON NODES - f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - f1.setName(name1); - f1.getMesh().setName(name3); - f1.setTime(110.,8,9); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(110.,108,109); - tmp=f1.getArray().getPointer(); - f1.getArray().setIJ(0,3,VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(210.,208,209); - f1.getArray().setIJ(0,3,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - # - it1=MEDLoader.GetCellFieldIterations(fileName,name3,name1); - self.assertEqual(5,len(it1)); - self.assertEqual(8,it1[0][0]); self.assertEqual(9,it1[0][1]); - self.assertEqual(18,it1[1][0]); self.assertEqual(19,it1[1][1]); - self.assertEqual(28,it1[2][0]); self.assertEqual(29,it1[2][1]); - self.assertEqual(38,it1[3][0]); self.assertEqual(39,it1[3][1]); - self.assertEqual(48,it1[4][0]); self.assertEqual(49,it1[4][1]); - it3=MEDLoader.GetNodeFieldIterations(fileName,name3,name1); - self.assertEqual(3,len(it3)); - self.assertEqual(8,it3[0][0]); self.assertEqual(9,it3[0][1]); - self.assertEqual(108,it3[1][0]); self.assertEqual(109,it3[1][1]); - self.assertEqual(208,it3[2][0]); self.assertEqual(209,it3[2][1]); - # - # - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9); - self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19); - self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,28,29); - self.assertAlmostEqual(3*VAL1,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,38,39); - self.assertAlmostEqual(3*VAL2,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,48,49); - self.assertAlmostEqual(4*VAL2,f1.getArray().getIJ(0,0),13); - # - f1=MEDLoader.ReadFieldNode(fileName,name3,0,name1,8,9); - self.assertAlmostEqual(71.,f1.getArray().getIJ(0,3),13); - f1=MEDLoader.ReadFieldNode(fileName,name3,0,name1,108,109); - self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,3),13); - f1=MEDLoader.ReadFieldNode(fileName,name3,0,name1,208,209); - self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13); - pass - - def testMultiMeshRW1(self): - fileName="Pyfile10.med"; - mesh1=MEDLoaderDataForTest.build3DMesh_1(); - part1=[1,2,4,13,15] - mesh2=mesh1.buildPartOfMySelf(part1,True); - mesh2.setName("mesh2"); - part2=[3,4,13,14] - mesh3=mesh1.buildPartOfMySelf(part2,True); - mesh3.setName("mesh3"); - mesh4=MEDCouplingUMesh.New(); - mesh4.setName("mesh4"); - mesh4.setMeshDimension(3); - mesh4.allocateCells(1); - conn=[0,11,1,3] - mesh4.insertNextCell(NORM_TETRA4,4,conn[0:4]) - mesh4.finishInsertingCells(); - mesh4.setCoords(mesh1.getCoords()); - meshes=[mesh1,mesh2,mesh3,mesh4] - mnane="3DToto"; - MEDLoader.WriteUMeshesPartition(fileName,mnane,meshes,True); - # - mesh5=MEDLoader.ReadUMeshFromFile(fileName,mnane); - mesh1.setName(mnane); - part3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] - mesh6=mesh5.buildPartOfMySelf(part3,True); - mesh6.setName(mnane); - self.assertTrue(mesh6.isEqual(mesh1,1e-12)); - grps=MEDLoader.GetMeshGroupsNames(fileName,mnane); - self.assertEqual(4,len(grps)); - grps.index("mesh2"); - grps.index("mesh3"); - grps.index("mesh4"); - grps.index("3DMesh_1"); - # - vec=["mesh2"]; - mesh2_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - self.assertTrue(mesh2_2.isEqual(mesh2,1e-12)); - vec=["mesh3"]; - mesh3_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - self.assertTrue(mesh3_2.isEqual(mesh3,1e-12)); - vec=["mesh4"]; - mesh4_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - self.assertTrue(mesh4_2.isEqual(mesh4,1e-12)); - vec=["3DMesh_1"]; - mesh1_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - mesh1.setName("3DMesh_1"); - self.assertTrue(mesh1_2.isEqual(mesh1,1e-12)); - # - vec=["Family_4","Family_2"]; - mesh2_2=MEDLoader.ReadUMeshFromFamilies(fileName,mnane,0,vec); - mesh2_2.setName("mesh2"); - self.assertTrue(mesh2_2.isEqual(mesh2,1e-12)); - pass - - def testFieldProfilRW1(self): - fileName="Pyfile12.med"; - mesh1=MEDLoaderDataForTest.build3DMesh_1(); - da,b,newNbOfNodes=mesh1.mergeNodes(1e-12); - MEDLoader.WriteUMesh(fileName,mesh1,True); - part1=[1,2,4,13,15] - mesh2=mesh1.buildPartOfMySelf(part1,True); - mesh2.setName(mesh1.getName());#<- important for the test - # - nbOfCells=mesh2.getNumberOfCells(); - self.assertEqual(5,nbOfCells); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setName("VectorFieldOnCells"); - f1.setMesh(mesh2); - array=DataArrayDouble.New(); - array.alloc(nbOfCells,2); - f1.setArray(array); - arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.] - array.setValues(arr1,nbOfCells,2); - f1.setTime(3.14,2,7); - f1.checkCoherency(); - # - MEDLoader.WriteField(fileName,f1,False);#<- False important for the test - # - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7); - f2.checkCoherency(); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - # - pass - - def testFieldGaussRW1(self): - fileName="Pyfile13.med"; - f1=MEDLoaderDataForTest.buildVecFieldOnGauss_1(); - MEDLoader.WriteField(fileName,f1,True); - f2=MEDLoader.ReadField(ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - pass - - def testFieldGaussNERW1(self): - fileName="Pyfile14.med"; - f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1(); - MEDLoader.WriteField(fileName,f1,True); - f2=MEDLoader.ReadField(ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - pass - - def testMesh3DSurfShuffleRW(self): - fileName="Pyfile15.med"; - mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); - renumber1=[2,5,1,0,3,4] - mesh.renumberCells(renumber1,False); - mesh.checkCoherency(); - MEDLoader.WriteUMesh(fileName,mesh,True); - mesh_rw=MEDLoader.ReadUMeshFromFile(fileName,mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMultiFieldShuffleRW1(self): - fileName="Pyfile17.med"; - m=MEDLoaderDataForTest.build3DMesh_2(); - self.assertEqual(20,m.getNumberOfCells()); - self.assertEqual(45,m.getNumberOfNodes()); - polys=[1,4,6] - m.convertToPolyTypes(polys); - renum=[1,3,2,8,9,12,13,16,19,0,4,7,5,15,14,17,10,18,6,11] - m.renumberCells(renum,False); - m.orientCorrectlyPolyhedrons(); - # Writing - MEDLoader.WriteUMesh(fileName,m,True); - f1Tmp=m.getMeasureField(False); - f1=f1Tmp.buildNewTimeReprFromThis(ONE_TIME,False); - f1.setTime(0.,1,2); - f_1=f1.cloneWithMesh(True); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.applyFunc("2*x"); - f1.setTime(0.01,3,4); - f_2=f1.cloneWithMesh(True); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.applyFunc("2*x/3"); - f1.setTime(0.02,5,6); - f_3=f1.cloneWithMesh(True); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - # Reading - its=[(1,2),(3,4),(5,6)]; - fs=MEDLoader.ReadFieldsOnSameMesh(ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its); - self.assertEqual(3,len(fs)); - self.assertTrue(fs[0].isEqual(f_1,1e-12,1e-12)); - self.assertTrue(fs[1].isEqual(f_2,1e-12,1e-12)); - self.assertTrue(fs[2].isEqual(f_3,1e-12,1e-12)); - pass - - def testWriteUMeshesRW1(self): - fileName="Pyfile18.med"; - m3d=MEDLoaderDataForTest.build3DMesh_2(); - pt=[0.,0.,-0.3] - vec=[0.,0.,1.] - nodes=m3d.findNodesOnPlane(pt,vec,1e-12); - m2d=m3d.buildFacePartOfMySelfNode(nodes,True); - renumber=[1,2,0,4,3] - m2d.renumberCells(renumber,False); - m2d.setName("ExampleOfMultiDimW"); - meshes=[m2d,m3d] - MEDLoader.WriteUMeshes(fileName,meshes,True); - m3d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),0); - self.assertTrue(not m3d_bis.isEqual(m3d,1e-12)); - m3d_bis.setName(m3d.getName()); - self.assertTrue(m3d_bis.isEqual(m3d,1e-12)); - m2d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces - self.assertTrue(m2d_bis.isEqual(m2d,1e-12)); - # Creation of a field on faces. - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setName("FieldOnFacesShuffle"); - f1.setMesh(m2d); - array=DataArrayDouble.New(); - arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.] - array.setValues(arr1,m2d.getNumberOfCells(),2); - array.setInfoOnComponent(0,"plkj (mm)"); - array.setInfoOnComponent(1,"pqqqss (mm)"); - f1.setArray(array); - tmp=array.setValues(arr1,m2d.getNumberOfCells(),2); - f1.setTime(3.14,2,7); - f1.checkCoherency(); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7); - self.assertTrue(f2.isEqual(f1,1e-12,1e-12)); - pass - - def testMixCellAndNodesFieldRW1(self): - fileName="Pyfile21.med"; - mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setName("FieldMix"); - f1.setMesh(mesh); - array=DataArrayDouble.New(); - f1.setArray(array); - arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.] - array.setValues(arr1,6,2); - array.setInfoOnComponent(0,"plkj (mm)"); - array.setInfoOnComponent(1,"pqqqss (mm)"); - f1.setTime(3.14,2,7); - f1.checkCoherency(); - # - f2=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME); - f2.setName("FieldMix"); - f2.setMesh(mesh); - array=DataArrayDouble.New(); - f2.setArray(array); - arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150., - 1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.] - array.setValues(arr2,12,2) - array.setInfoOnComponent(0,"plkj (mm)"); - array.setInfoOnComponent(1,"pqqqss (mm)"); - f2.setTime(3.14,2,7); - f2.checkCoherency(); - # - MEDLoader.WriteField(fileName,f1,True); - ts=MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName()); - self.assertEqual(1,len(ts)); - self.assertEqual(ON_CELLS,ts[0]); - fs=MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName()); - self.assertEqual(1,len(fs)); - self.assertTrue(fs[0]=="FieldMix"); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f2); - fs=MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName()); - self.assertEqual(1,len(fs)); - self.assertTrue(fs[0]=="FieldMix"); - # - ts=MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName()); - self.assertEqual(2,len(ts)); - self.assertEqual(ON_NODES,ts[0]); - self.assertEqual(ON_CELLS,ts[1]); - # - f3=MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7); - self.assertTrue(f3.isEqual(f2,1e-12,1e-12)); - f3=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7); - self.assertTrue(f3.isEqual(f1,1e-12,1e-12)); - # - pass - pass - -unittest.main() diff --git a/src/MEDLoader/Swig/MEDLoaderTest2.py b/src/MEDLoader/Swig/MEDLoaderTest2.py deleted file mode 100644 index f795d25d3..000000000 --- a/src/MEDLoader/Swig/MEDLoaderTest2.py +++ /dev/null @@ -1,339 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libMEDLoader_Swig import * -import unittest -from math import pi,e,sqrt -from MEDLoaderDataForTest import MEDLoaderDataForTest - -class MEDLoaderTest(unittest.TestCase): - def testMesh1DRW(self): - mesh=MEDLoaderDataForTest.build1DMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMeshDep("Pyfile1.med",mesh,False); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile1.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh2DCurveRW(self): - mesh=MEDLoaderDataForTest.build2DCurveMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMeshDep("Pyfile2.med",mesh,False); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile2.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh2DRW(self): - mesh=MEDLoaderDataForTest.build2DMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMeshDep("Pyfile3.med",mesh,False); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh3DSurfRW(self): - mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMeshDep("Pyfile4.med",mesh,False); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMesh3DRW(self): - mesh=MEDLoaderDataForTest.build3DMesh_1(); - mesh.checkCoherency(); - MEDLoader.WriteUMeshDep("Pyfile5.med",mesh,False); - mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testFieldRW1(self): - f1=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - MEDLoader.WriteFieldDep("Pyfile6.med",f1,False); - f2=MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - # - f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - MEDLoader.WriteFieldDep("Pyfile7.med",f1,False); - f2=MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - pass - - def testFieldRW2(self): - fileName="Pyfile8.med"; - VAL1=12345.67890314; - VAL2=-1111111111111.; - f1=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - MEDLoader.WriteFieldDep(fileName,f1,False); - f1.setTime(10.,8,9); - f1.getArray().setIJ(0,0,VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(10.14,18,19); - f1.getArray().setIJ(0,0,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - #retrieving time steps... - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9); - f1.setTime(10.,8,9); - f1.getArray().setIJ(0,0,VAL1); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1); - f3=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - self.assertTrue(f3.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19); - f1.setTime(10.14,18,19); - f1.getArray().setIJ(0,0,VAL2); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - #ON NODES - f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - fileName2="Pyfile9.med"; - MEDLoader.WriteFieldDep(fileName2,f1,False); - f1.setTime(110.,108,109); - tmp=f1.getArray().getPointer(); - f1.getArray().setIJ(0,3,VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1); - f1.setTime(210.,208,209); - f1.getArray().setIJ(0,3,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1); - f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109); - f1.setTime(110.,108,109); - f1.getArray().setIJ(0,3,VAL1); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3); - f3=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - self.assertTrue(f3.isEqual(f2,1e-12,1e-12)); - f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209); - f1.setTime(210.,208,209); - f1.getArray().setIJ(0,3,VAL2); - self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); - pass - - # - # Multi field in a same file, but this field has several - # - def testFieldRW3(self): - fileName="Pyfile11.med"; - VAL1=12345.67890314; - VAL2=-1111111111111.; - name1="AField"; - name3="AMesh1"; - f1=MEDLoaderDataForTest.buildVecFieldOnCells_1(); - f1.getMesh().setName(name3); - f1.setName(name1); - f1.setTime(10.,8,9); - tmp=f1.getArray().getPointer(); - f1.getArray().setIJ(0,0,VAL1); - MEDLoader.WriteFieldDep(fileName,f1,False); - f1.setTime(10.14,18,19); - f1.getArray().setIJ(0,0,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.getMesh().setName(name3); - f1.setTime(10.55,28,29); - f1.getArray().setIJ(0,0,3*VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(10.66,38,39); - f1.getArray().setIJ(0,0,3*VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(10.77,48,49); - f1.getArray().setIJ(0,0,4*VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - #ON NODES - f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); - f1.setName(name1); - f1.getMesh().setName(name3); - f1.setTime(110.,8,9); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(110.,108,109); - tmp=f1.getArray().getPointer(); - f1.getArray().setIJ(0,3,VAL1); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.setTime(210.,208,209); - f1.getArray().setIJ(0,3,VAL2); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - # - it1=MEDLoader.GetCellFieldIterations(fileName,name3,name1); - self.assertEqual(5,len(it1)); - self.assertEqual(8,it1[0][0]); self.assertEqual(9,it1[0][1]); - self.assertEqual(18,it1[1][0]); self.assertEqual(19,it1[1][1]); - self.assertEqual(28,it1[2][0]); self.assertEqual(29,it1[2][1]); - self.assertEqual(38,it1[3][0]); self.assertEqual(39,it1[3][1]); - self.assertEqual(48,it1[4][0]); self.assertEqual(49,it1[4][1]); - it3=MEDLoader.GetNodeFieldIterations(fileName,name3,name1); - self.assertEqual(3,len(it3)); - self.assertEqual(8,it3[0][0]); self.assertEqual(9,it3[0][1]); - self.assertEqual(108,it3[1][0]); self.assertEqual(109,it3[1][1]); - self.assertEqual(208,it3[2][0]); self.assertEqual(209,it3[2][1]); - # - # - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9); - self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19); - self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,28,29); - self.assertAlmostEqual(3*VAL1,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,38,39); - self.assertAlmostEqual(3*VAL2,f1.getArray().getIJ(0,0),13); - f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,48,49); - self.assertAlmostEqual(4*VAL2,f1.getArray().getIJ(0,0),13); - # - f1=MEDLoader.ReadFieldNode(fileName,name3,0,name1,8,9); - self.assertAlmostEqual(71.,f1.getArray().getIJ(0,3),13); - f1=MEDLoader.ReadFieldNode(fileName,name3,0,name1,108,109); - self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,3),13); - f1=MEDLoader.ReadFieldNode(fileName,name3,0,name1,208,209); - self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13); - pass - - def testMultiMeshRW1(self): - fileName="Pyfile10.med"; - mesh1=MEDLoaderDataForTest.build3DMesh_1(); - part1=[1,2,4,13,15] - mesh2=mesh1.buildPartOfMySelf(part1,True); - mesh2.setName("mesh2"); - part2=[3,4,13,14] - mesh3=mesh1.buildPartOfMySelf(part2,True); - mesh3.setName("mesh3"); - mesh4=MEDCouplingUMesh.New(); - mesh4.setName("mesh4"); - mesh4.setMeshDimension(3); - mesh4.allocateCells(1); - conn=[0,11,1,3] - mesh4.insertNextCell(NORM_TETRA4,4,conn[0:4]) - mesh4.finishInsertingCells(); - mesh4.setCoords(mesh1.getCoords()); - meshes=[mesh1,mesh2,mesh3,mesh4] - mnane="3DToto"; - MEDLoader.WriteUMeshesPartitionDep(fileName,mnane,meshes,False); - # - mesh5=MEDLoader.ReadUMeshFromFile(fileName,mnane); - mesh1.setName(mnane); - part3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] - mesh6=mesh5.buildPartOfMySelf(part3,True); - mesh6.setName(mnane); - self.assertTrue(mesh6.isEqual(mesh1,1e-12)); - grps=MEDLoader.GetMeshGroupsNames(fileName,mnane); - self.assertEqual(4,len(grps)); - grps.index("mesh2"); - grps.index("mesh3"); - grps.index("mesh4"); - grps.index("3DMesh_1"); - # - vec=["mesh2"]; - mesh2_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - self.assertTrue(mesh2_2.isEqual(mesh2,1e-12)); - vec=["mesh3"]; - mesh3_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - self.assertTrue(mesh3_2.isEqual(mesh3,1e-12)); - vec=["mesh4"]; - mesh4_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - self.assertTrue(mesh4_2.isEqual(mesh4,1e-12)); - vec=["3DMesh_1"]; - mesh1_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec); - mesh1.setName("3DMesh_1"); - self.assertTrue(mesh1_2.isEqual(mesh1,1e-12)); - # - vec=["Family_4","Family_2"]; - mesh2_2=MEDLoader.ReadUMeshFromFamilies(fileName,mnane,0,vec); - mesh2_2.setName("mesh2"); - self.assertTrue(mesh2_2.isEqual(mesh2,1e-12)); - pass - - def testMesh3DSurfShuffleRW(self): - fileName="Pyfile15.med"; - mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); - renumber1=[2,5,1,0,3,4] - mesh.renumberCells(renumber1,False); - mesh.checkCoherency(); - MEDLoader.WriteUMeshDep(fileName,mesh,False); - mesh_rw=MEDLoader.ReadUMeshFromFile(fileName,mesh.getName(),0); - self.assertTrue(mesh.isEqual(mesh_rw,1e-12)); - pass - - def testMultiFieldShuffleRW1(self): - fileName="Pyfile17.med"; - m=MEDLoaderDataForTest.build3DMesh_2(); - self.assertEqual(20,m.getNumberOfCells()); - self.assertEqual(45,m.getNumberOfNodes()); - polys=[1,4,6] - m.convertToPolyTypes(polys); - renum=[1,3,2,8,9,12,13,16,19,0,4,7,5,15,14,17,10,18,6,11] - m.renumberCells(renum,False); - m.orientCorrectlyPolyhedrons(); - # Writing - MEDLoader.WriteUMeshDep(fileName,m,False); - f1Tmp=m.getMeasureField(False); - f1=f1Tmp.buildNewTimeReprFromThis(ONE_TIME,False); - f1.setTime(0.,1,2); - f_1=f1.cloneWithMesh(True); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.applyFunc("2*x"); - f1.setTime(0.01,3,4); - f_2=f1.cloneWithMesh(True); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1.applyFunc("2*x/3"); - f1.setTime(0.02,5,6); - f_3=f1.cloneWithMesh(True); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - # Reading - its=[(1,2),(3,4),(5,6)]; - fs=MEDLoader.ReadFieldsOnSameMesh(ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its); - self.assertEqual(3,len(fs)); - self.assertTrue(fs[0].isEqual(f_1,1e-12,1e-12)); - self.assertTrue(fs[1].isEqual(f_2,1e-12,1e-12)); - self.assertTrue(fs[2].isEqual(f_3,1e-12,1e-12)); - pass - - def testWriteUMeshesRW1(self): - fileName="Pyfile18.med"; - m3d=MEDLoaderDataForTest.build3DMesh_2(); - pt=[0.,0.,-0.3] - vec=[0.,0.,1.] - nodes=m3d.findNodesOnPlane(pt,vec,1e-12); - m2d=m3d.buildFacePartOfMySelfNode(nodes,True); - renumber=[1,2,0,4,3] - m2d.renumberCells(renumber,False); - m2d.setName("ExampleOfMultiDimW"); - meshes=[m2d,m3d] - MEDLoader.WriteUMeshes(fileName,meshes,False); - m3d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),0); - self.assertTrue(not m3d_bis.isEqual(m3d,1e-12)); - m3d_bis.setName(m3d.getName()); - self.assertTrue(m3d_bis.isEqual(m3d,1e-12)); - m2d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces - self.assertTrue(m2d_bis.isEqual(m2d,1e-12)); - # Creation of a field on faces. - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setName("FieldOnFacesShuffle"); - f1.setMesh(m2d); - array=DataArrayDouble.New(); - arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.] - array.setValues(arr1,m2d.getNumberOfCells(),2); - array.setInfoOnComponent(0,"plkj (mm)"); - array.setInfoOnComponent(1,"pqqqss (mm)"); - f1.setArray(array); - tmp=array.setValues(arr1,m2d.getNumberOfCells(),2); - f1.setTime(3.14,2,7); - f1.checkCoherency(); - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7); - self.assertTrue(f2.isEqual(f1,1e-12,1e-12)); - pass - pass - -unittest.main() diff --git a/src/MEDLoader/Swig/MEDLoaderTypemaps.i b/src/MEDLoader/Swig/MEDLoaderTypemaps.i deleted file mode 100644 index 94811c36d..000000000 --- a/src/MEDLoader/Swig/MEDLoaderTypemaps.i +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2007-2010 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 - -static std::vector > convertTimePairIdsFromPy(PyObject *pyLi) -{ - std::vector > ret; - if(PyList_Check(pyLi)) - { - int size=PyList_Size(pyLi); - ret.resize(size); - for(int i=0;i p; - int size2=PyTuple_Size(o); - if(size2!=2) - { - const char msg[]="tuples in list must be of size 2 (dt,it) !"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - PyObject *o0=PyTuple_GetItem(o,0); - if(PyInt_Check(o0)) - p.first=(int)PyInt_AS_LONG(o0); - else - { - const char msg[]="First elem of tuples in list must be integer : dt !"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - PyObject *o1=PyTuple_GetItem(o,1); - if(PyInt_Check(o1)) - p.second=(int)PyInt_AS_LONG(o1); - else - { - const char msg[]="Second elem of tuples in list must be integer : dt !"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - ret[i]=p; - } - else - { - const char msg[]="list must contain tuples only"; - ret.clear(); - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - return ret; - } - } - } - else - { - ret.clear(); - const char msg[]="convertTimePairIdsFromPy : not a list"; - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - return ret; -} - -static PyObject *convertFieldDoubleVecToPy(const std::vector& li) -{ - int sz=li.size(); - PyObject *ret=PyList_New(sz); - for(int i=0;i convertFieldDoubleVecFromPy(PyObject *pyLi) -{ - std::vector ret; - if(PyList_Check(pyLi)) - { - int size=PyList_Size(pyLi); - ret.resize(size); - for(int i=0;i(argp); - ret[i]=arg; - } - } - else - { - ret.clear(); - const char msg[]="convertFieldDoubleVecFromPy : not a list"; - PyErr_SetString(PyExc_TypeError,msg); - PyErr_Print(); - throw INTERP_KERNEL::Exception(msg); - } - return ret; -} diff --git a/src/MEDLoader/Swig/Makefile.am b/src/MEDLoader/Swig/Makefile.am deleted file mode 100644 index ab110a19d..000000000 --- a/src/MEDLoader/Swig/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2007-2010 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 -# - -# MED MEDMEM_SWIG : binding of C++ implementation and Python -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES = _libMEDLoader_Swig.la - -salomeinclude_HEADERS = \ - libMEDLoader_Swig.i MEDLoaderTypemaps.i - -SWIG_DEF = libMEDLoader_Swig.i MEDLoaderTypemaps.i - -SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../MEDCoupling -I$(srcdir)/../../MEDCoupling_Swig \ - -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Bases - -dist__libMEDLoader_Swig_la_SOURCES = $(SWIG_DEF) -nodist__libMEDLoader_Swig_la_SOURCES = libMEDLoader_Swig_wrap.cxx -libMEDLoader_Swig.py: libMEDLoader_Swig_wrap.cxx - -libMEDLoader_Swig_wrap.cxx: $(SWIG_DEF) - $(SWIG) $(SWIG_FLAGS) -o $@ $< - -_libMEDLoader_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \ - $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ - -I$(srcdir)/../../INTERP_KERNEL \ - -I$(srcdir)/.. -I$(srcdir)/../../MEDCoupling_Swig -I$(srcdir)/../../INTERP_KERNEL/Bases \ - -I$(srcdir)/../../MEDCoupling - -_libMEDLoader_Swig_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) \ - ../../MEDCoupling/libmedcoupling.la ../../INTERP_KERNEL/libinterpkernel.la \ - ../libmedloader.la - -CLEANFILES = libMEDLoader_Swig_wrap.cxx libMEDLoader_Swig.py - -dist_salomescript_DATA= libMEDLoader_Swig.py MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py - -UNIT_TEST_PROG = MEDLoaderTest.py MEDLoaderTest2.py \ No newline at end of file diff --git a/src/MEDLoader/Swig/libMEDLoader_Swig.i b/src/MEDLoader/Swig/libMEDLoader_Swig.i deleted file mode 100644 index f9144f47f..000000000 --- a/src/MEDLoader/Swig/libMEDLoader_Swig.i +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - -%module libMEDLoader_Swig - -#define MEDCOUPLING_EXPORT -#define MEDLOADER_EXPORT - -%include "libMEDCoupling_Swig.i" - -%{ -#include "MEDLoader.hxx" -#include "MEDLoaderTypemaps.i" -%} - -#if SWIG_VERSION >= 0x010329 -%template() std::vector; -#endif - -%newobject MEDLoader::ReadUMeshFromFamilies; -%newobject MEDLoader::ReadUMeshFromGroups; -%newobject MEDLoader::ReadUMeshFromFile; -%newobject MEDLoader::ReadField; -%newobject MEDLoader::ReadFieldCell; -%newobject MEDLoader::ReadFieldNode; -%newobject MEDLoader::ReadFieldGauss; -%newobject MEDLoader::ReadFieldGaussNE; - -class MEDLoader -{ -public: - static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception); - static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception); - static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception); - static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - %extend - { - static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) - { - std::vector< std::pair > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName); - PyObject *ret=PyList_New(res.size()); - int rk=0; - for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) - { - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); - PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); - PyList_SetItem(ret,rk,elt); - } - return ret; - } - - static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) - { - std::vector< std::pair > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName); - PyObject *ret=PyList_New(res.size()); - int rk=0; - for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) - { - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); - PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); - PyList_SetItem(ret,rk,elt); - } - return ret; - } - static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) - { - std::vector< std::pair > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName); - PyObject *ret=PyList_New(res.size()); - int rk=0; - for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) - { - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); - PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); - PyList_SetItem(ret,rk,elt); - } - return ret; - } - static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, - const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception) - { - std::vector > its=convertTimePairIdsFromPy(liIts); - std::vector res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its); - return convertFieldDoubleVecToPy(res); - } - static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) - { - std::vector v=convertFieldDoubleVecFromPy(li); - MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch); - } - static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) - { - std::vector v=convertFieldDoubleVecFromPy(li); - MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch); - } - static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) - { - std::vector v=convertFieldDoubleVecFromPy(li); - std::vector v2(v.begin(),v.end()); - MEDLoader::WriteUMeshes(fileName,v2,writeFromScratch); - } - static PyObject *GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception) - { - std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,fieldName,meshName); - int size=v.size(); - PyObject *ret=PyList_New(size); - for(int i=0;i& fams) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& grps) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); -}; diff --git a/src/MEDLoader/Test/MEDLoaderTest.cxx b/src/MEDLoader/Test/MEDLoaderTest.cxx deleted file mode 100644 index 5004a768b..000000000 --- a/src/MEDLoader/Test/MEDLoaderTest.cxx +++ /dev/null @@ -1,973 +0,0 @@ -// Copyright (C) 2007-2010 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 "MEDLoaderTest.hxx" -#include "MEDLoader.hxx" -#include "MEDLoaderBase.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" - -#include - -using namespace ParaMEDMEM; - -void MEDLoaderTest::testMesh1DRW() -{ - MEDCouplingUMesh *mesh=build1DMesh_1(); - mesh->checkCoherency(); - MEDLoader::WriteUMesh("file1.med",mesh,true); - MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile("file1.med",mesh->getName(),0); - CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12)); - mesh_rw->decrRef(); - mesh->decrRef(); -} - -void MEDLoaderTest::testMesh2DCurveRW() -{ - MEDCouplingUMesh *mesh=build2DCurveMesh_1(); - mesh->checkCoherency(); - MEDLoader::WriteUMesh("file2.med",mesh,true); - MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile("file2.med",mesh->getName(),0); - CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12)); - mesh_rw->decrRef(); - mesh->decrRef(); -} - -void MEDLoaderTest::testMesh2DRW() -{ - MEDCouplingUMesh *mesh=build2DMesh_1(); - mesh->checkCoherency(); - MEDLoader::WriteUMesh("file3.med",mesh,true); - MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile("file3.med",mesh->getName(),0); - CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12)); - mesh_rw->decrRef(); - mesh->decrRef(); -} - -void MEDLoaderTest::testMesh3DSurfRW() -{ - MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - mesh->checkCoherency(); - MEDLoader::WriteUMesh("file4.med",mesh,true); - MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile("file4.med",mesh->getName(),0); - CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12)); - mesh_rw->decrRef(); - mesh->decrRef(); -} - -void MEDLoaderTest::testMesh3DRW() -{ - MEDCouplingUMesh *mesh=build3DMesh_1(); - mesh->checkCoherency(); - MEDLoader::WriteUMesh("file5.med",mesh,true); - MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile("file5.med",mesh->getName(),0); - CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12)); - mesh_rw->decrRef(); - mesh->decrRef(); -} - -/*! - * Most basic test : one and only one MEDCoupling field in a new file. - */ -void MEDLoaderTest::testFieldRW1() -{ - MEDCouplingFieldDouble *f1=buildVecFieldOnCells_1(); - MEDLoader::WriteField("file6.med",f1,true); - MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell("file6.med",f1->getMesh()->getName(),0,f1->getName(),0,1); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - f1->decrRef(); - f2->decrRef(); - // - f1=buildVecFieldOnNodes_1(); - MEDLoader::WriteField("file7.med",f1,true); - f2=MEDLoader::ReadFieldNode("file7.med",f1->getMesh()->getName(),0,f1->getName(),2,3); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - f1->decrRef(); - f2->decrRef(); -} - -/*! - * Multi field writing in a same file. - */ -void MEDLoaderTest::testFieldRW2() -{ - const char fileName[]="file8.med"; - static const double VAL1=12345.67890314; - static const double VAL2=-1111111111111.; - MEDCouplingFieldDouble *f1=buildVecFieldOnCells_1(); - MEDLoader::WriteField(fileName,f1,true); - f1->setTime(10.,8,9); - double *tmp=f1->getArray()->getPointer(); - tmp[0]=VAL1; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->setTime(10.14,18,19); - tmp[0]=VAL2; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - //retrieving time steps... - MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),8,9); - f1->setTime(10.,8,9); - tmp[0]=VAL1; - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - f2->decrRef(); - f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),0,1); - MEDCouplingFieldDouble *f3=buildVecFieldOnCells_1(); - CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12)); - f3->decrRef(); - f2->decrRef(); - f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),18,19); - f1->setTime(10.14,18,19); - tmp[0]=VAL2; - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - //test of throw on invalid (dt,it) - CPPUNIT_ASSERT_THROW(MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),28,19),INTERP_KERNEL::Exception); - f2->decrRef(); - f1->decrRef(); - //ON NODES - f1=buildVecFieldOnNodes_1(); - const char fileName2[]="file9.med"; - MEDLoader::WriteField(fileName2,f1,true); - f1->setTime(110.,108,109); - tmp=f1->getArray()->getPointer(); - tmp[3]=VAL1; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName2,f1); - f1->setTime(210.,208,209); - tmp[3]=VAL2; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName2,f1); - f2=MEDLoader::ReadFieldNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),108,109); - f1->setTime(110.,108,109); - tmp[3]=VAL1; - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - f2->decrRef(); - f2=MEDLoader::ReadFieldNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),2,3); - f3=buildVecFieldOnNodes_1(); - CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12)); - f3->decrRef(); - f2->decrRef(); - f2=MEDLoader::ReadFieldNode(fileName2,f1->getMesh()->getName(),0,f1->getName(),208,209); - f1->setTime(210.,208,209); - tmp[3]=VAL2; - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - f2->decrRef(); - f1->decrRef(); -} - -/*! - * Multi field in a same file, but this field has several - */ -void MEDLoaderTest::testFieldRW3() -{ - const char fileName[]="file11.med"; - static const double VAL1=12345.67890314; - static const double VAL2=-1111111111111.; - const char name1[]="AField"; - const char name3[]="AMesh1"; - MEDCouplingFieldDouble *f1=buildVecFieldOnCells_1(); - ((MEDCouplingMesh *)f1->getMesh())->setName(name3); - f1->setName(name1); - f1->setTime(10.,8,9); - double *tmp=f1->getArray()->getPointer(); - tmp[0]=VAL1; - MEDLoader::WriteField(fileName,f1,true); - f1->setTime(10.14,18,19); - tmp[0]=VAL2; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->setTime(10.55,28,29); - tmp[0]=3*VAL1; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->setTime(10.66,38,39); - tmp[0]=3*VAL2; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->setTime(10.77,48,49); - tmp[0]=4*VAL2; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - //ON NODES - f1->decrRef(); - f1=buildVecFieldOnNodes_1(); - f1->setName(name1); - ((MEDCouplingMesh *)f1->getMesh())->setName(name3); - f1->setTime(110.,8,9); - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->setTime(110.,108,109); - tmp=f1->getArray()->getPointer(); - tmp[3]=VAL1; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->setTime(210.,208,209); - tmp[3]=VAL2; - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - // - std::vector< std::pair > it1=MEDLoader::GetCellFieldIterations(fileName,name3,name1); - CPPUNIT_ASSERT_EQUAL(5,(int)it1.size()); - CPPUNIT_ASSERT_EQUAL(8,it1[0].first); CPPUNIT_ASSERT_EQUAL(9,it1[0].second); - CPPUNIT_ASSERT_EQUAL(18,it1[1].first); CPPUNIT_ASSERT_EQUAL(19,it1[1].second); - CPPUNIT_ASSERT_EQUAL(28,it1[2].first); CPPUNIT_ASSERT_EQUAL(29,it1[2].second); - CPPUNIT_ASSERT_EQUAL(38,it1[3].first); CPPUNIT_ASSERT_EQUAL(39,it1[3].second); - CPPUNIT_ASSERT_EQUAL(48,it1[4].first); CPPUNIT_ASSERT_EQUAL(49,it1[4].second); - std::vector< std::pair > it3=MEDLoader::GetNodeFieldIterations(fileName,name3,name1); - CPPUNIT_ASSERT_EQUAL(3,(int)it3.size()); - CPPUNIT_ASSERT_EQUAL(8,it3[0].first); CPPUNIT_ASSERT_EQUAL(9,it3[0].second); - CPPUNIT_ASSERT_EQUAL(108,it3[1].first); CPPUNIT_ASSERT_EQUAL(109,it3[1].second); - CPPUNIT_ASSERT_EQUAL(208,it3[2].first); CPPUNIT_ASSERT_EQUAL(209,it3[2].second); - // - f1->decrRef(); - // - f1=MEDLoader::ReadFieldCell(fileName,name3,0,name1,8,9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL1,f1->getArray()->getConstPointer()[0],1e-13); - f1->decrRef(); - f1=MEDLoader::ReadFieldCell(fileName,name3,0,name1,18,19); - CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL2,f1->getArray()->getConstPointer()[0],1e-13); - f1->decrRef(); - f1=MEDLoader::ReadFieldCell(fileName,name3,0,name1,28,29); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3*VAL1,f1->getArray()->getConstPointer()[0],1e-13); - f1->decrRef(); - f1=MEDLoader::ReadFieldCell(fileName,name3,0,name1,38,39); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3*VAL2,f1->getArray()->getConstPointer()[0],1e-13); - f1->decrRef(); - f1=MEDLoader::ReadFieldCell(fileName,name3,0,name1,48,49); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4*VAL2,f1->getArray()->getConstPointer()[0],1e-13); - f1->decrRef(); - // - f1=MEDLoader::ReadFieldNode(fileName,name3,0,name1,8,9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(71.,f1->getArray()->getConstPointer()[3],1e-13); - f1->decrRef(); - f1=MEDLoader::ReadFieldNode(fileName,name3,0,name1,108,109); - CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL1,f1->getArray()->getConstPointer()[3],1e-13); - f1->decrRef(); - f1=MEDLoader::ReadFieldNode(fileName,name3,0,name1,208,209); - CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL2,f1->getArray()->getConstPointer()[3],1e-13); - f1->decrRef(); -} - -void MEDLoaderTest::testMultiMeshRW1() -{ - const char fileName[]="file10.med"; - MEDCouplingUMesh *mesh1=build3DMesh_1(); - const int part1[5]={1,2,4,13,15}; - MEDCouplingUMesh *mesh2=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part1,part1+5,true); - mesh2->setName("mesh2"); - const int part2[4]={3,4,13,14}; - MEDCouplingUMesh *mesh3=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part2,part2+4,true); - mesh3->setName("mesh3"); - MEDCouplingUMesh *mesh4=MEDCouplingUMesh::New(); - mesh4->setName("mesh4"); - mesh4->setMeshDimension(3); - mesh4->allocateCells(1); - int conn[4]={0,11,1,3}; - mesh4->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn); - mesh4->finishInsertingCells(); - mesh4->setCoords(mesh1->getCoords()); - std::vector meshes; - meshes.push_back(mesh1); - meshes.push_back(mesh2); - meshes.push_back(mesh3); - meshes.push_back(mesh4); - const char mnane[]="3DToto"; - MEDLoader::WriteUMeshesPartition(fileName,mnane,meshes,true); - // - MEDCouplingUMesh *mesh5=MEDLoader::ReadUMeshFromFile(fileName,mnane); - mesh1->setName(mnane); - const int part3[18]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; - MEDCouplingUMesh *mesh6=(MEDCouplingUMesh *)mesh5->buildPartOfMySelf(part3,part3+18,true); - mesh6->setName(mnane); - mesh5->decrRef(); - CPPUNIT_ASSERT(mesh6->isEqual(mesh1,1e-12)); - mesh6->decrRef(); - std::vector grps=MEDLoader::GetMeshGroupsNames(fileName,mnane); - CPPUNIT_ASSERT_EQUAL(4,(int)grps.size()); - CPPUNIT_ASSERT(std::find(grps.begin(),grps.end(),std::string("mesh2"))!=grps.end()); - CPPUNIT_ASSERT(std::find(grps.begin(),grps.end(),std::string("mesh3"))!=grps.end()); - CPPUNIT_ASSERT(std::find(grps.begin(),grps.end(),std::string("mesh4"))!=grps.end()); - CPPUNIT_ASSERT(std::find(grps.begin(),grps.end(),std::string("3DMesh_1"))!=grps.end()); - // - std::vector vec; - vec.push_back(std::string("mesh2")); - MEDCouplingUMesh *mesh2_2=MEDLoader::ReadUMeshFromGroups(fileName,mnane,0,vec); - CPPUNIT_ASSERT(mesh2_2->isEqual(mesh2,1e-12)); - mesh2_2->decrRef(); - vec.clear(); vec.push_back(std::string("mesh3")); - MEDCouplingUMesh *mesh3_2=MEDLoader::ReadUMeshFromGroups(fileName,mnane,0,vec); - CPPUNIT_ASSERT(mesh3_2->isEqual(mesh3,1e-12)); - mesh3_2->decrRef(); - vec.clear(); vec.push_back(std::string("mesh4")); - MEDCouplingUMesh *mesh4_2=MEDLoader::ReadUMeshFromGroups(fileName,mnane,0,vec); - CPPUNIT_ASSERT(mesh4_2->isEqual(mesh4,1e-12)); - mesh4_2->decrRef(); - vec.clear(); vec.push_back(std::string("3DMesh_1")); - MEDCouplingUMesh *mesh1_2=MEDLoader::ReadUMeshFromGroups(fileName,mnane,0,vec); - mesh1->setName("3DMesh_1"); - CPPUNIT_ASSERT(mesh1_2->isEqual(mesh1,1e-12)); - mesh1_2->decrRef(); - // - vec.clear(); vec.push_back(std::string("Family_4")); vec.push_back(std::string("Family_2")); - mesh2_2=MEDLoader::ReadUMeshFromFamilies(fileName,mnane,0,vec); - mesh2_2->setName("mesh2"); - CPPUNIT_ASSERT(mesh2_2->isEqual(mesh2,1e-12)); - mesh2_2->decrRef(); - // - mesh4->decrRef(); - mesh3->decrRef(); - mesh2->decrRef(); - mesh1->decrRef(); -} - -void MEDLoaderTest::testFieldProfilRW1() -{ - const char fileName[]="file12.med"; - MEDCouplingUMesh *mesh1=build3DMesh_1(); - bool b; - int newNbOfNodes; - DataArrayInt *da=mesh1->mergeNodes(1e-12,b,newNbOfNodes); - da->decrRef(); - MEDLoader::WriteUMesh(fileName,mesh1,true); - const int part1[5]={1,2,4,13,15}; - MEDCouplingUMesh *mesh2=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part1,part1+5,true); - mesh2->setName(mesh1->getName());//<- important for the test - // - int nbOfCells=mesh2->getNumberOfCells(); - CPPUNIT_ASSERT_EQUAL(5,nbOfCells); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setName("VectorFieldOnCells"); - f1->setMesh(mesh2); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(nbOfCells,2); - f1->setArray(array); - array->decrRef(); - double *tmp=array->getPointer(); - const double arr1[10]={71.,171.,10.,110.,20.,120.,30.,130.,40.,140.}; - std::copy(arr1,arr1+10,tmp); - f1->setTime(3.14,2,7); - f1->checkCoherency(); - // - MEDLoader::WriteField(fileName,f1,false);//<- false important for the test - // - MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),2,7); - f2->checkCoherency(); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - // - f2->decrRef(); - f1->decrRef(); - mesh1->decrRef(); - mesh2->decrRef(); -} - -void MEDLoaderTest::testFieldNodeProfilRW1() -{ - const char fileName[]="file19.med"; - const char fileName2[]="file20.med"; - MEDCouplingUMesh *m=build2DMesh_1(); - int nbOfNodes=m->getNumberOfNodes(); - MEDLoader::WriteUMesh(fileName,m,true); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); - f1->setName("VFieldOnNodes"); - f1->setMesh(m); - DataArrayDouble *array=DataArrayDouble::New(); - const double arr1[24]={1.,101.,2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.}; - array->alloc(nbOfNodes,2); - std::copy(arr1,arr1+24,array->getPointer()); - f1->setArray(array); - array->setInfoOnComponent(0,"tyty (mm)"); - array->setInfoOnComponent(1,"uiop (MW)"); - array->decrRef(); - f1->setTime(3.14,2,7); - f1->checkCoherency(); - const int arr2[6]={2,4,5,3,6,7}; - MEDCouplingFieldDouble *f2=f1->buildSubPart(arr2,arr2+6); - ((MEDCouplingMesh *)f2->getMesh())->setName(f1->getMesh()->getName()); - MEDLoader::WriteField(fileName,f2,false);//<- false important for the test - // - MEDCouplingFieldDouble *f3=MEDLoader::ReadFieldNode(fileName,f2->getMesh()->getName(),0,f2->getName(),2,7); - f3->checkCoherency(); - CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12)); - f3->decrRef(); - // - const int arr3[6]={1,3,0,5,2,4}; - f2->renumberNodes(arr3); - MEDLoader::WriteUMesh(fileName2,m,true); - MEDLoader::WriteField(fileName2,f2,false);//<- false important for the test - f3=MEDLoader::ReadFieldNode(fileName,f2->getMesh()->getName(),0,f2->getName(),2,7); - f3->checkCoherency(); - //CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));//<- bug - f3->decrRef(); - f2->decrRef(); - // - f1->decrRef(); - m->decrRef(); -} - -void MEDLoaderTest::testFieldGaussRW1() -{ - const char fileName[]="file13.med"; - MEDCouplingFieldDouble *f1=buildVecFieldOnGauss_1(); - MEDLoader::WriteField(fileName,f1,true); - MEDCouplingFieldDouble *f2=MEDLoader::ReadField(ON_GAUSS_PT,fileName,f1->getMesh()->getName(),0,f1->getName(),1,5); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - f2->decrRef(); - f1->decrRef(); -} - -void MEDLoaderTest::testFieldGaussNERW1() -{ - const char fileName[]="file14.med"; - MEDCouplingFieldDouble *f1=buildVecFieldOnGaussNE_1(); - MEDLoader::WriteField(fileName,f1,true); - MEDCouplingFieldDouble *f2=MEDLoader::ReadField(ON_GAUSS_NE,fileName,f1->getMesh()->getName(),0,f1->getName(),1,5); - CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); - f2->decrRef(); - f1->decrRef(); -} - -void MEDLoaderTest::testLittleStrings1() -{ - std::string s("azeeeerrrtty"); - MEDLoaderBase::zipEqualConsChar(s,3); - CPPUNIT_ASSERT(s=="azertty"); -} - -void MEDLoaderTest::testMesh3DSurfShuffleRW() -{ - const char fileName[]="file15.med"; - MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - const int renumber1[6]={2,5,1,0,3,4}; - mesh->renumberCells(renumber1,false); - mesh->checkCoherency(); - MEDLoader::WriteUMesh(fileName,mesh,true); - MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(fileName,mesh->getName(),0); - CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12)); - mesh_rw->decrRef(); - mesh->decrRef(); -} - -void MEDLoaderTest::testFieldShuffleRW1() -{ - const char fileName[]="file16.med"; - MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setName("FieldOnCellsShuffle"); - f1->setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(6,2); - f1->setArray(array); - array->decrRef(); - double *tmp=array->getPointer(); - const double arr1[12]={71.,171.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.}; - std::copy(arr1,arr1+12,tmp); - f1->setTime(3.14,2,7); - f1->checkCoherency(); - // - const int renumber1[6]={2,1,5,0,3,4}; - f1->renumberCells(renumber1,false); - MEDLoader::WriteField(fileName,f1,true); - MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,mesh->getName(),0,f1->getName(),2,7); - CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12)); - f2->decrRef(); - // - mesh->decrRef(); - f1->decrRef(); -} - -void MEDLoaderTest::testMultiFieldShuffleRW1() -{ - const char fileName[]="file17.med"; - MEDCouplingUMesh *m=build3DMesh_2(); - CPPUNIT_ASSERT_EQUAL(20,m->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(45,m->getNumberOfNodes()); - const int polys[3]={1,4,6}; - std::vector poly2(polys,polys+3); - m->convertToPolyTypes(poly2); - const int renum[20]={1,3,2,8,9,12,13,16,19,0,4,7,5,15,14,17,10,18,6,11}; - m->renumberCells(renum,false); - m->orientCorrectlyPolyhedrons(); - // Writing - MEDLoader::WriteUMesh(fileName,m,true); - MEDCouplingFieldDouble *f1Tmp=m->getMeasureField(false); - MEDCouplingFieldDouble *f1=f1Tmp->buildNewTimeReprFromThis(ONE_TIME,false); - f1Tmp->decrRef(); - f1->setTime(0.,1,2); - MEDCouplingFieldDouble *f_1=f1->cloneWithMesh(true); - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->applyFunc("2*x"); - f1->setTime(0.01,3,4); - MEDCouplingFieldDouble *f_2=f1->cloneWithMesh(true); - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->applyFunc("2*x/3"); - f1->setTime(0.02,5,6); - MEDCouplingFieldDouble *f_3=f1->cloneWithMesh(true); - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - f1->decrRef(); - // Reading - std::vector > its; - its.push_back(std::pair(1,2)); - its.push_back(std::pair(3,4)); - its.push_back(std::pair(5,6)); - std::vector fs=MEDLoader::ReadFieldsOnSameMesh(ON_CELLS,fileName,f_1->getMesh()->getName(),0,f_1->getName(),its); - CPPUNIT_ASSERT_EQUAL(3,(int)fs.size()); - const MEDCouplingMesh *mm=fs[0]->getMesh(); - CPPUNIT_ASSERT(fs[0]->isEqual(f_1,1e-12,1e-12)); - CPPUNIT_ASSERT(fs[1]->isEqual(f_2,1e-12,1e-12)); - CPPUNIT_ASSERT(fs[2]->isEqual(f_3,1e-12,1e-12)); - CPPUNIT_ASSERT(mm==fs[1]->getMesh());// <- important for the test - CPPUNIT_ASSERT(mm==fs[2]->getMesh());// <- important for the test - for(std::vector::iterator iter=fs.begin();iter!=fs.end();iter++) - (*iter)->decrRef(); - // - f_1->decrRef(); - f_2->decrRef(); - f_3->decrRef(); - // - m->decrRef(); -} - -void MEDLoaderTest::testWriteUMeshesRW1() -{ - const char fileName[]="file18.med"; - MEDCouplingUMesh *m3d=build3DMesh_2(); - const double pt[3]={0.,0.,-0.3}; - const double vec[3]={0.,0.,1.}; - std::vector nodes; - m3d->findNodesOnPlane(pt,vec,1e-12,nodes); - MEDCouplingUMesh *m2d=(MEDCouplingUMesh *)m3d->buildFacePartOfMySelfNode(&nodes[0],&nodes[0]+nodes.size(),true); - const int renumber[5]={1,2,0,4,3}; - m2d->renumberCells(renumber,false); - m2d->setName("ExampleOfMultiDimW"); - std::vector meshes; - meshes.push_back(m2d); - meshes.push_back(m3d); - MEDLoader::WriteUMeshes(fileName,meshes,true); - MEDCouplingUMesh *m3d_bis=MEDLoader::ReadUMeshFromFile(fileName,m2d->getName(),0); - CPPUNIT_ASSERT(!m3d_bis->isEqual(m3d,1e-12)); - m3d_bis->setName(m3d->getName()); - CPPUNIT_ASSERT(m3d_bis->isEqual(m3d,1e-12)); - MEDCouplingUMesh *m2d_bis=MEDLoader::ReadUMeshFromFile(fileName,m2d->getName(),-1);//-1 for faces - CPPUNIT_ASSERT(m2d_bis->isEqual(m2d,1e-12)); - // Creation of a field on faces. - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setName("FieldOnFacesShuffle"); - f1->setMesh(m2d); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(m2d->getNumberOfCells(),2); - array->setInfoOnComponent(0,"plkj (mm)"); - array->setInfoOnComponent(1,"pqqqss (mm)"); - f1->setArray(array); - array->decrRef(); - double *tmp=array->getPointer(); - const double arr1[10]={71.,171.,10.,110.,20.,120.,30.,130.,40.,140.}; - std::copy(arr1,arr1+10,tmp); - f1->setTime(3.14,2,7); - f1->checkCoherency(); - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),-1,f1->getName(),2,7); - CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12)); - f1->decrRef(); - f2->decrRef(); - // - m2d_bis->decrRef(); - m3d_bis->decrRef(); - m2d->decrRef(); - m3d->decrRef(); -} - -void MEDLoaderTest::testMixCellAndNodesFieldRW1() -{ - const char fileName[]="file21.med"; - MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setName("FieldMix"); - f1->setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(6,2); - f1->setArray(array); - array->setInfoOnComponent(0,"plkj (mm)"); - array->setInfoOnComponent(1,"pqqqss (mm)"); - array->decrRef(); - double *tmp=array->getPointer(); - const double arr1[12]={71.,171.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.}; - std::copy(arr1,arr1+12,tmp); - f1->setTime(3.14,2,7); - f1->checkCoherency(); - // - MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); - f2->setName("FieldMix"); - f2->setMesh(mesh); - array=DataArrayDouble::New(); - array->alloc(12,2); - f2->setArray(array); - array->setInfoOnComponent(0,"plkj (mm)"); - array->setInfoOnComponent(1,"pqqqss (mm)"); - array->decrRef(); - tmp=array->getPointer(); - const double arr2[24]={ - 1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150., - 1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192. - }; - std::copy(arr2,arr2+24,tmp); - f2->setTime(3.14,2,7); - f2->checkCoherency(); - // - MEDLoader::WriteField(fileName,f1,true); - std::vector ts=MEDLoader::GetTypesOfField(fileName,f1->getName(),f1->getMesh()->getName()); - CPPUNIT_ASSERT_EQUAL(1,(int)ts.size()); - CPPUNIT_ASSERT_EQUAL(ON_CELLS,ts[0]); - std::vector fs=MEDLoader::GetAllFieldNamesOnMesh(fileName,f1->getMesh()->getName()); - CPPUNIT_ASSERT_EQUAL(1,(int)fs.size()); - CPPUNIT_ASSERT(fs[0]=="FieldMix"); - MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fileName,f2); - fs=MEDLoader::GetAllFieldNamesOnMesh(fileName,f1->getMesh()->getName()); - CPPUNIT_ASSERT_EQUAL(1,(int)fs.size()); - CPPUNIT_ASSERT(fs[0]=="FieldMix"); - // - ts=MEDLoader::GetTypesOfField(fileName,f1->getName(),f1->getMesh()->getName()); - CPPUNIT_ASSERT_EQUAL(2,(int)ts.size()); - CPPUNIT_ASSERT_EQUAL(ON_NODES,ts[0]); - CPPUNIT_ASSERT_EQUAL(ON_CELLS,ts[1]); - // - MEDCouplingFieldDouble *f3=MEDLoader::ReadFieldNode(fileName,f1->getMesh()->getName(),0,f1->getName(),2,7); - CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12)); - f3->decrRef(); - f3=MEDLoader::ReadFieldCell(fileName,f1->getMesh()->getName(),0,f1->getName(),2,7); - CPPUNIT_ASSERT(f3->isEqual(f1,1e-12,1e-12)); - f3->decrRef(); - // - f1->decrRef(); - f2->decrRef(); - mesh->decrRef(); -} - -MEDCouplingUMesh *MEDLoaderTest::build1DMesh_1() -{ - double coords[6]={ 0.0, 0.3, 0.75, 1.0, 1.4, 1.3 }; - int conn[9]={ 0,1, 1,2, 2,3 , 3,4,5}; - MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); - mesh->setName("1DMesh_1"); - mesh->setMeshDimension(1); - mesh->allocateCells(4); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+6); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(6,1); - myCoords->setInfoOnComponent(0,"tototototototot (m*m*m*m*m*m*m*m)"); - std::copy(coords,coords+6,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - return mesh; -} - -MEDCouplingUMesh *MEDLoaderTest::build2DCurveMesh_1() -{ - double coords[12]={ 0.0,0.0, 0.3,0.3, 0.75,0.75, 1.0,1.0, 1.4,1.4, 1.3,1.3 }; - int conn[9]={ 0,1, 1,2, 2,3 , 3,4,5}; - MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); - mesh->setName("2DCurveMesh_1"); - mesh->setMeshDimension(1); - mesh->allocateCells(4); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+6); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(6,2); - std::copy(coords,coords+12,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - return mesh; -} - -MEDCouplingUMesh *MEDLoaderTest::build2DMesh_1() -{ - double targetCoords[24]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, -0.05,0.95, 0.2,1.2, 0.45,0.95 }; - int targetConn[24]={1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(6); - targetMesh->setName("2DMesh_1"); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,targetConn+6); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+12); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+16); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POLYGON,4,targetConn+20); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(12,2); - myCoords->setInfoOnComponent(0,"tototototototot (m)"); - myCoords->setInfoOnComponent(1,"energie (kW)"); - std::copy(targetCoords,targetCoords+24,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDLoaderTest::build2DMesh_2() -{ - double targetCoords[24]={ - -0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, - -0.05,0.95, 0.2,1.2, 0.45,0.95 - }; - int targetConn[24]={1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(5); - targetMesh->setName("2DMesh_2"); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,targetConn+6); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+12); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+16); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(12,2); - myCoords->setInfoOnComponent(0,"toto (m)"); - myCoords->setInfoOnComponent(1,"energie (kW)"); - std::copy(targetCoords,targetCoords+24,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDLoaderTest::build3DSurfMesh_1() -{ - double targetCoords[36]={ - -0.3,-0.3,-0.3, 0.2,-0.3,-0.3, 0.7,-0.3,-0.3, -0.3,0.2,-0.3, 0.2,0.2,-0.3, 0.7,0.2,-0.3, -0.3,0.7,-0.3, 0.2,0.7,-0.3, 0.7,0.7,-0.3 - ,-0.05,0.95,-0.3, 0.2,1.2,-0.3, 0.45,0.95,-0.3 - }; - int targetConn[24]={1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); - targetMesh->setMeshDimension(2); - targetMesh->allocateCells(6); - targetMesh->setName("3DSurfMesh_1"); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,targetConn+6); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+12); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+16); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POLYGON,4,targetConn+20); - targetMesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(12,3); - myCoords->setInfoOnComponent(0,"toto (m)"); - myCoords->setInfoOnComponent(2,"ff (km)");//component 1 is not set for test - std::copy(targetCoords,targetCoords+36,myCoords->getPointer()); - targetMesh->setCoords(myCoords); - myCoords->decrRef(); - return targetMesh; -} - -MEDCouplingUMesh *MEDLoaderTest::build3DMesh_1() -{ - double coords[180]={ - 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., - 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., - 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., - 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1., - 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., - 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2., - 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., - 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.}; - - int conn[354]={ - // 0 - 0,11,1,3,15,26,16,18, 1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17, - 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21, - 11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23, - 7,12,14,13,22,27,29,28, - // 1 - 15,26,16,18,30,41,31,33, 16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32, - 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36, - 26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38, - 22,27,29,28,37,42,44,43, - // 2 - 30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47, - 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51, - 41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53, - 37,42,44,43,52,57,59,58 - }; - // - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setName("3DMesh_1"); - ret->setMeshDimension(3); - ret->allocateCells(18); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+51); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+59); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+110); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+118); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+169); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+177); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+228); - // - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+236); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+287); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+295); - ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+346); - // - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+8); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+67); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+126); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+185); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+244); - ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+303); - // - ret->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(60,3); - myCoords->setInfoOnComponent(0,"titi (m)"); - myCoords->setInfoOnComponent(1,"density power (MW/m^3)"); - myCoords->setInfoOnComponent(2,"t (kW)"); - std::copy(coords,coords+180,myCoords->getPointer()); - ret->setCoords(myCoords); - myCoords->decrRef(); - return ret; -} - -MEDCouplingUMesh *MEDLoaderTest::build3DMesh_2() -{ - MEDCouplingUMesh *m3dsurfBase=build3DSurfMesh_1(); - int numbers[5]={0,1,3,4,5}; - MEDCouplingUMesh *m3dsurf=(MEDCouplingUMesh *)m3dsurfBase->buildPartOfMySelf(numbers,numbers+5,false); - m3dsurfBase->decrRef(); - MEDCouplingUMesh *m1dBase=build1DMesh_1(); - int numbers2[4]={0,1,2,3}; - MEDCouplingUMesh *m1d=(MEDCouplingUMesh *)m1dBase->buildPartOfMySelf(numbers2,numbers2+4,false); - m1dBase->decrRef(); - m1d->changeSpaceDimension(3); - const double vec[3]={0.,1.,0.}; - const double pt[3]={0.,0.,0.}; - m1d->rotate(pt,vec,-M_PI/2.); - MEDCouplingUMesh *ret=m3dsurf->buildExtrudedMeshFromThis(m1d,0); - m1d->decrRef(); - m3dsurf->decrRef(); - return ret; -} - -MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnCells_1() -{ - MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - int nbOfCells=mesh->getNumberOfCells(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setName("VectorFieldOnCells"); - f1->setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(nbOfCells,3); - array->setInfoOnComponent(0,"power (MW/m^3)"); - array->setInfoOnComponent(1,"density (g/cm^3)"); - array->setInfoOnComponent(2,"temperature (K)"); - f1->setArray(array); - array->decrRef(); - double *tmp=array->getPointer(); - const double arr1[18]={0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.}; - std::copy(arr1,arr1+18,tmp); - f1->setTime(2.,0,1); - f1->checkCoherency(); - mesh->decrRef(); - return f1; -} - -MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnNodes_1() -{ - MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - int nbOfNodes=mesh->getNumberOfNodes(); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); - f1->setName("VectorFieldOnNodes"); - f1->setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(nbOfNodes,3); - f1->setArray(array); - array->setInfoOnComponent(0,"power (MW/m^3)"); - array->setInfoOnComponent(1,"density (g/cm^3)"); - array->setInfoOnComponent(2,"temperature (K)"); - array->decrRef(); - double *tmp=array->getPointer(); - const double arr1[36]={ - 70.,80.,90.,71.,81.,91.,72.,82.,92.,73.,83.,93.,74.,84.,94.,75.,85.,95., - 1000.,10010.,10020.,1001.,10011.,10021.,1002.,10012.,10022.,1003.,10013.,10023.,1004.,10014.,10024.,1005.,10015.,10025., - }; - std::copy(arr1,arr1+36,tmp); - f1->setTime(2.12,2,3); - f1->checkCoherency(); - mesh->decrRef(); - return f1; -} - -MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnGauss_1() -{ - const double _a=0.446948490915965; - const double _b=0.091576213509771; - const double _p1=0.11169079483905; - const double _p2=0.0549758718227661; - const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. }; - const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, - 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 }; - const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 }; - std::vector _refCoo1(refCoo1,refCoo1+6); - std::vector _gsCoo1(gsCoo1,gsCoo1+12); - std::vector _wg1(wg1,wg1+6); - MEDCouplingUMesh *m=build2DMesh_2(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME); - f->setTime(3.14,1,5); - f->setMesh(m); - f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1); - const double refCoo2[12]={-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 }; - std::vector _refCoo2(refCoo2,refCoo2+12); - _gsCoo1.resize(6); _wg1.resize(3); - f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,_refCoo2,_gsCoo1,_wg1); - const double refCoo3[8]={ 0.,0., 1.,0., 1.,1., 0.,1. }; - std::vector _refCoo3(refCoo3,refCoo3+8); - _gsCoo1.resize(4); _wg1.resize(2); - f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo3,_gsCoo1,_wg1); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(19,2); - double *ptr=array->getPointer(); - for(int i=0;i<19*2;i++) - ptr[i]=(double)(i+7); - f->setArray(array); - f->setName("MyFirstFieldOnGaussPoint"); - array->setInfoOnComponent(0,"power (MW/m^3)"); - array->setInfoOnComponent(1,"density"); - array->decrRef(); - f->checkCoherency(); - m->decrRef(); - return f; -} - -MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnGaussNE_1() -{ - MEDCouplingUMesh *m=build2DMesh_2(); - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME); - f->setTime(3.14,1,5); - f->setMesh(m); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(20,2); - double *ptr=array->getPointer(); - for(int i=0;i<20*2;i++) - ptr[i]=(double)(i+8); - f->setArray(array); - array->setInfoOnComponent(0,"power (W)"); - array->setInfoOnComponent(1,"temperature"); - f->setName("MyFieldOnGaussNE"); - array->decrRef(); - f->checkCoherency(); - m->decrRef(); - return f; -} - diff --git a/src/MEDLoader/Test/MEDLoaderTest.hxx b/src/MEDLoader/Test/MEDLoaderTest.hxx deleted file mode 100644 index 0863ad1df..000000000 --- a/src/MEDLoader/Test/MEDLoaderTest.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2007-2010 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 __MEDLOADERTEST_HXX__ -#define __MEDLOADERTEST_HXX__ - -#include - -namespace ParaMEDMEM -{ - class MEDCouplingUMesh; - class MEDCouplingFieldDouble; - - class MEDLoaderTest : public CppUnit::TestFixture - { - CPPUNIT_TEST_SUITE(MEDLoaderTest); - CPPUNIT_TEST( testMesh1DRW ); - CPPUNIT_TEST( testMesh2DCurveRW ); - CPPUNIT_TEST( testMesh2DRW ); - CPPUNIT_TEST( testMesh3DSurfRW ); - CPPUNIT_TEST( testMesh3DRW ); - CPPUNIT_TEST( testFieldRW1 ); - CPPUNIT_TEST( testFieldRW2 ); - CPPUNIT_TEST( testFieldRW3 ); - CPPUNIT_TEST( testMultiMeshRW1 ); - CPPUNIT_TEST( testFieldProfilRW1 ); - CPPUNIT_TEST( testFieldNodeProfilRW1 ); - CPPUNIT_TEST( testFieldGaussRW1 ); - CPPUNIT_TEST( testFieldGaussNERW1 ); - CPPUNIT_TEST( testLittleStrings1 ); - CPPUNIT_TEST( testMesh3DSurfShuffleRW ); - CPPUNIT_TEST( testFieldShuffleRW1 ); - CPPUNIT_TEST( testMultiFieldShuffleRW1 ); - CPPUNIT_TEST( testWriteUMeshesRW1 ); - CPPUNIT_TEST( testMixCellAndNodesFieldRW1 ); - CPPUNIT_TEST_SUITE_END(); - public: - void testMesh1DRW(); - void testMesh2DCurveRW(); - void testMesh2DRW(); - void testMesh3DSurfRW(); - void testMesh3DRW(); - void testFieldRW1(); - void testFieldRW2(); - void testFieldRW3(); - void testMultiMeshRW1(); - void testFieldProfilRW1(); - void testFieldNodeProfilRW1(); - void testFieldGaussRW1(); - void testFieldGaussNERW1(); - void testLittleStrings1(); - void testMesh3DSurfShuffleRW(); - void testFieldShuffleRW1(); - void testMultiFieldShuffleRW1(); - void testWriteUMeshesRW1(); - void testMixCellAndNodesFieldRW1(); - private: - MEDCouplingUMesh *build1DMesh_1(); - MEDCouplingUMesh *build2DCurveMesh_1(); - MEDCouplingUMesh *build2DMesh_1(); - MEDCouplingUMesh *build2DMesh_2(); - MEDCouplingUMesh *build3DSurfMesh_1(); - MEDCouplingUMesh *build3DMesh_1(); - MEDCouplingUMesh *build3DMesh_2(); - MEDCouplingFieldDouble *buildVecFieldOnCells_1(); - MEDCouplingFieldDouble *buildVecFieldOnNodes_1(); - MEDCouplingFieldDouble *buildVecFieldOnGauss_1(); - MEDCouplingFieldDouble *buildVecFieldOnGaussNE_1(); - }; -} - -#endif diff --git a/src/MEDLoader/Test/Makefile.am b/src/MEDLoader/Test/Makefile.am deleted file mode 100755 index 46e1c4052..000000000 --- a/src/MEDLoader/Test/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2007-2010 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -bin_PROGRAMS= TestMEDLoader - -TestMEDLoader_CPPFLAGS=@CPPUNIT_INCLUDES@ @PTHREAD_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../../INTERP_KERNEL/Bases -I$(srcdir)/../../INTERP_KERNELTest -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Geometric2D -I$(srcdir)/../../MEDCoupling - -TestMEDLoader_LDFLAGS = @CPPUNIT_LIBS@ ../libmedloader.la ../../MEDCoupling/libmedcoupling.la ../../INTERP_KERNEL/libinterpkernel.la - -dist_TestMEDLoader_SOURCES = TestMEDLoader.cxx MEDLoaderTest.cxx MEDLoaderTest.hxx - -UNIT_TEST_PROG = TestMEDLoader - -check : tests - -CLEANFILES = \ - UnitTestsResult - -clean-local: - rm -rf *.med - \ No newline at end of file diff --git a/src/MEDLoader/Test/TestMEDLoader.cxx b/src/MEDLoader/Test/TestMEDLoader.cxx deleted file mode 100644 index a48da92f5..000000000 --- a/src/MEDLoader/Test/TestMEDLoader.cxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2007-2010 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 "CppUnitTest.hxx" -#include "MEDLoaderTest.hxx" - -CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDLoaderTest ); - -#include "BasicMainTest.hxx" diff --git a/src/MEDMEM/DataTest/Data/pointe.med b/src/MEDMEM/DataTest/Data/pointe.med deleted file mode 100644 index 0dbc1e8fb..000000000 Binary files a/src/MEDMEM/DataTest/Data/pointe.med and /dev/null differ diff --git a/src/MedClient/test/resources/pointe.med b/src/MedClient/test/resources/pointe.med deleted file mode 100644 index 0dbc1e8fb..000000000 Binary files a/src/MedClient/test/resources/pointe.med and /dev/null differ diff --git a/src/ParaMEDLoader/Makefile.am b/src/ParaMEDLoader/Makefile.am deleted file mode 100755 index 624e6148b..000000000 --- a/src/ParaMEDLoader/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2007-2010 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES = libparamedloader.la - -salomeinclude_HEADERS= \ -ParaMEDLoader.hxx - -dist_libparamedloader_la_SOURCES= \ -ParaMEDLoader.cxx - -#libmedmem_la_LDFLAGS= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -libparamedloader_la_CPPFLAGS= $(MPI_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../MEDCoupling \ - -I$(srcdir)/../MEDLoader \ - -I$(srcdir)/../ParaMEDMEM - -libparamedloader_la_LDFLAGS= ../ParaMEDMEM/libparamedmem.la \ - ../MEDLoader/libmedloader.la \ - ../MEDCoupling/libmedcoupling.la \ - ../INTERP_KERNEL/libinterpkernel.la $(MPI_LIBS) $(MED2_LIBS) $(HDF5_LIBS) diff --git a/src/ParaMEDLoader/ParaMEDLoader.cxx b/src/ParaMEDLoader/ParaMEDLoader.cxx deleted file mode 100644 index 6aa090c71..000000000 --- a/src/ParaMEDLoader/ParaMEDLoader.cxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMEDLoader.hxx" -#include "MEDLoader.hxx" -#include "ParaMESH.hxx" -#include "BlockTopology.hxx" -#include "MEDCouplingUMesh.hxx" - -#include - -using namespace ParaMEDMEM; - -ParaMEDLoader::ParaMEDLoader() -{ -} - -void ParaMEDLoader::WriteParaMesh(const char *fileName, ParaMEDMEM::ParaMESH *mesh) -{ - if(!mesh->getBlockTopology()->getProcGroup()->containsMyRank()) - return ; - int myRank=mesh->getBlockTopology()->getProcGroup()->myRank(); - int nbDomains=mesh->getBlockTopology()->getProcGroup()->size(); - std::vector fileNames(nbDomains); - for(int i=0;igetCellMesh()->getName()); - MEDLoader::WriteUMesh(fileNames[myRank].c_str(),dynamic_cast(mesh->getCellMesh()),true); -} - -/*! - * This method builds the master file 'fileName' of a parallel MED file defined in 'fileNames'. - */ -void ParaMEDLoader::WriteMasterFile(const char *fileName, const std::vector& fileNames, const char *meshName) -{ - int nbOfDom=fileNames.size(); - std::ofstream fs(fileName); - fs << "#MED Fichier V 2.3" << " " << std::endl; - fs << "#"<<" " << std::endl; - fs << nbOfDom <<" " << std::endl; - for(int i=0;i -#include - -namespace ParaMEDMEM -{ - class ParaMESH; - class ParaFIELD; -} - -class ParaMEDLoader -{ -public: - static void WriteParaMesh(const char *fileName, ParaMEDMEM::ParaMESH *mesh); - static void WriteMasterFile(const char *fileName, const std::vector& fileNames, const char *meshName); -private: - ParaMEDLoader(); -}; - -#endif diff --git a/src/ParaMEDMEM/BASICS_JR b/src/ParaMEDMEM/BASICS_JR deleted file mode 100644 index 61a724d45..000000000 --- a/src/ParaMEDMEM/BASICS_JR +++ /dev/null @@ -1,339 +0,0 @@ - -Le document de specification : -============================== - -Globalement le document de specification correspond a -l'implementation qui a ete faite avec : - -. Transport-ParaMEDMEM qui a ete enrichi avec la classe MPI_Access - -. Presentation-ParaMEDMEM qui a ete enrichi avec la classe - MPI_AccessDEC - - -La conception correspondant a cette specification est restee -la meme : - -. MPI_Access gere pour un ProcessorGroup (IntraCommunicator) : - - Les structures MPI_Request et MPI_Status - - La valeur des "tags" MPI - - Les requetes d'ecritures et de lectures asynchrones - - Les communications en "Point a Point" [I]Send, [I]Recv ainsi - que [I]SendRecv. - - A la difference de l'API MPI [I]SendRecv ne concerne qu'un - seul et meme "target". - - Les controles de communications asynchrones Wait, Test, - WaitAll, TestAll, [I]Probe, Cancel et CancelAll. - - Comme c'etait demande seules les methodes "utiles" ont ete - implementees. - - Les appels a [I]Send ou a [I]Recv avec des sendbuff/recvbuff - de valeur NULL ou avec des sendcount/recvcount de valeur - nulle sont ignores. - - Les methodes de communications collectives ne sont pas - implementees dans MPI_Access. - - Les deux methodes "Cancel" concernent soit un IRecv deja - soumis soit un message en attente (sans IRecv deja soumis). - Elles regroupent les differents appels de l'API MPI - necessaires (IProbe, IRecv, Wait, Test_Canceled ...). - -. MPI_AccessDEC utilise les services de MPI_Access pour un - ProcessorGroup (IntraCommunicator) et gere : - - Les communications collectives en "Point a Point". - (AllToAll[v] synchrone ou asynchrone). - - Les temps et l'interpolation - - Les [I]Send avec leurs buffers (delete []) - - Les [I]Recv - - La finalisation des envois et receptions de messages dans - le destructeur afin qu'il n'y ait plus de message en attente - et afin de liberer les buffers - - -MPI_Access et "tags" (ou "MPITags") : -===================================== - -. Le constructeur permet optionnellement de fixer une plage de tags - a utiliser : [BaseTag , MaxTag]. - Par defaut c'est [ 0 , MPI_TAG_UB], MPI_TAG_UB etant la valeur - maximum d'une implementation de MPI (valeur minimum 32767 - soit 2**15-1). Sur awa avec l'implementation lam MPI_TAG_UB - vaut 7353944. La norme MPI specifie que cette valeur doit - etre la meme dans les process demarres avec mpirun. - Dans le cas de l'usage simultane du meme IntraCommunicator - dans un meme process (ou de plusieurs IntraCommunicator - d'intersection non nulle) cela peut eviter toute ambiguite - et aider au debug. - -. Dans MPI_Access les tags sont constitues de deux parties - (#define ModuloTag 10) : - + Le dernier digit decimal correspond au MPI_DataType ( 1 pour - les messages "temps", 2 pour MPI_INT et 3 pour MPI_DOUBLE) - + La valeur des autres digits correspond a une numerotation - circulaire des messages. - + Un message "temps" et le message de donnees associe ont le - meme numero de message (mais des types et donc des tags - differents). - -. Pour un envoi de message d'un process "source" vers un process - "target", on dispose de _SendMPITag[target] dans le process - source (il contient le dernier "tag" utilise pour l'envoi de - messages vers le process target). - Et dans le process "target" qui recoit ce message, on dispose - de _RecvMPITag[source] (il contient le dernier "tag" utilise - pour la reception de messages du process source). - Naturellement d'apres la norme MPI les valeurs de ces tags sont - les memes. - - -MPI_Access et "RequestIds" : -============================ - -. ATTENTION : Dans le document de specification, la distinction - n'est pas faite clairement entre les "MPITags" (voir ci-dessus) - qui sont un argument des appels a MPI et les "RequestIds" qui - ne concernent pas les appels MPI. Ces "RequestIds" figurent - en effet sous le nom de tag comme argument d'entree/sortie dans l'API - de MPI_Access decrite dans le document de specification. Mais - dans l'implementation on a bien le nom RequestId (ou bien - RecvRequestId/SendRequestId). - -. Lors de la soumission d'une requete d'ecriture ou de lecture MPI - via MPI_Access, on obtient un identifieur "RequestId". - Cet identifieur "RequestId" correspond a une structure RequestStruct - de MPI_Access a laquelle on accede avec la map - "_MapOfRequestStruct". - Cette structure RequestStruct permet de gerer MPI_Request et - MPI_Status * de MPI et permet d'obtenir des informations sur - la requete : target, send/recv, tag, [a]synchrone, type, outcount. - -. C'est cet identifieur qui peut etre utilise pour controler une - requete asynchrone via MPI_Access : Wait, Test, Probe, etc... - -. En pratique "RequestId" est simplement un entier de l'intervalle - [0 , 2**32-1]. Il y a uniquement un compteur cyclique global - aussi bien pour les [I]Send que pour les [I]Recv. - -. Ces "RequestIds" et leur structures associees facilitent les - communications asynchrones. - Par exemple on a mpi_access->Wait( int RequestId ) - au lieu de MPI_Wait(MPI_Request *request, MPI_Status *status) - avec gestion de status. - -. L'API de MPI_Access peut fournir les "SendRequestIds" d'un "target", - les "RecvRequestIds" d'un "source" ou bien les "SendRequestIds" de - tous les "targets" ou les "RecvRequestIds" de tous les "sources". - Cela permet d'eviter leur gestion au niveau de Presentation-ParaMEDMEM. - - -MPI_AccessDEC : -=============== - -. Comme la classe DEC, il est base sur local_group et distant_group - ce qui forme un MPI_union_group et donc un IntraCommunicator. - -. Il permet de choisir le mode synchrone ou asynchrone (par defaut). - Le meme programme peut fonctionner en synchrone ou en asynchrone - sans devoir etre modifie. - -. Il permet de choisir un mode d'interpolation (actuellement - uniquement une interpolation lineaire) ou bien un mode sans - interpolation (par defaut). Ceci pour les communications collectives. - Avec interpolation les communications collectives transmettent et - recoivent un message "temps" en plus des donnees. - -. Il implemente AllToAll[v] en "Point a Point" avec ou sans interpolation. - -. Il gere les buffers d'envoi de messages. Il les detruit donc - lorsqu'ils sont disponibles. - -. Il cree et utilise MPI_Access. - - -MPI_AccessDEC et la gestion des SendBuffers : -============================================= - -. Comme dans les communications collectives on n'envoie que des - parties du meme buffer à chaque process "target", il faut s'assurer - en asynchrone que toutes ces parties sont disponibles pour - pouvoir liberer le buffer. - -. On suppose que ces buffers ont ete alloues avec un new double[] - -. La structure SendBuffStruct permet de conserver l'adresse du buffer - et de gerer un compteur de references de ce buffer. Elle comporte - aussi MPI_Datatype pour pouvoir faire un delete [] (double *) ... - lorsque le compteur est null. - -. La map _MapOfSendBuffers etablit la correspondance entre chaque - RequestId obtenu de MPI_Access->ISend(...) et un SendBuffStruct - pour chaque "target" d'une partie du buffer. - -. Tout cela ne concerne que les envois asynchrones. En synchrone, - on detruit senbuf juste apres l'avoir transmis. - - -MPI_AccessDEC et la gestion des RecvBuffers : -============================================= - -S'il n'y a pas d'interpolation, rien de particulier n'est fait. - -Avec interpolation pour chaque target : ---------------------------------------- -. On a _TimeMessages[target] qui est un vecteur de TimesMessages. - On en a 2 dans notre cas avec une interpolation lineaire qui - contiennent le time(t0)/deltatime precedent et le dernier - time(t1)/deltatime. - -. On a _DataMessages[target] qui est un vecteur de DatasMessages - On en a 2 dans notre cas avec une interpolation lineaire qui - contiennent les donnees obtenues par Recv au time(t0)/deltatime - precedent et au dernier time(t1)/deltatime. - -. Au temps _t(t*) du processus courrant on effectue l'interpolation - entre les valeurs des 2 DatasMessages que l'on rend dans la - partie de recvbuf correspondant au target pourvu que t0 < t* <= t1. - -. Par suite de la difference des "deltatimes" entre process, on - peut avoir t0 < t1 < t* auquel cas on aura une extrapolation. - -. Les vecteurs _OutOfTime, _DataMessagesRecvCount et _DataMessagesType - contiennent pour chaque target true si t* > dernier t1, recvcount et - MPI_Datatype pour finaliser la gestion des messages a la fin. - - -Etapes des communications collectives de MPI_AccessDEC : -======================================================== - -AllToAll[v] : Les arguments sont les memes que dans MPI sauf MPI_Comm -------------- inutile (deja connu de MPI_AccessDEC et MPI_Access). - - Si on a un TimeInterpolator, appel de AllToAll[v]Time. - - Sinon, on appelle CheckSent pour les echanges - asynchrones (voir ci-apres) et on appelle SendRecv - pour chaque "target". - -AllToAll[v]Time : ------------------ - -. CheckSent() : - + appelle SendRequestIds de MPI_Access afin d'obtenir tous les - RequestIds d'envoi de messages a tous les "targets". - + Pour chaque RequestId, appelle Test de MPI_Access pour savoir - si le buffer est libre (flag = true). Lorsqu'il s'agit du - FinalCheckSent, on appelle Wait au lieu de Test. - + Si le buffer est libre, on decremente le compteur de la - structure SendBuffStruct obtenue avec _MapOfSendBuffers. - (voir MPI_AccessDEC et la gestion des SendBuffers ci-dessus) - + Si le compteur est nul on detruit le TimeMessage ou le - SendBuffer en fonction du DataType. - + Puis on detruit la structure SendBuffStruct avant de supprimer - (erase) cet item de _MapOfSendBuffers - -. DoSend : - + On cree un TimeMessage (voir cette structure dans MPI_Access). - + Si l'on est en asynchrone on cree deux structures SendBuffStruct - aSendTimeStruct et aSendDataStruct que l'on remplit. - + On remplit la structure aSendTimeMessage avec time/deltatime du - process courant. "deltatime" doit etre nul s'il s'agit du dernier - pas de temps. - + Puis pour chaque "target", on envoie le TimeMessage et la partie - de sendbuf concernee par ce target. - + Si l'on est en asynchrone, on incremente le compteur et on ajoute - a _MapOfSendBuffers aSendTimeStruct et aSendDataStruct avec les - identifieurs SendTimeRequestId et SendDataRequestId recus de - MPI_Access->Send(...). - + Et enfin si l'on est en synchrone, on detruit les SendMessages. - -. CheckTime(recvcount , recvtype , target , UntilEnd) - + Au depart, on lit le premier "Message-temps" dans - &(*_TimeMessages)[target][1] et le premier message de donnees - dans le buffer alloue (*_DataMessages)[target][1]. - + Par convention deltatime des messages temps est nul si c'est le - dernier. - + Boucle while : _t(t*) est le temps courant du processus. - "tant que _t(t*) est superieur au temps du "target" - (*_TimeMessages)[target][1].time et que - (*_TimeMessages)[target][1].deltatime n'est pas nul", - ainsi en fin de boucle on aura : - _t(t*) <= (*_TimeMessages)[target][1].time avec - _t(t*) > (*_TimeMessages)[target][0].time - ou bien on aura le dernier message temps du "target". - + S'il s'agit de la finalisation des receptions des messages - temps et donnees (UntilEnd vaut true), on effectue la - boucle jusqu'a ce que l'on trouve - (*_TimeMessages)[target][1].deltatime nul. - + Dans la boucle : - On recopie le dernier message temps dans le message temps - precedent et on lit le message temps suivant. - On detruit le buffer de donnees du temps precedent. - On recopie le pointeur du dernier buffer de donnees dans - le precedent. - On alloue un nouveau dernier buffer de donnees - (*_DataMessages)[target][1] et on lit les donnees - correspondantes dans ce buffer. - + Si le temps courant du process est plus grand que le dernier - temps (*_TimeMessages)[target][1].time du target, on donne - la valeur true a (*_OutOfTime)[target]. - (*_TimeMessages)[target][1].deltatime est alors nul. - -. CheckTime + DoRecv + DoInterp - + Pour chaque target on appelle CheckTime - + Si on a un TimeInterpolator et si le message temps du target - n'est pas le premier, on appelle l'interpolateur qui stocke - ses resultats dans la partie du buffer de reception qui - correspond au "target". - + Sinon, on recopie les donnees recues pour ce premier pas de - temps dans la partie du buffer de reception qui correspond au - "target". - - -Presentation-ParaMEDMEM : -========================= - -. Des modifications mineures ont ete effectuees dans Presentation-ParaMEDMEM - afin de pouvoir utiliser ces nouvelles fonctionnalites. Il n'y - a surtout pas eu de bouleversement destabilisateur. L'ancien - mode de fonctionnement reste naturellement disponible. - -. Cela repose sur trois nouvelles options creees avec registerOption - dans le constructeur de InterpKernelDEC : - + Asynchronous : true ou false (par defaut) - + TimeInterpolation : WithoutTimeInterp (par defaut) ou LinearTimeInterp - typedef enum{WithoutTimeInterp,LinearTimeInterp} TimeInterpolationMethod; - dans MPI_AccessDEC.hxx - + AllToAllMethod : Native (par defaut) ou PointToPoint - typedef enum{Native,PointToPoint} AllToAllMethod; - dans MxN_Mapping.hxx - -. Le choix des options se fait avec le Data Exchange Channel : - + ParaMEDMEM::InterpKernelDEC dec (*source_group,*target_group); - + dec.setOption("Asynchronous",true); - + dec.setOption("TimeInterpolation",LinearTimeInterp); - + dec.setOption("AllToAllMethod",PointToPoint); - -. Dans dec.synchronize(), - + on cree un objet InterpolationMatrix - qui lui-meme cree un objet MxN_Mapping - qui lui-meme cree maintenant un objet MPI_AccessDEC - + on transmet a MxN_Mapping via l'InterpolationMatrix l'option - choisie de AllToAllMethod - + on transmet a MPI_AccessDEC les valeurs des options Asynchronous - et TimeInterpolation : methodes Asynchronous et - SetTimeInterpolator de MPI_AccessDEC. - -. ParaMEDMEM::InterpKernelDEC comporte maintenant une surcharge des - methodes recvData() et sendData() : - + void InterpKernelDEC::recvData( double time ) qui appelle - SetTime(time) de MPI_AccessDEC et - recvData() - + void InterpKernelDEC::sendData( double time , double deltatime ) - qui appelle - SetTime(time,deltatime) de MPI_AccessDEC et - sendData() - -. recvData() et sendData() de ParaMEDMEM::InterpKernelDEC - appellent multiply et transposeMultiply de l'InterpolationMatrix - qui appellent sendRecv et reverseSendRecv de MxN_Mapping - qui appellent comm_interface.allToAllV en mode "Native" - ou bien MPI_AccessDEC::AllToAllv en mode "PointToPoint" - diff --git a/src/ParaMEDMEM/BlockTopology.cxx b/src/ParaMEDMEM/BlockTopology.cxx deleted file mode 100644 index 5d7cf0598..000000000 --- a/src/ParaMEDMEM/BlockTopology.cxx +++ /dev/null @@ -1,336 +0,0 @@ -// Copyright (C) 2007-2010 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 "BlockTopology.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingCMesh.hxx" -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "ComponentTopology.hxx" -#include "InterpKernelUtilities.hxx" - -#include -#include -#include -#include - -using namespace std; - -namespace ParaMEDMEM -{ - - //!converts a pair to a global number - std::pair BlockTopology::globalToLocal(const int global) const - { - int subdomain_id=0; - int position=global; - int size=_nb_elems; - int size_procs=_proc_group->size(); - int increment=size; - vectoraxis_position(_dimension); - vectoraxis_offset(_dimension); - for (int idim=0; idim<_dimension; idim++) - { - int axis_size=_local_array_indices[idim].size()-1; - int axis_nb_elem=_local_array_indices[idim][axis_size]; - increment=increment/axis_nb_elem; - int proc_increment = size_procs/(axis_size); - int axis_pos=position/increment; - position=position%increment; - int iaxis=1; - while (_local_array_indices[idim][iaxis]<=axis_pos) - { - subdomain_id+=proc_increment; - iaxis++; - } - axis_position[idim]=axis_pos-_local_array_indices[idim][iaxis-1]; - axis_offset[idim]=iaxis; - } - int local=0; - int local_increment=1; - for (int idim=_dimension-1; idim>=0; idim--) - { - local+=axis_position[idim]*local_increment; - local_increment*=_local_array_indices[idim][axis_offset[idim]]-_local_array_indices[idim][axis_offset[idim]-1]; - } - return make_pair(subdomain_id,local); - } - - //!converts local number to a global number - int BlockTopology::localToGlobal(const pair local) const - { - - int subdomain_id=local.first; - int global=0; - int loc=local.second; - int increment=_nb_elems; - int proc_increment=_proc_group->size(); - int local_increment=getNbLocalElements(); - for (int idim=0; idim < _dimension; idim++) - { - int axis_size=_local_array_indices[idim].size()-1; - int axis_nb_elem=_local_array_indices[idim][axis_size]; - increment=axis_nb_elem==0?0:increment/axis_nb_elem; - proc_increment = proc_increment/(axis_size); - int proc_axis=subdomain_id/proc_increment; - subdomain_id=subdomain_id%proc_increment; - int local_axis_nb_elem=_local_array_indices[idim][proc_axis+1]-_local_array_indices[idim][proc_axis]; - local_increment = (local_axis_nb_elem==0)?0:(local_increment/local_axis_nb_elem); - int iaxis=((local_increment==0)?0:(loc/local_increment))+_local_array_indices[idim][proc_axis]; - global+=increment*iaxis; - loc = (local_increment==0)?0:(loc%local_increment); - } - return global; - } - - //Retrieves the local number of elements - int BlockTopology::getNbLocalElements()const - { - int position=_proc_group->myRank(); - int nb_elem = 1; - int increment=1; - for (int i=_dimension-1; i>=0; i--) - { - increment *=_nb_procs_per_dim[i]; - int idim=position%increment; - position=position/increment; - int imin=_local_array_indices[i][idim]; - int imax=_local_array_indices[i][idim+1]; - nb_elem*=(imax-imin); - } - return nb_elem; - } - - /*! - * Constructor of a block topology from a grid. - * This preliminary version simply splits along the first axis - * instead of making the best choice with respect to the - * values of the different axes. - */ - BlockTopology::BlockTopology(const ProcessorGroup& group, MEDCouplingCMesh *grid): - _dimension(grid->getSpaceDimension()), _proc_group(&group), _owns_processor_group(false) - { - vector axis_length(_dimension); - _nb_elems=1; - for (int idim=0; idim <_dimension; idim++) - { - DataArrayDouble *arr=grid->getCoordsAt(idim); - axis_length[idim]=arr->getNbOfElems(); - _nb_elems*=axis_length[idim]; - } - //default splitting along 1st dimension - _local_array_indices.resize(_dimension); - _nb_procs_per_dim.resize(_dimension); - - _local_array_indices[0].resize(_proc_group->size()+1); - _local_array_indices[0][0]=0; - _nb_procs_per_dim[0]=_proc_group->size(); - - for (int i=1; i<=_proc_group->size(); i++) - { - _local_array_indices[0][i]=_local_array_indices[0][i-1]+ - axis_length[0]/_proc_group->size(); - if (i<= axis_length[0]%_proc_group->size()) - _local_array_indices[0][i]+=1; - } - for (int i=1; i<_dimension; i++) - { - _local_array_indices[i].resize(2); - _local_array_indices[i][0]=0; - _local_array_indices[i][1]=axis_length[i]; - _nb_procs_per_dim[i]=1; - } - _cycle_type.resize(_dimension); - for (int i=0; i<_dimension; i++) - _cycle_type[i]=ParaMEDMEM::Block; - } - - /*! - * Creation of a block topology by composing - * a geometrical topology and a component topology. - * This constructor is intended for creating fields - * for which the parallel distribution is made on the - * components of the field rather than on the geometrical - * partitioning of the underlying mesh. - * - */ - BlockTopology::BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo):_owns_processor_group(false) - { - // so far, the block topology can only be created if the proc group - // is either on geom_topo or on comp_topo - if (geom_topo.getProcGroup()->size()>1 && comp_topo.nbBlocks()>1) - throw INTERP_KERNEL::Exception(LOCALIZED("BlockTopology cannot yet be constructed with both complex geo and components topology")); - - if (comp_topo.nbComponents()==1) - { - *this=geom_topo; - return; - } - else - { - _dimension = geom_topo.getDimension()+1; - if (comp_topo.nbBlocks()>1) - _proc_group=comp_topo.getProcGroup(); - else - _proc_group=geom_topo.getProcGroup(); - _local_array_indices=geom_topo._local_array_indices; - vector comp_indices = *(comp_topo.getBlockIndices()); - _local_array_indices.push_back(comp_indices); - _nb_procs_per_dim=geom_topo._nb_procs_per_dim; - _nb_procs_per_dim.push_back(comp_topo.nbBlocks()); - _cycle_type=geom_topo._cycle_type; - _cycle_type.push_back(Block); - _nb_elems=geom_topo.getNbElements()*comp_topo.nbComponents(); - } - } - - /*! Constructor for creating a one-dimensional - * topology from a processor group and a local - * number of elements on each processor - * - * The function must be called only by the processors belonging - * to group \a group. Calling it from a processor not belonging - * to \a group will cause an MPI error, while calling from a subset - * of \a group will result in a deadlock. - */ - BlockTopology::BlockTopology(const ProcessorGroup& group, int nb_elem):_dimension(1),_proc_group(&group),_owns_processor_group(false) - { - int* nbelems_per_proc = new int[group.size()]; - const MPIProcessorGroup* mpi_group=dynamic_cast(_proc_group); - const MPI_Comm* comm=mpi_group->getComm(); - int nbtemp=nb_elem; - mpi_group->getCommInterface().allGather(&nbtemp, 1, MPI_INT, - nbelems_per_proc, 1, MPI_INT, - *comm); - _nb_elems=0; - - //splitting along only dimension - _local_array_indices.resize(1); - _nb_procs_per_dim.resize(1); - - _local_array_indices[0].resize(_proc_group->size()+1); - _local_array_indices[0][0]=0; - _nb_procs_per_dim[0]=_proc_group->size(); - - for (int i=1; i<=_proc_group->size(); i++) - { - _local_array_indices[0][i]=_local_array_indices[0][i-1]+ - nbelems_per_proc[i-1]; - _nb_elems+=nbelems_per_proc[i-1]; - } - _cycle_type.resize(1); - _cycle_type[0]=ParaMEDMEM::Block; - delete[] nbelems_per_proc; - } - - BlockTopology::~BlockTopology() - { - if (_owns_processor_group) - delete _proc_group; - } - - /*! Retrieves the min and max indices of the domain stored locally - * for each dimension. The output vector has the topology dimension - * as a size and each pair contains min and max. Indices - * range from min to max-1. - */ - std::vector > BlockTopology::getLocalArrayMinMax() const - { - vector > local_indices (_dimension); - int myrank=_proc_group->myRank(); - int increment=1; - for (int i=_dimension-1; i>=0; i--) - { - increment *=_nb_procs_per_dim[i]; - int idim=myrank%increment; - local_indices[i].first=_local_array_indices[i][idim]; - local_indices[i].second=_local_array_indices[i][idim+1]; - cout << local_indices[i].first << " "<< local_indices[i].second< buffer; - - buffer.push_back(_dimension); - buffer.push_back(_nb_elems); - for (int i=0; i<_dimension; i++) - { - buffer.push_back(_nb_procs_per_dim[i]); - buffer.push_back(_cycle_type[i]); - buffer.push_back(_local_array_indices[i].size()); - for (int j=0; j<(int)_local_array_indices[i].size(); j++) - buffer.push_back(_local_array_indices[i][j]); - } - - //serializing the comm group - int size_comm=_proc_group->size(); - buffer.push_back(size_comm); - MPIProcessorGroup world_group(_proc_group->getCommInterface()); - for (int i=0; i procs; - int size_comm=*(ptr_serializer++); - for (int i=0; i - -namespace ParaMEDMEM -{ - class ComponentTopology; - class MEDCouplingCMesh; - - typedef enum{Block,Cycle} CYCLE_TYPE; - - class BlockTopology : public Topology - { - public: - BlockTopology() { } - BlockTopology(const ProcessorGroup& group, MEDCouplingCMesh *grid); - BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo); - BlockTopology(const ProcessorGroup& group, int nb_elem); - virtual ~BlockTopology(); - //!Retrieves the number of elements for a given topology - int getNbElements()const { return _nb_elems; } - int getNbLocalElements() const; - const ProcessorGroup* getProcGroup()const { return _proc_group; } - std::pair globalToLocal (const int) const ; - int localToGlobal (const std::pair) const; - std::vector > getLocalArrayMinMax() const ; - int getDimension() const { return _dimension; } - void serialize(int* & serializer, int& size) const ; - void unserialize(const int* serializer, const CommInterface& comm_interface); - private: - //dimension : 2 or 3 - int _dimension; - //proc array - std::vector _nb_procs_per_dim; - //stores the offsets vector - std::vector > _local_array_indices; - //stores the cycle type (block or cyclic) - std::vector _cycle_type; - //Processor group - const ProcessorGroup* _proc_group; - //nb of elements - int _nb_elems; - bool _owns_processor_group; - }; -} - -#endif diff --git a/src/ParaMEDMEM/CommInterface.cxx b/src/ParaMEDMEM/CommInterface.cxx deleted file mode 100644 index 9f2ec299d..000000000 --- a/src/ParaMEDMEM/CommInterface.cxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2010 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 "CommInterface.hxx" - -namespace ParaMEDMEM -{ - /*! \defgroup comm_interface CommInterface - Class \a CommInterface is the gateway to the MPI library. - It is a helper class that gathers the calls to the MPI - library that are made in the ParaMEDMEM library. This gathering - allows easier gathering of information about the communication - in the library. - - It is typically called after the MPI_Init() call in a program. It is afterwards passed as a parameter to the constructors of ParaMEDMEM objects so that they access the MPI library via the CommInterface. - - As an example, the following code excerpt initializes a processor group made of the zero processor. - - \verbatim - #include "CommInterface.hxx" - #include "ProcessorGroup.hxx" - - int main(int argc, char** argv) - { - //initialization - MPI_Init(&argc, &argv); - ParaMEDMEM::CommInterface comm_interface; - - //setting up a processor group with proc 0 - set procs; - procs.insert(0); - ParaMEDMEM::ProcessorGroup group(procs, comm_interface); - - //cleanup - MPI_Finalize(); - } - \endverbatim - */ - - CommInterface::CommInterface() - { - } - - CommInterface::~CommInterface() - { - } -} diff --git a/src/ParaMEDMEM/CommInterface.hxx b/src/ParaMEDMEM/CommInterface.hxx deleted file mode 100644 index 2be3f4c10..000000000 --- a/src/ParaMEDMEM/CommInterface.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2007-2010 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 __COMMINTERFACE_HXX__ -#define __COMMINTERFACE_HXX__ - -#include -namespace ParaMEDMEM -{ - - class CommInterface - { - public: - CommInterface(){} - virtual ~CommInterface(){} - int worldSize() const { - int size; - MPI_Comm_size(MPI_COMM_WORLD, &size); - return size;} - int commSize(MPI_Comm comm, int* size) const { return MPI_Comm_size(comm,size); } - int commRank(MPI_Comm comm, int* rank) const { return MPI_Comm_rank(comm,rank); } - int commGroup(MPI_Comm comm, MPI_Group* group) const { return MPI_Comm_group(comm, group); } - int groupIncl(MPI_Group group, int size, int* ranks, MPI_Group* group_output) const { return MPI_Group_incl(group, size, ranks, group_output); } - int commCreate(MPI_Comm comm, MPI_Group group, MPI_Comm* comm_output) const { return MPI_Comm_create(comm,group,comm_output); } - int groupFree(MPI_Group* group) const { return MPI_Group_free(group); } - int commFree(MPI_Comm* comm) const { return MPI_Comm_free(comm); } - - int send(void* buffer, int count, MPI_Datatype datatype, int target, int tag, MPI_Comm comm) const { return MPI_Send(buffer,count, datatype, target, tag, comm); } - int recv(void* buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status) const { return MPI_Recv(buffer,count, datatype, source, tag, comm, status); } - int sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, - int dest, int sendtag, void* recvbuf, int recvcount, - MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, - MPI_Status* status) { return MPI_Sendrecv(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm,status); } - - int Isend(void* buffer, int count, MPI_Datatype datatype, int target, - int tag, MPI_Comm comm, MPI_Request *request) const { return MPI_Isend(buffer,count, datatype, target, tag, comm, request); } - int Irecv(void* buffer, int count, MPI_Datatype datatype, int source, - int tag, MPI_Comm comm, MPI_Request* request) const { return MPI_Irecv(buffer,count, datatype, source, tag, comm, request); } - - int wait(MPI_Request *request, MPI_Status *status) const { return MPI_Wait(request, status); } - int test(MPI_Request *request, int *flag, MPI_Status *status) const { return MPI_Test(request, flag, status); } - int requestFree(MPI_Request *request) const { return MPI_Request_free(request); } - int waitany(int count, MPI_Request *array_of_requests, int *index, MPI_Status *status) const { return MPI_Waitany(count, array_of_requests, index, status); } - int testany(int count, MPI_Request *array_of_requests, int *index, int *flag, MPI_Status *status) const { return MPI_Testany(count, array_of_requests, index, flag, status); } - int waitall(int count, MPI_Request *array_of_requests, MPI_Status *array_of_status) const { return MPI_Waitall(count, array_of_requests, array_of_status); } - int testall(int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_status) const { return MPI_Testall(count, array_of_requests, flag, array_of_status); } - int waitsome(int incount, MPI_Request *array_of_requests,int *outcount, int *array_of_indices, MPI_Status *array_of_status) const { return MPI_Waitsome(incount, array_of_requests, outcount, array_of_indices, array_of_status); } - int testsome(int incount, MPI_Request *array_of_requests, int *outcount, - int *array_of_indices, MPI_Status *array_of_status) const { return MPI_Testsome(incount, array_of_requests, outcount, array_of_indices, array_of_status); } - int probe(int source, int tag, MPI_Comm comm, MPI_Status *status) const { return MPI_Probe(source, tag, comm, status) ; } - int Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status) const { return MPI_Iprobe(source, tag, comm, flag, status) ; } - int cancel(MPI_Request *request) const { return MPI_Cancel(request); } - int testCancelled(MPI_Status *status, int *flag) const { return MPI_Test_cancelled(status, flag); } - int barrier(MPI_Comm comm) const { return MPI_Barrier(comm); } - int errorString(int errorcode, char *string, int *resultlen) const { return MPI_Error_string(errorcode, string, resultlen); } - int getCount(MPI_Status *status, MPI_Datatype datatype, int *count) const { return MPI_Get_count(status, datatype, count); } - - int broadcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) const { return MPI_Bcast(buffer, count, datatype, root, comm); } - int allGather(void* sendbuf, int sendcount, MPI_Datatype sendtype, - void* recvbuf, int recvcount, MPI_Datatype recvtype, - MPI_Comm comm) const { return MPI_Allgather(sendbuf,sendcount, sendtype, recvbuf, recvcount, recvtype, comm); } - int allToAll(void* sendbuf, int sendcount, MPI_Datatype sendtype, - void* recvbuf, int recvcount, MPI_Datatype recvtype, - MPI_Comm comm) const { return MPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); } - int allToAllV(void* sendbuf, int* sendcounts, int* senddispls, - MPI_Datatype sendtype, void* recvbuf, int* recvcounts, - int* recvdispls, MPI_Datatype recvtype, - MPI_Comm comm) const { return MPI_Alltoallv(sendbuf, sendcounts, senddispls, sendtype, recvbuf, recvcounts, recvdispls, recvtype, comm); } - - int reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, - MPI_Op op, int root, MPI_Comm comm) const { return MPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm); } - int allReduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) const { return MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm); } - }; -} - -#endif /*COMMINTERFACE_HXX_*/ diff --git a/src/ParaMEDMEM/ComponentTopology.cxx b/src/ParaMEDMEM/ComponentTopology.cxx deleted file mode 100644 index 60bed682f..000000000 --- a/src/ParaMEDMEM/ComponentTopology.cxx +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2007-2010 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 "ComponentTopology.hxx" -#include "ProcessorGroup.hxx" -#include "InterpolationUtils.hxx" - -namespace ParaMEDMEM -{ - /* Generic constructor for \a nb_comp components equally parted - * in \a nb_blocks blocks - */ - ComponentTopology::ComponentTopology(int nb_comp, ProcessorGroup* group):_proc_group(group) - { - int nb_blocks=group->size(); - - if (nb_blocks>nb_comp) - throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks"); - - _component_array.resize(nb_blocks+1); - _component_array[0]=0; - for (int i=1; i<=nb_blocks; i++) - { - _component_array[i]=_component_array[i-1]+nb_comp/nb_blocks; - if (i<=nb_comp%nb_blocks) - _component_array[i]++; - } - } - - /* Generic constructor for \a nb_comp components equally parted - * in \a nb_blocks blocks - */ - ComponentTopology::ComponentTopology(int nb_comp, int nb_blocks):_proc_group(0) - { - if (nb_blocks>nb_comp) - throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks"); - - _component_array.resize(nb_blocks+1); - _component_array[0]=0; - for (int i=1; i<=nb_blocks; i++) - { - _component_array[i]=_component_array[i-1]+nb_comp/nb_blocks; - if (i<=nb_comp%nb_blocks) - _component_array[i]++; - } - - } - - //!Constructor for one block of \a nb_comp components - ComponentTopology::ComponentTopology(int nb_comp):_proc_group(0) - { - - _component_array.resize(2); - _component_array[0]=0; - _component_array[1]=nb_comp; - - } - - //! Constructor for one component - ComponentTopology::ComponentTopology():_proc_group(0) - { - _component_array.resize(2); - _component_array[0]=0; - _component_array[1]=1; - - } - - ComponentTopology::~ComponentTopology() - { - } - - int ComponentTopology::nbLocalComponents() const - { - if (_proc_group==0) - return nbComponents(); - - int nbcomp; - int myrank = _proc_group->myRank(); - if (myrank!=-1) - nbcomp = _component_array[myrank+1]-_component_array[myrank]; - else - nbcomp=0; - return nbcomp; - } - - int ComponentTopology::firstLocalComponent() const - { - if (_proc_group==0) - return 0; - - int icomp; - int myrank = _proc_group->myRank(); - if (myrank!=-1) - icomp = _component_array[myrank]; - else - icomp=-1; - return icomp; - } -} diff --git a/src/ParaMEDMEM/ComponentTopology.hxx b/src/ParaMEDMEM/ComponentTopology.hxx deleted file mode 100644 index 4fd34616e..000000000 --- a/src/ParaMEDMEM/ComponentTopology.hxx +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2007-2010 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 __COMPONENTTOPOLOGY_HXX__ -#define __COMPONENTTOPOLOGY_HXX__ - -#include "Topology.hxx" - -#include - -namespace ParaMEDMEM -{ - class ProcessorGroup; - - class ComponentTopology - { - public: - ComponentTopology(int nb_comp, ProcessorGroup* group); - ComponentTopology(int nb_comp, int nb_blocks); - ComponentTopology(int nb_comp); - ComponentTopology(); - virtual ~ComponentTopology(); - //!returns the number of MED components in the topology - int nbComponents() const { return _component_array.back(); } - //!returns the number of MED components on local processor - int nbLocalComponents() const ; - //!returns the number of the first MED component on local processor - int firstLocalComponent() const ; - //!returns the number of blocks in the topology - int nbBlocks()const {return _component_array.size()-1;} - //!returns the block structure - const std::vector* getBlockIndices() const { return &_component_array; } - const ProcessorGroup* getProcGroup()const { return _proc_group; } - private: - std::vector _component_array; - ProcessorGroup* _proc_group; - }; -} - -#endif /*COMPONENTTOPOLOGY_HXX_*/ diff --git a/src/ParaMEDMEM/DEC.cxx b/src/ParaMEDMEM/DEC.cxx deleted file mode 100644 index 4003b65fc..000000000 --- a/src/ParaMEDMEM/DEC.cxx +++ /dev/null @@ -1,364 +0,0 @@ -// Copyright (C) 2007-2010 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 "CommInterface.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "ComponentTopology.hxx" -#include "ParaFIELD.hxx" -#include "ParaMESH.hxx" -#include "DEC.hxx" -#include "ICoCoField.hxx" -#include "ICoCoMEDField.hxx" -#include "ICoCoTrioField.hxx" -#include "MPIProcessorGroup.hxx" - -#include - -/*! \defgroup dec DEC - * - * \section decintroduction Introduction - * - * Interface class for creation of a link between two - * processor groups for exhanging mesh or field data. - * The DEC is defined by attaching a field on the receiving or on the - * sending side. - * On top of attaching a ParaMEDMEM::FIELD, it is possible to - * attach a ICoCo::Field. This class is an abstract class that enables - * coupling of codes that respect the ICoCo interface \ref icoco. It has two implementations: - * one for codes that express their fields as MEDCoupling fields (ICoCo::MEDField) and one - * for codes that express their fields as Trio/U fields. - * - * \section dec_options DEC Options - * Options supported by DEC objects are - * - * - * - * - *
OptionDescriptionDefault value
ForcedRenormalizationAfter receiving data, the target field is renormalized so that L2-norms of the source and target fields match. false
- - - The following code excerpt shows how to set options for an object that inherits from DEC : - - \code - InterpKernelDEC dec(source_group,target_group); - dec.setOptions("ForcedRenormalization",true); - dec.attachLocalField(field); - dec.synchronize(); - if (source_group.containsMyRank()) - dec.sendData(); - else - dec.recvData(); - \endcode -*/ - -namespace ParaMEDMEM -{ - - - /*! \addtogroup dec - @{ - */ - DEC::DEC(ProcessorGroup& source_group, ProcessorGroup& target_group):_local_field(0), - _source_group(&source_group), - _target_group(&target_group), - _owns_field(false), - _owns_groups(false), - _icoco_field(0) - { - _union_group = source_group.fuse(target_group); - } - DEC::DEC(const std::set& source_ids, const std::set& target_ids, const MPI_Comm& world_comm):_local_field(0), - _owns_field(false), - _owns_groups(true), - _icoco_field(0) - { - ParaMEDMEM::CommInterface comm; - // Create the list of procs including source and target - std::set union_ids; // source and target ids in world_comm - union_ids.insert(source_ids.begin(),source_ids.end()); - union_ids.insert(target_ids.begin(),target_ids.end()); - int* union_ranks_world=new int[union_ids.size()]; // ranks of sources and targets in world_comm - std::copy::const_iterator,int*> (union_ids.begin(), union_ids.end(), union_ranks_world); - - // Create a communicator on these procs - MPI_Group union_group,world_group; - comm.commGroup(world_comm,&world_group); - comm.groupIncl(world_group,union_ids.size(),union_ranks_world,&union_group); - MPI_Comm union_comm; - comm.commCreate(world_comm,union_group,&union_comm); - delete[] union_ranks_world; - - if (union_comm==MPI_COMM_NULL) - { // This process is not in union - _source_group=0; - _target_group=0; - _union_group=0; - return; - } - - // Translate source_ids and target_ids from world_comm to union_comm - int* source_ranks_world=new int[source_ids.size()]; // ranks of sources in world_comm - std::copy::const_iterator,int*> (source_ids.begin(), source_ids.end(),source_ranks_world); - int* source_ranks_union=new int[source_ids.size()]; // ranks of sources in union_comm - int* target_ranks_world=new int[target_ids.size()]; // ranks of targets in world_comm - std::copy::const_iterator,int*> (target_ids.begin(), target_ids.end(),target_ranks_world); - int* target_ranks_union=new int[target_ids.size()]; // ranks of targets in union_comm - MPI_Group_translate_ranks(world_group,source_ids.size(),source_ranks_world,union_group,source_ranks_union); - MPI_Group_translate_ranks(world_group,target_ids.size(),target_ranks_world,union_group,target_ranks_union); - std::set source_ids_union; - for (int i=0;i<(int)source_ids.size();i++) - source_ids_union.insert(source_ranks_union[i]); - std::set target_ids_union; - for (int i=0;i<(int)target_ids.size();i++) - target_ids_union.insert(target_ranks_union[i]); - delete [] source_ranks_world; - delete [] source_ranks_union; - delete [] target_ranks_world; - delete [] target_ranks_union; - - // Create the MPIProcessorGroups - _source_group= new MPIProcessorGroup(comm,source_ids_union,union_comm); - _target_group = new MPIProcessorGroup(comm,target_ids_union,union_comm); - _union_group = _source_group->fuse(*_target_group); - - } - - DEC::~DEC() - { - if(_owns_field) - delete _local_field; - if(_owns_groups) - { - delete _source_group; - delete _target_group; - } - delete _icoco_field; - delete _union_group; - } - - void DEC::setNature(NatureOfField nature) - { - if(_local_field) - _local_field->getField()->setNature(nature); - } - - /*! Attaches a local field to a DEC. - If the processor is on the receiving end of the DEC, the field - will be updated by a recvData() call. - Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side. - */ - void DEC::attachLocalField(const ParaFIELD* field, bool ownPt) - { - if(!isInUnion()) - return ; - if(_owns_field) - delete _local_field; - _local_field=field; - _owns_field=ownPt; - _comm_interface=&(field->getTopology()->getProcGroup()->getCommInterface()); - compareFieldAndMethod(); - } - - /*! Attaches a local field to a DEC. The method will test whether the processor - is on the source or the target side and will associate the mesh underlying the - field to the local side. - - If the processor is on the receiving end of the DEC, the field - will be updated by a recvData() call. - Reversely, if the processor is on the sending end, the field will be read, possibly transformed, - and sent appropriately to the other side. - */ - - void DEC::attachLocalField(MEDCouplingFieldDouble* field) - { - if(!isInUnion()) - return ; - ProcessorGroup* local_group; - if (_source_group->containsMyRank()) - local_group=_source_group; - else if (_target_group->containsMyRank()) - local_group=_target_group; - else - throw INTERP_KERNEL::Exception("Invalid procgroup for field attachment to DEC"); - ParaMESH *paramesh=new ParaMESH((MEDCouplingPointSet *)field->getMesh(),*local_group,field->getMesh()->getName()); - ParaFIELD *tmp=new ParaFIELD(field, paramesh, *local_group); - tmp->setOwnSupport(true); - attachLocalField(tmp,true); - //_comm_interface=&(local_group->getCommInterface()); - } - - /*! - Attaches a local field to a DEC. - If the processor is on the receiving end of the DEC, the field - will be updated by a recvData() call. - Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side. - The field type is a generic ICoCo Field, so that the DEC can couple a number of different fields : - - a ICoCo::MEDField, that is created from a MEDCoupling structure - - a ICOCo::TrioField, that is created from tables extracted from a TRIO-U structure. - - */ - - void DEC::attachLocalField(const ICoCo::Field* field) - { - if(!isInUnion()) - return ; - const ICoCo::MEDField* medfield=dynamic_cast (field); - if(medfield !=0) - { - attachLocalField(medfield->getField()); - return; - } - const ICoCo::TrioField* triofield=dynamic_cast (field); - if (triofield !=0) - { - ProcessorGroup* localgroup; - if (_source_group->containsMyRank()) - localgroup=_source_group; - else - localgroup=_target_group; - delete _icoco_field; - - _icoco_field=new ICoCo::MEDField(*const_cast(triofield)); - attachLocalField(_icoco_field); - return; - } - throw INTERP_KERNEL::Exception("incompatible field type"); - } - - /*! - Computes the field norm over its support - on the source side and renormalizes the field on the target side - so that the norms match. - - \f[ - I_{source}=\sum_{i=1}^{n_{source}}V_{i}.|\Phi^{source}_{i}|^2, - \f] - - \f[ - I_{target}=\sum_{i=1}^{n_{target}}V_{i}.|\Phi^{target}_{i}|^2, - \f] - - \f[ - \Phi^{target}:=\Phi^{target}.\sqrt{I_{source}/I_{target}}. - \f] - - */ - void DEC::renormalizeTargetField(bool isWAbs) - { - if (_source_group->containsMyRank()) - for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++) - { - double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs); - double source_norm = total_norm; - _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast(_union_group)->getComm()); - - } - if (_target_group->containsMyRank()) - { - for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++) - { - double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs); - double source_norm=total_norm; - _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast(_union_group)->getComm()); - - if (fabs(total_norm)>1e-100) - _local_field->getField()->applyLin(source_norm/total_norm,0.0,icomp+1); - } - } - } - /*! @} */ - - bool DEC::isInSourceSide() const - { - if(!_source_group) - return false; - return _source_group->containsMyRank(); - } - - bool DEC::isInTargetSide() const - { - if(!_target_group) - return false; - return _target_group->containsMyRank(); - } - - bool DEC::isInUnion() const - { - if(!_union_group) - return false; - return _union_group->containsMyRank(); - } - - void DEC::compareFieldAndMethod() const throw(INTERP_KERNEL::Exception) - { - if (_local_field) - { - TypeOfField entity = _local_field->getField()->getTypeOfField(); - if ( getMethod() == "P0" ) - { - if ( entity != ON_CELLS ) - throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch." - " For P0 interpolation, field must be on MED_CELL's"); - } - else if ( getMethod() == "P1" ) - { - if ( entity != ON_NODES ) - throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch." - " For P1 interpolation, field must be on MED_NODE's"); - } - else if ( getMethod() == "P1d" ) - { - if ( entity != ON_CELLS ) - throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch." - " For P1d interpolation, field must be on MED_CELL's"); - if ( _target_group->containsMyRank() ) - throw INTERP_KERNEL::Exception("Projection to P1d field not supported"); - } - else - { - throw INTERP_KERNEL::Exception("Unknown interpolation method. Possible methods: P0, P1, P1d"); - } - } - } - - /*! - If way==true, source procs call sendData() and target procs call recvData(). - if way==false, it's the other way round. - */ - void DEC::sendRecvData(bool way) - { - if(!isInUnion()) - return; - if(isInSourceSide()) - { - if(way) - sendData(); - else - recvData(); - } - else if(isInTargetSide()) - { - if(way) - recvData(); - else - sendData(); - } - } -} diff --git a/src/ParaMEDMEM/DEC.hxx b/src/ParaMEDMEM/DEC.hxx deleted file mode 100644 index 3c5ddf8fb..000000000 --- a/src/ParaMEDMEM/DEC.hxx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007-2010 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 __DEC_HXX__ -#define __DEC_HXX__ - -#include "MEDCouplingFieldDouble.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "DECOptions.hxx" - -#include - -namespace ICoCo -{ - class Field; -} - -namespace ParaMEDMEM -{ - class ProcessorGroup; - class ParaFIELD; - class CommInterface; - class DEC : public DECOptions - { - public: - DEC():_local_field(0) { } - DEC(ProcessorGroup& source_group, ProcessorGroup& target_group); - DEC(const std::set& src_ids, const std::set& trg_ids, - const MPI_Comm& world_comm=MPI_COMM_WORLD); - void setNature(NatureOfField nature); - void attachLocalField( MEDCouplingFieldDouble* field); - void attachLocalField(const ParaFIELD* field, bool ownPt=false); - void attachLocalField(const ICoCo::Field* field); - - virtual void prepareSourceDE() = 0; - virtual void prepareTargetDE() = 0; - virtual void recvData() = 0; - virtual void sendData() = 0; - void sendRecvData(bool way=true); - virtual void synchronize() = 0; - virtual ~DEC(); - virtual void computeProcGroup() { } - void renormalizeTargetField(bool isWAbs); - // - ProcessorGroup *getSourceGrp() const { return _source_group; } - ProcessorGroup *getTargetGrp() const { return _target_group; } - bool isInSourceSide() const; - bool isInTargetSide() const; - bool isInUnion() const; - protected: - void compareFieldAndMethod() const throw(INTERP_KERNEL::Exception); - protected: - const ParaFIELD* _local_field; - //! Processor group representing the union of target and source processors - ProcessorGroup* _union_group; - ProcessorGroup* _source_group; - ProcessorGroup* _target_group; - - const CommInterface* _comm_interface; - bool _owns_field; - bool _owns_groups; - private: - ICoCo::Field* _icoco_field; - }; -} - -#endif diff --git a/src/ParaMEDMEM/DECOptions.hxx b/src/ParaMEDMEM/DECOptions.hxx deleted file mode 100644 index 33f35d396..000000000 --- a/src/ParaMEDMEM/DECOptions.hxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2010 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 __DECOPTIONS_HXX__ -#define __DECOPTIONS_HXX__ - -#include - -namespace ParaMEDMEM -{ - //Enum describing the allToAll method used in the communication pattern - typedef enum { Native, PointToPoint } AllToAllMethod; - typedef enum { WithoutTimeInterp, LinearTimeInterp } TimeInterpolationMethod; - - class DECOptions - { - protected: - std::string _method; - bool _asynchronous; - TimeInterpolationMethod _timeInterpolationMethod; - AllToAllMethod _allToAllMethod; - bool _forcedRenormalization; - public: - DECOptions():_method("P0"), - _asynchronous(false), - _timeInterpolationMethod(WithoutTimeInterp), - _allToAllMethod(Native), - _forcedRenormalization(false) - { - } - - DECOptions(const DECOptions& deco) - { - _method=deco._method; - _timeInterpolationMethod=deco._timeInterpolationMethod; - _asynchronous=deco._asynchronous; - _forcedRenormalization=deco._forcedRenormalization; - _allToAllMethod=deco._allToAllMethod; - } - - const std::string& getMethod() const { return _method; } - void setMethod(const char *m) { _method=m; } - - TimeInterpolationMethod getTimeInterpolationMethod() const { return DECOptions::_timeInterpolationMethod; } - void setTimeInterpolationMethod(TimeInterpolationMethod it) { DECOptions::_timeInterpolationMethod=it; } - - bool getForcedRenormalization() const { return DECOptions::_forcedRenormalization; } - void setForcedRenormalization( bool dr) { DECOptions::_forcedRenormalization = dr; } - - bool getAsynchronous() const { return DECOptions::_asynchronous; } - void setAsynchronous( bool dr) { DECOptions::_asynchronous = dr; } - - AllToAllMethod getAllToAllMethod() const { return _allToAllMethod; } - void setAllToAllMethod(AllToAllMethod sp) { _allToAllMethod=sp; } - }; -} - -#endif diff --git a/src/ParaMEDMEM/ElementLocator.cxx b/src/ParaMEDMEM/ElementLocator.cxx deleted file mode 100644 index 3252279cd..000000000 --- a/src/ParaMEDMEM/ElementLocator.cxx +++ /dev/null @@ -1,717 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include "CommInterface.hxx" -#include "ElementLocator.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "ParaFIELD.hxx" -#include "ParaMESH.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "DirectedBoundingBox.hxx" - -#include -#include -#include - -using namespace std; - -//#define USE_DIRECTED_BB - -namespace ParaMEDMEM -{ - ElementLocator::ElementLocator(const ParaFIELD& sourceField, - const ProcessorGroup& distant_group, - const ProcessorGroup& local_group) - : _local_para_field(sourceField), - _local_cell_mesh(sourceField.getSupport()->getCellMesh()), - _local_face_mesh(sourceField.getSupport()->getFaceMesh()), - _distant_group(distant_group), - _local_group(local_group) - { - _union_group = _local_group.fuse(distant_group); - _computeBoundingBoxes(); - _comm=getCommunicator(); - } - - ElementLocator::~ElementLocator() - { - delete _union_group; - delete [] _domain_bounding_boxes; - } - - const MPI_Comm *ElementLocator::getCommunicator() const - { - MPIProcessorGroup* group=static_cast (_union_group); - return group->getComm(); - } - - NatureOfField ElementLocator::getLocalNature() const - { - return _local_para_field.getField()->getNature(); - } - - // ========================================================================== - // Procedure for exchanging mesh between a distant proc and a local processor - // param idistantrank proc id on distant group - // param distant_mesh on return , points to a local reconstruction of - // the distant mesh - // param distant_ids on return, contains a vector defining a correspondence - // between the distant ids and the ids of the local reconstruction - // ========================================================================== - void ElementLocator::exchangeMesh(int idistantrank, - MEDCouplingPointSet*& distant_mesh, - int*& distant_ids) - { - int rank = _union_group->translateRank(&_distant_group,idistantrank); - - if (find(_distant_proc_ids.begin(), _distant_proc_ids.end(),rank)==_distant_proc_ids.end()) - return; - - vector elems; -#ifdef USE_DIRECTED_BB - INTERP_KERNEL::DirectedBoundingBox dbb; - double* distant_bb = _domain_bounding_boxes+rank*dbb.dataSize(_local_cell_mesh_space_dim); - dbb.setData(distant_bb); - _local_cell_mesh->giveElemsInBoundingBox(dbb,getBoundingBoxAdjustment(),elems); -#else - double* distant_bb = _domain_bounding_boxes+rank*2*_local_cell_mesh_space_dim; - _local_cell_mesh->giveElemsInBoundingBox(distant_bb,getBoundingBoxAdjustment(),elems); -#endif - - DataArrayInt *distant_ids_send; - MEDCouplingPointSet *send_mesh = (MEDCouplingPointSet *)_local_para_field.getField()->buildSubMeshData(&elems[0],&elems[elems.size()],distant_ids_send); - _exchangeMesh(send_mesh, distant_mesh, idistantrank, distant_ids_send, distant_ids); - distant_ids_send->decrRef(); - - if(send_mesh) - send_mesh->decrRef(); - } - - void ElementLocator::exchangeMethod(const std::string& sourceMeth, int idistantrank, std::string& targetMeth) - { - CommInterface comm_interface=_union_group->getCommInterface(); - MPIProcessorGroup* group=static_cast (_union_group); - const MPI_Comm* comm=(group->getComm()); - MPI_Status status; - // it must be converted to union numbering before communication - int idistRankInUnion = group->translateRank(&_distant_group,idistantrank); - char *recv_buffer=new char[4]; - std::vector send_buffer(4); - std::copy(sourceMeth.begin(),sourceMeth.end(),send_buffer.begin()); - comm_interface.sendRecv(&send_buffer[0], 4, MPI_CHAR,idistRankInUnion, 1112, - recv_buffer, 4, MPI_CHAR,idistRankInUnion, 1112, - *comm, &status); - targetMeth=recv_buffer; - delete [] recv_buffer; - } - - - // ====================== - // Compute bounding boxes - // ====================== - - void ElementLocator::_computeBoundingBoxes() - { - CommInterface comm_interface =_union_group->getCommInterface(); - MPIProcessorGroup* group=static_cast (_union_group); - const MPI_Comm* comm = group->getComm(); - _local_cell_mesh_space_dim = -1; - if(_local_cell_mesh->getMeshDimension() != -1) - _local_cell_mesh_space_dim=_local_cell_mesh->getSpaceDimension(); - int *spaceDimForAll=new int[_union_group->size()]; - comm_interface.allGather(&_local_cell_mesh_space_dim, 1, MPI_INT, - spaceDimForAll,1, MPI_INT, - *comm); - _local_cell_mesh_space_dim=*std::max_element(spaceDimForAll,spaceDimForAll+_union_group->size()); - _is_m1d_corr=((*std::min_element(spaceDimForAll,spaceDimForAll+_union_group->size()))==-1); - for(int i=0;i<_union_group->size();i++) - if(spaceDimForAll[i]!=_local_cell_mesh_space_dim && spaceDimForAll[i]!=-1) - throw INTERP_KERNEL::Exception("Spacedim not matches !"); - delete [] spaceDimForAll; -#ifdef USE_DIRECTED_BB - INTERP_KERNEL::DirectedBoundingBox dbb; - int bbSize = dbb.dataSize(_local_cell_mesh_space_dim); - _domain_bounding_boxes = new double[bbSize*_union_group->size()]; - if(_local_cell_mesh->getMeshDimension() != -1) - dbb = INTERP_KERNEL::DirectedBoundingBox(_local_cell_mesh->getCoords()->getPointer(), - _local_cell_mesh->getNumberOfNodes(), - _local_cell_mesh_space_dim); - std::vector dbbData = dbb.getData(); - if ( dbbData.size() < bbSize ) dbbData.resize(bbSize,0); - double * minmax= &dbbData[0]; -#else - int bbSize = 2*_local_cell_mesh_space_dim; - _domain_bounding_boxes = new double[bbSize*_union_group->size()]; - double * minmax=new double [bbSize]; - if(_local_cell_mesh->getMeshDimension() != -1) - _local_cell_mesh->getBoundingBox(minmax); - else - for(int i=0;i<_local_cell_mesh_space_dim;i++) - { - minmax[i*2]=-std::numeric_limits::max(); - minmax[i*2+1]=std::numeric_limits::max(); - } -#endif - - comm_interface.allGather(minmax, bbSize, MPI_DOUBLE, - _domain_bounding_boxes,bbSize, MPI_DOUBLE, - *comm); - - for (int i=0; i< _distant_group.size(); i++) - { - int rank=_union_group->translateRank(&_distant_group,i); - - if (_intersectsBoundingBox(rank)) - { - _distant_proc_ids.push_back(rank); - } - } -#ifdef USE_DIRECTED_BB -#else - delete [] minmax; -#endif - } - - - // ============================================= - // Intersect Bounding Box (with a given "irank") - // ============================================= - bool ElementLocator::_intersectsBoundingBox(int irank) - { -#ifdef USE_DIRECTED_BB - INTERP_KERNEL::DirectedBoundingBox local_dbb, distant_dbb; - local_dbb.setData( _domain_bounding_boxes+_union_group->myRank()*local_dbb.dataSize( _local_cell_mesh_space_dim )); - distant_dbb.setData( _domain_bounding_boxes+irank*distant_dbb.dataSize( _local_cell_mesh_space_dim )); - return !local_dbb.isDisjointWith( distant_dbb ); -#else - double* local_bb = _domain_bounding_boxes+_union_group->myRank()*2*_local_cell_mesh_space_dim; - double* distant_bb = _domain_bounding_boxes+irank*2*_local_cell_mesh_space_dim; - - for (int idim=0; idim < _local_cell_mesh_space_dim; idim++) - { - const double eps = 1e-12; - bool intersects = (distant_bb[idim*2]getCommInterface(); - - // First stage : exchanging sizes - // ------------------------------ - vector tinyInfoLocal,tinyInfoDistant; - vector tinyInfoLocalS; - //Getting tiny info of local mesh to allow the distant proc to initialize and allocate - //the transmitted mesh. - local_mesh->getTinySerializationInformation(tinyInfoLocal,tinyInfoLocalS); - tinyInfoLocal.push_back(distant_ids_send->getNumberOfTuples()); - tinyInfoDistant.resize(tinyInfoLocal.size()); - std::fill(tinyInfoDistant.begin(),tinyInfoDistant.end(),0); - MPIProcessorGroup* group=static_cast (_union_group); - const MPI_Comm* comm=group->getComm(); - MPI_Status status; - - // iproc_distant is the number of proc in distant group - // it must be converted to union numbering before communication - int iprocdistant_in_union = group->translateRank(&_distant_group, - iproc_distant); - - comm_interface.sendRecv(&tinyInfoLocal[0], tinyInfoLocal.size(), MPI_INT, iprocdistant_in_union, 1112, - &tinyInfoDistant[0], tinyInfoDistant.size(), MPI_INT,iprocdistant_in_union,1112, - *comm, &status); - DataArrayInt *v1Local=0; - DataArrayDouble *v2Local=0; - DataArrayInt *v1Distant=DataArrayInt::New(); - DataArrayDouble *v2Distant=DataArrayDouble::New(); - //serialization of local mesh to send data to distant proc. - local_mesh->serialize(v1Local,v2Local); - //Building the right instance of copy of distant mesh. - MEDCouplingPointSet *distant_mesh_tmp=MEDCouplingPointSet::buildInstanceFromMeshType((MEDCouplingMeshType)tinyInfoDistant[0]); - std::vector unusedTinyDistantSts; - distant_mesh_tmp->resizeForUnserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts); - int nbLocalElems=0; - int nbDistElem=0; - int *ptLocal=0; - int *ptDist=0; - if(v1Local) - { - nbLocalElems=v1Local->getNbOfElems(); - ptLocal=v1Local->getPointer(); - } - if(v1Distant) - { - nbDistElem=v1Distant->getNbOfElems(); - ptDist=v1Distant->getPointer(); - } - comm_interface.sendRecv(ptLocal, nbLocalElems, MPI_INT, - iprocdistant_in_union, 1111, - ptDist, nbDistElem, MPI_INT, - iprocdistant_in_union,1111, - *comm, &status); - nbLocalElems=0; - double *ptLocal2=0; - double *ptDist2=0; - if(v2Local) - { - nbLocalElems=v2Local->getNbOfElems(); - ptLocal2=v2Local->getPointer(); - } - nbDistElem=0; - if(v2Distant) - { - nbDistElem=v2Distant->getNbOfElems(); - ptDist2=v2Distant->getPointer(); - } - comm_interface.sendRecv(ptLocal2, nbLocalElems, MPI_DOUBLE, - iprocdistant_in_union, 1112, - ptDist2, nbDistElem, MPI_DOUBLE, - iprocdistant_in_union, 1112, - *comm, &status); - // - distant_mesh=distant_mesh_tmp; - //finish unserialization - distant_mesh->unserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts); - // - distant_ids_recv=new int[tinyInfoDistant.back()]; - comm_interface.sendRecv((void *)distant_ids_send->getConstPointer(),tinyInfoLocal.back(), MPI_INT, - iprocdistant_in_union, 1113, - distant_ids_recv,tinyInfoDistant.back(), MPI_INT, - iprocdistant_in_union,1113, - *comm, &status); - if(v1Local) - v1Local->decrRef(); - if(v2Local) - v2Local->decrRef(); - if(v1Distant) - v1Distant->decrRef(); - if(v2Distant) - v2Distant->decrRef(); - } - - /*! - * connected with ElementLocator::sendPolicyToWorkingSideL - */ - void ElementLocator::recvPolicyFromLazySideW(std::vector& policy) - { - policy.resize(_distant_proc_ids.size()); - int procId=0; - CommInterface comm; - MPI_Status status; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - int toRecv; - comm.recv((void *)&toRecv,1,MPI_INT,*iter,1120,*_comm,&status); - policy[procId]=toRecv; - } - } - - /*! - * connected with ElementLocator::recvFromWorkingSideL - */ - void ElementLocator::sendSumToLazySideW(const std::vector< std::vector >& distantLocEltIds, const std::vector< std::vector >& partialSumRelToDistantIds) - { - int procId=0; - CommInterface comm; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - const vector& eltIds=distantLocEltIds[procId]; - const vector& valued=partialSumRelToDistantIds[procId]; - int lgth=eltIds.size(); - comm.send(&lgth,1,MPI_INT,*iter,1114,*_comm); - comm.send((void *)&eltIds[0],lgth,MPI_INT,*iter,1115,*_comm); - comm.send((void *)&valued[0],lgth,MPI_DOUBLE,*iter,1116,*_comm); - } - } - - /*! - * connected with ElementLocator::sendToWorkingSideL - */ - void ElementLocator::recvSumFromLazySideW(std::vector< std::vector >& globalSumRelToDistantIds) - { - int procId=0; - CommInterface comm; - MPI_Status status; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - std::vector& vec=globalSumRelToDistantIds[procId]; - comm.recv(&vec[0],vec.size(),MPI_DOUBLE,*iter,1117,*_comm,&status); - } - } - - /*! - * connected with ElementLocator::recvLocalIdsFromWorkingSideL - */ - void ElementLocator::sendLocalIdsToLazyProcsW(const std::vector< std::vector >& distantLocEltIds) - { - int procId=0; - CommInterface comm; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - const vector& eltIds=distantLocEltIds[procId]; - int lgth=eltIds.size(); - comm.send(&lgth,1,MPI_INT,*iter,1121,*_comm); - comm.send((void *)&eltIds[0],lgth,MPI_INT,*iter,1122,*_comm); - } - } - - /*! - * connected with ElementLocator::sendGlobalIdsToWorkingSideL - */ - void ElementLocator::recvGlobalIdsFromLazyProcsW(const std::vector< std::vector >& distantLocEltIds, std::vector< std::vector >& globalIds) - { - int procId=0; - CommInterface comm; - MPI_Status status; - globalIds.resize(_distant_proc_ids.size()); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - const std::vector& vec=distantLocEltIds[procId]; - std::vector& global=globalIds[procId]; - global.resize(vec.size()); - comm.recv(&global[0],vec.size(),MPI_INT,*iter,1123,*_comm,&status); - } - } - - /*! - * connected with ElementLocator::sendCandidatesGlobalIdsToWorkingSideL - */ - void ElementLocator::recvCandidatesGlobalIdsFromLazyProcsW(std::vector< std::vector >& globalIds) - { - int procId=0; - CommInterface comm; - MPI_Status status; - globalIds.resize(_distant_proc_ids.size()); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - std::vector& global=globalIds[procId]; - int lgth; - comm.recv(&lgth,1,MPI_INT,*iter,1132,*_comm,&status); - global.resize(lgth); - comm.recv(&global[0],lgth,MPI_INT,*iter,1133,*_comm,&status); - } - } - - /*! - * connected with ElementLocator::recvSumFromWorkingSideL - */ - void ElementLocator::sendPartialSumToLazyProcsW(const std::vector& distantGlobIds, const std::vector& sum) - { - int procId=0; - CommInterface comm; - int lgth=distantGlobIds.size(); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - comm.send(&lgth,1,MPI_INT,*iter,1124,*_comm); - comm.send((void*)&distantGlobIds[0],lgth,MPI_INT,*iter,1125,*_comm); - comm.send((void*)&sum[0],lgth,MPI_DOUBLE,*iter,1126,*_comm); - } - } - - /*! - * connected with ElementLocator::recvCandidatesForAddElementsL - */ - void ElementLocator::sendCandidatesForAddElementsW(const std::vector& distantGlobIds) - { - int procId=0; - CommInterface comm; - int lgth=distantGlobIds.size(); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - comm.send(&lgth,1,MPI_INT,*iter,1128,*_comm); - comm.send((void*)&distantGlobIds[0],lgth,MPI_INT,*iter,1129,*_comm); - } - } - - /*! - * connected with ElementLocator::sendAddElementsToWorkingSideL - */ - void ElementLocator::recvAddElementsFromLazyProcsW(std::vector >& elementsToAdd) - { - int procId=0; - CommInterface comm; - MPI_Status status; - int lgth=_distant_proc_ids.size(); - elementsToAdd.resize(lgth); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - int locLgth; - std::vector& eltToFeed=elementsToAdd[procId]; - comm.recv(&locLgth,1,MPI_INT,*iter,1130,*_comm,&status); - eltToFeed.resize(locLgth); - comm.recv(&eltToFeed[0],locLgth,MPI_INT,*iter,1131,*_comm,&status); - } - } - - /*! - * connected with ElementLocator::recvPolicyFromLazySideW - */ - int ElementLocator::sendPolicyToWorkingSideL() - { - CommInterface comm; - int toSend; - DataArrayInt *isCumulative=_local_para_field.returnCumulativeGlobalNumbering(); - if(isCumulative) - { - toSend=CUMULATIVE_POLICY; - isCumulative->decrRef(); - } - else - toSend=NO_POST_TREATMENT_POLICY; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++) - comm.send(&toSend,1,MPI_INT,*iter,1120,*_comm); - return toSend; - } - - /*! - * connected with ElementLocator::sendSumToLazySideW - */ - void ElementLocator::recvFromWorkingSideL() - { - _values_added.resize(_local_para_field.getField()->getNumberOfTuples()); - int procId=0; - CommInterface comm; - _ids_per_working_proc.resize(_distant_proc_ids.size()); - MPI_Status status; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - int lgth; - comm.recv(&lgth,1,MPI_INT,*iter,1114,*_comm,&status); - vector& ids=_ids_per_working_proc[procId]; - ids.resize(lgth); - vector values(lgth); - comm.recv(&ids[0],lgth,MPI_INT,*iter,1115,*_comm,&status); - comm.recv(&values[0],lgth,MPI_DOUBLE,*iter,1116,*_comm,&status); - for(int i=0;i::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - vector& ids=_ids_per_working_proc[procId]; - vector valsToSend(ids.size()); - vector::iterator iter3=valsToSend.begin(); - for(vector::const_iterator iter2=ids.begin();iter2!=ids.end();iter2++,iter3++) - *iter3=_values_added[*iter2]; - comm.send(&valsToSend[0],ids.size(),MPI_DOUBLE,*iter,1117,*_comm); - //ids.clear(); - } - //_ids_per_working_proc.clear(); - } - - /*! - * connected with ElementLocator::sendLocalIdsToLazyProcsW - */ - void ElementLocator::recvLocalIdsFromWorkingSideL() - { - int procId=0; - CommInterface comm; - _ids_per_working_proc.resize(_distant_proc_ids.size()); - MPI_Status status; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - int lgth; - vector& ids=_ids_per_working_proc[procId]; - comm.recv(&lgth,1,MPI_INT,*iter,1121,*_comm,&status); - ids.resize(lgth); - comm.recv(&ids[0],lgth,MPI_INT,*iter,1122,*_comm,&status); - } - } - - /*! - * connected with ElementLocator::recvGlobalIdsFromLazyProcsW - */ - void ElementLocator::sendGlobalIdsToWorkingSideL() - { - int procId=0; - CommInterface comm; - DataArrayInt *globalIds=_local_para_field.returnGlobalNumbering(); - const int *globalIdsC=globalIds->getConstPointer(); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - const vector& ids=_ids_per_working_proc[procId]; - vector valsToSend(ids.size()); - vector::iterator iter1=valsToSend.begin(); - for(vector::const_iterator iter2=ids.begin();iter2!=ids.end();iter2++,iter1++) - *iter1=globalIdsC[*iter2]; - comm.send(&valsToSend[0],ids.size(),MPI_INT,*iter,1123,*_comm); - } - if(globalIds) - globalIds->decrRef(); - } - - /*! - * connected with ElementLocator::sendPartialSumToLazyProcsW - */ - void ElementLocator::recvSumFromWorkingSideL() - { - int procId=0; - int wProcSize=_distant_proc_ids.size(); - CommInterface comm; - _ids_per_working_proc.resize(wProcSize); - _values_per_working_proc.resize(wProcSize); - MPI_Status status; - std::map sums; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - int lgth; - comm.recv(&lgth,1,MPI_INT,*iter,1124,*_comm,&status); - vector& ids=_ids_per_working_proc[procId]; - vector& vals=_values_per_working_proc[procId]; - ids.resize(lgth); - vals.resize(lgth); - comm.recv(&ids[0],lgth,MPI_INT,*iter,1125,*_comm,&status); - comm.recv(&vals[0],lgth,MPI_DOUBLE,*iter,1126,*_comm,&status); - vector::const_iterator iter1=ids.begin(); - vector::const_iterator iter2=vals.begin(); - for(;iter1!=ids.end();iter1++,iter2++) - sums[*iter1]+=*iter2; - } - //assign sum to prepare sending to working side - for(procId=0;procId& ids=_ids_per_working_proc[procId]; - vector& vals=_values_per_working_proc[procId]; - vector::const_iterator iter1=ids.begin(); - vector::iterator iter2=vals.begin(); - for(;iter1!=ids.end();iter1++,iter2++) - *iter2=sums[*iter1]; - ids.clear(); - } - } - - /*! - * Foreach working procs Wi compute and push it in _ids_per_working_proc3, - * if it exist, local id of nodes that are in interaction with an another lazy proc than this - * and that exists in this \b but with no interaction with this. - * The computation is performed here. sendAddElementsToWorkingSideL is only in charge to send - * precomputed _ids_per_working_proc3 attribute. - * connected with ElementLocator::sendCandidatesForAddElementsW - */ - void ElementLocator::recvCandidatesForAddElementsL() - { - int procId=0; - int wProcSize=_distant_proc_ids.size(); - CommInterface comm; - _ids_per_working_proc3.resize(wProcSize); - MPI_Status status; - std::map sums; - DataArrayInt *globalIds=_local_para_field.returnGlobalNumbering(); - const int *globalIdsC=globalIds->getConstPointer(); - int nbElts=globalIds->getNumberOfTuples(); - std::set globalIdsS(globalIdsC,globalIdsC+nbElts); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - const std::vector& ids0=_ids_per_working_proc[procId]; - int lgth0=ids0.size(); - std::set elts0; - for(int i=0;i ids(lgth); - comm.recv(&ids[0],lgth,MPI_INT,*iter,1129,*_comm,&status); - set ids1(ids.begin(),ids.end()); - ids.clear(); - set tmp5,tmp6; - set_intersection(globalIdsS.begin(),globalIdsS.end(),ids1.begin(),ids1.end(),inserter(tmp5,tmp5.begin())); - set_difference(tmp5.begin(),tmp5.end(),elts0.begin(),elts0.end(),inserter(tmp6,tmp6.begin())); - std::vector& ids2=_ids_per_working_proc3[procId]; - ids2.resize(tmp6.size()); - std::copy(tmp6.begin(),tmp6.end(),ids2.begin()); - //global->local - for(std::vector::iterator iter2=ids2.begin();iter2!=ids2.end();iter2++) - *iter2=std::find(globalIdsC,globalIdsC+nbElts,*iter2)-globalIdsC; - } - if(globalIds) - globalIds->decrRef(); - } - - /*! - * connected with ElementLocator::recvAddElementsFromLazyProcsW - */ - void ElementLocator::sendAddElementsToWorkingSideL() - { - int procId=0; - CommInterface comm; - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - const std::vector& vals=_ids_per_working_proc3[procId]; - int size=vals.size(); - comm.send((void *)&size,1,MPI_INT,*iter,1130,*_comm); - comm.send((void *)&vals[0],size,MPI_INT,*iter,1131,*_comm); - } - } - - /*! - * This method sends to working side Wi only nodes in interaction with Wi \b and located on boundary, to reduce number. - * connected with ElementLocator::recvCandidatesGlobalIdsFromLazyProcsW - */ - void ElementLocator::sendCandidatesGlobalIdsToWorkingSideL() - { - int procId=0; - CommInterface comm; - DataArrayInt *globalIds=_local_para_field.returnGlobalNumbering(); - const int *globalIdsC=globalIds->getConstPointer(); - std::vector candidates; - _local_para_field.getSupport()->getCellMesh()->findBoundaryNodes(candidates); - for(std::vector::iterator iter1=candidates.begin();iter1!=candidates.end();iter1++) - (*iter1)=globalIdsC[*iter1]; - std::set candidatesS(candidates.begin(),candidates.end()); - for(vector::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) - { - const vector& ids=_ids_per_working_proc[procId]; - vector valsToSend(ids.size()); - vector::iterator iter1=valsToSend.begin(); - for(vector::const_iterator iter2=ids.begin();iter2!=ids.end();iter2++,iter1++) - *iter1=globalIdsC[*iter2]; - std::set tmp2(valsToSend.begin(),valsToSend.end()); - std::vector tmp3; - set_intersection(candidatesS.begin(),candidatesS.end(),tmp2.begin(),tmp2.end(),std::back_insert_iterator< std::vector >(tmp3)); - int lgth=tmp3.size(); - comm.send(&lgth,1,MPI_INT,*iter,1132,*_comm); - comm.send(&tmp3[0],lgth,MPI_INT,*iter,1133,*_comm); - } - if(globalIds) - globalIds->decrRef(); - } -} diff --git a/src/ParaMEDMEM/ElementLocator.hxx b/src/ParaMEDMEM/ElementLocator.hxx deleted file mode 100644 index 6915736f3..000000000 --- a/src/ParaMEDMEM/ElementLocator.hxx +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2007-2010 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 __ELEMENTLOCATOR_HXX__ -#define __ELEMENTLOCATOR_HXX__ - -#include "InterpolationOptions.hxx" -#include "MEDCouplingNatureOfField.hxx" - -#include -#include -#include - -namespace ParaMEDMEM -{ - class ParaFIELD; - class ProcessorGroup; - class ParaSUPPORT; - class InterpolationMatrix; - class MEDCouplingPointSet; - class DataArrayInt; - - class ElementLocator : public INTERP_KERNEL::InterpolationOptions - { - public: - ElementLocator(const ParaFIELD& sourceField, const ProcessorGroup& distant_group, const ProcessorGroup& local_group); - - virtual ~ElementLocator(); - void exchangeMesh(int idistantrank, - MEDCouplingPointSet*& target_mesh, - int*& distant_ids); - void exchangeMethod(const std::string& sourceMeth, int idistantrank, std::string& targetMeth); - const std::vector& getDistantProcIds() const { return _distant_proc_ids; } - const MPI_Comm *getCommunicator() const; - NatureOfField getLocalNature() const; - //! This method is used to informed if there is -1D mesh on distant_group side or on local_group side. - bool isM1DCorr() const { return _is_m1d_corr; } - //Working side methods - void recvPolicyFromLazySideW(std::vector& policy); - void sendSumToLazySideW(const std::vector< std::vector >& distantLocEltIds, const std::vector< std::vector >& partialSumRelToDistantIds); - void recvSumFromLazySideW(std::vector< std::vector >& globalSumRelToDistantIds); - void sendCandidatesForAddElementsW(const std::vector& distantGlobIds); - void recvAddElementsFromLazyProcsW(std::vector >& elementsToAdd); - // - void sendLocalIdsToLazyProcsW(const std::vector< std::vector >& distantLocEltIds); - void recvGlobalIdsFromLazyProcsW(const std::vector< std::vector >& distantLocEltIds, std::vector< std::vector >& globalIds); - void recvCandidatesGlobalIdsFromLazyProcsW(std::vector< std::vector >& globalIds); - void sendPartialSumToLazyProcsW(const std::vector& distantGlobIds, const std::vector& sum); - //Lazy side methods - int sendPolicyToWorkingSideL(); - void recvFromWorkingSideL(); - void sendToWorkingSideL(); - // - void recvLocalIdsFromWorkingSideL(); - void sendGlobalIdsToWorkingSideL(); - void sendCandidatesGlobalIdsToWorkingSideL(); - // - void recvSumFromWorkingSideL(); - void recvCandidatesForAddElementsL(); - void sendAddElementsToWorkingSideL(); - private: - void _computeBoundingBoxes(); - bool _intersectsBoundingBox(int irank); - void _exchangeMesh(MEDCouplingPointSet* local_mesh, MEDCouplingPointSet*& distant_mesh, - int iproc_distant, const DataArrayInt* distant_ids_send, - int*& distant_ids_recv); - private: - const ParaFIELD& _local_para_field ; - MEDCouplingPointSet* _local_cell_mesh; - int _local_cell_mesh_space_dim; - bool _is_m1d_corr; - MEDCouplingPointSet* _local_face_mesh; - std::vector _distant_cell_meshes; - std::vector _distant_face_meshes; - double* _domain_bounding_boxes; - const ProcessorGroup& _distant_group; - const ProcessorGroup& _local_group; - ProcessorGroup* _union_group; - std::vector _distant_proc_ids; - const MPI_Comm *_comm; - //Attributes only used by lazy side - std::vector _values_added; - std::vector< std::vector > _ids_per_working_proc; - std::vector< std::vector > _ids_per_working_proc3; - std::vector< std::vector > _values_per_working_proc; - public: - static const int CUMULATIVE_POLICY=3; - static const int NO_POST_TREATMENT_POLICY=7; - }; - -} - -#endif diff --git a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx deleted file mode 100644 index 0d805af4f..000000000 --- a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include "CommInterface.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "ComponentTopology.hxx" -#include "ParaFIELD.hxx" -#include "MPIProcessorGroup.hxx" -#include "ExplicitCoincidentDEC.hxx" -#include "ExplicitMapping.hxx" -#include "InterpKernelUtilities.hxx" - -using namespace std; - -namespace ParaMEDMEM -{ - /*! \defgroup explicitcoincidentdec ExplicitCoincidentDEC - */ - ExplicitCoincidentDEC::ExplicitCoincidentDEC():_toposource(0),_topotarget(0) - { - } - - ExplicitCoincidentDEC::~ExplicitCoincidentDEC() - { - } - - - /*! - \addtogroup explicitcoincidentdec - @{ - */ - - /*! Synchronization process for exchanging topologies - */ - void ExplicitCoincidentDEC::synchronize() - { - if (_source_group->containsMyRank()) - { - _toposource = dynamic_cast(_local_field->getTopology()); - _sourcegroup= _toposource->getProcGroup()->createProcGroup(); - _targetgroup=_toposource->getProcGroup()->createComplementProcGroup(); - } - if (_target_group->containsMyRank()) - { - _topotarget = dynamic_cast(_local_field->getTopology()); - _sourcegroup= _topotarget->getProcGroup()->createComplementProcGroup(); - _targetgroup=_topotarget->getProcGroup()->createProcGroup(); - } - - // Exchanging - - // Transmitting source topology to target code - broadcastTopology(_toposource,_topotarget,1000); - transferMappingToSource(); - } - - /*! Creates the arrays necessary for the data transfer - * and fills the send array with the values of the - * source field - * */ - void ExplicitCoincidentDEC::prepareSourceDE() - { - //////////////////////////////////// - //Step 1 : buffer array creation - - if (!_toposource->getProcGroup()->containsMyRank()) - return; - MPIProcessorGroup* group=new MPIProcessorGroup(_sourcegroup->getCommInterface()); - - // Warning : the size of the target side is implicitly deduced - //from the size of MPI_COMM_WORLD - int target_size = _toposource->getProcGroup()->getCommInterface().worldSize()- _toposource->getProcGroup()->size() ; - - vector* target_arrays=new vector[target_size]; - - int nb_local = _toposource-> getNbLocalElements(); - - int union_size=group->size(); - - _sendcounts=new int[union_size]; - _senddispls=new int[union_size]; - _recvcounts=new int[union_size]; - _recvdispls=new int[union_size]; - - for (int i=0; i< union_size; i++) - { - _sendcounts[i]=0; - _recvcounts[i]=0; - _recvdispls[i]=0; - } - _senddispls[0]=0; - - int* counts=_explicit_mapping.getCounts(); - for (int i=0; isize(); i++) - _sendcounts[i]=counts[i]; - - for (int iproc=1; iprocsize();iproc++) - _senddispls[iproc]=_senddispls[iproc-1]+_sendcounts[iproc-1]; - - _sendbuffer = new double [nb_local * _toposource->getNbComponents()]; - - ///////////////////////////////////////////////////////////// - //Step 2 : filling the buffers with the source field values - - int* counter=new int [target_size]; - counter[0]=0; - for (int i=1; igetField()->getArray()->getPointer(); - - int* bufferindex= _explicit_mapping.getBufferIndex(); - - for (int ielem=0; ielemgetNbComponents(); - for (int icomp=0; icompgetProcGroup()->containsMyRank()) - return; - MPIProcessorGroup* group=new MPIProcessorGroup(_topotarget->getProcGroup()->getCommInterface()); - - vector < vector > source_arrays(_sourcegroup->size()); - int nb_local = _topotarget-> getNbLocalElements(); - for (int ielem=0; ielem< nb_local ; ielem++) - { - //pair source_local =_distant_elems[ielem]; - pair source_local=_explicit_mapping.getDistantNumbering(ielem); - source_arrays[source_local.first].push_back(source_local.second); - } - int union_size=group->size(); - _recvcounts=new int[union_size]; - _recvdispls=new int[union_size]; - _sendcounts=new int[union_size]; - _senddispls=new int[union_size]; - - for (int i=0; i< union_size; i++) - { - _sendcounts[i]=0; - _recvcounts[i]=0; - _recvdispls[i]=0; - } - for (int iproc=0; iproc < _sourcegroup->size(); iproc++) - { - //converts the rank in target to the rank in union communicator - int unionrank=group->translateRank(_sourcegroup,iproc); - _recvcounts[unionrank]=source_arrays[iproc].size()*_topotarget->getNbComponents(); - } - for (int i=1; igetNbComponents()]; - - } - - - /*! - * Synchronizing a topology so that all the - * group possesses it. - * - * \param toposend Topology that is transmitted. It is read on processes where it already exists, and it is created and filled on others. - * \param toporecv Topology which is received. - * \param tag Communication tag associated with this operation. - */ - void ExplicitCoincidentDEC::broadcastTopology(const ExplicitTopology* toposend, ExplicitTopology* toporecv, int tag) - { - MPI_Status status; - - int* serializer=0; - int size; - - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); - - // The send processors serialize the send topology - // and send the buffers to the recv procs - if (toposend !=0 && toposend->getProcGroup()->containsMyRank()) - { - toposend->serialize(serializer, size); - for (int iproc=0; iproc< group->size(); iproc++) - { - int itarget=iproc; - if (!toposend->getProcGroup()->contains(itarget)) - { - _comm_interface->send(&size,1,MPI_INT, itarget,tag+itarget,*(group->getComm())); - _comm_interface->send(serializer, size, MPI_INT, itarget, tag+itarget,*(group->getComm())); - } - } - } - else - { - vector size (group->size()); - int myworldrank=group->myRank(); - for (int iproc=0; iprocsize();iproc++) - { - int isource = iproc; - if (!toporecv->getProcGroup()->contains(isource)) - { - int nbelem; - _comm_interface->recv(&nbelem, 1, MPI_INT, isource, tag+myworldrank, *(group->getComm()), &status); - int* buffer = new int[nbelem]; - _comm_interface->recv(buffer, nbelem, MPI_INT, isource,tag+myworldrank, *(group->getComm()), &status); - - ExplicitTopology* topotemp=new ExplicitTopology(); - topotemp->unserialize(buffer, *_comm_interface); - delete[] buffer; - - for (int ielem=0; ielemgetNbLocalElements(); ielem++) - { - int global = toporecv->localToGlobal(ielem); - int sendlocal=topotemp->globalToLocal(global); - if (sendlocal!=-1) - { - size[iproc]++; - _explicit_mapping.pushBackElem(make_pair(iproc,sendlocal)); - } - } - delete topotemp; - } - } - } - MESSAGE (" rank "<myRank()<< " broadcastTopology is over"); - } - - void ExplicitCoincidentDEC::transferMappingToSource() - { - - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); - - // sending source->target mapping which is stored by target - //in _distant_elems from target to source - if (_topotarget!=0 && _topotarget->getProcGroup()->containsMyRank()) - { - int world_size = _topotarget->getProcGroup()->getCommInterface().worldSize() ; - int* nb_transfer_union=new int[world_size]; - int* dummy_recv=new int[world_size]; - for (int i=0; itranslateRank(_sourcegroup,_explicit_mapping.getDistantDomain(i)); - nb_transfer_union[unionrank]=_explicit_mapping.getNbDistantElems(i); - } - _comm_interface->allToAll(nb_transfer_union, 1, MPI_INT, dummy_recv, 1, MPI_INT, MPI_COMM_WORLD); - - int* sendbuffer= _explicit_mapping.serialize(_topotarget->getProcGroup()->myRank()); - - int* sendcounts= new int [world_size]; - int* senddispls = new int [world_size]; - for (int i=0; i< world_size; i++) - { - sendcounts[i]=2*nb_transfer_union[i]; - if (i==0) - senddispls[i]=0; - else - senddispls[i]=senddispls[i-1]+sendcounts[i-1]; - } - int* recvcounts=new int[world_size]; - int* recvdispls=new int[world_size]; - int *dummyrecv=0; - for (int i=0; i allToAllV(sendbuffer, sendcounts, senddispls, MPI_INT, dummyrecv, recvcounts, senddispls, MPI_INT, MPI_COMM_WORLD); - - } - //receiving in the source subdomains the mapping sent by targets - else - { - int world_size = _toposource->getProcGroup()->getCommInterface().worldSize() ; - int* nb_transfer_union=new int[world_size]; - int* dummy_send=new int[world_size]; - for (int i=0; iallToAll(dummy_send, 1, MPI_INT, nb_transfer_union, 1, MPI_INT, MPI_COMM_WORLD); - - int total_size=0; - for (int i=0; i< world_size; i++) - total_size+=nb_transfer_union[i]; - int nbtarget = _targetgroup->size(); - int* targetranks = new int[ nbtarget]; - for (int i=0; itranslateRank(_targetgroup,i); - int* mappingbuffer= new int [total_size*2]; - int* sendcounts= new int [world_size]; - int* senddispls = new int [world_size]; - int* recvcounts=new int[world_size]; - int* recvdispls=new int[world_size]; - for (int i=0; i< world_size; i++) - { - recvcounts[i]=2*nb_transfer_union[i]; - if (i==0) - recvdispls[i]=0; - else - recvdispls[i]=recvdispls[i-1]+recvcounts[i-1]; - } - - int *dummysend=0; - for (int i=0; i allToAllV(dummysend, sendcounts, senddispls, MPI_INT, mappingbuffer, recvcounts, recvdispls, MPI_INT, MPI_COMM_WORLD); - _explicit_mapping.unserialize(world_size,nb_transfer_union,nbtarget, targetranks, mappingbuffer); - } - } - - void ExplicitCoincidentDEC::recvData() - { - //MPI_COMM_WORLD is used instead of group because there is no - //mechanism for creating the union group yet - MESSAGE("recvData"); - - cout<<"start AllToAll"<allToAllV(_sendbuffer, _sendcounts, _senddispls, MPI_DOUBLE, - _recvbuffer, _recvcounts, _recvdispls, MPI_DOUBLE,MPI_COMM_WORLD); - cout<<"end AllToAll"<getNbLocalElements(); - double* value=new double[nb_local*_topotarget->getNbComponents()]; - - vector counters(_sourcegroup->size()); - counters[0]=0; - for (int i=0; i<_sourcegroup->size()-1; i++) - { - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); - int worldrank=group->translateRank(_sourcegroup,i); - counters[i+1]=counters[i]+_recvcounts[worldrank]; - } - - for (int ielem=0; ielem distant_numbering=_explicit_mapping.getDistantNumbering(ielem); - int iproc=distant_numbering.first; - int ncomp = _topotarget->getNbComponents(); - for (int icomp=0; icomp< ncomp; icomp++) - value[ielem*ncomp+icomp]=_recvbuffer[counters[iproc]*ncomp+icomp]; - counters[iproc]++; - } - _local_field->getField()->getArray()->useArray(value,true,CPP_DEALLOC,nb_local,_topotarget->getNbComponents()); - } - - void ExplicitCoincidentDEC::sendData() - { - MESSAGE ("sendData"); - for (int i=0; i< 4; i++) - cout << _sendcounts[i]<<" "; - cout <allToAllV(_sendbuffer, _sendcounts, _senddispls, MPI_DOUBLE, - _recvbuffer, _recvcounts, _recvdispls, MPI_DOUBLE,MPI_COMM_WORLD); - } - /*! - @} - */ -} - diff --git a/src/ParaMEDMEM/ExplicitCoincidentDEC.hxx b/src/ParaMEDMEM/ExplicitCoincidentDEC.hxx deleted file mode 100644 index 75ffa101b..000000000 --- a/src/ParaMEDMEM/ExplicitCoincidentDEC.hxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2010 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 __EXPLICITCOINCIDENTDEC_HXX__ -#define __EXPLICITCOINCIDENTDEC_HXX__ - -#include "DEC.hxx" -#include "ExplicitMapping.hxx" -#include "ExplicitTopology.hxx" - -#include - -namespace ParaMEDMEM -{ - class BlockTopology; - - class ExplicitCoincidentDEC : public DEC - { - public: - ExplicitCoincidentDEC(); - virtual ~ExplicitCoincidentDEC(); - void synchronize(); - void broadcastTopology(BlockTopology*&, int tag); - void broadcastTopology(const ExplicitTopology* toposend, ExplicitTopology* toporecv, int tag); - void transferMappingToSource(); - void prepareSourceDE(); - void prepareTargetDE(); - void recvData(); - void sendData(); - private: - ExplicitTopology* _toposource; - ExplicitTopology* _topotarget; - ProcessorGroup* _targetgroup; - ProcessorGroup* _sourcegroup; - int* _sendcounts; - int* _recvcounts; - int* _senddispls; - int* _recvdispls; - double* _recvbuffer; - double* _sendbuffer; - std::map > _distant_elems; - ExplicitMapping _explicit_mapping; - }; -} - -#endif diff --git a/src/ParaMEDMEM/ExplicitMapping.hxx b/src/ParaMEDMEM/ExplicitMapping.hxx deleted file mode 100644 index 825e4e53f..000000000 --- a/src/ParaMEDMEM/ExplicitMapping.hxx +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2007-2010 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 __EXPLICITMAPPING_HXX__ -#define __EXPLICITMAPPING_HXX__ - -#include -#include -#include - -namespace ParaMEDMEM -{ - class ExplicitMapping - { - public: - - ExplicitMapping():_numbers(0), _domains(0), _comm_buffer(0) { } - - ~ExplicitMapping() - { - if (_domains!=0) delete[] _domains; - if (_numbers!=0) delete[] _numbers; - if (_comm_buffer!=0) delete[] _comm_buffer; - } - - void pushBackElem(std::pair idistant) - { - _mapping.push_back(idistant); - } - - void setDistantElem(int ilocal, std::pair idistant) - { - _mapping[ilocal]=idistant; - } - - int nbDistantDomains() - { - if (_distant_domains.empty()) - { - for (std::vector >::const_iterator iter= _mapping.begin(); - iter!=_mapping.end(); - iter++) - _distant_domains.insert(iter->first); - } - return _distant_domains.size(); - } - - std::pair getDistantNumbering(int ielem)const - { - return _mapping[ielem]; - } - - int getDistantDomain(int i) - { - if (_domains==0) - computeNumbers(); - - return _domains[i]; - } - - int getNbDistantElems(int i) - { - if (_numbers==0) - computeNumbers(); - return _numbers[i]; - } - - int* serialize(int idproc) - { - _comm_buffer=new int[_mapping.size()*2]; - std::vector offsets(_distant_domains.size()); - offsets[0]=0; - for (int i=1; i<(int)_distant_domains.size();i++) - offsets[i]=offsets[i-1]+_numbers[i-1]; - - for (int i=0; i<(int)_mapping.size(); i++) - { - int offset= offsets[_mapping[i].first]; - _comm_buffer[offset*2]=idproc; - _comm_buffer[offset*2+1]=_mapping[i].second; - offsets[_mapping[i].first]++; - } - return _comm_buffer; - } - - void unserialize(int nbprocs, int* sizes,int nbtarget, int* targetrank, int* commbuffer) - { - int total_size=0; - for (int i=0; i< nbprocs; i++) - total_size+=sizes[i]; - - _mapping.resize(total_size); - _buffer_index=new int[total_size]; - int indmap=0; - for (int i=0; i0) - { - _numbers[index]=sizes[targetrank[i]]; - _domains[index]=i; - index++; - } - } - _send_counts=new int[nbprocs]; - for (int i=0; i > _mapping; - std::set _distant_domains; - int* _numbers; - int* _domains; - int* _comm_buffer; - int* _buffer_index; - int* _send_counts; - - void computeNumbers() - { - std::map counts; - if (_numbers==0) - { - _numbers=new int[nbDistantDomains()]; - _domains=new int[nbDistantDomains()]; - for (int i=0; i<(int)_mapping.size(); i++) - { - if ( counts.find(_mapping[i].first) == counts.end()) - counts.insert(std::make_pair(_mapping[i].first,1)); - else - (counts[_mapping[i].first])++; - } - int counter=0; - for (std::map::const_iterator iter=counts.begin(); - iter!=counts.end(); - iter++) - { - _numbers[counter]=iter->second; - _domains[counter]=iter->first; - counter++; - } - } - } - }; -} - -#endif diff --git a/src/ParaMEDMEM/ExplicitTopology.cxx b/src/ParaMEDMEM/ExplicitTopology.cxx deleted file mode 100644 index d65805828..000000000 --- a/src/ParaMEDMEM/ExplicitTopology.cxx +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2007-2010 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 "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "ParaMESH.hxx" -#include "Topology.hxx" -#include "ExplicitTopology.hxx" -#include "BlockTopology.hxx" -#include "ComponentTopology.hxx" - -#include -#include - -using namespace std; -namespace ParaMEDMEM -{ - -ExplicitTopology::ExplicitTopology(const ParaMESH& paramesh ): -_proc_group(paramesh.getBlockTopology()->getProcGroup()), -_nb_components(1) -{ - _nb_elems=paramesh.getCellMesh()->getNumberOfCells(); - const int* global=paramesh.getGlobalNumberingCell(); - _loc2glob=new int[_nb_elems]; - - for (int i=0; i<_nb_elems; i++) - { - _loc2glob[i]=global[i]; - _glob2loc[global[i]]=i; - } -} - -ExplicitTopology::ExplicitTopology(const ExplicitTopology& topo, int nb_components) -{ - _proc_group = topo._proc_group; - _nb_elems = topo._nb_elems; - _nb_components = nb_components; - _loc2glob=new int[_nb_elems]; - for (int i=0; i<_nb_elems; i++) - { - _loc2glob[i]=topo._loc2glob[i]; - } - _glob2loc=topo._glob2loc; -} - - -ExplicitTopology::~ExplicitTopology() -{ - if (_loc2glob != 0) delete[] _loc2glob; -} - - -/*! Serializes the data contained in the Explicit Topology - * for communication purposes*/ -void ExplicitTopology::serialize(int* & serializer, int& size) const -{ - vector buffer; - - buffer.push_back(_nb_elems); - for (int i=0; i<_nb_elems; i++) - { - buffer.push_back(_loc2glob[i]); - } - - serializer=new int[buffer.size()]; - size= buffer.size(); - copy(buffer.begin(), buffer.end(), serializer); - -} -/*! Unserializes the data contained in the Explicit Topology - * after communication. Uses the same structure as the one used for serialize() - * - * */ -void ExplicitTopology::unserialize(const int* serializer,const CommInterface& comm_interface) -{ - const int* ptr_serializer=serializer; - cout << "unserialize..."< -#include -#include - -namespace ParaMEDMEM -{ - class ParaMESH; - class Topology; - class ComponentTopology; - - class ExplicitTopology : public Topology - { - public: - ExplicitTopology() { } - ExplicitTopology( const ExplicitTopology& topo, int nbcomponents); - ExplicitTopology(const ParaMESH &mesh); - virtual ~ExplicitTopology(); - - inline int getNbElements()const; - inline int getNbLocalElements() const; - const ProcessorGroup* getProcGroup()const { return _proc_group; } - int localToGlobal (const std::pair local) const { return localToGlobal(local.second); } - inline int localToGlobal(int) const; - inline int globalToLocal(int) const; - void serialize(int* & serializer, int& size) const ; - void unserialize(const int* serializer, const CommInterface& comm_interface); - int getNbComponents() const { return _nb_components; } - private: - //Processor group - const ProcessorGroup* _proc_group; - //nb of elements - int _nb_elems; - //nb of components - int _nb_components; - //mapping local to global - int* _loc2glob; - //mapping global to local - INTERP_KERNEL::HashMap _glob2loc; - }; - - //!converts a pair to a global number - inline int ExplicitTopology::globalToLocal(const int global) const - { - return (_glob2loc.find(global))->second;; - } - - //!converts local number to a global number - int ExplicitTopology::localToGlobal(int local) const - { - return _loc2glob[local]; - } - - //!Retrieves the number of elements for a given topology - inline int ExplicitTopology::getNbElements() const - { - return _nb_elems; - } - - //Retrieves the local number of elements - inline int ExplicitTopology::getNbLocalElements()const - { - return _glob2loc.size(); - } -} - - -#endif diff --git a/src/ParaMEDMEM/ICoCoField.cxx b/src/ParaMEDMEM/ICoCoField.cxx deleted file mode 100644 index 1251ee1d6..000000000 --- a/src/ParaMEDMEM/ICoCoField.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2010 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 -// -// ICoCo file common to several codes -// ICoCoField.cpp -// version 1.2 10/05/2010 - -#include -#include - -using namespace ICoCo; -using std::string; - -Field::Field() { - _name=new string; -} - -Field::~Field() { - delete _name; -} - -void Field::setName(const string& name) { - *_name=name; -} - -const string& Field::getName() const { - return *_name; -} - -const char* Field::getCharName() const { - return _name->c_str(); -} diff --git a/src/ParaMEDMEM/ICoCoField.hxx b/src/ParaMEDMEM/ICoCoField.hxx deleted file mode 100644 index b38eb0034..000000000 --- a/src/ParaMEDMEM/ICoCoField.hxx +++ /dev/null @@ -1,24 +0,0 @@ -// ICoCo file common to several codes -// ICoCoField.h -// version 1.2 10/05/2010 - -#ifndef _ICoCoField_included_ -#define _ICoCoField_included_ -#include - - -namespace ICoCo { - - class Field { - public: - Field(); - virtual ~Field(); - void setName(const std::string& name); - const std::string& getName() const; - const char* getCharName() const; - - private: - std::string* _name; - }; -} -#endif diff --git a/src/ParaMEDMEM/ICoCoMEDField.cxx b/src/ParaMEDMEM/ICoCoMEDField.cxx deleted file mode 100644 index cc3b61dd5..000000000 --- a/src/ParaMEDMEM/ICoCoMEDField.cxx +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (C) 2007-2010 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 "ICoCoMEDField.hxx" -#include "ICoCoTrioField.hxx" -#include "ProcessorGroup.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace ICoCo -{ - - /*! Constructor directly attaching a MEDCouplingUMesh and a MEDCouplingFieldDouble - the object does not take the control the objects pointed by - \a mesh and \a field. - */ - - MEDField::MEDField(ParaMEDMEM::MEDCouplingUMesh* mesh, ParaMEDMEM::MEDCouplingFieldDouble* field): - _mesh(mesh), - _field(field) - { - if(_mesh) - _mesh->incrRef(); - if(_field) - _field->incrRef(); - } - - MEDField::MEDField(TrioField& triofield) - { - _mesh = ParaMEDMEM::MEDCouplingUMesh::New(); - _mesh->setMeshDimension(triofield._space_dim); - ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New(); - myCoords->alloc(triofield._nbnodes,triofield._space_dim); - _mesh->setCoords(myCoords); - myCoords->decrRef(); - double *ptr=myCoords->getPointer(); - std::copy(triofield._coords,triofield._coords+triofield._space_dim*triofield._nbnodes,ptr); - _mesh->allocateCells(triofield._nb_elems); - INTERP_KERNEL::NormalizedCellType elemtype; - switch (triofield._mesh_dim) - { - case 2: - switch (triofield._nodes_per_elem) - { - case 3: - elemtype=INTERP_KERNEL::NORM_TRI3; - break; - case 4 : - elemtype=INTERP_KERNEL::NORM_QUAD4; - break; - default: - throw INTERP_KERNEL::Exception("incompatible Trio field - wrong nb of nodes per elem"); - } - break; - case 3: - switch (triofield._nodes_per_elem) - { - case 4: - elemtype=INTERP_KERNEL::NORM_TETRA4; - break; - case 8 : - elemtype=INTERP_KERNEL::NORM_HEXA8; - break; - default: - throw INTERP_KERNEL::Exception("incompatible Trio field - wrong nb of nodes per elem"); - } - break; - default: - throw INTERP_KERNEL::Exception("incompatible Trio field - wrong mesh dimension"); - } - //creating a connectivity table that complies to MED (1 indexing) - //and passing it to _mesh - int* conn=new int[triofield._nodes_per_elem]; - for (int i=0; iinsertNextCell(elemtype,triofield._nodes_per_elem,conn); - } - delete[] conn; - - _mesh->setMeshDimension(triofield._mesh_dim); - _mesh->finishInsertingCells(); - - //field on the sending end - int nb_case=triofield.nb_values(); - if (triofield._type==0) - { - _field = ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME); - } - else - { - _field = ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::ONE_TIME ); - } - _field->setMesh(_mesh); - _field->setNature(ParaMEDMEM::ConservativeVolumic); - ParaMEDMEM::DataArrayDouble *fieldArr=ParaMEDMEM::DataArrayDouble::New(); - fieldArr->alloc(_field->getNumberOfTuples(),triofield._nb_field_components); - _field->setName(triofield.getName().c_str()); - std::string meshName("SupportOf_"); meshName+=_field->getName(); - _mesh->setName(meshName.c_str()); - _field->setTime(triofield._time1,0,triofield._itnumber); - if (triofield._field!=0) - { - for (int i =0; isetIJ(i,j,triofield._field[i*triofield._nb_field_components+j]); - } - } - //field on the receiving end - else - { - // the trio field points to the pointer inside the MED field - triofield._field=const_cast (fieldArr->getPointer()); - for (int i=0; isetArray(fieldArr); - fieldArr->decrRef(); - } - - MEDField::~MEDField() - { - if(_field) - _field->decrRef(); - if(_mesh) - _mesh->decrRef(); - } -} diff --git a/src/ParaMEDMEM/ICoCoMEDField.hxx b/src/ParaMEDMEM/ICoCoMEDField.hxx deleted file mode 100644 index e43512ad3..000000000 --- a/src/ParaMEDMEM/ICoCoMEDField.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2010 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 __ICOCOMEDFIELD_HXX__ -#define __ICOCOMEDFIELD_HXX__ - -#include "ICoCoField.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" - -#include - -namespace ICoCo -{ - class TrioField; - - class MEDField : public ICoCo::Field - { - public: - MEDField():_mesh(0),_field(0) { } - MEDField(ParaMEDMEM::MEDCouplingUMesh* mesh, ParaMEDMEM::MEDCouplingFieldDouble* field); - MEDField(TrioField&); - virtual ~MEDField(); - ParaMEDMEM::MEDCouplingFieldDouble* getField() const { return _field; } - ParaMEDMEM::MEDCouplingUMesh* getMesh()const { return _mesh; } - private: - ParaMEDMEM::MEDCouplingUMesh* _mesh; - ParaMEDMEM::MEDCouplingFieldDouble* _field; - }; -} - -#endif diff --git a/src/ParaMEDMEM/ICoCoTrioField.cxx b/src/ParaMEDMEM/ICoCoTrioField.cxx deleted file mode 100644 index 0b18196c2..000000000 --- a/src/ParaMEDMEM/ICoCoTrioField.cxx +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (C) 2007-2010 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 -// -// ICoCo file common to several codes -// ICoCoTrioField.cpp -// version 1.2 10/05/2010 - -#include -#include -#include -#include - -using namespace ICoCo; -using namespace std; - -// Default constructor -TrioField::TrioField() : - _type(0), - _mesh_dim(0), - _space_dim(0), - _nbnodes(0), - _nodes_per_elem(0), - _nb_elems(0), - _itnumber(0), - _connectivity(0), - _coords(0), - _time1(0.), - _time2(0.), - _nb_field_components(0), - _field(0), - _has_field_ownership(false) { } - -// Copy constructor -TrioField::TrioField(const TrioField& OtherField) { - (*this)=OtherField; -} - -// Destructor -TrioField::~TrioField() { - clear(); -} - -// After the call to clear(), all pointers are null and field ownership is false. -// Arrays are deleted if necessary -void TrioField::clear() { - if (_connectivity) - delete[] _connectivity; - if (_coords) - delete[] _coords; - if (_field && _has_field_ownership) - delete[] _field; - _connectivity=0; - _coords=0; - _field=0; - _has_field_ownership=false; -} - -// Returns the number of value locations -// The size of field is nb_values()*_nb_field_components -int TrioField::nb_values() const { - if (_type==0) - return _nb_elems; - else if (_type==1) - return _nbnodes; - throw 0; - //exit(-1); - return -1; -} - -// Save field to a .field file (loadable by visit!) -void TrioField::save(ostream& os) const{ - - os << setprecision(12); - os << getName() << endl; - os << _type << endl; - os << _mesh_dim << endl; - os << _space_dim << endl; - os << _nbnodes << endl; - os << _nodes_per_elem << endl; - os << _nb_elems << endl; - - os<< _itnumber<> name; - setName(name); - in >> _type; - in >> _mesh_dim; - in >> _space_dim; - in >> _nbnodes; - in >> _nodes_per_elem; - in >> _nb_elems; - - in >> _itnumber; - if (_connectivity) - delete [] _connectivity; - _connectivity=new int[_nodes_per_elem*_nb_elems]; - for (int i=0;i<_nb_elems;i++) { - for (int j=0;j<_nodes_per_elem;j++) - in >> _connectivity[i*_nodes_per_elem+j]; - } - if (_coords) - delete [] _coords; - _coords=new double[_nbnodes*_space_dim]; - for (int i=0;i<_nbnodes;i++) { - for (int j=0;j<_space_dim;j++) - in >> _coords[i*_space_dim+j]; - } - - in >> _time1; - in >> _time2; - in >> _nb_field_components; - int test; - in >> test; - if (test) { - if (_field) - delete [] _field; - _field=new double[_nb_field_components*nb_values()]; - for (int i=0;i> _field[i*_nb_field_components+j]; - } - } - else - _field=0; - - in >> _has_field_ownership; -} - - -// After the call to set_standalone(), field ownership is true and field is allocated -// to the size _nb_field_components*nb_values(). -// The values of the field have been copied if necessary. -void TrioField::set_standalone() { - if (!_field) { - _field=new double[_nb_field_components*nb_values()]; - _has_field_ownership=true; - - } - else if (!_has_field_ownership) { - double *tmp_field=new double[_nb_field_components*nb_values()]; - memcpy(tmp_field,_field,_nb_field_components*nb_values()*sizeof(double)); - _field=tmp_field; - _has_field_ownership=true; - } -} - -// Used to simulate a 0D geometry (Cathare/Trio for example). -void TrioField::dummy_geom() { - _type=0; - _mesh_dim=2; - _space_dim=2; - _nbnodes=3; - _nodes_per_elem=3; - _nb_elems=1; - _itnumber=0; - if (_connectivity) - delete[] _connectivity; - _connectivity=new int[3]; - _connectivity[0]=0; - _connectivity[1]=1; - _connectivity[2]=2; - if (_coords) - delete[] _coords; - _coords=new double[6]; - _coords[0]=0; - _coords[1]=0; - _coords[2]=1; - _coords[3]=0; - _coords[4]=0; - _coords[5]=1; - _time1=0; - _time2=1; - _nb_field_components=1; - if (_field && _has_field_ownership) - delete[] _field; - _has_field_ownership=false; - _field=0; -} - -// Overloading operator = for TrioField -// This becomes an exact copy of NewField. -// If NewField._has_field_ownership is false, they point to the same values. -// Otherwise the values are copied. -TrioField& TrioField::operator=(const TrioField& NewField){ - - clear(); - - _type=NewField._type; - _mesh_dim=NewField._mesh_dim; - _space_dim=NewField._space_dim; - _nbnodes=NewField._nbnodes; - _nodes_per_elem=NewField._nodes_per_elem; - _nb_elems=NewField._nb_elems; - _itnumber=NewField._itnumber; - _time1=NewField._time1; - _time2=NewField._time2; - _nb_field_components=NewField._nb_field_components; - - if (!NewField._connectivity) - _connectivity=0; - else { - _connectivity=new int[_nodes_per_elem*_nb_elems]; - memcpy( _connectivity,NewField._connectivity,_nodes_per_elem*_nb_elems*sizeof(int)); - } - - if (!NewField._coords) - _coords=0; - else { - _coords=new double[_nbnodes*_space_dim]; - memcpy( _coords,NewField._coords,_nbnodes*_space_dim*sizeof(double)); - } - - //Copie des valeurs du champ - _has_field_ownership=NewField._has_field_ownership; - if (_has_field_ownership) { - _field=new double[nb_values()*_nb_field_components]; - memcpy(_field,NewField._field,nb_values()*_nb_field_components*sizeof(double)); - } - else - _field=NewField._field; - - return(*this); - -} - - - diff --git a/src/ParaMEDMEM/ICoCoTrioField.hxx b/src/ParaMEDMEM/ICoCoTrioField.hxx deleted file mode 100644 index 738e312ea..000000000 --- a/src/ParaMEDMEM/ICoCoTrioField.hxx +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2010 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 -// -// ICoCo file common to several codes -// ICoCoTrioField.h -// version 1.2 10/05/2010 - -#ifndef _ICoCoTrioField_included_ -#define _ICoCoTrioField_included_ - -#include -namespace ICoCo { - - ////////////////////////////////////////////////////////////////////////////// - // - // .DESCRIPTION - // class TrioField, used for coupling Trio codes via the ICoCo interface - // This structure contains all the necessary information - // for constructing a ParaMEDMEM::ParaFIELD (with the addition of the MPI - // communicator). - // This structure can either own or not _field values (_has_field_ownership) - // For _coords, _connectivity and _field, a null pointer means no data allocated. - // _coords and _connectivity tables, when allocated, are always owned by the TrioField. - // - ////////////////////////////////////////////////////////////////////////////// - class TrioField:public Field { - public: - - TrioField(); - TrioField(const TrioField& OtherField); - ~TrioField(); - void clear(); - void set_standalone(); - void dummy_geom(); - TrioField& operator=(const TrioField& NewField); - void save(std::ostream& os) const; - void restore(std::istream& in); - int nb_values() const ; - - public: - int _type ; // 0 elem 1 nodes - int _mesh_dim; - int _space_dim; - int _nbnodes; - int _nodes_per_elem; - int _nb_elems; - int _itnumber; - int* _connectivity; - double* _coords; - - double _time1,_time2; - int _nb_field_components; - double* _field; - bool _has_field_ownership; - }; -} - -#endif diff --git a/src/ParaMEDMEM/InterpKernelDEC.cxx b/src/ParaMEDMEM/InterpKernelDEC.cxx deleted file mode 100644 index 6c4674f84..000000000 --- a/src/ParaMEDMEM/InterpKernelDEC.cxx +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include "CommInterface.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "ComponentTopology.hxx" -#include "ParaFIELD.hxx" -#include "MPIProcessorGroup.hxx" -#include "ParaMESH.hxx" -#include "DEC.hxx" -#include "InterpolationMatrix.hxx" -#include "InterpKernelDEC.hxx" -#include "ElementLocator.hxx" - -namespace ParaMEDMEM -{ - - /*! - \defgroup interpkerneldec InterpKernelDEC - - \section overview Overview - - The InterpKernelDEC enables the \ref conservativeremapping of fields between two parallel codes. This remapping is based on the computation of intersection volumes between elements from code A and elements from code B. The computation is possible for 3D meshes, 2D meshes, and 3D-surface meshes. Dimensions must be similar for code A and code B (for instance, though it could be desirable, it is not yet possible to couple 3D surfaces with 2D surfaces). - - In the present version, only fields lying on elements are considered. - - \image html NonCoincident_small.png "Example showing the transfer from a field based on a quadrangular mesh to a triangular mesh. In a P0-P0 interpolation, to obtain the value on a triangle, the values on quadrangles are weighted by their intersection area and summed." - - \image latex NonCoincident_small.eps "Example showing the transfer from a field based on a quadrangular mesh to a triangular mesh. In a P0-P0 interpolation, to obtain the value on a triangle, the values on quadrangles are weighted by their intersection area and summed." - - A typical use of InterpKernelDEC encompasses two distinct phases : - - A setup phase during which the intersection volumes are computed and the communication structures are setup. This corresponds to calling the InterpKernelDEC::synchronize() method. - - A use phase during which the remappings are actually performed. This corresponds to the calls to sendData() and recvData() which actually trigger the data exchange. The data exchange are synchronous in the current version of the library so that recvData() and sendData() calls must be synchronized on code A and code B processor groups. - - The following code excerpt illutrates a typical use of the InterpKernelDEC class. - - \code - ... - InterpKernelDEC dec(groupA, groupB); - dec.attachLocalField(field); - dec.synchronize(); - if (groupA.containsMyRank()) - dec.recvData(); - else if (groupB.containsMyRank()) - dec.sendData(); - ... - \endcode - A \ref conservativeremapping of the field from the source mesh to the target mesh is performed by the function synchronise(), which computes the \ref remappingmatrix. - - Computing the field on the receiving side can be expressed in terms of a matrix-vector product : \f$ \phi_t=W.\phi_s\f$, with \f$ \phi_t \f$ the field on the target side and \f$ \phi_s \f$ the field on the source side. - When remapping a 3D surface to another 3D surface, a projection phase is necessary to match elements from both sides. Care must be taken when defining this projection to obtain a \ref conservative remapping. - - In the P0-P0 case, this matrix is a plain rectangular matrix with coefficients equal to the intersection areas between triangle and quadrangles. For instance, in the above figure, the matrix is : - - \f[ - \begin{tabular}{|cccc|} - 0.72 & 0 & 0.2 & 0 \\ - 0.46 & 0 & 0.51 & 0.03\\ - 0.42 & 0.53 & 0 & 0.05\\ - 0 & 0 & 0.92 & 0.05 \\ - \end{tabular} - \f] - - - - \section interpkerneldec_options Options - On top of \ref dec_options, options supported by %InterpKernelDEC objects are - related to the underlying Intersector class. - All the options available in the intersector objects are - available for the %InterpKernelDEC object. The various options available for * intersectors can be reviewed in \ref InterpKerIntersectors. - - For instance : - \verbatim - InterpKernelDEC dec(source_group, target_group); - dec.attachLocalField(field); - dec.setOptions("DoRotate",false); - dec.setOptions("Precision",1e-12); - dec.synchronize(); - \endverbatim - - \warning{ Options must be set before calling the synchronize method. } - */ - - /*! - \addtogroup interpkerneldec - @{ - */ - - InterpKernelDEC::InterpKernelDEC() - { - } - - /*! - This constructor creates an InterpKernelDEC which has \a source_group as a working side - and \a target_group as an idle side. All the processors will actually participate, but intersection computations will be performed on the working side during the \a synchronize() phase. - The constructor must be called synchronously on all processors of both processor groups. - - \param source_group working side ProcessorGroup - \param target_group lazy side ProcessorGroup - - */ - InterpKernelDEC::InterpKernelDEC(ProcessorGroup& source_group, ProcessorGroup& target_group): - DEC(source_group, target_group),_interpolation_matrix(0) - { - - } - - InterpKernelDEC::InterpKernelDEC(const std::set& src_ids, const std::set& trg_ids, - const MPI_Comm& world_comm):DEC(src_ids,trg_ids,world_comm), - _interpolation_matrix(0) - { - } - - InterpKernelDEC::~InterpKernelDEC() - { - if (_interpolation_matrix !=0) - delete _interpolation_matrix; - } - - /*! - \brief Synchronization process for exchanging topologies. - - This method prepares all the structures necessary for sending data from a processor group to the other. It uses the mesh underlying the fields that have been set with attachLocalField method. - It works in four steps : - -# Bounding boxes are computed for each subdomain, - -# The lazy side mesh parts that are likely to intersect the working side local processor are sent to the working side, - -# The working side calls the interpolation kernel to compute the intersection between local and imported mesh. - -# The lazy side is updated so that it knows the structure of the data that will be sent by - the working side during a \a sendData() call. - - */ - void InterpKernelDEC::synchronize() - { - if(!isInUnion()) - return ; - delete _interpolation_matrix; - _interpolation_matrix = new InterpolationMatrix (_local_field, *_source_group,*_target_group,*this,*this); - - //setting up the communication DEC on both sides - if (_source_group->containsMyRank()) - { - //locate the distant meshes - ElementLocator locator(*_local_field, *_target_group, *_source_group); - //transfering option from InterpKernelDEC to ElementLocator - locator.copyOptions(*this); - MEDCouplingPointSet* distant_mesh=0; - int* distant_ids=0; - std::string distantMeth; - for (int i=0; i<_target_group->size(); i++) - { - // int idistant_proc = (i+_source_group->myRank())%_target_group->size(); - int idistant_proc=i; - - //gathers pieces of the target meshes that can intersect the local mesh - locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); - if (distant_mesh !=0) - { - locator.exchangeMethod(_method,idistant_proc,distantMeth); - //adds the contribution of the distant mesh on the local one - int idistant_proc_in_union=_union_group->translateRank(_target_group,idistant_proc); - std::cout <<"add contribution from proc "<myRank()<addContribution(*distant_mesh,idistant_proc_in_union,distant_ids,_method,distantMeth); - distant_mesh->decrRef(); - delete [] distant_ids; - distant_mesh=0; - distant_ids=0; - } - } - _interpolation_matrix->finishContributionW(locator); - } - - if (_target_group->containsMyRank()) - { - ElementLocator locator(*_local_field, *_source_group, *_target_group); - //transfering option from InterpKernelDEC to ElementLocator - locator.copyOptions(*this); - MEDCouplingPointSet* distant_mesh=0; - int* distant_ids=0; - for (int i=0; i<_source_group->size(); i++) - { - // int idistant_proc = (i+_target_group->myRank())%_source_group->size(); - int idistant_proc=i; - //gathers pieces of the target meshes that can intersect the local mesh - locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); - std::cout << " Data sent from "<<_union_group->myRank()<<" to source proc "<< idistant_proc<decrRef(); - delete [] distant_ids; - distant_mesh=0; - distant_ids=0; - } - } - _interpolation_matrix->finishContributionL(locator); - } - _interpolation_matrix->prepare(); - } - - - /*! - Receives the data whether the processor is on the working side or on the lazy side. It must match a \a sendData() call on the other side. - */ - void InterpKernelDEC::recvData() - { - if (_source_group->containsMyRank()) - _interpolation_matrix->transposeMultiply(*_local_field->getField()); - else if (_target_group->containsMyRank()) - { - _interpolation_matrix->multiply(*_local_field->getField()); - if (getForcedRenormalization()) - renormalizeTargetField(getMeasureAbsStatus()); - } - } - - - /*! - Receives the data at time \a time in asynchronous mode. The value of the field - will be time-interpolated from the field values received. - \param time time at which the value is desired - */ - void InterpKernelDEC::recvData( double time ) - { - _interpolation_matrix->getAccessDEC()->setTime(time); - recvData() ; - } - - /*! - Sends the data whether the processor is on the working side or on the lazy side. - It must match a recvData() call on the other side. - */ - void InterpKernelDEC::sendData() - { - if (_source_group->containsMyRank()) - { - - _interpolation_matrix->multiply(*_local_field->getField()); - if (getForcedRenormalization()) - renormalizeTargetField(getMeasureAbsStatus()); - - } - else if (_target_group->containsMyRank()) - _interpolation_matrix->transposeMultiply(*_local_field->getField()); - } - - /*! - Sends the data available at time \a time in asynchronous mode. - \param time time at which the value is available - \param deltatime time interval between the value presently sent and the next one. - */ - void InterpKernelDEC::sendData( double time , double deltatime ) - { - _interpolation_matrix->getAccessDEC()->setTime(time,deltatime); - sendData() ; - } - - /*! - @} - */ - -} diff --git a/src/ParaMEDMEM/InterpKernelDEC.hxx b/src/ParaMEDMEM/InterpKernelDEC.hxx deleted file mode 100644 index 7930a044d..000000000 --- a/src/ParaMEDMEM/InterpKernelDEC.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2010 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 __INTERPKERNELDEC_HXX__ -#define __INTERPKERNELDEC_HXX__ - -#include "DEC.hxx" -#include "MxN_Mapping.hxx" -#include "InterpolationOptions.hxx" - -namespace ParaMEDMEM -{ - class InterpolationMatrix; - - class InterpKernelDEC : public DEC, public INTERP_KERNEL::InterpolationOptions - { - public: - InterpKernelDEC(); - InterpKernelDEC(ProcessorGroup& source_group, ProcessorGroup& target_group); - InterpKernelDEC(const std::set& src_ids, const std::set& trg_ids, - const MPI_Comm& world_comm=MPI_COMM_WORLD); - virtual ~InterpKernelDEC(); - void synchronize(); - void recvData(); - void recvData(double time); - void sendData(); - void sendData(double time , double deltatime); - void prepareSourceDE() { } - void prepareTargetDE() { } - private : - //Number of distant points to be located locally - int _nb_distant_points; - //coordinates of distant points - const double* _distant_coords; - //local element number containing the distant points - const int* _distant_locations; - InterpolationMatrix* _interpolation_matrix; - }; -} - -#endif diff --git a/src/ParaMEDMEM/InterpolationMatrix.cxx b/src/ParaMEDMEM/InterpolationMatrix.cxx deleted file mode 100644 index c7db0371c..000000000 --- a/src/ParaMEDMEM/InterpolationMatrix.cxx +++ /dev/null @@ -1,939 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "ProcessorGroup.hxx" -#include "MxN_Mapping.hxx" -#include "InterpolationMatrix.hxx" -#include "TranslationRotationMatrix.hxx" -#include "Interpolation.hxx" -#include "Interpolation1D.txx" -#include "Interpolation2DCurve.txx" -#include "Interpolation2D.txx" -#include "Interpolation3DSurf.txx" -#include "Interpolation3D.txx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingNormalizedUnstructuredMesh.txx" -#include "InterpolationOptions.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "ElementLocator.hxx" - -#include - -// class InterpolationMatrix -// This class enables the storage of an interpolation matrix Wij mapping -// source field Sj to target field Ti via Ti=Vi^(-1).Wij.Sj. -// The matrix is built and stored on the processors belonging to the source -// group. - -using namespace std; - -namespace ParaMEDMEM -{ - - // ==================================================================== - // Creates an empty matrix structure linking two distributed supports. - // The method must be called by all processors belonging to source - // and target groups. - // param source_support local support - // param source_group processor group containing the local processors - // param target_group processor group containing the distant processors - // param method interpolation method - // ==================================================================== - - InterpolationMatrix::InterpolationMatrix(const ParaMEDMEM::ParaFIELD *source_field, - const ProcessorGroup& source_group, - const ProcessorGroup& target_group, - const DECOptions& dec_options, - const INTERP_KERNEL::InterpolationOptions& interp_options): - INTERP_KERNEL::InterpolationOptions(interp_options), - DECOptions(dec_options), - _source_field(source_field), - _source_support(source_field->getSupport()->getCellMesh()), - _mapping(source_group, target_group, dec_options), - _source_group(source_group), - _target_group(target_group) - { - int nbelems = source_field->getField()->getNumberOfTuples(); - _row_offsets.resize(nbelems+1); - _coeffs.resize(nbelems); - _target_volume.resize(nbelems); - } - - InterpolationMatrix::~InterpolationMatrix() - { - } - - - // ====================================================================== - // \brief Adds the contribution of a distant subdomain to the* - // interpolation matrix. - // The method adds contribution to the interpolation matrix. - // For each row of the matrix, elements are addded as - // a (column, coeff) pair in the _coeffs array. This column number refers - // to an element on the target side via the _col_offsets array. - // It is made of a series of (iproc, ielem) pairs. - // The number of elements per row is stored in the row_offsets array. - - // param distant_support local representation of the distant subdomain - // param iproc_distant id of the distant subdomain (in the distant group) - // param distant_elems mapping between the local representation of - // the subdomain and the actual elem ids on the distant subdomain - // ====================================================================== - - void InterpolationMatrix::addContribution ( MEDCouplingPointSet& distant_support, - int iproc_distant, - const int* distant_elems, - const std::string& srcMeth, - const std::string& targetMeth) - { - std::string interpMethod(targetMeth); - interpMethod+=srcMeth; - //creating the interpolator structure - vector > surfaces; - int colSize=0; - //computation of the intersection volumes between source and target elements - MEDCouplingUMesh *distant_supportC=dynamic_cast(&distant_support); - MEDCouplingUMesh *source_supportC=dynamic_cast(_source_support); - if ( distant_support.getMeshDimension() == -1 ) - { - if(source_supportC->getMeshDimension()==2 && source_supportC->getSpaceDimension()==2) - { - MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(source_supportC); - INTERP_KERNEL::Interpolation2D interpolation(*this); - colSize=interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str()); - } - else if(source_supportC->getMeshDimension()==3 && source_supportC->getSpaceDimension()==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(source_supportC); - INTERP_KERNEL::Interpolation3D interpolation(*this); - colSize=interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str()); - } - else if(source_supportC->getMeshDimension()==2 && source_supportC->getSpaceDimension()==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(source_supportC); - INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - colSize=interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str()); - } - else - throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh"); - } - else if ( source_supportC->getMeshDimension() == -1 ) - { - if(distant_supportC->getMeshDimension()==2 && distant_supportC->getSpaceDimension()==2) - { - MEDCouplingNormalizedUnstructuredMesh<2,2> distant_mesh_wrapper(distant_supportC); - INTERP_KERNEL::Interpolation2D interpolation(*this); - colSize=interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str()); - } - else if(distant_supportC->getMeshDimension()==3 && distant_supportC->getSpaceDimension()==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,3> distant_mesh_wrapper(distant_supportC); - INTERP_KERNEL::Interpolation3D interpolation(*this); - colSize=interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str()); - } - else if(distant_supportC->getMeshDimension()==2 && distant_supportC->getSpaceDimension()==3) - { - MEDCouplingNormalizedUnstructuredMesh<3,2> distant_mesh_wrapper(distant_supportC); - INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - colSize=interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str()); - } - else - throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of distant mesh to -1D sourceMesh"); - } - else if (distant_support.getMeshDimension() != _source_support->getMeshDimension()) - { - throw INTERP_KERNEL::Exception("local and distant meshes do not have the same space and mesh dimensions"); - } - else if( distant_support.getMeshDimension() == 1 - && distant_support.getSpaceDimension() == 1 ) - { - MEDCouplingNormalizedUnstructuredMesh<1,1> target_wrapper(distant_supportC); - MEDCouplingNormalizedUnstructuredMesh<1,1> source_wrapper(source_supportC); - - INTERP_KERNEL::Interpolation1D interpolation(*this); - colSize=interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); - target_wrapper.releaseTempArrays(); - source_wrapper.releaseTempArrays(); - } - else if( distant_support.getMeshDimension() == 1 - && distant_support.getSpaceDimension() == 2 ) - { - MEDCouplingNormalizedUnstructuredMesh<2,1> target_wrapper(distant_supportC); - MEDCouplingNormalizedUnstructuredMesh<2,1> source_wrapper(source_supportC); - - INTERP_KERNEL::Interpolation2DCurve interpolation(*this); - colSize=interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); - target_wrapper.releaseTempArrays(); - source_wrapper.releaseTempArrays(); - } - else if ( distant_support.getMeshDimension() == 2 - && distant_support.getSpaceDimension() == 3 ) - { - MEDCouplingNormalizedUnstructuredMesh<3,2> target_wrapper(distant_supportC); - MEDCouplingNormalizedUnstructuredMesh<3,2> source_wrapper(source_supportC); - - INTERP_KERNEL::Interpolation3DSurf interpolator (*this); - colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); - target_wrapper.releaseTempArrays(); - source_wrapper.releaseTempArrays(); - } - else if ( distant_support.getMeshDimension() == 2 - && distant_support.getSpaceDimension() == 2) - { - MEDCouplingNormalizedUnstructuredMesh<2,2> target_wrapper(distant_supportC); - MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(source_supportC); - - INTERP_KERNEL::Interpolation2D interpolator (*this); - colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); - target_wrapper.releaseTempArrays(); - source_wrapper.releaseTempArrays(); - } - else if ( distant_support.getMeshDimension() == 3 - && distant_support.getSpaceDimension() == 3 ) - { - MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(distant_supportC); - MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(source_supportC); - - INTERP_KERNEL::Interpolation3D interpolator (*this); - colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); - target_wrapper.releaseTempArrays(); - source_wrapper.releaseTempArrays(); - } - else - { - throw INTERP_KERNEL::Exception("no interpolator exists for these mesh and space dimensions "); - } - bool needTargetSurf=isSurfaceComputationNeeded(targetMeth); - - MEDCouplingFieldDouble *target_triangle_surf=0; - if(needTargetSurf) - target_triangle_surf = distant_support.getMeasureField(getMeasureAbsStatus()); - fillDSFromVM(iproc_distant,distant_elems,surfaces,target_triangle_surf); - - if(needTargetSurf) - target_triangle_surf->decrRef(); - } - - void InterpolationMatrix::fillDSFromVM(int iproc_distant, const int* distant_elems, const std::vector< std::map >& values, MEDCouplingFieldDouble *surf) - { - //loop over the elements to build the interpolation - //matrix structures - int source_size=values.size(); - for (int ielem=0; ielem < source_size; ielem++) - { - _row_offsets[ielem+1] += values[ielem].size(); - for(map::const_iterator iter=values[ielem].begin();iter!=values[ielem].end();iter++) - { - int localId; - if(distant_elems) - localId=distant_elems[iter->first]; - else - localId=iter->first; - //locating the (iproc, itriangle) pair in the list of columns - map,int >::iterator iter2 = _col_offsets.find(make_pair(iproc_distant,localId)); - int col_id; - - if (iter2 == _col_offsets.end()) - { - //(iproc, itriangle) is not registered in the list - //of distant elements - col_id =_col_offsets.size(); - _col_offsets.insert(make_pair(make_pair(iproc_distant,localId),col_id)); - _mapping.addElementFromSource(iproc_distant,localId); - } - else - { - col_id = iter2->second; - } - //the non zero coefficient is stored - //ielem is the row, - //col_id is the number of the column - //iter->second is the value of the coefficient - if(surf) - { - double surface = surf->getIJ(iter->first,0); - _target_volume[ielem].push_back(surface); - } - _coeffs[ielem].push_back(make_pair(col_id,iter->second)); - } - } - } - - void InterpolationMatrix::serializeMe(std::vector< std::vector< std::map > >& data1, std::vector& data2) const - { - data1.clear(); - data2.clear(); - const std::vector >& sendingIds=_mapping.getSendingIds(); - std::set procsS; - for(std::vector >::const_iterator iter1=sendingIds.begin();iter1!=sendingIds.end();iter1++) - procsS.insert((*iter1).first); - data1.resize(procsS.size()); - data2.resize(procsS.size()); - std::copy(procsS.begin(),procsS.end(),data2.begin()); - std::map fastProcAcc; - int id=0; - for(std::set::const_iterator iter2=procsS.begin();iter2!=procsS.end();iter2++,id++) - fastProcAcc[*iter2]=id; - int nbOfSrcElt=_coeffs.size(); - for(std::vector< std::vector< std::map > >::iterator iter3=data1.begin();iter3!=data1.end();iter3++) - (*iter3).resize(nbOfSrcElt); - id=0; - for(std::vector< std::vector< std::pair > >::const_iterator iter4=_coeffs.begin();iter4!=_coeffs.end();iter4++,id++) - { - for(std::vector< std::pair >::const_iterator iter5=(*iter4).begin();iter5!=(*iter4).end();iter5++) - { - const std::pair& elt=sendingIds[(*iter5).first]; - data1[fastProcAcc[elt.first]][id][elt.second]=(*iter5).second; - } - } - } - - void InterpolationMatrix::initialize() - { - int lgth=_coeffs.size(); - _row_offsets.clear(); _row_offsets.resize(lgth+1); - _coeffs.clear(); _coeffs.resize(lgth); - _target_volume.clear(); _target_volume.resize(lgth); - _col_offsets.clear(); - _mapping.initialize(); - } - - void InterpolationMatrix::finishContributionW(ElementLocator& elementLocator) - { - NatureOfField nature=elementLocator.getLocalNature(); - switch(nature) - { - case ConservativeVolumic: - computeConservVolDenoW(elementLocator); - break; - case Integral: - { - if(!elementLocator.isM1DCorr()) - computeIntegralDenoW(elementLocator); - else - computeGlobConstraintDenoW(elementLocator); - break; - } - case IntegralGlobConstraint: - computeGlobConstraintDenoW(elementLocator); - break; - case RevIntegral: - { - if(!elementLocator.isM1DCorr()) - computeRevIntegralDenoW(elementLocator); - else - computeConservVolDenoW(elementLocator); - break; - } - default: - throw INTERP_KERNEL::Exception("Not recognized nature of field. Change nature of Field."); - break; - } - } - - void InterpolationMatrix::finishContributionL(ElementLocator& elementLocator) - { - NatureOfField nature=elementLocator.getLocalNature(); - switch(nature) - { - case ConservativeVolumic: - computeConservVolDenoL(elementLocator); - break; - case Integral: - { - if(!elementLocator.isM1DCorr()) - computeIntegralDenoL(elementLocator); - else - computeConservVolDenoL(elementLocator); - break; - } - case IntegralGlobConstraint: - //this is not a bug doing like ConservativeVolumic - computeConservVolDenoL(elementLocator); - break; - case RevIntegral: - { - if(!elementLocator.isM1DCorr()) - computeRevIntegralDenoL(elementLocator); - else - computeConservVolDenoL(elementLocator); - break; - } - default: - throw INTERP_KERNEL::Exception("Not recognized nature of field. Change nature of Field."); - break; - } - } - - void InterpolationMatrix::computeConservVolDenoW(ElementLocator& elementLocator) - { - computeGlobalColSum(_deno_reverse_multiply); - computeGlobalRowSum(elementLocator,_deno_multiply,_deno_reverse_multiply); - } - - void InterpolationMatrix::computeConservVolDenoL(ElementLocator& elementLocator) - { - int pol1=elementLocator.sendPolicyToWorkingSideL(); - if(pol1==ElementLocator::NO_POST_TREATMENT_POLICY) - { - elementLocator.recvFromWorkingSideL(); - elementLocator.sendToWorkingSideL(); - } - else if(ElementLocator::CUMULATIVE_POLICY) - { - //ask for lazy side to deduce ids eventually missing on working side and to send it back. - elementLocator.recvLocalIdsFromWorkingSideL(); - elementLocator.sendCandidatesGlobalIdsToWorkingSideL(); - elementLocator.recvCandidatesForAddElementsL(); - elementLocator.sendAddElementsToWorkingSideL(); - //Working side has updated its eventually missing ids updates its global ids with lazy side procs contribution - elementLocator.recvLocalIdsFromWorkingSideL(); - elementLocator.sendGlobalIdsToWorkingSideL(); - //like no post treatment - elementLocator.recvFromWorkingSideL(); - elementLocator.sendToWorkingSideL(); - } - else - throw INTERP_KERNEL::Exception("Not managed policy detected on lazy side : not implemented !"); - } - - void InterpolationMatrix::computeIntegralDenoW(ElementLocator& elementLocator) - { - MEDCouplingFieldDouble *source_triangle_surf = _source_support->getMeasureField(getMeasureAbsStatus()); - _deno_multiply.resize(_coeffs.size()); - vector >::iterator iter6=_deno_multiply.begin(); - const double *values=source_triangle_surf->getArray()->getConstPointer(); - for(vector > >::const_iterator iter4=_coeffs.begin();iter4!=_coeffs.end();iter4++,iter6++,values++) - { - (*iter6).resize((*iter4).size()); - std::fill((*iter6).begin(),(*iter6).end(),*values); - } - source_triangle_surf->decrRef(); - _deno_reverse_multiply=_target_volume; - } - - void InterpolationMatrix::computeRevIntegralDenoW(ElementLocator& elementLocator) - { - _deno_multiply=_target_volume; - MEDCouplingFieldDouble *source_triangle_surf = _source_support->getMeasureField(getMeasureAbsStatus()); - _deno_reverse_multiply.resize(_coeffs.size()); - vector >::iterator iter6=_deno_reverse_multiply.begin(); - const double *values=source_triangle_surf->getArray()->getConstPointer(); - for(vector > >::const_iterator iter4=_coeffs.begin();iter4!=_coeffs.end();iter4++,iter6++,values++) - { - (*iter6).resize((*iter4).size()); - std::fill((*iter6).begin(),(*iter6).end(),*values); - } - source_triangle_surf->decrRef(); - } - - /*! - * Nothing to do because surface computation is on working side. - */ - void InterpolationMatrix::computeIntegralDenoL(ElementLocator& elementLocator) - { - } - - /*! - * Nothing to do because surface computation is on working side. - */ - void InterpolationMatrix::computeRevIntegralDenoL(ElementLocator& elementLocator) - { - } - - - void InterpolationMatrix::computeGlobConstraintDenoW(ElementLocator& elementLocator) - { - computeGlobalColSum(_deno_multiply); - computeGlobalRowSum(elementLocator,_deno_reverse_multiply,_deno_multiply); - } - - void InterpolationMatrix::computeGlobalRowSum(ElementLocator& elementLocator, std::vector >& denoStrorage, std::vector >& denoStrorageInv) - { - //stores id in distant procs sorted by lazy procs connected with - vector< vector > rowsPartialSumI; - //stores for each lazy procs connected with, if global info is available and if it's the case the policy - vector policyPartial; - //stores the corresponding values. - vector< vector > rowsPartialSumD; - elementLocator.recvPolicyFromLazySideW(policyPartial); - int pol1=mergePolicies(policyPartial); - if(pol1==ElementLocator::NO_POST_TREATMENT_POLICY) - { - computeLocalRowSum(elementLocator.getDistantProcIds(),rowsPartialSumI,rowsPartialSumD); - elementLocator.sendSumToLazySideW(rowsPartialSumI,rowsPartialSumD); - elementLocator.recvSumFromLazySideW(rowsPartialSumD); - } - else if(pol1==ElementLocator::CUMULATIVE_POLICY) - { - //updateWithNewAdditionnalElements(addingElements); - //stores for each lazy procs connected with, the ids in global mode if it exists (regarding policyPartial). This array has exactly the size of rowsPartialSumI, - //if policyPartial has CUMALATIVE_POLICY in each. - vector< vector > globalIdsPartial; - computeLocalRowSum(elementLocator.getDistantProcIds(),rowsPartialSumI,rowsPartialSumD); - elementLocator.sendLocalIdsToLazyProcsW(rowsPartialSumI); - elementLocator.recvCandidatesGlobalIdsFromLazyProcsW(globalIdsPartial); - std::vector< std::vector > addingElements; - findAdditionnalElements(elementLocator,addingElements,rowsPartialSumI,globalIdsPartial); - addGhostElements(elementLocator.getDistantProcIds(),addingElements); - rowsPartialSumI.clear(); - globalIdsPartial.clear(); - computeLocalRowSum(elementLocator.getDistantProcIds(),rowsPartialSumI,rowsPartialSumD); - elementLocator.sendLocalIdsToLazyProcsW(rowsPartialSumI); - elementLocator.recvGlobalIdsFromLazyProcsW(rowsPartialSumI,globalIdsPartial); - // - elementLocator.sendSumToLazySideW(rowsPartialSumI,rowsPartialSumD); - elementLocator.recvSumFromLazySideW(rowsPartialSumD); - mergeRowSum3(globalIdsPartial,rowsPartialSumD); - mergeCoeffs(elementLocator.getDistantProcIds(),rowsPartialSumI,globalIdsPartial,denoStrorageInv); - } - else - throw INTERP_KERNEL::Exception("Not managed policy detected : not implemented !"); - divideByGlobalRowSum(elementLocator.getDistantProcIds(),rowsPartialSumI,rowsPartialSumD,denoStrorage); - } - - /*! - * @param distantProcs in parameter that indicates which lazy procs are concerned. - * @param resPerProcI out parameter that must be cleared before calling this method. The size of 1st dimension is equal to the size of 'distantProcs'. - * It contains the element ids (2nd dimension) of the corresponding lazy proc. - * @param resPerProcD out parameter with the same format than 'resPerProcI'. It contains corresponding sum values. - */ - void InterpolationMatrix::computeLocalRowSum(const std::vector& distantProcs, std::vector >& resPerProcI, - std::vector >& resPerProcD) const - { - resPerProcI.resize(distantProcs.size()); - resPerProcD.resize(distantProcs.size()); - std::vector res(_col_offsets.size()); - for(vector > >::const_iterator iter=_coeffs.begin();iter!=_coeffs.end();iter++) - for(vector >::const_iterator iter3=(*iter).begin();iter3!=(*iter).end();iter3++) - res[(*iter3).first]+=(*iter3).second; - set procsSet; - int id; - const vector >& mapping=_mapping.getSendingIds(); - for(vector >::const_iterator iter2=mapping.begin();iter2!=mapping.end();iter2++) - { - std::pair::iterator,bool> isIns=procsSet.insert((*iter2).first); - if(isIns.second) - id=std::find(distantProcs.begin(),distantProcs.end(),(*iter2).first)-distantProcs.begin(); - resPerProcI[id].push_back((*iter2).second); - resPerProcD[id].push_back(res[iter2-mapping.begin()]); - } - } - - /*! - * This method is only usable when CUMULATIVE_POLICY detected. This method finds elements ids (typically nodes) lazy side that - * are not present in columns of 'this' and that should regarding cumulative merge of elements regarding their global ids. - */ - void InterpolationMatrix::findAdditionnalElements(ElementLocator& elementLocator, std::vector >& elementsToAdd, - const std::vector >& resPerProcI, const std::vector >& globalIdsPartial) - { - std::set globalIds; - int nbLazyProcs=globalIdsPartial.size(); - for(int i=0;i tmp(globalIds.size()); - std::copy(globalIds.begin(),globalIds.end(),tmp.begin()); - globalIds.clear(); - elementLocator.sendCandidatesForAddElementsW(tmp); - elementLocator.recvAddElementsFromLazyProcsW(elementsToAdd); - } - - void InterpolationMatrix::addGhostElements(const std::vector& distantProcs, const std::vector >& elementsToAdd) - { - std::vector< std::vector< std::map > > data1; - std::vector data2; - serializeMe(data1,data2); - initialize(); - int nbOfDistProcs=distantProcs.size(); - for(int i=0;i& eltsForThisProc=elementsToAdd[i]; - if(!eltsForThisProc.empty()) - { - std::vector::iterator iter1=std::find(data2.begin(),data2.end(),procId); - std::map *toFeed=0; - if(iter1!=data2.end()) - {//to test - int rank=iter1-data2.begin(); - toFeed=&(data1[rank].back()); - } - else - { - iter1=std::lower_bound(data2.begin(),data2.end(),procId); - int rank=iter1-data2.begin(); - data2.insert(iter1,procId); - std::vector< std::map > tmp(data1.front().size()); - data1.insert(data1.begin()+rank,tmp); - toFeed=&(data1[rank].back()); - } - for(std::vector::const_iterator iter2=eltsForThisProc.begin();iter2!=eltsForThisProc.end();iter2++) - (*toFeed)[*iter2]=0.; - } - } - // - nbOfDistProcs=data2.size(); - for(int j=0;j& policyPartial) - { - if(policyPartial.empty()) - return ElementLocator::NO_POST_TREATMENT_POLICY; - int ref=policyPartial[0]; - std::vector::const_iterator iter1=std::find_if(policyPartial.begin(),policyPartial.end(),std::bind2nd(std::not_equal_to(),ref)); - if(iter1!=policyPartial.end()) - { - std::ostringstream msg; msg << "Incompatible policies between lazy procs each other : proc # " << iter1-policyPartial.begin(); - throw INTERP_KERNEL::Exception(msg.str().c_str()); - } - return ref; - } - - /*! - * This method introduce global ids aspects in computed 'rowsPartialSumD'. - * As precondition rowsPartialSumD.size()==policyPartial.size()==globalIdsPartial.size(). Foreach i in [0;rowsPartialSumD.size() ) rowsPartialSumD[i].size()==globalIdsPartial[i].size() - * @param rowsPartialSumD : in parameter, Partial row sum computed for each lazy procs connected with. - * @param rowsPartialSumI : in parameter, Corresponding local ids for each lazy procs connected with. - * @param globalIdsPartial : in parameter, the global numbering, of elements connected with. - * @param globalIdsLazySideInteraction : out parameter, constituted from all global ids of lazy procs connected with. - * @para sumCorresponding : out parameter, relative to 'globalIdsLazySideInteraction' - */ - void InterpolationMatrix::mergeRowSum(const std::vector< std::vector >& rowsPartialSumD, const std::vector< std::vector >& globalIdsPartial, - std::vector& globalIdsLazySideInteraction, std::vector& sumCorresponding) - { - std::map sumToReturn; - int nbLazyProcs=rowsPartialSumD.size(); - for(int i=0;i& rowSumOfP=rowsPartialSumD[i]; - const std::vector& globalIdsOfP=globalIdsPartial[i]; - std::vector::const_iterator iter1=rowSumOfP.begin(); - std::vector::const_iterator iter2=globalIdsOfP.begin(); - for(;iter1!=rowSumOfP.end();iter1++,iter2++) - sumToReturn[*iter2]+=*iter1; - } - // - int lgth=sumToReturn.size(); - globalIdsLazySideInteraction.resize(lgth); - sumCorresponding.resize(lgth); - std::vector::iterator iter3=globalIdsLazySideInteraction.begin(); - std::vector::iterator iter4=sumCorresponding.begin(); - for(std::map::const_iterator iter5=sumToReturn.begin();iter5!=sumToReturn.end();iter5++,iter3++,iter4++) - { - *iter3=(*iter5).first; - *iter4=(*iter5).second; - } - } - - /*! - * This method simply reorganize the result contained in 'sumCorresponding' computed by lazy side into 'rowsPartialSumD' with help of 'globalIdsPartial' and 'globalIdsLazySideInteraction' - * - * @param globalIdsPartial : in parameter, global ids sorted by lazy procs - * @param rowsPartialSumD : in/out parameter, with exactly the same size as 'globalIdsPartial' - * @param globalIdsLazySideInteraction : in parameter that represents ALL the global ids of every lazy procs in interaction - * @param sumCorresponding : in parameter with same size as 'globalIdsLazySideInteraction' that stores the corresponding sum of 'globalIdsLazySideInteraction' - */ - void InterpolationMatrix::mergeRowSum2(const std::vector< std::vector >& globalIdsPartial, std::vector< std::vector >& rowsPartialSumD, - const std::vector& globalIdsLazySideInteraction, const std::vector& sumCorresponding) - { - std::map acc; - std::vector::const_iterator iter1=globalIdsLazySideInteraction.begin(); - std::vector::const_iterator iter2=sumCorresponding.begin(); - for(;iter1!=globalIdsLazySideInteraction.end();iter1++,iter2++) - acc[*iter1]=*iter2; - // - int nbLazyProcs=globalIdsPartial.size(); - for(int i=0;i& tmp1=globalIdsPartial[i]; - std::vector& tmp2=rowsPartialSumD[i]; - std::vector::const_iterator iter3=tmp1.begin(); - std::vector::iterator iter4=tmp2.begin(); - for(;iter3!=tmp1.end();iter3++,iter4++) - *iter4=acc[*iter3]; - } - } - - void InterpolationMatrix::mergeRowSum3(const std::vector< std::vector >& globalIdsPartial, std::vector< std::vector >& rowsPartialSumD) - { - std::map sum; - std::vector< std::vector >::const_iterator iter1=globalIdsPartial.begin(); - std::vector< std::vector >::iterator iter2=rowsPartialSumD.begin(); - for(;iter1!=globalIdsPartial.end();iter1++,iter2++) - { - std::vector::const_iterator iter3=(*iter1).begin(); - std::vector::const_iterator iter4=(*iter2).begin(); - for(;iter3!=(*iter1).end();iter3++,iter4++) - sum[*iter3]+=*iter4; - } - iter2=rowsPartialSumD.begin(); - for(iter1=globalIdsPartial.begin();iter1!=globalIdsPartial.end();iter1++,iter2++) - { - std::vector::const_iterator iter3=(*iter1).begin(); - std::vector::iterator iter4=(*iter2).begin(); - for(;iter3!=(*iter1).end();iter3++,iter4++) - *iter4=sum[*iter3]; - } - } - - /*! - * This method updates this->_coeffs attribute in order to take into account hidden (because having the same global number) similar nodes in _coeffs array. - * If in this->_coeffs two distant element id have the same global id their values will be replaced for each by the sum of the two. - * @param procsInInteraction input parameter : specifies the procId in absolute of distant lazy procs in interaction with - * @param rowsPartialSumI input parameter : local ids of distant lazy procs elements in interaction with - * @param globalIdsPartial input parameter : global ids of distant lazy procs elements in interaction with - */ - void InterpolationMatrix::mergeCoeffs(const std::vector& procsInInteraction, const std::vector< std::vector >& rowsPartialSumI, - const std::vector >& globalIdsPartial, std::vector >& denoStrorageInv) - { - //preparing fast access structures - std::map procT; - int localProcId=0; - for(std::vector::const_iterator iter1=procsInInteraction.begin();iter1!=procsInInteraction.end();iter1++,localProcId++) - procT[*iter1]=localProcId; - int size=procsInInteraction.size(); - std::vector > localToGlobal(size); - for(int i=0;i& myLocalToGlobal=localToGlobal[i]; - const std::vector& locals=rowsPartialSumI[i]; - const std::vector& globals=globalIdsPartial[i]; - std::vector::const_iterator iter3=locals.begin(); - std::vector::const_iterator iter4=globals.begin(); - for(;iter3!=locals.end();iter3++,iter4++) - myLocalToGlobal[*iter3]=*iter4; - } - // - const vector >& mapping=_mapping.getSendingIds(); - std::map globalIdVal; - //accumulate for same global id on lazy part. - for(vector > >::iterator iter1=_coeffs.begin();iter1!=_coeffs.end();iter1++) - for(vector >::iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) - { - const std::pair& distantLocalLazyId=mapping[(*iter2).first]; - int localLazyProcId=procT[distantLocalLazyId.first]; - int globalDistantLazyId=localToGlobal[localLazyProcId][distantLocalLazyId.second]; - globalIdVal[globalDistantLazyId]+=(*iter2).second; - } - //perform merge - std::vector >::iterator iter3=denoStrorageInv.begin(); - for(vector > >::iterator iter1=_coeffs.begin();iter1!=_coeffs.end();iter1++,iter3++) - { - double val=(*iter3).back(); - (*iter3).resize((*iter1).size()); - std::vector::iterator iter4=(*iter3).begin(); - for(vector >::iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++,iter4++) - { - const std::pair& distantLocalLazyId=mapping[(*iter2).first]; - int localLazyProcId=procT[distantLocalLazyId.first]; - int globalDistantLazyId=localToGlobal[localLazyProcId][distantLocalLazyId.second]; - double newVal=globalIdVal[globalDistantLazyId]; - if((*iter2).second!=0.) - (*iter4)=val*newVal/(*iter2).second; - else - (*iter4)=std::numeric_limits::max(); - (*iter2).second=newVal; - } - } - } - - void InterpolationMatrix::divideByGlobalRowSum(const std::vector& distantProcs, const std::vector >& resPerProcI, - const std::vector >& resPerProcD, std::vector >& deno) - { - map fastSums; - int procId=0; - for(vector::const_iterator iter1=distantProcs.begin();iter1!=distantProcs.end();iter1++,procId++) - { - const std::vector& currentProcI=resPerProcI[procId]; - const std::vector& currentProcD=resPerProcD[procId]; - vector::const_iterator iter3=currentProcD.begin(); - for(vector::const_iterator iter2=currentProcI.begin();iter2!=currentProcI.end();iter2++,iter3++) - fastSums[_col_offsets[std::make_pair(*iter1,*iter2)]]=*iter3; - } - deno.resize(_coeffs.size()); - vector >::iterator iter6=deno.begin(); - for(vector > >::const_iterator iter4=_coeffs.begin();iter4!=_coeffs.end();iter4++,iter6++) - { - (*iter6).resize((*iter4).size()); - vector::iterator iter7=(*iter6).begin(); - for(vector >::const_iterator iter5=(*iter4).begin();iter5!=(*iter4).end();iter5++,iter7++) - *iter7=fastSums[(*iter5).first]; - } - } - - void InterpolationMatrix::computeGlobalColSum(std::vector >& denoStrorage) - { - denoStrorage.resize(_coeffs.size()); - vector >::iterator iter2=denoStrorage.begin(); - for(vector > >::const_iterator iter1=_coeffs.begin();iter1!=_coeffs.end();iter1++,iter2++) - { - (*iter2).resize((*iter1).size()); - double sumOfCurrentRow=0.; - for(vector >::const_iterator iter3=(*iter1).begin();iter3!=(*iter1).end();iter3++) - sumOfCurrentRow+=(*iter3).second; - std::fill((*iter2).begin(),(*iter2).end(),sumOfCurrentRow); - } - } - - void InterpolationMatrix::resizeGlobalColSum(std::vector >& denoStrorage) - { - vector >::iterator iter2=denoStrorage.begin(); - for(vector > >::const_iterator iter1=_coeffs.begin();iter1!=_coeffs.end();iter1++,iter2++) - { - double val=(*iter2).back(); - (*iter2).resize((*iter1).size()); - std::fill((*iter2).begin(),(*iter2).end(),val); - } - } - - // ================================================================== - // The call to this method updates the arrays on the target side - // so that they know which amount of data from which processor they - // should expect. - // That call makes actual interpolations via multiply method - // available. - // ================================================================== - - void InterpolationMatrix::prepare() - { - int nbelems = _source_field->getField()->getNumberOfTuples(); - for (int ielem=0; ielem < nbelems; ielem++) - { - _row_offsets[ielem+1]+=_row_offsets[ielem]; - } - _mapping.prepareSendRecv(); - } - - - // ======================================================================= - // brief performs t=Ws, where t is the target field, s is the source field - - // The call to this method must be called both on the working side - // and on the idle side. On the working side, the vector T=VT^(-1).(W.S) - // is computed and sent. On the idle side, no computation is done, but the - // result from the working side is received and the field is updated. - - // param field source field on processors involved on the source side, - // target field on processors on the target side - // ======================================================================= - - void InterpolationMatrix::multiply(MEDCouplingFieldDouble& field) const - { - int nbcomp = field.getArray()->getNumberOfComponents(); - vector target_value(_col_offsets.size()* nbcomp,0.0); - - //computing the matrix multiply on source side - if (_source_group.containsMyRank()) - { - int nbrows = _coeffs.size(); - - // performing W.S - // W is the intersection matrix - // S is the source vector - - for (int irow=0; irowgetNumberOfTuples() ; - double* value = const_cast (field.getArray()->getPointer()); - for (int i=0; igetNumberOfComponents(); - vector source_value(_col_offsets.size()* nbcomp,0.0); - _mapping.reverseSendRecv(&source_value[0],field); - - //treatment of the transpose matrix multiply on the source side - if (_source_group.containsMyRank()) - { - int nbrows = _coeffs.size(); - double *array = field.getArray()->getPointer() ; - - // Initialization - std::fill(array, array+nbrows*nbcomp, 0.0) ; - - //performing WT.T - //WT is W transpose - //T is the target vector - for (int irow = 0; irow < nbrows; irow++) - { - for (int icol = _row_offsets[irow]; icol < _row_offsets[irow+1]; icol++) - { - int colid = _coeffs[irow][icol-_row_offsets[irow]].first; - double value = _coeffs[irow][icol-_row_offsets[irow]].second; - double deno = _deno_reverse_multiply[irow][icol-_row_offsets[irow]]; - for (int icomp=0; icomp& res) const; - void computeLocalRowSum(const std::vector& distantProcs, std::vector >& resPerProcI, - std::vector >& resPerProcD) const; - void computeGlobalRowSum(ElementLocator& elementLocator, std::vector >& denoStrorage, std::vector >& denoStrorageInv); - void computeGlobalColSum(std::vector >& denoStrorage); - void resizeGlobalColSum(std::vector >& denoStrorage); - void fillDSFromVM(int iproc_distant, const int* distant_elems, const std::vector< std::map >& values, MEDCouplingFieldDouble *surf); - void serializeMe(std::vector< std::vector< std::map > >& data1, std::vector& data2) const; - void initialize(); - void findAdditionnalElements(ElementLocator& elementLocator, std::vector >& elementsToAdd, - const std::vector >& resPerProcI, const std::vector >& globalIdsPartial); - void addGhostElements(const std::vector& distantProcs, const std::vector >& elementsToAdd); - int mergePolicies(const std::vector& policyPartial); - void mergeRowSum(const std::vector< std::vector >& rowsPartialSumD, const std::vector< std::vector >& globalIdsPartial, - std::vector& globalIdsLazySideInteraction, std::vector& sumCorresponding); - void mergeRowSum2(const std::vector< std::vector >& globalIdsPartial, std::vector< std::vector >& rowsPartialSumD, - const std::vector& globalIdsLazySideInteraction, const std::vector& sumCorresponding); - void mergeRowSum3(const std::vector< std::vector >& globalIdsPartial, std::vector< std::vector >& rowsPartialSumD); - void mergeCoeffs(const std::vector& procsInInteraction, const std::vector< std::vector >& rowsPartialSumI, - const std::vector >& globalIdsPartial, std::vector >& denoStrorageInv); - void divideByGlobalRowSum(const std::vector& distantProcs, const std::vector >& resPerProcI, - const std::vector >& resPerProcD, std::vector >& deno); - private: - bool isSurfaceComputationNeeded(const std::string& method) const; - private: - const ParaMEDMEM::ParaFIELD *_source_field; - std::vector _row_offsets; - std::map, int > _col_offsets; - MEDCouplingPointSet *_source_support; - MxN_Mapping _mapping; - - const ProcessorGroup& _source_group; - const ProcessorGroup& _target_group; - std::vector< std::vector > _target_volume; - std::vector > > _coeffs; - std::vector > _deno_multiply; - std::vector > _deno_reverse_multiply; - }; -} - -#endif diff --git a/src/ParaMEDMEM/LinearTimeInterpolator.cxx b/src/ParaMEDMEM/LinearTimeInterpolator.cxx deleted file mode 100644 index 23a698e4e..000000000 --- a/src/ParaMEDMEM/LinearTimeInterpolator.cxx +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2007-2010 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 "LinearTimeInterpolator.hxx" - -using namespace std; - -namespace ParaMEDMEM -{ - - LinearTimeInterpolator::LinearTimeInterpolator( double InterpPrecision, int nStepBefore, - int nStepAfter ): - TimeInterpolator( InterpPrecision, nStepBefore, nStepAfter ) - { - } - - LinearTimeInterpolator::~LinearTimeInterpolator() - { - } - - void LinearTimeInterpolator::doInterp( double time0, double time1, double time, - int recvcount , int nbuff0, int nbuff1, - int **recvbuff0, int **recvbuff1, int *result ) - { - for(int i = 0 ; i < recvcount ; i++ ) - result[i] = (int) ((recvbuff0[0][i]*(time1 - time) + recvbuff1[0][i]*(time - time0))/(time1 - time0) + _interp_precision); - } - - void LinearTimeInterpolator::doInterp( double time0, double time1, double time, - int recvcount , int nbuff0, int nbuff1, - double **recvbuff0, double **recvbuff1, - double *result ) - { - for(int i = 0 ; i < recvcount ; i++ ) - result[i] = (recvbuff0[0][i]*(time1 - time) + recvbuff1[0][i]*(time - time0))/(time1 - time0); - } - -} diff --git a/src/ParaMEDMEM/LinearTimeInterpolator.hxx b/src/ParaMEDMEM/LinearTimeInterpolator.hxx deleted file mode 100644 index b93c47bc6..000000000 --- a/src/ParaMEDMEM/LinearTimeInterpolator.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2010 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 __LINEARTIMEINTERPOLATOR_HXX__ -#define __LINEARTIMEINTERPOLATOR_HXX__ - -#include "TimeInterpolator.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class DEC; - - class LinearTimeInterpolator : public TimeInterpolator - { - public: - LinearTimeInterpolator( double InterpPrecision=0, int nStepBefore=1, - int nStepAfter=1 ) ; - virtual ~LinearTimeInterpolator(); - void doInterp( double time0, double time1, double time, int recvcount, - int nbuff0, int nbuff1, - int **recvbuff0, int **recvbuff1, int *result ); - void doInterp( double time0, double time1, double time, int recvcount, - int nbuff0, int nbuff1, - double **recvbuff0, double **recvbuff1, double *result ); - }; -} - -#endif diff --git a/src/ParaMEDMEM/MPIAccess.cxx b/src/ParaMEDMEM/MPIAccess.cxx deleted file mode 100644 index 6e2e5b1f9..000000000 --- a/src/ParaMEDMEM/MPIAccess.cxx +++ /dev/null @@ -1,1063 +0,0 @@ -// Copyright (C) 2007-2010 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 "MPIAccess.hxx" -#include "InterpolationUtils.hxx" - -#include - -using namespace std; - -namespace ParaMEDMEM -{ - /*! \defgroup mpi_access MPIAccess - Class \a MPIAccess is the gateway to the MPI library. - It is a helper class that gathers the calls to the MPI - library that are made in the ParaMEDMEM library. This gathering - allows easier gathering of information about the communication - in the library. With MPIAccess, tags are managed automatically - and asynchronous operations are easier. - - It is typically called after the MPI_Init() call in a program. It is afterwards passed as a parameter to the constructors of ParaMEDMEM objects so that they access the MPI library via the MPIAccess. - - As an example, the following code initializes a processor group made of the zero processor. - - \verbatim - #include "MPIAccess.hxx" - #include "ProcessorGroup.hxx" - - int main(int argc, char** argv) - { - //initialization - MPI_Init(&argc, &argv); - ParaMEDMEM::CommInterface comm_interface; - - //setting up a processor group with proc 0 - set procs; - procs.insert(0); - ParaMEDMEM::ProcessorGroup group(procs, comm_interface); - - ParaMEDMEM::MPIAccess mpi_access(group); - - //cleanup - MPI_Finalize(); - } - \endverbatim - */ - - - /*! Creates a MPIAccess that is based on the processors included in \a ProcessorGroup. - This class may be called for easier use of MPI API. - - \param ProcessorGroup MPIProcessorGroup object giving access to group management - \param BaseTag and MaxTag define the range of tags to be used. - Tags are managed by MPIAccess. They are cyclically incremented. - When there is a Send or a Receive operation there is a new RequestId tag returned - to the caller. That RequestId may be used to manage the operation Wait, Check of - status etc... The MPITag internally managed by MPIAccess is used as "tag" argument - in MPI call. - */ - - MPIAccess::MPIAccess(MPIProcessorGroup * ProcessorGroup, int BaseTag, int MaxTag) : - _comm_interface( ProcessorGroup->getCommInterface() ) , - _intra_communicator( ProcessorGroup->getComm() ) - { - int mpitagub ; - int flag ; - //MPI_Attr_get does not run with _IntraCommunicator ??? - //MPI_Attr_get(*_IntraCommunicator,MPI_TAG_UB,&mpitagub,&flag) ; - MPI_Attr_get(MPI_COMM_WORLD,MPI_TAG_UB,&mpitagub,&flag) ; - mpitagub=abs(mpitagub); - if ( BaseTag != 0 ) - BaseTag = (BaseTag/MODULO_TAG)*MODULO_TAG ; - if ( MaxTag == 0 ) - MaxTag = (mpitagub/MODULO_TAG-1)*MODULO_TAG ; - MPI_Comm_rank( *_intra_communicator, &_my_rank ) ; - if ( !flag | (BaseTag < 0) | (BaseTag >= MaxTag) | (MaxTag > mpitagub) ) - throw INTERP_KERNEL::Exception("wrong call to MPIAccess constructor"); - - _processor_group = ProcessorGroup ; - _processor_group_size = _processor_group->size() ; - _trace = false ; - - _base_request = -1 ; - _max_request = std::numeric_limits::max() ; - _request = _base_request ; - - _base_MPI_tag = BaseTag ; - _max_MPI_tag = MaxTag ; - - _send_request = new int[ _processor_group_size ] ; - _recv_request = new int[ _processor_group_size ] ; - - _send_requests.resize( _processor_group_size ) ; - _recv_requests.resize( _processor_group_size ) ; - - _send_MPI_tag = new int[ _processor_group_size ] ; - _recv_MPI_Tag = new int[ _processor_group_size ] ; - int i ; - for (i = 0 ; i < _processor_group_size ; i++ ) - { - _send_request[ i ] = _max_request ; - _recv_request[ i ] = _max_request ; - _send_requests[ i ].resize(0) ; - _recv_requests[ i ].resize(0) ; - _send_MPI_tag[ i ] = _max_MPI_tag ; - _recv_MPI_Tag[ i ] = _max_MPI_tag ; - } - MPI_Datatype array_of_types[3] ; - array_of_types[0] = MPI_DOUBLE ; - array_of_types[1] = MPI_DOUBLE ; - array_of_types[2] = MPI_INT ; - int array_of_blocklengths[3] ; - array_of_blocklengths[0] = 1 ; - array_of_blocklengths[1] = 1 ; - array_of_blocklengths[2] = 1 ; - MPI_Aint array_of_displacements[3] ; - array_of_displacements[0] = 0 ; - array_of_displacements[1] = sizeof(double) ; - array_of_displacements[2] = 2*sizeof(double) ; - MPI_Type_struct(3, array_of_blocklengths, array_of_displacements, - array_of_types, &_MPI_TIME) ; - MPI_Type_commit(&_MPI_TIME) ; - } - - MPIAccess::~MPIAccess() - { - delete [] _send_request ; - delete [] _recv_request ; - delete [] _send_MPI_tag ; - delete [] _recv_MPI_Tag ; - MPI_Type_free(&_MPI_TIME) ; - } - - /* - MPIAccess and "RequestIds" : - ============================ - - . WARNING : In the specification document, the distinction - between "MPITags" and "RequestIds" is not clear. "MPITags" - are arguments of calls to MPI. "RequestIds" does not concern - calls to MPI. "RequestIds" are named "tag"as arguments in/out - in the MPIAccess API in the specification documentation. - But in the implementation we have the right name RequestId (or - RecvRequestId/SendRequestId). - - . When we have a MPI write/read request via MPIAccess, we get - an identifier "RequestId". - That identifier matches a structure RequestStruct of - MPIAccess. The access to that structure is done with the map - "_MapOfRequestStruct". - That structure RequestStruct give the possibility to manage - the structures MPI_Request and MPI_Status * of MPI. It give - also the possibility to get informations about that request : - target, send/recv, tag, [a]synchronous, type, outcount. - - . That identifier is used to control an asynchronous request - via MPIAccess : Wait, Test, Probe, etc... - - . In practise "RequestId" is simply an integer fo the interval - [0 , 2**32-1]. There is only one such a cyclic for - [I]Sends and [I]Recvs. - - . That "RequestIds" and their associated structures give an easy - way to manage asynchronous communications. - For example we have mpi_access->Wait( int RequestId ) instead of - MPI_Wait(MPI_Request *request, MPI_Status *status). - - . The API of MPIAccess may give the "SendRequestIds" of a "target", - the "RecvRequestIds" from a "source" or the "SendRequestIds" of - all "targets" or the "RecvRequestIds" of all "sources". - That avoid to manage them in Presentation-ParaMEDMEM. - */ - - int MPIAccess::newRequest( MPI_Datatype datatype, int tag , int destsourcerank , - bool fromsourcerank , bool asynchronous ) - { - RequestStruct *mpiaccessstruct = new RequestStruct; - mpiaccessstruct->MPITag = tag ; - mpiaccessstruct->MPIDatatype = datatype ; - mpiaccessstruct->MPITarget = destsourcerank ; - mpiaccessstruct->MPIIsRecv = fromsourcerank ; - MPI_Status *aStatus = new MPI_Status ; - mpiaccessstruct->MPIStatus = aStatus ; - mpiaccessstruct->MPIAsynchronous = asynchronous ; - mpiaccessstruct->MPICompleted = !asynchronous ; - mpiaccessstruct->MPIOutCount = -1 ; - if ( !asynchronous ) - { - mpiaccessstruct->MPIRequest = MPI_REQUEST_NULL ; - mpiaccessstruct->MPIStatus->MPI_SOURCE = destsourcerank ; - mpiaccessstruct->MPIStatus->MPI_TAG = tag ; - mpiaccessstruct->MPIStatus->MPI_ERROR = MPI_SUCCESS ; - } - if ( _request == _max_request ) - _request = _base_request ; - _request += 1 ; - _map_of_request_struct[_request] = mpiaccessstruct ; - if ( fromsourcerank ) - _recv_request[ destsourcerank ] = _request; - else - _send_request[ destsourcerank ] = _request; - if ( _trace ) - cout << "NewRequest" << _my_rank << "( " << _request << " ) " - << mpiaccessstruct << endl ; - return _request ; - } - - /* - MPIAccess and "tags" (or "MPITags") : - ===================================== - - . The constructor give the possibility to choose an interval of - tags to use : [BaseTag , MaxTag]. - The default is [ 0 , MPI_TAG_UB], MPI_TAG_UB being the maximum - value in an implementation of MPI (minimum 32767 = 2**15-1). - On awa with the implementation lam MPI_TAG_UB value is - 7353944. The norma MPI specify that value is the same in all - processes started by mpirun. - In the case of the use of the same IntraCommunicator in a process - for several distinct data flows (or for several IntraCommunicators - with common processes), that permits to avoid ambibuity - and may help debug. - - . In MPIAccess the tags have two parts (#define MODULO_TAG 10) : - + The last decimal digit decimal correspond to MPI_DataType ( 1 for - TimeMessages, 2 for MPI_INT and 3 for MPI_DOUBLE) - + The value of other digits correspond to a circular numero for each - message. - + A TimeMessage and the associated DataMessage have the same numero - (but the types are different and the tags also). - - . For a Send of a message from a process "source" to a process - "target", we have _send_MPI_tag[target] in the process - source (it contains the last "tag" used for the Send of a pour l'envoi de - message to the process target). - And in the process "target" which receive that message, we have - _recv_MPI_Tag[source] (it contains the last "tag" used for the Recv - of messages from the process source). - Naturally in the MPI norma the values of that tags must be the same. - */ - int MPIAccess::newSendTag( MPI_Datatype datatype, int destrank , int method , - bool asynchronous, int &RequestId ) - { - int tag ; - tag = incrTag( _send_MPI_tag[destrank] ) ; - tag = valTag( tag, method ) ; - _send_MPI_tag[ destrank ] = tag ; - RequestId = newRequest( datatype, tag, destrank , false , asynchronous ) ; - _send_request[ destrank ] = RequestId ; - _send_requests[ destrank ].push_back( RequestId ) ; - return tag ; - } - - int MPIAccess::newRecvTag( MPI_Datatype datatype, int sourcerank , int method , - bool asynchronous, int &RequestId ) - { - int tag ; - tag = incrTag( _recv_MPI_Tag[sourcerank] ) ; - tag = valTag( tag, method ) ; - _recv_MPI_Tag[ sourcerank ] = tag ; - RequestId = newRequest( datatype, tag , sourcerank , true , asynchronous ) ; - _recv_request[ sourcerank ] = RequestId ; - _recv_requests[ sourcerank ].push_back( RequestId ) ; - return tag ; - } - - // Returns the number of all SendRequestIds that may be used to allocate - // ArrayOfSendRequests for the call to SendRequestIds - int MPIAccess::sendRequestIdsSize() - { - int size = 0; - for (int i = 0 ; i < _processor_group_size ; i++ ) - size += _send_requests[ i ].size() ; - return size ; - } - - // Returns in ArrayOfSendRequests with the dimension "size" all the - // SendRequestIds - int MPIAccess::sendRequestIds(int size, int *ArrayOfSendRequests) - { - int destrank ; - int i = 0 ; - for ( destrank = 0 ; destrank < _processor_group_size ; destrank++ ) - { - list< int >::const_iterator iter ; - for (iter = _send_requests[ destrank ].begin() ; iter != _send_requests[destrank].end() ; iter++ ) - ArrayOfSendRequests[i++] = *iter ; - } - return i ; - } - - // Returns the number of all RecvRequestIds that may be used to allocate - // ArrayOfRecvRequests for the call to RecvRequestIds - int MPIAccess::recvRequestIdsSize() - { - int size = 0 ; - for (int i = 0 ; i < _processor_group_size ; i++ ) - size += _recv_requests[ i ].size() ; - return size ; - } - - // Returns in ArrayOfRecvRequests with the dimension "size" all the - // RecvRequestIds - int MPIAccess::recvRequestIds(int size, int *ArrayOfRecvRequests) - { - int sourcerank ; - int i = 0 ; - for ( sourcerank = 0 ; sourcerank < _processor_group_size ; sourcerank++ ) - { - list< int >::const_iterator iter ; - for (iter = _recv_requests[ sourcerank ].begin() ; iter != _recv_requests[sourcerank].end() ; iter++ ) - ArrayOfRecvRequests[i++] = *iter ; - } - return i ; - } - - // Returns in ArrayOfSendRequests with the dimension "size" all the - // SendRequestIds to a destination rank - int MPIAccess::sendRequestIds(int destrank, int size, int *ArrayOfSendRequests) - { - if (size < (int)_send_requests[destrank].size() ) - throw INTERP_KERNEL::Exception("wrong call to MPIAccess::SendRequestIds"); - int i = 0 ; - list< int >::const_iterator iter ; - for (iter = _send_requests[ destrank ].begin() ; iter != _send_requests[destrank].end() ; iter++ ) - ArrayOfSendRequests[i++] = *iter ; - return _send_requests[destrank].size() ; - } - - // Returns in ArrayOfRecvRequests with the dimension "size" all the - // RecvRequestIds from a sourcerank - int MPIAccess::recvRequestIds(int sourcerank, int size, int *ArrayOfRecvRequests) - { - if (size < (int)_recv_requests[sourcerank].size() ) - throw INTERP_KERNEL::Exception("wrong call to MPIAccess::RecvRequestIds"); - int i = 0 ; - list< int >::const_iterator iter ; - _recv_requests[ sourcerank ] ; - for (iter = _recv_requests[ sourcerank ].begin() ; iter != _recv_requests[sourcerank].end() ; iter++ ) - ArrayOfRecvRequests[i++] = *iter ; - return _recv_requests[sourcerank].size() ; - } - - // Send in synchronous mode count values of type datatype from buffer to target - // (returns RequestId identifier even if the corresponding structure is deleted : - // it is only in order to have the same signature as the asynchronous mode) - int MPIAccess::send(void* buffer, int count, MPI_Datatype datatype, int target, int &RequestId) - { - int sts = MPI_SUCCESS ; - RequestId = -1 ; - if ( count ) - { - _MessageIdent aMethodIdent = methodId( datatype ) ; - int MPItag = newSendTag( datatype, target , aMethodIdent , false , RequestId ) ; - if ( aMethodIdent == _message_time ) - { - TimeMessage *aTimeMsg = (TimeMessage *) buffer ; - aTimeMsg->tag = MPItag ; - } - deleteRequest( RequestId ) ; - sts = _comm_interface.send(buffer, count, datatype, target, MPItag, - *_intra_communicator ) ; - if ( _trace ) - cout << "MPIAccess::Send" << _my_rank << " SendRequestId " - << RequestId << " count " << count << " target " << target - << " MPItag " << MPItag << endl ; - } - return sts ; - } - - // Receive (read) in synchronous mode count values of type datatype in buffer from source - // (returns RequestId identifier even if the corresponding structure is deleted : - // it is only in order to have the same signature as the asynchronous mode) - // The output argument OutCount is optionnal : *OutCount <= count - int MPIAccess::recv(void* buffer, int count, MPI_Datatype datatype, int source, int &RequestId, int *OutCount) - { - int sts = MPI_SUCCESS ; - RequestId = -1 ; - if ( OutCount != NULL ) - *OutCount = -1 ; - if ( count ) - { - _MessageIdent aMethodIdent = methodId( datatype ) ; - int MPItag = newRecvTag( datatype, source , aMethodIdent , false , RequestId ) ; - sts = _comm_interface.recv(buffer, count, datatype, source, MPItag, - *_intra_communicator , MPIStatus( RequestId ) ) ; - int outcount = 0 ; - if ( sts == MPI_SUCCESS ) - { - MPI_Datatype datatype = MPIDatatype( RequestId ) ; - _comm_interface.getCount(MPIStatus( RequestId ), datatype, &outcount ) ; - setMPIOutCount( RequestId , outcount ) ; - setMPICompleted( RequestId , true ) ; - deleteStatus( RequestId ) ; - } - if ( OutCount != NULL ) - *OutCount = outcount ; - if ( _trace ) - cout << "MPIAccess::Recv" << _my_rank << " RecvRequestId " - << RequestId << " count " << count << " source " << source - << " MPItag " << MPItag << endl ; - deleteRequest( RequestId ) ; - } - return sts ; - } - - // Send in asynchronous mode count values of type datatype from buffer to target - // Returns RequestId identifier. - int MPIAccess::ISend(void* buffer, int count, MPI_Datatype datatype, int target, int &RequestId) - { - int sts = MPI_SUCCESS ; - RequestId = -1 ; - if ( count ) - { - _MessageIdent aMethodIdent = methodId( datatype ) ; - int MPItag = newSendTag( datatype, target , aMethodIdent , true , RequestId ) ; - if ( aMethodIdent == _message_time ) - { - TimeMessage *aTimeMsg = (TimeMessage *) buffer ; - aTimeMsg->tag = MPItag ; - } - MPI_Request *aSendRequest = MPIRequest( RequestId ) ; - if ( _trace ) - { - cout << "MPIAccess::ISend" << _my_rank << " ISendRequestId " - << RequestId << " count " << count << " target " << target - << " MPItag " << MPItag << endl ; - if ( MPItag == 1 ) - cout << "MPIAccess::ISend" << _my_rank << " time " - << ((TimeMessage *)buffer)->time << " " << ((TimeMessage *)buffer)->deltatime - << endl ; - } - sts = _comm_interface.Isend(buffer, count, datatype, target, MPItag, - *_intra_communicator , aSendRequest) ; - } - return sts ; - } - - // Receive (read) in asynchronous mode count values of type datatype in buffer from source - // returns RequestId identifier. - int MPIAccess::IRecv(void* buffer, int count, MPI_Datatype datatype, int source, int &RequestId) - { - int sts = MPI_SUCCESS ; - RequestId = -1 ; - if ( count ) - { - _MessageIdent aMethodIdent = methodId( datatype ) ; - int MPItag = newRecvTag( datatype, source , aMethodIdent , true , RequestId ) ; - MPI_Request *aRecvRequest = MPIRequest( RequestId ) ; - if ( _trace ) - { - cout << "MPIAccess::IRecv" << _my_rank << " IRecvRequestId " - << RequestId << " count " << count << " source " << source - << " MPItag " << MPItag << endl ; - if ( MPItag == 1 ) - cout << "MPIAccess::ISend" << _my_rank << " time " - << ((TimeMessage *)buffer)->time << " " << ((TimeMessage *)buffer)->deltatime - << endl ; - } - sts = _comm_interface.Irecv(buffer, count, datatype, source, MPItag, - *_intra_communicator , aRecvRequest) ; - } - return sts ; - } - - // Perform a Send and a Recv in synchronous mode - int MPIAccess::sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, - int dest, int &SendRequestId, - void* recvbuf, int recvcount, MPI_Datatype recvtype, - int source, int &RecvRequestId, int *OutCount) - { - int sts = MPI_SUCCESS ; - SendRequestId = -1 ; - RecvRequestId = -1 ; - if ( recvcount ) - sts = IRecv(recvbuf, recvcount, recvtype, source, RecvRequestId) ; - int outcount = -1 ; - if ( _trace ) - cout << "MPIAccess::SendRecv" << _my_rank << " IRecv RecvRequestId " - << RecvRequestId << endl ; - if ( sts == MPI_SUCCESS ) - { - if ( sendcount ) - sts = send(sendbuf, sendcount, sendtype, dest, SendRequestId) ; - if ( _trace ) - cout << "MPIAccess::SendRecv" << _my_rank << " Send SendRequestId " - << SendRequestId << endl ; - if ( sts == MPI_SUCCESS && recvcount ) - { - sts = wait( RecvRequestId ) ; - outcount = MPIOutCount( RecvRequestId ) ; - if ( _trace ) - cout << "MPIAccess::SendRecv" << _my_rank << " IRecv RecvRequestId " - << RecvRequestId << " outcount " << outcount << endl ; - } - } - if ( OutCount != NULL ) - { - *OutCount = outcount ; - if ( _trace ) - cout << "MPIAccess::SendRecv" << _my_rank << " *OutCount = " << *OutCount - << endl ; - } - deleteRequest( RecvRequestId ) ; - return sts ; - } - - // Perform a Send and a Recv in asynchronous mode - int MPIAccess::ISendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, - int dest, int &SendRequestId, - void* recvbuf, int recvcount, MPI_Datatype recvtype, - int source, int &RecvRequestId) - { - int sts = MPI_SUCCESS ; - SendRequestId = -1 ; - RecvRequestId = -1 ; - if ( recvcount ) - sts = IRecv(recvbuf, recvcount, recvtype, source, RecvRequestId) ; - if ( sts == MPI_SUCCESS ) - if ( sendcount ) - sts = ISend(sendbuf, sendcount, sendtype, dest, SendRequestId) ; - return sts ; - } - - // Perform a wait of a Send or Recv asynchronous Request - // Do nothing for a synchronous Request - // Manage MPI_Request * and MPI_Status * structure - int MPIAccess::wait( int RequestId ) - { - int status = MPI_SUCCESS ; - if ( !MPICompleted( RequestId ) ) - { - if ( *MPIRequest( RequestId ) != MPI_REQUEST_NULL ) - { - if ( _trace ) - cout << "MPIAccess::Wait" << _my_rank << " -> wait( " << RequestId - << " ) MPIRequest " << MPIRequest( RequestId ) << " MPIStatus " - << MPIStatus( RequestId ) << " MPITag " << MPITag( RequestId ) - << " MPIIsRecv " << MPIIsRecv( RequestId ) << endl ; - status = _comm_interface.wait(MPIRequest( RequestId ), MPIStatus( RequestId )) ; - } - else - { - if ( _trace ) - cout << "MPIAccess::Wait" << _my_rank << " MPIRequest == MPI_REQUEST_NULL" - << endl ; - } - setMPICompleted( RequestId , true ) ; - if ( MPIIsRecv( RequestId ) && MPIStatus( RequestId ) ) - { - MPI_Datatype datatype = MPIDatatype( RequestId ) ; - int outcount ; - status = _comm_interface.getCount(MPIStatus( RequestId ), datatype, - &outcount ) ; - if ( status == MPI_SUCCESS ) - { - setMPIOutCount( RequestId , outcount ) ; - deleteStatus( RequestId ) ; - if ( _trace ) - cout << "MPIAccess::Wait" << _my_rank << " RequestId " << RequestId - << "MPIIsRecv " << MPIIsRecv( RequestId ) << " outcount " << outcount - << endl ; - } - else - { - if ( _trace ) - cout << "MPIAccess::Wait" << _my_rank << " MPIIsRecv " - << MPIIsRecv( RequestId ) << " outcount " << outcount << endl ; - } - } - else - { - if ( _trace ) - cout << "MPIAccess::Wait" << _my_rank << " MPIIsRecv " << MPIIsRecv( RequestId ) - << " MPIOutCount " << MPIOutCount( RequestId ) << endl ; - } - } - if ( _trace ) - cout << "MPIAccess::Wait" << _my_rank << " RequestId " << RequestId - << " Request " << MPIRequest( RequestId ) - << " Status " << MPIStatus( RequestId ) << " MPICompleted " - << MPICompleted( RequestId ) << " MPIOutCount " << MPIOutCount( RequestId ) - << endl ; - return status ; - } - - // Perform a "test" of a Send or Recv asynchronous Request - // If the request is done, returns true in the flag argument - // If the request is not finished, returns false in the flag argument - // Do nothing for a synchronous Request - // Manage MPI_request * and MPI_status * structure - int MPIAccess::test(int RequestId, int &flag) - { - int status = MPI_SUCCESS ; - flag = MPICompleted( RequestId ) ; - if ( _trace ) - cout << "MPIAccess::Test" << _my_rank << " flag " << flag ; - if ( MPIIsRecv( RequestId ) ) - { - if ( _trace ) - cout << " Recv" ; - } - else - { - if ( _trace ) - cout << " Send" ; - } - if( _trace ) - cout << "Request" << RequestId << " " << MPIRequest( RequestId ) - << " Status " << MPIStatus( RequestId ) << endl ; - if ( !flag ) - { - if ( *MPIRequest( RequestId ) != MPI_REQUEST_NULL ) - { - if ( _trace ) - cout << "MPIAccess::Test" << _my_rank << " -> test( " << RequestId - << " ) MPIRequest " << MPIRequest( RequestId ) - << " MPIStatus " << MPIStatus( RequestId ) - << " MPITag " << MPITag( RequestId ) - << " MPIIsRecv " << MPIIsRecv( RequestId ) << endl ; - status = _comm_interface.test(MPIRequest( RequestId ), &flag, - MPIStatus( RequestId )) ; - } - else - { - if ( _trace ) - cout << "MPIAccess::Test" << _my_rank << " MPIRequest == MPI_REQUEST_NULL" - << endl ; - } - if ( flag ) - { - setMPICompleted( RequestId , true ) ; - if ( MPIIsRecv( RequestId ) && MPIStatus( RequestId ) ) - { - int outcount ; - MPI_Datatype datatype = MPIDatatype( RequestId ) ; - status = _comm_interface.getCount( MPIStatus( RequestId ), datatype, - &outcount ) ; - if ( status == MPI_SUCCESS ) - { - setMPIOutCount( RequestId , outcount ) ; - deleteStatus( RequestId ) ; - if ( _trace ) - cout << "MPIAccess::Test" << _my_rank << " MPIIsRecv " - << MPIIsRecv( RequestId ) << " outcount " << outcount << endl ; - } - else - { - if ( _trace ) - cout << "MPIAccess::Test" << _my_rank << " MPIIsRecv " - << MPIIsRecv( RequestId ) << " outcount " << outcount << endl ; - } - } - else - { - if ( _trace ) - cout << "MPIAccess::Test" << _my_rank << " MPIIsRecv " - << MPIIsRecv( RequestId ) << " MPIOutCount " - << MPIOutCount( RequestId ) << endl ; - } - } - } - if ( _trace ) - cout << "MPIAccess::Test" << _my_rank << " RequestId " << RequestId - << " flag " << flag << " MPICompleted " << MPICompleted( RequestId ) - << " MPIOutCount " << MPIOutCount( RequestId ) << endl ; - return status ; - } - - int MPIAccess::waitAny(int count, int *array_of_RequestIds, int &RequestId) - { - int status = MPI_ERR_OTHER ; - RequestId = -1 ; - cout << "MPIAccess::WaitAny not yet implemented" << endl ; - return status ; - } - - int MPIAccess::testAny(int count, int *array_of_RequestIds, int &RequestId, int &flag) - { - int status = MPI_ERR_OTHER ; - RequestId = -1 ; - flag = 0 ; - cout << "MPIAccess::TestAny not yet implemented" << endl ; - return status ; - } - - // Perform a wait of each Send or Recv asynchronous Request of the array - // array_of_RequestIds of size "count". - // That array may be filled with a call to SendRequestIdsSize or RecvRequestIdsSize - // Do nothing for a synchronous Request - // Manage MPI_Request * and MPI_Status * structure - int MPIAccess::waitAll(int count, int *array_of_RequestIds) - { - if ( _trace ) - cout << "WaitAll" << _my_rank << " : count " << count << endl ; - int status ; - int retstatus = MPI_SUCCESS ; - int i ; - for ( i = 0 ; i < count ; i++ ) - { - if ( _trace ) - cout << "WaitAll" << _my_rank << " " << i << " -> Wait( " - << array_of_RequestIds[i] << " )" << endl ; - status = wait( array_of_RequestIds[i] ) ; - if ( status != MPI_SUCCESS ) - retstatus = status ; - } - if ( _trace ) - cout << "EndWaitAll" << _my_rank << endl ; - return retstatus ; - } - - // Perform a "test" of each Send or Recv asynchronous Request of the array - // array_of_RequestIds of size "count". - // That array may be filled with a call to SendRequestIdsSize or RecvRequestIdsSize - // If all requests are done, returns true in the flag argument - // If all requests are not finished, returns false in the flag argument - // Do nothing for a synchronous Request - // Manage MPI_Request * and MPI_Status * structure - int MPIAccess::testAll(int count, int *array_of_RequestIds, int &flag) - { - if ( _trace ) - cout << "TestAll" << _my_rank << " : count " << count << endl ; - int status ; - int retstatus = MPI_SUCCESS ; - bool retflag = true ; - int i ; - for ( i = 0 ; i < count ; i++ ) - { - status = test( array_of_RequestIds[i] , flag ) ; - retflag = retflag && (flag != 0) ; - if ( status != MPI_SUCCESS ) - retstatus = status ; - } - flag = retflag ; - if ( _trace ) - cout << "EndTestAll" << _my_rank << endl ; - return retstatus ; - } - - int MPIAccess::waitSome(int count, int *array_of_RequestIds, int outcount, - int *outarray_of_RequestIds) - { - int status = MPI_ERR_OTHER ; - cout << "MPIAccess::WaitSome not yet implemented" << endl ; - return status ; - } - - int MPIAccess::testSome(int count, int *array_of_RequestIds, int outcounts, - int *outarray_of_RequestIds) - { - int status = MPI_ERR_OTHER ; - cout << "MPIAccess::TestSome not yet implemented" << endl ; - return status ; - } - - // Probe checks if a message is available for read from FromSource rank. - // Returns the corresponding source, MPITag, datatype and outcount - // Probe is a blocking call which wait until a message is available - int MPIAccess::probe(int FromSource, int &source, int &MPITag, - MPI_Datatype &myDatatype, int &outcount) - { - MPI_Status aMPIStatus ; - int sts = _comm_interface.probe( FromSource, MPI_ANY_TAG, - *_intra_communicator , &aMPIStatus ) ; - if ( sts == MPI_SUCCESS ) - { - source = aMPIStatus.MPI_SOURCE ; - MPITag = aMPIStatus.MPI_TAG ; - int MethodId = (MPITag % MODULO_TAG) ; - myDatatype = datatype( (ParaMEDMEM::_MessageIdent) MethodId ) ; - _comm_interface.getCount(&aMPIStatus, myDatatype, &outcount ) ; - if ( _trace ) - cout << "MPIAccess::Probe" << _my_rank << " FromSource " << FromSource - << " source " << source << " MPITag " << MPITag << " MethodId " - << MethodId << " datatype " << myDatatype << " outcount " << outcount - << endl ; - } - else - { - source = -1 ; - MPITag = -1 ; - myDatatype = 0 ; - outcount = -1 ; - } - return sts ; - } - - // IProbe checks if a message is available for read from FromSource rank. - // If there is a message available, returns the corresponding source, - // MPITag, datatype and outcount with flag = true - // If not, returns flag = false - int MPIAccess::IProbe(int FromSource, int &source, int &MPITag, - MPI_Datatype &myDataType, int &outcount, int &flag) - { - MPI_Status aMPIStatus ; - int sts = _comm_interface.Iprobe( FromSource, MPI_ANY_TAG, - *_intra_communicator , &flag, - &aMPIStatus ) ; - if ( sts == MPI_SUCCESS && flag ) - { - source = aMPIStatus.MPI_SOURCE ; - MPITag = aMPIStatus.MPI_TAG ; - int MethodId = (MPITag % MODULO_TAG) ; - myDataType = datatype( (ParaMEDMEM::_MessageIdent) MethodId ) ; - _comm_interface.getCount(&aMPIStatus, myDataType, &outcount ) ; - if ( _trace ) - cout << "MPIAccess::IProbe" << _my_rank << " FromSource " << FromSource - << " source " << source << " MPITag " << MPITag << " MethodId " - << MethodId << " datatype " << myDataType << " outcount " << outcount - << " flag " << flag << endl ; - } - else - { - source = -1 ; - MPITag = -1 ; - myDataType = 0 ; - outcount = -1 ; - } - return sts ; - } - - // Cancel concerns a "posted" asynchronous IRecv - // Returns flag = true if the receiving request was successfully canceled - // Returns flag = false if the receiving request was finished but not canceled - // Use cancel, wait and test_cancelled of the MPI API - int MPIAccess::cancel( int RecvRequestId, int &flag ) - { - flag = 0 ; - int sts = _comm_interface.cancel( MPIRequest( RecvRequestId ) ) ; - if ( sts == MPI_SUCCESS ) - { - sts = _comm_interface.wait( MPIRequest( RecvRequestId ) , - MPIStatus( RecvRequestId ) ) ; - if ( sts == MPI_SUCCESS ) - sts = _comm_interface.testCancelled( MPIStatus( RecvRequestId ) , &flag ) ; - } - return sts ; - } - - // Cancel concerns a "pending" receiving message (without IRecv "posted") - // Returns flag = true if the message was successfully canceled - // Returns flag = false if the receiving request was finished but not canceled - // Use Irecv, cancel, wait and test_cancelled of the MPI API - int MPIAccess::cancel( int source, int theMPITag, MPI_Datatype datatype, int outcount, int &flag ) - { - int sts ; - MPI_Aint extent ; - flag = 0 ; - sts = MPI_Type_extent( datatype , &extent ) ; - if ( sts == MPI_SUCCESS ) - { - void * recvbuf = malloc( extent*outcount ) ; - MPI_Request aRecvRequest ; - if ( _trace ) - cout << "MPIAccess::Cancel" << _my_rank << " Irecv extent " << extent - << " datatype " << datatype << " source " << source << " theMPITag " - << theMPITag << endl ; - sts = _comm_interface.Irecv( recvbuf, outcount, datatype, source, theMPITag, - *_intra_communicator , &aRecvRequest ) ; - if ( sts == MPI_SUCCESS ) - { - sts = _comm_interface.cancel( &aRecvRequest ) ; - if ( _trace ) - cout << "MPIAccess::Cancel" << _my_rank << " theMPITag " << theMPITag - << " cancel done" << endl ; - if ( sts == MPI_SUCCESS ) - { - MPI_Status aStatus ; - if ( _trace ) - cout << "MPIAccess::Cancel" << _my_rank << " wait" << endl ; - sts = _comm_interface.wait( &aRecvRequest , &aStatus ) ; - if ( sts == MPI_SUCCESS ) - { - if ( _trace ) - cout << "MPIAccess::Cancel" << _my_rank << " test_cancelled" << endl ; - sts = _comm_interface.testCancelled( &aStatus , &flag ) ; - } - } - } - if ( _trace && datatype == timeType() ) - cout << "MPIAccess::Cancel" << _my_rank << " time " - << ((TimeMessage *) recvbuf)->time << " " - << ((TimeMessage *) recvbuf)->deltatime << endl ; - free( recvbuf ) ; - } - if ( _trace ) - cout << "MPIAccess::Cancel" << _my_rank << " flag " << flag << endl ; - return sts ; - } - - - // CancelAll concerns all "pending" receiving message (without IRecv "posted") - // CancelAll use IProbe and Cancel (see obove) - int MPIAccess::cancelAll() - { - int sts = MPI_SUCCESS ; - int target ; - int source ; - int MPITag ; - MPI_Datatype datatype ; - int outcount ; - int flag ; - for ( target = 0 ; target < _processor_group_size ; target++ ) - { - sts = IProbe(target, source, MPITag, datatype, outcount, flag) ; - if ( sts == MPI_SUCCESS && flag ) - { - sts = cancel(source, MPITag, datatype, outcount, flag) ; - if ( _trace ) - cout << "MPIAccess::CancelAll" << _my_rank << " source " << source - << " MPITag " << MPITag << " datatype " << datatype - << " outcount " << outcount << " Cancel flag " << flag << endl ; - if ( sts != MPI_SUCCESS ) - break ; - } - else if ( sts != MPI_SUCCESS ) - break ; - } - return sts ; - } - - // Same as barrier of MPI API - int MPIAccess::barrier() - { - int status = _comm_interface.barrier( *_intra_communicator ) ; - return status ; - } - - // Same as Error_string of MPI API - int MPIAccess::errorString(int errorcode, char *string, int *resultlen) const - { - return _comm_interface.errorString( errorcode, string, resultlen) ; - } - - // Returns source, tag, error and outcount corresponding to receiving RequestId - // By default the corresponding structure of RequestId is deleted - int MPIAccess::status(int RequestId, int &source, int &tag, int &error, - int &outcount, bool keepRequestStruct) - { - MPI_Status *myStatus = MPIStatus( RequestId ) ; - if ( _trace ) - cout << "MPIAccess::status" << _my_rank << " RequestId " << RequestId - << " status " << myStatus << endl ; - if ( myStatus != NULL && MPIAsynchronous( RequestId ) && - MPICompleted( RequestId ) ) - { - if ( MPIIsRecv( RequestId ) ) - { - source = myStatus->MPI_SOURCE ; - tag = myStatus->MPI_TAG ; - error = myStatus->MPI_ERROR ; - MPI_Datatype datatype = MPIDatatype( RequestId ) ; - _comm_interface.getCount(myStatus, datatype, &outcount ) ; - if ( _trace ) - cout << "MPIAccess::status" << _my_rank << " RequestId " << RequestId - << " status " << myStatus << " outcount " << outcount << endl ; - setMPIOutCount( RequestId , outcount ) ; - } - else - { - source = MPITarget( RequestId ) ; - tag = MPITag( RequestId ) ; - error = 0 ; - outcount = MPIOutCount( RequestId ) ; - } - if ( !keepRequestStruct ) - deleteRequest( RequestId ) ; - return MPI_SUCCESS ; - } - else - { - source = MPITarget( RequestId ) ; - tag = MPITag( RequestId ) ; - error = 0 ; - outcount = MPIOutCount( RequestId ) ; - } - return MPI_SUCCESS ; - } - - int MPIAccess::requestFree( MPI_Request *request ) - { - return _comm_interface.requestFree( request ) ; - } - - // Print all informations of all known requests for debugging purpose - void MPIAccess::check() const - { - int i = 0 ; - map< int , RequestStruct * >::const_iterator MapOfRequestStructiterator ; - cout << "MPIAccess::Check" << _my_rank << "_map_of_request_struct_size " - << _map_of_request_struct.size() << endl ; - for ( MapOfRequestStructiterator = _map_of_request_struct.begin() ; - MapOfRequestStructiterator != _map_of_request_struct.end() ; - MapOfRequestStructiterator++ ) - { - if ( MapOfRequestStructiterator->second != NULL ) - { - cout << " Check" << _my_rank << " " << i << ". Request" - << MapOfRequestStructiterator->first << "-->" ; - if ( (MapOfRequestStructiterator->second)->MPIAsynchronous ) - cout << "I" ; - if ( (MapOfRequestStructiterator->second)->MPIIsRecv ) - cout << "Recv from " ; - else - cout << "Send to " ; - cout << (MapOfRequestStructiterator->second)->MPITarget - << " MPITag " << (MapOfRequestStructiterator->second)->MPITag - << " DataType " << (MapOfRequestStructiterator->second)->MPIDatatype - << " Request " << (MapOfRequestStructiterator->second)->MPIRequest - << " Status " << (MapOfRequestStructiterator->second)->MPIStatus - << " Completed " << (MapOfRequestStructiterator->second)->MPICompleted - << endl ; - } - i++ ; - } - } - - // Outputs fields of a TimeMessage structure - ostream & operator<< (ostream & f ,const TimeMessage & aTimeMsg ) - { - f << " time " << aTimeMsg.time << " deltatime " << aTimeMsg.deltatime - << " tag " << aTimeMsg.tag ; - return f; - } - - // Outputs the DataType coded in a Tag - ostream & operator<< (ostream & f ,const _MessageIdent & methodtype ) - { - switch (methodtype) - { - case _message_time : - f << " MethodTime "; - break; - case _message_int : - f << " MPI_INT "; - break; - case _message_double : - f << " MPI_DOUBLE "; - break; - default : - f << " UnknownMethodType "; - break; - } - return f; - } -} diff --git a/src/ParaMEDMEM/MPIAccess.hxx b/src/ParaMEDMEM/MPIAccess.hxx deleted file mode 100644 index 2770e744e..000000000 --- a/src/ParaMEDMEM/MPIAccess.hxx +++ /dev/null @@ -1,495 +0,0 @@ -// Copyright (C) 2007-2010 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 __MPIACCESS_HXX__ -#define __MPIACCESS_HXX__ - -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" - -#include -#include -#include -#include - -namespace ParaMEDMEM -{ - typedef struct - { - double time ; - double deltatime ; - int tag ; - } TimeMessage; - - static MPI_Request mpirequestnull = MPI_REQUEST_NULL ; - enum _MessageIdent { _message_unknown, _message_time, _message_int, _message_double } ; - - class MPIAccess - { - private: - struct RequestStruct - { - int MPITarget ; - bool MPIIsRecv ; - int MPITag ; - bool MPIAsynchronous ; - bool MPICompleted ; - MPI_Datatype MPIDatatype ; - MPI_Request MPIRequest ; - MPI_Status *MPIStatus ; - int MPIOutCount ; - }; - public: - MPIAccess(MPIProcessorGroup * ProcessorGroup, int BaseTag=0, int MaxTag=0) ; - virtual ~MPIAccess() ; - - void trace( bool trace = true ) ; - - void deleteRequest( int RequestId ) ; - void deleteRequests(int size , int *ArrayOfSendRequests ) ; - - int sendMPITag(int destrank) ; - int recvMPITag(int sourcerank) ; - - int sendRequestIdsSize() ; - int sendRequestIds(int size, int *ArrayOfSendRequests) ; - int recvRequestIdsSize() ; - int recvRequestIds(int size, int *ArrayOfRecvRequests) ; - - int sendRequestIdsSize(int destrank) ; - int sendRequestIds(int destrank, int size, int *ArrayOfSendRequests) ; - int recvRequestIdsSize(int sourcerank) ; - int recvRequestIds(int sourcerank, int size, int *ArrayOfRecvRequests) ; - - int send(void* buffer, int count, MPI_Datatype datatype, int target, - int &RequestId) ; - int ISend(void* buffer, int count, MPI_Datatype datatype, int target, - int &RequestId) ; - int recv(void* buffer, int count, MPI_Datatype datatype, int source, - int &RequestId, int *OutCount=NULL) ; - int IRecv(void* buffer, int count, MPI_Datatype datatype, int source, - int &RequestId) ; - int sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dest, - int &SendRequestId, void* recvbuf, int recvcount, - MPI_Datatype recvtype, int source, - int &RecvRequestId, int *OutCount=NULL) ; - int ISendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dest, - int &SendRequestId, void* recvbuf, int recvcount, - MPI_Datatype recvtype, int source, int &RecvRequestId) ; - - int wait(int RequestId) ; - int test(int RequestId, int &flag) ; - int waitAny(int count, int *array_of_RequestIds, int &RequestId) ; - int testAny(int count, int *array_of_RequestIds, int &RequestId, int &flag) ; - int waitAll(int count, int *array_of_RequestIds) ; - int testAll(int count, int *array_of_RequestIds, int &flag) ; - int waitSome(int count, int *array_of_RequestIds, int outcount, - int *outarray_of_RequestIds) ; - int testSome(int count, int *array_of_RequestIds, int outcounts, - int *outarray_of_RequestIds) ; - int probe(int FromSource, int &source, int &MPITag, MPI_Datatype &datatype, - int &outcount) ; - int IProbe(int FromSource, int &source, int &MPITag, MPI_Datatype &datatype, - int &outcount, int &flag) ; - int cancel( int RecvRequestId, int &flag ) ; - int cancel( int source, int MPITag, MPI_Datatype datatype, int outcount, - int &flag ) ; - int cancelAll() ; - int barrier() ; - int errorString(int errorcode, char *string, int *resultlen) const ; - int status(int RequestId, int &source, int &tag, int &error, int &outcount, - bool keepRequestStruct=false) ; - int requestFree( MPI_Request *request ) ; - - void check() const ; - - MPI_Datatype timeType() const ; - bool isTimeMessage( int MPITag ) const ; - MPI_Aint timeExtent() const ; - MPI_Aint intExtent() const ; - MPI_Aint doubleExtent() const ; - MPI_Aint extent( MPI_Datatype datatype ) const ; - - int MPITag( int RequestId ) ; - int MPITarget( int RequestId ) ; - bool MPIIsRecv( int RequestId ) ; - bool MPIAsynchronous( int RequestId ) ; - bool MPICompleted( int RequestId ) ; - MPI_Datatype MPIDatatype( int RequestId ) ; - int MPIOutCount( int RequestId ) ; - - private: - int newRequest( MPI_Datatype datatype, int tag , int destsourcerank , - bool fromsourcerank , bool asynchronous ) ; - int newSendTag( MPI_Datatype datatype, int destrank , int method , - bool asynchronous, int &RequestId ) ; - int newRecvTag( MPI_Datatype datatype, int sourcerank , int method , - bool asynchronous, int &RequestId ) ; - int incrTag( int prevtag ) ; - int valTag( int tag, int method ) ; - - void deleteSendRecvRequest( int RequestId ) ; - - void deleteStatus( int RequestId ) ; - - MPI_Request *MPIRequest( int RequestId ) ; - MPI_Status *MPIStatus( int RequestId ) ; - void setMPICompleted( int RequestId , bool completed ) ; - void setMPIOutCount( int RequestId , int outcount ) ; - void clearMPIStatus( int RequestId ) ; - - _MessageIdent methodId( MPI_Datatype datatype ) const ; - MPI_Datatype datatype( _MessageIdent aMethodIdent ) const ; - private: - const CommInterface &_comm_interface ; - const MPI_Comm* _intra_communicator ; - MPIProcessorGroup * _processor_group ; - int _processor_group_size ; - int _my_rank ; - bool _trace ; - int _base_request ; - int _max_request ; - int _request ; - int * _send_request ; - int * _recv_request ; - std::vector< std::list< int > > _send_requests ; - std::vector< std::list< int > > _recv_requests ; - int _base_MPI_tag ; - int _max_MPI_tag ; - int * _send_MPI_tag ; - int * _recv_MPI_Tag ; - MPI_Datatype _MPI_TIME ; - static const int MODULO_TAG=10; - std::map< int , RequestStruct * > _map_of_request_struct ; - - }; - - inline void MPIAccess::trace( bool trace ) - { - _trace = trace ; - } - - // Delete the structure Request corresponding to RequestId identifier after - // the deletion of the structures MPI_Request * and MPI_Status * - // remove it from _MapOfRequestStruct (erase) - inline void MPIAccess::deleteRequest( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - { - if ( _trace ) - std::cout << "MPIAccess::DeleteRequest" << _my_rank << "( " << RequestId << " ) " - << aRequestStruct << " MPIRequest " << aRequestStruct->MPIRequest - << " MPIIsRecv " << aRequestStruct->MPIIsRecv << std::endl ; - if ( _map_of_request_struct[RequestId]->MPIRequest != MPI_REQUEST_NULL ) - requestFree( &_map_of_request_struct[RequestId]->MPIRequest ) ; - deleteSendRecvRequest( RequestId ) ; - deleteStatus( RequestId ) ; - _map_of_request_struct.erase( RequestId ) ; - delete aRequestStruct ; - } - else - { - if ( _trace ) - std::cout << "MPIAccess::DeleteRequest" << _my_rank << "( " << RequestId - << " ) Request not found" << std::endl ; - } - } - - // Delete all requests of the array ArrayOfSendRequests - inline void MPIAccess::deleteRequests(int size , int *ArrayOfSendRequests ) - { - for (int i = 0 ; i < size ; i++ ) - deleteRequest( ArrayOfSendRequests[i] ) ; - } - - // Returns the last MPITag of the destination rank destrank - inline int MPIAccess::sendMPITag(int destrank) - { - return _send_MPI_tag[destrank] ; - } - - // Returns the last MPITag of the source rank sourcerank - inline int MPIAccess::recvMPITag(int sourcerank) - { - return _recv_MPI_Tag[sourcerank] ; - } - - // Returns the number of all SendRequestIds matching a destination rank. It may be - // used to allocate ArrayOfSendRequests for the call to SendRequestIds - inline int MPIAccess::sendRequestIdsSize(int destrank) - { - return _send_requests[destrank].size() ; - } - - // Returns the number of all RecvRequestIds matching a source rank. It may be - // used to allocate ArrayOfRecvRequests for the call to RecvRequestIds - inline int MPIAccess::recvRequestIdsSize(int sourcerank) - { - return _recv_requests[sourcerank].size() ; - } - - // Returns the MPI_Datatype (registered in MPI in the constructor with - // MPI_Type_struct and MPI_Type_commit) for TimeMessages - inline MPI_Datatype MPIAccess::timeType() const - { - return _MPI_TIME ; - } - - // Returns true if the tag MPITag corresponds to a TimeMessage - inline bool MPIAccess::isTimeMessage( int MPITag ) const - { - return ((MPITag%MODULO_TAG) == _message_time) ; - } - - // Returns the MPI size of a TimeMessage - inline MPI_Aint MPIAccess::timeExtent() const - { - MPI_Aint extent ; - MPI_Type_extent( _MPI_TIME , &extent ) ; - return extent ; - } - - // Returns the MPI size of a MPI_INT - inline MPI_Aint MPIAccess::intExtent() const - { - MPI_Aint extent ; - MPI_Type_extent( MPI_INT , &extent ) ; - return extent ; - } - - // Returns the MPI size of a MPI_DOUBLE - inline MPI_Aint MPIAccess::doubleExtent() const - { - MPI_Aint extent ; - MPI_Type_extent( MPI_DOUBLE , &extent ) ; - return extent ; - } - - // Returns the MPI size of the MPI_Datatype datatype - inline MPI_Aint MPIAccess::extent( MPI_Datatype datatype ) const - { - if ( datatype == _MPI_TIME ) - return timeExtent() ; - if ( datatype == MPI_INT ) - return intExtent() ; - if ( datatype == MPI_DOUBLE ) - return doubleExtent() ; - return 0 ; - } - - // Returns the MPITag of the request corresponding to RequestId identifier - inline int MPIAccess::MPITag( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return aRequestStruct->MPITag ; - return -1 ; - } - - // Returns the MPITarget of the request corresponding to RequestId identifier - inline int MPIAccess::MPITarget( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return aRequestStruct->MPITarget ; - return -1 ; - } - - // Returns true if the request corresponding to RequestId identifier was [I]Recv - inline bool MPIAccess::MPIIsRecv( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return aRequestStruct->MPIIsRecv ; - return false ; - } - - // Returns true if the request corresponding to RequestId identifier was asynchronous - inline bool MPIAccess::MPIAsynchronous( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return aRequestStruct->MPIAsynchronous ; - return false ; - } - - // Returns true if the request corresponding to RequestId identifier was completed - inline bool MPIAccess::MPICompleted( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return aRequestStruct->MPICompleted; - return true ; - } - - // Returns the MPI_datatype of the request corresponding to RequestId identifier - inline MPI_Datatype MPIAccess::MPIDatatype( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return aRequestStruct->MPIDatatype; - return (MPI_Datatype ) NULL ; - } - - // Returns the size of the receiving message of the request corresponding to - // RequestId identifier - inline int MPIAccess::MPIOutCount( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return aRequestStruct->MPIOutCount; - return 0 ; - } - - // Increments the previous tag value (cyclically) - // Look at MPIAccess::NewSendTag/NewRecvTag in MPIAccess.cxx - inline int MPIAccess::incrTag( int prevtag ) - { - int tag; - if ( (prevtag % MODULO_TAG) == _message_time ) - tag = ((prevtag/MODULO_TAG)*MODULO_TAG); - else - tag = ((prevtag/MODULO_TAG + 1)*MODULO_TAG); - if ( tag > _max_MPI_tag ) - tag = _base_MPI_tag ; - return tag ; - } - - // Returns the MPITag with the method-type field - // Look at MPIAccess::NewSendTag/NewRecvTag in MPIAccess.cxx - inline int MPIAccess::valTag( int tag, int method ) - { - return ((tag/MODULO_TAG)*MODULO_TAG) + method; - } - - // Remove a Request identifier from the list _RecvRequests/_SendRequests for - // the corresponding target. - inline void MPIAccess::deleteSendRecvRequest( int RequestId ) - { - if ( _trace ) - std::cout << "MPIAccess::DeleteSendRecvRequest" << _my_rank - << "( " << RequestId << " ) " << std::endl ; - if ( MPIIsRecv( RequestId ) ) - _recv_requests[ MPITarget( RequestId ) ].remove( RequestId ); - else - _send_requests[ MPITarget( RequestId ) ].remove( RequestId ); - } - - // Delete the MPI structure MPI_status * of a ReaquestId - inline void MPIAccess::deleteStatus( int RequestId ) - { - if ( _map_of_request_struct[RequestId]->MPIStatus != NULL ) - { - delete _map_of_request_struct[RequestId]->MPIStatus ; - clearMPIStatus( RequestId ) ; - } - } - - // Returns the MPI structure MPI_request * of a RequestId - inline MPI_Request * MPIAccess::MPIRequest( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - return &aRequestStruct->MPIRequest; - return &mpirequestnull ; - } - - // Returns the MPI structure MPI_status * of a RequestId - inline MPI_Status * MPIAccess::MPIStatus( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ]; - if ( aRequestStruct ) - return aRequestStruct->MPIStatus; - return NULL ; - } - - // Set the MPICompleted field of the structure Request corresponding to RequestId - // identifier with the value completed - inline void MPIAccess::setMPICompleted( int RequestId , bool completed ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - aRequestStruct->MPICompleted = completed; - } - - // Set the MPIOutCount field of the structure Request corresponding to RequestId - // identifier with the value outcount - inline void MPIAccess::setMPIOutCount( int RequestId , int outcount ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - aRequestStruct->MPIOutCount = outcount; - } - - // Nullify the MPIStatusfield of the structure Request corresponding to RequestId - // identifier - inline void MPIAccess::clearMPIStatus( int RequestId ) - { - struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ] ; - if ( aRequestStruct ) - aRequestStruct->MPIStatus = NULL ; - } - - // Returns the _MessageIdent enum value corresponding to the MPI_Datatype datatype - // Look at MPIAccess::NewSendTag/NewRecvTag in MPIAccess.cxx - inline _MessageIdent MPIAccess::methodId( MPI_Datatype datatype ) const - { - _MessageIdent aMethodIdent ; - if ( datatype == _MPI_TIME ) - aMethodIdent = _message_time; - else if ( datatype == MPI_INT ) - aMethodIdent = _message_int ; - else if ( datatype == MPI_DOUBLE ) - aMethodIdent = _message_double ; - else - aMethodIdent = _message_unknown ; - return aMethodIdent ; - } - - // Returns the MPI_Datatype corresponding to the _MessageIdent enum aMethodIdent - inline MPI_Datatype MPIAccess::datatype( _MessageIdent aMethodIdent ) const - { - MPI_Datatype aDataType ; - switch( aMethodIdent ) - { - case _message_time : - aDataType = _MPI_TIME ; - break ; - case _message_int : - aDataType = MPI_INT ; - break ; - case _message_double : - aDataType = MPI_DOUBLE ; - break ; - default : - aDataType = (MPI_Datatype) -1 ; - break ; - } - return aDataType ; - } - - std::ostream & operator<< (std::ostream &,const _MessageIdent &); - - std::ostream & operator<< (std::ostream &,const TimeMessage &); - -} - -#endif diff --git a/src/ParaMEDMEM/MPIAccessDEC.cxx b/src/ParaMEDMEM/MPIAccessDEC.cxx deleted file mode 100644 index ea5cdf0d3..000000000 --- a/src/ParaMEDMEM/MPIAccessDEC.cxx +++ /dev/null @@ -1,1054 +0,0 @@ -// Copyright (C) 2007-2010 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 "MPIAccessDEC.hxx" - -#include - -using namespace std; - -namespace ParaMEDMEM -{ - - /*! - This constructor creates an MPIAccessDEC which has \a source_group as a working side - and \a target_group as an idle side. - The constructor must be called synchronously on all processors of both processor groups. - - \param source_group working side ProcessorGroup - \param target_group lazy side ProcessorGroup - \param Asynchronous Communication mode (default asynchronous) - \param nStepBefore Number of Time step needed for the interpolation before current time - \param nStepAfter Number of Time step needed for the interpolation after current time - - */ - - MPIAccessDEC::MPIAccessDEC( const ProcessorGroup& source_group, - const ProcessorGroup& target_group, - bool Asynchronous ) - { - - ProcessorGroup * union_group = source_group.fuse(target_group) ; - int i ; - std::set procs; - for ( i = 0 ; i < union_group->size() ; i++ ) - { - procs.insert(i) ; - } - MPIProcessorGroup *mpilg = (MPIProcessorGroup *)&source_group; - _MPI_union_group = new ParaMEDMEM::MPIProcessorGroup( union_group->getCommInterface(),procs,mpilg->getWorldComm()); - delete union_group ; - _my_rank = _MPI_union_group->myRank() ; - _group_size = _MPI_union_group->size() ; - _MPI_access = new MPIAccess( _MPI_union_group ) ; - _asynchronous = Asynchronous ; - _time_messages = new vector< vector< TimeMessage > > ; - _time_messages->resize( _group_size ) ; - _out_of_time = new vector< bool > ; - _out_of_time->resize( _group_size ) ; - _data_messages_recv_count = new vector< int > ; - _data_messages_recv_count->resize( _group_size ) ; - for ( i = 0 ; i < _group_size ; i++ ) - { - (*_out_of_time)[i] = false ; - (*_data_messages_recv_count)[i] = 0 ; - } - _data_messages_type = new vector< MPI_Datatype > ; - _data_messages_type->resize( _group_size ) ; - _data_messages = new vector< vector< void * > > ; - _data_messages->resize( _group_size ) ; - _time_interpolator = NULL ; - _map_of_send_buffers = new map< int , SendBuffStruct * > ; - } - - MPIAccessDEC::~MPIAccessDEC() - { - checkFinalSent() ; - checkFinalRecv() ; - delete _MPI_union_group ; - delete _MPI_access ; - if ( _time_interpolator ) - delete _time_interpolator ; - if ( _time_messages ) - delete _time_messages ; - if ( _out_of_time ) - delete _out_of_time ; - if ( _data_messages_recv_count ) - delete _data_messages_recv_count ; - if ( _data_messages_type ) - delete _data_messages_type ; - if ( _data_messages ) - delete _data_messages ; - if ( _map_of_send_buffers ) - delete _map_of_send_buffers ; - } - - void MPIAccessDEC::setTimeInterpolator( TimeInterpolationMethod aTimeInterp , - double InterpPrecision, int nStepBefore, - int nStepAfter ) - { - if ( _time_interpolator ) - delete _time_interpolator ; - switch ( aTimeInterp ) - { - case WithoutTimeInterp : - _time_interpolator = NULL ; - _n_step_before = 0 ; - _n_step_after = 0 ; - break ; - case LinearTimeInterp : - _time_interpolator = new LinearTimeInterpolator( InterpPrecision , nStepBefore , - nStepAfter ) ; - _n_step_before = nStepBefore ; - _n_step_after = nStepAfter ; - int i ; - for ( i = 0 ; i < _group_size ; i++ ) - { - (*_time_messages)[ i ].resize( _n_step_before + _n_step_after ) ; - (*_data_messages)[ i ].resize( _n_step_before + _n_step_after ) ; - int j ; - for ( j = 0 ; j < _n_step_before + _n_step_after ; j++ ) - { - (*_time_messages)[ i ][ j ].time = -1 ; - (*_time_messages)[ i ][ j ].deltatime = -1 ; - (*_data_messages)[ i ][ j ] = NULL ; - } - } - break ; - } - } - - /*! - Send sendcount datas from sendbuf[offset] with type sendtype to target of IntraCommunicator - (Internal Protected method) - - Returns the request identifier SendRequestId - - */ - int MPIAccessDEC::send( void* sendbuf, int sendcount , int offset , - MPI_Datatype sendtype , int target , int &SendRequestId ) - { - int sts ; - if ( _asynchronous ) - { - if ( sendtype == MPI_INT ) - { - sts = _MPI_access->ISend( &((int *) sendbuf)[offset] , sendcount , sendtype , - target , SendRequestId ) ; - } - else - { - sts = _MPI_access->ISend( &((double *) sendbuf)[offset] , sendcount , sendtype , - target , SendRequestId ) ; - } - } - else - { - if ( sendtype == MPI_INT ) - { - sts = _MPI_access->send( &((int *) sendbuf)[offset] , sendcount , sendtype , - target , SendRequestId ) ; - } - else - { - sts = _MPI_access->send( &((double *) sendbuf)[offset] , sendcount , sendtype , - target , SendRequestId ) ; - } - } - return sts ; - } - - /*! - Receive recvcount datas to recvbuf[offset] with type recvtype from target of IntraCommunicator - (Internal Protected method) - - Returns the request identifier RecvRequestId - - */ - int MPIAccessDEC::recv( void* recvbuf, int recvcount , int offset , - MPI_Datatype recvtype , int target , int &RecvRequestId ) - { - int sts ; - if ( _asynchronous ) - { - if ( recvtype == MPI_INT ) - { - sts = _MPI_access->IRecv( &((int *) recvbuf)[offset] , recvcount , recvtype , - target , RecvRequestId ) ; - } - else - { - sts = _MPI_access->IRecv( &((double *) recvbuf)[offset] , recvcount , recvtype , - target , RecvRequestId ) ; - } - } - else - { - if ( recvtype == MPI_INT ) - { - sts = _MPI_access->recv( &((int *) recvbuf)[offset] , recvcount , recvtype , - target , RecvRequestId ) ; - } - else - { - sts = _MPI_access->recv( &((double *) recvbuf)[offset] , recvcount , recvtype , - target , RecvRequestId ) ; - } - } - return sts ; - } - - /*! - Send sendcount datas from sendbuf[offset] with type sendtype to target of IntraCommunicator - Receive recvcount datas to recvbuf[offset] with type recvtype from target of IntraCommunicator - (Internal Protected method) - - Returns the request identifier SendRequestId - Returns the request identifier RecvRequestId - - */ - int MPIAccessDEC::sendRecv( void* sendbuf, int sendcount , int sendoffset , - MPI_Datatype sendtype , - void* recvbuf, int recvcount , int recvoffset , - MPI_Datatype recvtype , int target , - int &SendRequestId , int &RecvRequestId ) - { - int sts ; - if ( _asynchronous ) - { - if ( sendtype == MPI_INT ) - { - if ( recvtype == MPI_INT ) - { - sts = _MPI_access->ISendRecv( &((int *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((int *) recvbuf)[recvoffset] , recvcount , - recvtype , target , RecvRequestId ) ; - } - else - { - sts = _MPI_access->ISendRecv( &((int *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((double *) recvbuf)[recvoffset] , - recvcount , recvtype , target , RecvRequestId ) ; - } - } - else - { - if ( recvtype == MPI_INT ) - { - sts = _MPI_access->ISendRecv( &((double *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((int *) recvbuf)[recvoffset] , - recvcount , recvtype , target , RecvRequestId ) ; - } - else - { - sts = _MPI_access->ISendRecv( &((double *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((double *) recvbuf)[recvoffset] , - recvcount , recvtype , target , RecvRequestId ) ; - } - } - } - else - { - if ( sendtype == MPI_INT ) - { - if ( recvtype == MPI_INT ) - { - sts = _MPI_access->sendRecv( &((int *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((int *) recvbuf)[recvoffset] , recvcount , - recvtype , target , RecvRequestId ) ; - } - else - { - sts = _MPI_access->sendRecv( &((int *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((double *) recvbuf)[recvoffset] , - recvcount , recvtype , target , RecvRequestId ) ; - } - } - else - { - if ( recvtype == MPI_INT ) - { - sts = _MPI_access->sendRecv( &((double *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((int *) recvbuf)[recvoffset] , - recvcount , recvtype , target , RecvRequestId ) ; - } - else - { - sts = _MPI_access->sendRecv( &((double *) sendbuf)[sendoffset] , sendcount , - sendtype , target , SendRequestId , - &((double *) recvbuf)[recvoffset] , - recvcount , recvtype , target , RecvRequestId ) ; - } - } - } - return sts ; - } - - /*! - Send sendcount datas from sendbuf[offset] with type sendtype to all targets of IntraCommunicator - Receive recvcount datas to recvbuf[offset] with type recvtype from all targets of IntraCommunicator - - */ - int MPIAccessDEC::allToAll( void* sendbuf, int sendcount, MPI_Datatype sendtype , - void* recvbuf, int recvcount, MPI_Datatype recvtype ) - { - if ( _time_interpolator ) - { - return allToAllTime( sendbuf, sendcount, sendtype , recvbuf, recvcount, recvtype ) ; - } - int sts ; - int target ; - int sendoffset = 0 ; - int recvoffset = 0 ; - int SendRequestId ; - int RecvRequestId ; - - //Free of SendBuffers - if ( _asynchronous ) - checkSent() ; - - //DoSend + DoRecv : SendRecv - SendBuffStruct * aSendDataStruct = NULL ; - if ( _asynchronous && sendbuf ) - { - aSendDataStruct = new SendBuffStruct ; - aSendDataStruct->SendBuffer = sendbuf ; - aSendDataStruct->Counter = 0 ; - aSendDataStruct->DataType = sendtype ; - } - for ( target = 0 ; target < _group_size ; target++ ) - { - sts = sendRecv( sendbuf , sendcount , sendoffset , sendtype , - recvbuf , recvcount , recvoffset , recvtype , - target , SendRequestId , RecvRequestId ) ; - if ( _asynchronous && sendbuf && sendcount ) - { - aSendDataStruct->Counter += 1 ; - (*_map_of_send_buffers)[ SendRequestId ] = aSendDataStruct ; - } - sendoffset += sendcount ; - recvoffset += recvcount ; - } - if ( !_asynchronous && sendbuf ) - { - if ( sendtype == MPI_INT ) - { - delete [] (int *) sendbuf ; - } - else - { - delete [] (double *) sendbuf ; - } - } - return sts ; - } - - /*! - Send sendcounts[target] datas from sendbuf[sdispls[target]] with type sendtype to all targets of IntraCommunicator - Receive recvcounts[target] datas to recvbuf[rdispls[target]] with type recvtype from all targets of IntraCommunicator - - */ - int MPIAccessDEC::allToAllv( void* sendbuf, int* sendcounts, int* sdispls, - MPI_Datatype sendtype , - void* recvbuf, int* recvcounts, int* rdispls, - MPI_Datatype recvtype ) - { - if ( _time_interpolator ) - { - return allToAllvTime( sendbuf, sendcounts, sdispls, sendtype , - recvbuf, recvcounts, rdispls, recvtype ) ; - } - int sts ; - int target ; - int SendRequestId ; - int RecvRequestId ; - - //Free of SendBuffers - if ( _asynchronous ) - { - checkSent() ; - } - - //DoSend + DoRecv : SendRecv - SendBuffStruct * aSendDataStruct = NULL ; - if ( _asynchronous && sendbuf ) - { - aSendDataStruct = new SendBuffStruct ; - aSendDataStruct->SendBuffer = sendbuf ; - aSendDataStruct->Counter = 0 ; - aSendDataStruct->DataType = sendtype ; - } - for ( target = 0 ; target < _group_size ; target++ ) - { - if ( sendcounts[target] || recvcounts[target] ) - { - sts = sendRecv( sendbuf , sendcounts[target] , sdispls[target] , sendtype , - recvbuf , recvcounts[target] , rdispls[target] , recvtype , - target , SendRequestId , RecvRequestId ) ; - if ( _asynchronous && sendbuf && sendcounts[target]) - { - aSendDataStruct->Counter += 1 ; - (*_map_of_send_buffers)[ SendRequestId ] = aSendDataStruct ; - } - } - } - if ( !_asynchronous && sendbuf ) - { - if ( sendtype == MPI_INT ) - { - delete [] (int *) sendbuf ; - } - else - { - delete [] (double *) sendbuf ; - } - } - return sts ; - } - - /* - MPIAccessDEC and the management of SendBuffers : - ================================================= - - . In the collective communications collectives we send only parts of - the same buffer to each "target". So in asynchronous mode it is - necessary that all parts are free before to delete/free the - buffer. - - . We assume that buffers are allocated with a new double[]. so a - delete [] is done. - - . The structure SendBuffStruct permit to keep the adress of the buffer - and to manage a reference counter of that buffer. It contains - also MPI_Datatype for the delete [] (double *) ... when the counter - is null. - - . The map _MapOfSendBuffers etablish the correspondance between each - RequestId given by a MPI_Access->ISend(...) and a SendBuffStruct - for each "target" of a part of the buffer. - - . All that concerns only asynchronous Send. In synchronous mode, - we delete senbuf just after the Send. - */ - - /* - MPIAccessDEC and the management of RecvBuffers : - ================================================= - - If there is no interpolation, no special action is done. - - With interpolation for each target : - ------------------------------------ - . We have _time_messages[target] which is a vector of TimesMessages. - We have 2 TimesMessages in our case with a linear interpolation. - They contain the previous time(t0)/deltatime and the last - time(t1)/deltatime. - - . We have _data_messages[target] which is a vector of DatasMessages. - We have 2 DatasMessages in our case with a linear interpolation. - They contain the previous datas at time(t0)/deltatime and at last - time(t1)/deltatime. - - . At time _t(t*) of current processus we do the interpolation of - the values of the 2 DatasMessages which are returned in the part of - recvbuf corresponding to the target with t0 < t* <= t1. - - . Because of the difference of "deltatimes" between processes, we - may have t0 < t1 < t* and there is an extrapolation. - - . The vectors _out_of_time, _DataMessagesRecvCount and _DataMessagesType - contain for each target true if t* > last t1, recvcount and - MPI_Datatype for the finalize of messages at the end. - */ - - /*! - Send a TimeMessage to all targets of IntraCommunicator - Receive the TimeMessages from targets of IntraCommunicator if necessary. - - Send sendcount datas from sendbuf[offset] with type sendtype to all targets of IntraCommunicator - Returns recvcount datas to recvbuf[offset] with type recvtype after an interpolation - with datas received from all targets of IntraCommunicator. - - */ - int MPIAccessDEC::allToAllTime( void* sendbuf, int sendcount , MPI_Datatype sendtype , - void* recvbuf, int recvcount , MPI_Datatype recvtype ) - { - int sts ; - int target ; - int sendoffset = 0 ; - int SendTimeRequestId ; - int SendDataRequestId ; - - if ( _time_interpolator == NULL ) - { - return MPI_ERR_OTHER ; - } - - //Free of SendBuffers - if ( _asynchronous ) - { - checkSent() ; - } - - //DoSend : Time + SendBuff - SendBuffStruct * aSendTimeStruct = NULL ; - SendBuffStruct * aSendDataStruct = NULL ; - if ( sendbuf && sendcount ) - { - TimeMessage * aSendTimeMessage = new TimeMessage ; - if ( _asynchronous ) - { - aSendTimeStruct = new SendBuffStruct ; - aSendTimeStruct->SendBuffer = aSendTimeMessage ; - aSendTimeStruct->Counter = 0 ; - aSendTimeStruct->DataType = _MPI_access->timeType() ; - aSendDataStruct = new SendBuffStruct ; - aSendDataStruct->SendBuffer = sendbuf ; - aSendDataStruct->Counter = 0 ; - aSendDataStruct->DataType = sendtype ; - } - aSendTimeMessage->time = _t ; - aSendTimeMessage->deltatime = _dt ; - for ( target = 0 ; target < _group_size ; target++ ) - { - sts = send( aSendTimeMessage , 1 , 0 , _MPI_access->timeType() , target , - SendTimeRequestId ) ; - sts = send( sendbuf , sendcount , sendoffset , sendtype , target , SendDataRequestId ) ; - if ( _asynchronous ) - { - aSendTimeStruct->Counter += 1 ; - (*_map_of_send_buffers)[ SendTimeRequestId ] = aSendTimeStruct ; - aSendDataStruct->Counter += 1 ; - (*_map_of_send_buffers)[ SendDataRequestId ] = aSendDataStruct ; - } - sendoffset += sendcount ; - } - if ( !_asynchronous ) - { - delete aSendTimeMessage ; - if ( sendtype == MPI_INT ) - { - delete [] (int *) sendbuf ; - } - else - { - delete [] (double *) sendbuf ; - } - } - } - - //CheckTime + DoRecv + DoInterp - if ( recvbuf && recvcount ) - { - for ( target = 0 ; target < _group_size ; target++ ) - { - int recvsize = recvcount*_MPI_access->extent( recvtype ) ; - checkTime( recvcount , recvtype , target , false ) ; - //=========================================================================== - //TODO : it is assumed actually that we have only 1 timestep before nad after - //=========================================================================== - if ( _time_interpolator && (*_time_messages)[target][0].time != -1 ) - { - if ( (*_out_of_time)[target] ) - { - cout << " =====================================================" << endl - << "Recv" << _my_rank << " <-- target " << target << " t0 " - << (*_time_messages)[target][0].time << " < t1 " - << (*_time_messages)[target][1].time << " < t* " << _t << endl - << " =====================================================" << endl ; - } - if ( recvtype == MPI_INT ) - { - _time_interpolator->doInterp( (*_time_messages)[target][0].time, - (*_time_messages)[target][1].time, _t, recvcount , - _n_step_before, _n_step_after, - (int **) &(*_data_messages)[target][0], - (int **) &(*_data_messages)[target][1], - &((int *)recvbuf)[target*recvcount] ) ; - } - else - { - _time_interpolator->doInterp( (*_time_messages)[target][0].time, - (*_time_messages)[target][1].time, _t, recvcount , - _n_step_before, _n_step_after, - (double **) &(*_data_messages)[target][0], - (double **) &(*_data_messages)[target][1], - &((double *)recvbuf)[target*recvcount] ) ; - } - } - else - { - char * buffdest = (char *) recvbuf ; - char * buffsrc = (char *) (*_data_messages)[target][1] ; - memcpy( &buffdest[target*recvsize] , buffsrc , recvsize ) ; - } - } - } - - return sts ; - } - - int MPIAccessDEC::allToAllvTime( void* sendbuf, int* sendcounts, int* sdispls, - MPI_Datatype sendtype , - void* recvbuf, int* recvcounts, int* rdispls, - MPI_Datatype recvtype ) - { - int sts ; - int target ; - int SendTimeRequestId ; - int SendDataRequestId ; - - if ( _time_interpolator == NULL ) - { - return MPI_ERR_OTHER ; - } - - //Free of SendBuffers - if ( _asynchronous ) - { - checkSent() ; - } - - /* - . DoSend : - + We create a TimeMessage (look at that structure in MPI_Access). - + If we are in asynchronous mode, we create two structures SendBuffStruct - aSendTimeStruct and aSendDataStruct that we fill. - + We fill the structure aSendTimeMessage with time/deltatime of - the current process. "deltatime" must be nul if it is the last step of - Time. - + After that for each "target", we Send the TimeMessage and the part - of sendbuf corresponding to that target. - + If we are in asynchronous mode, we increment the counter and we add - aSendTimeStruct and aSendDataStruct to _MapOfSendBuffers with the - identifiers SendTimeRequestId and SendDataRequestId returned by - MPI_Access->Send(...). - + And if we are in synchronous mode we delete the SendMessages. - */ - //DoSend : Time + SendBuff - SendBuffStruct * aSendTimeStruct = NULL ; - SendBuffStruct * aSendDataStruct = NULL ; - if ( sendbuf ) - { - TimeMessage * aSendTimeMessage = new TimeMessage ; - if ( _asynchronous ) - { - aSendTimeStruct = new SendBuffStruct ; - aSendTimeStruct->SendBuffer = aSendTimeMessage ; - aSendTimeStruct->Counter = 0 ; - aSendTimeStruct->DataType = _MPI_access->timeType() ; - aSendDataStruct = new SendBuffStruct ; - aSendDataStruct->SendBuffer = sendbuf ; - aSendDataStruct->Counter = 0 ; - aSendDataStruct->DataType = sendtype ; - } - aSendTimeMessage->time = _t ; - aSendTimeMessage->deltatime = _dt ; - for ( target = 0 ; target < _group_size ; target++ ) - { - if ( sendcounts[target] ) - { - sts = send( aSendTimeMessage , 1 , 0 , _MPI_access->timeType() , target , - SendTimeRequestId ) ; - sts = send( sendbuf , sendcounts[target] , sdispls[target] , sendtype , target , - SendDataRequestId ) ; - if ( _asynchronous ) - { - aSendTimeStruct->Counter += 1 ; - (*_map_of_send_buffers)[ SendTimeRequestId ] = aSendTimeStruct ; - aSendDataStruct->Counter += 1 ; - (*_map_of_send_buffers)[ SendDataRequestId ] = aSendDataStruct ; - } - } - } - if ( !_asynchronous ) - { - delete aSendTimeMessage ; - if ( sendtype == MPI_INT ) - { - delete [] (int *) sendbuf ; - } - else - { - delete [] (double *) sendbuf ; - } - } - } - - /* - . CheckTime + DoRecv + DoInterp - + For each target we call CheckTime - + If there is a TimeInterpolator and if the TimeMessage of the target - is not the first, we call the interpolator which return its - results in the part of the recv buffer corresponding to the "target". - + If not, there is a copy of received datas for that first step of time - in the part of the recv buffer corresponding to the "target". - */ - //CheckTime + DoRecv + DoInterp - if ( recvbuf ) - { - for ( target = 0 ; target < _group_size ; target++ ) - { - if ( recvcounts[target] ) - { - int recvsize = recvcounts[target]*_MPI_access->extent( recvtype ) ; - checkTime( recvcounts[target] , recvtype , target , false ) ; - //=========================================================================== - //TODO : it is assumed actually that we have only 1 timestep before nad after - //=========================================================================== - if ( _time_interpolator && (*_time_messages)[target][0].time != -1 ) - { - if ( (*_out_of_time)[target] ) - { - cout << " =====================================================" << endl - << "Recv" << _my_rank << " <-- target " << target << " t0 " - << (*_time_messages)[target][0].time << " < t1 " - << (*_time_messages)[target][1].time << " < t* " << _t << endl - << " =====================================================" << endl ; - } - if ( recvtype == MPI_INT ) - { - _time_interpolator->doInterp( (*_time_messages)[target][0].time, - (*_time_messages)[target][1].time, _t, - recvcounts[target] , _n_step_before, _n_step_after, - (int **) &(*_data_messages)[target][0], - (int **) &(*_data_messages)[target][1], - &((int *)recvbuf)[rdispls[target]] ) ; - } - else - { - _time_interpolator->doInterp( (*_time_messages)[target][0].time, - (*_time_messages)[target][1].time, _t, - recvcounts[target] , _n_step_before, _n_step_after, - (double **) &(*_data_messages)[target][0], - (double **) &(*_data_messages)[target][1], - &((double *)recvbuf)[rdispls[target]] ) ; - } - } - else - { - char * buffdest = (char *) recvbuf ; - char * buffsrc = (char *) (*_data_messages)[target][1] ; - memcpy( &buffdest[rdispls[target]*_MPI_access->extent( recvtype )] , buffsrc , - recvsize ) ; - } - } - } - } - - return sts ; - } - - /* - . CheckTime(recvcount , recvtype , target , UntilEnd) - + At the beginning, we read the first TimeMessage in - &(*_TimeMessages)[target][1] and the first DataMessage - in the allocated buffer (*_DataMessages)[target][1]. - + deltatime of TimesMessages must be nul if it is the last one. - + While : _t(t*) is the current time of the processus. - "while _t(t*) is greater than the time of the "target" - (*_TimeMessages)[target][1].time and - (*_TimeMessages)[target][1].deltatime is not nul", - So at the end of the while we have : - _t(t*) <= (*_TimeMessages)[target][1].time with - _t(t*) > (*_TimeMessages)[target][0].time - or we have the last TimeMessage of the "target". - + If it is the finalization of the recv of TimeMessages and - DataMessages (UntilEnd value is true), we execute the while - until (*_TimeMessages)[target][1].deltatime is nul. - + In the while : - We copy the last TimeMessage in the previoud TimeMessage and - we read a new TimeMessage - We delete the previous DataMessage. - We copy the last DataMessage pointer in the previous one. - We allocate a new last DataMessage buffer - (*_DataMessages)[target][1] and we read the corresponding - datas in that buffe. - + If the current time of the current process is greater than the - last time (*_TimeMessages)[target][1].time du target, we give - a true value to (*_OutOfTime)[target]. - (*_TimeMessages)[target][1].deltatime is nul. - */ - int MPIAccessDEC::checkTime( int recvcount , MPI_Datatype recvtype , int target , - bool UntilEnd ) - { - int sts = MPI_SUCCESS ; - int RecvTimeRequestId ; - int RecvDataRequestId ; - //Pour l'instant on cherche _time_messages[target][0] < _t <= _time_messages[target][1] - //=========================================================================== - //TODO : it is assumed actually that we have only 1 timestep before and after - // instead of _n_step_before and _n_step_after ... - //=========================================================================== - (*_data_messages_recv_count)[target] = recvcount ; - (*_data_messages_type)[target] = recvtype ; - if ( (*_time_messages)[target][1].time == -1 ) - { - (*_time_messages)[target][0] = (*_time_messages)[target][1] ; - sts = recv( &(*_time_messages)[target][1] , 1 , _MPI_access->timeType() , - target , RecvTimeRequestId ) ; - (*_data_messages)[target][0] = (*_data_messages)[target][1] ; - if ( recvtype == MPI_INT ) - { - (*_data_messages)[target][1] = new int[recvcount] ; - } - else - { - (*_data_messages)[target][1] = new double[recvcount] ; - } - sts = recv( (*_data_messages)[target][1] , recvcount , recvtype , target , - RecvDataRequestId ) ; - } - else - { - while ( ( _t > (*_time_messages)[target][1].time || UntilEnd ) && - (*_time_messages)[target][1].deltatime != 0 ) - { - (*_time_messages)[target][0] = (*_time_messages)[target][1] ; - sts = recv( &(*_time_messages)[target][1] , 1 , _MPI_access->timeType() , - target , RecvTimeRequestId ) ; - if ( UntilEnd ) - { - cout << "CheckTime" << _my_rank << " TimeMessage target " << target - << " RecvTimeRequestId " << RecvTimeRequestId << " MPITag " - << _MPI_access->recvMPITag(target) << endl ; - } - if ( recvtype == MPI_INT ) - { - delete [] (int *) (*_data_messages)[target][0] ; - } - else - { - delete [] (double *) (*_data_messages)[target][0] ; - } - (*_data_messages)[target][0] = (*_data_messages)[target][1] ; - if ( recvtype == MPI_INT ) - { - (*_data_messages)[target][1] = new int[recvcount] ; - } - else - { - (*_data_messages)[target][1] = new double[recvcount] ; - } - sts = recv( (*_data_messages)[target][1] , recvcount , recvtype , target , - RecvDataRequestId ) ; - if ( UntilEnd ) - { - cout << "CheckTime" << _my_rank << " DataMessage target " << target - << " RecvDataRequestId " << RecvDataRequestId << " MPITag " - << _MPI_access->recvMPITag(target) << endl ; - } - } - - if ( _t > (*_time_messages)[target][0].time && - _t <= (*_time_messages)[target][1].time ) - { - } - else - { - (*_out_of_time)[target] = true ; - } - } - return sts ; - } - - /* - . CheckSent() : - + call SendRequestIds of MPI_Access in order to get all - RequestIds of SendMessages of all "targets". - + For each RequestId, CheckSent call "Test" of MPI_Access in order - to know if the buffer is "free" (flag = true). If it is the - FinalCheckSent (WithWait = true), we call Wait instead of Test. - + If the buffer is "free", the counter of the structure SendBuffStruct - (from _MapOfSendBuffers) is decremented. - + If that counter is nul we delete the TimeMessage or the - SendBuffer according to the DataType. - + And we delete the structure SendBuffStruct before the suppression - (erase) of that item of _MapOfSendBuffers - */ - int MPIAccessDEC::checkSent(bool WithWait) - { - int sts = MPI_SUCCESS ; - int flag = WithWait ; - int size = _MPI_access->sendRequestIdsSize() ; - int * ArrayOfSendRequests = new int[ size ] ; - int nSendRequest = _MPI_access->sendRequestIds( size , ArrayOfSendRequests ) ; - bool SendTrace = false ; - int i ; - for ( i = 0 ; i < nSendRequest ; i++ ) - { - if ( WithWait ) - { - cout << "CheckSent" << _my_rank << " " << i << "./" << nSendRequest - << " SendRequestId " << ArrayOfSendRequests[i] << " MPITarget " - << _MPI_access->MPITarget(ArrayOfSendRequests[i]) << " MPITag " - << _MPI_access->MPITag(ArrayOfSendRequests[i]) << " Wait :" << endl ; - sts = _MPI_access->wait( ArrayOfSendRequests[i] ) ; - } - else - { - sts = _MPI_access->test( ArrayOfSendRequests[i] , flag ) ; - } - if ( flag ) - { - _MPI_access->deleteRequest( ArrayOfSendRequests[i] ) ; - if ( SendTrace ) - { - cout << "CheckSent" << _my_rank << " " << i << "./" << nSendRequest - << " SendRequestId " << ArrayOfSendRequests[i] - << " flag " << flag - << " Counter " << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->Counter - << " DataType " << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->DataType - << endl ; - } - (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->Counter -= 1 ; - if ( SendTrace ) - { - if ( (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->DataType == - _MPI_access->timeType() ) - { - cout << "CheckTimeSent" << _my_rank << " Request " ; - } - else - { - cout << "CheckDataSent" << _my_rank << " Request " ; - } - cout << ArrayOfSendRequests[i] - << " _map_of_send_buffers->SendBuffer " - << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->SendBuffer - << " Counter " << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->Counter - << endl ; - } - if ( (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->Counter == 0 ) - { - if ( SendTrace ) - { - cout << "CheckSent" << _my_rank << " SendRequestId " << ArrayOfSendRequests[i] - << " Counter " << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->Counter - << " flag " << flag << " SendBuffer " - << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->SendBuffer - << " deleted. Erase in _map_of_send_buffers :" << endl ; - } - if ( (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->DataType == - _MPI_access->timeType() ) - { - delete (TimeMessage * ) (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->SendBuffer ; - } - else - { - if ( (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->DataType == MPI_INT ) - { - delete [] (int *) (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->SendBuffer ; - } - else - { - delete [] (double *) (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->SendBuffer ; - } - } - delete (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ] ; - } - if ( SendTrace ) - { - cout << "CheckSent" << _my_rank << " Erase in _map_of_send_buffers SendRequestId " - << ArrayOfSendRequests[i] << endl ; - } - (*_map_of_send_buffers).erase( ArrayOfSendRequests[i] ) ; - } - else if ( SendTrace ) - { - cout << "CheckSent" << _my_rank << " " << i << "./" << nSendRequest - << " SendRequestId " << ArrayOfSendRequests[i] - << " flag " << flag - << " Counter " << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->Counter - << " DataType " << (*_map_of_send_buffers)[ ArrayOfSendRequests[i] ]->DataType - << endl ; - } - } - if ( SendTrace ) - { - _MPI_access->check() ; - } - delete [] ArrayOfSendRequests ; - return sts ; - } - - int MPIAccessDEC::checkFinalRecv() - { - int sts = MPI_SUCCESS ; - if ( _time_interpolator ) - { - int target ; - for ( target = 0 ; target < _group_size ; target++ ) - { - if ( (*_data_messages)[target][0] != NULL ) - { - sts = checkTime( (*_data_messages_recv_count)[target] , (*_data_messages_type)[target] , - target , true ) ; - if ( (*_data_messages_type)[target] == MPI_INT ) - { - delete [] (int *) (*_data_messages)[target][0] ; - } - else - { - delete [] (double *) (*_data_messages)[target][0] ; - } - (*_data_messages)[target][0] = NULL ; - if ( (*_data_messages)[target][1] != NULL ) - { - if ( (*_data_messages_type)[target] == MPI_INT ) - { - delete [] (int *) (*_data_messages)[target][1] ; - } - else - { - delete [] (double *) (*_data_messages)[target][1] ; - } - (*_data_messages)[target][1] = NULL ; - } - } - } - } - return sts ; - } - - ostream & operator<< (ostream & f ,const TimeInterpolationMethod & interpolationmethod ) - { - switch (interpolationmethod) - { - case WithoutTimeInterp : - f << " WithoutTimeInterpolation "; - break; - case LinearTimeInterp : - f << " LinearTimeInterpolation "; - break; - default : - f << " UnknownTimeInterpolation "; - break; - } - - return f; - } -} diff --git a/src/ParaMEDMEM/MPIAccessDEC.hxx b/src/ParaMEDMEM/MPIAccessDEC.hxx deleted file mode 100644 index 0f1862f11..000000000 --- a/src/ParaMEDMEM/MPIAccessDEC.hxx +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (C) 2007-2010 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 __MPIACCESSDEC_HXX__ -#define __MPIACCESSDEC_HXX__ - -#include "MPIAccess.hxx" -#include "DEC.hxx" -#include "LinearTimeInterpolator.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class MPIAccessDEC - { - public: - MPIAccessDEC( const ProcessorGroup& local_group, const ProcessorGroup& distant_group, - bool Asynchronous = true ); - virtual ~MPIAccessDEC(); - MPIAccess * getMPIAccess() { return _MPI_access; } - const MPI_Comm* getComm() { return _MPI_union_group->getComm(); } - void asynchronous( bool Asynchronous = true ) { _asynchronous = Asynchronous; } - void setTimeInterpolator( TimeInterpolationMethod anInterp , double InterpPrecision=0 , - int n_step_before=1, int nStepAfter=1 ); - - void setTime( double t ) { _t = t; _dt = -1; } - void setTime( double t , double dt ) { _t = t; _dt = dt; } - bool outOfTime( int target ) { return (*_out_of_time)[target]; } - - int send( void* sendbuf, int sendcount , MPI_Datatype sendtype , int target ); - int recv( void* recvbuf, int recvcount , MPI_Datatype recvtype , int target ); - int recv( void* recvbuf, int recvcount , MPI_Datatype recvtype , int target , - int &RecvRequestId , bool Asynchronous=false ); - int sendRecv( void* sendbuf, int sendcount , MPI_Datatype sendtype , - void* recvbuf, int recvcount , MPI_Datatype recvtype , int target ); - - int allToAll( void* sendbuf, int sendcount, MPI_Datatype sendtype , - void* recvbuf, int recvcount, MPI_Datatype recvtype ); - int allToAllv( void* sendbuf, int* sendcounts, int* sdispls, MPI_Datatype sendtype , - void* recvbuf, int* recvcounts, int* rdispls, MPI_Datatype recvtype ); - - int allToAllTime( void* sendbuf, int sendcount , MPI_Datatype sendtype , - void* recvbuf, int recvcount , MPI_Datatype recvtype ); - int allToAllvTime( void* sendbuf, int* sendcounts, int* sdispls, - MPI_Datatype sendtype , - void* recvbuf, int* recvcounts, int* rdispls, - MPI_Datatype recvtype ); - int checkTime( int recvcount , MPI_Datatype recvtype , int target , bool UntilEnd ); - int checkSent(bool WithWait=false); - int checkFinalSent() { return checkSent( true ); } - int checkFinalRecv(); - protected: - int send( void* sendbuf, int sendcount , int sendoffset , MPI_Datatype sendtype , - int target, int &SendRequestId ); - int recv( void* recvbuf, int recvcount , int recvoffset , MPI_Datatype recvtype , - int target, int &RecvRequestId ); - int sendRecv( void* sendbuf, int sendcount , int sendoffset , - MPI_Datatype sendtype , - void* recvbuf, int recvcount , int recvoffset , - MPI_Datatype recvtype , int target , - int &SendRequestId ,int &RecvRequestId ); - private : - bool _asynchronous; - MPIProcessorGroup* _MPI_union_group; - - TimeInterpolator* _time_interpolator; - int _n_step_before; - int _n_step_after; - - int _my_rank; - int _group_size; - MPIAccess* _MPI_access; - - // Current time and deltatime of current process - double _t; - double _dt; - - // TimeMessages from each target _TimeMessages[target][Step] : TimeMessage - std::vector< std::vector< TimeMessage > > *_time_messages; - // Corresponding DataMessages from each target _DataMessages[target][~TimeStep] - std::vector< bool >* _out_of_time; - std::vector< int >* _data_messages_recv_count; - std::vector< MPI_Datatype >* _data_messages_type; - std::vector< std::vector< void * > >* _data_messages; - - typedef struct - { - void * SendBuffer; - int Counter; - MPI_Datatype DataType; } - SendBuffStruct; - std::map< int , SendBuffStruct * > *_map_of_send_buffers; - }; - - inline int MPIAccessDEC::send( void* sendbuf, int sendcount , MPI_Datatype sendtype , int target ) - { - int SendRequestId; - int sts; - if ( _asynchronous ) - { - sts = _MPI_access->ISend( sendbuf , sendcount , sendtype , target , - SendRequestId ); - } - else - { - sts = _MPI_access->send( sendbuf , sendcount , sendtype , target , - SendRequestId ); - if ( sts == MPI_SUCCESS ) - free( sendbuf ); - } - return sts; - } - - inline int MPIAccessDEC::recv( void* recvbuf, int recvcount , MPI_Datatype recvtype , int target ) - { - int RecvRequestId; - int sts; - if ( _asynchronous ) - sts = _MPI_access->IRecv( recvbuf , recvcount , recvtype , target , RecvRequestId ); - else - sts = _MPI_access->recv( recvbuf , recvcount , recvtype , target , RecvRequestId ); - return sts; - } - - inline int MPIAccessDEC::recv( void* recvbuf, int recvcount , MPI_Datatype recvtype , - int target , int &RecvRequestId , bool Asynchronous ) - { - int sts; - if ( Asynchronous ) - sts = _MPI_access->IRecv( recvbuf , recvcount , recvtype , target , - RecvRequestId ); - else - sts = _MPI_access->recv( recvbuf , recvcount , recvtype , target , - RecvRequestId ); - return sts; - } - - inline int MPIAccessDEC::sendRecv( void* sendbuf, int sendcount , MPI_Datatype sendtype , - void* recvbuf, int recvcount , MPI_Datatype recvtype , - int target ) - { - int SendRequestId; - int RecvRequestId; - int sts; - if ( _asynchronous ) - sts = _MPI_access->ISendRecv( sendbuf , sendcount , sendtype , target , - SendRequestId , - recvbuf , recvcount , recvtype , target , - RecvRequestId ); - else - sts = _MPI_access->sendRecv( sendbuf , sendcount , sendtype , target , - SendRequestId , - recvbuf , recvcount , recvtype , target , - RecvRequestId ); - return sts; - } - - std::ostream & operator<< (std::ostream &,const TimeInterpolationMethod &); -} - -#endif diff --git a/src/ParaMEDMEM/MPIProcessorGroup.cxx b/src/ParaMEDMEM/MPIProcessorGroup.cxx deleted file mode 100644 index 9681349f9..000000000 --- a/src/ParaMEDMEM/MPIProcessorGroup.cxx +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (C) 2007-2010 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 "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "CommInterface.hxx" -#include "InterpolationUtils.hxx" - -#include -#include -#include -#include "mpi.h" - -using namespace std; - -/*! \defgroup processor_group Processor Groups - * - * \section processor_group_overview Overview - * The MPIProcessorGroup class is used to set up processor groups that help to define - * the MPI topology of the couplings. They can be set up in various ways, the most common being - * the use of the \c MPIProcessorGroup(Comminterface, int pfirst, int plast) - * constructor. - * - * The following code excerpt creates two processor groups on respectively 3 and 2 processors. - \verbatim - int main() - { - MPI_Init(&argc,&argv); - CommInterface comm_interface; - MPIProcessorGroup codeA_group(comm_interface, 0, 2); - MPIProcessorGroup codeB_group(comm_interface, 3, 4); - - ... - } - \endverbatim -*/ - - -namespace ParaMEDMEM -{ - /*! - \addtogroup processor_group - @{ - */ - - /*! - * Creates a processor group that is based on all the - MPI_COMM_WORLD processor.This routine must be called by all processors in MPI_COMM_WORLD. - \param interface CommInterface object giving access to the MPI - communication layer - */ - MPIProcessorGroup::MPIProcessorGroup(const CommInterface& interface): - ProcessorGroup(interface),_world_comm(MPI_COMM_WORLD) - { - _comm=_world_comm; - _comm_interface.commGroup(_world_comm, &_group); - int size; - _comm_interface.commSize(_world_comm,&size); - for (int i=0; i proc_ids, const MPI_Comm& world_comm): - ProcessorGroup(interface, proc_ids),_world_comm(world_comm) - { - //Creation of a communicator - MPI_Group group_world; - - int size_world; - _comm_interface.commSize(_world_comm,&size_world); - int rank_world; - _comm_interface.commRank(_world_comm,&rank_world); - _comm_interface.commGroup(_world_comm, &group_world); - - int* ranks=new int[proc_ids.size()]; - - // copying proc_ids in ranks - copy::const_iterator,int*> (proc_ids.begin(), proc_ids.end(), ranks); - for (int i=0; i< (int)proc_ids.size();i++) - if (ranks[i]>size_world-1) - throw INTERP_KERNEL::Exception("invalid rank in set argument of MPIProcessorGroup constructor"); - - _comm_interface.groupIncl(group_world, proc_ids.size(), ranks, &_group); - - _comm_interface.commCreate(_world_comm, _group, &_comm); - delete[] ranks; - } - /*! Creates a processor group that is based on the processors between \a pstart and \a pend. - This routine must be called by all processors in MPI_COMM_WORLD. - - \param comm_interface CommInterface object giving access to the MPI - communication layer - \param pstart id in MPI_COMM_WORLD of the first processor in the group - \param pend id in MPI_COMM_WORLD of the last processor in the group - */ - MPIProcessorGroup::MPIProcessorGroup (const CommInterface& comm_interface, int pstart, int pend, const MPI_Comm& world_comm): ProcessorGroup(comm_interface,pstart,pend),_world_comm(world_comm) - { - //Creation of a communicator - MPI_Group group_world; - - int size_world; - _comm_interface.commSize(_world_comm,&size_world); - int rank_world; - _comm_interface.commRank(_world_comm,&rank_world); - _comm_interface.commGroup(_world_comm, &group_world); - - if (pend>size_world-1 || pend proc_ids) : - ProcessorGroup(proc_group.getCommInterface()),_world_comm(MPI_COMM_WORLD) - { - cout << "MPIProcessorGroup (const ProcessorGroup& proc_group, set proc_ids)" <(group); - int local_rank; - MPI_Group_translate_ranks(targetgroup->_group, 1, &rank, _group, &local_rank); - return local_rank; - } - - /*!Creates a processor group that is the complement of the current group - inside MPI_COMM_WORLD - \return pointer to the new ProcessorGroup structure. - */ - ProcessorGroup* MPIProcessorGroup::createComplementProcGroup() const - { - set procs; - int world_size=_comm_interface.worldSize(); - for (int i=0; i::const_iterator iter=_proc_ids.begin(); iter!= _proc_ids.end(); iter++) - procs.erase(*iter); - - return new MPIProcessorGroup(_comm_interface, procs, _world_comm); - - } - - /*!Adding processors of group \a group to local group. - \param group group that is to be fused with current group - \return new group formed by the fusion of local group and \a group. - */ - ProcessorGroup* MPIProcessorGroup::fuse (const ProcessorGroup& group) const - { - set procs = _proc_ids; - const set& distant_proc_ids = group.getProcIDs(); - for (set::const_iterator iter=distant_proc_ids.begin(); iter!=distant_proc_ids.end(); iter++) - { - procs.insert(*iter); - } - return new MPIProcessorGroup(_comm_interface, procs, _world_comm); - } - - int MPIProcessorGroup::myRank() const - { - int rank; - MPI_Comm_rank(_comm,&rank); - return rank; - } - - /*! - @} - */ - ProcessorGroup* MPIProcessorGroup::createProcGroup() const - { - set procs; - for (set::const_iterator iter=_proc_ids.begin(); iter!= _proc_ids.end(); iter++) - procs.insert(*iter); - - return new MPIProcessorGroup(_comm_interface, procs, _world_comm); - - } -} diff --git a/src/ParaMEDMEM/MPIProcessorGroup.hxx b/src/ParaMEDMEM/MPIProcessorGroup.hxx deleted file mode 100644 index c43a4476d..000000000 --- a/src/ParaMEDMEM/MPIProcessorGroup.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2007-2010 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 __MPIPROCESSORGROUP_HXX__ -#define __MPIPROCESSORGROUP_HXX__ - -#include -#include - -namespace ParaMEDMEM -{ - class ProcessorGroup; - class CommInterface; - - class MPIProcessorGroup : public ProcessorGroup - { - public: - MPIProcessorGroup(const CommInterface& interface); - MPIProcessorGroup(const CommInterface& interface, std::set proc_ids, const MPI_Comm& world_comm=MPI_COMM_WORLD); - MPIProcessorGroup (const ProcessorGroup& proc_group, std::set proc_ids); - MPIProcessorGroup(const CommInterface& interface,int pstart, int pend, const MPI_Comm& world_comm=MPI_COMM_WORLD); - virtual ~MPIProcessorGroup(); - virtual ProcessorGroup* fuse (const ProcessorGroup&) const; - void intersect (ProcessorGroup&) { } - int myRank() const; - bool containsMyRank() const { int rank; MPI_Group_rank(_group, &rank); return (rank!=MPI_UNDEFINED); } - int translateRank(const ProcessorGroup* group, int rank) const; - const MPI_Comm* getComm() const { return &_comm; } - ProcessorGroup* createComplementProcGroup() const; - ProcessorGroup* createProcGroup() const; - MPI_Comm getWorldComm() { return _world_comm; } - private: - const MPI_Comm _world_comm; - MPI_Group _group; - MPI_Comm _comm; - }; -} - -#endif diff --git a/src/ParaMEDMEM/Makefile.am b/src/ParaMEDMEM/Makefile.am deleted file mode 100644 index 5bc571a2b..000000000 --- a/src/ParaMEDMEM/Makefile.am +++ /dev/null @@ -1,105 +0,0 @@ -# Copyright (C) 2007-2010 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES= libparamedmem.la - -salomeinclude_HEADERS= \ -CommInterface.hxx\ -MPIProcessorGroup.hxx\ -ProcessorGroup.hxx\ -BlockTopology.hxx\ -Topology.hxx\ -ParaGRID.hxx\ -ParaMESH.hxx\ -ComponentTopology.hxx\ -ExplicitTopology.hxx\ -ParaFIELD.hxx\ -DEC.hxx\ -DECOptions.hxx\ -MxN_Mapping.hxx\ -StructuredCoincidentDEC.hxx\ -InterpolationMatrix.hxx\ -InterpKernelDEC.hxx\ -ExplicitCoincidentDEC.hxx\ -ElementLocator.hxx\ -ExplicitMapping.hxx\ -ICoCoField.hxx \ -ICoCoMEDField.hxx \ -ICoCoTrioField.hxx \ -MPIAccess.hxx \ -MPIAccessDEC.hxx \ -TimeInterpolator.hxx \ -LinearTimeInterpolator.hxx - -dist_libparamedmem_la_SOURCES= \ -ProcessorGroup.cxx \ -MPIProcessorGroup.cxx\ -ParaMESH.cxx\ -ComponentTopology.cxx\ -MPIAccess.cxx \ -InterpolationMatrix.cxx\ -StructuredCoincidentDEC.cxx\ -ExplicitCoincidentDEC.cxx\ -InterpKernelDEC.cxx\ -ElementLocator.cxx\ -MPIAccessDEC.cxx \ -TimeInterpolator.cxx \ -LinearTimeInterpolator.cxx\ -DEC.cxx\ -ExplicitTopology.cxx\ -MxN_Mapping.cxx\ -ICoCoMEDField.cxx\ -ICoCoField.cxx\ -ICoCoTrioField.cxx\ -ParaFIELD.cxx\ -ParaGRID.cxx\ -BlockTopology.cxx - -#libmedmem_la_LDFLAGS= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -libparamedmem_la_CPPFLAGS= $(MPI_INCLUDES) @CXXTMPDPTHFLAGS@ \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../MEDCoupling - -# change motivated by the bug KERNEL4778. -libparamedmem_la_LDFLAGS= ../MEDCoupling/libmedcoupling.la \ -../INTERP_KERNEL/libinterpkernel.la \ -$(MPI_LIBS) - -if MED_ENABLE_FVM - salomeinclude_HEADERS += NonCoincidentDEC.hxx - libparamedmem_la_SOURCES+= NonCoincidentDEC.cxx - libparamedmem_la_LDFLAGS+= $(FVM_LIBS) - libparamedmem_la_CPPFLAGS+= $(FVM_INCLUDES) -endif - -LDADD= -lm - -EXTRA_DIST += \ - BASICS_JR \ - CommInterface.cxx \ - NonCoincidentDEC.cxx \ - NonCoincidentDEC.hxx \ - DECOptions.hxx \ - README_JR \ - TODO_JR \ - Topology.cxx diff --git a/src/ParaMEDMEM/MxN_Mapping.cxx b/src/ParaMEDMEM/MxN_Mapping.cxx deleted file mode 100644 index 179017a9a..000000000 --- a/src/ParaMEDMEM/MxN_Mapping.cxx +++ /dev/null @@ -1,313 +0,0 @@ -// Copyright (C) 2007-2010 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 "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "MPIAccessDEC.hxx" -#include "MxN_Mapping.hxx" - -using namespace std; - -namespace ParaMEDMEM -{ - - MxN_Mapping::MxN_Mapping(const ProcessorGroup& source_group, const ProcessorGroup& target_group,const DECOptions& dec_options) - : DECOptions(dec_options),_union_group(source_group.fuse(target_group)) - { - _access_DEC = new MPIAccessDEC(source_group,target_group,getAsynchronous()); - _access_DEC->setTimeInterpolator(getTimeInterpolationMethod()); - _send_proc_offsets.resize(_union_group->size()+1,0); - _recv_proc_offsets.resize(_union_group->size()+1,0); - - } - - MxN_Mapping::~MxN_Mapping() - { - delete _union_group; - delete _access_DEC; - } - - - /*! - Method registering a new element for correspondence with a distant element - \param distant_proc proc rank of the distant processor (in terms of the union group) - \param distant_element id of the element on the distant processor - */ - void MxN_Mapping::addElementFromSource(int distant_proc, int distant_element) - { - _sending_ids.push_back(make_pair(distant_proc,distant_element)); - for (int i=distant_proc; i<_union_group->size(); i++) - _send_proc_offsets[i+1]++; - } - - void MxN_Mapping::initialize() - { - _sending_ids.clear(); - std::fill(_send_proc_offsets.begin(),_send_proc_offsets.end(),0); - } - - void MxN_Mapping::prepareSendRecv() - { - CommInterface comm_interface=_union_group->getCommInterface(); - // sending count pattern - int* nbsend=new int[_union_group->size()]; - int* nbrecv=new int[_union_group->size()]; - for (int i=0; i<_union_group->size(); i++) - { - nbsend[i]=_send_proc_offsets[i+1]-_send_proc_offsets[i]; - } - - MPIProcessorGroup* group = static_cast(_union_group); - const MPI_Comm* comm=group->getComm(); - comm_interface.allToAll(nbsend, 1, MPI_INT, - nbrecv, 1, MPI_INT, - *comm); - - for (int i=0; i<_union_group->size(); i++) - { - for (int j=i+1;j<_union_group->size()+1; j++) - _recv_proc_offsets[j]+=nbrecv[i]; - - } - - delete[] nbsend; - delete[] nbrecv; - - _recv_ids.resize(_recv_proc_offsets[_union_group->size()]); - int* isendbuf=0; - int* irecvbuf=0; - if (_sending_ids.size()>0) - isendbuf = new int[_sending_ids.size()]; - if (_recv_ids.size()>0) - irecvbuf = new int[_recv_ids.size()]; - int* sendcounts = new int[_union_group->size()]; - int* senddispls=new int[_union_group->size()]; - int* recvcounts=new int[_union_group->size()]; - int* recvdispls=new int[_union_group->size()]; - for (int i=0; i< _union_group->size(); i++) - { - sendcounts[i]=_send_proc_offsets[i+1]-_send_proc_offsets[i]; - senddispls[i]=_send_proc_offsets[i]; - recvcounts[i]=_recv_proc_offsets[i+1]-_recv_proc_offsets[i]; - recvdispls[i]=_recv_proc_offsets[i]; - } - vector offsets = _send_proc_offsets; - for (int i=0; i<(int)_sending_ids.size();i++) - { - int iproc = _sending_ids[i].first; - isendbuf[offsets[iproc]]=_sending_ids[i].second; - offsets[iproc]++; - } - comm_interface.allToAllV(isendbuf, sendcounts, senddispls, MPI_INT, - irecvbuf, recvcounts, recvdispls, MPI_INT, - *comm); - - for (int i=0; i< _recv_proc_offsets[_union_group->size()]; i++) - _recv_ids[i]=irecvbuf[i]; - - if (_sending_ids.size()>0) - delete[] isendbuf; - if (_recv_ids.size()>0) - delete[] irecvbuf; - delete[] sendcounts; - delete[]recvcounts; - delete[]senddispls; - delete[] recvdispls; - } - - /*! Exchanging field data between two groups of processes - * - * \param field MEDCoupling field containing the values to be sent - * - * The ids that were defined by addElementFromSource method - * are sent. - */ - void MxN_Mapping::sendRecv(double* sendfield, MEDCouplingFieldDouble& field) const - { - CommInterface comm_interface=_union_group->getCommInterface(); - const MPIProcessorGroup* group = static_cast(_union_group); - - int nbcomp=field.getArray()->getNumberOfComponents(); - double* sendbuf=0; - double* recvbuf=0; - if (_sending_ids.size() >0) - sendbuf = new double[_sending_ids.size()*nbcomp]; - if (_recv_ids.size()>0) - recvbuf = new double[_recv_ids.size()*nbcomp]; - - int* sendcounts = new int[_union_group->size()]; - int* senddispls=new int[_union_group->size()]; - int* recvcounts=new int[_union_group->size()]; - int* recvdispls=new int[_union_group->size()]; - - for (int i=0; i< _union_group->size(); i++) - { - sendcounts[i]=nbcomp*(_send_proc_offsets[i+1]-_send_proc_offsets[i]); - senddispls[i]=nbcomp*(_send_proc_offsets[i]); - recvcounts[i]=nbcomp*(_recv_proc_offsets[i+1]-_recv_proc_offsets[i]); - recvdispls[i]=nbcomp*(_recv_proc_offsets[i]); - } - //building the buffer of the elements to be sent - vector offsets = _send_proc_offsets; - - for (int i=0; i<(int)_sending_ids.size();i++) - { - int iproc = _sending_ids[i].first; - for (int icomp=0; icompgetComm(); - comm_interface.allToAllV(sendbuf, sendcounts, senddispls, MPI_DOUBLE, - recvbuf, recvcounts, recvdispls, MPI_DOUBLE, - *comm); - } - break; - case PointToPoint: - _access_DEC->allToAllv(sendbuf, sendcounts, senddispls, MPI_DOUBLE, - recvbuf, recvcounts, recvdispls, MPI_DOUBLE); - break; - } - - //setting the received values in the field - DataArrayDouble *fieldArr=field.getArray(); - double* recvptr=recvbuf; - for (int i=0; i< _recv_proc_offsets[_union_group->size()]; i++) - { - for (int icomp=0; icompgetIJ(_recv_ids[i],icomp); - fieldArr->setIJ(_recv_ids[i],icomp,temp+*recvptr); - recvptr++; - } - } - if (sendbuf!=0 && getAllToAllMethod()== Native) - delete[] sendbuf; - if (recvbuf !=0) - delete[] recvbuf; - delete[] sendcounts; - delete[] recvcounts; - delete[] senddispls; - delete[] recvdispls; - - } - - /*! Exchanging field data between two groups of processes - * - * \param field MEDCoupling field containing the values to be sent - * - * The ids that were defined by addElementFromSource method - * are sent. - */ - void MxN_Mapping::reverseSendRecv(double* recvfield, MEDCouplingFieldDouble& field) const - { - CommInterface comm_interface=_union_group->getCommInterface(); - const MPIProcessorGroup* group = static_cast(_union_group); - - int nbcomp=field.getArray()->getNumberOfComponents(); - double* sendbuf=0; - double* recvbuf=0; - if (_recv_ids.size() >0) - sendbuf = new double[_recv_ids.size()*nbcomp]; - if (_sending_ids.size()>0) - recvbuf = new double[_sending_ids.size()*nbcomp]; - - int* sendcounts = new int[_union_group->size()]; - int* senddispls=new int[_union_group->size()]; - int* recvcounts=new int[_union_group->size()]; - int* recvdispls=new int[_union_group->size()]; - - for (int i=0; i< _union_group->size(); i++) - { - sendcounts[i]=nbcomp*(_recv_proc_offsets[i+1]-_recv_proc_offsets[i]); - senddispls[i]=nbcomp*(_recv_proc_offsets[i]); - recvcounts[i]=nbcomp*(_send_proc_offsets[i+1]-_send_proc_offsets[i]); - recvdispls[i]=nbcomp*(_send_proc_offsets[i]); - } - //building the buffer of the elements to be sent - vector offsets = _recv_proc_offsets; - DataArrayDouble *fieldArr=field.getArray(); - for (int iproc=0; iproc<_union_group->size();iproc++) - for (int i=_recv_proc_offsets[iproc]; i<_recv_proc_offsets[iproc+1]; i++) - { - for (int icomp=0; icompgetIJ(_recv_ids[i],icomp); - } - - //communication phase - switch (getAllToAllMethod()) - { - case Native: - { - const MPI_Comm* comm = group->getComm(); - comm_interface.allToAllV(sendbuf, sendcounts, senddispls, MPI_DOUBLE, - recvbuf, recvcounts, recvdispls, MPI_DOUBLE, - *comm); - } - break; - case PointToPoint: - _access_DEC->allToAllv(sendbuf, sendcounts, senddispls, MPI_DOUBLE, - recvbuf, recvcounts, recvdispls, MPI_DOUBLE); - break; - } - - //setting the received values in the field - double* recvptr=recvbuf; - for (int i=0; i< _send_proc_offsets[_union_group->size()]; i++) - { - for (int icomp=0; icomp - -namespace ParaMEDMEM -{ - - class ProcessorGroup; - - class MxN_Mapping : public DECOptions - { - public: - MxN_Mapping(); - MxN_Mapping(const ProcessorGroup& source_group, const ProcessorGroup& target_group, const DECOptions& dec_options); - virtual ~MxN_Mapping(); - void addElementFromSource(int distant_proc, int distant_elem); - void prepareSendRecv(); - void sendRecv(MEDCouplingFieldDouble& field); - void sendRecv(double* sendfield, MEDCouplingFieldDouble& field) const ; - void reverseSendRecv(double* recvfield, MEDCouplingFieldDouble& field) const ; - - // - const std::vector >& getSendingIds() const { return _sending_ids; } - const std::vector& getSendProcsOffsets() const { return _send_proc_offsets; } - void initialize(); - - MPIAccessDEC* getAccessDEC(){ return _access_DEC; } - private : - ProcessorGroup* _union_group; - MPIAccessDEC * _access_DEC; - int _nb_comps; - std::vector > _sending_ids; - std::vector _recv_ids; - std::vector _send_proc_offsets; - std::vector _recv_proc_offsets; - }; - - std::ostream & operator<< (std::ostream &,const AllToAllMethod &); - -} - -#endif diff --git a/src/ParaMEDMEM/NonCoincidentDEC.cxx b/src/ParaMEDMEM/NonCoincidentDEC.cxx deleted file mode 100644 index 2ff66ca3c..000000000 --- a/src/ParaMEDMEM/NonCoincidentDEC.cxx +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include "CommInterface.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "ComponentTopology.hxx" -#include "ParaFIELD.hxx" -#include "MPIProcessorGroup.hxx" -#include "DEC.hxx" -#include "NonCoincidentDEC.hxx" - -extern "C" { -#include -#include -#include -#include -} - -namespace ParaMEDMEM -{ - - /*! - \defgroup noncoincidentdec NonCoincidentDEC - - \section overview Overview - - \c NonCoincidentDEC enables nonconservative remapping of fields - between two parallel codes. - The computation is possible for 3D meshes and 2D meshes. - It is not available for 3D surfaces. The computation enables fast parallel localization, based on the - FVM library. The computation is based on a point in element search, followed - by a field evaluation at the point location. Thus, it is typically - faster than the \ref interpkerneldec which gives a \ref conservativeremapping. - It is particularly true for the initialisation phase (synchronize) - which is very computationnaly intensive in \ref interpkerneldec. - - In the present version, only fields lying on elements are considered. - The value is estimated by locating the barycenter of the target - side cell in a source cell and sending the value of this source cell - as the value of the target cell. - - \image html NonCoincident_small.png "Example showing the transfer from a field based on a quadrangular mesh to a triangular mesh. The triangle barycenters are computed and located in the quadrangles. In a P0-P0 interpolation, the value on the quadrangle is then applied to the triangles whose barycenter lies within." - - \image latex NonCoincident_small.eps "Example showing the transfer from a field based on a quadrangular mesh to a triangular mesh. The triangle barycenters are computed and located in the quadrangles. In a P0-P0 interpolation, the value on the quadrangle is then applied to the triangles whose barycenter lies within." - - A typical use of NonCoincidentDEC encompasses two distinct phases : - - A setup phase during which the intersection volumes are computed and the communication structures are setup. This corresponds to calling the NonCoincidentDEC::synchronize() method. - - A use phase during which the remappings are actually performed. This corresponds to the calls to sendData() and recvData() which actually trigger the data exchange. The data exchange are synchronous in the current version of the library so that recvData() and sendData() calls must be synchronized on code A and code B processor groups. - - The following code excerpt illutrates a typical use of the NonCoincidentDEC class. - - \code - ... - NonCoincidentDEC dec(groupA, groupB); - dec.attachLocalField(field); - dec.synchronize(); - if (groupA.containsMyRank()) - dec.recvData(); - else if (groupB.containsMyRank()) - dec.sendData(); - ... - \endcode - - Computing the field on the receiving side can be expressed in terms - of a matrix-vector product : \f$ \phi_t=W.\phi_s\f$, with \f$ \phi_t - \f$ the field on the target side and \f$ \phi_s \f$ the field on - the source side. - In the P0-P0 case, this matrix is a plain rectangular matrix with one - non-zero element per row (with value 1). For instance, in the above figure, the matrix is : - \f[ - - \begin{tabular}{|cccc|} - 1 & 0 & 0 & 0\\ - 0 & 0 & 1 & 0\\ - 1 & 0 & 0 & 0\\ - 0 & 0 & 1 & 0\\ - \end{tabular} - \f] - */ - - fvm_nodal_t* medmemMeshToFVMMesh(const MEDMEM::MESH* mesh) - { - // create an FVM structure from the paramesh structure - fvm_nodal_t * fvm_nodal = fvm_nodal_create(mesh->getName().c_str(),mesh->getMeshDimension()); - - //loop on cell types - int nbtypes = mesh->getNumberOfTypes(MED_EN::MED_CELL); - const MED_EN::medGeometryElement* types = mesh->getTypes(MED_EN::MED_CELL); - for (int itype=0; itypegetNumberOfElements(MED_EN::MED_CELL, types[itype]); - fvm_lnum_t* conn = new fvm_lnum_t[nbelems*(types[itype]%100)]; - const int* mesh_conn =mesh->getConnectivity(MED_EN::MED_FULL_INTERLACE,MED_EN::MED_NODAL, MED_EN::MED_CELL, types[itype]); - for (int i=0; igetNumberOfNodes(); - int spacedim=mesh->getSpaceDimension(); - fvm_coord_t* coords = new fvm_coord_t[nbnodes*spacedim]; - const double* mesh_coords=mesh->getCoordinates(MED_EN::MED_FULL_INTERLACE); - for (int i=0; igetName().c_str(),1); - - const MEDMEM::MESH* mesh= support->getMesh(); - - //loop on cell types - MED_EN::medEntityMesh entity = support->getEntity(); - - int nbtypes = support->getNumberOfTypes(); - const MED_EN::medGeometryElement* types = support->getTypes(); - int ioffset=0; - const int* type_offset = support->getNumberIndex(); - - //browsing through all types - for (int itype=0; itypegetNumberOfElements(types[itype]); - - //for a partial support, defining the element numbers that are taken into - //account in the support - fvm_lnum_t* elem_numbers=0; - if (!support->isOnAllElements()) - { - elem_numbers = const_cast (support->getNumber(types[itype])); - - //creating work arrays to store list of elems for partial suports - if (itype>0) - { - fvm_lnum_t* temp = new int[nbelems]; - for (int i=0; i< nbelems; i++) - temp[i] = elem_numbers [i]-ioffset; - ioffset+=type_offset[itype]; - elem_numbers = temp; - } - } - //retrieving original mesh connectivity - fvm_lnum_t* conn = const_cast (mesh->getConnectivity(MED_EN::MED_FULL_INTERLACE,MED_EN::MED_NODAL,entity, types[itype])); - - // adding the elements to the FVM structure - fvm_nodal_append_by_transfer(fvm_nodal, nbelems, fvm_type,0,0,0,conn,elem_numbers); - - //cleaning work arrays (for partial supports) - if (!support->isOnAllElements() && itype>0) - delete[] elem_numbers; - - } - return fvm_nodal; - } - - NonCoincidentDEC::NonCoincidentDEC() - { - } - - /*! - \addtogroup noncoincidentdec - @{ - */ - - /*! Constructor of a non coincident DEC with - * a source group on which lies a field lying on a mesh and a - * target group on which lies a mesh. - * - * \param source_group ProcessorGroup on the source side - * \param target_group ProcessorGroup on the target side - */ - - NonCoincidentDEC::NonCoincidentDEC(ProcessorGroup& source_group, - ProcessorGroup& target_group) - :DEC(source_group, target_group) - {} - - NonCoincidentDEC::~NonCoincidentDEC() - { - } - - /*! Synchronization process. Calling this method - * synchronizes the topologies so that the target side - * gets the information which enable it to fetch the field value - * from the source side. - * A typical call is : - \verbatim - NonCoincidentDEC dec(source_group,target_group); - dec.attachLocalField(field); - dec.synchronize(); - \endverbatim - */ - void NonCoincidentDEC::synchronize() - { - - //initializing FVM parallel environment - const MPI_Comm* comm=dynamic_cast (_union_group)->getComm(); - fvm_parall_set_mpi_comm(*const_cast (comm)); - - - //setting up the communication DEC on both sides - - if (_source_group->containsMyRank()) - { - MEDMEM::MESH* mesh = _local_field->getField()->getSupport()->getMesh(); - fvm_nodal_t* source_nodal = ParaMEDMEM::medmemMeshToFVMMesh(mesh); - - int target_size = _target_group->size() ; - int start_rank= _source_group->size(); - const MPI_Comm* comm = (dynamic_cast (_union_group))->getComm(); - - _locator = fvm_locator_create(1e-6, - *comm, - target_size, - start_rank); - - fvm_locator_set_nodal(_locator, - source_nodal, - mesh->getSpaceDimension(), - 0, - NULL, - 0); - - - _nb_distant_points = fvm_locator_get_n_dist_points(_locator); - _distant_coords = fvm_locator_get_dist_coords(_locator); - _distant_locations = fvm_locator_get_dist_locations(_locator); - - } - if (_target_group->containsMyRank()) - { - MEDMEM::MESH* mesh = _local_field->getField()->getSupport()->getMesh(); - - fvm_nodal_t* target_nodal = ParaMEDMEM::medmemMeshToFVMMesh(mesh); - int source_size = _source_group->size(); - int start_rank= 0 ; - const MPI_Comm* comm = (dynamic_cast (_union_group))->getComm(); - - _locator = fvm_locator_create(1e-6, - *comm, - source_size, - start_rank); - int nbcells = mesh->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - const MEDMEM::SUPPORT* support=_local_field->getField()->getSupport(); - MEDMEM::FIELD* barycenter_coords = mesh->getBarycenter(support); - const double* coords = barycenter_coords->getValue(); - fvm_locator_set_nodal(_locator, - target_nodal, - mesh->getSpaceDimension(), - nbcells, - NULL, - coords); - delete barycenter_coords; - } - } - - - /*! This method is called on the target group in order to - * trigger the retrieveal of field data. It must - * be called synchronously with a sendData() call on - * the source group. - */ - void NonCoincidentDEC::recvData() - { - int nbelems = _local_field->getField()->getSupport()->getMesh()->getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - int nbcomp = _local_field->getField()->getNumberOfComponents(); - double* values = new double [nbelems*nbcomp]; - fvm_locator_exchange_point_var(_locator, - 0, - values, - 0, - sizeof(double), - nbcomp, - 0); - _local_field->getField()->setValue(values); - if (_forced_renormalization_flag) - renormalizeTargetField(); - delete[]values; - } - - /*! This method is called on the source group in order to - * send field data. It must be called synchronously with - * a recvData() call on - * the target group. - */ - void NonCoincidentDEC::sendData() - { - const double* values=_local_field->getField()->getValue(); - int nbcomp = _local_field->getField()->getNumberOfComponents(); - double* distant_values = new double [_nb_distant_points*nbcomp]; - - //cheap interpolation : the value of the cell is transfered to the point - for (int i=0; i<_nb_distant_points; i++) - for (int j=0; j - -namespace ParaMEDMEM -{ - /*! - \defgroup parafield ParaFIELD - This class encapsulates parallel fields. It basically encapsulates - a MEDCouplingField with extra information related to parallel - topology. - It is most conveniently created by giving a pointer to a MEDCouplingField - object and a \c ProcessorGroup. - By default, a ParaFIELD object will be constructed with all field components - located on the same processors. In some specific cases, it might be necessary to scatter components over several processors. In this case, the constructor - using a ComponentTopology is required. - - @{ */ - - /*! - - \brief Constructing a \c ParaFIELD from a \c ParaSUPPORT and a \c ComponentTopology. - - This constructor creates an empty field based on the ParaSUPPORT description - and the partitioning of components described in \a component_topology. - It takes ownership over the \c _field object that it creates. - - Here come the three ComponentTopology constructors : - \verbatim - ComponentTopology c; // one component in the field - ComponentTopology c(6); //six components, all of them on the same processor - ComponentTopology c(6, proc_group); // six components, evenly distributed over the processors of procgroup - \endverbatim - - */ - ParaFIELD::ParaFIELD(TypeOfField type, TypeOfTimeDiscretization td, ParaMESH* para_support, const ComponentTopology& component_topology) - :_field(0), - _component_topology(component_topology),_topology(0),_own_support(false), - _support(para_support) - { - if (para_support->isStructured() || (para_support->getTopology()->getProcGroup()->size()==1 && component_topology.nbBlocks()!=1)) - { - const BlockTopology* source_topo = dynamic_cast(para_support->getTopology()); - _topology=new BlockTopology(*source_topo,component_topology); - } - else - { - if (component_topology.nbBlocks()!=1 && para_support->getTopology()->getProcGroup()->size()!=1) - throw INTERP_KERNEL::Exception(LOCALIZED("ParaFIELD constructor : Unstructured Support not taken into account with component topology yet")); - else - { - const BlockTopology* source_topo=dynamic_cast (para_support->getTopology()); - int nb_local_comp=component_topology.nbLocalComponents(); - _topology=new BlockTopology(*source_topo,nb_local_comp); - } - } - int nb_components = component_topology.nbLocalComponents(); - if (nb_components!=0) - { - _field=MEDCouplingFieldDouble::New(type,td); - _field->setMesh(_support->getCellMesh()); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(_field->getNumberOfTuples(),nb_components); - _field->setArray(array); - array->decrRef(); - } - else return; - - _field->setName("Default ParaFIELD name"); - _field->setDescription("Default ParaFIELD description"); - } - - /*! \brief Constructor creating the ParaFIELD - from a given FIELD and a processor group. - - This constructor supposes that support underlying \a subdomain_field has no ParaSUPPORT - attached and it therefore recreates one. It therefore takes ownership over _support. The component topology associated with the field is a basic one (all components on the same processor). - */ - ParaFIELD::ParaFIELD(MEDCouplingFieldDouble* subdomain_field, ParaMESH *sup, const ProcessorGroup& proc_group): - _field(subdomain_field), - _component_topology(ComponentTopology(_field->getNumberOfComponents())),_topology(0),_own_support(false), - _support(sup) - { - if(_field) - _field->incrRef(); - const BlockTopology* source_topo=dynamic_cast (_support->getTopology()); - _topology=new BlockTopology(*source_topo,_component_topology.nbLocalComponents()); - } - - ParaFIELD::~ParaFIELD() - { - if(_field) - _field->decrRef(); - if(_own_support) - delete _support; - delete _topology; - } - - void ParaFIELD::synchronizeTarget(ParaFIELD* source_field) - { - DEC* data_channel; - if (dynamic_cast(_topology)!=0) - { - data_channel=new StructuredCoincidentDEC; - } - else - { - data_channel=new ExplicitCoincidentDEC; - } - data_channel->attachLocalField(this); - data_channel->synchronize(); - data_channel->prepareTargetDE(); - data_channel->recvData(); - - delete data_channel; - } - - void ParaFIELD::synchronizeSource(ParaFIELD* target_field) - { - DEC* data_channel; - if (dynamic_cast(_topology)!=0) - { - data_channel=new StructuredCoincidentDEC; - } - else - { - data_channel=new ExplicitCoincidentDEC; - } - data_channel->attachLocalField(this); - data_channel->synchronize(); - data_channel->prepareSourceDE(); - data_channel->sendData(); - - delete data_channel; - } - - /*! - * This method returns, if it exists, an array with only one component and as many as tuples as _field has. - * This array gives for every element on which this->_field lies, its global number, if this->_field is nodal. - * For example if _field is a nodal field : returned array will be the nodal global numbers. - * The content of this method is used to inform Working side to accumulate data recieved by lazy side. - */ - DataArrayInt* ParaFIELD::returnCumulativeGlobalNumbering() const - { - if(!_field) - return 0; - TypeOfField type=_field->getTypeOfField(); - switch(type) - { - case ON_CELLS: - return 0; - case ON_NODES: - return _support->getGlobalNumberingNodeDA(); - default: - return 0; - } - } - - DataArrayInt* ParaFIELD::returnGlobalNumbering() const - { - if(!_field) - return 0; - TypeOfField type=_field->getTypeOfField(); - switch(type) - { - case ON_CELLS: - return _support->getGlobalNumberingCellDA(); - case ON_NODES: - return _support->getGlobalNumberingNodeDA(); - default: - return 0; - } - } - - int ParaFIELD::nbComponents() const - { - return _component_topology.nbComponents(); - } - - - /*! This method retrieves the integral of component \a icomp - over the all domain. */ - double ParaFIELD::getVolumeIntegral(int icomp, bool isWAbs) const - { - CommInterface comm_interface = _topology->getProcGroup()->getCommInterface(); - double integral=_field->integral(icomp,isWAbs); - double total=0.; - const MPI_Comm* comm = (dynamic_cast(_topology->getProcGroup()))->getComm(); - comm_interface.allReduce(&integral, &total, 1, MPI_DOUBLE, MPI_SUM, *comm); - - return total; - } -} diff --git a/src/ParaMEDMEM/ParaFIELD.hxx b/src/ParaMEDMEM/ParaFIELD.hxx deleted file mode 100644 index 05f39094b..000000000 --- a/src/ParaMEDMEM/ParaFIELD.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAFIELD_HXX__ -#define __PARAFIELD_HXX__ - -#include "MEDCouplingRefCountObject.hxx" -#include "ComponentTopology.hxx" - -namespace ParaMEDMEM -{ - class DataArrayInt; - class ParaMESH; - class ProcessorGroup; - class MEDCouplingFieldDouble; - class ComponentTopology; - class Topology; - - class ParaFIELD - { - public: - - ParaFIELD(TypeOfField type, TypeOfTimeDiscretization td, ParaMESH* mesh, const ComponentTopology& component_topology); - - - ParaFIELD(MEDCouplingFieldDouble* field, ParaMESH *sup, const ProcessorGroup& group); - - virtual ~ParaFIELD(); - void synchronizeTarget( ParaMEDMEM::ParaFIELD* source_field); - void synchronizeSource( ParaMEDMEM::ParaFIELD* target_field); - MEDCouplingFieldDouble* getField() const { return _field; } - void setOwnSupport(bool v) const { _own_support=v; } - DataArrayInt* returnCumulativeGlobalNumbering() const; - DataArrayInt* returnGlobalNumbering() const; - Topology* getTopology() const { return _topology; } - ParaMESH* getSupport() const { return _support; } - int nbComponents() const; - double getVolumeIntegral(int icomp, bool isWAbs) const; - double getL2Norm()const { return -1; } - private: - MEDCouplingFieldDouble* _field; - ParaMEDMEM::ComponentTopology _component_topology; - Topology* _topology; - mutable bool _own_support; - ParaMESH* _support; - }; - -} - -#endif diff --git a/src/ParaMEDMEM/ParaGRID.cxx b/src/ParaMEDMEM/ParaGRID.cxx deleted file mode 100644 index 14a6c46c6..000000000 --- a/src/ParaMEDMEM/ParaGRID.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaGRID.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingCMesh.hxx" -#include "InterpKernelUtilities.hxx" - -#include - -using namespace std; - -namespace ParaMEDMEM -{ - - ParaGRID::ParaGRID(MEDCouplingCMesh* global_grid, Topology* topology) throw(INTERP_KERNEL::Exception) - { - - _block_topology = dynamic_cast(topology); - if(_block_topology==0) - throw INTERP_KERNEL::Exception(LOCALIZED("ParaGRID::ParaGRID topology must be block topology")); - - if (!_block_topology->getProcGroup()->containsMyRank()) - return; - - int dimension=_block_topology->getDimension() ; - if (dimension != global_grid->getSpaceDimension()) - throw INTERP_KERNEL::Exception(LOCALIZED("ParaGrid::ParaGrid incompatible topology")); - _grid=global_grid; - _grid->incrRef(); - /*vector > xyz_array(dimension); - vector > local_indices = _block_topology->getLocalArrayMinMax(); - vector coordinates_names; - vector coordinates_units; - for (int idim=0; idimgetCoordsAt(idim); - double *arrayC=array->getPointer(); - cout << " Indices "<< local_indices[idim].first <<" "<getName()); - coordinates_units.push_back(array->getInfoOnComponentAt(0)); - } - _grid=MEDCouplingCMesh::New(); - _grid->set(xyz_array, coordinates_names,coordinates_units); - _grid->setName(global_grid->getName()); - _grid->setDescription(global_grid->getDescription());*/ - } - - ParaGRID::~ParaGRID() - { - if(_grid) - _grid->decrRef(); - } -} diff --git a/src/ParaMEDMEM/ParaGRID.hxx b/src/ParaMEDMEM/ParaGRID.hxx deleted file mode 100644 index 032564391..000000000 --- a/src/ParaMEDMEM/ParaGRID.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAGRID_HXX__ -#define __PARAGRID_HXX__ - -#include "InterpolationUtils.hxx" - -#include - -namespace ParaMEDMEM -{ - class Topology; - class BlockTopology; - class MEDCouplingCMesh; - - class ParaGRID - { - public: - ParaGRID(MEDCouplingCMesh* global_grid, Topology* topology) throw(INTERP_KERNEL::Exception); - BlockTopology * getBlockTopology() const { return _block_topology; } - virtual ~ParaGRID(); - MEDCouplingCMesh* getGrid() const { return _grid; } - private: - MEDCouplingCMesh* _grid; - // structured grid topology - ParaMEDMEM::BlockTopology* _block_topology; - // stores the x,y,z axes on the global grid - std::vector > _global_axis; - //id of the local grid - int _my_domain_id; - }; -} - -#endif diff --git a/src/ParaMEDMEM/ParaMESH.cxx b/src/ParaMEDMEM/ParaMESH.cxx deleted file mode 100644 index fe8397cba..000000000 --- a/src/ParaMEDMEM/ParaMESH.cxx +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMESH.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "MEDCouplingMemArray.hxx" - -#include -#include - -//inclusion for the namespaces -using namespace std; - -namespace ParaMEDMEM -{ - ParaMESH::ParaMESH( MEDCouplingPointSet *subdomain_mesh, MEDCouplingPointSet *subdomain_face, - DataArrayInt *CorrespElt_local2global, DataArrayInt *CorrespFace_local2global, - DataArrayInt *CorrespNod_local2global, const ProcessorGroup& proc_group ): - _cell_mesh(subdomain_mesh), - _face_mesh(subdomain_face), - _my_domain_id(proc_group.myRank()), - _block_topology (new BlockTopology(proc_group, subdomain_mesh->getNumberOfCells())), - _explicit_topology(0), - _node_global(CorrespNod_local2global), - _face_global(CorrespFace_local2global), - _cell_global(CorrespElt_local2global) - { - if(_cell_mesh) - _cell_mesh->incrRef(); - if(_face_mesh) - _face_mesh->incrRef(); - if(CorrespElt_local2global) - CorrespElt_local2global->incrRef(); - if(CorrespFace_local2global) - CorrespFace_local2global->incrRef(); - if(CorrespNod_local2global) - CorrespNod_local2global->incrRef(); - } - - ParaMESH::ParaMESH( MEDCouplingPointSet *mesh, const ProcessorGroup& proc_group, const std::string& name): - _cell_mesh(mesh), - _face_mesh(0), - _my_domain_id(proc_group.myRank()), - _block_topology (new BlockTopology(proc_group, mesh->getNumberOfCells())), - _node_global(0), - _face_global(0) - { - if(_cell_mesh) - _cell_mesh->incrRef(); - int nb_elem=mesh->getNumberOfCells(); - _explicit_topology=new BlockTopology(proc_group,nb_elem); - int nbOfCells=mesh->getNumberOfCells(); - _cell_global = DataArrayInt::New(); - _cell_global->alloc(nbOfCells,1); - int *cellglobal=_cell_global->getPointer(); - int offset = _block_topology->localToGlobal(make_pair(_my_domain_id,0)); - for (int i=0; idecrRef(); - _node_global=nodeGlobal; - if(_node_global) - _node_global->incrRef(); - } - } - - void ParaMESH::setCellGlobal(DataArrayInt *cellGlobal) - { - if(cellGlobal!=_cell_global) - { - if(_cell_global) - _cell_global->decrRef(); - _cell_global=cellGlobal; - if(_cell_global) - _cell_global->incrRef(); - } - } - - ParaMESH::~ParaMESH() - { - if(_cell_mesh) - _cell_mesh->decrRef(); - if(_face_mesh) - _face_mesh->decrRef(); - delete _block_topology; - if(_node_global) - _node_global->decrRef(); - if(_cell_global) - _cell_global->decrRef(); - if(_face_global) - _face_global->decrRef(); - delete _explicit_topology; - } - -} diff --git a/src/ParaMEDMEM/ParaMESH.hxx b/src/ParaMEDMEM/ParaMESH.hxx deleted file mode 100644 index 1b5b96281..000000000 --- a/src/ParaMEDMEM/ParaMESH.hxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2007-2010 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 __PARAMESH_HXX__ -#define __PARAMESH_HXX__ - -#include "MEDCouplingPointSet.hxx" -#include "ProcessorGroup.hxx" -#include "MEDCouplingMemArray.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class Topology; - class BlockTopology; - class DataArrayInt; - - class ParaMESH - { - public: - ParaMESH( MEDCouplingPointSet *subdomain_mesh, - MEDCouplingPointSet *subdomain_face, - DataArrayInt *CorrespElt_local2global, - DataArrayInt *CorrespFace_local2global, - DataArrayInt *CorrespNod_local2global, - const ProcessorGroup& proc_group ) ; - ParaMESH( MEDCouplingPointSet *mesh, - const ProcessorGroup& proc_group, const std::string& name); - - virtual ~ParaMESH(); - void setNodeGlobal(DataArrayInt *nodeGlobal); - void setCellGlobal(DataArrayInt *cellGlobal); - Topology* getTopology() const { return _explicit_topology; } - bool isStructured() const { return _cell_mesh->isStructured(); } - MEDCouplingPointSet *getCellMesh() const { return _cell_mesh; } - MEDCouplingPointSet *getFaceMesh() const { return _face_mesh; } - BlockTopology* getBlockTopology() const { return _block_topology; } - - DataArrayInt* getGlobalNumberingNodeDA() const { if(_node_global) _node_global->incrRef(); return _node_global; } - DataArrayInt* getGlobalNumberingFaceDA() const { if(_face_global) _face_global->incrRef(); return _face_global; } - DataArrayInt* getGlobalNumberingCellDA() const { if(_cell_global) _cell_global->incrRef(); return _cell_global; } - const int* getGlobalNumberingNode() const { if(_node_global) return _node_global->getConstPointer(); return 0; } - const int* getGlobalNumberingFace() const { if(_face_global) return _face_global->getConstPointer(); return 0; } - const int* getGlobalNumberingCell() const { if(_cell_global) return _cell_global->getConstPointer(); return 0; } - - private: - //mesh object underlying the ParaMESH object - MEDCouplingPointSet *_cell_mesh ; - MEDCouplingPointSet *_face_mesh ; - - //id of the local grid - int _my_domain_id; - - //global topology of the cells - ParaMEDMEM::BlockTopology* _block_topology; - Topology* _explicit_topology; - // pointers to global numberings - DataArrayInt* _node_global; - DataArrayInt* _face_global; - DataArrayInt* _cell_global; - }; -} - -#endif diff --git a/src/ParaMEDMEM/ProcessorGroup.cxx b/src/ParaMEDMEM/ProcessorGroup.cxx deleted file mode 100644 index e6b0401df..000000000 --- a/src/ParaMEDMEM/ProcessorGroup.cxx +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2007-2010 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 "ProcessorGroup.hxx" -#include "InterpolationUtils.hxx" - -namespace ParaMEDMEM -{ - ProcessorGroup::ProcessorGroup (const CommInterface& interface, int start, int end):_comm_interface(interface) - { - if (start>end) - throw INTERP_KERNEL::Exception("wrong call to Processor group constructor"); - for (int i=start; i<=end;i++) - _proc_ids.insert(i); - } -} diff --git a/src/ParaMEDMEM/ProcessorGroup.hxx b/src/ParaMEDMEM/ProcessorGroup.hxx deleted file mode 100644 index df781aaf5..000000000 --- a/src/ParaMEDMEM/ProcessorGroup.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2010 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 __PROCESSORGROUP_HXX__ -#define __PROCESSORGROUP_HXX__ - -#include "CommInterface.hxx" - -#include - -namespace ParaMEDMEM -{ - class ProcessorGroup - { - public: - - ProcessorGroup(const CommInterface& interface):_comm_interface(interface) { } - ProcessorGroup(const CommInterface& interface, std::set proc_ids): - _comm_interface(interface),_proc_ids(proc_ids) { } - ProcessorGroup (const ProcessorGroup& proc_group, std::set proc_ids): - _comm_interface(proc_group.getCommInterface()) { } - ProcessorGroup (const CommInterface& interface, int start, int end); - virtual ~ProcessorGroup() { } - virtual ProcessorGroup* fuse (const ProcessorGroup&) const = 0; - virtual void intersect (ProcessorGroup&) = 0; - bool contains(int rank) const { return _proc_ids.find(rank)!=_proc_ids.end(); } - virtual bool containsMyRank() const = 0; - int size() const { return _proc_ids.size(); } - const CommInterface& getCommInterface()const { return _comm_interface; } - virtual int myRank() const = 0; - virtual int translateRank(const ProcessorGroup*, int) const = 0; - virtual ProcessorGroup* createComplementProcGroup() const = 0; - virtual ProcessorGroup* createProcGroup() const = 0; - virtual const std::set& getProcIDs()const { return _proc_ids; } - protected: - const CommInterface _comm_interface; - std::set _proc_ids; - }; -} - -#endif diff --git a/src/ParaMEDMEM/README_JR b/src/ParaMEDMEM/README_JR deleted file mode 100644 index 865af2b1d..000000000 --- a/src/ParaMEDMEM/README_JR +++ /dev/null @@ -1,446 +0,0 @@ - -CVS : -===== - -Branche : BR_MEDPARA : MED_SRC -setenv CVSROOT :pserver:rahuel@cvs.opencascade.com:/home/server/cvs/MED -cvs login -... - -Repertoires : -============= - -Sources : /home/rahuel/MEDPARAsynch -Construction sur awa : /data/tmpawa/rahuel/MEDPARAsynch/MED_Build -Intallation sur awa : /data/tmpawa/rahuel/MEDPARAsynch/MED_Install - - -Environnement : -=============== - -source /home/rahuel/MEDPARAsynch/env_products.csh - -On utilise : -/data/tmpawa/vb144235/valgrind-3.2.1/valgrind_install/bin -/data/tmpawa/adam/Salome3/V3_2_7_AWA_OCC/Python-2.4.1 -/data/tmpawa/vb144235/med_231_install -/data/tmpawa2/adam/omniORB/omniORB-4.0.7 -/data/tmpawa/vb144235/lam_install -/data/tmpawa/vb144235/cppunit_install -/data/tmpawa/vb144235/fvm_install_lam -/data/tmpawa/vb144235/bft_install -/home/rahuel/MEDPARAsynch/ICoCo -/data/tmpawa2/adam/Salome3/V3_2_0_maintainance/KERNEL/KERNEL_INSTALL - - -Build_Configure et Configure : -============================== - -MEDMEM est en "stand-alone" sans KERNEL ni IHM. - -cd $MED_BUILD_DIR -${MED_SRC_DIR}/build_configure --without-kernel --without-ihm -rm ${MED_SRC_DIR}/adm_local_without_kernel/adm_local_without_kernel -rm -fR $MED_BUILD_DIR/adm_local_without_kernel/adm_local_without_kernel - -cd $MED_BUILD_DIR -${MED_SRC_DIR}/configure --without-kernel --without-ihm --with-lam=/data/tmpawa/vb144235/lam_install --prefix=${MED_ROOT_DIR} --with-med2=/data/tmpawa/vb144235/med_231_install --with-python=/data/tmpawa/adam/Salome3/V3_2_7_AWA_OCC/Python-2.4.1 --with-cppunit=/data/tmpawa/vb144235/cppunit_install --with-cppunit_inc=/data/tmpawa/vb144235/cppunit_install/include --with-fvm=/data/tmpawa/vb144235/fvm_install_lam -rm ${MED_SRC_DIR}/adm_local_without_kernel/adm_local_without_kernel -rm -fR $MED_BUILD_DIR/adm_local_without_kernel/adm_local_without_kernel - - -Construction : -============== - -cd $MED_BUILD_DIR -make -make install - -Problemes de construction : -=========================== - -Liste des fichiers modifies et differents de la base CVS pour pouvoir -effectuer la construction et l'installation : - -M MED_SRC/configure.in.base : ------------------------------ -CHECK_MPICH -CHECK_LAM -CHECK_OPENMPI mis en commentaire (redefinit le resultat de CHECK_LAM) -CHECK_CPPUNIT a ete ajoute - -M MED_SRC/adm_local_without_kernel/unix/config_files/check_lam.m4 : -------------------------------------------------------------------- -Debugs pour trouver la bonne configuration de LAM - -M MED_SRC/src/INTERP_KERNEL/Makefile.in : ------------------------------------------ -Problemes de construction des tests - -M MED_SRC/src/ParaMEDMEM/Makefile.in : --------------------------------------- -. Construction de libParaMEDMEM.a pour gcov (link statique) -. Ajout d'options de compilations : -fprofile-arcs -ftest-coverage -pg (gcov) ==> - instrumentation du code - -C MED_SRC/src/ParaMEDMEM/Test/Makefile.in : -------------------------------------------- -. Construction de libParaMEDMEMTest.a pour gcov (link statique) -. Ajout d'options de compilations : -fprofile-arcs -ftest-coverage -pg (gcov) ==> - instrumentation du code -. Prise en compte de $(MED_WITH_KERNEL) avec : - ifeq ($(MED_WITH_KERNEL),yes) - LDFLAGSFORBIN += $(LDFLAGS) -lm $(MED2_LIBS) $(HDF5_LIBS) $(MPI_LIBS) \ - -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -lmed_V2_1 -lparamed -lmedmem \ - ${KERNEL_LDFLAGS} -lSALOMELocalTrace -lSALOMEBasics \ - $(CPPUNIT_LIBS) \ - -lParaMEDMEMTest - endif - ifeq ($(MED_WITH_KERNEL),no) - LDFLAGSFORBIN += $(LDFLAGS) -lm $(MED2_LIBS) $(HDF5_LIBS) $(MPI_LIBS) \ - -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -lmed_V2_1 -lparamed -linterpkernel -lmedmem \ - ${KERNEL_LDFLAGS} ${FVM_LIBS} ${CPPUNIT_LIBS} -L/data/tmpawa/vb144235/bft_install/lib -lbft\ - -lParaMEDMEMTest - endif - -M MED_SRC/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx : --------------------------------------------------- -Mise en commentaire du test manquant : -CPPUNIT_TEST(testNonCoincidentDEC_3D); - -U MED_SRC/src/ParaMEDMEM/Test/ParaMEDMEMTest_NonCoincidentDEC.cxx : -------------------------------------------------------------------- -Manque dans CVS - -Pour forcer la reconstruction des tests : -========================================= - -cd $MED_BUILD_DIR -rm src/ParaMEDMEM/*o -rm src/ParaMEDMEM/*.la -rm src/ParaMEDMEM/test_* -rm src/ParaMEDMEM/.libs/* -rm src/ParaMEDMEM/Test/*o -rm src/ParaMEDMEM/Test/*.la -rm src/ParaMEDMEM/Test/.libs/* -rm core.* -rm vgcore.* -cd $MED_BUILD_DIR/src/ParaMEDMEM/Test -make -make install -cd $MED_BUILD_DIR - - -Probleme avec lam : -=================== - -jr[1175]> mpirun -np 5 -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} TestParaMEDMEM -21508 TestParaMEDMEM running on n0 (o) -21509 TestParaMEDMEM running on n0 (o) -21510 TestParaMEDMEM running on n0 (o) -21511 TestParaMEDMEM running on n0 (o) -21512 TestParaMEDMEM running on n0 (o) -- Trace /home/rahuel/MEDPARAsynch/MED_SRC/src/MEDMEM/MEDMEM_Init.cxx [54] : Med Memory Initialization with $SALOME_trace = local -- Trace /home/rahuel/MEDPARAsynch/MED_SRC/src/MEDMEM/MEDMEM_Init.cxx [54] : Med Memory Initialization with $SALOME_trace = local -- Trace /home/rahuel/MEDPARAsynch/MED_SRC/src/MEDMEM/MEDMEM_Init.cxx [54] : Med Memory Initialization with $SALOME_trace = local -- Trace /home/rahuel/MEDPARAsynch/MED_SRC/src/MEDMEM/MEDMEM_Init.cxx [54] : Med Memory Initialization with $SALOME_trace = local -- Trace /home/rahuel/MEDPARAsynch/MED_SRC/src/MEDMEM/MEDMEM_Init.cxx [54] : Med Memory Initialization with $SALOME_trace = local ------------------------------------------------------------------------------ -The selected RPI failed to initialize during MPI_INIT. This is a -fatal error; I must abort. - -This occurred on host awa (n0). -The PID of failed process was 21508 (MPI_COMM_WORLD rank: 0) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -One of the processes started by mpirun has exited with a nonzero exit -code. This typically indicates that the process finished in error. -If your process did not finish in error, be sure to include a "return -0" or "exit(0)" in your C code before exiting the application. - -PID 21510 failed on node n0 (127.0.0.1) with exit status 1. ------------------------------------------------------------------------------ -jr[1176]> - - -Contournement du probleme lam : -=============================== - -mpirun -np 5 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} TestParaMEDMEM - - -Valgrind : -========== -. Les tests avec valgrind indiquent des erreurs dans MPI_Init et - MPI_Finalize ainsi que dans des programmes appeles "below main". -. De plus on obtient un "Segmentation Violation" accompagne d'un - fichier "vgcore.*" (plantage de valgrind) -. Mais on a " All heap blocks were freed -- no leaks are possible." - et on n'a aucune erreur de malloc/free new/delete dans ParaMEDMEM et - dans les tests. - -. Cependant si on execute les tests sans valgrind, il n'y a pas - d'erreur ni de fichier "core.*". - - -Tests avec CPPUNIT de $MED_BUILD_DIR/src/ParaMEDMEM/Test : -========================================================== - -L'appel a MPI_Init n'est fait qu'une seule fois. -Il est suivi par l'execution de toute la suite des tests regroupes -dans les trois executables TestParaMEDMEM, TestMPIAccessDEC et -TestMPIAccess -On a enfin un seul appel a MPI_Finalize. - -Si un des tests d'une suite de tests comporte une anomalie cela -peut avoir des implications sur l'execution des tests suivants. - -Lors de la mise au point de la suite de tests de TestMPIAccessDEC -cela etait le cas : il restait des messages postes dans lam mais -non lus. Le test suivant s'executait de plus en plus lentement -sans donner d'erreur (probleme difficile a identifier). - - -Lancement des tests de TestParaMEDMEM avec CPPUNIT et TotalView (option -tv) : -============================================================================== - -mpirun -np 5 -ssi rpi tcp C -tv -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} TestParaMEDMEM - -Il arrive qu'on ne puisse pas utiliser totalview par manque de -license. - - - -Lancement des tests de TestParaMEDMEM avec CPPUNIT et Valgrind avec "memory leaks" : -==================================================================================== - -mpirun -np 5 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full TestParaMEDMEM - - -Lancement des tests fonctionnels de MPI_AccessDEC avec CPPUNIT : -================================================================ - -mpirun -np 11 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full TestMPIAccessDEC - - -Lancement des tests unitaires de MPI_Access avec CPPUNIT : -========================================================== - -mpirun -np 3 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full TestMPIAccess - - -TestMPIAccess/TestMPIAccessDEC/TestParaMEDMEM et gcov : -======================================================= - -Les resultats sont dans les repertoires suivants de $MED_BUILD_DIR/src/ParaMEDMEM/Test : -------------- - - TestParaMEDMEM-gcov/ - TestMPIAccessDEC-gcov/ - TestMPIAccess-gcov/ - -Je n'y ai pas trouve d'anomalies. - -compilation : -fprofile-arcs -ftest-coverage -------------- - -$MED_BUILD_DIR/src/ParaMEDMEM/makefile.in : LIB=libparamedar.a \ -------------------------------------------- libparamed.la - -$MED_BUILD_DIR/src/ParaMEDMEM/Test/makefile.in : LIB = libParaMEDMEMTestar.a \ ------------------------------------------------- libParaMEDMEMTest.la - -links statiques manuels : -------------------------- - -g++ -g -D_DEBUG_ -Wno-deprecated -Wparentheses -Wreturn-type -Wunused -DPCLINUX -I/data/tmpawa/vb144235/cppunit_install/include -I/data/tmpawa/vb144235/lam_install/include -ftemplate-depth-42 -I/home/rahuel/MEDPARAsynch/MED_SRC/src/ParaMEDMEM -fprofile-arcs -ftest-coverage -o TestMPIAccess TestMPIAccess.lo -L../../../lib64/salome -lstdc++ -L../../../lib64/salome -lstdc++ -lm -L/data/tmpawa/vb144235/med_231_install/lib -lmed -lhdf5 -lhdf5 -L/data/tmpawa/vb144235/lam_install/lib -llam -lmpi -L../../../lib64/salome -lmed_V2_1 --whole-archive -linterpkernel -lmedmem -L/data/tmpawa/vb144235/fvm_install_lam/lib -lfvm -L/data/tmpawa/vb144235/cppunit_install/lib -lcppunit -L/data/tmpawa/vb144235/bft_install/lib -lbft -lutil -lm -lrt -ldl -Bstatic -L./ -lParaMEDMEMTestar -L../ -lparamedar -L./ -lParaMEDMEMTestar - -g++ -g -D_DEBUG_ -Wno-deprecated -Wparentheses -Wreturn-type -Wunused -DPCLINUX -I/data/tmpawa/vb144235/cppunit_install/include -I/data/tmpawa/vb144235/lam_install/include -ftemplate-depth-42 -I/home/rahuel/MEDPARAsynch/MED_SRC/src/ParaMEDMEM -fprofile-arcs -ftest-coverage -o TestMPIAccessDEC TestMPIAccessDEC.lo -L../../../lib64/salome -lstdc++ -L../../../lib64/salome -lstdc++ -lm -L/data/tmpawa/vb144235/med_231_install/lib -lmed -lhdf5 -lhdf5 -L/data/tmpawa/vb144235/lam_install/lib -llam -lmpi -L../../../lib64/salome -lmed_V2_1 --whole-archive -linterpkernel -lmedmem -L/data/tmpawa/vb144235/fvm_install_lam/lib -lfvm -L/data/tmpawa/vb144235/cppunit_install/lib -lcppunit -L/data/tmpawa/vb144235/bft_install/lib -lbft -lutil -lm -lrt -ldl -Bstatic -L./ -lParaMEDMEMTestar -L../ -lparamedar -L./ -lParaMEDMEMTestar - -g++ -g -D_DEBUG_ -Wno-deprecated -Wparentheses -Wreturn-type -Wunused -DPCLINUX -I/data/tmpawa/vb144235/cppunit_install/include -I/data/tmpawa/vb144235/lam_install/include -ftemplate-depth-42 -I/home/rahuel/MEDPARAsynch/MED_SRC/src/ParaMEDMEM -fprofile-arcs -ftest-coverage -o TestParaMEDMEM TestParaMEDMEM.lo -L../../../lib64/salome -lstdc++ -L../../../lib64/salome -lstdc++ -lm -L/data/tmpawa/vb144235/med_231_install/lib -lmed -lhdf5 -lhdf5 -L/data/tmpawa/vb144235/lam_install/lib -llam -lmpi -L../../../lib64/salome -lmed_V2_1 --whole-archive -linterpkernel -lmedmem -L/data/tmpawa/vb144235/fvm_install_lam/lib -lfvm -L/data/tmpawa/vb144235/cppunit_install/lib -lcppunit -L/data/tmpawa/vb144235/bft_install/lib -lbft -lutil -lm -lrt -ldl -Bstatic -L./ -lParaMEDMEMTestar -L../ -lparamedar -L./ -lParaMEDMEMTestar - -Ne pas oublier le make install apres ... - -execution et gcov : -------------------- - -Pour pouvoir traiter les .cxx de ${MED_BUILD_DIR}/src/ParaMEDMEM et de -${MED_BUILD_DIR}/src/ParaMEDMEM/Test, on execute deux fois gcov. - -cd ${MED_BUILD_DIR}/src/ParaMEDMEM/Test - -mpirun -np 3 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} TestMPIAccess - -gcov TestMPIAccess.cxx test_MPI_Access_Send_Recv.cxx \ - test_MPI_Access_Cyclic_Send_Recv.cxx \ - test_MPI_Access_SendRecv.cxx \ - test_MPI_Access_ISend_IRecv.cxx \ - test_MPI_Access_Cyclic_ISend_IRecv.cxx \ - test_MPI_Access_ISendRecv.cxx \ - test_MPI_Access_Probe.cxx \ - test_MPI_Access_IProbe.cxx \ - test_MPI_Access_Cancel.cxx \ - test_MPI_Access_Send_Recv_Length.cxx \ - test_MPI_Access_ISend_IRecv_Length.cxx \ - test_MPI_Access_ISend_IRecv_Length_1.cxx \ - test_MPI_Access_Time.cxx \ - test_MPI_Access_Time_0.cxx \ - test_MPI_Access_ISend_IRecv_BottleNeck.cxx \ - ../MPI_Access.cxx -gcov -o ../ TestMPIAccess.cxx test_MPI_Access_Send_Recv.cxx \ - test_MPI_Access_Cyclic_Send_Recv.cxx \ - test_MPI_Access_SendRecv.cxx \ - test_MPI_Access_ISend_IRecv.cxx \ - test_MPI_Access_Cyclic_ISend_IRecv.cxx \ - test_MPI_Access_ISendRecv.cxx \ - test_MPI_Access_Probe.cxx \ - test_MPI_Access_IProbe.cxx \ - test_MPI_Access_Cancel.cxx \ - test_MPI_Access_Send_Recv_Length.cxx \ - test_MPI_Access_ISend_IRecv_Length.cxx \ - test_MPI_Access_ISend_IRecv_Length_1.cxx \ - test_MPI_Access_Time.cxx \ - test_MPI_Access_Time_0.cxx \ - test_MPI_Access_ISend_IRecv_BottleNeck.cxx \ - ../MPI_Access.cxx - - -cd ${MED_BUILD_DIR}/src/ParaMEDMEM/Test -mpirun -np 11 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} TestMPIAccessDEC - -gcov TestMPIAccessDEC.cxx test_AllToAllDEC.cxx \ - test_AllToAllvDEC.cxx \ - test_AllToAllTimeDEC.cxx \ - test_AllToAllvTimeDEC.cxx \ - test_AllToAllvTimeDoubleDEC.cxx \ - ../TimeInterpolator.cxx \ - ../LinearTimeInterpolator.cxx \ - ../MPI_Access.cxx \ - ../MPI_AccessDEC.cxx -gcov -o ../ TestMPIAccessDEC.cxx test_AllToAllDEC.cxx \ - test_AllToAllvDEC.cxx \ - test_AllToAllTimeDEC.cxx \ - test_AllToAllvTimeDEC.cxx \ - test_AllToAllvTimeDoubleDEC.cxx \ - ../TimeInterpolator.cxx \ - ../LinearTimeInterpolator.cxx \ - ../MPI_Access.cxx \ - ../MPI_AccessDEC.cxx - -cd ${MED_BUILD_DIR}/src/ParaMEDMEM/Test -mpirun -np 5 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} TestParaMEDMEM - -gcov TestParaMEDMEM.cxx ParaMEDMEMTest.cxx \ - ParaMEDMEMTest_MPIProcessorGroup.cxx \ - ParaMEDMEMTest_BlockTopology.cxx \ - ParaMEDMEMTest_InterpKernelDEC.cxx \ - ../BlockTopology.cxx \ - ../ComponentTopology.cxx \ - ../DEC.cxx \ - ../ElementLocator.cxx \ - ../InterpolationMatrix.cxx \ - ../InterpKernelDEC.cxx \ - ../MPIProcessorGroup.cxx \ - ../MxN_Mapping.cxx \ - ../ParaFIELD.cxx \ - ../ParaMESH.cxx \ - ../ParaSUPPORT.cxx \ - ../ProcessorGroup.cxx \ - ../TimeInterpolator.cxx \ - ../LinearTimeInterpolator.cxx \ - ../MPI_Access.cxx \ - ../MPI_AccessDEC.cxx - -gcov -o ../ TestParaMEDMEM.cxx ParaMEDMEMTest.cxx \ - ParaMEDMEMTest_MPIProcessorGroup.cxx \ - ParaMEDMEMTest_BlockTopology.cxx \ - ParaMEDMEMTest_InterpKernelDEC.cxx \ - ../BlockTopology.cxx \ - ../ComponentTopology.cxx \ - ../DEC.cxx \ - ../ElementLocator.cxx \ - ../InterpolationMatrix.cxx \ - ../InterpKernelDEC.cxx \ - ../MPIProcessorGroup.cxx \ - ../MxN_Mapping.cxx \ - ../ParaFIELD.cxx \ - ../ParaMESH.cxx \ - ../ParaSUPPORT.cxx \ - ../ProcessorGroup.cxx \ - ../TimeInterpolator.cxx \ - ../LinearTimeInterpolator.cxx \ - ../MPI_Access.cxx \ - ../MPI_AccessDEC.cxx - - - - - -Lancement des tests unitaires sans CPPUNIT : -============================================ - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Send_Recv - -mpirun -np 3 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Cyclic_Send_Recv - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_SendRecv - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_ISend_IRecv - -mpirun -np 3 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Cyclic_ISend_IRecv - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_ISendRecv - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Probe - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_IProbe - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Cancel - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Send_Recv_Length - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_ISend_IRecv_Length - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_ISend_IRecv_Length_1 - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Time - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_Time_0 2 1 - - -#AllToAllDEC -mpirun -np 4 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllDEC 0 - -mpirun -np 4 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllDEC 1 - - -#AllToAllvDEC -mpirun -np 4 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllvDEC 0 - -mpirun -np 4 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllvDEC 1 - - -#AllToAllTimeDEC -mpirun -np 4 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllTimeDEC 0 - -mpirun -np 4 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllTimeDEC 1 - - -#AllToAllvTimeDEC -mpirun -np 11 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllvTimeDEC 0 1 - -mpirun -np 11 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllvTimeDEC 0 - -mpirun -np 11 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllvTimeDEC 1 - - - -#AllToAllvTimeDoubleDEC -mpirun -np 11 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllvTimeDoubleDEC 0 - -mpirun -np 11 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_AllToAllvTimeDoubleDEC 1 - - - -mpirun -np 2 -ssi rpi tcp C -v -x PATH=${PATH},LD_LIBRARY_PATH=${LD_LIBRARY_PATH} valgrind --leak-check=full test_MPI_Access_ISend_IRecv_BottleNeck - diff --git a/src/ParaMEDMEM/StructuredCoincidentDEC.cxx b/src/ParaMEDMEM/StructuredCoincidentDEC.cxx deleted file mode 100644 index 1f787b881..000000000 --- a/src/ParaMEDMEM/StructuredCoincidentDEC.cxx +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include "CommInterface.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "ComponentTopology.hxx" -#include "ParaFIELD.hxx" -#include "MPIProcessorGroup.hxx" -#include "StructuredCoincidentDEC.hxx" -#include "InterpKernelUtilities.hxx" - -#include - -using namespace std; - -namespace ParaMEDMEM -{ - - /*! \defgroup structuredcoincidentdec StructuredCoincidentDEC - - This class is meant for remapping fields that have identical - supports with different parallel topologies. It can be used to couple - together multiphysics codes that operate on the same domain - with different partitionings, which can be useful if one of - the computation is much faster than the other. It can also be used - to couple together codes that share an interface that was generated - in the same manner (with identical global ids). - Also, this DEC can be used for fields that have component topologies, - i.e., components that are scattered over several processors. - - The remapping between the two supports is based on identity of global - ids, instead of geometrical considerations as it is the case for - NonCoincidentDEC and InterpKernelDEC. Therefore, this DEC must not be used - for coincident meshes that do not have the same numbering. - - As all the other DECs, its use is made of two phases : - - a setup phase during which the topologies are exchanged so that - the target side knows from which processors it should expect - the data. - - a send/recv phase during which the field data is actually transferred. - - This example illustrates the sending of a field with - the DEC : - \code - ... - StructuredCoincidentDEC dec(groupA, groupB); - dec.attachLocalField(field); - dec.synchronize(); - if (groupA.containsMyRank()) - dec.recvData(); - else if (groupB.containsMyRank()) - dec.sendData(); - ... - \endcode - - Creating a ParaFIELD to be attached to the DEC is exactly the same as for - other DECs in the case when the remapping concerns similar meshes - that only have different partitionings. In the case when the - fields have also different component topologies, creating the ParaFIELD - requires some more effort. See \ref parafield section for more details. - */ - - - StructuredCoincidentDEC::StructuredCoincidentDEC():_topo_source(0),_topo_target(0), - _send_counts(0),_recv_counts(0), - _send_displs(0),_recv_displs(0), - _recv_buffer(0),_send_buffer(0) - { - } - - - StructuredCoincidentDEC::~StructuredCoincidentDEC() - { - delete [] _send_buffer; - delete [] _recv_buffer; - delete []_send_displs; - delete [] _recv_displs; - delete [] _send_counts; - delete [] _recv_counts; - if (! _source_group->containsMyRank()) - delete _topo_source; - if(!_target_group->containsMyRank()) - delete _topo_target; - } - - /*! - \addtogroup structuredcoincidentdec - @{ - */ - StructuredCoincidentDEC::StructuredCoincidentDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group):DEC(local_group,distant_group), - _topo_source(0),_topo_target(0), - _send_counts(0),_recv_counts(0), - _send_displs(0),_recv_displs(0), - _recv_buffer(0),_send_buffer(0) - { - } - - /*! Synchronization process for exchanging topologies - */ - void StructuredCoincidentDEC::synchronizeTopology() - { - if (_source_group->containsMyRank()) - _topo_source = dynamic_cast(_local_field->getTopology()); - if (_target_group->containsMyRank()) - _topo_target = dynamic_cast(_local_field->getTopology()); - - // Transmitting source topology to target code - broadcastTopology(_topo_source,1000); - // Transmitting target topology to source code - broadcastTopology(_topo_target,2000); - if (_topo_source->getNbElements() != _topo_target->getNbElements()) - throw INTERP_KERNEL::Exception("Incompatible dimensions for target and source topologies"); - - } - - /*! Creates the arrays necessary for the data transfer - * and fills the send array with the values of the - * source field - * */ - void StructuredCoincidentDEC::prepareSourceDE() - { - //////////////////////////////////// - //Step 1 : _buffer array creation - - if (!_topo_source->getProcGroup()->containsMyRank()) - return; - MPIProcessorGroup* group=new MPIProcessorGroup(_topo_source->getProcGroup()->getCommInterface()); - - int myranksource = _topo_source->getProcGroup()->myRank(); - - vector * target_arrays=new vector[_topo_target->getProcGroup()->size()]; - - //cout<<" topotarget size"<< _topo_target->getProcGroup()->size()< getNbLocalElements(); - for (int ielem=0; ielem< nb_local ; ielem++) - { - // cout <<"source local :"<localToGlobal(make_pair(myranksource, ielem)); - // cout << "global "< target_local =_topo_target->globalToLocal(global); - // cout << "target local : "<size(); - - _send_counts=new int[union_size]; - _send_displs=new int[union_size]; - _recv_counts=new int[union_size]; - _recv_displs=new int[union_size]; - - for (int i=0; i< union_size; i++) - { - _send_counts[i]=0; - _recv_counts[i]=0; - _recv_displs[i]=0; - } - _send_displs[0]=0; - - for (int iproc=0; iproc < _topo_target->getProcGroup()->size(); iproc++) - { - //converts the rank in target to the rank in union communicator - int unionrank=group->translateRank(_topo_target->getProcGroup(),iproc); - _send_counts[unionrank]=target_arrays[iproc].size(); - } - - for (int iproc=1; iprocsize();iproc++) - _send_displs[iproc]=_send_displs[iproc-1]+_send_counts[iproc-1]; - - _send_buffer = new double [nb_local ]; - - ///////////////////////////////////////////////////////////// - //Step 2 : filling the _buffers with the source field values - - int* counter=new int [_topo_target->getProcGroup()->size()]; - counter[0]=0; - for (int i=1; i<_topo_target->getProcGroup()->size(); i++) - counter[i]=counter[i-1]+target_arrays[i-1].size(); - - - const double* value = _local_field->getField()->getArray()->getPointer(); - //cout << "Nb local " << nb_local<localToGlobal(make_pair(myranksource, ielem)); - pair target_local =_topo_target->globalToLocal(global); - //cout <<"global : "<< global<<" local :"<getProcGroup()->containsMyRank()) - return; - MPIProcessorGroup* group=new MPIProcessorGroup(_topo_source->getProcGroup()->getCommInterface()); - - int myranktarget = _topo_target->getProcGroup()->myRank(); - - vector < vector > source_arrays(_topo_source->getProcGroup()->size()); - int nb_local = _topo_target-> getNbLocalElements(); - for (int ielem=0; ielem< nb_local ; ielem++) - { - // cout <<"TS target local :"<localToGlobal(make_pair(myranktarget, ielem)); - //cout << "TS global "< source_local =_topo_source->globalToLocal(global); - // cout << "TS source local : "<size(); - _recv_counts=new int[union_size]; - _recv_displs=new int[union_size]; - _send_counts=new int[union_size]; - _send_displs=new int[union_size]; - - for (int i=0; i< union_size; i++) - { - _send_counts[i]=0; - _recv_counts[i]=0; - _recv_displs[i]=0; - } - for (int iproc=0; iproc < _topo_source->getProcGroup()->size(); iproc++) - { - //converts the rank in target to the rank in union communicator - int unionrank=group->translateRank(_topo_source->getProcGroup(),iproc); - _recv_counts[unionrank]=source_arrays[iproc].size(); - } - for (int i=1; igetProcGroup()->myRank()==0) - { - MESSAGE ("Master rank"); - topo->serialize(serializer, size); - rank_master = group->translateRank(topo->getProcGroup(),0); - MESSAGE("Master rank world number is "<size()); - for (int i=0; i< group->size(); i++) - { - if (i!= rank_master) - _comm_interface->send(&rank_master,1,MPI_INT, i,tag+i,*(group->getComm())); - } - } - else - { - MESSAGE(" rank "<myRank()<< " waiting ..."); - _comm_interface->recv(&rank_master, 1,MPI_INT, MPI_ANY_SOURCE, tag+group->myRank(), *(group->getComm()),&status); - MESSAGE(" rank "<myRank()<< "received master rank"<broadcast(&size, 1,MPI_INT,rank_master,*(group->getComm())); - - int* buffer=new int[size]; - if (topo!=0 && topo->getProcGroup()->myRank()==0) - copy(serializer, serializer+size, buffer); - _comm_interface->broadcast(buffer,size,MPI_INT,rank_master,*(group->getComm())); - - // Processors which did not possess the source topology - // unserialize it - - BlockTopology* topotemp=new BlockTopology(); - topotemp->unserialize(buffer, *_comm_interface); - - if (topo==0) - topo=topotemp; - else - delete topotemp; - - // Memory cleaning - delete[] buffer; - if (serializer!=0) - delete[] serializer; - MESSAGE (" rank "<myRank()<< " unserialize is over"); - delete group; - } - - - - void StructuredCoincidentDEC::recvData() - { - //MPI_COMM_WORLD is used instead of group because there is no - //mechanism for creating the union group yet - MESSAGE("recvData"); - for (int i=0; i< 4; i++) - cout << _recv_counts[i]<<" "; - cout <(_union_group)->getComm()); - _comm_interface->allToAllV(_send_buffer, _send_counts, _send_displs, MPI_DOUBLE, - _recv_buffer, _recv_counts, _recv_displs, MPI_DOUBLE,comm); - cout<<"end AllToAll"<getNbLocalElements(); - //double* value=new double[nb_local]; - double* value=const_cast(_local_field->getField()->getArray()->getPointer()); - - int myranktarget=_topo_target->getProcGroup()->myRank(); - vector counters(_topo_source->getProcGroup()->size()); - counters[0]=0; - for (int i=0; i<_topo_source->getProcGroup()->size()-1; i++) - { - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); - int worldrank=group->translateRank(_topo_source->getProcGroup(),i); - counters[i+1]=counters[i]+_recv_counts[worldrank]; - delete group; - } - - for (int ielem=0; ielemlocalToGlobal(make_pair(myranktarget, ielem)); - pair source_local =_topo_source->globalToLocal(global); - value[ielem]=_recv_buffer[counters[source_local.first]++]; - } - - - //_local_field->getField()->setValue(value); - } - - void StructuredCoincidentDEC::sendData() - { - MESSAGE ("sendData"); - for (int i=0; i< 4; i++) - cout << _send_counts[i]<<" "; - cout <(_union_group)->getComm()); - _comm_interface->allToAllV(_send_buffer, _send_counts, _send_displs, MPI_DOUBLE, - _recv_buffer, _recv_counts, _recv_displs, MPI_DOUBLE,comm); - cout<<"end AllToAll"<containsMyRank()) - { - synchronizeTopology(); - prepareSourceDE(); - } - else if (_target_group->containsMyRank()) - { - synchronizeTopology(); - prepareTargetDE(); - } - } - /*! - @} - */ -} - diff --git a/src/ParaMEDMEM/StructuredCoincidentDEC.hxx b/src/ParaMEDMEM/StructuredCoincidentDEC.hxx deleted file mode 100644 index f25227194..000000000 --- a/src/ParaMEDMEM/StructuredCoincidentDEC.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2010 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 __STRUCTUREDCOINCIDENTDEC_HXX__ -#define __STRUCTUREDCOINCIDENTDEC_HXX__ - -#include "DEC.hxx" -#include "BlockTopology.hxx" - - -namespace ParaMEDMEM -{ - class DEC; - class BlockTopology; - class StructuredCoincidentDEC : public DEC - { - public: - StructuredCoincidentDEC(); - StructuredCoincidentDEC( ProcessorGroup& source, ProcessorGroup& target); - virtual ~StructuredCoincidentDEC(); - void synchronize(); - void recvData(); - void sendData(); - void prepareSourceDE(); - void prepareTargetDE(); - - private : - void synchronizeTopology(); - void broadcastTopology(BlockTopology*&, int tag); - - BlockTopology* _topo_source; - BlockTopology* _topo_target; - int* _send_counts; - int* _recv_counts; - int* _send_displs; - int* _recv_displs; - double* _recv_buffer; - double* _send_buffer; - }; -} - -#endif diff --git a/src/ParaMEDMEM/TODO_JR b/src/ParaMEDMEM/TODO_JR deleted file mode 100644 index de2318d54..000000000 --- a/src/ParaMEDMEM/TODO_JR +++ /dev/null @@ -1,50 +0,0 @@ - -MPI_Access : -============ - -. Creer des methodes [I]SendRecv en point a point avec un "target" - pour le Send et un "target" pour le Recv comme le SendRecv MPI. - -. Ne pas creer de structure RequestStruct en mode synchrone. - - -MPI_AccessDEC : -=============== - -. AllToAll, AllToAllv, AllToAllTime et AllToAllvTime comportent - des sequences de code semblables qui pourraient etre regroupees - sans que cela nuise a la lisibilite du code. - -. En mode asynchrone, il n'y a pas de controle d'engorgement des - messages envoyes dans CheckSent(). Il est vrai qu'en pratique - une synchronisation des temps est faite dans AllToAllTime et - AllToAllvTime. Mais ce probleme pourrait se produire avec - AllToAll et AllToAllv. Il serait possible de fixer un nombre - maximum de messages envoyes et "en cours" et de le comparer avec - le nombre de requetes rendu par MPI_Access. En cas de depassement - de ?n?*UnionGroupSize par exemple, CheckSent pourrait fonctionner - en mode "WithWait". Ce qui ferait qu'on apellerait Wait au lieu de Test. - -. Meme si le prototype d'interpolateur comporte des parametres - int nStepBefore et int nStepAfter, le codage actuel considere - qu'on n'a que nStepBefore=1 et nStepAfter=1. - Ainsi on a (*_TimeMessages)[target][0] et (*_TimeMessages)[target][1] - ainsi que &(*_DataMessages)[target][0] et &(*_DataMessages)[target][1]. - -. Les champs nStepBefore et nStepAfter correspondent a un maximum - requis. On devrait avoir les champs correspondants qui valent les - nombres disponibles a un moment donne. - -. Il existe un champs OutOfTime qui n'est pas utilise actuellement. - Il faudrait definir son usage et le transmettre sans doute à - l'interpolateur. Actuellement, L'interpolateur lineaire effectue une - extrapolation si OutOfTime vaut true. - -. Dans CheckTime, on alloue et detruit les (*_DataMessages)[target][] - alors qu'on pourrait considerer que pour un "target" donne, les - recvcount sont constants pendant toute la boucle de temps. Ainsi - on n'allouerait les buffers qu'une fois au depart et ils ne seraient - liberes qu'a la fin. - - - diff --git a/src/ParaMEDMEM/TimeInterpolator.cxx b/src/ParaMEDMEM/TimeInterpolator.cxx deleted file mode 100644 index b5466df14..000000000 --- a/src/ParaMEDMEM/TimeInterpolator.cxx +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2007-2010 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 "TimeInterpolator.hxx" - -namespace ParaMEDMEM -{ - TimeInterpolator::TimeInterpolator( double InterpPrecision, int nStepBefore, int nStepAfter ) - { - _interp_precision=InterpPrecision; - _n_step_before=nStepBefore; - _n_step_after=nStepAfter; - } - - TimeInterpolator::~TimeInterpolator() - { - } -} diff --git a/src/ParaMEDMEM/TimeInterpolator.hxx b/src/ParaMEDMEM/TimeInterpolator.hxx deleted file mode 100644 index 967a26ce7..000000000 --- a/src/ParaMEDMEM/TimeInterpolator.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2007-2010 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 __TIMEINTERPOLATOR_HXX__ -#define __TIMEINTERPOLATOR_HXX__ - -#include "ProcessorGroup.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class TimeInterpolator - { - public: - TimeInterpolator( double InterpPrecision, int nStepBefore=1, int nStepAfter=1 ); - virtual ~TimeInterpolator(); - - void setInterpParams( double InterpPrecision, int nStepBefore=1, int nStepAfter=1 ) { _interp_precision=InterpPrecision; _n_step_before=nStepBefore; _n_step_after=nStepAfter; } - void steps( int &nStepBefore, int &nStepAfter ) { nStepBefore=_n_step_before; nStepAfter=_n_step_after ; } - virtual void doInterp( double time0, double time1, double time, int recvcount , - int nbuff0, int nbuff1, - int **recvbuff0, int **recvbuff1, int *result ) = 0; - virtual void doInterp( double time0, double time1, double time, int recvcount , - int nbuff0, int nbuff1, - double **recvbuff0, double **recvbuff1, double *result ) = 0; - protected : - double _interp_precision; - int _n_step_before; - int _n_step_after; - }; -} - -#endif diff --git a/src/ParaMEDMEM/Topology.cxx b/src/ParaMEDMEM/Topology.cxx deleted file mode 100644 index acc0fa2c4..000000000 --- a/src/ParaMEDMEM/Topology.cxx +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2007-2010 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 "Topology.hxx" - -namespace ParaMEDMEM -{ - Topology::Topology() - { - } - - Topology::~Topology() - { - } -} diff --git a/src/ParaMEDMEM/Topology.hxx b/src/ParaMEDMEM/Topology.hxx deleted file mode 100644 index 0ca48c83a..000000000 --- a/src/ParaMEDMEM/Topology.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2010 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 __TOPOLOGY_HXX__ -#define __TOPOLOGY_HXX__ - -#include - -namespace ParaMEDMEM -{ - class ProcessorGroup; - - class Topology - { - public: - Topology() { } - virtual ~Topology() { } - virtual int getNbElements() const = 0; - virtual int getNbLocalElements() const = 0; - virtual const ProcessorGroup* getProcGroup()const = 0; - }; -} - -#endif diff --git a/src/ParaMEDMEMTest/MPI2Connector.cxx b/src/ParaMEDMEMTest/MPI2Connector.cxx deleted file mode 100644 index 8daa23516..000000000 --- a/src/ParaMEDMEMTest/MPI2Connector.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2007-2010 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 "MPI2Connector.hxx" - -#include - -MPI2Connector::MPI2Connector() -{ - MPI_Comm_size( MPI_COMM_WORLD, &_nb_proc ); - MPI_Comm_rank( MPI_COMM_WORLD, &_num_proc ); -} - -MPI2Connector::~MPI2Connector() -{ -} - -MPI_Comm MPI2Connector::remoteMPI2Connect(const std::string& service) -{ - int i; - char port_name[MPI_MAX_PORT_NAME]; - char port_name_clt[MPI_MAX_PORT_NAME]; - std::ostringstream msg; - MPI_Comm icom; - - if( service.size() == 0 ) - { - msg << "[" << _num_proc << "] You have to give a service name !"; - std::cerr << msg.str().c_str() << std::endl; - throw std::exception(); - } - - _srv = false; - - MPI_Barrier(MPI_COMM_WORLD); - - MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); - if( _num_proc == 0 ) - { - /* rank 0 try to be a server. If service is already published, try to be a cient */ - MPI_Open_port(MPI_INFO_NULL, port_name); - if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS ) - { - _srv = true; - _port_name = port_name; - std::cerr << "[" << _num_proc << "] service " << service << " available at " << port_name << std::endl; - } - else if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ) - { - std::cerr << "[" << _num_proc << "] I get the connection with " << service << " at " << port_name_clt << std::endl; - MPI_Close_port( port_name ); - } - else - { - msg << "[" << _num_proc << "] Error on connection with " << service << " at " << port_name_clt; - std::cerr << msg.str().c_str() << std::endl; - throw std::exception(); - } - } - else - { - i=0; - /* Waiting rank 0 publish name and try to be a client */ - while ( i != TIMEOUT ) - { - sleep(1); - if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ) - { - std::cerr << "[" << _num_proc << "] I get the connection with " << service << " at " << port_name_clt << std::endl; - break; - } - i++; - } - if(i==TIMEOUT) - { - msg << "[" << _num_proc << "] Error on connection with " << service << " at " << port_name_clt; - std::cerr << msg.str().c_str() << std::endl; - throw std::exception(); - } - } - MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); - - /* If rank 0 is server, all processes call MPI_Comm_accept */ - /* If rank 0 is not server, all processes call MPI_Comm_connect */ - int srv = (int)_srv; - MPI_Bcast(&srv,1,MPI_INT,0,MPI_COMM_WORLD); - _srv = (bool)srv; - if ( _srv ) - MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &icom ); - else - MPI_Comm_connect(port_name_clt, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &icom ); - - /* create global communicator: servers have low index in global communicator*/ - MPI_Intercomm_merge(icom,!_srv,&_gcom); - - /* only rank 0 can be server for unpublish name */ - if(_num_proc != 0) _srv = false; - - return _gcom; - -} - -void MPI2Connector::remoteMPI2Disconnect(const std::string& service) -{ - std::ostringstream msg; - - if( service.size() == 0 ) - { - msg << "[" << _num_proc << "] You have to give a service name !"; - std::cerr << msg.str().c_str() << std::endl; - throw std::exception(); - } - - MPI_Comm_disconnect( &_gcom ); - if ( _srv ) - { - - char port_name[MPI_MAX_PORT_NAME]; - strcpy(port_name,_port_name.c_str()); - - MPI_Unpublish_name((char*)service.c_str(), MPI_INFO_NULL, port_name); - std::cerr << "[" << _num_proc << "] " << service << ": close port " << _port_name << std::endl; - MPI_Close_port( port_name ); - } - -} - diff --git a/src/ParaMEDMEMTest/MPI2Connector.hxx b/src/ParaMEDMEMTest/MPI2Connector.hxx deleted file mode 100644 index 905de10fb..000000000 --- a/src/ParaMEDMEMTest/MPI2Connector.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2010 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 __MPI2CONNECTOR_HXX__ -#define __MPI2CONNECTOR_HXX__ - -#include -#include -#include - -class MPI2Connector -{ -public: - MPI2Connector(); - ~MPI2Connector(); - // MPI2 connection - MPI_Comm remoteMPI2Connect(const std::string& service); - // MPI2 disconnection - void remoteMPI2Disconnect(const std::string& service); -private: - // Processus id - int _num_proc; - // Processus size - int _nb_proc; - MPI_Comm _gcom; - bool _srv; - std::string _port_name; -private: - static const int TIMEOUT=5; -}; - -#endif diff --git a/src/ParaMEDMEMTest/MPIAccessDECTest.cxx b/src/ParaMEDMEMTest/MPIAccessDECTest.cxx deleted file mode 100644 index 00ad69dab..000000000 --- a/src/ParaMEDMEMTest/MPIAccessDECTest.cxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2010 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 "MPIAccessDECTest.hxx" -#include - -#include -#include - -using namespace std; - - - -/*! - * Tool to remove temporary files. - * Allows automatique removal of temporary files in case of test failure. - */ -MPIAccessDECTest_TmpFilesRemover::~MPIAccessDECTest_TmpFilesRemover() -{ - set::iterator it = myTmpFiles.begin(); - for (; it != myTmpFiles.end(); it++) { - if (access((*it).data(), F_OK) == 0) - remove((*it).data()); - } - myTmpFiles.clear(); - //cout << "~MPIAccessTest_TmpFilesRemover()" << endl; -} - -bool MPIAccessDECTest_TmpFilesRemover::Register(const string theTmpFile) -{ - return (myTmpFiles.insert(theTmpFile)).second; -} diff --git a/src/ParaMEDMEMTest/MPIAccessDECTest.hxx b/src/ParaMEDMEMTest/MPIAccessDECTest.hxx deleted file mode 100644 index 5ee346ac3..000000000 --- a/src/ParaMEDMEMTest/MPIAccessDECTest.hxx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2007-2010 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 _MPIACCESSDECTEST_HXX_ -#define _MPIACCESSDECTEST_HXX_ - -#include - -#include -#include -#include -#include "mpi.h" - - -class MPIAccessDECTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( MPIAccessDECTest ); - // CPPUNIT_TEST( test_AllToAllDECSynchronousPointToPoint ) ; - CPPUNIT_TEST( test_AllToAllDECAsynchronousPointToPoint ) ; - //CPPUNIT_TEST( test_AllToAllvDECSynchronousPointToPoint ) ; - CPPUNIT_TEST( test_AllToAllvDECAsynchronousPointToPoint ) ; - //CPPUNIT_TEST( test_AllToAllTimeDECSynchronousPointToPoint ) ; - CPPUNIT_TEST( test_AllToAllTimeDECAsynchronousPointToPoint ) ; - CPPUNIT_TEST( test_AllToAllvTimeDECSynchronousNative ) ; - //CPPUNIT_TEST( test_AllToAllvTimeDECSynchronousPointToPoint ) ; - CPPUNIT_TEST( test_AllToAllvTimeDECAsynchronousPointToPoint ) ; - //CPPUNIT_TEST( test_AllToAllvTimeDoubleDECSynchronousPointToPoint ) ; - CPPUNIT_TEST( test_AllToAllvTimeDoubleDECAsynchronousPointToPoint ) ; - CPPUNIT_TEST_SUITE_END(); - - -public: - - MPIAccessDECTest():CppUnit::TestFixture(){} - ~MPIAccessDECTest(){} - void setUp(){} - void tearDown(){} - void test_AllToAllDECSynchronousPointToPoint() ; - void test_AllToAllDECAsynchronousPointToPoint() ; - void test_AllToAllvDECSynchronousPointToPoint() ; - void test_AllToAllvDECAsynchronousPointToPoint() ; - void test_AllToAllTimeDECSynchronousPointToPoint() ; - void test_AllToAllTimeDECAsynchronousPointToPoint() ; - void test_AllToAllvTimeDECSynchronousNative() ; - void test_AllToAllvTimeDECSynchronousPointToPoint() ; - void test_AllToAllvTimeDECAsynchronousPointToPoint() ; - void test_AllToAllvTimeDoubleDECSynchronousPointToPoint() ; - void test_AllToAllvTimeDoubleDECAsynchronousPointToPoint() ; - -private: - void test_AllToAllDEC( bool Asynchronous ) ; - void test_AllToAllvDEC( bool Asynchronous ) ; - void test_AllToAllTimeDEC( bool Asynchronous ) ; - void test_AllToAllvTimeDEC( bool Asynchronous , bool UseMPINative ) ; - void test_AllToAllvTimeDoubleDEC( bool Asynchronous ) ; - }; - -// to automatically remove temporary files from disk -class MPIAccessDECTest_TmpFilesRemover -{ -public: - MPIAccessDECTest_TmpFilesRemover() {} - ~MPIAccessDECTest_TmpFilesRemover(); - bool Register(const std::string theTmpFile); - -private: - std::set myTmpFiles; -}; - -/*! - * Tool to print array to stream. - */ -template -void MPIAccessDECTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text) -{ - stream << text << ": {"; - if (length > 0) { - stream << array[0]; - for (int i = 1; i < length; i++) { - stream << ", " << array[i]; - } - } - stream << "}" << std::endl; -}; - -#endif diff --git a/src/ParaMEDMEMTest/MPIAccessTest.cxx b/src/ParaMEDMEMTest/MPIAccessTest.cxx deleted file mode 100644 index d8413f1fc..000000000 --- a/src/ParaMEDMEMTest/MPIAccessTest.cxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2010 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 "MPIAccessTest.hxx" -#include - -#include -#include - -using namespace std; - - - -/*! - * Tool to remove temporary files. - * Allows automatique removal of temporary files in case of test failure. - */ -MPIAccessTest_TmpFilesRemover::~MPIAccessTest_TmpFilesRemover() -{ - set::iterator it = myTmpFiles.begin(); - for (; it != myTmpFiles.end(); it++) { - if (access((*it).data(), F_OK) == 0) - remove((*it).data()); - } - myTmpFiles.clear(); - //cout << "~MPIAccessTest_TmpFilesRemover()" << endl; -} - -bool MPIAccessTest_TmpFilesRemover::Register(const string theTmpFile) -{ - return (myTmpFiles.insert(theTmpFile)).second; -} diff --git a/src/ParaMEDMEMTest/MPIAccessTest.hxx b/src/ParaMEDMEMTest/MPIAccessTest.hxx deleted file mode 100644 index ddb899053..000000000 --- a/src/ParaMEDMEMTest/MPIAccessTest.hxx +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2007-2010 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 _MPIACCESSTEST_HXX_ -#define _MPIACCESSTEST_HXX_ - -#include - -#include -#include -#include -#include "mpi.h" - - -class MPIAccessTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( MPIAccessTest ); - CPPUNIT_TEST( test_MPI_Access_Send_Recv ) ; - CPPUNIT_TEST( test_MPI_Access_Cyclic_Send_Recv ) ; - CPPUNIT_TEST( test_MPI_Access_SendRecv ) ; - CPPUNIT_TEST( test_MPI_Access_ISend_IRecv ) ; - CPPUNIT_TEST( test_MPI_Access_Cyclic_ISend_IRecv ) ; - CPPUNIT_TEST( test_MPI_Access_ISendRecv ) ; - CPPUNIT_TEST( test_MPI_Access_Probe ) ; - CPPUNIT_TEST( test_MPI_Access_IProbe ) ; - CPPUNIT_TEST( test_MPI_Access_Cancel ) ; - CPPUNIT_TEST( test_MPI_Access_Send_Recv_Length ) ; - CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_Length ) ; - CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_Length_1 ) ; - CPPUNIT_TEST( test_MPI_Access_Time ) ; - CPPUNIT_TEST( test_MPI_Access_Time_0 ) ; - CPPUNIT_TEST( test_MPI_Access_ISend_IRecv_BottleNeck ) ; - CPPUNIT_TEST_SUITE_END(); - - -public: - - MPIAccessTest():CppUnit::TestFixture(){} - ~MPIAccessTest(){} - void setUp(){} - void tearDown(){} - void test_MPI_Access_Send_Recv() ; - void test_MPI_Access_Cyclic_Send_Recv() ; - void test_MPI_Access_SendRecv() ; - void test_MPI_Access_ISend_IRecv() ; - void test_MPI_Access_Cyclic_ISend_IRecv() ; - void test_MPI_Access_ISendRecv() ; - void test_MPI_Access_Probe() ; - void test_MPI_Access_IProbe() ; - void test_MPI_Access_Cancel() ; - void test_MPI_Access_Send_Recv_Length() ; - void test_MPI_Access_ISend_IRecv_Length() ; - void test_MPI_Access_ISend_IRecv_Length_1() ; - void test_MPI_Access_Time() ; - void test_MPI_Access_Time_0() ; - void test_MPI_Access_ISend_IRecv_BottleNeck() ; - -private: - }; - -// to automatically remove temporary files from disk -class MPIAccessTest_TmpFilesRemover -{ -public: - MPIAccessTest_TmpFilesRemover() {} - ~MPIAccessTest_TmpFilesRemover(); - bool Register(const std::string theTmpFile); - -private: - std::set myTmpFiles; -}; - -/*! - * Tool to print array to stream. - */ -template -void MPIAccessTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text) -{ - stream << text << ": {"; - if (length > 0) { - stream << array[0]; - for (int i = 1; i < length; i++) { - stream << ", " << array[i]; - } - } - stream << "}" << std::endl; -}; - -#endif diff --git a/src/ParaMEDMEMTest/MPIMainTest.hxx b/src/ParaMEDMEMTest/MPIMainTest.hxx deleted file mode 100644 index b96d31e33..000000000 --- a/src/ParaMEDMEMTest/MPIMainTest.hxx +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2007-2010 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 _MPIMAINTEST_HXX_ -#define _MPIMAINTEST_HXX_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#ifndef WIN32 -#include -#endif - -// ============================================================================ -/*! - * Main program source for Unit Tests with cppunit package does not depend - * on actual tests, so we use the same for all partial unit tests. - */ -// ============================================================================ - -int main(int argc, char* argv[]) -{ -#ifndef WIN32 - fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM); - _FPU_SETCW(cw); -#endif - MPI_Init(&argc,&argv); - int rank; - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - - // --- Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // --- Add a listener that colllects test result - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // --- Add a listener that print dots as test run. -#ifdef WIN32 - CPPUNIT_NS::TextTestProgressListener progress; -#else - CPPUNIT_NS::BriefTestProgressListener progress; -#endif - controller.addListener( &progress ); - - // --- Get the top level suite from the registry - - CPPUNIT_NS::Test *suite = - CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); - - // --- Adds the test to the list of test to run - - CPPUNIT_NS::TestRunner runner; - runner.addTest( suite ); - runner.run( controller); - - // --- Print test in a compiler compatible format. - - std::ostringstream testFileName; - testFileName<<"UnitTestResult"< - -#include -#include -#include -#include -#include - -//================================================================================ -/*! - * \brief Get path to the resources file. - * - * When running 'make test' source file is taken from MED_SRC/resources folder. - * Otherwise, file is searched in ${MED_ROOT_DIR}/share/salome/resources/med folder. - * - * \param filename name of the resource file (should not include a path) - * \return full path to the resource file - */ -//================================================================================ - -std::string ParaMEDMEMTest::getResourceFile( const std::string& filename ) -{ - std::string resourceFile = ""; - - if ( getenv("top_srcdir") ) { - // we are in 'make check' step - resourceFile = getenv("top_srcdir"); - resourceFile += "/resources/"; - } - else if ( getenv("MED_ROOT_DIR") ) { - // use MED_ROOT_DIR env.var - resourceFile = getenv("MED_ROOT_DIR"); - resourceFile += "/share/salome/resources/med/"; - } - resourceFile += filename; - return resourceFile; -} - - -//================================================================================ -/*! - * \brief Returns writable temporary directory - * \return full path to the temporary directory - */ -//================================================================================ - -std::string ParaMEDMEMTest::getTmpDirectory() -{ - std::string path; - - std::list dirs; - if ( getenv("TMP") ) dirs.push_back( getenv("TMP" )); - if ( getenv("TMPDIR") ) dirs.push_back( getenv("TMPDIR" )); - dirs.push_back( "/tmp" ); - - std::string tmpd = ""; - for ( std::list::iterator dir = dirs.begin(); dir != dirs.end() && tmpd == "" ; ++dir ) { - if ( access( dir->data(), W_OK ) == 0 ) { - tmpd = dir->data(); - } - } - - if ( tmpd == "" ) - throw std::runtime_error("Can't find writable temporary directory. Set TMP environment variable"); - - return tmpd; -} - -//================================================================================ -/*! - * \brief Creates a copy of source file (if source file is specified) - * in the temporary directory and returns a path to the tmp file - * - * \param tmpfile name of the temporary file (without path) - * \param srcfile source file - * \return path to the temporary file - */ -//================================================================================ -std::string ParaMEDMEMTest::makeTmpFile( const std::string& tmpfile, const std::string& srcfile ) -{ - std::string tmpf = getTmpDirectory() + "/" + tmpfile; - if ( srcfile != "" ) { - std::string cmd = "cp " + srcfile + " " + tmpf + " ; chmod +w " + tmpf; - system( cmd.c_str() ); - } - return tmpf; -} - - -/*! - * Tool to remove temporary files. - * Allows automatique removal of temporary files in case of test failure. - */ -ParaMEDMEMTest_TmpFilesRemover::~ParaMEDMEMTest_TmpFilesRemover() -{ - std::set::iterator it = myTmpFiles.begin(); - for (; it != myTmpFiles.end(); it++) { - if (access((*it).data(), F_OK) == 0) - remove((*it).data()); - } - myTmpFiles.clear(); - //cout << "~ParaMEDMEMTest_TmpFilesRemover()" << endl; -} - -bool ParaMEDMEMTest_TmpFilesRemover::Register(const std::string theTmpFile) -{ - return (myTmpFiles.insert(theTmpFile)).second; -} diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx b/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx deleted file mode 100644 index be30599ae..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (C) 2007-2010 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 _ParaMEDMEMTEST_HXX_ -#define _ParaMEDMEMTEST_HXX_ - -#include - -#include -#include -#include -#include "mpi.h" - - -class ParaMEDMEMTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( ParaMEDMEMTest ); - CPPUNIT_TEST(testMPIProcessorGroup_constructor); - CPPUNIT_TEST(testMPIProcessorGroup_boolean); - CPPUNIT_TEST(testMPIProcessorGroup_rank); - CPPUNIT_TEST(testBlockTopology_constructor); - CPPUNIT_TEST(testBlockTopology_serialize); - CPPUNIT_TEST(testInterpKernelDEC_1D); - CPPUNIT_TEST(testInterpKernelDEC_2DCurve); - CPPUNIT_TEST(testInterpKernelDEC_2D); - CPPUNIT_TEST(testInterpKernelDEC2_2D); - CPPUNIT_TEST(testInterpKernelDEC_2DP0P1); - CPPUNIT_TEST(testInterpKernelDEC_3D); - CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P0); - CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P1P1P0); - CPPUNIT_TEST(testInterpKernelDEC2DM1D_P0P0); - CPPUNIT_TEST(testInterpKernelDECPartialProcs); - CPPUNIT_TEST(testInterpKernelDEC3DSurfEmptyBBox); - - CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D); - CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpDEC_2D); - CPPUNIT_TEST(testSynchronousEqualInterpKernelDEC_2D); - CPPUNIT_TEST(testSynchronousFasterSourceInterpKernelDEC_2D); - CPPUNIT_TEST(testSynchronousSlowerSourceInterpKernelDEC_2D); - CPPUNIT_TEST(testSynchronousSlowSourceInterpKernelDEC_2D); - CPPUNIT_TEST(testSynchronousFastSourceInterpKernelDEC_2D); - CPPUNIT_TEST(testAsynchronousEqualInterpKernelDEC_2D); - CPPUNIT_TEST(testAsynchronousFasterSourceInterpKernelDEC_2D); - CPPUNIT_TEST(testAsynchronousSlowerSourceInterpKernelDEC_2D); - CPPUNIT_TEST(testAsynchronousSlowSourceInterpKernelDEC_2D); - CPPUNIT_TEST(testAsynchronousFastSourceInterpKernelDEC_2D); -#ifdef MED_ENABLE_FVM - //can be added again after FVM correction for 2D - // CPPUNIT_TEST(testNonCoincidentDEC_2D); - CPPUNIT_TEST(testNonCoincidentDEC_3D); -#endif - CPPUNIT_TEST(testStructuredCoincidentDEC); - CPPUNIT_TEST(testStructuredCoincidentDEC); - CPPUNIT_TEST(testICocoTrio1); - CPPUNIT_TEST(testGauthier1); - CPPUNIT_TEST(testGauthier2); - CPPUNIT_TEST(testFabienAPI1); - CPPUNIT_TEST(testFabienAPI2); - CPPUNIT_TEST(testMEDLoaderRead1); - CPPUNIT_TEST(testMEDLoaderPolygonRead); - CPPUNIT_TEST(testMEDLoaderPolyhedronRead); - //CPPUNIT_TEST(testMEDLoaderWrite1); - //CPPUNIT_TEST(testMEDLoaderPolygonWrite); - CPPUNIT_TEST_SUITE_END(); - - -public: - - ParaMEDMEMTest():CppUnit::TestFixture(){} - ~ParaMEDMEMTest(){} - void setUp(){} - void tearDown(){} - void testMPIProcessorGroup_constructor(); - void testMPIProcessorGroup_boolean(); - void testMPIProcessorGroup_rank(); - void testBlockTopology_constructor(); - void testBlockTopology_serialize(); - void testInterpKernelDEC_1D(); - void testInterpKernelDEC_2DCurve(); - void testInterpKernelDEC_2D(); - void testInterpKernelDEC2_2D(); - void testInterpKernelDEC_2DP0P1(); - void testInterpKernelDEC_3D(); - void testInterpKernelDECNonOverlapp_2D_P0P0(); - void testInterpKernelDECNonOverlapp_2D_P0P1P1P0(); - void testInterpKernelDEC2DM1D_P0P0(); - void testInterpKernelDECPartialProcs(); - void testInterpKernelDEC3DSurfEmptyBBox(); -#ifdef MED_ENABLE_FVM - void testNonCoincidentDEC_2D(); - void testNonCoincidentDEC_3D(); -#endif - void testStructuredCoincidentDEC(); - void testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D(); - void testSynchronousEqualInterpKernelWithoutInterpDEC_2D(); - void testSynchronousEqualInterpKernelDEC_2D(); - void testSynchronousFasterSourceInterpKernelDEC_2D(); - void testSynchronousSlowerSourceInterpKernelDEC_2D(); - void testSynchronousSlowSourceInterpKernelDEC_2D(); - void testSynchronousFastSourceInterpKernelDEC_2D(); - - void testAsynchronousEqualInterpKernelDEC_2D(); - void testAsynchronousFasterSourceInterpKernelDEC_2D(); - void testAsynchronousSlowerSourceInterpKernelDEC_2D(); - void testAsynchronousSlowSourceInterpKernelDEC_2D(); - void testAsynchronousFastSourceInterpKernelDEC_2D(); - // - void testICocoTrio1(); - void testGauthier1(); - void testGauthier2(); - void testFabienAPI1(); - void testFabienAPI2(); - // - void testMEDLoaderRead1(); - void testMEDLoaderPolygonRead(); - void testMEDLoaderPolyhedronRead(); - void testMEDLoaderWrite1(); - void testMEDLoaderPolygonWrite(); - - std::string getResourceFile( const std::string& ); - std::string getTmpDirectory(); - std::string makeTmpFile( const std::string&, const std::string& = "" ); - -private: -#ifdef MED_ENABLE_FVM - void testNonCoincidentDEC(const std::string& filename1, - const std::string& meshname1, - const std::string& filename2, - const std::string& meshname2, - int nbprocsource, double epsilon); -#endif - void testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA, - double dtB, double tmaxB, - bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth); - void testInterpKernelDEC_2D_(const char *srcMeth, const char *targetMeth); - void testInterpKernelDEC2_2D_(const char *srcMeth, const char *targetMeth); - void testInterpKernelDEC_3D_(const char *srcMeth, const char *targetMeth); -}; - -// to automatically remove temporary files from disk -class ParaMEDMEMTest_TmpFilesRemover -{ -public: - ParaMEDMEMTest_TmpFilesRemover() {} - ~ParaMEDMEMTest_TmpFilesRemover(); - bool Register(const std::string theTmpFile); - -private: - std::set myTmpFiles; -}; - -/*! - * Tool to print array to stream. - */ -template -void ParaMEDMEMTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text) -{ - stream << text << ": {"; - if (length > 0) { - stream << array[0]; - for (int i = 1; i < length; i++) { - stream << ", " << array[i]; - } - } - stream << "}" << std::endl; -}; - -#endif diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx deleted file mode 100644 index 599d3fb57..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2007-2010 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 - -#include "MPI2Connector.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "InterpKernelDEC.hxx" -#include "MPIProcessorGroup.hxx" -#include "CommInterface.hxx" - -#include -#include -#include - -class MPI2ParaMEDMEMTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( MPI2ParaMEDMEMTest ); - CPPUNIT_TEST( testBasicMPI2_1 ); - CPPUNIT_TEST_SUITE_END(); -public: - void testBasicMPI2_1(); -}; - -using namespace ParaMEDMEM; - -void MPI2ParaMEDMEMTest::testBasicMPI2_1() -{ - int lsize, lrank, gsize, grank; - MPI_Comm gcom; - std::string service = "SERVICE"; - std::ostringstream meshfilename, meshname; - ParaMEDMEM::ParaMESH *paramesh=0; - ParaMEDMEM::MEDCouplingUMesh *mesh; - ParaMEDMEM::ParaFIELD *parafield=0; - ParaMEDMEM::CommInterface *interface; - ParaMEDMEM::MPIProcessorGroup *source, *target; - - MPI_Comm_size( MPI_COMM_WORLD, &lsize ); - MPI_Comm_rank( MPI_COMM_WORLD, &lrank ); - if(lsize!=2) - { - CPPUNIT_ASSERT(false); - return; - } - - /* Connection to remote programm */ - MPI2Connector *mpio = new MPI2Connector; - gcom = mpio->remoteMPI2Connect(service); - MPI_Comm_size( gcom, &gsize ); - MPI_Comm_rank( gcom, &grank ); - if(gsize!=5) - { - CPPUNIT_ASSERT(false); - return; - } - interface = new ParaMEDMEM::CommInterface; - source = new ParaMEDMEM::MPIProcessorGroup(*interface,0,lsize-1,gcom); - target = new ParaMEDMEM::MPIProcessorGroup(*interface,lsize,gsize-1,gcom); - - const double sourceCoordsAll[2][8]={{0.4,0.5,0.4,1.5,1.6,1.5,1.6,0.5}, - {0.3,-0.5,1.6,-0.5,1.6,-1.5,0.3,-1.5}}; - - int conn4All[8]={0,1,2,3,4,5,6,7}; - - std::ostringstream stream; stream << "sourcemesh2D proc " << grank; - mesh=MEDCouplingUMesh::New(stream.str().c_str(),2); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - const double *sourceCoords=sourceCoordsAll[grank]; - std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*source,"source mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - double *value=parafield->getField()->getArray()->getPointer(); - value[0]=34+13*((double)grank); - - ParaMEDMEM::InterpKernelDEC dec(*source,*target); - parafield->getField()->setNature(ConservativeVolumic); - - - dec.setMethod("P0"); - dec.attachLocalField(parafield); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.sendData(); - /* Deconnection of remote programm */ - mpio->remoteMPI2Disconnect(service); - /* clean-up */ - delete mpio; - delete parafield; - mesh->decrRef(); - delete paramesh; - delete source; - delete target; - delete interface; -} - -CPPUNIT_TEST_SUITE_REGISTRATION( MPI2ParaMEDMEMTest ); - -#include "MPIMainTest.hxx" diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx deleted file mode 100644 index 9ed8819b0..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2007-2010 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 - -#include "MPI2Connector.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "InterpKernelDEC.hxx" -#include "MPIProcessorGroup.hxx" -#include "CommInterface.hxx" - -#include -#include -#include - -class MPI2ParaMEDMEMTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( MPI2ParaMEDMEMTest ); - CPPUNIT_TEST( testBasicMPI2_1 ); - CPPUNIT_TEST_SUITE_END(); -public: - void testBasicMPI2_1(); -}; - -using namespace ParaMEDMEM; - -void MPI2ParaMEDMEMTest::testBasicMPI2_1() -{ - int lsize, lrank, gsize, grank; - MPI_Comm gcom; - std::string service = "SERVICE"; - std::ostringstream meshfilename, meshname; - ParaMEDMEM::ParaMESH *paramesh=0; - ParaMEDMEM::MEDCouplingUMesh* mesh; - ParaMEDMEM::ParaFIELD *parafield=0; - ParaMEDMEM::CommInterface* interface; - ParaMEDMEM::MPIProcessorGroup* source, *target; - - MPI_Comm_size( MPI_COMM_WORLD, &lsize ); - MPI_Comm_rank( MPI_COMM_WORLD, &lrank ); - if(lsize!=3) - { - CPPUNIT_ASSERT(false); - return; - } - - /* Connection to remote programm */ - MPI2Connector *mpio = new MPI2Connector; - gcom = mpio->remoteMPI2Connect(service); - - MPI_Comm_size( gcom, &gsize ); - MPI_Comm_rank( gcom, &grank ); - if(gsize!=5) - { - CPPUNIT_ASSERT(false); - return; - } - - interface = new ParaMEDMEM::CommInterface; - source = new ParaMEDMEM::MPIProcessorGroup(*interface,0,gsize-lsize-1,gcom); - target = new ParaMEDMEM::MPIProcessorGroup(*interface,gsize-lsize,gsize-1,gcom); - - const double targetCoordsAll[3][16]={{0.7,1.45,0.7,1.65,0.9,1.65,0.9,1.45, 1.1,1.4,1.1,1.6,1.3,1.6,1.3,1.4}, - {0.7,-0.6,0.7,0.7,0.9,0.7,0.9,-0.6, 1.1,-0.7,1.1,0.6,1.3,0.6,1.3,-0.7}, - {0.7,-1.55,0.7,-1.35,0.9,-1.35,0.9,-1.55, 1.1,-1.65,1.1,-1.45,1.3,-1.45,1.3,-1.65}}; - int conn4All[8]={0,1,2,3,4,5,6,7}; - double targetResults[3][2]={{34.,34.},{38.333333333333336,42.666666666666664},{47.,47.}}; - - std::ostringstream stream; stream << "targetmesh2D proc " << grank-(gsize-lsize); - mesh=MEDCouplingUMesh::New(stream.str().c_str(),2); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All+4); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(8,2); - const double *targetCoords=targetCoordsAll[grank-(gsize-lsize)]; - std::copy(targetCoords,targetCoords+16,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH (mesh,*target,"target mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - - ParaMEDMEM::InterpKernelDEC dec(*source,*target); - parafield->getField()->setNature(ConservativeVolumic); - - dec.setMethod("P0"); - dec.attachLocalField(parafield); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - const double *expected=targetResults[grank-(gsize-lsize)]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13); - /* Deconnection of remote programm */ - mpio->remoteMPI2Disconnect(service); - /* clean-up */ - delete mpio; - delete parafield; - mesh->decrRef(); - delete paramesh; - delete source; - delete target; - delete interface; -} - -CPPUNIT_TEST_SUITE_REGISTRATION( MPI2ParaMEDMEMTest ); - -#include "MPIMainTest.hxx" diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_BlockTopology.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_BlockTopology.cxx deleted file mode 100644 index 780b71f41..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_BlockTopology.cxx +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMEDMEMTest.hxx" -#include - -#include "InterpolationUtils.hxx" -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" - -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - - -using namespace std; -using namespace ParaMEDMEM; - -/* - * Check methods defined in BlockTopology.hxx - * - BlockTopology(){}; - BlockTopology(const ProcessorGroup& group, const MEDMEM::GRID& grid); - BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo); - (+) BlockTopology(const ProcessorGroup& group, int nb_elem); - virtual ~BlockTopology(); - (+) inline int getNbElements()const; - (+) inline int getNbLocalElements() const; - const ProcessorGroup* getProcGroup()const {return _proc_group;}; - (+) inline std::pair globalToLocal (const int) const ; - (+) inline int localToGlobal (const std::pair) const; - (+) std::vector > getLocalArrayMinMax() const ; - (+) int getDimension() const {return _dimension;}; - (+) void serialize(int* & serializer, int& size) const ; - (+) void unserialize(const int* serializer, const CommInterface& comm_interface); - - */ - -void ParaMEDMEMTest::testBlockTopology_constructor() -{ - //test constructor - int size; - MPI_Comm_size(MPI_COMM_WORLD,&size); - int rank; - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - CommInterface interface; - MPIProcessorGroup group(interface); - BlockTopology blocktopo(group,1); - CPPUNIT_ASSERT_EQUAL(1,blocktopo.getNbLocalElements()); - CPPUNIT_ASSERT_EQUAL(size,blocktopo.getNbElements()); - CPPUNIT_ASSERT_EQUAL(1,blocktopo.getDimension()); - - //checking access methods - BlockTopology blocktopo2(group,2); - std::pair local= blocktopo2.globalToLocal(0); - CPPUNIT_ASSERT_EQUAL(local.first,0); - CPPUNIT_ASSERT_EQUAL(local.second,0); - int global=blocktopo2.localToGlobal(local); - CPPUNIT_ASSERT_EQUAL(global,0); - - local = blocktopo2.globalToLocal(1); - CPPUNIT_ASSERT_EQUAL(local.first,0); - CPPUNIT_ASSERT_EQUAL(local.second,1); - global=blocktopo2.localToGlobal(local); - CPPUNIT_ASSERT_EQUAL(global,1); - - local = blocktopo2.globalToLocal(2*size-1); - CPPUNIT_ASSERT_EQUAL(local.first,size-1); - CPPUNIT_ASSERT_EQUAL(local.second,1); - global=blocktopo2.localToGlobal(local); - CPPUNIT_ASSERT_EQUAL(global,2*size-1); - - std::vector > bounds = blocktopo2.getLocalArrayMinMax(); - int vecsize = bounds.size(); - CPPUNIT_ASSERT_EQUAL(1,vecsize); - CPPUNIT_ASSERT_EQUAL(2*rank, (bounds[0]).first); - CPPUNIT_ASSERT_EQUAL(2*rank+2, (bounds[0]).second); - } - -void ParaMEDMEMTest::testBlockTopology_serialize() -{ - - int size; - MPI_Comm_size(MPI_COMM_WORLD,&size); - int rank; - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - CommInterface interface; - MPIProcessorGroup group(interface); - BlockTopology blocktopo(group,3); - -//testing the serialization process that is used to transfer a -//block topology via a MPI_Send/Recv comm - BlockTopology blocktopo_recv; - int* serializer; - int sersize; - blocktopo.serialize(serializer,sersize); - blocktopo_recv.unserialize(serializer,interface); - CPPUNIT_ASSERT_EQUAL(blocktopo.getNbElements(),blocktopo_recv.getNbElements()); - delete [] serializer; -} diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx deleted file mode 100644 index a08eb9995..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMEDMEMTest.hxx" -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "InterpKernelDEC.hxx" -#include "MEDCouplingUMesh.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "ComponentTopology.hxx" - -#include - -using namespace ParaMEDMEM; - -void ParaMEDMEMTest::testFabienAPI1() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=3) - return ; - int procs_source_c[1]={0}; - std::set procs_source(procs_source_c,procs_source_c+1); - int procs_target_c[1]={1}; - std::set procs_target(procs_target_c,procs_target_c+1); - // - ParaMEDMEM::MEDCouplingUMesh *mesh=0; - ParaMEDMEM::ParaMESH *paramesh=0; - ParaMEDMEM::ParaFIELD *parafield=0; - // - ParaMEDMEM::CommInterface interface; - // - MPI_Barrier(MPI_COMM_WORLD); - double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. }; - CommInterface comm; - // - ParaMEDMEM::InterpKernelDEC *dec=new ParaMEDMEM::InterpKernelDEC(procs_source,procs_target); - if(dec->isInSourceSide()) - { - mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - int targetConn[4]={0,2,3,1}; - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - mesh->finishInsertingCells(); - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*dec->getSourceGrp(),"source mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - double *vals=parafield->getField()->getArray()->getPointer(); - vals[0]=7.; - } - if(dec->isInTargetSide()) - { - mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - int targetConn[6]={0,2,1,2,3,1}; - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - mesh->finishInsertingCells(); - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*dec->getTargetGrp(),"target mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - } - dec->attachLocalField(parafield); - dec->synchronize(); - dec->sendRecvData(); - if(dec->isInTargetSide()) - { - const double *valsToTest=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[0],7.,1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[1],7.,1e-14); - } - // - delete parafield; - delete paramesh; - if(mesh) - mesh->decrRef(); - delete dec; - MPI_Barrier(MPI_COMM_WORLD); -} - -/*! - * Idem testFabienAPI1 except that procs are shuffled. Test of the good management of group translation in newly created communicator. - */ -void ParaMEDMEMTest::testFabienAPI2() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=3) - return ; - int procs_source_c[1]={2};//difference with testFabienAPI1 - std::set procs_source(procs_source_c,procs_source_c+1); - int procs_target_c[1]={1}; - std::set procs_target(procs_target_c,procs_target_c+1); - // - ParaMEDMEM::MEDCouplingUMesh *mesh=0; - ParaMEDMEM::ParaMESH *paramesh=0; - ParaMEDMEM::ParaFIELD *parafield=0; - // - ParaMEDMEM::CommInterface interface; - // - MPI_Barrier(MPI_COMM_WORLD); - double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. }; - CommInterface comm; - // - ParaMEDMEM::InterpKernelDEC *dec=new ParaMEDMEM::InterpKernelDEC(procs_source,procs_target); - if(dec->isInSourceSide()) - { - mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - int targetConn[4]={0,2,3,1}; - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - mesh->finishInsertingCells(); - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*dec->getSourceGrp(),"source mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - double *vals=parafield->getField()->getArray()->getPointer(); - vals[0]=7.; - } - if(dec->isInTargetSide()) - { - mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - int targetConn[6]={0,2,1,2,3,1}; - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - mesh->finishInsertingCells(); - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*dec->getTargetGrp(),"target mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - } - dec->attachLocalField(parafield); - dec->synchronize(); - dec->sendRecvData(); - if(dec->isInTargetSide()) - { - const double *valsToTest=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[0],7.,1e-14); - CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[1],7.,1e-14); - } - // - delete parafield; - delete paramesh; - if(mesh) - mesh->decrRef(); - delete dec; - MPI_Barrier(MPI_COMM_WORLD); -} diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx deleted file mode 100644 index 17cadfe05..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx +++ /dev/null @@ -1,434 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMEDMEMTest.hxx" -#include - -#include -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "DEC.hxx" -#include "InterpKernelDEC.hxx" -#include -#include -#include "ICoCoTrioField.hxx" -#include -#include -#include - -using namespace std; -using namespace ParaMEDMEM; -using namespace ICoCo; - -void afficheGauthier1( const TrioField& field, const double *vals, int lgth) -{ - CPPUNIT_ASSERT_EQUAL(lgth,field._nb_elems); - for (int ele=0;ele emetteur_ids; - set recepteur_ids; - emetteur_ids.insert(0); - if(size!=4) - return; - recepteur_ids.insert(1); - if (size >2) - recepteur_ids.insert(2); - if (size >2) - emetteur_ids.insert(3); - if ((rank==0)||(rank==1)) - is_master=1; - - MPIProcessorGroup recepteur_group(comm,recepteur_ids); - MPIProcessorGroup emetteur_group(comm,emetteur_ids); - - - string cas; - if (recepteur_group.containsMyRank()) - { - cas="recepteur"; - //freopen("recpeteur.out","w",stdout); - //freopen("recepteur.err","w",stderr); - - } - else - { - cas="emetteur"; - // freopen("emetteur.out","w",stdout); - //freopen("emetteur.err","w",stderr); - } - double expected[8][4]={ - {1.,1.,1.,1.}, - {40., 40., 1., 1.}, - {1.,1.,1e200,1e200}, - {40.,1.,1e200,1e200}, - {1.,1.,1.,1.}, - {40.,1.,1.,1.}, - {1.,1.,1e200,1e200}, - {20.5,1.,1e200,1e200} - }; - - int expectedLgth[8]={4,4,2,2,4,4,2,2}; - - for (int send=0;send<2;send++) - for (int rec=0;rec<2;rec++) - { - InterpKernelDEC dec_emetteur(emetteur_group, recepteur_group); - dec_emetteur.setOrientation(2); - TrioField champ_emetteur, champ_recepteur; - - if (send==0) - init_quadGauthier1(champ_emetteur,is_master); - else - init_triangleGauthier1(champ_emetteur,is_master); - if (rec==0) - init_triangleGauthier1(champ_recepteur,is_master); - else - init_quadGauthier1(champ_recepteur,is_master); - - if (cas=="emetteur") - { - champ_emetteur._field=new double[champ_emetteur._nb_elems]; - for (int ele=0;ele Genepi_ids; - set entree_chaude_ids; - Genepi_ids.insert(0); - for (int i=1;iP0 - vitesse._type=type; - } - - if (vitesse._type==1) - dec_vit_in_chaude.setMethod("P1"); - - - - dec_vit_in_chaude.attachLocalField((ICoCo::Field*) &vitesse); - - dec_vit_in_chaude.synchronize(); - - - // Envois - receptions - if (entree_chaude_group.containsMyRank()) - { - dec_vit_in_chaude.sendData(); - } - else - { - dec_vit_in_chaude.recvData(); - } - if (entree_chaude_group.containsMyRank() ) - { - if (1) - { - ostringstream save_vit(save_vit_in_2); - vitesse.save(save_vit); - } - } - else - { - - double pmin=1e38, pmax=-1e38; - - for(int i=0;ipmax) pmax=p; - } - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected1[type],pmin,1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[type],pmax,1e-12); - - ostringstream save_vit(save_vit_outs[type]); - vitesse.save(save_vit); - - for(int i=0;i -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "DEC.hxx" -#include "InterpKernelDEC.hxx" -#include -#include -#include "ICoCoTrioField.hxx" -#include -#include - -using namespace std; -using namespace ParaMEDMEM; -using namespace ICoCo; - -typedef enum {sync_and,sync_or} synctype; -void synchronize_bool(bool& stop, synctype s) -{ - int my_stop; - int my_stop_temp = stop?1:0; - if (s==sync_and) - MPI_Allreduce(&my_stop_temp,&my_stop,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD); - else if (s==sync_or) - MPI_Allreduce(&my_stop_temp,&my_stop,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD); - stop =(my_stop==1); -} - -void synchronize_dt(double& dt) -{ - double dttemp=dt; - MPI_Allreduce(&dttemp,&dt,1,MPI_DOUBLE,MPI_MIN,MPI_COMM_WORLD); -} - - -void affiche( const TrioField& field) -{ - cout < emetteur_ids; - set recepteur_ids; - emetteur_ids.insert(0); - recepteur_ids.insert(1); - - MPIProcessorGroup recepteur_group(comm,recepteur_ids); - MPIProcessorGroup emetteur_group(comm,emetteur_ids); - - - string cas; - if (recepteur_group.containsMyRank()) - { - cas="recepteur"; - - } - else - cas="emetteur"; - - InterpKernelDEC dec_emetteur(emetteur_group, recepteur_group); - - TrioField champ_emetteur, champ_recepteur; - - init_triangle(champ_emetteur); - //init_triangle(champ_emetteur); - init_quad(champ_recepteur); - //init_emetteur(champ_recepteur); - - if (cas=="emetteur") - { - champ_emetteur._field=new double[champ_emetteur._nb_elems]; - for (int ele=0;ele - -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "DEC.hxx" -#include "MxN_Mapping.hxx" -#include "InterpKernelDEC.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "ComponentTopology.hxx" -#include "ICoCoMEDField.hxx" -#include "ParaMEDLoader.hxx" -#include "MEDLoader.hxx" - - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - - -using namespace std; -using namespace ParaMEDMEM; - -void ParaMEDMEMTest::testInterpKernelDEC_2D() -{ - testInterpKernelDEC_2D_("P0","P0"); -} - -void ParaMEDMEMTest::testInterpKernelDEC2_2D() -{ - testInterpKernelDEC2_2D_("P0","P0"); -} - -void ParaMEDMEMTest::testInterpKernelDEC_3D() -{ - testInterpKernelDEC_3D_("P0","P0"); -} - -void ParaMEDMEMTest::testInterpKernelDEC_2DP0P1() -{ - //testInterpKernelDEC_2D_("P0","P1"); -} - -void ParaMEDMEMTest::testInterpKernelDEC_1D() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=5) - return ; - int nproc_source = 3; - set self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - if(rank==0) - { - double coords[4]={0.3,0.7, 0.9,1.0}; - int conn[4]={0,1,2,3}; - mesh=MEDCouplingUMesh::New("Source mesh Proc0",1); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,1); - std::copy(coords,coords+4,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - if(rank==1) - { - double coords[2]={0.7,0.9}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Source mesh Proc1",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,1); - std::copy(coords,coords+2,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - if(rank==2) - { - double coords[2]={1.,1.12}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Source mesh Proc2",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,1); - std::copy(coords,coords+2,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - paramesh=new ParaMESH(mesh,*source_group,"source mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - parafieldP0->getField()->setNature(ConservativeVolumic); - if(rank==0) - { - valueP0[0]=7.; valueP0[1]=8.; - } - if(rank==1) - { - valueP0[0]=9.; - } - if(rank==2) - { - valueP0[0]=10.; - } - } - else - { - const char targetMeshName[]="target mesh"; - if(rank==3) - { - double coords[2]={0.5,0.75}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Target mesh Proc3",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,1); - std::copy(coords,coords+2,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - } - if(rank==4) - { - double coords[2]={0.75,1.2}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Target mesh Proc4",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,1); - std::copy(coords,coords+2,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - } - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafieldP0->getField()->setNature(ConservativeVolumic); - } - // test 1 - ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); - if (source_group->containsMyRank()) - { - dec.setMethod("P0"); - dec.attachLocalField(parafieldP0); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.sendData(); - dec.recvData(); - const double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - if(rank==0) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7); - } - if(rank==1) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7); - } - if(rank==2) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7); - } - } - else - { - dec.setMethod("P0"); - dec.attachLocalField(parafieldP0); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.recvData(); - const double *res=parafieldP0->getField()->getArray()->getConstPointer(); - if(rank==3) - { - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12); - } - if(rank==4) - { - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12); - } - dec.sendData(); - } - // - delete parafieldP0; - mesh->decrRef(); - delete paramesh; - delete self_group; - delete target_group; - delete source_group; - // - MPI_Barrier(MPI_COMM_WORLD); -} - -void ParaMEDMEMTest::testInterpKernelDEC_2DCurve() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=5) - return ; - int nproc_source = 3; - set self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - if(rank==0) - { - double coords[8]={0.3,0.3,0.7,0.7, 0.9,0.9,1.0,1.0}; - int conn[4]={0,1,2,3}; - mesh=MEDCouplingUMesh::New("Source mesh Proc0",1); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(coords,coords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - if(rank==1) - { - double coords[4]={0.7,0.7,0.9,0.9}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Source mesh Proc1",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,2); - std::copy(coords,coords+4,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - if(rank==2) - { - double coords[4]={1.,1.,1.12,1.12}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Source mesh Proc2",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,2); - std::copy(coords,coords+4,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - paramesh=new ParaMESH(mesh,*source_group,"source mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - parafieldP0->getField()->setNature(ConservativeVolumic); - if(rank==0) - { - valueP0[0]=7.; valueP0[1]=8.; - } - if(rank==1) - { - valueP0[0]=9.; - } - if(rank==2) - { - valueP0[0]=10.; - } - } - else - { - const char targetMeshName[]="target mesh"; - if(rank==3) - { - double coords[4]={0.5,0.5,0.75,0.75}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Target mesh Proc3",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,2); - std::copy(coords,coords+4,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - } - if(rank==4) - { - double coords[4]={0.75,0.75,1.2,1.2}; - int conn[2]={0,1}; - mesh=MEDCouplingUMesh::New("Target mesh Proc4",1); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(2,2); - std::copy(coords,coords+4,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - } - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafieldP0->getField()->setNature(ConservativeVolumic); - } - // test 1 - ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); - if (source_group->containsMyRank()) - { - dec.setMethod("P0"); - dec.attachLocalField(parafieldP0); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.sendData(); - dec.recvData(); - const double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - if(rank==0) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7); - } - if(rank==1) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7); - } - if(rank==2) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7); - } - } - else - { - dec.setMethod("P0"); - dec.attachLocalField(parafieldP0); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.recvData(); - const double *res=parafieldP0->getField()->getArray()->getConstPointer(); - if(rank==3) - { - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12); - } - if(rank==4) - { - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12); - } - dec.sendData(); - } - // - delete parafieldP0; - mesh->decrRef(); - delete paramesh; - delete self_group; - delete target_group; - delete source_group; - // - MPI_Barrier(MPI_COMM_WORLD); -} - - -/* - * Check methods defined in InterpKernelDEC.hxx - * - InterpKernelDEC(); - InterpKernelDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group); - virtual ~InterpKernelDEC(); - void synchronize(); - void recvData(); - void sendData(); -*/ - -void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *targetMeth) -{ - std::string srcM(srcMeth); - std::string targetM(targetMeth); - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - - //the test is meant to run on five processors - if (size !=5) return ; - - int nproc_source = 3; - set self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - string master = filename_xml1; - - ostringstream strstream; - strstream <getField()->setNature(ConservativeVolumic); - } - else - parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - int nb_local; - if(srcM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - // double * value= new double[nb_local]; - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - dec.setMethod(srcMeth); - dec.attachLocalField(icocofield); - } - - //loading the geometry for the target group - if (target_group->containsMyRank()) - { - string master= filename_xml2; - ostringstream strstream; - strstream << master<<(rank-nproc_source+1)<<".med"; - ostringstream meshname ; - meshname<< "Mesh_3_"<getField()->setNature(ConservativeVolumic); - } - else - parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - int nb_local; - if(targetM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - // double * value= new double[nb_local]; - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - dec.setMethod(targetMeth); - dec.attachLocalField(icocofield); - } - - - //attaching a DEC to the source group - double field_before_int; - double field_after_int; - - if (source_group->containsMyRank()) - { - field_before_int = parafield->getVolumeIntegral(0,true); - dec.synchronize(); - cout<<"DEC usage"<myRank()==0) - aRemover.Register("./sourcesquareb"); - ostringstream filename; - filename<<"./sourcesquareb_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - //MEDLoader::WriteField("./sourcesquareb",parafield->getField()); - - dec.recvData(); - cout <<"writing"<myRank()==0) - aRemover.Register("./sourcesquare"); - //MEDLoader::WriteField("./sourcesquare",parafield->getField()); - - - filename<<"./sourcesquare_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - field_after_int = parafield->getVolumeIntegral(0,true); - - - // MPI_Bcast(&field_before_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD); - // MPI_Bcast(&field_after_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6); - - } - - //attaching a DEC to the target group - if (target_group->containsMyRank()) - { - dec.synchronize(); - dec.setForcedRenormalization(false); - - dec.recvData(); - ParaMEDLoader::WriteParaMesh("./targetsquareb",paramesh); - //MEDLoader::WriteField("./targetsquareb",parafield->getField()); - if (target_group->myRank()==0) - aRemover.Register("./targetsquareb"); - ostringstream filename; - filename<<"./targetsquareb_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - dec.sendData(); - ParaMEDLoader::WriteParaMesh("./targetsquare",paramesh); - //MEDLoader::WriteField("./targetsquare",parafield->getField()); - - if (target_group->myRank()==0) - aRemover.Register("./targetsquareb"); - - filename<<"./targetsquareb_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - // double field_before_int, field_after_int; - // MPI_Bcast(&field_before_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD); - // MPI_Bcast(&field_after_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD); - - // CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6); - - } - - delete source_group; - delete target_group; - delete self_group; - delete parafield; - delete paramesh; - mesh->decrRef(); - - delete icocofield; - - MPI_Barrier(MPI_COMM_WORLD); - cout << "end of InterpKernelDEC_2D test"< self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - string master = filename_xml1; - - ostringstream strstream; - strstream <setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mcfield->getNumberOfTuples(),1); - mcfield->setArray(array); - array->decrRef(); - mcfield->setNature(ConservativeVolumic); - } - else - { - mcfield = MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - mcfield->setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mcfield->getNumberOfTuples(),1); - mcfield->setArray(array); - array->decrRef(); - } - int nb_local; - if(srcM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - double *value=mcfield->getArray()->getPointer(); - for(int ielem=0; ielemcontainsMyRank()) - { - string master= filename_xml2; - ostringstream strstream; - strstream << master<<(rank-nproc_source+1)<<".med"; - ostringstream meshname ; - meshname<< "Mesh_3_"<setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mcfield->getNumberOfTuples(),1); - mcfield->setArray(array); - array->decrRef(); - mcfield->setNature(ConservativeVolumic); - } - else - { - mcfield = MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); - mcfield->setMesh(mesh); - DataArrayDouble *array=DataArrayDouble::New(); - array->alloc(mcfield->getNumberOfTuples(),1); - mcfield->setArray(array); - array->decrRef(); - } - int nb_local; - if(targetM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - double *value=mcfield->getArray()->getPointer(); - for(int ielem=0; ielemcontainsMyRank()) - { - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.sendData(); - dec.recvData(); - } - - //attaching a DEC to the target group - if (target_group->containsMyRank()) - { - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.recvData(); - dec.sendData(); - } - delete source_group; - delete target_group; - delete self_group; - mcfield->decrRef(); - mesh->decrRef(); - - MPI_Barrier(MPI_COMM_WORLD); - cout << "end of InterpKernelDEC2_2D test"< self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - string master = filename_xml1; - - ostringstream strstream; - strstream <getField()->setNature(ConservativeVolumic); - } - else - parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - int nb_local; - if(srcM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - // double * value= new double[nb_local]; - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - dec.setMethod(srcMeth); - dec.attachLocalField(icocofield); - } - - //loading the geometry for the target group - if (target_group->containsMyRank()) - { - string master= filename_xml2; - ostringstream strstream; - strstream << master << ".med"; - ostringstream meshname ; - meshname<< "Mesh_6"; - mesh = MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0); - - paramesh=new ParaMESH (mesh,*target_group,"target mesh"); - // ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT(support,*target_group); - ParaMEDMEM::ComponentTopology comptopo; - if(targetM=="P0") - { - parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - } - else - parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - int nb_local; - if(targetM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - // double * value= new double[nb_local]; - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - dec.setMethod(targetMeth); - dec.attachLocalField(icocofield); - } - //attaching a DEC to the source group - double field_before_int; - double field_after_int; - - if (source_group->containsMyRank()) - { - field_before_int = parafield->getVolumeIntegral(0,true); - dec.synchronize(); - cout<<"DEC usage"<myRank()==0) - aRemover.Register("./sourcesquareb"); - ostringstream filename; - filename<<"./sourcesquareb_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - //MEDLoader::WriteField("./sourcesquareb",parafield->getField()); - - dec.recvData(); - cout <<"writing"<myRank()==0) - aRemover.Register("./sourcesquare"); - //MEDLoader::WriteField("./sourcesquare",parafield->getField()); - - - filename<<"./sourcesquare_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - field_after_int = parafield->getVolumeIntegral(0,true); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6); - - } - - //attaching a DEC to the target group - if (target_group->containsMyRank()) - { - dec.synchronize(); - dec.setForcedRenormalization(false); - - dec.recvData(); - ParaMEDLoader::WriteParaMesh("./targetsquareb",paramesh); - //MEDLoader::WriteField("./targetsquareb",parafield->getField()); - if (target_group->myRank()==0) - aRemover.Register("./targetsquareb"); - ostringstream filename; - filename<<"./targetsquareb_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - dec.sendData(); - ParaMEDLoader::WriteParaMesh("./targetsquare",paramesh); - //MEDLoader::WriteField("./targetsquare",parafield->getField()); - - if (target_group->myRank()==0) - aRemover.Register("./targetsquareb"); - - filename<<"./targetsquareb_"<myRank()+1; - aRemover.Register(filename.str().c_str()); - } - delete source_group; - delete target_group; - delete self_group; - delete parafield; - delete paramesh; - mesh->decrRef(); - - delete icocofield; - - MPI_Barrier(MPI_COMM_WORLD); - cout << "end of InterpKernelDEC_3D test"< self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - std::ostringstream stream; stream << "sourcemesh2D proc " << rank; - mesh=MEDCouplingUMesh::New(stream.str().c_str(),2); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - const double *sourceCoords=sourceCoordsAll[rank]; - std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*source_group,"source mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - double *value=parafield->getField()->getArray()->getPointer(); - value[0]=34+13*((double)rank); - } - else - { - std::ostringstream stream; stream << "targetmesh2D proc " << rank-nproc_source; - mesh=MEDCouplingUMesh::New(stream.str().c_str(),2); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All+4); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(8,2); - const double *targetCoords=targetCoordsAll[rank-nproc_source]; - std::copy(targetCoords,targetCoords+16,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH (mesh,*target_group,"target mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - } - //test 1 - Conservative volumic - ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); - parafield->getField()->setNature(ConservativeVolumic); - if (source_group->containsMyRank()) - { - dec.setMethod("P0"); - dec.attachLocalField(parafield); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.sendData(); - } - else - { - dec.setMethod("P0"); - dec.attachLocalField(parafield); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - const double *expected=targetResults[rank-nproc_source]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13); - } - //test 2 - Integral - ParaMEDMEM::InterpKernelDEC dec2(*source_group,*target_group); - parafield->getField()->setNature(Integral); - if (source_group->containsMyRank()) - { - dec2.setMethod("P0"); - dec2.attachLocalField(parafield); - dec2.synchronize(); - dec2.setForcedRenormalization(false); - dec2.sendData(); - } - else - { - dec2.setMethod("P0"); - dec2.attachLocalField(parafield); - dec2.synchronize(); - dec2.setForcedRenormalization(false); - dec2.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - const double *expected=targetResults2[rank-nproc_source]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13); - } - //test 3 - Integral with global constraint - ParaMEDMEM::InterpKernelDEC dec3(*source_group,*target_group); - parafield->getField()->setNature(IntegralGlobConstraint); - if (source_group->containsMyRank()) - { - dec3.setMethod("P0"); - dec3.attachLocalField(parafield); - dec3.synchronize(); - dec3.setForcedRenormalization(false); - dec3.sendData(); - } - else - { - dec3.setMethod("P0"); - dec3.attachLocalField(parafield); - dec3.synchronize(); - dec3.setForcedRenormalization(false); - dec3.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - const double *expected=targetResults3[rank-nproc_source]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13); - } - //test 4 - RevIntegral - ParaMEDMEM::InterpKernelDEC dec4(*source_group,*target_group); - parafield->getField()->setNature(RevIntegral); - if (source_group->containsMyRank()) - { - dec4.setMethod("P0"); - dec4.attachLocalField(parafield); - dec4.synchronize(); - dec4.setForcedRenormalization(false); - dec4.sendData(); - } - else - { - dec4.setMethod("P0"); - dec4.attachLocalField(parafield); - dec4.synchronize(); - dec4.setForcedRenormalization(false); - dec4.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - const double *expected=targetResults4[rank-nproc_source]; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13); - } - //test 5 - Conservative volumic reversed - ParaMEDMEM::InterpKernelDEC dec5(*source_group,*target_group); - parafield->getField()->setNature(ConservativeVolumic); - if (source_group->containsMyRank()) - { - dec5.setMethod("P0"); - dec5.attachLocalField(parafield); - dec5.synchronize(); - dec5.setForcedRenormalization(false); - dec5.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples()); - const double expected[]={37.8518518518519,43.5333333333333}; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13); - } - else - { - dec5.setMethod("P0"); - dec5.attachLocalField(parafield); - dec5.synchronize(); - dec5.setForcedRenormalization(false); - double *res=parafield->getField()->getArray()->getPointer(); - const double *toSet=targetResults[rank-nproc_source]; - res[0]=toSet[0]; - res[1]=toSet[1]; - dec5.sendData(); - } - //test 6 - Integral reversed - ParaMEDMEM::InterpKernelDEC dec6(*source_group,*target_group); - parafield->getField()->setNature(Integral); - if (source_group->containsMyRank()) - { - dec6.setMethod("P0"); - dec6.attachLocalField(parafield); - dec6.synchronize(); - dec6.setForcedRenormalization(false); - dec6.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples()); - const double expected[]={0.794600591715977,1.35631163708087}; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13); - } - else - { - dec6.setMethod("P0"); - dec6.attachLocalField(parafield); - dec6.synchronize(); - dec6.setForcedRenormalization(false); - double *res=parafield->getField()->getArray()->getPointer(); - const double *toSet=targetResults2[rank-nproc_source]; - res[0]=toSet[0]; - res[1]=toSet[1]; - dec6.sendData(); - } - //test 7 - Integral with global constraint reversed - ParaMEDMEM::InterpKernelDEC dec7(*source_group,*target_group); - parafield->getField()->setNature(IntegralGlobConstraint); - if (source_group->containsMyRank()) - { - dec7.setMethod("P0"); - dec7.attachLocalField(parafield); - dec7.synchronize(); - dec7.setForcedRenormalization(false); - dec7.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples()); - const double expected[]={36.4592592592593,44.5407407407407}; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13); - } - else - { - dec7.setMethod("P0"); - dec7.attachLocalField(parafield); - dec7.synchronize(); - dec7.setForcedRenormalization(false); - double *res=parafield->getField()->getArray()->getPointer(); - const double *toSet=targetResults3[rank-nproc_source]; - res[0]=toSet[0]; - res[1]=toSet[1]; - dec7.sendData(); - } - //test 8 - Integral with RevIntegral reversed - ParaMEDMEM::InterpKernelDEC dec8(*source_group,*target_group); - parafield->getField()->setNature(RevIntegral); - if (source_group->containsMyRank()) - { - dec8.setMethod("P0"); - dec8.attachLocalField(parafield); - dec8.synchronize(); - dec8.setForcedRenormalization(false); - dec8.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples()); - const double expected[]={0.81314102564102553,1.3428994082840233}; - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13); - } - else - { - dec8.setMethod("P0"); - dec8.attachLocalField(parafield); - dec8.synchronize(); - dec8.setForcedRenormalization(false); - double *res=parafield->getField()->getArray()->getPointer(); - const double *toSet=targetResults4[rank-nproc_source]; - res[0]=toSet[0]; - res[1]=toSet[1]; - dec8.sendData(); - } - // - delete parafield; - mesh->decrRef(); - delete paramesh; - delete self_group; - delete target_group; - delete source_group; - // - MPI_Barrier(MPI_COMM_WORLD); -} - -void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=5) - return ; - int nproc_source = 2; - set self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - if(rank==0) - { - double coords[6]={-0.3,-0.3, 0.7,0.7, 0.7,-0.3}; - int conn[3]={0,1,2}; - //int globalNode[3]={1,2,0}; - mesh=MEDCouplingUMesh::New("Source mesh Proc0",2); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(3,2); - std::copy(coords,coords+6,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - if(rank==1) - { - double coords[6]={-0.3,-0.3, -0.3,0.7, 0.7,0.7}; - int conn[3]={0,1,2}; - //int globalNode[3]={1,3,2}; - mesh=MEDCouplingUMesh::New("Source mesh Proc1",2); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(3,2); - std::copy(coords,coords+6,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - } - paramesh=new ParaMESH(mesh,*source_group,"source mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafieldP1 = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - double *valueP1=parafieldP1->getField()->getArray()->getPointer(); - parafieldP0->getField()->setNature(ConservativeVolumic); - parafieldP1->getField()->setNature(ConservativeVolumic); - if(rank==0) - { - valueP0[0]=31.; - valueP1[0]=34.; valueP1[1]=77.; valueP1[2]=53.; - } - if(rank==1) - { - valueP0[0]=47.; - valueP1[0]=34.; valueP1[1]=57.; valueP1[2]=77.; - } - } - else - { - const char targetMeshName[]="target mesh"; - if(rank==2) - { - double coords[10]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2 }; - int conn[7]={0,3,4,1, 1,4,2}; - //int globalNode[5]={4,3,0,2,1}; - mesh=MEDCouplingUMesh::New("Target mesh Proc2",2); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+4); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(5,2); - std::copy(coords,coords+10,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - DataArrayInt *da=DataArrayInt::New(); - const int globalNumberingP2[5]={0,1,2,3,4}; - da->useArray(globalNumberingP2,false,CPP_DEALLOC,5,1); - paramesh->setNodeGlobal(da); - da->decrRef(); - } - if(rank==3) - { - double coords[6]={0.2,0.2, 0.7,-0.3, 0.7,0.2}; - int conn[3]={0,2,1}; - //int globalNode[3]={1,0,5}; - mesh=MEDCouplingUMesh::New("Target mesh Proc3",2); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(3,2); - std::copy(coords,coords+6,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - DataArrayInt *da=DataArrayInt::New(); - const int globalNumberingP3[3]={4,2,5}; - da->useArray(globalNumberingP3,false,CPP_DEALLOC,3,1); - paramesh->setNodeGlobal(da); - da->decrRef(); - } - if(rank==4) - { - double coords[12]={-0.3,0.2, -0.3,0.7, 0.2,0.7, 0.2,0.2, 0.7,0.7, 0.7,0.2}; - int conn[8]={0,1,2,3, 3,2,4,5}; - //int globalNode[6]={2,6,7,1,8,5}; - mesh=MEDCouplingUMesh::New("Target mesh Proc4",2); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+4); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(6,2); - std::copy(coords,coords+12,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - DataArrayInt *da=DataArrayInt::New(); - const int globalNumberingP4[6]={3,6,7,4,8,5}; - da->useArray(globalNumberingP4,false,CPP_DEALLOC,6,1); - paramesh->setNodeGlobal(da); - da->decrRef(); - } - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafieldP1 = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - parafieldP0->getField()->setNature(ConservativeVolumic); - parafieldP1->getField()->setNature(ConservativeVolumic); - } - // test 1 - P0 P1 - ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); - if (source_group->containsMyRank()) - { - dec.setMethod("P0"); - dec.attachLocalField(parafieldP0); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.sendData(); - dec.recvData(); - const double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - if(rank==0) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(34.42857143,valueP0[0],1e-7); - } - if(rank==1) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(44.,valueP0[0],1e-7); - } - } - else - { - dec.setMethod("P1"); - dec.attachLocalField(parafieldP1); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.recvData(); - const double *res=parafieldP1->getField()->getArray()->getConstPointer(); - if(rank==2) - { - const double expectP2[5]={39.0, 31.0, 31.0, 47.0, 39.0}; - CPPUNIT_ASSERT_EQUAL(5,parafieldP1->getField()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,parafieldP1->getField()->getNumberOfComponents()); - for(int kk=0;kk<5;kk++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expectP2[kk],res[kk],1e-12); - } - if(rank==3) - { - const double expectP3[3]={39.0, 31.0, 31.0}; - CPPUNIT_ASSERT_EQUAL(3,parafieldP1->getField()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,parafieldP1->getField()->getNumberOfComponents()); - for(int kk=0;kk<3;kk++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expectP3[kk],res[kk],1e-12); - } - if(rank==4) - { - const double expectP4[6]={47.0, 47.0, 47.0, 39.0, 39.0, 31.0}; - CPPUNIT_ASSERT_EQUAL(6,parafieldP1->getField()->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,parafieldP1->getField()->getNumberOfComponents()); - for(int kk=0;kk<6;kk++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expectP4[kk],res[kk],1e-12); - } - dec.sendData(); - } - // - delete parafieldP0; - delete parafieldP1; - mesh->decrRef(); - delete paramesh; - delete self_group; - delete target_group; - delete source_group; - // - MPI_Barrier(MPI_COMM_WORLD); -} - -void ParaMEDMEMTest::testInterpKernelDEC2DM1D_P0P0() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=3) - return ; - int nproc_source=2; - set procs_source; - set procs_target; - // - for (int i=0; icontainsMyRank()) - { - double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; - mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,2); - std::copy(targetCoords,targetCoords+18,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - if(rank==0) - { - int targetConn[7]={0,3,4,1, 1,4,2}; - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - mesh->finishInsertingCells(); - } - else - { - int targetConn[11]={4,5,2, 6,7,4,3, 7,8,5,4}; - mesh->allocateCells(3); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+3); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+7); - mesh->finishInsertingCells(); - } - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*source_group,"source mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - double *vals=parafield->getField()->getArray()->getPointer(); - if(rank==0) - { vals[0]=7.; vals[1]=8.; } - else - { vals[0]=9.; vals[1]=10.; vals[2]=11.; } - } - else - { - mesh=MEDCouplingUMesh::New("an example of -1 D mesh",-1); - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*target_group,"target mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - } - ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); - if(source_group->containsMyRank()) - { - dec.setMethod("P0"); - dec.attachLocalField(parafield); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.sendData(); - dec.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - if(rank==0) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12); - } - else - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[2],1e-12); - } - } - else - { - dec.setMethod("P0"); - dec.attachLocalField(parafield); - dec.synchronize(); - dec.setForcedRenormalization(false); - dec.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12); - dec.sendData(); - } - ParaMEDMEM::InterpKernelDEC dec2(*source_group,*target_group); - dec2.setMethod("P0"); - parafield->getField()->setNature(IntegralGlobConstraint); - if(source_group->containsMyRank()) - { - double *vals=parafield->getField()->getArray()->getPointer(); - if(rank==0) - { vals[0]=7.; vals[1]=8.; } - else - { vals[0]=9.; vals[1]=10.; vals[2]=11.; } - dec2.attachLocalField(parafield); - dec2.synchronize(); - dec2.sendData(); - dec2.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - if(rank==0) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[1],1e-12); - } - else - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[2],1e-12); - } - } - else - { - dec2.attachLocalField(parafield); - dec2.synchronize(); - dec2.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(45.,res[0],1e-12); - dec2.sendData(); - } - // - ParaMEDMEM::InterpKernelDEC dec3(*source_group,*target_group); - dec3.setMethod("P0"); - parafield->getField()->setNature(Integral); - if(source_group->containsMyRank()) - { - double *vals=parafield->getField()->getArray()->getPointer(); - if(rank==0) - { vals[0]=7.; vals[1]=8.; } - else - { vals[0]=9.; vals[1]=10.; vals[2]=11.; } - dec3.attachLocalField(parafield); - dec3.synchronize(); - dec3.sendData(); - dec3.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - if(rank==0) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[1],1e-12); - } - else - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[2],1e-12); - } - } - else - { - dec3.attachLocalField(parafield); - dec3.synchronize(); - dec3.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(45.,res[0],1e-12); - dec3.sendData(); - } - // - ParaMEDMEM::InterpKernelDEC dec4(*source_group,*target_group); - dec4.setMethod("P0"); - parafield->getField()->setNature(RevIntegral); - if(source_group->containsMyRank()) - { - double *vals=parafield->getField()->getArray()->getPointer(); - if(rank==0) - { vals[0]=7.; vals[1]=8.; } - else - { vals[0]=9.; vals[1]=10.; vals[2]=11.; } - dec4.attachLocalField(parafield); - dec4.synchronize(); - dec4.sendData(); - dec4.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - if(rank==0) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12); - } - else - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[2],1e-12); - } - } - else - { - dec4.attachLocalField(parafield); - dec4.synchronize(); - dec4.recvData(); - const double *res=parafield->getField()->getArray()->getConstPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12); - dec4.sendData(); - } - delete parafield; - delete paramesh; - mesh->decrRef(); - delete target_group; - delete source_group; - // - MPI_Barrier(MPI_COMM_WORLD); -} - -void ParaMEDMEMTest::testInterpKernelDECPartialProcs() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=3) - return ; - set procs_source; - set procs_target; - // - procs_source.insert(0); - procs_target.insert(1); - // - ParaMEDMEM::MEDCouplingUMesh *mesh=0; - ParaMEDMEM::ParaMESH *paramesh=0; - ParaMEDMEM::ParaFIELD *parafield=0; - // - ParaMEDMEM::CommInterface interface; - // - MPI_Barrier(MPI_COMM_WORLD); - double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. }; - CommInterface comm; - int grpIds[2]={0,1}; - MPI_Group grp,group_world; - comm.commGroup(MPI_COMM_WORLD,&group_world); - comm.groupIncl(group_world,2,grpIds,&grp); - MPI_Comm partialComm; - comm.commCreate(MPI_COMM_WORLD,grp,&partialComm); - // - ProcessorGroup* target_group=0; - ProcessorGroup* source_group=0; - // - ParaMEDMEM::InterpKernelDEC *dec=0; - if(rank==0 || rank==1) - { - target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target,partialComm); - source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source,partialComm); - if(source_group->containsMyRank()) - { - mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - int targetConn[4]={0,2,3,1}; - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - mesh->finishInsertingCells(); - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*source_group,"source mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - double *vals=parafield->getField()->getArray()->getPointer(); - vals[0]=7.; - dec=new ParaMEDMEM::InterpKernelDEC(*source_group,*target_group); - dec->attachLocalField(parafield); - dec->synchronize(); - dec->sendData(); - dec->recvData(); - } - else - { - mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,2); - std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - int targetConn[6]={0,2,1,2,3,1}; - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); - mesh->finishInsertingCells(); - ParaMEDMEM::ComponentTopology comptopo; - paramesh=new ParaMESH(mesh,*target_group,"target mesh"); - parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafield->getField()->setNature(ConservativeVolumic); - dec=new ParaMEDMEM::InterpKernelDEC(*source_group,*target_group); - dec->attachLocalField(parafield); - dec->synchronize(); - dec->recvData(); - dec->sendData(); - } - } - delete parafield; - delete paramesh; - if(mesh) - mesh->decrRef(); - delete target_group; - delete source_group; - delete dec; - MPI_Barrier(MPI_COMM_WORLD); -} - -/*! - * This test reproduces bug of Gauthier on 13/9/2010 concerning 3DSurf meshes. - * It is possible to lead to dead lock in InterpKernelDEC when 3DSurfMeshes global bounding boxes intersects whereas cell bounding box intersecting only on one side. - */ -void ParaMEDMEMTest::testInterpKernelDEC3DSurfEmptyBBox() -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - // - if(size!=3) - return ; - int nproc_source = 1; - set self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - double coords[15]={1.,0.,0., 2.,0.,0., 2.,2.,0., 0.,2.,0., 0.5,0.5,1.}; - int conn[4]={0,1,2,3}; - mesh=MEDCouplingUMesh::New("Source mesh Proc0",2); - mesh->allocateCells(2); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,2,conn+4); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(5,3); - std::copy(coords,coords+15,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - // - paramesh=new ParaMESH(mesh,*source_group,"source mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - parafieldP0->getField()->setNature(ConservativeVolumic); - valueP0[0]=7.; valueP0[1]=8.; - } - else - { - const char targetMeshName[]="target mesh"; - if(rank==1) - { - double coords[12]={0.25,0.25,0.5, 0.,0.25,0.5, 0.,0.,0.5, 0.25,0.,0.5}; - int conn[4]={0,1,2,3}; - mesh=MEDCouplingUMesh::New("Target mesh Proc1",2); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,3); - std::copy(coords,coords+12,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - } - if(rank==2) - { - double coords[12]={0.,0.25,0.5, 0.,0.,0.5, -1.,0.,0.5, -1.,0.25,0.5}; - int conn[4]={0,1,2,3}; - mesh=MEDCouplingUMesh::New("Target mesh Proc2",2); - mesh->allocateCells(1); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(4,3); - std::copy(coords,coords+12,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - paramesh=new ParaMESH(mesh,*target_group,targetMeshName); - } - ParaMEDMEM::ComponentTopology comptopo; - parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - parafieldP0->getField()->setNature(ConservativeVolumic); - } - // test 1 - ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); - if (source_group->containsMyRank()) - { - dec.setMethod("P0"); - dec.attachLocalField(parafieldP0); - dec.synchronize(); - // dec.setForcedRenormalization(false); - // dec.sendData(); - // dec.recvData(); - // const double *valueP0=parafieldP0->getField()->getArray()->getPointer(); - // if(rank==0) - // { - // CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7); - // } - // if(rank==1) - // { - // CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7); - // } - // if(rank==2) - // { - // CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7); - // } - } - else - { - dec.setMethod("P0"); - dec.attachLocalField(parafieldP0); - dec.synchronize(); - // dec.setForcedRenormalization(false); - // dec.recvData(); - // const double *res=parafieldP0->getField()->getArray()->getConstPointer(); - // if(rank==3) - // { - // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); - // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12); - // } - // if(rank==4) - // { - // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); - // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); - // CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12); - // } - // dec.sendData(); - } - // - delete parafieldP0; - mesh->decrRef(); - delete paramesh; - delete self_group; - delete target_group; - delete source_group; - // - MPI_Barrier(MPI_COMM_WORLD); -} - -/*! - * Tests an asynchronous exchange between two codes - * one sends data with dtA as an interval, the max time being tmaxA - * the other one receives with dtB as an interval, the max time being tmaxB - */ -void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA, - double dtB, double tmaxB, bool WithPointToPoint, bool Asynchronous, - bool WithInterp, const char *srcMeth, const char *targetMeth) -{ - std::string srcM(srcMeth); - std::string targetM(targetMeth); - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - - //the test is meant to run on five processors - if (size !=5) return ; - - int nproc_source = 3; - set self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()) - { - string master = filename_xml1; - - ostringstream strstream; - strstream <getField()->setNature(ConservativeVolumic);//InvertIntegral);//ConservativeVolumic); - } - else - parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - - int nb_local; - if(srcM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - // double * value= new double[nb_local]; - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - - dec.attachLocalField(icocofield); - - - } - - //loading the geometry for the target group - if (target_group->containsMyRank()) - { - string master= filename_xml2; - ostringstream strstream; - strstream << master<<(rank-nproc_source+1)<<".med"; - ostringstream meshname ; - meshname<< "Mesh_3_"<getField()->setNature(ConservativeVolumic);//InvertIntegral);//ConservativeVolumic); - } - else - parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo); - - int nb_local; - if(targetM=="P0") - nb_local=mesh->getNumberOfCells(); - else - nb_local=mesh->getNumberOfNodes(); - - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - - dec.attachLocalField(icocofield); - } - - - //attaching a DEC to the source group - - if (source_group->containsMyRank()) - { - cout<<"DEC usage"<getField()->getArray()->getPointer(); - int nb_local=parafield->getField()->getMesh()->getNumberOfCells(); - for (int i=0; icontainsMyRank()) - { - cout<<"DEC usage"< times; - for (double time=0; timegetVolumeIntegral(0,true); - cout << "testAsynchronousInterpKernelDEC_2D" << rank << " time " << time - << " VolumeIntegral " << vi - << " time*10000 " << time*10000 << endl ; - - CPPUNIT_ASSERT_DOUBLES_EQUAL(vi,time*10000,0.001); - } - - } - - delete source_group; - delete target_group; - delete self_group; - delete parafield ; - delete paramesh ; - mesh->decrRef() ; - delete icocofield ; - - cout << "testAsynchronousInterpKernelDEC_2D" << rank << " MPI_Barrier " << endl ; - - if (Asynchronous) MPI_Barrier(MPI_COMM_WORLD); - cout << "end of InterpKernelDEC_2D test"< -#include "MEDLoader.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" - -#include -#include -#include -#include - -using namespace std; -using namespace INTERP_KERNEL; -using namespace ParaMEDMEM; - -void ParaMEDMEMTest::testMEDLoaderRead1() -{ - string fileName=getResourceFile("pointe_import22.med"); - vector meshNames=MEDLoader::GetMeshNames(fileName.c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size()); - MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size()); - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(12)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(13)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(14)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(15)); - CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(705,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12); - mesh->decrRef(); - // - vector families=MEDLoader::GetMeshFamiliesNames(fileName.c_str(),meshNames[0].c_str()); - CPPUNIT_ASSERT_EQUAL(8,(int)families.size()); - CPPUNIT_ASSERT(families[2]=="FAMILLE_ELEMENT_3"); - // - vector families2; - families2.push_back(families[2]); - mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),0,families2); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(1)); - CPPUNIT_ASSERT_EQUAL(11,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(132,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+11,0)); - CPPUNIT_ASSERT_EQUAL(16,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+3,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12); - mesh->decrRef(); - // - vector groups=MEDLoader::GetMeshGroupsNames(fileName.c_str(),meshNames[0].c_str()); - CPPUNIT_ASSERT_EQUAL(5,(int)groups.size()); - CPPUNIT_ASSERT(groups[0]=="groupe1"); - CPPUNIT_ASSERT(groups[1]=="groupe2"); - CPPUNIT_ASSERT(groups[2]=="groupe3"); - CPPUNIT_ASSERT(groups[3]=="groupe4"); - CPPUNIT_ASSERT(groups[4]=="groupe5"); - vector groups2; - groups2.push_back(groups[0]); - mesh=MEDLoader::ReadUMeshFromGroups(fileName.c_str(),meshNames[0].c_str(),0,groups2); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(7,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(6)); - CPPUNIT_ASSERT_EQUAL(36,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(254,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+36,0)); - CPPUNIT_ASSERT_EQUAL(141,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+8,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12); - mesh->decrRef(); - // - std::vector fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str()); - CPPUNIT_ASSERT_EQUAL(2,(int)fieldsName.size()); - CPPUNIT_ASSERT(fieldsName[0]=="fieldcelldoublescalar"); - CPPUNIT_ASSERT(fieldsName[1]=="fieldcelldoublevector"); - std::vector > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)its0.size()); - CPPUNIT_ASSERT_EQUAL(-1,its0[0].first); - CPPUNIT_ASSERT_EQUAL(-1,its0[0].second); - std::vector > its1=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[1].c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)its1.size()); - CPPUNIT_ASSERT_EQUAL(-1,its1[0].first); - CPPUNIT_ASSERT_EQUAL(-1,its1[0].second); - // - MEDCouplingFieldDouble *field0=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second); - field0->checkCoherency(); - CPPUNIT_ASSERT(field0->getName()==fieldsName[0]); - CPPUNIT_ASSERT_EQUAL(1,field0->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(16,field0->getNumberOfTuples()); - const double expectedValues[16]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,2.,3.,3.,2.}; - double diffValue[16]; - std::transform(field0->getArray()->getPointer(),field0->getArray()->getPointer()+16,expectedValues,diffValue,std::minus()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue,diffValue+16),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue,diffValue+16),1e-12); - const MEDCouplingUMesh *constMesh=dynamic_cast(field0->getMesh()); - CPPUNIT_ASSERT(constMesh); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); - field0->decrRef(); - // - MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second); - field1->checkCoherency(); - CPPUNIT_ASSERT(field1->getName()==fieldsName[1]); - CPPUNIT_ASSERT_EQUAL(3,field1->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(16,field1->getNumberOfTuples()); - const double expectedValues2[48]={1.,0.,1.,1.,0.,1.,1.,0.,1.,2.,1.,0.,2.,1.,0.,2.,1.,0.,3.,0.,1.,3.,0.,1.,3.,0.,1.,4.,1.,0.,4.,1.,0.,4.,1.,0.,5.,0.,0.,6.,1.,1.,6.,0.,0.,5.,1.,1.}; - double diffValue2[48]; - std::transform(field1->getArray()->getPointer(),field1->getArray()->getPointer()+48,expectedValues2,diffValue2,std::minus()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue2,diffValue2+48),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue2,diffValue2+48),1e-12); - constMesh=dynamic_cast(field1->getMesh()); - CPPUNIT_ASSERT(constMesh); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); - field1->decrRef(); - //fields on nodes - std::vector fieldsNameNode=MEDLoader::GetNodeFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str()); - CPPUNIT_ASSERT_EQUAL(2,(int)fieldsNameNode.size()); - CPPUNIT_ASSERT(fieldsNameNode[0]=="fieldnodedouble"); - CPPUNIT_ASSERT(fieldsNameNode[1]=="fieldnodeint"); - std::vector > its0Node=MEDLoader::GetNodeFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsNameNode[0].c_str()); - CPPUNIT_ASSERT_EQUAL(3,(int)its0Node.size()); - CPPUNIT_ASSERT_EQUAL(1,its0Node[0].first); - CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].second); - CPPUNIT_ASSERT_EQUAL(2,its0Node[1].first); - CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second); - CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].first);//strange but like that - CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second); - MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second); - field0Nodes->checkCoherency(); - CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]); - CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples()); - const double expectedValues3[19]={1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.}; - double diffValue3[19]; - std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues3,diffValue3,std::minus()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12); - constMesh=dynamic_cast(field0Nodes->getMesh()); - CPPUNIT_ASSERT(constMesh); - field0Nodes->decrRef(); - // - field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second); - field0Nodes->checkCoherency(); - CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]); - CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples()); - const double expectedValues4[19]={1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.,7.,7.}; - std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues4,diffValue3,std::minus()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12); - constMesh=dynamic_cast(field0Nodes->getMesh()); - CPPUNIT_ASSERT(constMesh); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); - field0Nodes->decrRef(); - // - field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second); - field0Nodes->checkCoherency(); - CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]); - CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples()); - const double expectedValues5[19]={1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.}; - std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues5,diffValue3,std::minus()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12); - constMesh=dynamic_cast(field0Nodes->getMesh()); - CPPUNIT_ASSERT(constMesh); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); - field0Nodes->decrRef(); -} - -void ParaMEDMEMTest::testMEDLoaderPolygonRead() -{ - string fileName=getResourceFile("polygones.med"); - vector meshNames=MEDLoader::GetMeshNames(fileName.c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size()); - CPPUNIT_ASSERT(meshNames[0]=="Bord"); - MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(538,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(579,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - for(int i=0;i<514;i++) - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i)); - for(int i=514;i<538;i++) - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+1737,0),1e-12); - const double expectedVals1[12]={1.4851585216522212,-0.5,0.,1.4851585216522212,-0.4,0.,1.4851585216522212,-0.3,0., 1.5741585216522211, -0.5, 0. }; - double diffValue1[12]; - std::transform(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+12,expectedVals1,diffValue1,std::minus()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue1,diffValue1+12),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue1,diffValue1+12),1e-12); - CPPUNIT_ASSERT_EQUAL(2768,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+2768,0)); - CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+539,0)); - mesh->decrRef(); - // - std::vector fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str()); - CPPUNIT_ASSERT_EQUAL(3,(int)fieldsName.size()); - CPPUNIT_ASSERT(fieldsName[0]=="bord_:_distorsion"); - CPPUNIT_ASSERT(fieldsName[1]=="bord_:_familles"); - CPPUNIT_ASSERT(fieldsName[2]=="bord_:_non-ortho"); - std::vector > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)its0.size()); - MEDCouplingFieldDouble *field=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second); - field->checkCoherency(); - CPPUNIT_ASSERT(field->getName()==fieldsName[0]); - CPPUNIT_ASSERT_EQUAL(1,field->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(538,field->getNumberOfTuples()); - const MEDCouplingUMesh *constMesh=dynamic_cast(field->getMesh()); - CPPUNIT_ASSERT(constMesh); - CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,constMesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(538,constMesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(579,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)constMesh->getAllTypes().size()); - for(int i=0;i<514;i++) - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,constMesh->getTypeOfCell(i)); - for(int i=514;i<538;i++) - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+1737,0),1e-12); - std::transform(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+12,expectedVals1,diffValue1,std::minus()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue1,diffValue1+12),1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue1,diffValue1+12),1e-12); - CPPUNIT_ASSERT_EQUAL(2768,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+2768,0)); - CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+539,0)); - const double *values=field->getArray()->getPointer(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.87214203182918,std::accumulate(values,values+538,0.),1e-12); - field->decrRef(); -} - -void ParaMEDMEMTest::testMEDLoaderPolyhedronRead() -{ - string fileName=getResourceFile("poly3D.med"); - vector meshNames=MEDLoader::GetMeshNames(fileName.c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size()); - CPPUNIT_ASSERT(meshNames[0]=="poly3D"); - MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0)); - CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(1)); - CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(2)); - CPPUNIT_ASSERT_EQUAL(98,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(725,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+98,0)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(110.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12); - CPPUNIT_ASSERT_EQUAL(155,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+4,0)); - mesh->decrRef(); - // - mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),-1); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(17,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(0)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(1)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(2)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(3)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(4)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(5)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(6)); - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(7)); - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(8)); - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(9)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(10)); - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(11)); - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(12)); - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(13)); - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(14)); - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(15)); - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(16)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(110.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12); - CPPUNIT_ASSERT_EQUAL(83,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(619,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+83,0)); - mesh->decrRef(); - // - vector families=MEDLoader::GetMeshFamiliesNames(fileName.c_str(),meshNames[0].c_str()); - CPPUNIT_ASSERT_EQUAL(4,(int)families.size()); - CPPUNIT_ASSERT(families[0]=="FAMILLE_FACE_POLYGONS3"); - CPPUNIT_ASSERT(families[1]=="FAMILLE_FACE_QUAD41"); - CPPUNIT_ASSERT(families[2]=="FAMILLE_FACE_TRIA32"); - CPPUNIT_ASSERT(families[3]=="FAMILLE_ZERO"); - vector families2; - families2.push_back(families[0]); - mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),-1,families2); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(1,(int)mesh->getAllTypes().size()); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(117,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+19,0)); - mesh->decrRef(); - // - mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),0,families2); - CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(0,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(0,(int)mesh->getAllTypes().size()); - mesh->decrRef(); -} - -void ParaMEDMEMTest::testMEDLoaderWrite1() -{ - const char meshName[]="MEDLoaderWrite1"; - string outFileName=makeTmpFile("toto22137.med"); - double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; - int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4}; - MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); - mesh->setMeshDimension(2); - mesh->allocateCells(5); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); - mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); - mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); - mesh->finishInsertingCells(); - DataArrayDouble *myCoords=DataArrayDouble::New(); - myCoords->alloc(9,2); - std::copy(targetCoords,targetCoords+18,myCoords->getPointer()); - mesh->setCoords(myCoords); - myCoords->decrRef(); - mesh->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes()); - bool normalThrow=false; - try - { - MEDLoader::WriteUMesh(outFileName.c_str(),mesh,true); - } - catch(INTERP_KERNEL::Exception& e) - { - normalThrow=true; - } - CPPUNIT_ASSERT(normalThrow); - mesh->setName(meshName); - MEDLoader::WriteUMesh(outFileName.c_str(),mesh,true); - mesh->decrRef(); - // - mesh=MEDLoader::ReadUMeshFromFile(outFileName.c_str(),meshName,0); - CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - for(int i=0;i<2;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(i)); - for(int i=2;i<5;i++) - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.6,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+18,0.),1.e-12); - mesh->decrRef(); -} - -void ParaMEDMEMTest::testMEDLoaderPolygonWrite() -{ - string fileName=getResourceFile("polygones.med"); - vector meshNames=MEDLoader::GetMeshNames(fileName.c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size()); - CPPUNIT_ASSERT(meshNames[0]=="Bord"); - MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0); - mesh->checkCoherency(); - string outFileName=makeTmpFile("toto22138.med"); - MEDLoader::WriteUMesh(outFileName.c_str(),mesh,true); - // - MEDCouplingUMesh *mesh2=MEDLoader::ReadUMeshFromFile(outFileName.c_str(),meshNames[0].c_str(),0); - // - mesh2->decrRef(); - mesh->decrRef(); -} diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_MPIProcessorGroup.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_MPIProcessorGroup.cxx deleted file mode 100644 index 010b30396..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_MPIProcessorGroup.cxx +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMEDMEMTest.hxx" -#include -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "InterpolationUtils.hxx" - -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - - -using namespace std; -using namespace ParaMEDMEM; - -/* - * Check methods defined in MPPIProcessorGroup.hxx - * - (+) MPIProcessorGroup(const CommInterface& interface); - (+) MPIProcessorGroup(const CommInterface& interface, set proc_ids); - (u) MPIProcessorGroup (const ProcessorGroup& proc_group, set proc_ids); - (+) MPIProcessorGroup(const CommInterface& interface,int pstart, int pend); - (+) virtual ~MPIProcessorGroup(); - (+) virtual ProcessorGroup* fuse (const ProcessorGroup&) const; - (u) void intersect (ProcessorGroup&){}; - (+) int myRank() const {int rank; MPI_Comm_rank(_comm,&rank); return rank;} - (+) bool containsMyRank() const { int rank; MPI_Group_rank(_group, &rank); return (rank!=MPI_UNDEFINED);} - (+) int translateRank(const ProcessorGroup* group, int rank) const; - (+) const MPI_Comm* getComm() const {return &_comm;} - (+) ProcessorGroup* createComplementProcGroup() const; - (o) ProcessorGroup* createProcGroup() const; - -*/ - -void ParaMEDMEMTest::testMPIProcessorGroup_constructor() -{ - CommInterface comm_interface; - MPIProcessorGroup* group= new MPIProcessorGroup(comm_interface); - int size; - MPI_Comm_size(MPI_COMM_WORLD, &size); - CPPUNIT_ASSERT_EQUAL(size,group->size()); - int size2; - const MPI_Comm* communicator=group->getComm(); - MPI_Comm_size(*communicator, &size2); - CPPUNIT_ASSERT_EQUAL(size,size2); - delete group; - - set procs; - - procs.insert(0); - procs.insert(1); - if (size==1) - CPPUNIT_ASSERT_THROW(group=new MPIProcessorGroup(comm_interface,procs),INTERP_KERNEL::Exception); - else - { - CPPUNIT_ASSERT_NO_THROW( group=new MPIProcessorGroup(comm_interface,procs)); - CPPUNIT_ASSERT_EQUAL (group->size(),2); - delete group; - } - - - //throws because plast1) - { - group=new MPIProcessorGroup(comm_interface,0,size-2); - CPPUNIT_ASSERT_EQUAL(group->size(),size-1); - delete group; - } - -} - -void ParaMEDMEMTest::testMPIProcessorGroup_boolean() -{ - int size; - MPI_Comm_size(MPI_COMM_WORLD, &size); - - CommInterface comm_interface; - MPIProcessorGroup group(comm_interface,0,0); - MPIProcessorGroup group2(comm_interface,size-1,size-1); - ProcessorGroup* group_fuse=group.fuse(group2); - int group_fuse_size=(size==1)?1:2; - CPPUNIT_ASSERT_EQUAL(group_fuse_size,group_fuse->size()); - - ProcessorGroup* group_complement=((MPIProcessorGroup*)group_fuse)->createComplementProcGroup(); - CPPUNIT_ASSERT_EQUAL(group_complement->size(),size-group_fuse_size); - - delete group_fuse; - delete group_complement; - - //intersect not implemented yet - // if (size>1) - // { - // MPIProcessorGroup group3(comm_interface,0,size-2); - // MPIProcessorGroup group4(comm_interface,1,size-1); - // group3.intersect(group4); - // CPPUNIT_ASSERT_EQUAL(group3.size(),size-2); - // } -} - -void ParaMEDMEMTest::testMPIProcessorGroup_rank() -{ - int size; - MPI_Comm_size(MPI_COMM_WORLD, &size); - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - CommInterface comm_interface; - MPIProcessorGroup group(comm_interface,0,0); - MPIProcessorGroup group2(comm_interface,size-1,size-1); - ProcessorGroup* group_fuse=group2.fuse(group); - - if (group.containsMyRank()) - CPPUNIT_ASSERT_EQUAL (group.myRank(), rank); - - if (group2.containsMyRank()) - { - int trank=group_fuse->translateRank(&group2,0); - if (size==1) - CPPUNIT_ASSERT_EQUAL(trank,0); - else - CPPUNIT_ASSERT_EQUAL(trank,1); - } - delete group_fuse; -} diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx deleted file mode 100644 index 8911fba39..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - -#ifdef MED_ENABLE_FVM - -#include "ParaMEDMEMTest.hxx" -#include - -#include "MEDMEM_Exception.hxx" -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "DEC.hxx" -#include "NonCoincidentDEC.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "UnstructuredParaSUPPORT.hxx" -#include "ICoCoMEDField.hxx" - -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - - -using namespace std; -using namespace ParaMEDMEM; -using namespace MEDMEM; - -/* - * Check methods defined in InterpKernelDEC.hxx - * - InterpKernelDEC(); - InterpKernelDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group); - virtual ~InterpKernelDEC(); - void synchronize(); - void recvData(); - void sendData(); -*/ - -void ParaMEDMEMTest::testNonCoincidentDEC_2D() -{ - - int size; - MPI_Comm_size(MPI_COMM_WORLD,&size); - - //the test is meant to run on five processors - if (size !=5) return ; - - testNonCoincidentDEC( "/share/salome/resources/med/square1_split", - "Mesh_2", - "/share/salome/resources/med/square2_split", - "Mesh_3", - 3, - 1e-6); -} - -void ParaMEDMEMTest::testNonCoincidentDEC_3D() -{ - int size; - MPI_Comm_size(MPI_COMM_WORLD,&size); - - //the test is meant to run on five processors - if (size !=4) return ; - - testNonCoincidentDEC( "/share/salome/resources/med/blade_12000_split2", - "Mesh_1", - "/share/salome/resources/med/blade_3000_split2", - "Mesh_1", - 2, - 1e4); -} - -void ParaMEDMEMTest::testNonCoincidentDEC(const string& filename1, - const string& meshname1, - const string& filename2, - const string& meshname2, - int nproc_source, - double epsilon) -{ - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - - set self_procs; - set procs_source; - set procs_target; - - for (int i=0; i* field; - ParaMEDMEM::ParaMESH* paramesh; - ParaMEDMEM::ParaFIELD* parafield; - - string filename_xml1 = getResourceFile(filename1); - string filename_xml2 = getResourceFile(filename2); - //string filename_seq_wr = makeTmpFile(""); - //string filename_seq_med = makeTmpFile("myWrField_seq_pointe221.med"); - - // To remove tmp files from disk - ParaMEDMEMTest_TmpFilesRemover aRemover; - //aRemover.Register(filename_seq_wr); - //aRemover.Register(filename_seq_med); - MPI_Barrier(MPI_COMM_WORLD); - ICoCo::Field* icocofield; - if (source_group->containsMyRank()) - { - string master = filename_xml1; - - ostringstream strstream; - strstream <getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - double * value= new double[nb_local]; - for(int ielem=0; ielemgetField()->setValue(value); - - icocofield=new ICoCo::MEDField(paramesh,parafield); - - dec.attachLocalField(icocofield); - delete [] value; - } - - //loading the geometry for the target group - if (target_group->containsMyRank()) - { - string master= filename_xml2; - ostringstream strstream; - strstream << master<<(rank-nproc_source+1)<<".med"; - ostringstream meshname ; - meshname<< meshname2<<"_"<getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - double * value= new double[nb_local]; - for(int ielem=0; ielemgetField()->setValue(value); - icocofield=new ICoCo::MEDField(paramesh,parafield); - - dec.attachLocalField(icocofield); - delete [] value; - } - - - //attaching a DEC to the source group - double field_before_int; - double field_after_int; - - if (source_group->containsMyRank()) - { - field_before_int = parafield->getVolumeIntegral(1); - MPI_Bcast(&field_before_int, 1,MPI_DOUBLE, 0,MPI_COMM_WORLD); - dec.synchronize(); - cout<<"DEC usage"<write(MED_DRIVER,"./sourcesquarenc"); - //parafield->write(MED_DRIVER,"./sourcesquarenc","boundary"); - - - } - - //attaching a DEC to the target group - if (target_group->containsMyRank()) - { - MPI_Bcast(&field_before_int, 1,MPI_DOUBLE, 0,MPI_COMM_WORLD); - - dec.synchronize(); - dec.setOption("ForcedRenormalization",false); - dec.recvData(); - //paramesh->write(MED_DRIVER, "./targetsquarenc"); - //parafield->write(MED_DRIVER, "./targetsquarenc", "boundary"); - field_after_int = parafield->getVolumeIntegral(1); - - } - MPI_Bcast(&field_before_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD); - MPI_Bcast(&field_after_int, 1,MPI_DOUBLE, size-1,MPI_COMM_WORLD); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, epsilon); - - delete source_group; - delete target_group; - delete self_group; - delete icocofield; - delete paramesh; - delete parafield; - delete support; - delete parasupport; - delete mesh; - MPI_Barrier(MPI_COMM_WORLD); - -} -#endif diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx deleted file mode 100644 index 973ed8760..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2007-2010 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 "ParaMEDMEMTest.hxx" -#include - -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "DEC.hxx" -#include "StructuredCoincidentDEC.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "ComponentTopology.hxx" -#include "ICoCoMEDField.hxx" -#include "MEDLoader.hxx" - -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -/* - * Check methods defined in StructuredCoincidentDEC.hxx - * - StructuredCoincidentDEC(); - StructuredCoincidentDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group); - virtual ~StructuredCoincidentDEC(); - void synchronize(); - void recvData(); - void sendData(); -*/ - -void ParaMEDMEMTest::testStructuredCoincidentDEC() { - string testname="ParaMEDMEM - testStructured CoincidentDEC"; - // MPI_Init(&argc, &argv); - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD, &size); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - if (size<4) { - return; - } - - ParaMEDMEM::CommInterface interface; - - ParaMEDMEM::MPIProcessorGroup self_group (interface,rank,rank); - ParaMEDMEM::MPIProcessorGroup target_group(interface,3,size-1); - ParaMEDMEM::MPIProcessorGroup source_group (interface,0,2); - - ParaMEDMEM::MEDCouplingUMesh* mesh; - ParaMEDMEM::ParaMESH* paramesh; - ParaMEDMEM::ParaFIELD* parafield; - - string filename_xml1 = getResourceFile("square1_split"); - string filename_2 = getResourceFile("square1.med"); - //string filename_seq_wr = makeTmpFile(""); - //string filename_seq_med = makeTmpFile("myWrField_seq_pointe221.med"); - - // To remove tmp files from disk - ParaMEDMEMTest_TmpFilesRemover aRemover; - - //loading the geometry for the source group - - ParaMEDMEM::StructuredCoincidentDEC dec(source_group, target_group); - - MPI_Barrier(MPI_COMM_WORLD); - if (source_group.containsMyRank()) { - string master = filename_xml1; - - ostringstream strstream; - strstream <getNumberOfCells(); - const int* global_numbering = paramesh->getGlobalNumberingCell(); - - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - - dec.attachLocalField(parafield); - dec.synchronize(); - dec.sendData(); - //delete icocofield; - } - - //loading the geometry for the target group - if (target_group.containsMyRank()) { - - string meshname2("Mesh_2"); - mesh = MEDLoader::ReadUMeshFromFile(filename_2.c_str(),meshname2.c_str(),0); - - paramesh=new ParaMESH (mesh,self_group,"target mesh"); - ParaMEDMEM::ComponentTopology comptopo(6, &target_group); - - parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - - int nb_local=mesh->getNumberOfCells(); - double *value=parafield->getField()->getArray()->getPointer(); - for (int ielem=0; ielemgetCellMesh(),parafield->getField()); - - dec.attachLocalField(parafield); - dec.synchronize(); - dec.recvData(); - - //checking validity of field - const double* recv_value = parafield->getField()->getArray()->getPointer(); - for (int i=0; i< nb_local; i++) { - int first = comptopo.firstLocalComponent(); - for (int icomp = 0; icomp < comptopo.nbLocalComponents(); icomp++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(recv_value[i*comptopo.nbLocalComponents()+icomp],(double)(i*6+icomp+first),1e-12); - } - //delete icocofield; - } - delete parafield; - delete paramesh; - mesh->decrRef(); - - // MPI_Barrier(MPI_COMM_WORLD); - -} diff --git a/src/ParaMEDMEMTest/TestMPIAccess.cxx b/src/ParaMEDMEMTest/TestMPIAccess.cxx deleted file mode 100644 index 5d6955daf..000000000 --- a/src/ParaMEDMEMTest/TestMPIAccess.cxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2010 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 all MPIAccess Test -// -#include "MPIAccessTest.hxx" - -// --- Registers the fixture into the 'registry' - -CPPUNIT_TEST_SUITE_REGISTRATION( MPIAccessTest ); - -// --- generic Main program from KERNEL_SRC/src/Basics/Test - -#include "MPIMainTest.hxx" diff --git a/src/ParaMEDMEMTest/TestMPIAccessDEC.cxx b/src/ParaMEDMEMTest/TestMPIAccessDEC.cxx deleted file mode 100644 index 7776eafb9..000000000 --- a/src/ParaMEDMEMTest/TestMPIAccessDEC.cxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2010 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 all MPIAccessDEC Test -// -#include "MPIAccessDECTest.hxx" - -// --- Registers the fixture into the 'registry' - -CPPUNIT_TEST_SUITE_REGISTRATION( MPIAccessDECTest ); - -// --- generic Main program from KERNEL_SRC/src/Basics/Test - -#include "MPIMainTest.hxx" diff --git a/src/ParaMEDMEMTest/TestParaMEDMEM.cxx b/src/ParaMEDMEMTest/TestParaMEDMEM.cxx deleted file mode 100644 index 8c7be29e7..000000000 --- a/src/ParaMEDMEMTest/TestParaMEDMEM.cxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2010 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 all MEDMEM Test -// -#include "ParaMEDMEMTest.hxx" - -// --- Registers the fixture into the 'registry' - -CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEMTest ); - -// --- generic Main program from KERNEL_SRC/src/Basics/Test - -#include "MPIMainTest.hxx" diff --git a/src/ParaMEDMEMTest/test_AllToAllDEC.cxx b/src/ParaMEDMEMTest/test_AllToAllDEC.cxx deleted file mode 100644 index 498fbc046..000000000 --- a/src/ParaMEDMEMTest/test_AllToAllDEC.cxx +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessDECTest.hxx" -#include -#include "MPIAccessDEC.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessDECTest::test_AllToAllDECSynchronousPointToPoint() { - test_AllToAllDEC( false ) ; -} -void MPIAccessDECTest::test_AllToAllDECAsynchronousPointToPoint() { - test_AllToAllDEC( true ) ; -} - -static void chksts( int sts , int myrank , ParaMEDMEM::MPIAccess mpi_access ) { - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - if ( sts != MPI_SUCCESS ) { - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - ostringstream strstream ; - strstream << "===========================================================" << endl - << "test_AllToAllDEC" << myrank << " KO" << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - return ; -} - -void MPIAccessDECTest::test_AllToAllDEC( bool Asynchronous ) { - - cout << "test_AllToAllDEC" << endl ; - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 || size > 11 ) { - ostringstream strstream ; - strstream << "usage :" << endl - << "mpirun -np test_AllToAllDEC" << endl - << " (nbprocs >=2)" << endl - << "test must be runned with more than 1 proc and less than 12 procs" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_AllToAllDEC" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - std::set sourceprocs; - std::set targetprocs; - int i ; - for ( i = 0 ; i < size/2 ; i++ ) { - sourceprocs.insert(i); - } - for ( i = size/2 ; i < size ; i++ ) { - targetprocs.insert(i); - } - - ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ; - ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ; - - MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup , - Asynchronous ) ; - - MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ; - -#define maxreq 100 -#define datamsglength 10 - - // int sts ; - int sendcount = datamsglength ; - int recvcount = datamsglength ; - int * recvbuf = new int[datamsglength*size] ; - - int ireq ; - for ( ireq = 0 ; ireq < maxreq ; ireq++ ) { - int * sendbuf = new int[datamsglength*size] ; - int j ; - for ( j = 0 ; j < datamsglength*size ; j++ ) { - sendbuf[j] = myrank*1000000 + ireq*1000 + j ; - recvbuf[j] = -1 ; - } - - MyMPIAccessDEC->allToAll( sendbuf, sendcount , MPI_INT , - recvbuf, recvcount , MPI_INT ) ; - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - int *ArrayOfRecvRequests = new int[nRecvReq] ; - int nReq = mpi_access->recvRequestIds( nRecvReq, ArrayOfRecvRequests ) ; - mpi_access->waitAll( nReq , ArrayOfRecvRequests ) ; - mpi_access->deleteRequests( nReq , ArrayOfRecvRequests ) ; - delete [] ArrayOfRecvRequests ; - } - - int nSendReq = mpi_access->sendRequestIdsSize() ; - cout << "test_AllToAllDEC" << myrank << " final SendRequestIds " << nSendReq << " SendRequests" - << endl ; - if ( nSendReq ) { - int *ArrayOfSendRequests = new int[nSendReq] ; - int nReq = mpi_access->sendRequestIds( nSendReq, ArrayOfSendRequests ) ; - mpi_access->waitAll( nReq , ArrayOfSendRequests ) ; - delete [] ArrayOfSendRequests ; - } - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq ) { - ostringstream strstream ; - strstream << "test_AllToAllDEC" << myrank << " final RecvRequestIds " << nRecvReq - << " RecvRequests # 0 Error" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "test_AllToAllDEC" << myrank << " final RecvRequestIds " << nRecvReq - << " RecvRequests = 0 OK" << endl ; - } - - mpi_access->barrier() ; - - delete sourcegroup ; - delete targetgroup ; - delete MyMPIAccessDEC ; - delete [] recvbuf ; - - // MPI_Finalize(); - - cout << "test_AllToAllDEC" << myrank << " OK" << endl ; - - return ; -} diff --git a/src/ParaMEDMEMTest/test_AllToAllTimeDEC.cxx b/src/ParaMEDMEMTest/test_AllToAllTimeDEC.cxx deleted file mode 100644 index 3e9a55815..000000000 --- a/src/ParaMEDMEMTest/test_AllToAllTimeDEC.cxx +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessDECTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccessDEC.hxx" -#include "LinearTimeInterpolator.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessDECTest::test_AllToAllTimeDECSynchronousPointToPoint() { - test_AllToAllTimeDEC( false ) ; -} -void MPIAccessDECTest::test_AllToAllTimeDECAsynchronousPointToPoint() { - test_AllToAllTimeDEC( true ) ; -} - -static void chksts( int sts , int myrank , ParaMEDMEM::MPIAccess * mpi_access ) { - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - if ( sts != MPI_SUCCESS ) { - mpi_access->errorString(sts, msgerr, &lenerr) ; - cout << "test_AllToAllTimeDEC" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - ostringstream strstream ; - strstream << "===========================================================" - << "test_AllToAllTimeDEC" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - return ; -} - -void MPIAccessDECTest::test_AllToAllTimeDEC( bool Asynchronous ) { - - cout << "test_AllToAllTimeDEC" << endl ; - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 || size > 11 ) { - ostringstream strstream ; - strstream << "usage :" << endl - << "mpirun -np test_AllToAllTimeDEC" << endl - << " (nbprocs >=2)" << endl - << "test must be runned with more than 1 proc and less than 12 procs" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - // int Asynchronous = atoi(argv[1]); - - cout << "test_AllToAllTimeDEC" << myrank << " Asynchronous " << Asynchronous << endl ; - - ParaMEDMEM::CommInterface interface ; - std::set sourceprocs; - std::set targetprocs; - int i ; - for ( i = 0 ; i < size/2 ; i++ ) { - sourceprocs.insert(i); - } - for ( i = size/2 ; i < size ; i++ ) { - targetprocs.insert(i); - } - - ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ; - ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ; - - // LinearTimeInterpolator * aLinearInterpDEC = new LinearTimeInterpolator( 0.5 ) ; - MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup , - Asynchronous ) ; - // Asynchronous , LinearInterp , 0.5 ) ; - MyMPIAccessDEC->setTimeInterpolator( LinearTimeInterp ) ; - MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ; - - cout << "test_AllToAllTimeDEC" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - cout << "test_AllToAllTimeDEC" << myrank << " Barrier done" << endl ; - -#define maxproc 11 -#define maxreq 10000 -#define datamsglength 10 - - int sts ; - int sendcount = datamsglength ; - int recvcount = datamsglength ; - - double time = 0 ; - // double deltatime[maxproc] = {1.,2.1,3.2,4.3,5.4,6.5,7.6,8.7,9.8,10.9,11.} ; - double deltatime[maxproc] = {1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.} ; - double maxtime = maxreq ; - double nextdeltatime = deltatime[myrank] ; - // MyMPIAccessDEC->InitTime( time , deltatime[myrank] , maxtime ) ; - // for ( time = 0 ; time <= maxtime ; time+=deltatime[myrank] ) { - for ( time = 0 ; time <= maxtime && nextdeltatime != 0 ; time+=nextdeltatime ) { - if ( time != 0 ) { - nextdeltatime = deltatime[myrank] ; - if ( time+nextdeltatime > maxtime ) { - nextdeltatime = 0 ; - } - // MyMPIAccessDEC->NextTime( nextdeltatime ) ; - } - MyMPIAccessDEC->setTime( time , nextdeltatime ) ; - cout << "test_AllToAllTimeDEC" << myrank << "=====TIME " << time << "=====DELTATIME " - << nextdeltatime << "=====MAXTIME " << maxtime << " ======" << endl ; - int * sendbuf = new int[datamsglength*size] ; - // int * sendbuf = (int *) malloc(sizeof(int)*datamsglength*size) ; - int * recvbuf = new int[datamsglength*size] ; - int j ; - for ( j = 0 ; j < datamsglength*size ; j++ ) { - sendbuf[j] = myrank*1000000 + (j/datamsglength)*1000 + j ; - recvbuf[j] = -1 ; - } - - int sts = MyMPIAccessDEC->allToAllTime( sendbuf, sendcount , MPI_INT , - recvbuf, recvcount , MPI_INT ) ; - chksts( sts , myrank , mpi_access ) ; - - // cout << "test_AllToAllTimeDEC" << myrank << " recvbuf before CheckSent" ; - // for ( i = 0 ; i < datamsglength*size ; i++ ) { - // cout << " " << recvbuf[i] ; - // } - // cout << endl ; - - // cout << "test_AllToAllTimeDEC" << myrank << " sendbuf " << sendbuf << endl ; - // MyMPIAccessDEC->CheckSent() ; - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq != 0 ) { - ostringstream strstream ; - strstream << "=============================================================" << endl - << "test_AllToAllTimeDEC" << myrank << " WaitAllRecv " << nRecvReq << " Requests # 0 ERROR" - << endl << "=============================================================" - << endl ; - int *ArrayOfRecvRequests = new int[nRecvReq] ; - int nReq = mpi_access->recvRequestIds( nRecvReq, ArrayOfRecvRequests ) ; - mpi_access->waitAll( nReq , ArrayOfRecvRequests ) ; - delete [] ArrayOfRecvRequests ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - // cout << "test_AllToAllTimeDEC" << myrank << " recvbuf" << endl ; - bool badrecvbuf = false ; - for ( i = 0 ; i < datamsglength*size ; i++ ) { - if ( recvbuf[i] != (i/datamsglength)*1000000 + myrank*1000 + - myrank*datamsglength+(i%datamsglength) ) { - badrecvbuf = true ; - cout << "test_AllToAllTimeDEC" << myrank << " recvbuf[" << i << "] " - << recvbuf[i] << " # " << (i/datamsglength)*1000000 + myrank*1000 + - myrank*datamsglength+(i%datamsglength) << endl ; - } - else if ( badrecvbuf ) { - cout << "test_AllToAllTimeDEC" << myrank << " recvbuf[" << i << "] " - << recvbuf[i] << " == " << (i/datamsglength)*1000000 + myrank*1000 + - myrank*datamsglength+(i%datamsglength) << endl ; - } - } - if ( badrecvbuf ) { - ostringstream strstream ; - strstream << "==============================================================" << endl - << "test_AllToAllTimeDEC" << myrank << " badrecvbuf" - << endl << "=============================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - delete [] recvbuf ; - } - - cout << "test_AllToAllTimeDEC" << myrank << " final CheckSent" << endl ; - sts = MyMPIAccessDEC->checkSent() ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "================================================================" << endl - << "test_AllToAllTimeDEC" << myrank << " final CheckSent ERROR" - << endl << "================================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - int nSendReq = mpi_access->sendRequestIdsSize() ; - cout << "test_AllToAllTimeDEC" << myrank << " final SendRequestIds " << nSendReq << " SendRequests" - << endl ; - if ( nSendReq ) { - int *ArrayOfSendRequests = new int[nSendReq] ; - int nReq = mpi_access->sendRequestIds( nSendReq, ArrayOfSendRequests ) ; - mpi_access->waitAll( nReq , ArrayOfSendRequests ) ; - delete [] ArrayOfSendRequests ; - } - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq ) { - ostringstream strstream ; - strstream << "===============================================================" << endl - << "test_AllToAllTimeDEC" << myrank << " RecvRequestIds " << nRecvReq - << " RecvRequests # 0 Error" - << endl << "===============================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "test_AllToAllTimeDEC" << myrank << " RecvRequestIds " << nRecvReq - << " RecvRequests = 0 OK" << endl ; - } - - cout << "test_AllToAllTimeDEC" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - cout << "test_AllToAllTimeDEC" << myrank << " Barrier done" << endl ; - - delete sourcegroup ; - delete targetgroup ; - // delete aLinearInterpDEC ; - delete MyMPIAccessDEC ; - - // MPI_Finalize(); - - cout << "test_AllToAllTimeDEC" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_AllToAllvDEC.cxx b/src/ParaMEDMEMTest/test_AllToAllvDEC.cxx deleted file mode 100644 index 0a294ba91..000000000 --- a/src/ParaMEDMEMTest/test_AllToAllvDEC.cxx +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessDECTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccessDEC.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessDECTest::test_AllToAllvDECSynchronousPointToPoint() { - test_AllToAllvDEC( false ) ; -} -void MPIAccessDECTest::test_AllToAllvDECAsynchronousPointToPoint() { - test_AllToAllvDEC( true ) ; -} - -static void chksts( int sts , int myrank , ParaMEDMEM::MPIAccess mpi_access ) { - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - if ( sts != MPI_SUCCESS ) { - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test_AllToAllvDEC" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - ostringstream strstream ; - strstream << "===========================================================" - << "test_AllToAllvDEC" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - return ; -} - -void MPIAccessDECTest::test_AllToAllvDEC( bool Asynchronous ) { - - cout << "test_AllToAllvDEC" << endl ; - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 || size > 11 ) { - ostringstream strstream ; - strstream << "usage :" << endl - << "mpirun -np test_AllToAllvDEC" << endl - << " (nbprocs >=2)" << endl - << "test must be runned with more than 1 proc and less than 12 procs" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - // int Asynchronous = atoi(argv[1]); - - cout << "test_AllToAllvDEC" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - std::set sourceprocs; - std::set targetprocs; - int i ; - for ( i = 0 ; i < size/2 ; i++ ) { - sourceprocs.insert(i); - } - for ( i = size/2 ; i < size ; i++ ) { - targetprocs.insert(i); - } - - ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ; - ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ; - - MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup , - Asynchronous ) ; - - MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ; - -#define maxreq 100 -#define datamsglength 10 - - // int sts ; - int *sendcounts = new int[size] ; - int *sdispls = new int[size] ; - int *recvcounts = new int[size] ; - int *rdispls = new int[size] ; - for ( i = 0 ; i < size ; i++ ) { - sendcounts[i] = datamsglength-i; - sdispls[i] = i*datamsglength ; - recvcounts[i] = datamsglength-myrank; - rdispls[i] = i*datamsglength ; - } - int * recvbuf = new int[datamsglength*size] ; - - int ireq ; - for ( ireq = 0 ; ireq < maxreq ; ireq++ ) { - int * sendbuf = new int[datamsglength*size] ; - // int * sendbuf = (int *) malloc( sizeof(int)*datamsglength*size) ; - int j ; - for ( j = 0 ; j < datamsglength*size ; j++ ) { - sendbuf[j] = myrank*1000000 + ireq*1000 + j ; - recvbuf[j] = -1 ; - } - - MyMPIAccessDEC->allToAllv( sendbuf, sendcounts , sdispls , MPI_INT , - recvbuf, recvcounts , rdispls , MPI_INT ) ; - - // cout << "test_AllToAllvDEC" << myrank << " recvbuf before CheckSent" ; - // for ( i = 0 ; i < datamsglength*size ; i++ ) { - // cout << " " << recvbuf[i] ; - // } - // cout << endl ; - - // cout << "test_AllToAllvDEC" << myrank << " sendbuf " << sendbuf << endl ; - // MyMPIAccessDEC->CheckSent() ; - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - // cout << "test_AllToAllvDEC" << myrank << " WaitAllRecv " << nRecvReq << " Requests" << endl ; - int *ArrayOfRecvRequests = new int[nRecvReq] ; - int nReq = mpi_access->recvRequestIds( nRecvReq, ArrayOfRecvRequests ) ; - mpi_access->waitAll( nReq , ArrayOfRecvRequests ) ; - mpi_access->deleteRequests( nReq , ArrayOfRecvRequests ) ; - delete [] ArrayOfRecvRequests ; - - // cout << "test_AllToAllvDEC" << myrank << " recvbuf" ; - // for ( i = 0 ; i < datamsglength*size ; i++ ) { - // cout << " " << recvbuf[i] ; - // } - // cout << endl ; - } - - // cout << "test_AllToAllvDEC" << myrank << " final CheckSent" << endl ; - // MyMPIAccessDEC->CheckSent() ; - - int nSendReq = mpi_access->sendRequestIdsSize() ; - cout << "test_AllToAllvDEC" << myrank << " final SendRequestIds " << nSendReq << " SendRequests" - << endl ; - if ( nSendReq ) { - int *ArrayOfSendRequests = new int[nSendReq] ; - int nReq = mpi_access->sendRequestIds( nSendReq, ArrayOfSendRequests ) ; - mpi_access->waitAll( nReq , ArrayOfSendRequests ) ; - delete [] ArrayOfSendRequests ; - } - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq ) { - ostringstream strstream ; - strstream << "test_AllToAllvDEC" << myrank << " final RecvRequestIds " << nRecvReq - << " RecvRequests # 0 Error" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "test_AllToAllvDEC" << myrank << " final RecvRequestIds " << nRecvReq - << " RecvRequests = 0 OK" << endl ; - } - - mpi_access->barrier() ; - - delete sourcegroup ; - delete targetgroup ; - delete MyMPIAccessDEC ; - delete [] sendcounts ; - delete [] sdispls ; - delete [] recvcounts ; - delete [] rdispls ; - delete [] recvbuf ; - - // MPI_Finalize(); - - cout << "test_AllToAllvDEC" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_AllToAllvTimeDEC.cxx b/src/ParaMEDMEMTest/test_AllToAllvTimeDEC.cxx deleted file mode 100644 index 5d4cac7b2..000000000 --- a/src/ParaMEDMEMTest/test_AllToAllvTimeDEC.cxx +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include -#include - -#include "MPIAccessDECTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccessDEC.hxx" -#include "LinearTimeInterpolator.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessDECTest::test_AllToAllvTimeDECSynchronousNative() { - test_AllToAllvTimeDEC( false , true ) ; -} -void MPIAccessDECTest::test_AllToAllvTimeDECSynchronousPointToPoint() { - test_AllToAllvTimeDEC( false , false ) ; -} -void MPIAccessDECTest::test_AllToAllvTimeDECAsynchronousPointToPoint() { - test_AllToAllvTimeDEC( true , false ) ; -} - -static void chksts( int sts , int myrank , ParaMEDMEM::MPIAccess * mpi_access ) { - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - if ( sts != MPI_SUCCESS ) { - mpi_access->errorString(sts, msgerr, &lenerr) ; - cout << "test_AllToAllvTimeDEC" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - ostringstream strstream ; - strstream << "===========================================================" - << "test_AllToAllvTimeDEC" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - return ; -} - -void MPIAccessDECTest::test_AllToAllvTimeDEC( bool Asynchronous , bool UseMPINative ) { - - cout << "test_AllToAllvTimeDEC" << endl ; - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 || size > 11 ) { - ostringstream strstream ; - strstream << "usage :" << endl - << "mpirun -np test_AllToAllTimeDEC" << endl - << " (nbprocs >=2)" << endl - << "test must be runned with more than 1 proc and less than 12 procs" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - // int Asynchronous = atoi(argv[1]) ; - int UseMPI_Alltoallv = UseMPINative ; - // if ( argc == 3 ) { - // UseMPI_Alltoallv = atoi(argv[2]) ; - // } - - cout << "test_AllToAllvTimeDEC" << myrank << " Asynchronous " << Asynchronous - << " UseMPI_Alltoallv " << UseMPI_Alltoallv << endl ; - - ParaMEDMEM::CommInterface interface ; - std::set sourceprocs; - std::set targetprocs; - int i ; - for ( i = 0 ; i < size/2 ; i++ ) { - sourceprocs.insert(i); - } - for ( i = size/2 ; i < size ; i++ ) { - targetprocs.insert(i); - } - - ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ; - ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ; - - // TimeInterpolator * aLinearInterpDEC = new LinearTimeInterpolator( 0.5 ) ; - MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup , - Asynchronous ) ; - // Asynchronous , LinearInterp , 0.5 ) ; - MyMPIAccessDEC->setTimeInterpolator( LinearTimeInterp , 0.5 ) ; - MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ; - - cout << "test_AllToAllvTimeDEC" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - cout << "test_AllToAllvTimeDEC" << myrank << " Barrier done" << endl ; - -#define maxproc 11 -#define maxreq 10000 -#define datamsglength 10 - - int sts ; - int *sendcounts = new int[size] ; - int *sdispls = new int[size] ; - int *recvcounts = new int[size] ; - int *rdispls = new int[size] ; - int *sendtimecounts = new int[size] ; - int *stimedispls = new int[size] ; - int *recvtimecounts = new int[size] ; - int *rtimedispls = new int[size] ; - for ( i = 0 ; i < size ; i++ ) { - sendcounts[i] = datamsglength-i ; - sdispls[i] = i*datamsglength ; - recvcounts[i] = datamsglength-myrank ; - rdispls[i] = i*datamsglength ; - sendtimecounts[i] = 1 ; - stimedispls[i] = 0 ; - recvtimecounts[i] = 1 ; - rtimedispls[i] = i ; - //rtimedispls[i] = i*mpi_access->TimeExtent() ; - } - - double timeLoc = 0 ; - double deltatime[maxproc] = {1.,2.1,3.2,4.3,5.4,6.5,7.6,8.7,9.8,10.9,11.} ; - double maxtime ; - double nextdeltatime = deltatime[myrank] ; - if ( UseMPI_Alltoallv ) { - maxtime = maxreq*nextdeltatime - 0.1 ; - } - else { - maxtime = maxreq ; - // MyMPIAccessDEC->InitTime( time , nextdeltatime , maxtime ) ; - } - time_t begintime = time(NULL) ; - // for ( time = 0 ; time <= maxtime ; time+=deltatime[myrank] ) { - for ( timeLoc = 0 ; timeLoc <= maxtime && nextdeltatime != 0 ; timeLoc+=nextdeltatime ) { - nextdeltatime = deltatime[myrank] ; - if ( timeLoc != 0 ) { - nextdeltatime = deltatime[myrank] ; - if ( timeLoc+nextdeltatime > maxtime ) { - nextdeltatime = 0 ; - } - // MyMPIAccessDEC->NextTime( nextdeltatime ) ; - } - MyMPIAccessDEC->setTime( timeLoc , nextdeltatime ) ; - cout << "test_AllToAllvTimeDEC" << myrank << "=====TIME " << time << "=====DELTATIME " - << nextdeltatime << "=====MAXTIME " << maxtime << " ======" << endl ; - int * sendbuf = new int[datamsglength*size] ; - // int * sendbuf = (int *) malloc(sizeof(int)*datamsglength*size) ; - int * recvbuf = new int[datamsglength*size] ; - int j ; - for ( j = 0 ; j < datamsglength*size ; j++ ) { - sendbuf[j] = myrank*1000000 + (j/datamsglength)*1000 + j ; - recvbuf[j] = -1 ; - } - - if ( UseMPI_Alltoallv ) { - const MPI_Comm* comm = MyMPIAccessDEC->getComm(); - TimeMessage * aSendTimeMessage = new TimeMessage ; - aSendTimeMessage->time = timeLoc ; - // aSendTimeMessage->deltatime = deltatime[myrank] ; - aSendTimeMessage->deltatime = nextdeltatime ; - // aSendTimeMessage->maxtime = maxtime ; - aSendTimeMessage->tag = (int ) (timeLoc/deltatime[myrank]) ; - TimeMessage * aRecvTimeMessage = new TimeMessage[size] ; - interface.allToAllV(aSendTimeMessage, sendtimecounts , stimedispls , - mpi_access->timeType() , - aRecvTimeMessage, recvtimecounts , rtimedispls , - mpi_access->timeType() , *comm ) ; - // for ( j = 0 ; j < size ; j++ ) { - // cout << "test_AllToAllvTimeDEC" << myrank << " TimeMessage received " << j << " " - // << aRecvTimeMessage[j] << endl ; - // } - delete aSendTimeMessage ; - delete [] aRecvTimeMessage ; - interface.allToAllV(sendbuf, sendcounts , sdispls , MPI_INT , - recvbuf, recvcounts , rdispls , MPI_INT , *comm ) ; - // free(sendbuf) ; - delete [] sendbuf ; - } - else { - int sts = MyMPIAccessDEC->allToAllvTime( sendbuf, sendcounts , sdispls , MPI_INT , - recvbuf, recvcounts , rdispls , MPI_INT ) ; - chksts( sts , myrank , mpi_access ) ; - } - - // cout << "test_AllToAllvTimeDEC" << myrank << " recvbuf before CheckSent" ; - // for ( i = 0 ; i < datamsglength*size ; i++ ) { - // cout << " " << recvbuf[i] ; - // } - // cout << endl ; - - // cout << "test_AllToAllvTimeDEC" << myrank << " sendbuf " << sendbuf << endl ; - // MyMPIAccessDEC->CheckSent() ; - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq != 0 ) { - ostringstream strstream ; - strstream << "=============================================================" << endl - << "test_AllToAllvTimeDEC" << myrank << " WaitAllRecv " << nRecvReq << " Requests # 0 ERROR" - << endl << "=============================================================" - << endl ; - int *ArrayOfRecvRequests = new int[nRecvReq] ; - int nReq = mpi_access->recvRequestIds( nRecvReq, ArrayOfRecvRequests ) ; - mpi_access->waitAll( nReq , ArrayOfRecvRequests ) ; - delete [] ArrayOfRecvRequests ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - // cout << "test_AllToAllvTimeDEC" << myrank << " check of recvbuf" << endl ; - bool badrecvbuf = false ; - for ( i = 0 ; i < size ; i++ ) { - int j ; - for ( j = 0 ; j < datamsglength ; j++ ) { - int index = i*datamsglength+j ; - if ( j < recvcounts[i] ) { - if ( recvbuf[index] != (index/datamsglength)*1000000 + myrank*1000 + - myrank*datamsglength+(index%datamsglength) ) { - badrecvbuf = true ; - cout << "test_AllToAllvTimeDEC" << myrank << " recvbuf[" << index << "] " - << recvbuf[index] << " # " << (index/datamsglength)*1000000 + - myrank*1000 + - myrank*datamsglength+(index%datamsglength) << endl ; - } - else if ( badrecvbuf ) { - cout << "test_AllToAllvTimeDEC" << myrank << " recvbuf[" << index << "] " - << recvbuf[index] << " == " << (index/datamsglength)*1000000 + - myrank*1000 + - myrank*datamsglength+(index%datamsglength) << endl ; - } - } - else if ( recvbuf[index] != -1 ) { - badrecvbuf = true ; - cout << "test_AllToAllvTimeDEC" << myrank << " recvbuf[" << index << "] " - << recvbuf[index] << " # -1" << endl ; - } - } - } - if ( badrecvbuf ) { - ostringstream strstream ; - strstream << "==============================================================" << endl - << "test_AllToAllvTimeDEC" << myrank << " badrecvbuf" - << endl << "=============================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - delete [] recvbuf ; - } - - cout << "test_AllToAllvTimeDEC" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - cout << "test_AllToAllvTimeDEC" << myrank << " Barrier done" << endl ; - - cout << "test_AllToAllvTimeDEC" << myrank << " CheckFinalSent" << endl ; - sts = MyMPIAccessDEC->checkFinalSent() ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "================================================================" << endl - << "test_AllToAllvTimeDEC" << myrank << " final CheckSent ERROR" - << endl << "================================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_AllToAllvTimeDEC" << myrank << " CheckFinalRecv" << endl ; - sts = MyMPIAccessDEC->checkFinalRecv() ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "================================================================" << endl - << "test_AllToAllvTimeDEC" << myrank << " CheckFinalRecv ERROR" - << endl << "================================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq ) { - ostringstream strstream ; - strstream << "===============================================================" << endl - << "test_AllToAllvTimeDEC" << myrank << " RecvRequestIds " << nRecvReq - << " RecvRequests # 0 Error" - << endl << "===============================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "test_AllToAllvTimeDEC" << myrank << " RecvRequestIds " << nRecvReq - << " RecvRequests = 0 OK" << endl ; - } - - time_t endtime = time(NULL) ; - cout << "test_AllToAllvTimeDEC" << myrank << " begintime " << begintime << " endtime " << endtime - << " elapse " << endtime-begintime << " " << maxtime/deltatime[myrank] - << " calls to AllToAll" << endl ; - - cout << "test_AllToAllvTimeDEC" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - cout << "test_AllToAllvTimeDEC" << myrank << " Barrier done" << endl ; - - delete sourcegroup ; - delete targetgroup ; - delete MyMPIAccessDEC ; - // delete aLinearInterpDEC ; - - delete [] sendcounts ; - delete [] sdispls ; - delete [] recvcounts ; - delete [] rdispls ; - delete [] sendtimecounts ; - delete [] stimedispls ; - delete [] recvtimecounts ; - delete [] rtimedispls ; - - // MPI_Finalize(); - - endtime = time(NULL) ; - - cout << "test_AllToAllvTimeDEC" << myrank << " OK begintime " << begintime << " endtime " << endtime - << " elapse " << endtime-begintime << " " << maxtime/deltatime[myrank] - << " calls to AllToAll" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_AllToAllvTimeDoubleDEC.cxx b/src/ParaMEDMEMTest/test_AllToAllvTimeDoubleDEC.cxx deleted file mode 100644 index 0b717c21f..000000000 --- a/src/ParaMEDMEMTest/test_AllToAllvTimeDoubleDEC.cxx +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include -#include -#include - -#include "MPIAccessDECTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccessDEC.hxx" -#include "LinearTimeInterpolator.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessDECTest::test_AllToAllvTimeDoubleDECSynchronousPointToPoint() { - test_AllToAllvTimeDoubleDEC( false ) ; -} -void MPIAccessDECTest::test_AllToAllvTimeDoubleDECAsynchronousPointToPoint() { - test_AllToAllvTimeDoubleDEC( true ) ; -} - -static void chksts( int sts , int myrank , ParaMEDMEM::MPIAccess * mpi_access ) { - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - if ( sts != MPI_SUCCESS ) { - mpi_access->errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - return ; -} - -void MPIAccessDECTest::test_AllToAllvTimeDoubleDEC( bool Asynchronous ) { - - cout << "test_AllToAllvTimeDoubleDEC" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 || size > 11 ) { - ostringstream strstream ; - strstream << "usage :" << endl - << "mpirun -np test_AllToAllTimeDEC" << endl - << " (nbprocs >=2)" << endl - << "test must be runned with more than 1 proc and less than 12 procs" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - -// int Asynchronous = atoi(argv[1]) ; - - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " Asynchronous " << Asynchronous << endl ; - - ParaMEDMEM::CommInterface interface ; - std::set sourceprocs; - std::set targetprocs; - int i ; - for ( i = 0 ; i < size/2 ; i++ ) { - sourceprocs.insert(i); - } - for ( i = size/2 ; i < size ; i++ ) { - targetprocs.insert(i); - } - - ParaMEDMEM::MPIProcessorGroup* sourcegroup = new ParaMEDMEM::MPIProcessorGroup(interface,sourceprocs) ; - ParaMEDMEM::MPIProcessorGroup* targetgroup = new ParaMEDMEM::MPIProcessorGroup(interface,targetprocs) ; - -// TimeInterpolator * aLinearInterpDEC = new LinearTimeInterpolator( 0 ) ; - MPIAccessDEC * MyMPIAccessDEC = new MPIAccessDEC( *sourcegroup , *targetgroup , - Asynchronous ) ; -// Asynchronous , LinearInterp , 0.5 ) ; - MyMPIAccessDEC->setTimeInterpolator( LinearTimeInterp ) ; - MPIAccess * mpi_access = MyMPIAccessDEC->getMPIAccess() ; - - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - -#define maxproc 11 -#define maxreq 100 -#define datamsglength 10 - - int sts ; - int *sendcounts = new int[size] ; - int *sdispls = new int[size] ; - int *recvcounts = new int[size] ; - int *rdispls = new int[size] ; - int *sendtimecounts = new int[size] ; - int *stimedispls = new int[size] ; - int *recvtimecounts = new int[size] ; - int *rtimedispls = new int[size] ; - for ( i = 0 ; i < size ; i++ ) { - sendcounts[i] = datamsglength-i ; - sdispls[i] = i*datamsglength ; - recvcounts[i] = datamsglength-myrank ; - rdispls[i] = i*datamsglength ; - sendtimecounts[i] = 1 ; - stimedispls[i] = 0 ; - recvtimecounts[i] = 1 ; - rtimedispls[i] = i ; - } - - double timeLoc[maxproc] ; - double deltatime[maxproc] = {1.,2.1,3.2,4.3,5.4,6.5,7.6,8.7,9.8,10.9,11.} ; - double maxtime[maxproc] ; - double nextdeltatime[maxproc] ; - for ( i = 0 ; i < size ; i++ ) { - timeLoc[i] = 0 ; - maxtime[i] = maxreq ; - nextdeltatime[i] = deltatime[i] ; - } - time_t begintime = time(NULL) ; - for ( timeLoc[myrank] = 0 ; timeLoc[myrank] <= maxtime[myrank] && nextdeltatime[myrank] != 0 ; - timeLoc[myrank]+=nextdeltatime[myrank] ) { -//local and target times - int target ; - for ( target = 0 ; target < size ; target++ ) { - nextdeltatime[target] = deltatime[target] ; - if ( timeLoc[target] != 0 ) { - if ( timeLoc[target]+nextdeltatime[target] > maxtime[target] ) { - nextdeltatime[target] = 0 ; - } - } - if ( target != myrank ) { - while ( timeLoc[myrank] >= timeLoc[target] ) { - timeLoc[target] += deltatime[target] ; - } - } - } - MyMPIAccessDEC->setTime( timeLoc[myrank] , nextdeltatime[myrank] ) ; - cout << "test" << myrank << "=====TIME " << timeLoc[myrank] << "=====DELTATIME " - << nextdeltatime[myrank] << "=====MAXTIME " << maxtime[myrank] << " ======" - << endl ; - double * sendbuf = new double[datamsglength*size] ; -// double * sendbuf = (double *) malloc(sizeof(double)*datamsglength*size) ; - double * recvbuf = new double[datamsglength*size] ; - int j ; - //cout << "test_AllToAllvTimeDoubleDEC" << myrank << " sendbuf" ; - for ( target = 0 ; target < size ; target++ ) { - for ( j = 0 ; j < datamsglength ; j++ ) { - //sendbuf[j] = myrank*10000 + (j/datamsglength)*100 + j ; - sendbuf[target*datamsglength+j] = myrank*1000000 + target*10000 + - (timeLoc[myrank]/deltatime[myrank])*100 + j ; - //cout << " " << (int ) sendbuf[target*datamsglength+j] ; - recvbuf[target*datamsglength+j] = -1 ; - } - //cout << endl ; - } - - int sts = MyMPIAccessDEC->allToAllvTime( sendbuf, sendcounts , sdispls , MPI_DOUBLE , - recvbuf, recvcounts , rdispls , MPI_DOUBLE ) ; - chksts( sts , myrank , mpi_access ) ; - -// cout << "test_AllToAllvTimeDoubleDEC" << myrank << " recvbuf before CheckSent" ; -// for ( i = 0 ; i < datamsglength*size ; i++ ) { -// cout << " " << recvbuf[i] ; -// } -// cout << endl ; - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq != 0 ) { - ostringstream strstream ; - strstream << "=============================================================" << endl - << "test_AllToAllvTimeDoubleDEC" << myrank << " WaitAllRecv " - << nRecvReq << " Requests # 0 ERROR" - << endl << "============================================================" - << endl ; - int *ArrayOfRecvRequests = new int[nRecvReq] ; - int nReq = mpi_access->recvRequestIds( nRecvReq, ArrayOfRecvRequests ) ; - mpi_access->waitAll( nReq , ArrayOfRecvRequests ) ; - delete [] ArrayOfRecvRequests ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - -// cout << "test_AllToAllvTimeDoubleDEC" << myrank << " check of recvbuf" << endl ; - bool badrecvbuf = false ; - for ( target = 0 ; target < size ; target++ ) { - int j ; - for ( j = 0 ; j < datamsglength ; j++ ) { - int index = target*datamsglength+j ; - if ( j < recvcounts[target] ) { - if ( fabs(recvbuf[index] - (target*1000000 + myrank*10000 + - (timeLoc[target]/deltatime[target])*100 + j)) > 101) { - badrecvbuf = true ; - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " target " << target << " timeLoc[target] " - << timeLoc[target] << " recvbuf[" << index << "] " << (int ) recvbuf[index] - << " # " << (int ) (target*1000000 + - myrank*10000 + (timeLoc[target]/deltatime[target])*100 + j) - << endl ; - } - else if ( badrecvbuf ) { - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " recvbuf[" << index << "] " - << recvbuf[index] << " ~= " << (int ) (target*1000000 + - myrank*10000 + (timeLoc[target]/deltatime[target])*100 + j) << endl ; - } - } - else if ( recvbuf[index] != -1 ) { - badrecvbuf = true ; - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " recvbuf[" << index << "] " - << recvbuf[index] << " # -1" << endl ; - } - } - } - if ( badrecvbuf ) { - ostringstream strstream ; - strstream << "==================================================================" << endl - << "test_AllToAllvTimeDoubleDEC" << myrank << " badrecvbuf" - << endl << "==================================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - delete [] recvbuf ; - } - - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalSent" << endl ; - sts = MyMPIAccessDEC->checkFinalSent() ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "=================================================================" << endl - << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalSent ERROR" - << endl << "=================================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalRecv" << endl ; - sts = MyMPIAccessDEC->checkFinalRecv() ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "=================================================================" << endl - << "test_AllToAllvTimeDoubleDEC" << myrank << " CheckFinalRecv ERROR" - << endl << "================================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - int nRecvReq = mpi_access->recvRequestIdsSize() ; - if ( nRecvReq ) { - ostringstream strstream ; - strstream << "===============================================================" << endl - << "test_AllToAllvTimeDoubleDEC" << myrank << " RecvRequestIds " << nRecvReq - << " RecvRequests # 0 Error" - << endl << "===============================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " RecvRequestIds " << nRecvReq - << " RecvRequests = 0 OK" << endl ; - } - - time_t endtime = time(NULL) ; - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " begintime " << begintime << " endtime " << endtime - << " elapse " << endtime-begintime << " " << maxtime[myrank]/deltatime[myrank] - << " calls to AllToAll" << endl ; - - cout << "test" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - - delete sourcegroup ; - delete targetgroup ; - delete MyMPIAccessDEC ; -// delete aLinearInterpDEC ; - - delete [] sendcounts ; - delete [] sdispls ; - delete [] recvcounts ; - delete [] rdispls ; - delete [] sendtimecounts ; - delete [] stimedispls ; - delete [] recvtimecounts ; - delete [] rtimedispls ; - -// MPI_Finalize(); - - endtime = time(NULL) ; - - cout << "test_AllToAllvTimeDoubleDEC" << myrank << " OK begintime " << begintime << " endtime " << endtime - << " elapse " << endtime-begintime << " " << maxtime[myrank]/deltatime[myrank] - << " calls to AllToAll" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Cancel.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Cancel.cxx deleted file mode 100644 index 5b95d0d65..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Cancel.cxx +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_Cancel() { - - cout << "test_MPI_Access_Cancel" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "test_MPI_Access_Cancel must be runned with 2 procs" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_MPI_Access_Cancel" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int intsendbuf[5] ; - double doublesendbuf[10] ; - int RequestId[10] ; - int sts ; - int i , j ; - for ( j = 0 ; j < 3 ; j++ ) { - for ( i = 0 ; i < 10 ; i++ ) { - cout << "test" << myrank << " ============================ i " << i - << "============================" << endl ; - if ( myrank == 0 ) { - if ( i < 5 ) { - intsendbuf[i] = i ; - sts = mpi_access.ISend(&intsendbuf[i],1,MPI_INT,target, RequestId[i]) ; - cout << "test" << myrank << " Send MPI_INT RequestId " << RequestId[i] - << endl ; - } - else { - doublesendbuf[i] = i ; - sts = mpi_access.ISend(&doublesendbuf[i],1,MPI_DOUBLE,target, - RequestId[i]) ; - cout << "test" << myrank << " Send MPI_DOUBLE RequestId " << RequestId[i] - << endl ; - } - } - else { - int flag = false ; - while ( !flag ) { - int source, tag, outcount ; - MPI_Datatype datatype ; - sts = mpi_access.IProbe(target, source, tag, datatype, outcount, - flag ) ; - if ( flag ) { - cout << "test" << myrank << " " << i << " IProbe target " << target - << " source " << source << " tag " << tag - << " outcount " << outcount << " flag " << flag << endl ; - } - else { - cout << "test" << myrank << " flag " << flag << endl ; - sleep( 1 ) ; - } - if ( flag ) { - int recvbuf ; - sts = mpi_access.IRecv(&recvbuf,outcount,MPI_INT,source, - RequestId[i] ) ; - if ( datatype == MPI_INT ) { - int source, tag, error, outcount ; - mpi_access.wait( RequestId[i] ) ; - mpi_access.status( RequestId[i], source, tag, error, outcount, - true ) ; - if ( (outcount != 1) | (recvbuf != i) ) { - ostringstream strstream ; - strstream << "======================================================" - << endl << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " KO" << endl - << "======================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - cout << "========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " OK" << endl - << "========================================================" - << endl ; - } - } - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - - if ( myrank != 0 ) { - int iprobe ; - for ( iprobe = 5 ; iprobe < 10 ; iprobe++ ) { - cout << "test" << myrank << " ============================ iprobe " - << iprobe << "============================" << endl ; - int source, tag, outcount ; - MPI_Datatype datatype ; - int probeflag = false ; - while ( !probeflag ) { - sts = mpi_access.IProbe( target, source, tag, datatype, outcount, - probeflag ) ; - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " IProbe iprobe " << iprobe - << " target " << target << " probeflag " << probeflag - << " tag " << tag << " outcount " << outcount << " datatype " - << datatype << " lenerr " << lenerr << " " << msgerr << endl ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "==========================================================" - << endl << "test" << myrank << " IProbe KO iprobe " << iprobe - << endl - << "==========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - if ( !probeflag ) { - //cout << "========================================================" - // << endl << "test" << myrank << " IProbe KO(OK) iprobe " << iprobe - // << " probeflag " << probeflag << endl - // << "========================================================" - // << endl ; - } - else { - cout << "test" << myrank << " " << iprobe << " IProbe target " - << target << " source " << source << " tag " << tag - << " outcount " << outcount << " probeflag " << probeflag - << endl ; - if ( datatype != MPI_DOUBLE ) { - ostringstream strstream ; - strstream << "========================================================" - << endl << "test" << myrank << " MPI_DOUBLE KO" << endl - << "========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - int flag ; - sts = mpi_access.cancel( source, tag, datatype, outcount, flag ) ; - if ( sts != MPI_SUCCESS || !flag ) { - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "======================================================" - << endl << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl << "test" << myrank - << " Cancel PendingIrecv KO flag " << flag << " iprobe " - << iprobe << " Irecv completed" << endl - << "======================================================" - << endl ; - //return 1 ; - } - else { - cout << "======================================================" - << endl << "test" << myrank - << " Cancel PendingIrecv OK RequestId " << " flag " - << flag << " iprobe " << iprobe << endl - << "======================================================" - << endl ; - } - } - int Reqtarget, Reqtag, Reqerror, Reqoutcount ; - mpi_access.status( RequestId[iprobe], Reqtarget, Reqtag, Reqerror, - Reqoutcount, true ) ; - cout << "test" << myrank << " Status Reqtarget "<< Reqtarget - << " Reqtag " << Reqtag << " Reqoutcount " << Reqoutcount - << endl ; - int Reqflag ; - sts = mpi_access.cancel( RequestId[iprobe] , Reqflag ) ; - cout << "test" << myrank << " " << iprobe - << " Cancel Irecv done Reqtarget " << Reqtarget - << " Reqtag " << Reqtag << " Reqoutcount " << Reqoutcount - << " Reqflag " << Reqflag << endl ; - if ( sts != MPI_SUCCESS || !Reqflag ) { - mpi_access.errorString(sts, msgerr, &lenerr) ; - ostringstream strstream ; - strstream << "========================================================" - << endl << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl << "test" << myrank - << " Cancel Irecv KO Reqflag " << Reqflag << " iprobe " - << iprobe << endl - << "========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "========================================================" - << endl << "test" << myrank - << " Cancel Irecv OK RequestId " << RequestId[iprobe] - << " Reqflag " << Reqflag << " iprobe " << iprobe << endl - << "========================================================" - << endl ; - probeflag = Reqflag ; - } - } - } - } - } - mpi_access.waitAll(10,RequestId) ; - mpi_access.deleteRequests(10,RequestId) ; - } - - int source, tag, outcount, flag ; - MPI_Datatype datatype ; - sts = mpi_access.IProbe(target, source, tag, datatype, outcount, flag ) ; - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - if ( sts != MPI_SUCCESS || flag ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " IProbe KO flag " << flag - << " remaining unread/cancelled message :" << endl - << " source " << source << " tag " << tag << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - mpi_access.testAll(10,RequestId,flag) ; - mpi_access.waitAll(10,RequestId) ; - mpi_access.deleteRequests(10,RequestId) ; - mpi_access.testAll(10,RequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Cyclic_ISend_IRecv.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Cyclic_ISend_IRecv.cxx deleted file mode 100644 index c10f0599a..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Cyclic_ISend_IRecv.cxx +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_Cyclic_ISend_IRecv() { - - cout << "test_MPI_Access_Cyclic_ISend_IRecv" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 3 ) { - cout << "test_MPI_Access_Cyclic_ISend_IRecv must be runned with 3 procs" << endl ; - CPPUNIT_FAIL("test_MPI_Access_Cyclic_ISend_IRecv must be runned with 3 procs") ; - } - - cout << "test_MPI_Access_Cyclic_ISend_IRecv" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - -#define maxsend 100 - - if ( myrank >= 3 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int alltarget[3] = {1 , 2 , 0 } ; - int allsource[3] = {2 , 0 , 1 } ; - int SendRequestId[maxsend] ; - int RecvRequestId[maxsend] ; - int sendbuf[maxsend] ; - int recvbuf[maxsend] ; - int sts ; - int i = 0 ; - if ( myrank == 0 ) { - sendbuf[i] = i ; - sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,alltarget[myrank], - SendRequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(alltarget[myrank]) << endl ; - } - for ( i = 0 ; i < maxsend ; i++ ) { - recvbuf[i] = -1 ; - sts = mpi_access.IRecv(&recvbuf[i],1,MPI_INT,allsource[myrank], - RecvRequestId[i]) ; - cout << "test" << myrank << " Recv RequestId " << RecvRequestId[i] - << " tag " << mpi_access.recvMPITag(allsource[myrank]) << endl ; - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr - << " " << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - int j ; - for (j = 0 ; j <= i ; j++) { - int flag ; - if ( j < i ) { - cout << "test" << myrank << " " << j << " -> Test-Send("<< SendRequestId[j] - << ")" << endl ; - mpi_access.test( SendRequestId[j], flag ) ; - if ( flag ) { - int target, tag, error, outcount ; - mpi_access.status( SendRequestId[j], target, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Send RequestId " << SendRequestId[j] - << " target " << target << " tag " << tag << " error " << error - << endl ; - mpi_access.deleteRequest( SendRequestId[j] ) ; - } - } - cout << "test" << myrank << " " << j << " -> Test-Recv("<< SendRequestId[j] - << ")" << endl ; - mpi_access.test( RecvRequestId[j], flag ) ; - if ( flag ) { - int source, tag, error, outcount ; - mpi_access.status( RecvRequestId[j], source, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Recv RequestId" << j << " " - << RecvRequestId[j] << " source " << source << " tag " << tag - << " error " << error << " outcount " << outcount << endl ; - if ( (outcount != 1) | (recvbuf[j] != j) ) { - ostringstream strstream ; - strstream << "=====================================================" - << endl << "test" << myrank << " outcount " - << outcount << " recvbuf[ " << j << " ] " << recvbuf[j] << " KO" - << endl << "=====================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - } - if ( myrank == 0 ) { - if ( i != maxsend-1 ) { - sendbuf[i+1] = i + 1 ; - sts = mpi_access.ISend(&sendbuf[i+1],1,MPI_INT,alltarget[myrank], - SendRequestId[i+1]) ; - cout << "test" << myrank << " Send RequestId " << SendRequestId[i+1] - << " tag " << mpi_access.sendMPITag(alltarget[myrank]) << endl ; - } - } - else { - sendbuf[i] = i ; - sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,alltarget[myrank], - SendRequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(alltarget[myrank]) << endl ; - } - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr - << " " << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - - int flag ; - mpi_access.testAll(maxsend,SendRequestId,flag) ; - mpi_access.testAll(maxsend,RecvRequestId,flag) ; - mpi_access.waitAll(maxsend,SendRequestId) ; - mpi_access.deleteRequests(maxsend,SendRequestId) ; - mpi_access.waitAll(maxsend,RecvRequestId) ; - mpi_access.deleteRequests(maxsend,RecvRequestId) ; - mpi_access.check() ; - mpi_access.testAll(maxsend,SendRequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " TestAllSendflag " << flag << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " TestAllSendflag " << flag << " OK" << endl - << "=========================================================" << endl ; - } - mpi_access.testAll(maxsend,RecvRequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " TestAllRecvflag " << flag << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " TestAllRecvflag " << flag << " OK" << endl - << "=========================================================" << endl ; - } - - int sendrequests[maxsend] ; - int sendreqsize = mpi_access.sendRequestIds( alltarget[myrank] , maxsend , - sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - int source, tag, error, outcount ; - mpi_access.status(sendrequests[0], source, tag, error, outcount, true) ; - cout << "test" << myrank << " RequestId " << sendrequests[0] - << " source " << source << " tag " << tag << " error " << error - << " outcount " << outcount << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - int recvrequests[maxsend] ; - int recvreqsize = mpi_access.sendRequestIds( allsource[myrank] , maxsend , - recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Cyclic_Send_Recv.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Cyclic_Send_Recv.cxx deleted file mode 100644 index dd67d4d28..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Cyclic_Send_Recv.cxx +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_Cyclic_Send_Recv() { - - cout << "test_MPI_Access_Cyclic_Send_Recv" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 3 ) { - cout << "test_MPI_Access_Send_Recv must be runned with 3 procs" << endl ; - CPPUNIT_FAIL("test_MPI_Access_Send_Recv must be runned with 3 procs") ; - } - - cout << "test_MPI_Access_Cyclic_Send_Recv" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 3 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int alltarget[3] = {1 , 2 , 0 } ; - int allsource[3] = {2 , 0 , 1 } ; - int RequestId[10] ; - int sts ; - int i = 0 ; - if ( myrank == 0 ) { - sts = mpi_access.send(&i,1,MPI_INT,alltarget[myrank], RequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << RequestId[i] - << " tag " << mpi_access.sendMPITag(alltarget[myrank]) << endl ; - } - for ( i = 0 ; i < 10 ; i++ ) { - int recvbuf ; - int outcount ; - if ( i & 1 ) { - outcount = 0 ; - sts = mpi_access.recv(&recvbuf,1,MPI_INT,allsource[myrank], RequestId[i], - &outcount) ; - } - else { - sts = mpi_access.recv(&recvbuf,1,MPI_INT,allsource[myrank], RequestId[i]) ; - outcount = 1 ; - } - //int source, tag, error, outcount ; - //mpi_access.Status( RequestId[i], source, tag, error, outcount, true) ; - cout << "test" << myrank << " Recv RequestId " << RequestId[i] - << " tag " << mpi_access.recvMPITag(allsource[myrank]) - << " outcount " << outcount << endl ; - if ( (outcount != 1) | (recvbuf != i) ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " outcount " - << outcount << " recvbuf " << recvbuf << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - if ( myrank == 0 ) { - if ( i != 9 ) { - int ii = i + 1 ; - sts = mpi_access.send(&ii,1,MPI_INT,alltarget[myrank], RequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << RequestId[i] - << " tag " << mpi_access.sendMPITag(alltarget[myrank]) << endl ; - } - } - else { - sts = mpi_access.send(&i,1,MPI_INT,alltarget[myrank], RequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << RequestId[i] - << " tag " << mpi_access.sendMPITag(alltarget[myrank]) << endl ; - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr - << " " << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - - int flag ; - mpi_access.testAll(10,RequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.waitAll(10,RequestId) ; - mpi_access.check() ; - - int sendrequests[10] ; - int sendreqsize = mpi_access.sendRequestIds( alltarget[myrank] , 10 , - sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - int recvrequests[10] ; - int recvreqsize = mpi_access.sendRequestIds( allsource[myrank] , 10 , - recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_IProbe.cxx b/src/ParaMEDMEMTest/test_MPI_Access_IProbe.cxx deleted file mode 100644 index 5e07db5c5..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_IProbe.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_IProbe() { - - cout << "test_MPI_Access_IProbe" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "test_MPI_Access_IProbe must be runned with 2 procs" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_MPI_Access_IProbe" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int sendbuf[10] ; - int RequestId[10] ; - int sts ; - int i ; - for ( i = 0 ; i < 10 ; i++ ) { - if ( myrank == 0 ) { - sendbuf[i] = i ; - sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,target, RequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << RequestId[i] - << endl ; - } - else { - int flag = false ; - while ( !flag ) { - int source, tag, outcount ; - MPI_Datatype datatype ; - sts = mpi_access.IProbe(target, source, tag, datatype, outcount, flag ) ; - if ( flag ) { - cout << "test" << myrank << " " << i << " IProbe target " << target - << " source " << source << " tag " << tag - << " outcount " << outcount << " flag " << flag << endl ; - } - else { - cout << "test" << myrank << " IProbe flag " << flag << endl ; - sleep( 1 ) ; - } - if ( flag ) { - int recvbuf ; - sts = mpi_access.recv(&recvbuf,outcount,datatype,source, RequestId[i], - &outcount) ; - if ( (outcount != 1) | (recvbuf != i) ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " KO" << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - cout << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " OK" << endl - << "===========================================================" - << endl ; - } - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - int flag ; - mpi_access.testAll(10,RequestId,flag) ; - mpi_access.waitAll(10,RequestId) ; - mpi_access.deleteRequests(10,RequestId) ; - mpi_access.testAll(10,RequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_ISendRecv.cxx b/src/ParaMEDMEMTest/test_MPI_Access_ISendRecv.cxx deleted file mode 100644 index e11dc7698..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_ISendRecv.cxx +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_ISendRecv() { - - cout << "test_MPI_Access_ISendRecv" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - cout << "test_MPI_Access_ISendRecv must be runned with 2 procs" << endl ; - CPPUNIT_FAIL("test_MPI_Access_ISendRecv must be runned with 2 procs") ; - } - - cout << "test_MPI_Access_ISendRecv" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int SendRequestId[10] ; - int RecvRequestId[10] ; - int sendbuf[10] ; - int recvbuf[10] ; - int sts ; - int i ; - for ( i = 0 ; i < 10 ; i++ ) { - sendbuf[i] = i ; - sts = mpi_access.ISendRecv(&sendbuf[i],1,MPI_INT,target, SendRequestId[i], - &recvbuf[i],1,MPI_INT,target, RecvRequestId[i]) ; - cout << "test" << myrank << " Send sendRequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(target) - << " recvRequestId " << RecvRequestId[i] - << " tag " << mpi_access.recvMPITag(target) << endl ; - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr - << " " << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - int j ; - for (j = 0 ; j <= i ; j++) { - int flag ; - if ( j < i ) { - cout << "test" << myrank << " " << j << " -> Test-Send("<< SendRequestId[j] - << ")" << endl ; - mpi_access.test( SendRequestId[j], flag ) ; - if ( flag ) { - int target, tag, error, outcount ; - mpi_access.status( SendRequestId[j], target, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Send RequestId " << SendRequestId[j] - << " target " << target << " tag " << tag << " error " << error - << endl ; - mpi_access.deleteRequest( SendRequestId[j] ) ; - } - } - cout << "test" << myrank << " " << j << " -> Test-Recv("<< SendRequestId[j] - << ")" << endl ; - mpi_access.test( RecvRequestId[j], flag ) ; - if ( flag ) { - int source, tag, error, outcount ; - mpi_access.status( RecvRequestId[j], source, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Recv RequestId" << j << " " - << RecvRequestId[j] << " source " << source << " tag " << tag - << " error " << error << " outcount " << outcount << endl ; - if ( (outcount != 1) | (recvbuf[j] != j) ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " outcount " - << outcount << " recvbuf[ " << j << " ] " << recvbuf[j] << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - } - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - mpi_access.check() ; - } - - int flag ; - mpi_access.testAll(10,SendRequestId,flag) ; - mpi_access.waitAll(10,SendRequestId) ; - mpi_access.deleteRequests(10,SendRequestId) ; - mpi_access.testAll(10,SendRequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - mpi_access.testAll(10,RecvRequestId,flag) ; - mpi_access.waitAll(10,RecvRequestId) ; - mpi_access.deleteRequests(10,RecvRequestId) ; - mpi_access.testAll(10,RecvRequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - - int sendrequests[10] ; - int sendreqsize = mpi_access.sendRequestIds( target , 10 , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - int recvrequests[10] ; - int recvreqsize = mpi_access.sendRequestIds( target , 10 , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv.cxx b/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv.cxx deleted file mode 100644 index 369952c8a..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv.cxx +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_ISend_IRecv() { - - cout << "test_MPI_Access_ISend_IRecv" << endl ; - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - cout << "test_MPI_Access_ISend_IRecv must be runned with 2 procs" << endl ; - CPPUNIT_FAIL("test_MPI_Access_ISend_IRecv must be runned with 2 procs") ; - } - - cout << "test_MPI_Access_ISend_IRecv" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - -#define maxreq 100 - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int SendRequestId[maxreq] ; - int RecvRequestId[maxreq] ; - int sts ; - int sendbuf[maxreq] ; - int recvbuf[maxreq] ; - int i ; - for ( i = 0 ; i < maxreq ; i++ ) { - if ( myrank == 0 ) { - sendbuf[i] = i ; - sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,target, SendRequestId[i]) ; - cout << "test" << myrank << " ISend RequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - } - else { - sts = mpi_access.IRecv(&recvbuf[i],1,MPI_INT,target, RecvRequestId[i]) ; - cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i] - << " tag " << mpi_access.recvMPITag(target) << endl ; - } - int j ; - for (j = 0 ; j <= i ; j++) { - int flag ; - if ( myrank == 0 ) { - mpi_access.test( SendRequestId[j], flag ) ; - } - else { - mpi_access.test( RecvRequestId[j], flag ) ; - } - if ( flag ) { - int target,source, tag, error, outcount ; - if ( myrank == 0 ) { - mpi_access.status( SendRequestId[j], target, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j] - << ") : target " << target << " tag " << tag << " error " << error - << " flag " << flag << endl ; - } - else { - mpi_access.status( RecvRequestId[j], source, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Recv RequestId " - << RecvRequestId[j] << ") : source " << source << " tag " << tag - << " error " << error << " outcount " << outcount - << " flag " << flag << endl ; - if ( (outcount != 1) | (recvbuf[j] != j) ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " outcount " - << outcount << " recvbuf " << recvbuf[j] << " KO" << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - //else { - // cout << "===========================================================" - // << endl << "test" << myrank << " outcount " << outcount - // << " RequestId " << RecvRequestId[j] << " recvbuf " - // << recvbuf[j] << " OK" << endl - // << "===========================================================" - // << endl ; - //} - } - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - - mpi_access.check() ; - if ( myrank == 0 ) { - mpi_access.waitAll(maxreq, SendRequestId) ; - mpi_access.deleteRequests(maxreq, SendRequestId) ; - } - else { - mpi_access.waitAll(maxreq, RecvRequestId) ; - mpi_access.deleteRequests(maxreq, RecvRequestId) ; - } - mpi_access.check() ; - - if ( myrank == 0 ) { - int sendrequests[maxreq] ; - int sendreqsize = mpi_access.sendRequestIds( target , maxreq , sendrequests ) ; - int i ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - for ( i = 0 ; i < sendreqsize ; i++ ) { - cout << "test" << myrank << " sendrequests[ " << i << " ] = " - << sendrequests[i] << endl ; - } - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - else { - int recvrequests[maxreq] ; - int recvreqsize = mpi_access.sendRequestIds( target , maxreq , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - - mpi_access.barrier() ; - - delete group ; - - // MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_BottleNeck.cxx b/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_BottleNeck.cxx deleted file mode 100644 index 3482278c2..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_BottleNeck.cxx +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_ISend_IRecv_BottleNeck() { - - cout << "test_MPI_Access_ISend_IRecv_BottleNeck" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "test_MPI_Access_ISend_IRecv_BottleNeck must be runned with 2 procs" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_MPI_Access_ISend_IRecv_BottleNeck" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - -#define maxreq 10000 - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int SendRequestId[maxreq] ; - int RecvRequestId[maxreq] ; - int sts ; - int sendbuf[maxreq] ; - int recvbuf[maxreq] ; - int i ; - for ( i = 0 ; i < maxreq ; i++ ) { - if ( myrank == 0 ) { - sendbuf[i] = i ; - sts = mpi_access.ISend(sendbuf,i,MPI_INT,target, SendRequestId[i]) ; - cout << "test" << myrank << " ISend RequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - } - else { - //sleep( 1 ) ; - sts = mpi_access.IRecv(recvbuf,i,MPI_INT,target, RecvRequestId[i]) ; - cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i] - << " tag " << mpi_access.recvMPITag(target) << endl ; - int recvreqsize = mpi_access.recvRequestIdsSize() ; - int * recvrequests = new int[ recvreqsize ] ; - recvreqsize = mpi_access.recvRequestIds( target , recvreqsize , recvrequests ) ; - int j ; - for (j = 0 ; j < recvreqsize ; j++) { - int flag ; - mpi_access.test( recvrequests[j], flag ) ; - if ( flag ) { - int source, tag, error, outcount ; - mpi_access.status( recvrequests[j], source, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Recv RequestId " - << recvrequests[j] << ") : source " << source << " tag " << tag - << " error " << error << " outcount " << outcount - << " flag " << flag << " : DeleteRequest" << endl ; - mpi_access.deleteRequest( recvrequests[j] ) ; - } - else { -// cout << "test" << myrank << " Test(Recv RequestId " -// << recvrequests[j] << ") flag " << flag << endl ; - } - } - delete [] recvrequests ; - } - if ( sts != MPI_SUCCESS ) { - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - } - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - - mpi_access.check() ; - if ( myrank == 0 ) { - int size = mpi_access.sendRequestIdsSize() ; - cout << "test" << myrank << " before WaitAll sendreqsize " << size << endl ; - mpi_access.waitAll(maxreq, SendRequestId) ; - size = mpi_access.sendRequestIdsSize() ; - cout << "test" << myrank << " after WaitAll sendreqsize " << size << endl ; - int * ArrayOfSendRequests = new int[ size ] ; - int nSendRequest = mpi_access.sendRequestIds( size , ArrayOfSendRequests ) ; - int i ; - for ( i = 0 ; i < nSendRequest ; i++ ) { - mpi_access.deleteRequest( ArrayOfSendRequests[i] ) ; - } - delete [] ArrayOfSendRequests ; - } - else { - int size = mpi_access.recvRequestIdsSize() ; - cout << "test" << myrank << " before WaitAll recvreqsize " << size << endl ; - mpi_access.waitAll(maxreq, RecvRequestId) ; - size = mpi_access.recvRequestIdsSize() ; - cout << "test" << myrank << " after WaitAll recvreqsize " << size << endl ; - int * ArrayOfRecvRequests = new int[ size ] ; - int nRecvRequest = mpi_access.recvRequestIds( size , ArrayOfRecvRequests ) ; - int i ; - for ( i = 0 ; i < nRecvRequest ; i++ ) { - mpi_access.deleteRequest( ArrayOfRecvRequests[i] ) ; - } - delete [] ArrayOfRecvRequests ; - } - mpi_access.check() ; - - if ( myrank == 0 ) { - int sendrequests[maxreq] ; - int sendreqsize = mpi_access.sendRequestIds( target , maxreq , sendrequests ) ; - int i ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - for ( i = 0 ; i < sendreqsize ; i++ ) { - cout << "test" << myrank << " sendrequests[ " << i << " ] = " - << sendrequests[i] << endl ; - } - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - else { - int recvrequests[maxreq] ; - int recvreqsize = mpi_access.recvRequestIds( target , maxreq , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length.cxx b/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length.cxx deleted file mode 100644 index bba555e5f..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length.cxx +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_ISend_IRecv_Length() { - - cout << "test_MPI_Access_ISend_IRecv_Length" << endl ; - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "test_MPI_Access_ISend_IRecv_Length must be runned with 2 procs" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_MPI_Access_ISend_IRecv_Length" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - -#define maxreq 10 - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int SendRequestId[maxreq] ; - int RecvRequestId[maxreq] ; - int sts ; - int sendbuf[1000*(maxreq-1)] ; - int recvbuf[maxreq-1][1000*(maxreq-1)] ; - int i ; - for ( i = 0 ; i < 1000*(maxreq-1) ; i++ ) { - sendbuf[i] = i ; - } - for ( i = 0 ; i < maxreq ; i++ ) { - if ( myrank == 0 ) { - sts = mpi_access.ISend( sendbuf, 1000*i, MPI_INT, target, SendRequestId[i] ) ; - cout << "test" << myrank << " ISend RequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - } - else { - sts = mpi_access.IRecv( recvbuf[i], 1000*i, MPI_INT, target, - RecvRequestId[i] ) ; - cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i] - << " tag " << mpi_access.recvMPITag(target) << endl ; - } - int j ; - for (j = 0 ; j <= i ; j++) { - int flag ; - if ( myrank == 0 ) { - mpi_access.test( SendRequestId[j], flag ) ; - } - else { - mpi_access.test( RecvRequestId[j], flag ) ; - } - if ( flag ) { - int target,source, tag, error, outcount ; - if ( myrank == 0 ) { - mpi_access.status( SendRequestId[j], target, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j] - << ") : target " << target << " tag " << tag << " error " << error - << " flag " << flag << endl ; - } - else { - mpi_access.status( RecvRequestId[j], source, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Recv RequestId " - << RecvRequestId[j] << ") : source " << source << " tag " << tag - << " error " << error << " outcount " << outcount - << " flag " << flag << endl ; - if ( outcount != 0 ) { - if ( (outcount != 1000*j) | - (recvbuf[j][outcount-1] != (outcount-1)) ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " outcount " - << outcount << " recvbuf " << recvbuf[j][outcount-1] << " KO" - << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " RequestId " << RecvRequestId[j] << " recvbuf " - << recvbuf[j][outcount-1] << " OK" << endl - << "===========================================================" - << endl ; - } - } - else { - cout << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " RequestId " << RecvRequestId[j] << " OK" << endl - << "===========================================================" - << endl ; - } - } - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - - mpi_access.check() ; - cout << "test" << myrank << " WaitAll" << endl ; - if ( myrank == 0 ) { - mpi_access.waitAll(maxreq, SendRequestId) ; - mpi_access.deleteRequests(maxreq, SendRequestId) ; - } - else { - mpi_access.waitAll(maxreq, RecvRequestId) ; - mpi_access.deleteRequests(maxreq, RecvRequestId) ; - } - mpi_access.check() ; - - if ( myrank == 0 ) { - int sendrequests[maxreq] ; - int sendreqsize = mpi_access.sendRequestIds( target , maxreq , sendrequests ) ; - sendreqsize = mpi_access.sendRequestIds( target , maxreq , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - else { - int recvrequests[maxreq] ; - int recvreqsize = mpi_access.sendRequestIds( target , maxreq , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - - mpi_access.barrier() ; - - delete group ; - - // MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length_1.cxx b/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length_1.cxx deleted file mode 100644 index f463d68d2..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_ISend_IRecv_Length_1.cxx +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_ISend_IRecv_Length_1() { - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "test_MPI_Access_ISend_IRecv_Length_1 must be runned with 2 procs" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_MPI_Access_ISend_IRecv_Length_1" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - -#define maxreq 10 - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int SendRequestId[maxreq] ; - int RecvRequestId[maxreq] ; - int sts ; - int sendbuf[1000*(maxreq-1)] ; - int recvbuf[maxreq-1][1000*(maxreq-1)] ; - int maxirecv = 1 ; - int i ; - RecvRequestId[0] = -1 ; - for ( i = 0 ; i < 1000*(maxreq-1) ; i++ ) { - sendbuf[i] = i ; - } - for ( i = 0 ; i < maxreq ; i++ ) { - sts = MPI_SUCCESS ; - if ( myrank == 0 ) { - sts = mpi_access.ISend( sendbuf, 1000*i, MPI_INT, target, SendRequestId[i] ) ; - cout << "test" << myrank << " ISend RequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - } - int j ; - for (j = 1 ; j <= i ; j++) { - int source ; - MPI_Datatype datatype ; - int outcount ; - int flag ; - if ( myrank == 0 ) { - mpi_access.test( SendRequestId[j], flag ) ; - } - else { - int MPITag ; - sts = mpi_access.IProbe( target , source, MPITag, datatype, - outcount, flag) ; - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " IProbe lenerr " << lenerr << " " - << msgerr << endl ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " IProbe KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - cout << "test" << myrank << " IProbe i/j " << i << "/" << j - << " MPITag " << MPITag << " datatype " << datatype - << " outcount " << outcount << " flag " << flag << endl ; - } - if ( flag ) { - if ( myrank == 0 ) { - int target, tag, error, outcount ; - mpi_access.status( SendRequestId[j], target, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j] - << ") : target " << target << " tag " << tag << " error " << error - << " flag " << flag << endl ; - } - else { - sts = mpi_access.IRecv( recvbuf[maxirecv], outcount, datatype, source, - RecvRequestId[maxirecv] ) ; - cout << "test" << myrank << " maxirecv " << maxirecv << " IRecv RequestId " - << RecvRequestId[maxirecv] << " source " << source - << " outcount " << outcount << " tag " - << mpi_access.recvMPITag(target) << endl ; - maxirecv = maxirecv + 1 ; - } - } - else if ( myrank == 1 && i == maxreq-1 && j >= maxirecv ) { - sts = mpi_access.IRecv( recvbuf[j], 1000*j, MPI_INT, target, - RecvRequestId[j] ) ; - cout << "test" << myrank << " maxirecv " << maxirecv << " IRecv RequestId " - << RecvRequestId[j] << " target " << target << " length " << 1000*j - << " tag " << mpi_access.recvMPITag(target) << endl ; - maxirecv = maxirecv + 1 ; - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " KO" << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - - mpi_access.check() ; - int flag ; - if ( myrank == 0 ) { - mpi_access.testAll( maxreq, SendRequestId, flag ) ; - cout << "test" << myrank << " TestAll SendRequest flag " << flag << endl ; - } - else { - int i ; - int source ; - int outcount ; - int flag ; - if ( maxirecv != maxreq ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " KO" << " maxirecv " << maxirecv - << " != maxreq " << maxreq << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - while ( maxirecv > 0 ) { - for ( i = 1 ; i < maxreq ; i++ ) { - cout << "test" << myrank << " IProbe : " << endl ; - sts = mpi_access.test( RecvRequestId[i] , flag ) ; - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " flag " << flag << " lenerr " - << lenerr << " " << msgerr << " maxirecv " << maxirecv << endl ; - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - cout << "test" << myrank << " Test flag " << flag << endl ; - if ( flag ) { - int tag, error ; - mpi_access.status( RecvRequestId[i] , source , tag , error , - outcount ) ; - if ( i != 0 ) { - if ( outcount != 1000*i | - (recvbuf[i][outcount-1] != (outcount-1)) ) { - ostringstream strstream ; - strstream << "========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " KO" << " i " << i - << " recvbuf " << recvbuf[i][outcount-1] << endl - << "========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - else if ( outcount != 0 ) { - ostringstream strstream ; - strstream << "========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " KO" << " i " << i << endl - << "========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - maxirecv = maxirecv - 1 ; - } - } - } - mpi_access.testAll( maxreq, RecvRequestId, flag ) ; - cout << "test" << myrank << " TestAll RecvRequest flag " << flag << endl ; - } - mpi_access.check() ; - cout << "test" << myrank << " WaitAll :" << endl ; - if ( myrank == 0 ) { - mpi_access.waitAll( maxreq, SendRequestId ) ; - mpi_access.deleteRequests( maxreq, SendRequestId ) ; - } - else { - mpi_access.waitAll( maxreq, RecvRequestId ) ; - mpi_access.deleteRequests( maxreq, RecvRequestId ) ; - } - - if ( myrank == 0 ) { - int sendrequests[maxreq] ; - int sendreqsize = mpi_access.sendRequestIds( target , maxreq , sendrequests ) ; - sendreqsize = mpi_access.sendRequestIds( target , maxreq , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - else { - int recvrequests[maxreq] ; - int recvreqsize = mpi_access.sendRequestIds( target , maxreq , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - - mpi_access.barrier() ; - - delete group ; - - // MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Probe.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Probe.cxx deleted file mode 100644 index 6f86702dc..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Probe.cxx +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_Probe() { - - cout << "test_MPI_Access_Probe" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - cout << "test_MPI_Access_Probe must be runned with 2 procs" << endl ; - CPPUNIT_FAIL("test_MPI_Access_Probe must be runned with 2 procs") ; - } - - cout << "test_MPI_Access_Probe" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int RequestId[10] ; - int sts ; - int i ; - for ( i = 0 ; i < 10 ; i++ ) { - if ( myrank == 0 ) { - sts = mpi_access.send(&i,1,MPI_INT,target, RequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << RequestId[i] - << endl ; - } - else { - int source, tag, outcount ; - MPI_Datatype datatype ; - sts = mpi_access.probe(target, source, tag, datatype, outcount ) ; - cout << "test" << myrank << " Probe target " << target << " source " << source - << " tag " << tag << " outcount " << outcount << endl ; - int recvbuf ; - sts = mpi_access.recv(&recvbuf,outcount,datatype,source, RequestId[i], - &outcount) ; - if ( (outcount != 1) | (recvbuf != i) ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - int flag ; - mpi_access.testAll(10,RequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.waitAll(10,RequestId) ; - mpi_access.check() ; - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_SendRecv.cxx b/src/ParaMEDMEMTest/test_MPI_Access_SendRecv.cxx deleted file mode 100644 index 2f7a4d73b..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_SendRecv.cxx +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_SendRecv() { - - cout << "MPIAccessTest::test_MPI_Access_SendRecv" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - cout << "MPIAccessTest::test_MPI_Access_SendRecv must be runned with 2 procs" << endl ; - CPPUNIT_FAIL("test_MPI_Access_SendRecv must be runned with 2 procs") ; - } - - cout << "MPIAccessTest::test_MPI_Access_SendRecv" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int sendRequestId[10] ; - int recvRequestId[10] ; - int sts ; - int i ; - for ( i = 0 ; i < 10 ; i++ ) { - int recvbuf ; - int outcount ; - if ( i & 1 ) { - outcount = -1 ; - sts = mpi_access.sendRecv(&i,1,MPI_INT,target, sendRequestId[i], - &recvbuf,1,MPI_INT,target, recvRequestId[i], - &outcount) ; - } - else { - sts = mpi_access.sendRecv(&i,1,MPI_INT,target, sendRequestId[i], - &recvbuf,1,MPI_INT,target, recvRequestId[i]) ; -// outcount = mpi_access.MPIOutCount( recvRequestId[i] ) ; - outcount = 1 ; - } - cout << "test" << myrank << " Send sendRequestId " << sendRequestId[i] - << " tag " << mpi_access.sendMPITag(target) - << " recvRequestId " << recvRequestId[i] - << " tag " << mpi_access.recvMPITag(target) - << " outcount " << outcount << " MPIOutCount " - << mpi_access.MPIOutCount( recvRequestId[i] ) << endl ; - if ( (outcount != 1) | (recvbuf != i) ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - - int flag ; - mpi_access.testAll(10,sendRequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.waitAll(10,sendRequestId) ; - mpi_access.testAll(10,recvRequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.waitAll(10,recvRequestId) ; - mpi_access.check() ; - - int sendrequests[10] ; - int sendreqsize = mpi_access.sendRequestIds( target , 10 , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - int recvrequests[10] ; - int recvreqsize = mpi_access.sendRequestIds( target , 10 , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Send_Recv.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Send_Recv.cxx deleted file mode 100644 index d147b891d..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Send_Recv.cxx +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_Send_Recv() { - - cout << "test_MPI_Access_Send_Recv" << endl ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - cout << "test_MPI_Access_Send_Recv must be runned with 2 procs" << endl ; - CPPUNIT_FAIL("test_MPI_Access_Send_Recv must be runned with 2 procs") ; - } - - cout << "test_MPI_Access_Send_Recv" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int RequestId[10] ; - int sts ; - int i ; - for ( i = 0 ; i < 10 ; i++ ) { - if ( myrank == 0 ) { - sts = mpi_access.send(&i,1,MPI_INT,target, RequestId[i]) ; - cout << "test" << myrank << " Send RequestId " << RequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - } - else { - int recvbuf ; - int outcount ; - sts = mpi_access.recv(&recvbuf,1,MPI_INT,target, RequestId[i],&outcount) ; - //int source, tag, error, outcount ; - //mpi_access.Status( RequestId[i], source, tag, error, outcount, true) ; - cout << "test" << myrank << " Recv RequestId " << RequestId[i] - << " tag " << mpi_access.recvMPITag(target) - << " outcount " << outcount << endl ; - if ( (outcount != 1) | (recvbuf != i) ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - int flag ; - mpi_access.testAll(10,RequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.waitAll(10,RequestId) ; - mpi_access.check() ; - - if ( myrank == 0 ) { - int sendrequests[10] ; - int sendreqsize = mpi_access.sendRequestIds( target , 10 , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - else { - int recvrequests[10] ; - int recvreqsize = mpi_access.sendRequestIds( target , 10 , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Send_Recv_Length.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Send_Recv_Length.cxx deleted file mode 100644 index db48addac..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Send_Recv_Length.cxx +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_Send_Recv_Length() { - - cout << "test_MPI_Access_Send_Recv_Length" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "test_MPI_Access_Send_Recv_Length must be runned with 2 procs" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_MPI_Access_Send_Recv_Length" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - - if ( myrank >= 2 ) { - mpi_access.barrier() ; - delete group ; - return ; - } - - int target = 1 - myrank ; - int RequestId[10] ; - int sendbuf[9000] ; - int recvbuf[9000] ; - bool recvbufok ; - int sts ; - int i , j ; - for ( i = 0 ; i < 9000 ; i++ ) { - sendbuf[i] = i ; - } - for ( i = 0 ; i < 10 ; i++ ) { - if ( myrank == 0 ) { - sts = mpi_access.send( sendbuf, 1000*i, MPI_INT, target, RequestId[i] ) ; - cout << "test" << myrank << " Send RequestId " << RequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - } - else { - sts = MPI_SUCCESS ; - RequestId[i] = -1 ; - int outcount = 0 ; - if ( i != 0 ) { - sts = mpi_access.recv( recvbuf,1000*i+1,MPI_INT,target, RequestId[i], - &outcount ) ; - } - //int source, tag, error, outcount ; - //mpi_access.Status( RequestId[i], source, tag, error, outcount, true) ; - cout << "test" << myrank << " Recv RequestId " << RequestId[i] - << " tag " << mpi_access.recvMPITag(target) - << " outcount " << outcount << endl ; - recvbufok = true ; - for ( j = 0 ; j < outcount ; j++ ) { - if ( recvbuf[j] != j ) { - cout << "test" << myrank << " recvbuf[ " << j << " ] = " << recvbuf[j] - << endl ; - recvbufok = false ; - break ; - } - } - if ( (outcount != 1000*i) | !recvbufok ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " recvbuf " << recvbuf << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.check() ; - } - int flag ; - mpi_access.testAll(10,RequestId,flag) ; - if ( !flag ) { - ostringstream strstream ; - strstream << "test" << myrank << " flag " << flag << " KO" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - mpi_access.waitAll(10,RequestId) ; - mpi_access.check() ; - - if ( myrank == 0 ) { - int sendrequests[10] ; - int sendreqsize = mpi_access.sendRequestIds( target , 10 , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - else { - int recvrequests[10] ; - int recvreqsize = mpi_access.sendRequestIds( target , 10 , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - } - - mpi_access.barrier() ; - - delete group ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Time.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Time.cxx deleted file mode 100644 index d25251a2e..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Time.cxx +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void MPIAccessTest::test_MPI_Access_Time() { - - cout << "test_MPI_Access_Time" << endl ; - - // MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "test_MPI_Access_Time must be runned with 2 procs" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - - cout << "test_MPI_Access_Time" << myrank << endl ; - - ParaMEDMEM::CommInterface interface ; - - ParaMEDMEM::MPIProcessorGroup* group = new ParaMEDMEM::MPIProcessorGroup(interface) ; - - ParaMEDMEM::MPIAccess mpi_access( group ) ; - -#define maxreq 10 - - if ( myrank >= 2 ) { - cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->Barrier" << endl ; - mpi_access.barrier() ; - cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->Barrier" << endl ; - delete group ; - cout << "test_MPI_Access_Time" << myrank << " OK" << endl ; - return ; - } - - int target = 1 - myrank ; - int SendTimeRequestId[maxreq] ; - int RecvTimeRequestId[maxreq] ; - int SendRequestId[maxreq] ; - int RecvRequestId[maxreq] ; - int sts ; - int sendbuf[maxreq] ; - int recvbuf[maxreq] ; - int i = 0 ; - ParaMEDMEM::TimeMessage aSendTimeMsg[maxreq] ; - ParaMEDMEM::TimeMessage aRecvTimeMsg[maxreq] ; - double t ; - double dt = 1. ; - double maxt = 10. ; - for ( t = 0 ; t < maxt ; t = t+dt ) { - if ( myrank == 0 ) { - aSendTimeMsg[i].time = t ; - aSendTimeMsg[i].deltatime = dt ; - //aSendTimeMsg[i].maxtime = maxt ; - //sts = mpi_access.ISend( &aSendTimeMsg , mpi_access.timeExtent() , - sts = mpi_access.ISend( &aSendTimeMsg[i] , 1 , - mpi_access.timeType() , target , - SendTimeRequestId[i]) ; - cout << "test" << myrank << " ISend RequestId " << SendTimeRequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - sendbuf[i] = i ; - sts = mpi_access.ISend(&sendbuf[i],1,MPI_INT,target, SendRequestId[i]) ; - cout << "test" << myrank << " ISend RequestId " << SendRequestId[i] - << " tag " << mpi_access.sendMPITag(target) << endl ; - } - else { - //sts = mpi_access.IRecv( &aRecvTimeMsg , mpi_access.timeExtent() , - sts = mpi_access.IRecv( &aRecvTimeMsg[i] , 1 , - mpi_access.timeType() , target , - RecvTimeRequestId[i]) ; - cout << "test" << myrank << " IRecv RequestId " << RecvTimeRequestId[i] - << " tag " << mpi_access.recvMPITag(target) << endl ; - sts = mpi_access.IRecv(&recvbuf[i],1,MPI_INT,target, RecvRequestId[i]) ; - cout << "test" << myrank << " IRecv RequestId " << RecvRequestId[i] - << " tag " << mpi_access.recvMPITag(target) << endl ; - } - int j ; - for (j = 0 ; j <= i ; j++) { - int flag ; - if ( myrank == 0 ) { - mpi_access.test( SendTimeRequestId[j], flag ) ; - } - else { - mpi_access.test( RecvTimeRequestId[j], flag ) ; - } - if ( flag ) { - int target,source, tag, error, outcount ; - if ( myrank == 0 ) { - mpi_access.status( SendTimeRequestId[j], target, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Send TimeRequestId " << SendTimeRequestId[j] - << ") : target " << target << " tag " << tag << " error " << error - << " flag " << flag << aSendTimeMsg[j] << endl ; - } - else { - mpi_access.status( RecvTimeRequestId[j], source, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Recv TimeRequestId " - << RecvTimeRequestId[j] << ") : source " << source << " tag " << tag - << " error " << error << " outcount " << outcount - << " flag " << flag << aRecvTimeMsg[j] << endl ; - if ( (outcount != 1) | (aRecvTimeMsg[j].time != j) ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount << " KO" - << " RecvTimeRequestId " << RecvTimeRequestId[j] << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " RecvTimeRequestId " << RecvTimeRequestId[j] << " OK" << endl - << "===========================================================" - << endl ; - } - } - } - if ( myrank == 0 ) { - mpi_access.test( SendRequestId[j], flag ) ; - } - else { - mpi_access.test( RecvRequestId[j], flag ) ; - } - if ( flag ) { - int target,source, tag, error, outcount ; - if ( myrank == 0 ) { - mpi_access.status( SendRequestId[j], target, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Send RequestId " << SendRequestId[j] - << ") : target " << target << " tag " << tag << " error " << error - << " flag " << flag << endl ; - } - else { - mpi_access.status( RecvRequestId[j], source, tag, error, outcount, - true ) ; - cout << "test" << myrank << " Test(Recv RequestId " - << RecvRequestId[j] << ") : source " << source << " tag " << tag - << " error " << error << " outcount " << outcount - << " flag " << flag << endl ; - if ( (outcount != 1) | (recvbuf[j] != j) ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " outcount " - << outcount << " recvbuf " << recvbuf[j] << " KO" << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "===========================================================" - << endl << "test" << myrank << " outcount " << outcount - << " RequestId " << RecvRequestId[j] << " OK" << endl - << "===========================================================" - << endl ; - } - } - } - } - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - mpi_access.errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - - if ( sts != MPI_SUCCESS ) { - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - i = i + 1 ; - } - - mpi_access.check() ; - if ( myrank == 0 ) { - mpi_access.waitAll(maxreq, SendTimeRequestId) ; - mpi_access.deleteRequests(maxreq, SendTimeRequestId) ; - mpi_access.waitAll(maxreq, SendRequestId) ; - mpi_access.deleteRequests(maxreq, SendRequestId) ; - } - else { - mpi_access.waitAll(maxreq, RecvTimeRequestId) ; - mpi_access.deleteRequests(maxreq, RecvTimeRequestId) ; - mpi_access.waitAll(maxreq, RecvRequestId) ; - mpi_access.deleteRequests(maxreq, RecvRequestId) ; - } - mpi_access.check() ; - - if ( myrank == 0 ) { - int sendrequests[2*maxreq] ; - int sendreqsize = mpi_access.sendRequestIds( target , 2*maxreq , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - else { - int recvrequests[2*maxreq] ; - int recvreqsize = mpi_access.sendRequestIds( target , 2*maxreq , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - - cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->Barrier" << endl ; - mpi_access.barrier() ; - cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->Barrier" << endl ; - - delete group ; - - // MPI_Finalize(); - - cout << "test_MPI_Access_Time" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_MPI_Access_Time_0.cxx b/src/ParaMEDMEMTest/test_MPI_Access_Time_0.cxx deleted file mode 100644 index c83eab086..000000000 --- a/src/ParaMEDMEMTest/test_MPI_Access_Time_0.cxx +++ /dev/null @@ -1,471 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "MPIAccessTest.hxx" -#include - -//#include "CommInterface.hxx" -//#include "ProcessorGroup.hxx" -//#include "MPIProcessorGroup.hxx" -#include "MPIAccess.hxx" - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace ParaMEDMEM; - -void chksts( int sts , int myrank , ParaMEDMEM::MPIAccess * mpi_access ) { - char msgerr[MPI_MAX_ERROR_STRING] ; - int lenerr ; - if ( sts != MPI_SUCCESS ) { - mpi_access->errorString(sts, msgerr, &lenerr) ; - cout << "test" << myrank << " lenerr " << lenerr << " " - << msgerr << endl ; - ostringstream strstream ; - strstream << "===========================================================" - << "test" << myrank << " KO" - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } -return ; -} - -void MPIAccessTest::test_MPI_Access_Time_0() { - - cout << "test_MPI_Access_Time_0" << endl ; - -// MPI_Init(&argc, &argv) ; - - int size ; - int myrank ; - MPI_Comm_size(MPI_COMM_WORLD,&size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&myrank) ; - - if ( size < 2 ) { - ostringstream strstream ; - strstream << "usage :" << endl - << "mpirun -np test_MPI_Access_Time_0" <= 2 ) { - cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ; - mpi_access->barrier() ; - cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ; - cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ; - mpi_access->barrier() ; - cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ; - delete group ; - delete mpi_access ; - cout << "test_MPI_Access_Time" << myrank << " OK" << endl ; - return ; - } - - int target = 1 - myrank ; - int SendTimeRequestId[maxreq] ; - int RecvTimeRequestId[maxreq] ; - int SendRequestId[maxreq] ; - int RecvRequestId[maxreq] ; - int sts ; - int sendbuf[maxreq] ; - int recvbuf[maxreq] ; - ParaMEDMEM::TimeMessage aSendTimeMsg[maxreq] ; - int lasttime = -1 ; - ParaMEDMEM::TimeMessage RecvTimeMessages[maxreq+1] ; - ParaMEDMEM::TimeMessage *aRecvTimeMsg = &RecvTimeMessages[1] ; -// mpi_access->Trace() ; - int istep = 0 ; - for ( t = 0 ; t < maxt ; t = t+dt[myrank] ) { - cout << "test" << myrank << " ==========================TIME " << t - << " ==========================" << endl ; - if ( myrank == 0 ) { - aSendTimeMsg[istep].time = t ; - aSendTimeMsg[istep].deltatime = dt[myrank] ; - //aSendTimeMsg[istep].maxtime = maxt ; - if ( t+dt[myrank] >= maxt ) { - aSendTimeMsg[istep].deltatime = 0 ; - } - sts = mpi_access->ISend( &aSendTimeMsg[istep] , 1 , - mpi_access->timeType() , target , - SendTimeRequestId[istep]) ; - cout << "test" << myrank << " ISend TimeRequestId " << SendTimeRequestId[istep] - << " tag " << mpi_access->MPITag(SendTimeRequestId[istep]) << endl ; - chksts( sts , myrank , mpi_access ) ; - sendbuf[istep] = istep ; - sts = mpi_access->ISend(&sendbuf[istep],1,MPI_INT,target, SendRequestId[istep]) ; - cout << "test" << myrank << " ISend Data RequestId " << SendRequestId[istep] - << " tag " << mpi_access->MPITag(SendRequestId[istep]) << endl ; - chksts( sts , myrank , mpi_access ) ; -//CheckSent -//========= - int sendrequests[2*maxreq] ; - int sendreqsize = mpi_access->sendRequestIds( target , 2*maxreq , - sendrequests ) ; - int j , flag ; - for ( j = 0 ; j < sendreqsize ; j++ ) { - sts = mpi_access->test( sendrequests[j] , flag ) ; - chksts( sts , myrank , mpi_access ) ; - if ( flag ) { - mpi_access->deleteRequest( sendrequests[j] ) ; - cout << "test" << myrank << " " << j << ". " << sendrequests[j] - << " sendrequest deleted" << endl ; - } - } - } - else { -//InitRecv -//======== - if ( t == 0 ) { - aRecvTimeMsg[lasttime].time = 0 ; - sts = mpi_access->IRecv( &aRecvTimeMsg[lasttime+1] , 1 , - mpi_access->timeType() , - target , RecvTimeRequestId[lasttime+1]) ; - cout << "test" << myrank << " t == 0 IRecv TimeRequestId " - << RecvTimeRequestId[lasttime+1] - << " MPITag " << mpi_access->MPITag( RecvTimeRequestId[lasttime+1] ) - << " MPICompleted " - << mpi_access->MPICompleted( RecvTimeRequestId[lasttime+1] ) << endl ; - chksts( sts , myrank , mpi_access ) ; - } - else { - cout << "test" << myrank << " t # 0 lasttime " << lasttime << endl ; -//InitialOutTime -//============== - bool outtime = false ; - if ( lasttime != -1 ) { - if ( t <= aRecvTimeMsg[lasttime-1].time ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " t " << t << " <= " - << "aRecvTimeMsg[ " << lasttime << "-1 ].time " - << aRecvTimeMsg[lasttime-1].time << " KO" << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "===========================================================" - << endl << "test" << myrank << " t " << t << " > " - << "aRecvTimeMsg[ " << lasttime << "-1 ].time " - << aRecvTimeMsg[lasttime-1].time << " OK" << endl - << "===========================================================" - << endl ; - } - //outtime = ((aRecvTimeMsg[lasttime].time + - // aRecvTimeMsg[lasttime].deltatime) >= - // aRecvTimeMsg[lasttime].maxtime) ; - outtime = aRecvTimeMsg[lasttime].deltatime == 0 ; - } -// CheckRecv - CheckTime -// On a lasttime tel que : -// aRecvTimeMsg[ lasttime-1 ].time < T(i-1) <= aRecvTimeMsg[ lasttime ].time -// On cherche lasttime tel que : -// aRecvTimeMsg[ lasttime-1 ].time < T(i) <= aRecvTimeMsg[ lasttime ].time - if ( t <= aRecvTimeMsg[lasttime].time ) { - outtime = false ; - } - cout << "test" << myrank << " while outtime( " << outtime << " && t " << t - << " > aRecvTimeMsg[ " << lasttime << " ] " - << aRecvTimeMsg[lasttime].time << " )" << endl ; - while ( !outtime && (t > aRecvTimeMsg[lasttime].time) ) { - lasttime += 1 ; -//TimeMessage -//=========== - sts = mpi_access->wait( RecvTimeRequestId[lasttime] ) ; - chksts( sts , myrank , mpi_access ) ; - cout << "test" << myrank << " Wait done RecvTimeRequestId " - << RecvTimeRequestId[lasttime] << " lasttime " << lasttime - << " tag " << mpi_access->MPITag(RecvTimeRequestId[lasttime]) - << aRecvTimeMsg[lasttime] << endl ; - if ( lasttime == 0 ) { - aRecvTimeMsg[lasttime-1] = aRecvTimeMsg[lasttime] ; - } - mpi_access->deleteRequest( RecvTimeRequestId[lasttime] ) ; - - double deltatime = aRecvTimeMsg[lasttime].deltatime ; - //double maxtime = aRecvTimeMsg[lasttime].maxtime ; - double nexttime = aRecvTimeMsg[lasttime].time + deltatime ; - cout << "test" << myrank << " t " << t << " lasttime " << lasttime - << " deltatime " << deltatime - << " nexttime " << nexttime << endl ; - //if ( nexttime < maxtime && t > nexttime ) { - if ( deltatime != 0 && t > nexttime ) { -//CheckRecv : -//========= - //while ( nexttime < maxtime && t > nexttime ) { - while ( deltatime != 0 && t > nexttime ) { - int source, MPITag, outcount ; - MPI_Datatype datatype ; - sts = mpi_access->probe( target , source, MPITag, datatype, - outcount ) ; - chksts( sts , myrank , mpi_access ) ; -// Cancel DataMessages jusqu'a un TimeMessage - int cancelflag ; - while ( !mpi_access->isTimeMessage( MPITag ) ) { - sts = mpi_access->cancel( source, MPITag, datatype, outcount , - //sts = mpi_access->cancel( source, datatype, outcount , - //RecvRequestId[lasttime] , - cancelflag ) ; - cout << "test" << myrank << " Recv TO CANCEL RequestId " - << RecvRequestId[lasttime] - << " tag " << mpi_access->recvMPITag( target ) - << " cancelflag " << cancelflag << endl ; - chksts( sts , myrank , mpi_access ) ; - sts = mpi_access->probe( target , source, MPITag, datatype, - outcount ) ; - chksts( sts , myrank , mpi_access ) ; - } -//On peut avancer en temps - nexttime += deltatime ; - //if ( nexttime < maxtime && t > nexttime ) { - if ( deltatime != 0 && t > nexttime ) { -// Cancel du TimeMessage - sts = mpi_access->cancel( source, MPITag, datatype, outcount , - //sts = mpi_access->cancel( source, datatype, outcount , - //RecvRequestId[lasttime] , - cancelflag ) ; - cout << "test" << myrank << " Time TO CANCEL RequestId " - << RecvRequestId[lasttime] - << " tag " << mpi_access->recvMPITag( target ) - << " cancelflag " << cancelflag << endl ; - chksts( sts , myrank , mpi_access ) ; - } - } - } - else { -//DoRecv -//====== - cout << "test" << myrank << " Recv target " << target - << " lasttime " << lasttime - << " lasttime-1 " << aRecvTimeMsg[lasttime-1] - << " lasttime " << aRecvTimeMsg[lasttime] - << endl ; - sts = mpi_access->recv(&recvbuf[lasttime],1,MPI_INT,target, - RecvRequestId[lasttime]) ; - cout << "test" << myrank << " Recv RequestId " - << RecvRequestId[lasttime] - << " tag " << mpi_access->recvMPITag( target ) - << endl ; - chksts( sts , myrank , mpi_access ) ; - } - //outtime = ((aRecvTimeMsg[lasttime].time + - // aRecvTimeMsg[lasttime].deltatime) >= - // aRecvTimeMsg[lasttime].maxtime) ; - outtime = aRecvTimeMsg[lasttime].deltatime == 0 ; - if ( !outtime ) { -// Une lecture asynchrone d'un message temps a l'avance - sts = mpi_access->IRecv( &aRecvTimeMsg[lasttime+1] , 1 , - mpi_access->timeType() , target , - RecvTimeRequestId[lasttime+1]) ; - cout << "test" << myrank << " IRecv TimeRequestId " - << RecvTimeRequestId[lasttime+1] << " MPITag " - << mpi_access->MPITag( RecvTimeRequestId[lasttime+1] ) - << " MPICompleted " - << mpi_access->MPICompleted( RecvTimeRequestId[lasttime+1] ) - << endl ; - chksts( sts , myrank , mpi_access ) ; - } - else if ( t <= aRecvTimeMsg[lasttime].time ) { - outtime = false ; - } - } - - //printf("DEBUG t %.15f Msg[lasttime-1] %.15f Msg[lasttime] %.15f \n",t, - // aRecvTimeMsg[lasttime-1].time,aRecvTimeMsg[lasttime].time) ; - if ( ((t <= aRecvTimeMsg[lasttime-1].time) || - (t > aRecvTimeMsg[lasttime].time)) && !outtime ) { - ostringstream strstream ; - strstream << "===========================================================" - << endl << "test" << myrank << " t " << t << " <= " - << "aRecvTimeMsg[ " << lasttime << "-1 ].time " - << aRecvTimeMsg[lasttime-1].time << " ou t " << t << " > " - << "aRecvTimeMsg[ " << lasttime << " ].time " - << aRecvTimeMsg[lasttime].time << endl - << " ou bien outtime " << outtime << " KO RequestTimeIds " - << RecvTimeRequestId[lasttime-1] << " " << RecvTimeRequestId[lasttime] - << " RequestIds " - << RecvRequestId[lasttime-1] << " " << RecvRequestId[lasttime] << endl - << "===========================================================" - << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "===========================================================" - << endl << "test" << myrank - << " aRecvTimeMsg[ " << lasttime << "-1 ].time " - << aRecvTimeMsg[lasttime-1].time << " < t " << t << " <= " - << "aRecvTimeMsg[ " << lasttime << " ].time " - << aRecvTimeMsg[lasttime].time << endl - << " ou bien outtime " << outtime << " OK RequestTimeIds " - << RecvTimeRequestId[lasttime-1] << " " << RecvTimeRequestId[lasttime] - << " RequestIds " - << RecvRequestId[lasttime-1] << " " << RecvRequestId[lasttime] << endl - << "===========================================================" - << endl ; - } - } - } - chksts( sts , myrank , mpi_access ) ; - istep = istep + 1 ; - } - - cout << "test" << myrank << " Barrier :" << endl ; - mpi_access->barrier() ; - - mpi_access->check() ; - - if ( myrank == 0 ) { -//CheckFinalSent -//============== - cout << "test" << myrank << " CheckFinalSent :" << endl ; - int sendrequests[2*maxreq] ; - int sendreqsize = mpi_access->sendRequestIds( target , 2*maxreq , sendrequests ) ; - int j ; - for ( j = 0 ; j < sendreqsize ; j++ ) { - sts = mpi_access->wait( sendrequests[j] ) ; - chksts( sts , myrank , mpi_access ) ; - mpi_access->deleteRequest( sendrequests[j] ) ; - cout << "test" << myrank << " " << j << ". " << sendrequests[j] << " deleted" - << endl ; - } - } - else { - cout << "test" << myrank << " CheckFinalRecv :" << endl ; - int recvrequests[2*maxreq] ; - int recvreqsize = mpi_access->recvRequestIds( target , 2*maxreq , recvrequests ) ; - int cancelflag ; - int j ; - for ( j = 0 ; j < recvreqsize ; j++ ) { - sts = mpi_access->cancel( recvrequests[j] , cancelflag ) ; - chksts( sts , myrank , mpi_access ) ; - mpi_access->deleteRequest( recvrequests[j] ) ; - cout << "test" << myrank << " " << j << ". " << recvrequests[j] << " deleted" - << " cancelflag " << cancelflag << endl ; - } - int source, MPITag, outcount , flag ; - MPI_Datatype datatype ; - sts = mpi_access->IProbe( target , source, MPITag, datatype, - outcount , flag ) ; - chksts( sts , myrank , mpi_access ) ; - while ( flag ) { - sts = mpi_access->cancel( source, MPITag, datatype, outcount , - //sts = mpi_access->cancel( source, datatype, outcount , - //RecvRequestId[lasttime] , - cancelflag ) ; - cout << "test" << myrank << " TO CANCEL RequestId " - << RecvRequestId[lasttime] - << " tag " << mpi_access->recvMPITag( target ) - << " cancelflag " << cancelflag << endl ; - chksts( sts , myrank , mpi_access ) ; - sts = mpi_access->IProbe( target , source, MPITag, datatype, - outcount , flag ) ; - chksts( sts , myrank , mpi_access ) ; - } - } - mpi_access->check() ; - - if ( myrank == 0 ) { - int sendrequests[2*maxreq] ; - int sendreqsize = mpi_access->sendRequestIds( target , 2*maxreq , sendrequests ) ; - if ( sendreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " sendreqsize " << sendreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - else { - int recvrequests[2*maxreq] ; - int recvreqsize = mpi_access->recvRequestIds( target , 2*maxreq , recvrequests ) ; - if ( recvreqsize != 0 ) { - ostringstream strstream ; - strstream << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " KO" << endl - << "=========================================================" << endl ; - cout << strstream.str() << endl ; - CPPUNIT_FAIL( strstream.str() ) ; - } - else { - cout << "=========================================================" << endl - << "test" << myrank << " recvreqsize " << recvreqsize << " OK" << endl - << "=========================================================" << endl ; - } - } - - int i ; - for ( i = 0 ; i <= lasttime ; i++ ) { - cout << "test" << myrank << " " << i << ". RecvTimeMsg " - << aRecvTimeMsg[i].time << " recvbuf " << recvbuf[i] << endl ; - } - - cout << "test_MPI_Access_Time_0 rank" << myrank << " --> mpi_access->barrier" << endl ; - mpi_access->barrier() ; - cout << "test_MPI_Access_Time_0 rank" << myrank << " <-- mpi_access->barrier" << endl ; - - delete group ; - delete mpi_access ; - -// MPI_Finalize(); - - cout << "test" << myrank << " OK" << endl ; - - return ; -} - - - - diff --git a/src/ParaMEDMEMTest/test_perf.cxx b/src/ParaMEDMEMTest/test_perf.cxx deleted file mode 100644 index 9c40165c0..000000000 --- a/src/ParaMEDMEMTest/test_perf.cxx +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include "ParaMEDMEMTest.hxx" -#include - -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "DEC.hxx" -#include "MxN_Mapping.hxx" -#include "InterpKernelDEC.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "ComponentTopology.hxx" -#include "ICoCoMEDField.hxx" -#include "MEDLoader.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -#define ENABLE_FORCED_FAILURES - -#ifndef CLK_TCK -#include -#define CLK_TCK sysconf(_SC_CLK_TCK); -#endif - -using namespace std; -using namespace ParaMEDMEM; - -void testInterpKernelDEC_2D(const string& filename1, const string& meshname1, - const string& filename2, const string& meshname2, - int nproc_source, double epsilon, bool tri, bool all); -void get_time( float *telps, float *tuser, float *tsys, float *tcpu ); - -int main(int argc, char *argv[]) -{ - string filename1, filename2; - string meshname1, meshname2; - int nproc_source=1, rank; - double epsilon=1.e-6; - int count=0; - bool tri=false; - bool all=false; - - MPI_Init(&argc,&argv); - - for(int i=1;i self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()){ - string master = filename_xml1; - - ostringstream strstream; - if( nproc_source == 1 ) - strstream <getNumberOfCells(); - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - - dec.attachLocalField(icocofield); - } - - //loading the geometry for the target group - if (target_group->containsMyRank()){ - string master= filename_xml2; - ostringstream strstream; - if( (size-nproc_source) == 1 ) - strstream << master<<".med"; - else - strstream << master<<(rank-nproc_source+1)<<".med"; - ostringstream meshname ; - if( (size-nproc_source) == 1 ) - meshname<< meshname2; - else - meshname<< meshname2<<"_"<incrRef(); - - paramesh=new ParaMESH (mesh,*target_group,"target mesh"); - ParaMEDMEM::ComponentTopology comptopo; - parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); - - int nb_local=mesh->getNumberOfCells(); - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemgetCellMesh(),parafield->getField()); - - dec.attachLocalField(icocofield); - } - - - //attaching a DEC to the source group - double field_before_int; - double field_after_int; - - if (source_group->containsMyRank()){ - field_before_int = parafield->getVolumeIntegral(0,true); - get_time( &telps, &tcpu_u, &tcpu_s, &tcpu ); - dec.synchronize(); - get_time( &telps, &tcpu_u, &tcpu_s, &tcpu ); - if( rank == 0 ) - cout << "SYNCHRONIZE : Telapse = " << telps << " TuserCPU = " << tcpu_u << " TsysCPU = " << tcpu_s << " TCPU = " << tcpu << endl; - cout<<"DEC usage"< - -using namespace ParaMEDMEM; -using namespace ICoCo; - -enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int }; -%} - -%include "CommInterface.hxx" -%include "ProcessorGroup.hxx" -%include "DECOptions.hxx" -%include "ParaMESH.hxx" -%include "ParaFIELD.hxx" -%include "MPIProcessorGroup.hxx" -%include "ComponentTopology.hxx" -%include "DEC.hxx" -%include "InterpKernelDEC.hxx" -%include "StructuredCoincidentDEC.hxx" - -%rename(ICoCoMEDField) ICoCo::MEDField; -%include "ICoCoMEDField.hxx" - -%nodefaultctor; - -/* This object can be used only if MED_ENABLE_FVM is defined*/ -#ifdef MED_ENABLE_FVM -class NonCoincidentDEC : public DEC -{ -public: - NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target); -}; -#endif - -%extend ParaMEDMEM::ParaMESH -{ - PyObject *getGlobalNumberingCell2() const - { - const int *tmp=self->getGlobalNumberingCell(); - int size=self->getCellMesh()->getNumberOfCells(); - PyObject *ret=PyList_New(size); - for(int i=0;igetGlobalNumberingFace(); - int size=self->getFaceMesh()->getNumberOfCells(); - PyObject *ret=PyList_New(size); - for(int i=0;igetGlobalNumberingNode(); - int size=self->getCellMesh()->getNumberOfNodes(); - PyObject *ret=PyList_New(size); - for(int i=0;i MPI_COMM_WORLD and MPI_COMM_SELF -%typemap(in) MPI_Comm -{ - switch (PyInt_AsLong($input)) - { - case mpi_comm_world: $1 = MPI_COMM_WORLD; break; - case mpi_comm_self: $1 = MPI_COMM_SELF; break; - default: - PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Comm"); - return NULL; - } -} -// Map mpi_double and mpi_int -> MPI_DOUBLE and MPI_INT -%typemap(in) MPI_Datatype -{ - switch (PyInt_AsLong($input)) - { - case mpi_double: $1 = MPI_DOUBLE; break; - case mpi_int: $1 = MPI_INT; break; - default: - PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Datatype"); - return NULL; - } -} -// The following code gets inserted into the result python file: -// create needed python symbols -%pythoncode %{ -MPI_COMM_WORLD = mpi_comm_world -MPI_COMM_SELF = mpi_comm_self -MPI_DOUBLE = mpi_double -MPI_INT = mpi_int -%} -//============================================================================================= - -// ============== -// MPI_Comm_size -// ============== -%inline %{ PyObject* MPI_Comm_size(MPI_Comm comm) - { - int res = 0; - int err = MPI_Comm_size(comm, &res); - if ( err != MPI_SUCCESS ) - { - PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_size()"); - return NULL; - } - return PyInt_FromLong( res ); - } %} - -// ============== -// MPI_Comm_rank -// ============== -%inline %{ PyObject* MPI_Comm_rank(MPI_Comm comm) - { - int res = 0; - int err = MPI_Comm_rank(comm, &res); - if ( err != MPI_SUCCESS ) - { - PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_rank()"); - return NULL; - } - return PyInt_FromLong( res ); - } - %} - -int MPI_Init(int *argc, char ***argv ); -int MPI_Barrier(MPI_Comm comm); -int MPI_Finalize(); - -// ========== -// MPI_Bcast -// ========== - -%inline %{ PyObject* MPI_Bcast(PyObject* buffer, int nb, MPI_Datatype type, int root, MPI_Comm c) - { - // buffer must be a list - if (!PyList_Check(buffer)) - { - PyErr_SetString(PyExc_TypeError, "buffer is expected to be a list"); - return NULL; - } - // check list size - int aSize = PyList_Size(buffer); - if ( aSize != nb ) - { - std::ostringstream stream; stream << "buffer is expected to be of size " << nb; - PyErr_SetString(PyExc_ValueError, stream.str().c_str()); - return NULL; - } - // allocate and fill a buffer - void* aBuf = 0; - int* intBuf = 0; - double* dblBuf = 0; - if ( type == MPI_DOUBLE ) - { - aBuf = (void*) ( dblBuf = new double[ nb ] ); - for ( int i = 0; i < aSize; ++i ) - dblBuf[i] = PyFloat_AS_DOUBLE( PyList_GetItem( buffer, i )); - } - else if ( type == MPI_INT ) - { - aBuf = (void*) ( intBuf = new int[ nb ] ); - for ( int i = 0; i < aSize; ++i ) - intBuf[i] = int( PyInt_AS_LONG( PyList_GetItem( buffer, i ))); - } - else - { - PyErr_SetString(PyExc_TypeError, "Only MPI_DOUBLE and MPI_INT supported"); - return NULL; - } - // call MPI_Bcast - int err = MPI_Bcast(aBuf, nb, type, root, c); - // treat error - if ( err != MPI_SUCCESS ) - { - PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Bcast()"); - delete [] intBuf; delete [] dblBuf; - return NULL; - } - // put recieved data into the list - int pyerr = 0; - if ( type == MPI_DOUBLE ) - { - for ( int i = 0; i < aSize && !pyerr; ++i ) - pyerr = PyList_SetItem(buffer, i, PyFloat_FromDouble( dblBuf[i] )); - delete [] dblBuf; - } - else - { - for ( int i = 0; i < aSize && !pyerr; ++i ) - pyerr = PyList_SetItem(buffer, i, PyInt_FromLong( intBuf[i] )); - delete [] intBuf; - } - if ( pyerr ) - { - PyErr_SetString(PyExc_RuntimeError, "Error of PyList_SetItem()"); - return NULL; - } - return PyInt_FromLong( err ); - - } - %} - diff --git a/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.typemap b/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.typemap deleted file mode 100644 index f73253e4b..000000000 --- a/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.typemap +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2007-2010 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 std_set.i -%include std_string.i - -%template() std::set; - -// Creates "int *argc, char ***argv" parameters from input list -%typemap(in) (int *argc, char ***argv) { - int i; - if (!PyList_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting a list"); - return NULL; - } - int aSize = PyList_Size($input); - $1 = &aSize; - char** aStrs = (char **) malloc((aSize+1)*sizeof(char *)); - for (i = 0; i < aSize; i++) { - PyObject *s = PyList_GetItem($input,i); - if (!PyString_Check(s)) { - free(aStrs); - PyErr_SetString(PyExc_ValueError, "List items must be strings"); - return NULL; - } - aStrs[i] = PyString_AsString(s); - } - aStrs[i] = 0; - $2 = &aStrs; -} - -%typemap(freearg) (int *argc, char ***argv) { - if ($2) free(*($2)); -} - -/* MACRO: IN typemap for std::set C++ object */ -%define TYPEMAP_INPUT_SET_BY_VALUE( TYPE ) -{ - /* typemap in for set */ - /* Check if is a list */ - if (PyList_Check($input)) - { - int size = PyList_Size($input); - std::set< TYPE > tmpSet; - - for (int i=0; i < size; i++) - { - PyObject * tmp = PyList_GetItem($input,i); - TYPE elem = PyInt_AsLong(tmp); - tmpSet.insert(elem); - } - $1 = tmpSet; - } - else - { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} -%enddef - -%typemap(in) std::set -{ - TYPEMAP_INPUT_SET_BY_VALUE( int ) -} -%typecheck(SWIG_TYPECHECK_POINTER) std::set { - $1 = PyList_Check($input) ? 1 : 0; -} diff --git a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py b/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py deleted file mode 100755 index 2a9a77d29..000000000 --- a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libParaMEDMEM_Swig import * -import sys, os -import unittest -import math - -class ParaMEDMEMBasicsTest(unittest.TestCase): - def testInterpKernelDEC_2D(self): - MPI_Init(sys.argv) - size = MPI_Comm_size(MPI_COMM_WORLD) - rank = MPI_Comm_rank(MPI_COMM_WORLD) - if size != 5: - raise RuntimeError, "Expect MPI_COMM_WORLD size == 5" - print rank - nproc_source = 3 - procs_source = range( nproc_source ) - procs_target = range( size - nproc_source + 1, size) - - interface = CommInterface() - target_group = MPIProcessorGroup(interface, procs_target) - source_group = MPIProcessorGroup(interface, procs_source) - dec = InterpKernelDEC(source_group, target_group) - - mesh =0 - support =0 - paramesh =0 - parafield =0 - icocofield =0 - data_dir = os.environ['MED_ROOT_DIR'] - tmp_dir = os.environ['TMP'] - - if not tmp_dir or len(tmp_dir)==0: - tmp_dir = "/tmp" - pass - - filename_xml1 = os.path.join(data_dir, "share/salome/resources/med/square1_split") - filename_xml2 = os.path.join(data_dir, "share/salome/resources/med/square2_split") - - MPI_Barrier(MPI_COMM_WORLD) - if source_group.containsMyRank(): - filename = filename_xml1 + str(rank+1) + ".med" - meshname = "Mesh_2_" + str(rank+1) - mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0) - paramesh=ParaMESH(mesh,source_group,"source mesh") - comptopo = ComponentTopology() - parafield = ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo) - parafield.getField().setNature(ConservativeVolumic) - nb_local=mesh.getNumberOfCells() - value = [1.0]*nb_local - parafield.getField().setValues(value) - icocofield = ICoCoMEDField(mesh,parafield.getField()) - dec.setMethod("P0") - dec.attachLocalField(icocofield) - pass - else: - filename = filename_xml2 + str(rank - nproc_source + 1) + ".med" - meshname = "Mesh_3_" + str(rank - nproc_source + 1) - mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0) - paramesh=ParaMESH(mesh,target_group,"target mesh") - comptopo = ComponentTopology() - parafield = ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo) - parafield.getField().setNature(ConservativeVolumic) - nb_local=mesh.getNumberOfCells() - value = [0.0]*nb_local - parafield.getField().setValues(value) - icocofield = ICoCoMEDField(mesh,parafield.getField()) - dec.setMethod("P0") - dec.attachLocalField(icocofield) - pass - - if source_group.containsMyRank(): - field_before_int = parafield.getVolumeIntegral(0,True) - dec.synchronize() - dec.setForcedRenormalization(False) - dec.sendData() - dec.recvData() - field_after_int=parafield.getVolumeIntegral(0,True); - self.failUnless(math.fabs(field_after_int-field_before_int)<1e-8) - pass - else: - dec.synchronize() - dec.setForcedRenormalization(False) - dec.recvData() - dec.sendData() - pass - ## end - interface = 0 - target_group = 0 - source_group = 0 - dec = 0 - mesh =0 - support =0 - paramesh =0 - parafield =0 - icocofield =0 - MPI_Barrier(MPI_COMM_WORLD) - MPI_Finalize() - pass - pass - -unittest.main() diff --git a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py deleted file mode 100755 index 256a0a3ce..000000000 --- a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from ParaMEDMEM import * -import sys, os - -MPI_Init(sys.argv) - -size = MPI_Comm_size(MPI_COMM_WORLD) -rank = MPI_Comm_rank(MPI_COMM_WORLD) -if size != 5: - raise RuntimeError, "Expect MPI_COMM_WORLD size == 5" - -nproc_source = 3 -procs_source = range( nproc_source ) -procs_target = range( size - nproc_source + 1, size) - -interface = CommInterface() - -target_group = MPIProcessorGroup(interface, procs_target) -source_group = MPIProcessorGroup(interface, procs_source) - -source_mesh= 0 -target_mesh= 0 -parasupport= 0 -mesh = 0 -support = 0 -field = 0 -paramesh = 0 -parafield = 0 -icocofield = 0 - -dec = NonCoincidentDEC(source_group, target_group) - -data_dir = os.environ['MED_ROOT_DIR'] -tmp_dir = os.environ['TMP'] -if tmp_dir == '': - tmp_dir = "/tmp" - pass - -filename_xml1 = data_dir + "/share/salome/resources/med/square1_split" -filename_xml2 = data_dir + "/share/salome/resources/med/square2_split" - -MPI_Barrier(MPI_COMM_WORLD) - -if source_group.containsMyRank(): - - filename = filename_xml1 + str(rank+1) + ".med" - meshname = "Mesh_2_" + str(rank+1) - - mesh = MESH(MED_DRIVER, filename, meshname) - support = SUPPORT(mesh, "all elements", MED_CELL) - paramesh = ParaMESH(mesh, source_group, "source mesh") - - parasupport = UnstructuredParaSUPPORT( support, source_group) - comptopo = ComponentTopology() - - parafield = ParaFIELD(parasupport, comptopo) - - nb_local = support.getNumberOfElements(MED_ALL_ELEMENTS); - - value = [1.0]*nb_local - - parafield.getField().setValue(value) - icocofield = ICoCo_MEDField(paramesh,parafield) - dec.attachLocalField(icocofield,'P0') - pass - -if target_group.containsMyRank(): - - filename = filename_xml2 + str(rank - nproc_source + 1) + ".med" - meshname = "Mesh_3_" + str(rank - nproc_source + 1) - - mesh = MESH(MED_DRIVER, filename, meshname) - support = SUPPORT(mesh, "all elements", MED_CELL) - paramesh = ParaMESH(mesh, target_group, "target mesh") - - parasupport = UnstructuredParaSUPPORT( support, target_group) - comptopo = ComponentTopology() - parafield = ParaFIELD(parasupport, comptopo) - - nb_local = support.getNumberOfElements(MED_ALL_ELEMENTS) - value = [0.0]*nb_local - - parafield.getField().setValue(value) - icocofield = ICoCo_MEDField(paramesh,parafield) - - dec.attachLocalField(icocofield, 'P0') - pass - -field_before_int = [0.0] -field_after_int = [0.0] - -if source_group.containsMyRank(): - - field_before_int = [parafield.getVolumeIntegral(1)] - MPI_Bcast(field_before_int, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); - dec.synchronize() - print "DEC usage" - dec.setForcedRenormalization(False) - - dec.sendData() - pass - -if target_group.containsMyRank(): - - MPI_Bcast(field_before_int, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD) - dec.synchronize() - dec.setForcedRenormalization(False) - dec.recvData() - field_after_int = [parafield.getVolumeIntegral(1)] - pass - -MPI_Bcast(field_before_int, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD) -MPI_Bcast(field_after_int , 1, MPI_DOUBLE, size-1, MPI_COMM_WORLD) - -epsilon = 1e-6 -if abs(field_before_int[0] - field_after_int[0]) > epsilon: - print "Field before is not equal field after: %s != %s"%\ - (field_before_int[0],field_after_int[0]) - pass - - -MPI_Barrier(MPI_COMM_WORLD) -MPI_Finalize() -print "# End of testNonCoincidentDEC" diff --git a/src/ParaMEDMEM_Swig/test_StructuredCoincodentDEC.py b/src/ParaMEDMEM_Swig/test_StructuredCoincodentDEC.py deleted file mode 100755 index 95a184e98..000000000 --- a/src/ParaMEDMEM_Swig/test_StructuredCoincodentDEC.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 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 -# - -from libParaMEDMEM_Swig import * -import sys, os -import unittest -import math - -class ParaMEDMEMBasicsTest2(unittest.TestCase): - def testStructuredCoincidentDEC(self): - MPI_Init(sys.argv) - # - size = MPI_Comm_size(MPI_COMM_WORLD) - rank = MPI_Comm_rank(MPI_COMM_WORLD) - # - if size < 4: - raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4" - # - interface = CommInterface() - # - self_group = MPIProcessorGroup(interface, rank, rank) - target_group = MPIProcessorGroup(interface, 3, size-1) - source_group = MPIProcessorGroup(interface, 0, 2) - # - mesh = 0 - support = 0 - paramesh = 0 - parafield = 0 - comptopo = 0 - icocofield= 0 - # - data_dir = os.environ['MED_ROOT_DIR'] - tmp_dir = os.environ['TMP'] - if tmp_dir == '': - tmp_dir = "/tmp" - pass - - filename_xml1 = data_dir + "/share/salome/resources/med/square1_split" - filename_2 = data_dir + "/share/salome/resources/med/square1.med" - filename_seq_wr = tmp_dir + "/" - filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med" - - dec = StructuredCoincidentDEC(source_group, target_group) - MPI_Barrier(MPI_COMM_WORLD) - if source_group.containsMyRank(): - filename = filename_xml1 + str(rank+1) + ".med" - meshname = "Mesh_2_" + str(rank+1) - mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0) - paramesh=ParaMESH(mesh,source_group,"source mesh") - comptopo=ComponentTopology(6) - parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh,comptopo) - parafield.getField().setNature(ConservativeVolumic) - nb_local=mesh.getNumberOfCells() - global_numbering=paramesh.getGlobalNumberingCell2() - value = [] - for ielem in range(nb_local): - for icomp in range(6): - value.append(global_numbering[ielem]*6.0+icomp); - pass - pass - parafield.getField().setValues(value) - icocofield = ICoCoMEDField(mesh,parafield.getField()) - dec.setMethod("P0") - dec.attachLocalField(parafield) - dec.synchronize() - dec.sendData() - pass - - if target_group.containsMyRank(): - meshname2 = "Mesh_2" - mesh=MEDLoader.ReadUMeshFromFile(filename_2, meshname2,0) - paramesh=ParaMESH(mesh, self_group, "target mesh") - comptopo=ComponentTopology(6,target_group) - parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo) - parafield.getField().setNature(ConservativeVolumic) - nb_local=mesh.getNumberOfCells() - value = [0.0]*(nb_local*comptopo.nbLocalComponents()) - parafield.getField().setValues(value) - icocofield = ICoCoMEDField(mesh,parafield.getField()) - dec.setMethod("P0") - dec.attachLocalField(parafield) - dec.synchronize() - dec.recvData() - recv_value = parafield.getField().getArray().getValues() - for i in range(nb_local): - first=comptopo.firstLocalComponent() - for icomp in range(comptopo.nbLocalComponents()): - self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]- - (float)(i*6+icomp+first))<1e-12) - pass - pass - pass - comptopo=0 - interface = 0 - mesh =0 - support =0 - paramesh =0 - parafield =0 - icocofield =0 - dec=0 - self_group =0 - target_group = 0 - source_group = 0 - MPI_Barrier(MPI_COMM_WORLD) - MPI_Finalize() - print "End of test StructuredCoincidentDEC" - pass - - -unittest.main() diff --git a/src/RENUMBER/Makefile.am b/src/RENUMBER/Makefile.am deleted file mode 100644 index b170b2dd3..000000000 --- a/src/RENUMBER/Makefile.am +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright (C) 2007-2010 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 -# - -# MED MEDMEM : MED files in memory -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -# this directory must be recompiled before Test folder - -if CPPUNIT_IS_OK -# SUBDIRS=. Test -endif - -lib_LTLIBRARIES= librenumber.la - -salomeinclude_HEADERS= \ -RENUMBER_Renumbering.hxx \ -RenumberingFactory.hxx - -if MED_ENABLE_METIS - salomeinclude_HEADERS+= RENUMBER_METISRenumbering.hxx -endif -if BOOST_IS_OK - salomeinclude_HEADERS+= RENUMBER_BOOSTRenumbering.hxx -endif - -dist_librenumber_la_SOURCES= \ -RENUMBER_Renumbering.cxx \ -RenumberingFactory.cxx - -if MED_ENABLE_METIS - dist_librenumber_la_SOURCES+= RENUMBER_METISRenumbering.cxx -endif -if BOOST_IS_OK - dist_librenumber_la_SOURCES+= RENUMBER_BOOSTRenumbering.cxx -endif - -librenumber_la_CPPFLAGS= $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ - $(BOOST_CPPFLAGS) \ - -I$(srcdir)/../MEDMEM -I$(srcdir)/../INTERP_KERNEL/Bases - -librenumber_la_LDFLAGS= -#libmedsplitter_la_LDFLAGS= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) \ -# ../MEDMEM/libmedmem.la ../MEDWrapper/V2_1/Core/libmed_V2_1.la - -if MED_ENABLE_METIS - librenumber_la_CPPFLAGS+= $(METIS_CPPFLAGS) - librenumber_la_LDFLAGS+= $(METIS_LIBS) -endif -if BOOST_IS_OK - librenumber_la_CPPFLAGS+= $(BOOST_CPPFLAGS) -DENABLE_BOOST - librenumber_la_LDFLAGS+= $(BOOST_LIBS) -endif -if MED_ENABLE_KERNEL - librenumber_la_CPPFLAGS+= ${KERNEL_CXXFLAGS} - librenumber_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace -endif - -librenumber_la_LDFLAGS+= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) \ - ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la - -# Executables targets -bin_PROGRAMS= renumber - -dist_renumber_SOURCES= renumbering.cxx - -renumber_CPPFLAGS= $(librenumber_la_CPPFLAGS) -renumber_LDADD= $(librenumber_la_LDFLAGS) -lm $(BOOST_LIBS) librenumber.la -if MED_ENABLE_KERNEL - renumber_LDADD+= -lSALOMEBasics -endif - -OBSOLETE_FILES = -# MEDSPLITTER_SequentialTopology.cxx \ -# test_HighLevelAPI.cxx - -EXTRA_DIST += $(OBSOLETE_FILES) testRenumbering.py - diff --git a/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx b/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx deleted file mode 100644 index deef9f1f7..000000000 --- a/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include -#include - -#include "RENUMBER_BOOSTRenumbering.hxx" - -void BOOSTRenumbering::renumber(const int* graph,const int* index_graph,int nb_cell,std::vector& iperm,std::vector& perm) -{ - iperm.resize(nb_cell,0); - perm.resize(nb_cell,0); - - typedef boost::adjacency_list > > Graph; - typedef boost::graph_traits::vertex_descriptor Vertex; - typedef boost::graph_traits::vertices_size_type size_type; - Graph G(nb_cell); - for (int i=0;i::type - index_map = boost::get(boost::vertex_index, G); - boost::cuthill_mckee_ordering(G, iperm.rbegin(), boost::get(boost::vertex_color, G), - boost::make_degree_map(G)); - for (size_type c = 0; c != iperm.size(); ++c) - perm[index_map[iperm[c]]] = c; - for(int i=0;i& iperm,std::vector& perm); -}; - -#endif /*BOOSTRENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RENUMBER_METISRenumbering.cxx b/src/RENUMBER/RENUMBER_METISRenumbering.cxx deleted file mode 100644 index 3a98fdf0c..000000000 --- a/src/RENUMBER/RENUMBER_METISRenumbering.cxx +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - -extern "C" -{ -#include "metis.h" -} - -#include "RENUMBER_METISRenumbering.hxx" - -void METISRenumbering::renumber(const int* graph,const int* index_graph,int nb_cell,std::vector& iperm,std::vector& perm) -{ - iperm.resize(nb_cell,0); - perm.resize(nb_cell,0); - int num_flag=1; - int options=0; - METIS_NodeND(&nb_cell,(int*)index_graph,(int*)graph,&num_flag,&options,&iperm[0],&perm[0]); -} diff --git a/src/RENUMBER/RENUMBER_METISRenumbering.hxx b/src/RENUMBER/RENUMBER_METISRenumbering.hxx deleted file mode 100644 index f590a0ebd..000000000 --- a/src/RENUMBER/RENUMBER_METISRenumbering.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2007-2010 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 METISRENUMBERING_HXX_ -#define METISRENUMBERING_HXX_ - -#include "RENUMBER_Renumbering.hxx" - -class METISRenumbering:public Renumbering -{ -public: - virtual void renumber(const int* graph,const int* index_graph,int nb_cell,std::vector& iperm,std::vector& perm); -}; - -#endif /*METISRENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RENUMBER_Renumbering.cxx b/src/RENUMBER/RENUMBER_Renumbering.cxx deleted file mode 100644 index 83f12ed41..000000000 --- a/src/RENUMBER/RENUMBER_Renumbering.cxx +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2007-2010 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 -// - diff --git a/src/RENUMBER/RENUMBER_Renumbering.hxx b/src/RENUMBER/RENUMBER_Renumbering.hxx deleted file mode 100644 index 2c5afe43e..000000000 --- a/src/RENUMBER/RENUMBER_Renumbering.hxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2010 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 RENUMBERING_HXX_ -#define RENUMBERING_HXX_ -#include - -class Renumbering -{ -public: - virtual void renumber(const int* graphe,const int* index_graphe,int nb_cell,std::vector& iperm,std::vector& perm)=0; -}; - -#endif /*RENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RenumberingFactory.cxx b/src/RENUMBER/RenumberingFactory.cxx deleted file mode 100644 index 36f256929..000000000 --- a/src/RENUMBER/RenumberingFactory.cxx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007-2010 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 "RenumberingFactory.hxx" -#include "RENUMBER_Renumbering.hxx" -#ifdef ENABLE_METIS -#include "RENUMBER_METISRenumbering.hxx" -#endif -#ifdef ENABLE_BOOST -#include "RENUMBER_BOOSTRenumbering.hxx" -#endif - -#include - -using namespace std; - -namespace MED_RENUMBER -{ - Renumbering* RenumberingFactory(const string &s) - { -#ifdef ENABLE_METIS -#ifdef ENABLE_BOOST - if (s=="METIS") - { - return new METISRenumbering; - } - else if(s=="BOOST") - { - return new BOOSTRenumbering; - } - else - { - std::cerr << "The method has to be METIS or BOOST" << std::endl; - return 0; - } -#endif -#ifndef ENABLE_BOOST - if (s=="METIS") - { - return new METISRenumbering; - } - else - { - std::cerr << "The method has to be METIS!" << std::endl; - return 0; - } -#endif -#endif -#ifndef ENABLE_METIS -#ifdef ENABLE_BOOST - if (s=="BOOST") - { - return new BOOSTRenumbering; - } - else - { - std::cerr << "The method has to be BOOST!" << std::endl; - return 0; - } -#endif -#ifndef ENABLE_BOOST - std::cerr << "Error, no method compiled" << std::endl; - return 0; -#endif -#endif - } -} diff --git a/src/RENUMBER/RenumberingFactory.hxx b/src/RENUMBER/RenumberingFactory.hxx deleted file mode 100644 index 3ddd2cab8..000000000 --- a/src/RENUMBER/RenumberingFactory.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2007-2010 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 RENUMBERINGFACTORY_HXX_ -#define RENUMBERINGFACTORY_HXX_ - -#include -#include "RENUMBER_Renumbering.hxx" - -namespace MED_RENUMBER -{ - Renumbering* RenumberingFactory(const std::string& s); -} - -#endif /*RENUMBERINGFACTORY_HXX_*/ diff --git a/src/RENUMBER/renumbering.cxx b/src/RENUMBER/renumbering.cxx deleted file mode 100644 index d5ef000c7..000000000 --- a/src/RENUMBER/renumbering.cxx +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright (C) 2007-2010 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 -#include -#include -#include - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_MedFileBrowser.hxx" - -#include "RenumberingFactory.hxx" - -#include -using namespace MEDMEM; -using namespace std; -using namespace MED_EN; -using namespace MED_RENUMBER; - -namespace -{ - -void computeNeighbour(const MESH* mesh,const medGeometryElement& Type, vector >& neighbour, int& ntot,int& nb_cell) -{ - CONNECTIVITY* conn = (CONNECTIVITY*)mesh->getConnectivityptr(); - conn->calculateFullDescendingConnectivity(MED_CELL); - const int* rev_conn=mesh->getReverseConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - const int* rev_conn_index=mesh->getReverseConnectivityIndex(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - int nb_face= mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS); - int nb_edge = mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS); - nb_cell= mesh->getNumberOfElements(MED_CELL,Type); - - int nb_constituent; - if(mesh->getMeshDimension()==2) - nb_constituent = nb_edge; - else if (mesh->getMeshDimension()==3) - nb_constituent = nb_face; - else - throw MEDEXCEPTION("Wrong dimension"); - - neighbour.resize(nb_cell,(list)0); - ntot=0; - for(int i=0;i& iperm) -{ - { - const int *conn_init=mesh.getConnectivity(MED_NODAL,MED_CELL,Type); - const int *conn_index_init=mesh.getConnectivityIndex(MED_NODAL,MED_CELL); - int *conn_renum=new int[conn_index_init[nb_cell]-1]; - int *conn_index_renum=new int[nb_cell+1]; - - int iter=0; - int i2; - conn_index_renum[0]=1; - for(int i=0;isetNodal(conn_renum,MED_CELL,Type,conn_index_renum); - delete[] conn_renum; - delete[] conn_index_renum; - } -} - -void changeFamily(MESH* mesh, const medGeometryElement& Type, const vector& perm) -{ - int nb_families=mesh->getNumberOfFamilies(MED_CELL); - for (int i=0;igetFamily(MED_CELL,i+1); - if (!family->isOnAllElements()) - { - int nb_elem=family->getNumberOfElements(Type); - int *number=(int *)family->getNumber(Type); - for(int j=0;jdesactivateFacesComputation(); - int newDrv=myMesh.addDriver(*drv22); - delete drv22; - myMesh.read(newDrv); - int nb_type=myMesh.getNumberOfTypes(MED_CELL); - if (nb_type!=1) - { - cout << "Mesh must have only one type of cell" << endl; - return -1; - } - const medGeometryElement *Types = myMesh.getTypes(MED_CELL); - medGeometryElement Type=Types[0]; - - t_read_mesh=clock(); - MESH* workMesh=new MESH(myMesh); - cout << "Building the graph "; - cout.flush(); - int ntot,nb_cell; - vector > neighbour; - computeNeighbour(workMesh,Type,neighbour,ntot,nb_cell); - int* graph=new int[ntot]; - int* graph_index=new int[nb_cell+1]; - graph_index[0]=1; - int count=0; - for(int i=0;i::const_iterator it=neighbour[i].begin();it!=neighbour[i].end();++it) - { - graph[count]=*it; - ++count; - } - graph_index[i+1]=count+1; - } - - - // Compute permutation - vector iperm,perm; - Renumbering* renumb= RenumberingFactory(type_renum); - renumb->renumber(graph,graph_index,nb_cell,iperm,perm); - delete renumb; - delete workMesh; - t_compute_graph=clock(); - cout << " : " << (t_compute_graph-t_read_mesh)/(double) CLOCKS_PER_SEC << "s" << endl; - cout.flush(); - - // Connectivity - cout << "Computing connectivity"; - cout.flush(); - MESH meshRenum(myMesh); - changeConnectivity(meshRenum,Type,nb_cell,iperm); - t_connectiv=clock(); - cout << " : " << (t_connectiv-t_compute_graph)/(double) CLOCKS_PER_SEC << "s" << endl; - cout.flush(); - - // Familles - cout << "Computing families "; - cout.flush(); - changeFamily(&meshRenum,Type,perm); - int drv3=meshRenum.addDriver(MED_DRIVER,filename_out,meshRenum.getName()); - meshRenum.write(drv3); - t_family=clock(); - cout << " : " << (t_family-t_connectiv)/(double) CLOCKS_PER_SEC << "s" << endl; - cout.flush(); - - // Fields - cout << "Computing fields "; - cout.flush(); - bool exist_type; - vector field_names = med_struct.getFieldNames(); - for(unsigned ifield=0;ifield myField(MED_DRIVER,filename_in,field_names[ifield],dtit[i].dt,dtit[i].it); - FIELD newField(myField); - const SUPPORT* mySupport=newField.getSupport(); - const medGeometryElement *typesOfSupport = mySupport->getTypes(); - for(int t=0;tgetNumberOfTypes();++t) - { - if(typesOfSupport[t]==Type) - { - exist_type=true; - break; - } - } - if(exist_type) - { - for(int i=0;igetNumberOfElements(Type);++i) - { - for(int j=0;j