From: admin Date: Mon, 24 May 2010 11:54:42 +0000 (+0000) Subject: This commit was generated by cvs2git to create branch X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_Prepare_to_SALOME_6x;p=tools%2Fmedcoupling.git This commit was generated by cvs2git to create branch 'BR_Prepare_to_SALOME_6x'. Sprout from V6_main 2010-05-24 11:54:38 UTC inv 'Changing version to 6.1.0' Cherrypick from master 2009-03-06 09:28:28 UTC secher 'debug: forget of TRI6': adm_local/unix/config_files/check_libxml.m4 adm_local_without_kernel/unix/config_files/check_pthreads.m4 adm_local_without_kernel/unix/config_files/config.guess adm_local_without_kernel/unix/config_files/config.sub adm_local_without_kernel/unix/config_files/install-sh adm_local_without_kernel/unix/config_files/libtool.m4 adm_local_without_kernel/unix/config_files/ltconfig adm_local_without_kernel/unix/config_files/ltmain.sh resources/Deff_fdt_5.8_castem_efmh_diff_conc_dom.med resources/Deff_fdt_5.8_castem_vf_diff_conc_dom.med resources/MED.config resources/MED_en.xml resources/Old_Deff_fdt_5.8_castem_efmh_diff_conc_dom.med resources/Old_Deff_fdt_5.8_castem_vf_diff_conc_dom.med src/INTERP_KERNEL/Geometric2D/AbstractEdge.cxx src/INTERP_KERNEL/Geometric2D/AbstractEdge.hxx src/INTERP_KERNEL/Geometric2D/Bounds.cxx src/INTERP_KERNEL/Geometric2D/Bounds.hxx src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx src/INTERP_KERNEL/Geometric2D/Edge.cxx src/INTERP_KERNEL/Geometric2D/Edge.hxx src/INTERP_KERNEL/Geometric2D/Edge.txx src/INTERP_KERNEL/Geometric2D/EdgeArcCircle.cxx src/INTERP_KERNEL/Geometric2D/EdgeArcCircle.hxx src/INTERP_KERNEL/Geometric2D/EdgeInfLin.cxx src/INTERP_KERNEL/Geometric2D/EdgeInfLin.hxx src/INTERP_KERNEL/Geometric2D/EdgeLin.cxx src/INTERP_KERNEL/Geometric2D/EdgeLin.hxx src/INTERP_KERNEL/Geometric2D/ElementaryEdge.cxx src/INTERP_KERNEL/Geometric2D/ElementaryEdge.hxx src/INTERP_KERNEL/Geometric2D/Node.cxx src/INTERP_KERNEL/Geometric2D/Node.hxx src/INTERP_KERNEL/Geometric2D/Precision.cxx src/INTERP_KERNEL/Geometric2D/Precision.hxx src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx src/INTERP_KERNEL/PolyhedronIntersector.hxx src/INTERP_KERNEL/PolyhedronIntersector.txx src/INTERP_KERNELTest/RemapperTest.hxx src/MEDCoupling/MEDCouplingSMesh.cxx src/MEDCoupling/MEDCouplingSMesh.hxx src/MEDCoupling/MemArray.cxx src/MEDCoupling/MemArray.hxx src/MEDCoupling/MemArray.txx src/MEDCoupling/RefCountObject.hxx src/MEDCoupling/TimeLabel.cxx src/MEDCoupling/TimeLabel.hxx src/MEDGUI/MED_images.po src/MEDGUI/MED_msg_en.po src/MEDGUI/MED_msg_fr.po src/MEDMEM/PointLocatorAlgos.txx src/MEDMEM/Remapper.cxx src/MEDMEM/Remapper.hxx src/ParaMEDMEM/IntersectionDEC.cxx src/ParaMEDMEM/IntersectionDEC.hxx src/ParaMEDMEM/MEDLoader/MEDLoader.cxx src/ParaMEDMEM/MEDLoader/MEDLoader.hxx src/ParaMEDMEM/MEDLoader/Makefile.am src/ParaMEDMEM/Test/MPIAccessDECTest.cxx src/ParaMEDMEM/Test/MPIAccessDECTest.hxx src/ParaMEDMEM/Test/MPIAccessTest.cxx src/ParaMEDMEM/Test/MPIAccessTest.hxx src/ParaMEDMEM/Test/MPIMainTest.hxx src/ParaMEDMEM/Test/Makefile.am src/ParaMEDMEM/Test/ParaMEDMEMTest.cxx src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx src/ParaMEDMEM/Test/ParaMEDMEMTest_BlockTopology.cxx src/ParaMEDMEM/Test/ParaMEDMEMTest_IntersectionDEC.cxx src/ParaMEDMEM/Test/ParaMEDMEMTest_MPIProcessorGroup.cxx src/ParaMEDMEM/Test/ParaMEDMEMTest_NonCoincidentDEC.cxx src/ParaMEDMEM/Test/ParaMEDMEMTest_StructuredCoincidentDEC.cxx src/ParaMEDMEM/Test/TestMPIAccess.cxx src/ParaMEDMEM/Test/TestMPIAccessDEC.cxx src/ParaMEDMEM/Test/TestParaMEDMEM.cxx src/ParaMEDMEM/Test/test_AllToAllDEC.cxx src/ParaMEDMEM/Test/test_AllToAllTimeDEC.cxx src/ParaMEDMEM/Test/test_AllToAllvDEC.cxx src/ParaMEDMEM/Test/test_AllToAllvTimeDEC.cxx src/ParaMEDMEM/Test/test_AllToAllvTimeDoubleDEC.cxx src/ParaMEDMEM/Test/test_MPI_Access_Cancel.cxx src/ParaMEDMEM/Test/test_MPI_Access_Cyclic_ISend_IRecv.cxx src/ParaMEDMEM/Test/test_MPI_Access_Cyclic_Send_Recv.cxx src/ParaMEDMEM/Test/test_MPI_Access_IProbe.cxx src/ParaMEDMEM/Test/test_MPI_Access_ISendRecv.cxx src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv.cxx src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_BottleNeck.cxx src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length.cxx src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length_1.cxx src/ParaMEDMEM/Test/test_MPI_Access_Probe.cxx src/ParaMEDMEM/Test/test_MPI_Access_SendRecv.cxx src/ParaMEDMEM/Test/test_MPI_Access_Send_Recv.cxx src/ParaMEDMEM/Test/test_MPI_Access_Send_Recv_Length.cxx src/ParaMEDMEM/Test/test_MPI_Access_Time.cxx src/ParaMEDMEM/Test/test_MPI_Access_Time_0.cxx src/ParaMEDMEM_Swig/test_IntersectionDEC.py Delete: adm_local/cmake_files/FindXDR.cmake adm_local/unix/config_files/check_GUI.m4 adm_local/unix/config_files/renumber.m4 adm_local_without_kernel/cmake_files/FindMPI.cmake adm_local_without_kernel/cmake_files/FindPLATFORM.cmake adm_local_without_kernel/cmake_files/am2cmake.py adm_local_without_kernel/unix/config_files/DEPRECATED/check_pthreads.m4 adm_local_without_kernel/unix/config_files/DEPRECATED/config.guess adm_local_without_kernel/unix/config_files/DEPRECATED/config.sub adm_local_without_kernel/unix/config_files/DEPRECATED/install-sh adm_local_without_kernel/unix/config_files/DEPRECATED/libtool.m4 adm_local_without_kernel/unix/config_files/DEPRECATED/ltconfig adm_local_without_kernel/unix/config_files/DEPRECATED/ltmain.sh adm_local_without_kernel/unix/config_files/acx_pthread.m4 adm_local_without_kernel/unix/config_files/check_htmlgen.m4 adm_local_without_kernel/unix/config_files/check_libxml.m4 adm_local_without_kernel/unix/config_files/local_install.m4 doc/doxygen/images/head.png doc/doxygen/medcoupling.dox doc/doxygen/static/doxygen.css doc/doxygen/static/footer.html doc/doxygen/static/header.html.in doc/salome/tui/images/head.png doc/salome/tui/input/index.doc doc/salome/tui/static/header.html.in idl/MEDCouplingCorbaServant.idl idl/MEDCouplingCorbaServantTest.idl idl/ParaMEDCouplingCorbaServant.idl idl/ParaMEDMEMComponent.idl resources/Mesh3D_10_2d1.med resources/Mesh3D_10_2d2.med resources/Mesh3D_11.med resources/Test2D.med resources/Test2Dpoly.med resources/Test3D.med resources/Test3Dpoly.med resources/testStructCart3D.med 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/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/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/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/IntegralUniformIntersector.hxx src/INTERP_KERNEL/IntegralUniformIntersector.txx src/INTERP_KERNEL/Interpolation.txx src/INTERP_KERNEL/Interpolation1D.hxx src/INTERP_KERNEL/Interpolation1D.txx src/INTERP_KERNEL/Interpolation2DCurve.hxx src/INTERP_KERNEL/Interpolation2DCurve.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/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/PlanarIntersectorP0P1PL.hxx src/INTERP_KERNEL/PlanarIntersectorP0P1PL.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/PolyhedronIntersectorP0P0.hxx src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx src/INTERP_KERNEL/VolSurfUser.hxx src/INTERP_KERNEL/VolSurfUser.txx src/INTERP_KERNELTest/ExprEvalInterpTest.cxx src/INTERP_KERNELTest/ExprEvalInterpTest.hxx src/INTERP_KERNELTest/InterpKernelTestExport.hxx src/INTERP_KERNELTest/TestInterpKernelUtils.cxx src/INTERP_KERNELTest/TestInterpKernelUtils.hxx src/MEDCoupling/MEDCoupling.hxx src/MEDCoupling/MEDCouplingCMesh.cxx src/MEDCoupling/MEDCouplingCMesh.hxx src/MEDCoupling/MEDCouplingExtrudedMesh.cxx src/MEDCoupling/MEDCouplingExtrudedMesh.hxx src/MEDCoupling/MEDCouplingFieldDiscretization.cxx src/MEDCoupling/MEDCouplingFieldDiscretization.hxx src/MEDCoupling/MEDCouplingMemArray.cxx src/MEDCoupling/MEDCouplingMemArray.hxx src/MEDCoupling/MEDCouplingMemArray.txx src/MEDCoupling/MEDCouplingMesh.cxx src/MEDCoupling/MEDCouplingNatureOfField.hxx src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.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/MEDCouplingUMeshDesc.cxx src/MEDCoupling/MEDCouplingUMeshDesc.hxx src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx src/MEDCouplingCorba/Client/MEDCouplingClient.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/MEDCouplingCorba.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/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/MEDLoader/MEDLoader.cxx src/MEDLoader/MEDLoader.hxx src/MEDLoader/MEDLoaderBase.cxx src/MEDLoader/MEDLoaderBase.hxx src/MEDLoader/Makefile.am src/MEDLoader/Swig/Makefile.am src/MEDLoader/Swig/libMEDLoader_Swig.i src/MEDMEM/MEDMEM_RCBase.cxx src/MEDMEM/MEDMEM_Remapper.cxx src/MEDMEM/MEDMEM_Remapper.hxx src/MEDMEMBinTest/dumpInterpolation.cxx src/MEDMEMCppTest/MEDMEMCppTestExport.hxx src/MEDMEMCppTest/MEDMEMTest_DesactivateFacesComputation.cxx src/MEDMEMCppTest/MEDMEMTest_GetVolumeAbs.cxx src/MEDMEMCppTest/MEDMEMTest_PartialDescendingConnectivity.cxx src/MEDMEMCppTest/MEDMEMTest_Remapper.cxx src/MEDMEMCppTest/MEDMEMTest_Utils.cxx src/MEDMEMCppTest/MEDMEMTest_Utils.hxx src/MEDMEM_SWIG/avs2med src/MEDMEM_SWIG/med2sauv src/MEDMEM_SWIG/medutilities.py src/MEDMEM_SWIG/sauv2med src/MedClient/src/MEDClient.hxx 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/ICoCoField.cxx src/ParaMEDMEM/ICoCoTrioField.cxx src/ParaMEDMEM/InterpKernelDEC.cxx src/ParaMEDMEM/InterpKernelDEC.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/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/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/test_InterpKernelDEC.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/adm_local/unix/config_files/renumber.m4 b/adm_local/unix/config_files/renumber.m4 deleted file mode 100644 index b62ec3eeb..000000000 --- a/adm_local/unix/config_files/renumber.m4 +++ /dev/null @@ -1,57 +0,0 @@ -dnl Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -dnl -dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -dnl - -dnl define macros : -dnl AC_ENABLE_RENUMBER AC_DISABLE_RENUMBER -dnl author Vincent BERGEAUD -dnl -# AC_ENABLE_RENUMBER -AC_DEFUN([AC_ENABLE_RENUMBER], [dnl -define([AC_ENABLE_RENUMBER_DEFAULT], ifelse($1, yes, yes, no))dnl -AC_ARG_ENABLE(renumber, -changequote(<<, >>)dnl -<< --enable-renumber[=PKGS] build with renumber tool [default=>>AC_ENABLE_RENUMBER_DEFAULT], -changequote([, ])dnl -[p=${PACKAGE-default} -case "$enableval" in -yes) enable_renumber=yes ;; -no) enable_renumber=no ;; -*) - enable_renumber=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_renumber=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac], -enable_renumber=AC_ENABLE_RENUMBER_DEFAULT)dnl - -if test "X$enable_renumber" = "Xyes"; then - ENABLE_RENUMBER="yes" - AC_SUBST(ENABLE_RENUMBER) -fi -]) - -# AC_DISABLE_RENUMBER - set the default flag to --disable-renumber -AC_DEFUN([AC_DISABLE_RENUMBER], [AC_ENABLE_RENUMBER(no)]) - 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/medcoupling.dox b/doc/doxygen/medcoupling.dox deleted file mode 100644 index cd5fdb3d1..000000000 --- a/doc/doxygen/medcoupling.dox +++ /dev/null @@ -1,411 +0,0 @@ -/*! -\page medcoupling MEDCoupling - -\section MEDCouplingIntro Introduction - -The MEDCoupling module is presented under the form of a library -libmedcoupling and interfaces. This module MEDCoupling represents the -DataStructure designed to be exchanged by processors as well in -parallel case in SPMD paradigm ( \ref paramedmem "ParaMEDMEM" ), as in -distributed paradigm using CORBA. This DataStructure is \b fully -deconnected from \ref medmem "MEDMEM". This DataStructure is light in -order to minimize as much as possible the number of prerequisites needed -to use it. The idea is that as this DataStructure is intended to be -linked with all of code candidate for coupling ; the number of -prerequisites of medcoupling has to be threfore tiny. MEDCoupling has -been developped to comply with ICOCO API, \ref interpkernel -"conservative interpolators" and VTK visualization -DataStructure. The MEDCoupling DataStructures have been -developped to be compatible with HPC constraints (compact structures, -limitation of copies and launching of CPU consuming algorithms only when -absolutely needed ). - -\section MEDCouplingMainConc Main Concepts - -- \ref MEDCouplingMeshesP "Meshes" -- \ref MEDCouplingFieldsP "Fields" - -\section MEDCouplingFirstSteps1 Building an array from scratch - -All of exemples given here make the assumption that the \c ParaMEDMEM -namespace is visible ( by calling for example \c using \c -namespace \c ParaMEDMEM; ). - -Here a description of typical usages to use MEDCoupling arrays. -In this example we will create arrays with 12 tuples constituted each -of 3 components. These arrays will be created using different ways. - -\code - -const int nbOfNodes=12; -double coords[3*nbOfNodes]={ ... }; - -DataArrayDouble *myCoords=0; -double *tmp=0; -\endcode - -- no copy no ownership -\code -myCoords=DataArrayDouble::New(); -myCoords->useArray(coords,false,CPP_DEALLOC,nbOfNodes,3); -//now use myCoords as you need -... -//myCoords is no more usefully here : release it -myCoords->decrRef(); -\endcode - - -- no copy and ownership C++ -\code -myCoords=DataArrayDouble::New(); -tmp=new double[3*nbOfNodes]; -std::copy(coords,coords+3*nbOfNodes,tmp); -myCoords->useArray(tmp,true,CPP_DEALLOC,nbOfNodes,3); -//now use myCoords as you need -... -//myCoords is no more usefully, release it -myCoords->decrRef(); -\endcode - -- no copy and ownership C -\code -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); -//now use myCoords as you need -... -//myCoords is no more usefully here : release it -myCoords->decrRef(); -\endcode - -- copy -\code -myCoords=DataArrayDouble::New(); -myCoords->alloc(nbOfNodes,3); -tmp=myCoords->getPointer(); -std::copy(coords,coords+3*nbOfNodes,tmp); -myCoords->declareAsNew();//you have modified data pointed by internal pointer notify object -//now use myCoords as you need -... -//myCoords is no more usefully here : release it -myCoords->decrRef(); -\endcode - -\section MEDCouplingFirstSteps2 Building unstructured mesh from scratch - -All of exemples given here make the assumption that the \c ParaMEDMEM -namespace is visible ( by calling for example \c using \c -namespace \c ParaMEDMEM; ). - -Here we will create a mesh with spacedim==2 and meshdim==2 too with 5 -cells and 9 nodes. - -You can notice that it is possible to mix cell -types as you want as long as the dimension of cell is exactly equal to -meshDim to respect \ref MEDCouplingMeshes "this rule". - -\code - -double coords[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 conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4}; -MEDCouplingUMesh *mesh=MEDCouplingUMesh::New(); -mesh->setName("My2DMesh"); -mesh->setMeshDimension(2); -mesh->allocateCells(5);//You can put more than 5 if you want but not less. -mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); -mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+4); -mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+7); -mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); -mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); -mesh->finishInsertingCells(); -DataArrayDouble *myCoords=DataArrayDouble::New(); -myCoords->alloc(9,2);//here myCoords are declared to have 2 components, mesh will deduce that spaceDim==2 -std::copy(coords,coords+18,myCoords->getPointer()); -mesh->setCoords(myCoords); -myCoords->decrRef(); -//mesh is now usable -... -//mesh is no more usefully here : release it -mesh->decrRef(); - -\endcode - -\section MEDCouplingFirstSteps3 Building a field from scratch - -All of exemples given here make the assumption that the \c ParaMEDMEM -namespace is visible ( by calling for example \c using \c -namespace \c ParaMEDMEM; ). - -Here we will make the assumption that an instance of \c MEDCouplingMesh -called \c mesh has been created. - -- create a tensor field with 9 components on cells with no time step -\code -MEDCouplingFieldDouble* fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); -fieldOnCells->setName("MyTensorFieldOnCellNoTime"); -fieldOnCells->setMesh(mesh); -DataArrayDouble *array=DataArrayDouble::New(); -array->alloc(mesh->getNumberOfCells(),9);//Implicitely fieldOnCells will be a 9 components field. -fieldOnCells->setArray(array); -tmp=array->getPointer(); -std::fill(tmp,tmp+9*mesh->getNumberOfCells(),7.); -array->declareAsNew(); -array->decrRef(); -//fieldOnCells is now usable -... -//fieldOnCells is no more usefully here : release it -fieldOnCells->decrRef(); -\endcode -- create a scalar field on nodes with no time step -\code -MEDCouplingFieldDouble* fieldOnNodes=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); -fieldOnNodes->setName("MyScalarFieldOnNodeNoTime"); -fieldOnNodes->setMesh(mesh); -DataArrayDouble *array=DataArrayDouble::New(); -array->alloc(mesh->getNumberOfNodes(),1);//Implicitely fieldOnNodes will be a scalar field. -fieldOnNodes->setArray(array); -tmp=array->getPointer(); -std::fill(tmp,tmp+mesh->getNumberOfNodes(),7.); -array->declareAsNew(); -array->decrRef(); -//fieldOnNodes is now usable -... -//fieldOnNodes is no more usefully here : release it -fieldOnNodes->decrRef(); -\endcode -- create a 2 components-vector field on cells with one time step and no interval -\code -MEDCouplingFieldDouble* fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); -fieldOnCells->setName("MyVecFieldOnCellWithTime"); -fieldOnCells->setMesh(mesh); -fieldOnCells->setTime(4.22,2,-1); -DataArrayDouble *array=DataArrayDouble::New(); -array->alloc(mesh->getNumberOfCells(),2);//Implicitely fieldOnCells will be a 2 components field. -fieldOnCells->setArray(array); -tmp=array->getPointer(); -std::fill(tmp,tmp+2*mesh->getNumberOfCells(),7.); -array->declareAsNew(); -array->decrRef(); -//fieldOnCells is now usable -... -//fieldOnCells is no more usefully here : release it -fieldOnCells->decrRef(); -\endcode -- create a 3 components-vector field on nodes with a time interval where hied is constant -\code -MEDCouplingFieldDouble* fieldOnNodes=MEDCouplingFieldDouble::New(ON_NODES,CONST_ON_TIME_INTERVAL); -fieldOnNodes->setName("MyVecFieldOnNodeWithConstTime"); -fieldOnNodes->setMesh(mesh); -fieldOnNodes->setStartTime(4.22,2,-1); -fieldOnNodes->setEndTime(6.44,4,-1); -DataArrayDouble *array=DataArrayDouble::New(); -array->alloc(mesh->getNumberOfNodes(),3);//Implicitely fieldOnNodes will be a 3 components field. -fieldOnNodes->setArray(array); -tmp=array->getPointer(); -std::fill(tmp,tmp+3*mesh->getNumberOfNodes(),7.); -array->declareAsNew(); -array->decrRef(); -//fieldOnNodes is now usable -... -//fieldOnNodes is no more usefully here : release it -fieldOnNodes->decrRef(); -\endcode - -\section MEDCouplingSecondStep0 Operations on Fields -Here we will make the assumption that an instance of \ref ParaMEDMEM::MEDCouplingMesh "MEDCouplingMesh" -called \c mesh has been created with spaceDim==2. -Here some exemple of more advanced use of \ref ParaMEDMEM::MEDCouplingFieldDouble "MEDCouplingFieldDouble". -\code -MEDCouplingFieldDouble *f1=mesh->fillFromAnalytic(ON_NODES,1,"x*x+y*y*3+2.*x");//f1 is scalar -MEDCouplingFieldDouble *f2=mesh->fillFromAnalytic(ON_NODES,1,"cos(x+y/x)");//f2 is scalar too -MEDCouplingFieldDouble *f2bis=mesh->fillFromAnalytic(ON_NODES,2,"x*x*IVec+3*y*JVec");//f2bis is a vectors field -MEDCouplingFieldDouble *f3=(*f1)+(*f2);//f3 scalar -MEDCouplingFieldDouble *f4=(*f3)/(*f2);//f4 scalar -f2bis->applyFunc(1,"sqrt(x*x+y*y)");//f2bis becomes scalar -MEDCouplingFieldDouble *f5=(*f2bis)*(*f4);//f5 scalar -const double pos1[2]={0.25,0.}; -double res; -f4->getValueOn(pos1,&res);//f4 is scalar so the returned value is of size 1. -// -... -//f1, f2, f2bis, f3, f4, f5 are no more usefully here : release them -f1->decrRef(); -f2->decrRef(); -f2bis->decrRef(); -f3->decrRef(); -f4->decrRef(); -f5->decrRef(); -\endcode -*/ - -/*! - \page MEDCouplingMeshesP Meshes in MEDCoupling - -\section MEDCouplingMeshes Common concept shared by all type of Meshes - -A mesh has a the following properties : - -- name -- a dimension (called mesh dimension) and only one (it implies that \b all cells constituting -mesh have the same dimension) -- a space dimension (relative to coordinates) -- a number of nodes -- a number of cells - -The class that incarnates the concept described above is : -\ref ParaMEDMEM::MEDCouplingMesh. - -\section MEDCouplingUMeshes Unstructured meshes - -An unstructured mesh is defined by : - -- a point clouds where the explicit -coordinates of each point must be specified. -- nodal connectivity that specifies for each cell, the points in the -previous point clouds that constitutes the cell. - -As unstructured mesh is dynamically defined enough, this struture is -used by MEDCoupling to instanciate degenerated meshes as : - -- points cloud only meshes. This type of mesh will have mesh dimension - == 0 -- abstract meshes containing only one cell that covers a potentially - infinite space. This abstract mesh is used as support of fields - containing only one integrated value. This is typically used to - represent fields used by system code. This type of mesh will have - mesh dimension equal to -1. - -The norm used for cells connectivity of different types, is the same as specified in MED file execpt -that connectivities are in represented in \b C \b format and \b not \b in -\b FORTRAN \b format ! - -The class in charge to dealt with the described concept is \ref -ParaMEDMEM::MEDCouplingUMesh. This class inherits -from \ref MEDCouplingPointSets "PointSet" abstract meshes. - -\section MEDCouplingPointSets PointSet - -This is a \b non \b instanciable class that deals with set of points without -any connectivity aspect. - -The class that incarnates this concept in -MEDCoupling is : \ref ParaMEDMEM::MEDCouplingPointSet. - -This class is in charge to perform whole or part of algorithms of -its subclasses (\ref -ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh" and \ref -ParaMEDMEM::MEDCouplingUMeshDesc "MEDCouplingUMeshDesc") for -factorization reasons. - -Some of most important implemented methods are : - -- \ref ParaMEDMEM::MEDCouplingPointSet::getSpaceDimension "getSpaceDimension" -- \ref ParaMEDMEM::MEDCouplingPointSet::getNumberOfNodes "getNumberOfNodes" -- \ref ParaMEDMEM::MEDCouplingPointSet::rotate "rotate" -- \ref ParaMEDMEM::MEDCouplingPointSet::translate "translate" -- \ref ParaMEDMEM::MEDCouplingPointSet::scale "scale" -- \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes "findCommonNodes" -- \ref ParaMEDMEM::MEDCouplingPointSet::renumberNodes "renumberNodes" -- \ref ParaMEDMEM::MEDCouplingPointSet::getBoundingBox "getBoundingBox" - -\section MEDCouplingCMeshs Cartesian Mesh - -A cartesian mesh is a mesh that represents structured mesh whose nodes -are arranged along axes of trihedron. To instanciate an object of this -type, only n arrays are needed. In this type of mesh space dimension -\b and mesh dimension are equals and the value is n. The n arrays will have only one component and the values -contained in these arrays will be ascendantly sorted. - -The class that incarnates this concept in MEDCoupling is : \ref ParaMEDMEM::MEDCouplingCMesh. - -\section MEDCouplingExtrudedMeshes Extruded Mesh - -An extruded mesh is a mesh also called 2.5 D. It a convolution of 2D -unstructured mesh with 1D unstructured mesh. The problem is that this -type of mesh is not managed by any file format that's why to build an -instance of this mesh you need 3D unstructured mesh and a 2D -unstructured mesh lying on the same coordinates. The advantage of this -structure is that the interpolation time is optimized. - -The class that incarnates this concept in MEDCoupling is : \ref ParaMEDMEM::MEDCouplingExtrudedMesh. -*/ - -/*! -\page MEDCouplingFieldsP Fields in MEDCoupling - -\section MEDCouplingFields Field concept - -A field in MEDCoupling point of view, is a structure that allows to -store a discretization of a physical value on a defined discretized spatial and -possibly temporal support. - -The spatial support is a \ref MEDCouplingMeshesP "mesh". -A field is lying on an entity that will be specified by the spatial -discretization of the field. For exemple a field on node will lie on -all nodes of its mesh. - -A field on cell will lie on all cells of its mesh. - -Fields in MEDCoupling follow the two following rules : - -- A field will lie on \b ALL entities of its spatial support (\ref MEDCouplingMeshesP "mesh"). -- A field has \b only \b one spatial support (\ref MEDCouplingMeshesP "mesh") on its temporal support. - -The main properties of a field are : - -- name -- spatial support which is a \ref MEDCouplingMeshesP "mesh" -- a \ref MEDCouplingSpatialDisc "spatial discretization" -- a description of intrinsic nature of the values of field. This is important for conservative interpolation. -- a temporal discretization that specifies, if it exists, the time interval on which the field is covering, and how. -- number of components - -This definition of field in MEDCoupling allows an instance of field to -know at any point inside its spatial-temporal support the value. - -The class that incarnates the concept described above is : \ref ParaMEDMEM::MEDCouplingFieldDouble. - -Some of most important implemented methods are : - -- \ref ParaMEDMEM::MEDCouplingFieldDouble::getNumberOfComponents "getNumberOfComponents" -- \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOn "getValueOn" -- \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc "applyFunc" -- \ref ParaMEDMEM::MEDCouplingFieldDouble::addFields "cross instances operations" - -\section MEDCouplingSpatialDisc Spatial discretization concept - -This is the concept that makes the link, independantly from temporal -discretization, between the field and its spatial support(\ref MEDCouplingMeshesP "mesh"). This -concept allows the field to make a check and interpretation of an -array of values given a spatial support (\ref MEDCouplingMeshesP "mesh"). - -The abstract class that incarnates the concept is : \ref ParaMEDMEM::MEDCouplingFieldDiscretization. - -The most important pure virtual methods are : - -- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getNumberOfTuples "getnumberOfTuples" -- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOn "getValueOn" -- \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getWeightingField "getWeightingField" - -\section MEDCouplingTemporalDisc Temporal discretization concept - -This information allows, independantly from spatial discretization, to -associate a time interval, if it exists, on which the field will be -defined. This concept is able to give the value at any time of -the definition interval (if any). - -The abstract class \ref ParaMEDMEM::MEDCouplingTimeDiscretization -incarnates this described concept. - -This classes and its subclasses are responsible in storing the arrays -of the aggregating field. - -The most important methods are : - -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setTime "setTime" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getTime "getTime" -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArray "getArray" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setArray "setArray" -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArraysForTime "getArraysForTime" -- \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getValueForTime "getValueForTime" - -*/ 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/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: -
    -
  • Modules - documentation of TUI functionality.
  • -
  • Name Spaces - list of TUI packages and scripts.
  • -
  • Data Structures - list of all data structures and classes with brief descriptions.
  • -
  • Files - list of all files with brief descriptions.
  • -
- -\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/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/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/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/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/CurveIntersector.hxx b/src/INTERP_KERNEL/CurveIntersector.hxx deleted file mode 100644 index 8e1f3929c..000000000 --- a/src/INTERP_KERNEL/CurveIntersector.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 __CURVEINTERSECTOR_HXX__ -#define __CURVEINTERSECTOR_HXX__ - -#include "TargetIntersector.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -namespace INTERP_KERNEL -{ - template - 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 c25136b5d..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 < 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 bafd3ad9e..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 < 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 fd43fe7fc..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 < 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 < 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 72b5c5101..000000000 --- a/src/INTERP_KERNEL/DirectedBoundingBox.cxx +++ /dev/null @@ -1,749 +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 < dim; ++i ) - gc[i] += *coord++; - for ( int j = 0; j < 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 < dim; ++j ) - gc[j] += pts[i][j]; - for ( int j = 0; j < 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]; - } - } - } - - //================================================================================ - /*! - * \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<_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 - - // 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 - - // 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 < _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() < 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 93874acdb..000000000 --- a/src/INTERP_KERNEL/DirectedBoundingBox.hxx +++ /dev/null @@ -1,118 +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 < _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 < _dim; ++i ) - { - double c = 0; - for ( int j = 0; j < _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/InterpKernelExprParser.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx deleted file mode 100644 index 5dde84961..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx +++ /dev/null @@ -1,693 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 -#include -#include -#include -#include - -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):_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):_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, double *outParam, const double *inParam) 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; -} diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx deleted file mode 100644 index 032f7070a..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.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 __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; - static LeafExpr *buildInstanceFrom(const std::string& expr) throw(INTERP_KERNEL::Exception); - }; - - class INTERPKERNELEXPREVAL_EXPORT LeafExprVal : public LeafExpr - { - public: - LeafExprVal(double value); - ~LeafExprVal(); - 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 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(const char *expr, int lgth); - ~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, double *outParam, const double *inParam) const throw(INTERP_KERNEL::Exception); - void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception); - void getSetOfVars(std::set& vars) const; - void getTrueSetOfVars(std::set& vars) 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: - 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 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 6e8316526..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx +++ /dev/null @@ -1,568 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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) -{ -} - -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) -{ -} - -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(); -} - -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(); -} - -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(); -} - -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(); -} - -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(); -} - -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(); -} - -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(); -} - -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(); -} - -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; -} - -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; -} - -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; -} - -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; -} - -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; -} - -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; -} - -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; -} - -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 548a09f1e..000000000 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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 4a67afba5..000000000 --- a/src/INTERP_KERNEL/ExprEval/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 -# - -# 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 - - -EXTRA_DIST += \ -INTERPKERNELEXPREVALDefines.hxx \ -InterpKernelExprParser.hxx \ -InterpKernelFunction.hxx \ -InterpKernelUnit.hxx \ -InterpKernelValue.hxx - -dist_libinterpkernelexpreval_la_SOURCES = \ - InterpKernelExprParser.cxx \ - InterpKernelFunction.cxx \ - InterpKernelUnit.cxx \ - InterpKernelValue.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/Geometric2D/AbstractEdge.cxx b/src/INTERP_KERNEL/Geometric2D/AbstractEdge.cxx new file mode 100644 index 000000000..1085fd171 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/AbstractEdge.cxx @@ -0,0 +1,116 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "AbstractEdge.hxx" +#include "ComposedEdge.hxx" +#include "ElementaryEdge.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 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/Bounds.cxx b/src/INTERP_KERNEL/Geometric2D/Bounds.cxx new file mode 100644 index 000000000..8e168ea5a --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Bounds.cxx @@ -0,0 +1,197 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "Bounds.hxx" +#include "InterpKernelException.hxx" +#include "EdgeArcCircle.hxx" +#include "Node.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/Bounds.hxx b/src/INTERP_KERNEL/Geometric2D/Bounds.hxx new file mode 100644 index 000000000..49d72dc67 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Bounds.hxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __BOUNDS_HXX__ +#define __BOUNDS_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/ComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx new file mode 100644 index 000000000..9909ada8d --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx @@ -0,0 +1,446 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "ComposedEdge.hxx" +#include "ElementaryEdge.hxx" +#include "EdgeInfLin.hxx" +#include "InterpKernelException.hxx" + +#include +#include +#include + +using namespace std; +using namespace INTERP_KERNEL; + +ComposedEdge::ComposedEdge(const ComposedEdge& other) +{ + for(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) +{ + 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(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) +{ + list *elemsOfElem=elem->getListBehind(); + _sub_edges.insert(_sub_edges.end(),elemsOfElem->begin(),elemsOfElem->end()); +} + +ElementaryEdge *ComposedEdge::operator[](int i) const +{ + 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(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(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(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(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(list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + { + (*iter)->getBarycenterOfZone(bary); + area+=(*iter)->getAreaOfZone(); + } + bary[0]/=area; + bary[1]/=area; +} + +double ComposedEdge::normalize(ComposedEdge *other) +{ + Bounds b; + b.prepareForAggregation(); + fillBounds(b); + other->fillBounds(b); + double dimChar=b.getCaracteristicDim(); + double xBary,yBary; + 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(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(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(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) +{ + set allNodes; + getAllNodes(allNodes); + for(set::iterator iter=allNodes.begin();iter!=allNodes.end();iter++) + (*iter)->applySimilarity(xBary,yBary,dimChar); + for(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(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(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 +{ + 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(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 + set nodes; + getAllNodes(nodes); + set radialDistributionOfNodes; + set::const_iterator iter; + for(iter=nodes.begin();iter!=nodes.end();iter++) + radialDistributionOfNodes.insert(nodeToTest->getSlope(*(*iter))); + vector radialDistrib(radialDistributionOfNodes.begin(),radialDistributionOfNodes.end()); + radialDistributionOfNodes.clear(); + vector radialDistrib2(radialDistrib.size()); + copy(radialDistrib.begin()+1,radialDistrib.end(),radialDistrib2.begin()); + radialDistrib2.back()=M_PI+radialDistrib.front(); + vector radialDistrib3(radialDistrib.size()); + transform(radialDistrib2.begin(),radialDistrib2.end(),radialDistrib.begin(),radialDistrib3.begin(),minus()); + 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); + set< IntersectElement > inOutSwitch; + for(list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + { + ElementaryEdge *val=(*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::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(list::iterator startToDel) +{ + for(list::iterator iter=startToDel;iter!=_sub_edges.end();iter++) + delete (*iter); +} diff --git a/src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx new file mode 100644 index 000000000..583e4af08 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx @@ -0,0 +1,95 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __COMPOSEDNODE_HXX__ +#define __COMPOSEDNODE_HXX__ + +#include "INTERPKERNELGEOMETRIC2DDefines.hxx" + +#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; + double normalize(ComposedEdge *other); + 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/Edge.cxx b/src/INTERP_KERNEL/Geometric2D/Edge.cxx new file mode 100644 index 000000000..334b4d886 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Edge.cxx @@ -0,0 +1,846 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "Edge.hxx" +#include "EdgeLin.hxx" +#include "EdgeInfLin.hxx" +//#include "EdgeParabol.hxx" +#include "EdgeArcCircle.hxx" +#include "InterpKernelException.hxx" + +#include + +using namespace std; +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) +{ + list< IntersectElement > listOfIntesc=getIntersectionsCharacteristicVal(); + 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 + { + vector vecOfIntesc(listOfIntesc.begin(),listOfIntesc.end()); + listOfIntesc.clear(); + sort(vecOfIntesc.begin(),vecOfIntesc.end()); + for(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 +{ + copy((const double *)(*_end),(const double *)(*_end)+2,vectOutput); + transform(vectOutput,vectOutput+2,(const double *)(*_start),vectOutput,minus()); + double norm=1./Node::norm(vectOutput); + transform(vectOutput,vectOutput+2,vectOutput,bind2nd(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(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; + 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 + vector::iterator iter=newNodes.begin(); + vector::reverse_iterator iterR=newNodes.rbegin(); + f1->addSubEdgeInVector(f1->getStartNode(),*iter,outValForF1); + f2->addSubEdgeInVector(f2->getStartNode(),order?*iter:*iterR,outValForF2); + for(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/Edge.hxx b/src/INTERP_KERNEL/Geometric2D/Edge.hxx new file mode 100644 index 000000000..3aff6efce --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Edge.hxx @@ -0,0 +1,279 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __EDGE_HXX__ +#define __EDGE_HXX__ + +#include "INTERPKERNELGEOMETRIC2DDefines.hxx" +#include "ComposedEdge.hxx" +#include "InterpKernelException.hxx" +#include "Bounds.hxx" +#include "Node.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/Edge.txx b/src/INTERP_KERNEL/Geometric2D/Edge.txx new file mode 100644 index 000000000..6a3f80f5b --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Edge.txx @@ -0,0 +1,30 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __EDGE_TXX__ +#define __EDGE_TXX__ + +#include "EdgeArcCircle.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/EdgeArcCircle.cxx b/src/INTERP_KERNEL/Geometric2D/EdgeArcCircle.cxx new file mode 100644 index 000000000..f65ab1510 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/EdgeArcCircle.cxx @@ -0,0 +1,695 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "EdgeArcCircle.hxx" +#include "EdgeLin.hxx" +#include "InterpKernelException.hxx" +#include "Node.hxx" + +#include +#include + +using namespace std; +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=*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 << 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/EdgeArcCircle.hxx b/src/INTERP_KERNEL/Geometric2D/EdgeArcCircle.hxx new file mode 100644 index 000000000..b3a4a3e20 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/EdgeArcCircle.hxx @@ -0,0 +1,122 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __EDGEARCCIRCLE_HXX__ +#define __EDGEARCCIRCLE_HXX__ + +#include "Edge.hxx" + +namespace INTERP_KERNEL +{ + class 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 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 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/EdgeInfLin.cxx b/src/INTERP_KERNEL/Geometric2D/EdgeInfLin.cxx new file mode 100644 index 000000000..2f3fd9da5 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/EdgeInfLin.cxx @@ -0,0 +1,28 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "EdgeInfLin.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/EdgeInfLin.hxx b/src/INTERP_KERNEL/Geometric2D/EdgeInfLin.hxx new file mode 100644 index 000000000..d600b7701 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/EdgeInfLin.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __EDGEINFLIN_HXX__ +#define __EDGEINFLIN_HXX__ + +#include "EdgeLin.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/EdgeLin.cxx b/src/INTERP_KERNEL/Geometric2D/EdgeLin.cxx new file mode 100644 index 000000000..92f051610 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/EdgeLin.cxx @@ -0,0 +1,294 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "EdgeLin.hxx" +#include "Node.hxx" +#include "InterpKernelException.hxx" + +using namespace std; +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" << endl; + direction?_start->dumpInXfigFile(stream,resolution,box):_end->dumpInXfigFile(stream,resolution,box); + direction?_end->dumpInXfigFile(stream,resolution,box):_start->dumpInXfigFile(stream,resolution,box); + stream << 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/EdgeLin.hxx b/src/INTERP_KERNEL/Geometric2D/EdgeLin.hxx new file mode 100644 index 000000000..0c11ae39b --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/EdgeLin.hxx @@ -0,0 +1,78 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __EDGELIN_HXX__ +#define __EDGELIN_HXX__ + +#include "Edge.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 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/ElementaryEdge.hxx b/src/INTERP_KERNEL/Geometric2D/ElementaryEdge.hxx new file mode 100644 index 000000000..19f4e1968 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/ElementaryEdge.hxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __ELEMENTARYEDGE_HXX__ +#define __ELEMENTARYEDGE_HXX__ + +#include "INTERPKERNELGEOMETRIC2DDefines.hxx" +#include "InterpKernelException.hxx" +#include "AbstractEdge.hxx" +#include "Edge.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/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/Node.cxx b/src/INTERP_KERNEL/Geometric2D/Node.cxx new file mode 100644 index 000000000..fb64ded3c --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Node.cxx @@ -0,0 +1,132 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "Node.hxx" +#include "EdgeArcCircle.hxx" + +using namespace std; +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/Node.hxx b/src/INTERP_KERNEL/Geometric2D/Node.hxx new file mode 100644 index 000000000..46957dac0 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Node.hxx @@ -0,0 +1,94 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __NODE_HXX__ +#define __NODE_HXX__ + +#include "Precision.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/Precision.cxx b/src/INTERP_KERNEL/Geometric2D/Precision.cxx new file mode 100644 index 000000000..1e4f3510c --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Precision.cxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "Precision.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/Precision.hxx b/src/INTERP_KERNEL/Geometric2D/Precision.hxx new file mode 100644 index 000000000..31fa8f60a --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/Precision.hxx @@ -0,0 +1,36 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __PRECISION_HXX__ +#define __PRECISION_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/QuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx new file mode 100644 index 000000000..d8faa8a4c --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx @@ -0,0 +1,553 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "QuadraticPolygon.hxx" +#include "ElementaryEdge.hxx" +#include "EdgeArcCircle.hxx" +#include "AbstractEdge.hxx" +#include "EdgeLin.hxx" +#include "Bounds.hxx" +#include "Edge.txx" + +#include +#include + +using namespace std; +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]; + ifstream stream(file); + stream.exceptions(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(ifstream::failure& e) + { + } + 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) +{ + ofstream file(fileName); + file << setprecision(16); + file << " double coords[]=" << endl << " { "; + for(vector::const_iterator iter=nodes.begin();iter!=nodes.end();iter++) + { + if(iter!=nodes.begin()) + file << "," << endl << " "; + file << (*(*iter))[0] << ", " << (*(*iter))[1]; + } + file << "};" << 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); + } +} + +void QuadraticPolygon::dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const +{ + 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 +{ + 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" << endl; + stream << "Landscape" << endl; + stream << "Center" << endl; + stream << "Metric" << endl; + stream << "Letter" << endl; + stream << "100.00" << endl; + stream << "Single" << endl; + stream << "-2" << endl; + stream << resolution << " 2" << 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.; + double fact=normalize(&other); + vector polygs=intersectMySelfWith(other); + for(vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) + { + ret+=fabs((*iter)->getArea()); + delete *iter; + } + 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.; + vector polygs=intersectMySelfWith(other); + for(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. + */ +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 +{ + vector ret; + 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 +{ + 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(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; + list::iterator iter2=iter; iter2++; + 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(list::iterator iter=iStart;iter!=iEnd;iter++) + if((*iter)->isNodeIn(n)) + return iter; + return iEnd; +} diff --git a/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx new file mode 100644 index 000000000..78977ecf5 --- /dev/null +++ b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx @@ -0,0 +1,92 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __QUADRATICPOLYGON_HXX__ +#define __QUADRATICPOLYGON_HXX__ + +#include "INTERPKERNELGEOMETRIC2DDefines.hxx" + +#include "ComposedEdge.hxx" +#include "AbstractEdge.hxx" +#include "ElementaryEdge.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(); + 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); + double intersectWith(const QuadraticPolygon& other) 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/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/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/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/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 6eb93e9aa..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, 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/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/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/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/PolyhedronIntersector.hxx b/src/INTERP_KERNEL/PolyhedronIntersector.hxx new file mode 100644 index 000000000..4cf4fb4ee --- /dev/null +++ b/src/INTERP_KERNEL/PolyhedronIntersector.hxx @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __POLYHEDRONINTERSECTOR_HXX__ +#define __POLYHEDRONINTERSECTOR_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 PolyhedronIntersector : 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: + + PolyhedronIntersector(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); + + ~PolyhedronIntersector(); + + 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/PolyhedronIntersector.txx b/src/INTERP_KERNEL/PolyhedronIntersector.txx new file mode 100644 index 000000000..1d58f7a58 --- /dev/null +++ b/src/INTERP_KERNEL/PolyhedronIntersector.txx @@ -0,0 +1,94 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __POLYHEDRONINTERSECTOR_TXX__ +#define __POLYHEDRONINTERSECTOR_TXX__ + +#include "PolyhedronIntersector.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 + PolyhedronIntersector::PolyhedronIntersector(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 + PolyhedronIntersector::~PolyhedronIntersector() + { + releaseArrays(); + } + + template + void PolyhedronIntersector::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 PolyhedronIntersector::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/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/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/VolSurfUser.hxx b/src/INTERP_KERNEL/VolSurfUser.hxx deleted file mode 100644 index a0eafd221..000000000 --- a/src/INTERP_KERNEL/VolSurfUser.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 __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); -} - -#endif diff --git a/src/INTERP_KERNEL/VolSurfUser.txx b/src/INTERP_KERNEL/VolSurfUser.txx deleted file mode 100644 index d6fcd11bf..000000000 --- a/src/INTERP_KERNEL/VolSurfUser.txx +++ /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 -// -#ifndef __VOLSURFUSER_TXX__ -#define __VOLSURFUSER_TXX__ - -#include "VolSurfUser.hxx" -#include "VolSurfFormulae.hxx" -#include "InterpolationUtils.hxx" - -namespace INTERP_KERNEL -{ - template - double computeVolSurfOfCell(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords) - { - switch(type) - { - 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 : - { - throw INTERP_KERNEL::Exception("Polyedra Not yet implemented !"); - } - break; - default: - throw INTERP_KERNEL::Exception("Not recognized cell type to get 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); - throw INTERP_KERNEL::Exception("Invalid spaceDim specified : must be 2 or 3"); - } -} - -#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/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/RemapperTest.hxx b/src/INTERP_KERNELTest/RemapperTest.hxx new file mode 100644 index 000000000..bd58b533b --- /dev/null +++ b/src/INTERP_KERNELTest/RemapperTest.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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_REMAPPER_HXX__ +#define __TU_REMAPPER_HXX__ + +#include +#include "Remapper.hxx" +#include "MEDMEM_Field.hxx" + +namespace INTERP_TEST +{ + + /** + * \brief Test suite testing some of the low level methods of TransformedTriangle. + * + */ + class RemapperTest : public CppUnit::TestFixture + { + + CPPUNIT_TEST_SUITE( RemapperTest ); + CPPUNIT_TEST( test_Remapper ); + CPPUNIT_TEST_SUITE_END(); + + + public: + void setUp(); + + void tearDown(); + + // tests + void test_Remapper(); + + private: + void absField(MEDMEM::FIELD&); + }; + + + + +} + + + +#endif 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/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/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx deleted file mode 100644 index 8829b19de..000000000 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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() -{ - if(_x_array) - _x_array->decrRef(); - if(_y_array) - _y_array->decrRef(); - if(_z_array) - _z_array->decrRef(); -} - -MEDCouplingCMesh *MEDCouplingCMesh::New() -{ - return new MEDCouplingCMesh; -} - -void MEDCouplingCMesh::updateTime() -{ - if(_x_array) - updateTimeWith(*_x_array); - if(_y_array) - updateTimeWith(*_y_array); - if(_z_array) - updateTimeWith(*_z_array); -} - -bool MEDCouplingCMesh::isEqual(const MEDCouplingMesh *other, double prec) const -{ - const MEDCouplingCMesh *otherC=dynamic_cast(other); - if(!otherC) - return false; - return true; -} - -void MEDCouplingCMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) -{ - const char msg0[]="Invalid "; - const char msg1[]=" array ! Must contain more than 1 element."; - if(_x_array) - if(_x_array->getNbOfElems()<2) - { - std::ostringstream os; os << msg0 << 'X' << msg1; - 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(_z_array) - if(_z_array->getNbOfElems()<2) - { - std::ostringstream os; os << msg0 << 'Z' << msg1; - throw INTERP_KERNEL::Exception(os.str().c_str()); - } -} - -bool MEDCouplingCMesh::isStructured() const -{ - return true; -} - -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 !"); - } -} - -void MEDCouplingCMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const -{ - //not implemented yet -} - -void MEDCouplingCMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const -{ - //not implemented yet -} - -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::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(); -} - -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])); -} - -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& conn) const; - void getCoordinatesOfNode(int nodeId, std::vector& coo) const; - DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception); - void setCoords(DataArrayDouble *coordsX, - DataArrayDouble *coordsY=0, - DataArrayDouble *coordsZ=0); - // tools - 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); - MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - DataArrayDouble *getCoordinatesAndOwner() const; - DataArrayDouble *getBarycenterAndOwner() const; - //some useful methods - void getSplitCellValues(int *res) const; - void getSplitNodeValues(int *res) const; - private: - MEDCouplingCMesh(); - ~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 3233ac549..000000000 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ /dev/null @@ -1,472 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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); -} - -MEDCouplingMeshType MEDCouplingExtrudedMesh::getType() const -{ - return EXTRUDED; -} - -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); -} -catch(INTERP_KERNEL::Exception&) - { - } - -bool MEDCouplingExtrudedMesh::isStructured() const -{ - return false; -} - -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; -} - -INTERP_KERNEL::NormalizedCellType MEDCouplingExtrudedMesh::getTypeOfCell(int cellId) const -{ - int nbOfCells2D=_mesh2D->getNumberOfCells(); - int locId=cellId%nbOfCells2D; - INTERP_KERNEL::NormalizedCellType tmp=_mesh2D->getTypeOfCell(locId); - return INTERP_KERNEL::CellModel::getCellModel(tmp).getExtrudedType(); -} - -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()); -} - -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); - } -} - -MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::getMeasureField(bool) const -{ - //not implemented yet - return 0; -} - -MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::getMeasureFieldOnNode(bool) const -{ - //not implemented yet - return 0; -} - -MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::buildOrthogonalField() const -{ - //not implemented yet - throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::buildOrthogonalField not implemented yet !"); -} - -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); -} - -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(); -} diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx deleted file mode 100644 index 60f46c047..000000000 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.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_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); - MEDCouplingMeshType getType() const; - bool isStructured() const; - int getNumberOfCells() const; - int getNumberOfNodes() const; - int getSpaceDimension() const; - int getMeshDimension() const; - INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; - void getNodeIdsOfCell(int cellId, std::vector& conn) const; - void getCoordinatesOfNode(int nodeId, std::vector& coo) const; - void checkCoherency() const throw (INTERP_KERNEL::Exception); - void getBoundingBox(double *bbox) const; - void updateTime(); - MEDCouplingUMesh *getMesh2D() const { return _mesh2D; } - MEDCouplingUMesh *getMesh1D() const { return _mesh1D; } - DataArrayInt *getMesh3DIds() const { return _mesh3D_ids; } - 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); - MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - DataArrayDouble *getCoordinatesAndOwner() const; - DataArrayDouble *getBarycenterAndOwner() const; - private: - MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); - 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; - DataArrayInt *_mesh3D_ids; - int _cell_2D_id; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx deleted file mode 100644 index 7e7c7b298..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 "MEDCouplingPointSet.hxx" -#include "MEDCouplingCMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" - -#include "InterpolationUtils.hxx" - -#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; - -MEDCouplingFieldDiscretization::MEDCouplingFieldDiscretization():_precision(DFLT_PRECISION) -{ -} - -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::New(TypeOfField type) -{ - switch(type) - { - case MEDCouplingFieldDiscretizationP0::TYPE: - return new MEDCouplingFieldDiscretizationP0; - case MEDCouplingFieldDiscretizationP1::TYPE: - return new MEDCouplingFieldDiscretizationP1; - 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; - throw INTERP_KERNEL::Exception("Representation does not match with any field discretization !"); -} - -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) const -{ - const MEDCouplingFieldDiscretizationP0 *otherC=dynamic_cast(other); - return otherC!=0; -} - -int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const -{ - return mesh->getNumberOfCells(); -} - -DataArrayDouble *MEDCouplingFieldDiscretizationP0::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const -{ - return mesh->getBarycenterAndOwner(); -} - -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::getWeightingField(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 DataArrayInt *old2New, DataArrayDouble *arr) 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 int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const -{ - MEDCouplingPointSet* ret=((const MEDCouplingPointSet *) mesh)->buildPartOfMySelf(start,end,false); - di=DataArrayInt::New(); - di->alloc(end-start,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) const -{ - const MEDCouplingFieldDiscretizationP1 *otherC=dynamic_cast(other); - return otherC!=0; -} - -int MEDCouplingFieldDiscretizationP1::getNumberOfTuples(const MEDCouplingMesh *mesh) const -{ - return mesh->getNumberOfNodes(); -} - -DataArrayDouble *MEDCouplingFieldDiscretizationP1::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const -{ - return mesh->getCoordinatesAndOwner(); -} - -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 << " cells in mesh and " << da->getNumberOfTuples() << " tuples in field !"; - throw INTERP_KERNEL::Exception(message.str().c_str()); - } -} - -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getWeightingField(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 DataArrayInt *old2New, DataArrayDouble *arr) const -{ - int oldNbOfElems=old2New->getNbOfElems(); - const int *old2NewPtr=old2New->getConstPointer(); - 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 invert array 'di' that is a conversion map from Old to New node numbering to New to Old node numbering. - */ -DataArrayInt *MEDCouplingFieldDiscretizationP1::invertArrayO2N2N2O(const MEDCouplingMesh *mesh, const DataArrayInt *di) -{ - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(mesh->getNumberOfNodes(),1); - int nbOfOldNodes=di->getNumberOfTuples(); - const int *old2New=di->getConstPointer(); - int *pt=ret->getPointer(); - for(int i=0;i!=nbOfOldNodes;i++) - if(old2New[i]!=-1) - pt[old2New[i]]=i; - return ret; -} - -/*! - * 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 int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const -{ - MEDCouplingPointSet* ret=((const MEDCouplingPointSet *) mesh)->buildPartOfMySelf(start,end,true); - DataArrayInt *diInv=ret->zipCoordsTraducer(); - di=invertArrayO2N2N2O(ret,diInv); - diInv->decrRef(); - return ret; -} diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx deleted file mode 100644 index 25d52f542..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ /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 __MEDCOUPLINGFIELDDISCRETIZATION_HXX__ -#define __MEDCOUPLINGFIELDDISCRETIZATION_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "InterpKernelException.hxx" -#include "MEDCouplingNatureOfField.hxx" - -namespace ParaMEDMEM -{ - class DataArrayInt; - class MEDCouplingMesh; - class DataArrayDouble; - class MEDCouplingFieldDouble; - - class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization - { - public: - static MEDCouplingFieldDiscretization *New(TypeOfField type); - double getPrecision() const { return _precision; } - void setPrecision(double val) { _precision=val; } - static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception); - virtual TypeOfField getEnum() const = 0; - virtual bool isEqual(const MEDCouplingFieldDiscretization *other) const = 0; - virtual MEDCouplingFieldDiscretization *clone() const = 0; - virtual const char *getStringRepr() const = 0; - virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0; - virtual DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const = 0; - virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0; - virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0; - virtual MEDCouplingFieldDouble *getWeightingField(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 int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const = 0; - virtual void renumberValuesOnNodes(const DataArrayInt *old2New, DataArrayDouble *arr) const = 0; - 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) const; - int getNumberOfTuples(const MEDCouplingMesh *mesh) const; - DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; - void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception); - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getWeightingField(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 DataArrayInt *old2New, DataArrayDouble *arr) const; - MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, 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) const; - int getNumberOfTuples(const MEDCouplingMesh *mesh) const; - DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; - void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception); - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getWeightingField(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 int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const; - void renumberValuesOnNodes(const DataArrayInt *old2New, DataArrayDouble *arr) const; - static DataArrayInt *invertArrayO2N2N2O(const MEDCouplingMesh *mesh, const DataArrayInt *di); - public: - static const char REPR[]; - static const TypeOfField TYPE; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx deleted file mode 100644 index 3456e329b..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 - -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; -} - -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(); -} - -bool DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const -{ - if(!areInfoEquals(other)) - return false; - return _mem.isEqual(other._mem,prec); -} - -void DataArrayDouble::reAlloc(int nbOfTuples) -{ - _mem.reAlloc(_info_on_compo.size()*nbOfTuples); - _nb_of_tuples=nbOfTuples; - declareAsNew(); -} - -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 !"); -} - -DataArrayDouble *DataArrayDouble::aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) -{ - 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::add(const DataArrayDouble *a1, const DataArrayDouble *a2) -{ - 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) -{ - 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) -{ - 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) -{ - 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) -{ - 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) -{ - 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 !"); - DataArrayDouble *ret=0; - if(nbOfComp==nbOfComp2) - { - ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - 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) -{ - 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) -{ - 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(); -} - -bool DataArrayInt::isEqual(const DataArrayInt& other) const -{ - if(!areInfoEquals(other)) - return false; - 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::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; -} - -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 74d165bb9..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.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 __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingRefCountObject.hxx" -#include "InterpKernelException.hxx" - -#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 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; - //T *_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 std::string getName() const { return _name; } - MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const { return _info_on_compo[i]; } - MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) { _info_on_compo[i]=info; } - 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 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 bool isEqual(const DataArrayDouble& other, double prec) const; - //!alloc or useArray should have been called before. - MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples); - 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; } - 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 static DataArrayDouble *aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2); - MEDCOUPLING_EXPORT static DataArrayDouble *add(const DataArrayDouble *a1, const DataArrayDouble *a2); - MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other); - MEDCOUPLING_EXPORT static DataArrayDouble *substract(const DataArrayDouble *a1, const DataArrayDouble *a2); - MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other); - MEDCOUPLING_EXPORT static DataArrayDouble *multiply(const DataArrayDouble *a1, const DataArrayDouble *a2); - MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other); - MEDCOUPLING_EXPORT static DataArrayDouble *divide(const DataArrayDouble *a1, const DataArrayDouble *a2); - MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other); - //! 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; - //!alloc or useArray should have been called before. - MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples); - 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 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 476f147ae..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ /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 __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; - for(int i=0;i<_nb_of_elem;i++) - if(pt1[i]-pt2[i]<-prec || (pt1[i]-pt2[i])>prec) - return false; - return true; - } - - 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 a552ea588..000000000 --- a/src/MEDCoupling/MEDCouplingMesh.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 "MEDCouplingMesh.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingFieldDiscretization.hxx" - -#include "InterpKernelExprParser.hxx" - -#include -#include - -using namespace ParaMEDMEM; - -bool MEDCouplingMesh::areCompatible(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 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/MEDCouplingNatureOfField.hxx b/src/MEDCoupling/MEDCouplingNatureOfField.hxx deleted file mode 100644 index bdc1c78dd..000000000 --- a/src/MEDCoupling/MEDCouplingNatureOfField.hxx +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 __MEDCOUPLINGNATUREOFFIELD_HXX__ -#define __MEDCOUPLINGNATUREOFFIELD_HXX__ - -namespace ParaMEDMEM -{ - typedef enum - { - NoNature = 17, - ConservativeVolumic = 26, - Integral = 32, - IntegralGlobConstraint = 35, - RevIntegral = 37 - } NatureOfField; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx deleted file mode 100644 index ebb12e01a..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 __MEDCouplingNormalizedCartesianMesh_HXX__ -#define __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/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx deleted file mode 100644 index 0c0ce1887..000000000 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ /dev/null @@ -1,715 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 "MEDCouplingPointSet.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingUMeshDesc.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingPointSet.txx" -#include "PlanarIntersector.txx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DNode.hxx" -#include "DirectedBoundingBox.hxx" - -#include -#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); - } -} - -bool MEDCouplingPointSet::isStructured() const -{ - return false; -} - -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; -} - -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::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); -} - -/*! - * 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 comm out parameter (not inout) - * @param commIndex out parameter (not inout) - */ -void MEDCouplingPointSet::findCommonNodes(DataArrayInt *&comm, DataArrayInt *&commIndex, double prec) 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,prec,c,cI); - break; - case 2: - findCommonNodesAlg<2>(bbox,nbNodesOld,prec,c,cI); - break; - case 1: - findCommonNodesAlg<1>(bbox,nbNodesOld,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::buildNewNumberingFromCommNodesFrmt(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(); -} - -/*! - * 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=DataArrayDouble::New(); - newCoords->alloc(getCoords()->getNumberOfTuples(),newSpaceDim); - const double *oldc=getCoords()->getConstPointer(); - double *nc=newCoords->getPointer(); - int nbOfNodes=getNumberOfNodes(); - int dim=std::min(oldSpaceDim,newSpaceDim); - for(int i=0;isetName(getCoords()->getName().c_str()); - for(int i=0;isetInfoOnComponent(i,getCoords()->getInfoOnComponent(i).c_str()); - setCoords(newCoords); - newCoords->decrRef(); -} - -/*! - * 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->isEqual(*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) -{ - 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, 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' 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 601777efc..000000000 --- a/src/MEDCoupling/MEDCouplingPointSet.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 __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(); - bool isStructured() const; - int getNumberOfNodes() const; - int getSpaceDimension() const; - void setCoords(DataArrayDouble *coords); - DataArrayDouble *getCoords() const { return _coords; } - DataArrayDouble *getCoordinatesAndOwner() const; - bool isEqual(const MEDCouplingMesh *other, double prec) const; - bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const; - virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged) = 0; - void findCommonNodes(DataArrayInt *&comm, DataArrayInt *&commIndex, double prec) const; - DataArrayInt *buildNewNumberingFromCommNodesFrmt(const DataArrayInt *comm, const DataArrayInt *commIndex, - int& newNbOfNodes) const; - void getBoundingBox(double *bbox) const; - void zipCoords(); - 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) throw(INTERP_KERNEL::Exception); - void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); - 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); - 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); - //! size of returned tinyInfo must be always the same. - virtual void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - virtual bool isEmptyMesh(const std::vector& tinyInfo) const = 0; - virtual void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings); - virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - virtual void unserialization(const std::vector& tinyInfo, 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, 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 300aab235..000000000 --- a/src/MEDCoupling/MEDCouplingPointSet.txx +++ /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 __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, 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(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) -{ - 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) -{ - 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) -{ - 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) -{ - 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, std::string& value) -{ - return INTERP_KERNEL::InterpolationOptions::setOptionString(key,value); -} - -int MEDCouplingRemapper::prepareUU(const char *method) -{ - 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==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) -{ - 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) -{ - _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()->getWeightingField(srcField->getMesh(),true); - MEDCouplingFieldDouble *denoR=trgField->getDiscretization()->getWeightingField(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()->getWeightingField(trgField->getMesh(),true); - MEDCouplingFieldDouble *denoR=srcField->getDiscretization()->getWeightingField(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 5e2bd63dd..000000000 --- a/src/MEDCoupling/MEDCouplingRemapper.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 __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__ - -#include "MEDCoupling.hxx" -#include "MEDCouplingTimeLabel.hxx" -#include "InterpolationOptions.hxx" -#include "MEDCouplingNatureOfField.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); - MEDCOUPLINGREMAPPER_EXPORT void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue); - MEDCOUPLINGREMAPPER_EXPORT void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue); - MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue); - MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue); - 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, std::string& value); - public: - MEDCOUPLINGREMAPPER_EXPORT static void printMatrix(const std::vector >& m); - private: - int prepareUU(const char *method); - int prepareEE(const char *method); - 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); - 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/MEDCouplingSMesh.cxx b/src/MEDCoupling/MEDCouplingSMesh.cxx new file mode 100644 index 000000000..724b157dd --- /dev/null +++ b/src/MEDCoupling/MEDCouplingSMesh.cxx @@ -0,0 +1,164 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "MEDCouplingSMesh.hxx" +#include "MemArray.hxx" + +using namespace ParaMEDMEM; + +MEDCouplingSMesh::MEDCouplingSMesh():_x_array(0),_y_array(0),_z_array(0) +{ +} + +MEDCouplingSMesh::~MEDCouplingSMesh() +{ + if(_x_array) + _x_array->decrRef(); + if(_y_array) + _y_array->decrRef(); + if(_z_array) + _z_array->decrRef(); +} + +MEDCouplingSMesh *MEDCouplingSMesh::New() +{ + return new MEDCouplingSMesh; +} + +void MEDCouplingSMesh::updateTime() +{ + if(_x_array) + updateTimeWith(*_x_array); + if(_y_array) + updateTimeWith(*_y_array); + if(_z_array) + updateTimeWith(*_z_array); +} + +void MEDCouplingSMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) +{ + const char msg0[]="Invalid "; + const char msg1[]=" array ! Must contain more than 1 element."; + if(_x_array) + if(_x_array->getNbOfElems()<2) + { + std::ostringstream os; os << msg0 << 'X' << msg1; + 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(_z_array) + if(_z_array->getNbOfElems()<2) + { + std::ostringstream os; os << msg0 << 'Z' << msg1; + throw INTERP_KERNEL::Exception(os.str().c_str()); + } +} + +bool MEDCouplingSMesh::isStructured() const +{ + return true; +} + +int MEDCouplingSMesh::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 MEDCouplingSMesh::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; +} + +int MEDCouplingSMesh::getSpaceDimension() const +{ + int ret=0; + if(_x_array) + ret++; + if(_y_array) + ret++; + if(_z_array) + ret++; + return ret; +} + +int MEDCouplingSMesh::getMeshDimension() const +{ + int ret=0; + if(_x_array) + ret++; + if(_y_array) + ret++; + if(_z_array) + ret++; + return ret; +} + +DataArrayDouble *MEDCouplingSMesh::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 MEDCouplingSMesh::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(); +} + diff --git a/src/MEDCoupling/MEDCouplingSMesh.hxx b/src/MEDCoupling/MEDCouplingSMesh.hxx new file mode 100644 index 000000000..d782107db --- /dev/null +++ b/src/MEDCoupling/MEDCouplingSMesh.hxx @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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_MEDCOUPLINGSMESH_HXX__ +#define __PARAMEDMEM_MEDCOUPLINGSMESH_HXX__ + +#include "MEDCouplingMesh.hxx" + +namespace ParaMEDMEM +{ + class DataArrayDouble; + + class MEDCouplingSMesh : public MEDCouplingMesh + { + public: + static MEDCouplingSMesh *New(); + void updateTime(); + void checkCoherency() const throw(INTERP_KERNEL::Exception); + bool isStructured() const; + int getNumberOfCells() const; + int getNumberOfNodes() const; + int getSpaceDimension() const; + int getMeshDimension() const; + DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception); + void setCoords(DataArrayDouble *coordsX, + DataArrayDouble *coordsY=0, + DataArrayDouble *coordsZ=0); + private: + MEDCouplingSMesh(); + ~MEDCouplingSMesh(); + private: + DataArrayDouble *_x_array; + DataArrayDouble *_y_array; + DataArrayDouble *_z_array; + }; +} + +#endif diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx deleted file mode 100644 index a030e1b4c..000000000 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ /dev/null @@ -1,1064 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 "InterpKernelExprParser.hxx" - -#include -#include - -using namespace ParaMEDMEM; - -const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached."; - -const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time."; - -const char MEDCouplingConstOnTimeInterval::EXCEPTION_MSG[]="No data on this time."; - -const double MEDCouplingTimeDiscretization::TIME_TOLERANCE_DFT=1.e-12; - -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; - default: - throw INTERP_KERNEL::Exception("Time discretization not implemented yet"); - } -} - -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::areCompatibleForMul(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(!areCompatible(other)) - return false; - if(_array==other->_array) - return true; - return _array->isEqual(*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(); - } -} - -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 dt,it; - double time1=getEndTime(dt,it)-_time_tolerance; - double time2=other->getStartTime(dt,it)+other->getTimeTolerance(); - return time1<=time2; -} - -bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) -{ - int dt,it; - double time1=getEndTime(dt,it)+_time_tolerance; - double time2=other->getStartTime(dt,it)-other->getTimeTolerance(); - return time1getPointer()+compoId; - int nbOfComp=_array->getNumberOfComponents(); - int nbOfTuple=_array->getNumberOfTuples(); - for(int i=0;igetNumberOfTuples(); - int oldNbOfComp=_array->getNumberOfComponents(); - newArr->alloc(nbOfTuples,nbOfComp); - const double *ptr=_array->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()); - } - } - _array->decrRef(); - _array=newArr; -} - -void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func) -{ - INTERP_KERNEL::ExprParser expr(func); - expr.parse(); - std::set vars; - expr.getTrueSetOfVars(vars); - int oldNbOfComp=_array->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=_array->getNumberOfTuples(); - newArr->alloc(nbOfTuples,nbOfComp); - const double *ptr=_array->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()); - } - } - _array->decrRef(); - _array=newArr; -} - -void MEDCouplingTimeDiscretization::applyFunc(const char *func) -{ - INTERP_KERNEL::ExprParser expr(func); - expr.parse(); - expr.prepareExprEvaluationVec(); - // - DataArrayDouble *newArr=DataArrayDouble::New(); - int nbOfTuples=_array->getNumberOfTuples(); - int nbOfComp=_array->getNumberOfComponents(); - newArr->alloc(nbOfTuples,nbOfComp); - const double *ptr=_array->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()); - } - } - _array->decrRef(); - _array=newArr; -} - -MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel() -{ -} - -MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy) -{ -} - -bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatible(other)) - return false; - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); - return otherC!=0; -} - -bool MEDCouplingNoTimeLabel::areCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatibleForMul(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); -} - -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::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& dt, int& it) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -double MEDCouplingNoTimeLabel::getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingNoTimeLabel::setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) -{ - throw INTERP_KERNEL::Exception(EXCEPTION_MSG); -} - -void MEDCouplingNoTimeLabel::setEndTime(double time, int dt, int it) 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 dt, int it, 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),_dt(other._dt),_it(other._it) -{ -} - -MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_dt(-1),_it(-1) -{ -} - -void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo); - tinyInfo.push_back(_dt); - tinyInfo.push_back(_it); -} - -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]; - _dt=tinyInfoI[2]; - _it=tinyInfoI[3]; -} - -bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatible(other)) - return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - return false; - return std::fabs(_time-otherC->_time)<_time_tolerance; -} - -bool MEDCouplingWithTimeStep::areCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatibleForMul(other)) - return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - return false; - return std::fabs(_time-otherC->_time)<_time_tolerance; -} - -bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_dt!=otherC->_dt) - return false; - if(_it!=otherC->_it) - return false; - if(std::fabs(_time-otherC->_time)>_time_tolerance) - return false; - return MEDCouplingTimeDiscretization::isEqual(other,prec); -} - -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::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 dt, int it, double *value) const throw(INTERP_KERNEL::Exception) -{ - if(_dt==dt && _it==it) - 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_dt(-1),_end_dt(-1),_start_it(-1),_end_it(-1) -{ -} - -void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo); - tinyInfo.push_back(_start_dt); - tinyInfo.push_back(_start_it); - tinyInfo.push_back(_end_dt); - tinyInfo.push_back(_end_it); -} - -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_dt=tinyInfoI[2]; - _start_it=tinyInfoI[3]; - _end_dt=tinyInfoI[4]; - _end_it=tinyInfoI[5]; -} - -MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy): - MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_dt(other._start_dt), - _end_dt(other._end_dt),_start_it(other._start_it),_end_it(other._end_it) -{ -} - -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); - if(!otherC) - return false; - return (std::fabs(_start_time-otherC->_start_time)<_time_tolerance && std::fabs(_end_time-otherC->_end_time)<_time_tolerance); -} - -bool MEDCouplingConstOnTimeInterval::areCompatibleForMul(const MEDCouplingTimeDiscretization *other) const -{ - if(!MEDCouplingTimeDiscretization::areCompatible(other)) - return false; - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - return false; - return (std::fabs(_start_time-otherC->_start_time)<_time_tolerance && std::fabs(_end_time-otherC->_end_time)<_time_tolerance); -} - -bool MEDCouplingConstOnTimeInterval::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const -{ - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - if(!otherC) - return false; - if(_start_dt!=otherC->_start_dt) - return false; - if(_start_it!=otherC->_start_it) - return false; - if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance) - return false; - if(_end_dt!=otherC->_end_dt) - return false; - if(_end_it!=otherC->_end_it) - return false; - if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance) - return false; - return MEDCouplingTimeDiscretization::isEqual(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 dt, int it, double *value) const throw(INTERP_KERNEL::Exception) -{ - if(dt>=_start_dt && dt<=_end_dt) - 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 << " with 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::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():_start_time(0.),_end_time(0.),_start_dt(-1),_end_dt(-1),_start_it(-1),_end_it(-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 << " with 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::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[2]!=-1 && tinyInfoI[3]!=-1) - { - arr=DataArrayDouble::New(); - arr->alloc(tinyInfoI[2],tinyInfoI[3]); - } - _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_dt=tinyInfoI[2]; - _end_dt=tinyInfoI[3]; - _start_it=tinyInfoI[4]; - _end_it=tinyInfoI[5]; -} diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx deleted file mode 100644 index 8ea2f8c6d..000000000 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 __MEDCOUPLINGTIMEDISCRETIZATION_HXX__ -#define __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 bool areCompatible(const MEDCouplingTimeDiscretization *other) const; - virtual bool areCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; - virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; - virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other, - TypeOfTimeDiscretization type, bool deepCpy) const; - virtual TypeOfTimeDiscretization getEnum() const = 0; - virtual MEDCouplingTimeDiscretization *aggregate(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 setArrays(const std::vector& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getArray() const { return _array; } - virtual DataArrayDouble *getEndArray() const { return _array; } - 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& dt, int& it) const throw(INTERP_KERNEL::Exception) { return getStartTime(dt,it); } - virtual double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) = 0; - virtual double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) = 0; - void setTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { setStartTime(time,dt,it); } - virtual void setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) = 0; - virtual void setEndTime(double time, int dt, int it) 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 dt, int it, double *value) const throw(INTERP_KERNEL::Exception) = 0; - // - 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 ~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); - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCouplingTimeDiscretization *aggregate(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 areCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areCompatibleForMul(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& dt, int& it) const throw(INTERP_KERNEL::Exception); - double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception); - void setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception); - void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception); - void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); - void getValueOnDiscTime(int eltId, int dt, int it, double *value) const throw(INTERP_KERNEL::Exception); - public: - static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME; - private: - static const char EXCEPTION_MSG[]; - }; - - class MEDCOUPLING_EXPORT MEDCouplingWithTimeStep : public MEDCouplingTimeDiscretization - { - protected: - MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy); - public: - MEDCouplingWithTimeStep(); - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCouplingTimeDiscretization *aggregate(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 areCompatible(const MEDCouplingTimeDiscretization *other) const; - bool areCompatibleForMul(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 dt, int it) throw(INTERP_KERNEL::Exception) { _time=time; _dt=dt; _it=it; } - void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _time=time; _dt=dt; _it=it; } - double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_dt; it=_it; return _time; } - double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_dt; it=_it; return _time; } - DataArrayDouble *getArrayOnTime(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; - void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); - void getValueOnDiscTime(int eltId, int dt, int it, double *value) const throw(INTERP_KERNEL::Exception); - public: - static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME; - private: - static const char EXCEPTION_MSG[]; - protected: - double _time; - int _dt; - int _it; - }; - - class MEDCOUPLING_EXPORT MEDCouplingConstOnTimeInterval : public MEDCouplingTimeDiscretization - { - protected: - MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy); - public: - MEDCouplingConstOnTimeInterval(); - 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 areCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; - bool isEqual(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 dt, int it, double *value) const throw(INTERP_KERNEL::Exception); - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCouplingTimeDiscretization *aggregate(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 dt, int it) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_dt=dt; _start_it=it; } - void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_dt=dt; _end_it=it; } - double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_start_dt; it=_start_it; return _start_time; } - double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_end_dt; it=_end_it; 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; - private: - static const char EXCEPTION_MSG[]; - protected: - double _start_time; - double _end_time; - int _start_dt; - int _end_dt; - int _start_it; - int _end_it; - }; - - class MEDCOUPLING_EXPORT MEDCouplingTwoTimeSteps : public MEDCouplingTimeDiscretization - { - protected: - MEDCouplingTwoTimeSteps(); - ~MEDCouplingTwoTimeSteps(); - public: - void checkNoTimePresence() const throw(INTERP_KERNEL::Exception); - void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); - void getArrays(std::vector& arrays) const; - DataArrayDouble *getEndArray() const { return _end_array; } - void setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_dt=dt; _start_it=it; } - void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_dt=dt; _end_it=it; } - double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_start_dt; it=_start_it; return _start_time; } - double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_end_dt; it=_end_it; return _end_time; } - void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); - void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - protected: - double _start_time; - double _end_time; - int _start_dt; - int _end_dt; - int _start_it; - int _end_it; - DataArrayDouble *_end_array; - }; - - class MEDCOUPLING_EXPORT MEDCouplingLinearTime : public MEDCouplingTwoTimeSteps - { - public: - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME; - }; -} - -#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 - -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; -} - -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::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]; -} - -void MEDCouplingUMeshDesc::getNodeIdsOfCell(int cellId, std::vector& conn) const -{ - //not implemented yet. -} - -void MEDCouplingUMeshDesc::getCoordinatesOfNode(int nodeId, std::vector& coo) const -{ - //not implemented yet. -} - -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) -{ - //not implemented yet. - areNodesMerged=false; - return 0; -} - -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::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 91ce649ed..000000000 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.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_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 void checkCoherency() 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 void getNodeIdsOfCell(int cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector& coo) 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); - 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 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/MemArray.cxx b/src/MEDCoupling/MemArray.cxx new file mode 100644 index 000000000..90d43a8fe --- /dev/null +++ b/src/MEDCoupling/MemArray.cxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "MemArray.txx" + +using namespace ParaMEDMEM; + +void DataArray::setName(const char *name) +{ + _name=name; +} + +DataArrayDouble *DataArrayDouble::New() +{ + return new DataArrayDouble; +} + +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::reAlloc(int nbOfTuples) +{ + _mem.reAlloc(_info_on_compo.size()*nbOfTuples); + _nb_of_tuples=nbOfTuples; + declareAsNew(); +} + +void DataArrayDouble::useArray(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(); +} + +DataArrayInt *DataArrayInt::New() +{ + return new DataArrayInt; +} + +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::useArray(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::reAlloc(int nbOfTuples) +{ + _mem.reAlloc(_info_on_compo.size()*nbOfTuples); + _nb_of_tuples=nbOfTuples; + declareAsNew(); +} diff --git a/src/MEDCoupling/MemArray.hxx b/src/MEDCoupling/MemArray.hxx new file mode 100644 index 000000000..b8c9c4e38 --- /dev/null +++ b/src/MEDCoupling/MemArray.hxx @@ -0,0 +1,116 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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_MEMARRAY_HXX__ +#define __PARAMEDMEM_MEMARRAY_HXX__ + +#include "RefCountObject.hxx" + +#include +#include + +namespace ParaMEDMEM +{ + template + class MemArray + { + public: + MemArray():_nb_of_elem(-1),_ownership(false),_pointer(0),_dealloc(CPP_DEALLOC) { } + T *getPointer() const { return _pointer; } + MemArray &operator=(const MemArray& other); + T operator[](int id) const { return _pointer[id]; } + T& operator[](int id) { return _pointer[id]; } + void alloc(int nbOfElements); + void reAlloc(int newNbOfElements); + void useArray(void *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; + T *_pointer; + DeallocType _dealloc; + }; + + class DataArray : public RefCountObject + { + public: + void setName(const char *name); + std::string getName() const { return _name; } + std::string getInfoOnComponent(int i) const { return _info_on_compo[i]; } + void setInfoOnComponent(int i, const char *info) { _info_on_compo[i]=info; } + int getNumberOfComponents() const { return _info_on_compo.size(); } + int getNumberOfTuples() const { return _nb_of_tuples; } + 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 "MemArray.txx" + +namespace ParaMEDMEM +{ + class DataArrayDouble : public DataArray + { + public: + static DataArrayDouble *New(); + void alloc(int nbOfTuple, int nbOfCompo); + //!alloc or useArray should have been called before. + void reAlloc(int nbOfTuples); + double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } + void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } + double *getPointer() const { return _mem.getPointer(); } + void useArray(double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); + void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } + //! nothing to do here because this class does not aggregate any TimeLabel instance. + void updateTime() { } + private: + DataArrayDouble() { } + private: + MemArray _mem; + }; + + class DataArrayInt : public DataArray + { + public: + static DataArrayInt *New(); + void alloc(int nbOfTuple, int nbOfCompo); + //!alloc or useArray should have been called before. + void reAlloc(int nbOfTuples); + int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } + int *getPointer() const { return _mem.getPointer(); } + void useArray(int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); + 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. + void updateTime() { } + private: + DataArrayInt() { } + private: + MemArray _mem; + }; +} + +#endif diff --git a/src/MEDCoupling/MemArray.txx b/src/MEDCoupling/MemArray.txx new file mode 100644 index 000000000..8c858bd1f --- /dev/null +++ b/src/MEDCoupling/MemArray.txx @@ -0,0 +1,112 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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_MEMARRAY_TXX__ +#define __PARAMEDMEM_MEMARRAY_TXX__ + +#include "MemArray.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpKernelException.hxx" + +#include +#include + +namespace ParaMEDMEM +{ + template + void MemArray::useArray(void *array, bool ownership, DeallocType type, int nbOfElem) + { + _nb_of_elem=nbOfElem; + destroy(); + _pointer=(T *)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); + _pointer[id]=element0; + memcpy(_pointer+id+1,others,sizeOfOthers*sizeof(T)); + } + + template + void MemArray::alloc(int nbOfElements) + { + destroy(); + _nb_of_elem=nbOfElements; + _pointer=new T[_nb_of_elem]; + _ownership=true; + _dealloc=CPP_DEALLOC; + } + + template + void MemArray::reAlloc(int newNbOfElements) + { + T *pointer=new T[newNbOfElements]; + memcpy(pointer,_pointer,std::min(_nb_of_elem,newNbOfElements)*sizeof(int)); + destroyPointer(_pointer,_dealloc); + _pointer=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(_pointer,_dealloc); + _pointer=0; + _ownership=false; + } + + template + MemArray &MemArray::operator=(const MemArray& other) + { + alloc(other._nb_of_elem); + memcpy(_pointer,other._pointer,_nb_of_elem*sizeof(T)); + return *this; + } +} + +#endif diff --git a/src/MEDCoupling/RefCountObject.hxx b/src/MEDCoupling/RefCountObject.hxx new file mode 100644 index 000000000..ca28fd1bf --- /dev/null +++ b/src/MEDCoupling/RefCountObject.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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_REFCOUNTOBJECT_HXX__ +#define __PARAMEDMEM_REFCOUNTOBJECT_HXX__ + +#include "TimeLabel.hxx" + +namespace ParaMEDMEM +{ + typedef enum + { + C_DEALLOC = 2, + CPP_DEALLOC = 3 + } DeallocType; + + typedef enum + { + ON_CELLS = 0, + ON_NODES = 1 + } TypeOfField; + + class RefCountObject : public TimeLabel + { + public: + RefCountObject():_cnt(1) { } + bool decrRef() { bool ret=((--_cnt)==0); if(ret)delete this; return ret; } + void incrRef() { _cnt++; } + protected: + virtual ~RefCountObject() { } + private: + int _cnt; + }; +} + +#endif diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx deleted file mode 100644 index 959a8c2c3..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx +++ /dev/null @@ -1,688 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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; -} - -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 dbd2a6ff9..000000000 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ /dev/null @@ -1,1881 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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::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())); - subMesh->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[9]={0,1,-1,2,3,4,-1,5,6}; - CPPUNIT_ASSERT(std::equal(expectedTraducer,expectedTraducer+9,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::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; - DataArrayInt *da=mTT->mergeNodes(1e-12,b); - 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); - 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); - 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(); -} - -void MEDCouplingBasicsTest::testFindCommonNodes() -{ - DataArrayInt *comm,*commI; - MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - targetMesh->findCommonNodes(comm,commI,1e-10); - CPPUNIT_ASSERT_EQUAL(1,commI->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(0,comm->getNumberOfTuples()); - int newNbOfNodes; - DataArrayInt *o2n=targetMesh->buildNewNumberingFromCommNodesFrmt(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(comm,commI,1e-10); - 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->buildNewNumberingFromCommNodesFrmt(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); - 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); - 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); - 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; - DataArrayInt *da=m3C->mergeNodes(1.e-12,isMerged); - CPPUNIT_ASSERT_EQUAL(11,m3C->getNumberOfNodes()); - CPPUNIT_ASSERT(isMerged); - da->decrRef(); - m3->decrRef(); - m1->decrRef(); - m2->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->measureAccumulate(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->measureAccumulate(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(); -} - -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()); - CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypes()); - targetMesh->decrRef(); - sourceMesh->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,arr+5,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,arr2+5,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/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 b7c30b712..000000000 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx +++ /dev/null @@ -1,986 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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::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; - DataArrayInt *da=meshTT->mergeNodes(1e-12,b); - 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 61dc0e701..000000000 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.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 __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( 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 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/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/TimeLabel.cxx b/src/MEDCoupling/TimeLabel.cxx new file mode 100644 index 000000000..df03416ec --- /dev/null +++ b/src/MEDCoupling/TimeLabel.cxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "TimeLabel.hxx" + +using namespace ParaMEDMEM; + +unsigned int TimeLabel::GLOBAL_TIME=0; + +TimeLabel::TimeLabel():_time(GLOBAL_TIME++) +{ +} + + 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 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 setUp(self): - pass - pass - -unittest.main() 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 4b8e950b2..000000000 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner) -{ - PyObject *ret; - if(dynamic_cast(mesh)) - ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner); - return ret; -} - -static PyObject *convertIntArrToPyList(const int *ptr, int size) -{ - PyObject *ret=PyList_New(size); - for(int i=0;idecrRef();" -%feature("unref") MEDCouplingUMesh "$this->decrRef();" -%feature("unref") DataArrayInt "$this->decrRef();" -%feature("unref") MEDCouplingFieldDouble "$this->decrRef();" - -%ignore ParaMEDMEM::TimeLabel::operator=; -%ignore ParaMEDMEM::MemArray::operator=; -%ignore ParaMEDMEM::MemArray::operator[]; - -%nodefaultctor; -%include "MEDCouplingTimeLabel.hxx" -%include "MEDCouplingRefCountObject.hxx" -%include "MEDCouplingMesh.hxx" -%include "MEDCouplingPointSet.hxx" -%include "MEDCouplingMemArray.hxx" -%include "MEDCouplingMesh.hxx" -%include "NormalizedUnstructuredMesh.hxx" -%include "MEDCouplingField.hxx" -%include "MEDCouplingNatureOfField.hxx" - -namespace ParaMEDMEM -{ - class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet - { - public: - static MEDCouplingUMesh *New(); - static MEDCouplingUMesh *New(const char *meshName, int meshDim); - MEDCouplingUMesh *clone(bool recDeepCpy) const; - void updateTime(); - void checkCoherency() const throw(INTERP_KERNEL::Exception); - void setMeshDimension(int meshDim); - void allocateCells(int nbOfCells); - void setCoords(DataArrayDouble *coords); - DataArrayDouble *getCoords() const; - void finishInsertingCells(); - void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true); - DataArrayInt *getNodalConnectivity() const; - DataArrayInt *getNodalConnectivityIndex() const; - INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; - int getNumberOfNodesInCell(int cellId) const; - bool isStructured() const; - int getNumberOfCells() const; - int getNumberOfNodes() const; - int getSpaceDimension() const; - int getMeshDimension() const; - int getMeshLength() const; - //tools - void zipCoords(); - DataArrayInt *zipCoordsTraducer(); - void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const; - MEDCouplingUMesh *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const; - %extend { - void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) - { - int *tmp=convertPyToNewIntArr(li,size); - 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; - DataArrayInt *ret0=self->mergeNodes(precision,ret1); - 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_bool(ret1)); - return res; - } - } - MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2); - }; -} - -%extend ParaMEDMEM::DataArrayDouble - { - void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) - { - double *tmp=convertPyToNewDblArr2(li); - self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); - } - - PyObject *getValues() - { - const double *vals=self->getPointer(); - return convertDblArrToPyList(vals,self->getNbOfElems()); - } - }; - -%extend ParaMEDMEM::DataArrayInt - { - void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) - { - int *tmp=convertPyToNewIntArr2(li); - self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); - } - - PyObject *getValues() - { - const int *vals=self->getPointer(); - return convertIntArrToPyList(vals,self->getNbOfElems()); - } - }; - -%include "MEDCouplingField.hxx" - -namespace ParaMEDMEM -{ - class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField - { - public: - static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME); - MEDCouplingFieldDouble *clone(bool recDeepCpy) const; - void checkCoherency() const throw(INTERP_KERNEL::Exception); - double getIJ(int tupleId, int compoId) const; - void setArray(DataArrayDouble *array); - void setTime(double val, int dt, int it); - void setStartTime(double val, int dt, int it); - void setEndTime(double val, int dt, int it); - DataArrayDouble *getArray() const { return _array; } - void applyLin(double a, double b, int compoId); - int getNumberOfComponents() const; - int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); - NatureOfField getNature() const { return _nature; } - void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); - void updateTime(); - bool mergeNodes(double eps); - void applyFunc(int nbOfComp, const char *func); - void applyFunc(const char *func); - static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - %extend { - void setValues(PyObject *li) - { - if(self->getArray()!=0) - { - double *tmp=convertPyToNewDblArr2(li); - 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; - } - } - }; -} diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx deleted file mode 100644 index f68192850..000000000 --- a/src/MEDLoader/MEDLoader.cxx +++ /dev/null @@ -1,1347 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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" - -extern "C" -{ -#include "med.h" -} - -#include -#include -#include -#include -#include -#include -#include - -med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+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_geometrie_element typmainoeud[1] = { MED_NONE }; - -INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2] = { INTERP_KERNEL::NORM_ERROR, - 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_geometrie_element 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 -}; - -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::string buildStringFromFortran(const char *expr, int lgth); - std::vector getMeshNamesFid(med_idt fid); - void readFieldDoubleDataInMedFile(const char *fileName, const char *meshName, const char *fieldName, std::list& field, - int iteration, int order, ParaMEDMEM::TypeOfField typeOfOutField, double& time); - 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_entite_maillage& whichEntity); - void readUMeshDataInMedFile(med_idt fid, med_int meshId, double *&coords, int& nCoords, int& spaceDim, std::list& conn); - int buildMEDSubConnectivityOfOneType(DataArrayInt *conn, DataArrayInt *connIndex, INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile, - std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile); - MEDCouplingUMesh *readUMeshFromFileLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& ids, - const std::vector& typesToKeep, unsigned& meshDimExtract) throw(INTERP_KERNEL::Exception); - void tradMEDFileCoreFrmt2MEDCouplingUMesh(const std::list& medConnFrmt, - DataArrayInt* &conn, - DataArrayInt* &connIndex, - const std::vector& familiesToKeep); - ParaMEDMEM::DataArrayDouble *buildArrayFromRawData(const std::list& fieldPerType); - int buildMEDSubConnectivityOfOneTypesPolyg(DataArrayInt *conn, DataArrayInt *connIndex, std::vector& conn4MEDFile, std::vector& connIndex4MEDFile); - int buildMEDSubConnectivityOfOneTypesPolyh(DataArrayInt *conn, DataArrayInt *connIndex, std::vector& conn4MEDFile, - std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile); - int buildMEDSubConnectivityOfOneTypeStaticTypes(DataArrayInt *conn, DataArrayInt *connIndex, INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile); - ParaMEDMEM::MEDCouplingFieldDouble *readFieldDoubleLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order, - ParaMEDMEM::TypeOfField typeOfOutField); - void appendFieldDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); - void prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCouplingFieldDouble *f, std::list& split); - void writeUMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool forceFromScratch); - void writeFieldAndMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool forceFromScratch); -} - -const char WHITE_SPACES[]=" \n"; - -/*! - * @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),_type(type), - _conn_lgth(connLgth) -{ -} - -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):_ntuple(ntuple),_ncomp(ncomp),_values(values),_type(type) -{ -} - -void MEDLoader::MEDFieldDoublePerCellType::releaseArray() -{ - delete [] _values; -} - - -std::string MEDLoaderNS::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; -} - -std::vector MEDLoaderNS::getMeshNamesFid(med_idt fid) -{ - med_maillage type_maillage; - char maillage_description[MED_TAILLE_DESC+1]; - med_int dim; - char nommaa[MED_TAILLE_NOM+1]; - med_int n=MEDnMaa(fid); - std::vector ret(n); - for(int i=0;i MEDLoader::GetMeshNames(const char *fileName) -{ - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - std::vector ret=MEDLoaderNS::getMeshNamesFid(fid); - MEDfermer(fid); - return ret; -} - -std::vector MEDLoader::GetMeshFamilyNames(const char *fileName, const char *meshName) -{ - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nfam=MEDnFam(fid,(char *)meshName); - std::vector ret(nfam); - char nomfam[MED_TAILLE_NOM+1]; - med_int numfam; - for(int i=0;i MEDLoader::GetMeshGroupsNames(const char *fileName, const char *meshName) -{ - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nfam=MEDnFam(fid,(char *)meshName); - std::vector ret; - char nomfam[MED_TAILLE_NOM+1]; - med_int numfam; - for(int i=0;i MEDLoader::GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) -{ - std::vector ret; - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nbFields=MEDnChamp(fid,0); - // - med_type_champ typcha; - //med_int nbpdtnor=0,pflsize,*pflval,lnsize; - med_int ngauss=0; - med_int numdt=0,numo=0,nbrefmaa; - med_float dt=0.0; - med_booleen local; - //char pflname[MED_TAILLE_NOM+1]=""; - //char locname[MED_TAILLE_NOM+1]=""; - char maa_ass[MED_TAILLE_NOM+1]=""; - char dt_unit[MED_TAILLE_PNOM+1]=""; - char nomcha[MED_TAILLE_NOM+1]=""; - // - for(int i=0;i0) - { - MEDpasdetempsInfo(fid,nomcha,MED_MAILLE,typmai[j],1, &ngauss, &numdt, &numo, dt_unit,&dt, maa_ass, &local, &nbrefmaa); - std::string curMeshName=MEDLoaderNS::buildStringFromFortran(maa_ass,MED_TAILLE_NOM+1); - if(curMeshName==meshName) - { - found=true; - ret.push_back(curFieldName); - } - } - } - } - MEDfermer(fid); - return ret; -} - -std::vector MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) -{ - std::vector ret; - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nbFields=MEDnChamp(fid,0); - // - med_type_champ typcha; - med_int ngauss=0; - med_int numdt=0,numo=0,nbrefmaa; - med_float dt=0.0; - med_booleen local; - char maa_ass[MED_TAILLE_NOM+1]=""; - char dt_unit[MED_TAILLE_PNOM+1]=""; - char nomcha[MED_TAILLE_NOM+1]=""; - // - for(int i=0;i0) - { - MEDpasdetempsInfo(fid,nomcha,MED_NOEUD,MED_NONE,1, &ngauss, &numdt, &numo, dt_unit,&dt, maa_ass, &local, &nbrefmaa); - std::string curMeshName=MEDLoaderNS::buildStringFromFortran(maa_ass,MED_TAILLE_NOM+1); - if(curMeshName==meshName) - { - found=true; - ret.push_back(curFieldName); - } - } - } - MEDfermer(fid); - return ret; -} - -std::vector< std::pair > MEDLoader::GetCellFieldIterations(const char *fileName, const char *fieldName) -{ - std::vector< std::pair > ret; - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nbFields=MEDnChamp(fid,0); - // - med_type_champ typcha; - med_int ngauss=0; - med_int numdt=0,numo=0,nbrefmaa; - med_float dt=0.0; - med_booleen local; - char maa_ass[MED_TAILLE_NOM+1]=""; - char dt_unit[MED_TAILLE_PNOM+1]=""; - char nomcha[MED_TAILLE_NOM+1]=""; - // - for(int i=0;i > MEDLoader::GetNodeFieldIterations(const char *fileName, const char *fieldName) -{ - std::vector< std::pair > ret; - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nbFields=MEDnChamp(fid,0); - // - med_type_champ typcha; - med_int ngauss=0; - med_int numdt=0,numo=0,nbrefmaa; - med_float dt=0.0; - med_booleen local; - char maa_ass[MED_TAILLE_NOM+1]=""; - char dt_unit[MED_TAILLE_PNOM+1]=""; - char nomcha[MED_TAILLE_NOM+1]=""; - // - for(int i=0;i& field, - int iteration, int order, ParaMEDMEM::TypeOfField typeOfOutField, double& time) -{ - time=0.; - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nbFields=MEDnChamp(fid,0); - // - med_type_champ typcha; - char nomcha[MED_TAILLE_NOM+1]=""; - char pflname [MED_TAILLE_NOM+1]=""; - char locname [MED_TAILLE_NOM+1]=""; - std::map tabEnt; - std::map tabType; - std::map tabTypeLgth; - tabEnt[ON_CELLS]=MED_MAILLE; - tabType[ON_CELLS]=typmai; - tabTypeLgth[ON_CELLS]=MED_NBR_GEOMETRIE_MAILLE+2; - tabEnt[ON_NODES]=MED_NOEUD; - tabType[ON_NODES]=typmainoeud; - tabTypeLgth[ON_NODES]=1; - // - for(int i=0;i0) - { - int nval=MEDnVal(fid,(char *)fieldName,tabEnt[typeOfOutField],tabType[typeOfOutField][j],iteration,order,(char *)meshName,MED_COMPACT); - double *valr=new double[ncomp*nval]; - // - med_int ngauss=0; - med_int numdt=0,numo=0,nbrefmaa; - char dt_unit[MED_TAILLE_PNOM+1]=""; - char maa_ass[MED_TAILLE_NOM+1]=""; - med_float dt=0.0; - med_booleen local; - med_int nbPdt=MEDnPasdetemps(fid,(char *)fieldName,MED_MAILLE,tabType[typeOfOutField][j]); - bool found2=false; - for(int k=0;k MEDLoaderNS::getIdsFromFamilies(const char *fileName, const char *meshName, const std::vector& fams) -{ - std::vector ret; - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nfam=MEDnFam(fid,(char *)meshName); - char nomfam[MED_TAILLE_NOM+1]; - med_int numfam; - for(int i=0;i MEDLoaderNS::getIdsFromGroups(const char *fileName, const char *meshName, const std::vector& grps) -{ - std::vector ret; - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - med_int nfam=MEDnFam(fid,(char *)meshName); - char nomfam[MED_TAILLE_NOM+1]; - med_int numfam; - for(int i=0;i meshes=getMeshNamesFid(fid); - if(meshes.empty()) - throw INTERP_KERNEL::Exception("No mesh in file"); - trueMeshName=meshes[0]; - return 1; - } - std::string meshNameStr(meshName); - std::vector 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_entite_maillage& whichEntity) -{ - if(nbOfElemCell>=nbOfElemFace) - { - whichEntity=MED_MAILLE; - nbOfElem=nbOfElemCell; - } - else - { - whichEntity=MED_FACE; - nbOfElem=nbOfElemFace; - } -} - -void MEDLoaderNS::readUMeshDataInMedFile(med_idt fid, med_int meshId, double *&coords, int& nCoords, int& spaceDim, std::list& conn) -{ - char nommaa[MED_TAILLE_NOM+1]; - char maillage_description[MED_TAILLE_DESC+1]; - char comp[3*MED_TAILLE_PNOM+1]; - char unit[3*MED_TAILLE_PNOM+1]; - med_maillage type_maillage; - med_int Mdim; - MEDmaaInfo(fid,meshId,nommaa,&Mdim,&type_maillage,maillage_description); - spaceDim=(int)Mdim; - nCoords=MEDnEntMaa(fid,nommaa,MED_COOR,MED_NOEUD,(med_geometrie_element)0,(med_connectivite)0); - coords=new double[nCoords*spaceDim]; - med_repere repere; - MEDcoordLire(fid,nommaa,Mdim,coords,MED_FULL_INTERLACE,MED_ALL,NULL,0,&repere,comp,unit); - med_booleen inoele, inuele; - 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); - int *tmp=new int[curNbOfElem]; - char *noms=new char[MED_TAILLE_PNOM*curNbOfElem+1]; - MEDelementsLire(fid,nommaa,Mdim,connTab,MED_FULL_INTERLACE,noms,&inoele,tmp,&inuele,fam,curNbOfElem,whichEntity,curMedType,MED_NOD); - delete [] tmp; - delete [] noms; - //trying to read global numbering - int *globArr=new int[curNbOfElem]; - if(MEDglobalNumLire(fid,nommaa,globArr,curNbOfElem,whichEntity,curMedType)==0) - elem.setGlobal(globArr); - else - delete [] globArr; - conn.push_back(elem); - } - } - int curNbOfPolyElem; - int curNbOfPolyElemM=MEDnEntMaa(fid,nommaa,MED_CONN,MED_MAILLE,MED_POLYGONE,MED_NOD); - int curNbOfPolyElemF=MEDnEntMaa(fid,nommaa,MED_CONN,MED_FACE,MED_POLYGONE,MED_NOD); - med_entite_maillage whichPolyEntity; - MEDLoaderNS::dispatchElems(curNbOfPolyElemM,curNbOfPolyElemF,curNbOfPolyElem,whichPolyEntity); - if(curNbOfPolyElem>0) - { - med_int arraySize; - MEDpolygoneInfo(fid,nommaa,whichPolyEntity,MED_NOD,&arraySize); - int *index=new int[curNbOfPolyElem+1]; - int *locConn=new int[arraySize]; - int *fam=new int[curNbOfPolyElem]; - MEDLoader::MEDConnOfOneElemType elem(INTERP_KERNEL::NORM_POLYGON,locConn,index,fam,curNbOfPolyElem,arraySize); - MEDpolygoneConnLire(fid,nommaa,index,curNbOfPolyElem+1,locConn,whichPolyEntity,MED_NOD); - MEDfamLire(fid,nommaa,fam,curNbOfPolyElem,MED_MAILLE,MED_POLYGONE); - conn.push_back(elem); - } - curNbOfPolyElem=MEDnEntMaa(fid,nommaa,MED_CONN,MED_MAILLE,MED_POLYEDRE,MED_NOD); - if(curNbOfPolyElem>0) - { - med_int indexFaceLgth,connFaceLgth; - MEDpolyedreInfo(fid,nommaa,MED_NOD,&indexFaceLgth,&connFaceLgth); - int *index=new int[curNbOfPolyElem+1]; - int *indexFace=new int[indexFaceLgth]; - int *locConn=new int[connFaceLgth]; - int *fam=new int[curNbOfPolyElem]; - MEDpolyedreConnLire(fid,nommaa,index,curNbOfPolyElem+1,indexFace,indexFaceLgth,locConn,MED_NOD); - MEDfamLire(fid,nommaa,fam,curNbOfPolyElem,MED_MAILLE,MED_POLYEDRE); - 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) -{ - 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)); - 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; -}; - -void MEDLoaderNS::tradMEDFileCoreFrmt2MEDCouplingUMesh(const std::list& medConnFrmt, - DataArrayInt* &conn, - DataArrayInt* &connIndex, - const std::vector& familiesToKeep) -{ - bool keepAll=familiesToKeep.empty(); - if(medConnFrmt.empty()) - { - conn=0; - connIndex=0; - return ; - } - std::list::const_iterator iter=medConnFrmt.begin(); - int totalNbOfCells=0; - int totalNbOfMedConn=0; - for(;iter!=medConnFrmt.end();iter++) - { - 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(); - 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 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()) - { - *connIdxPtr=connFillId; - *connPtr++=type; - if(!isDyn) - tmpConnPtr=std::transform(sourceConn,sourceConn+nbOfNodesIn1Cell,connPtr,std::bind2nd(std::minus(),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; - } - 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'. - * @param conn input containing connectivity with MEDCoupling format. - * @param connIndex input containing connectivity index in MEDCoupling format. - * @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. - * @return nb of elements extracted. - */ -int MEDLoaderNS::buildMEDSubConnectivityOfOneTypeStaticTypes(DataArrayInt *conn, DataArrayInt *connIndex, INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile) -{ - int ret=0; - int nbOfElem=connIndex->getNbOfElems()-1; - const int *connPtr=conn->getPointer(); - const int *connIdxPtr=connIndex->getPointer(); - for(int i=0;i(),1)); - return ret; -} - -int MEDLoaderNS::buildMEDSubConnectivityOfOneTypesPolyg(DataArrayInt *conn, DataArrayInt *connIndex, std::vector& conn4MEDFile, std::vector& connIndex4MEDFile) -{ - int ret=0; - int nbOfElem=connIndex->getNbOfElems()-1; - const int *connPtr=conn->getPointer(); - const int *connIdxPtr=connIndex->getPointer(); - connIndex4MEDFile.push_back(1); - for(int i=0;i(),1)); - return ret; -} - -int MEDLoaderNS::buildMEDSubConnectivityOfOneTypesPolyh(DataArrayInt *conn, DataArrayInt *connIndex, std::vector& conn4MEDFile, std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile) -{ - return 0; -} - -/*! - * 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 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. - * @return nb of elements extracted. - */ -int MEDLoaderNS::buildMEDSubConnectivityOfOneType(DataArrayInt *conn, DataArrayInt *connIndex, INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile, - std::vector& connIndex4MEDFile, std::vector& connIndexRk24MEDFile) -{ - - const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel(type); - if(!cellMod.isDynamic()) - return buildMEDSubConnectivityOfOneTypeStaticTypes(conn,connIndex,type,conn4MEDFile); - else - { - if(type==INTERP_KERNEL::NORM_POLYGON) - return buildMEDSubConnectivityOfOneTypesPolyg(conn,connIndex,conn4MEDFile,connIndex4MEDFile); - else - return buildMEDSubConnectivityOfOneTypesPolyh(conn,connIndex,conn4MEDFile,connIndex4MEDFile,connIndexRk24MEDFile); - } -} - -/*! - * @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. - */ -MEDCouplingUMesh *MEDLoaderNS::readUMeshFromFileLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& ids, - const std::vector& typesToKeep, unsigned& meshDimExtract) throw(INTERP_KERNEL::Exception) -{ - //Extraction data from MED file. - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); - std::string trueMeshName; - med_int mid=getIdFromMeshName(fid,meshName,trueMeshName); - double *coords; - int nCoords; - int spaceDim; - std::list conn; - readUMeshDataInMedFile(fid,mid,coords,nCoords,spaceDim,conn); - meshDimExtract=MEDLoaderNS::calculateHighestMeshDim(conn); - meshDimExtract=meshDimExtract+meshDimRelToMax; - MEDLoaderNS::keepSpecifiedMeshDim(conn,meshDimExtract); - MEDLoaderNS::keepTypes(conn,typesToKeep); - MEDfermer(fid); - //Put data in returned data structure. - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setName(trueMeshName.c_str()); - ret->setMeshDimension(meshDimExtract); - // - DataArrayDouble *coordsArr=DataArrayDouble::New(); - coordsArr->useArray(coords,true,ParaMEDMEM::CPP_DEALLOC,nCoords,spaceDim); - ret->setCoords(coordsArr); - coordsArr->decrRef(); - // - DataArrayInt *connArr,*connIndexArr; - tradMEDFileCoreFrmt2MEDCouplingUMesh(conn,connArr,connIndexArr,ids); - ret->setConnectivity(connArr,connIndexArr); - //clean-up - if(connArr) - connArr->decrRef(); - if(connIndexArr) - connIndexArr->decrRef(); - releaseMEDFileCoreFrmt(conn); - 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; - readFieldDoubleDataInMedFile(fileName,meshName,fieldName,fieldPerCellType,iteration,order,typeOfOutField,time); - std::vector familiesToKeep; - std::vector typesToKeep; - if(typeOfOutField==ON_CELLS) - for(std::list::const_iterator iter=fieldPerCellType.begin();iter!=fieldPerCellType.end();iter++) - typesToKeep.push_back((*iter).getType()); - unsigned meshDim; - ParaMEDMEM::MEDCouplingUMesh *mesh=readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim); - if(typeOfOutField==ON_CELLS) - MEDLoaderNS::keepSpecifiedMeshDim(fieldPerCellType,meshDim); - ParaMEDMEM::MEDCouplingFieldDouble *ret=ParaMEDMEM::MEDCouplingFieldDouble::New(typeOfOutField,ONE_TIME); - ret->setName(fieldName); - ret->setTime(time,iteration,order); - ret->setMesh(mesh); - mesh->decrRef(); - ParaMEDMEM::DataArrayDouble *arr=buildArrayFromRawData(fieldPerCellType); - ret->setArray(arr); - arr->decrRef(); - releaseMEDFileCoreFrmt(fieldPerCellType); - return ret; -} - -MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax) throw(INTERP_KERNEL::Exception) -{ - std::vector familiesToKeep; - std::vector typesToKeep; - unsigned meshDim; - return MEDLoaderNS::readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim); -} - -ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, int meshDimRelToMax) throw(INTERP_KERNEL::Exception) -{ - std::vector familiesToKeep; - std::vector typesToKeep; - unsigned meshDim; - return MEDLoaderNS::readUMeshFromFileLev1(fileName,0,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim); -} - -ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& fams) -{ - std::vector familiesToKeep=MEDLoaderNS::getIdsFromFamilies(fileName,meshName,fams); - std::vector typesToKeep; - unsigned meshDim; - return MEDLoaderNS::readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim); -} - -ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& grps) -{ - std::vector familiesToKeep=MEDLoaderNS::getIdsFromGroups(fileName,meshName,grps); - std::vector typesToKeep; - unsigned meshDim; - return MEDLoaderNS::readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim); -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) -{ - return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_CELLS); -} - -ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldDoubleNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) -{ - return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_NODES); -} - -void MEDLoaderNS::writeUMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool forceFromScratch) -{ - med_idt fid=MEDouvrir((char *)fileName,forceFromScratch?MED_CREATION:MED_LECTURE_ECRITURE); - std::string meshName(mesh->getName()); - if(meshName=="") - { - MEDfermer(fid); - throw INTERP_KERNEL::Exception("MEDCouplingMesh must have a not null name !"); - } - char maa[MED_TAILLE_NOM+1]; - strcpy(maa,meshName.c_str()); - MEDmaaCr(fid,maa,mesh->getSpaceDimension(),MED_NON_STRUCTURE,maa); - std::set allTypes(mesh->getAllTypes()); - DataArrayInt *conn=mesh->getNodalConnectivity(); - DataArrayInt *connIndex=mesh->getNodalConnectivityIndex(); - char familyName[MED_TAILLE_NOM+1]; - std::fill(familyName,familyName+MED_TAILLE_NOM+1,'\0'); - const char DftFamilyName[]="DftFamily"; - std::copy(DftFamilyName,DftFamilyName+sizeof(DftFamilyName),familyName); - for(int i=0;i medConn; - std::vector medConnIndex; - std::vector medConnIndex2; - int nbOfElt=MEDLoaderNS::buildMEDSubConnectivityOfOneType(conn,connIndex,curType,medConn,medConnIndex,medConnIndex2); - if(curMedType!=MED_POLYGONE && curMedType!=MED_POLYEDRE) - MEDconnEcr(fid,maa,mesh->getMeshDimension(),&medConn[0],MED_FULL_INTERLACE,nbOfElt,MED_MAILLE,curMedType,MED_NOD); - else - { - if(curMedType==MED_POLYGONE) - MEDpolygoneConnEcr(fid,maa,&medConnIndex[0],medConnIndex.size(),&medConn[0],MED_MAILLE,MED_NOD); - } - } - } - MEDfamCr(fid,maa,familyName,0,0,0,0,0,0,0); - DataArrayDouble *arr=mesh->getCoords(); - char comp[2*MED_TAILLE_PNOM+1]; - char unit[2*MED_TAILLE_PNOM+1]; - std::fill(comp,comp+2*MED_TAILLE_PNOM,' '); - comp[2*MED_TAILLE_PNOM]='\0'; - char *work=comp; - for(int i=0;igetSpaceDimension();i++,work+=3) - *work='X'+i; - std::fill(unit,unit+2*MED_TAILLE_PNOM+1,'\0'); - MEDcoordEcr(fid,maa,mesh->getSpaceDimension(),arr->getPointer(),MED_FULL_INTERLACE,mesh->getNumberOfNodes(),MED_CART,comp,unit); - MEDfermer(fid); -} - -void MEDLoaderNS::appendFieldDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f) -{ - med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE_ECRITURE); - int nbComp=f->getNumberOfComponents(); - char *comp=new char[nbComp*MED_TAILLE_PNOM+1]; - std::fill(comp,comp+nbComp*MED_TAILLE_PNOM,' '); - comp[nbComp*MED_TAILLE_PNOM]='\0'; - char *unit=new char[nbComp*MED_TAILLE_PNOM+1]; - std::fill(unit,unit+nbComp*MED_TAILLE_PNOM,' '); - unit[nbComp*MED_TAILLE_PNOM]='\0'; - MEDchampCr(fid,(char *)f->getName(),MED_FLOAT64,comp,unit,nbComp); - med_int numdt,numo; - med_float dt; - ParaMEDMEM::TypeOfTimeDiscretization td=f->getTimeDiscretization(); - if(td==ParaMEDMEM::NO_TIME) - { - numdt=MED_NOPDT; numo=MED_NONOR; 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; - } - const double *pt=f->getArray()->getConstPointer(); - switch(f->getTypeOfField()) - { - case ParaMEDMEM::ON_CELLS: - { - std::list split; - prepareCellFieldDoubleForWriting(f,split); - for(std::list::const_iterator iter=split.begin();iter!=split.end();iter++) - { - char nommaa[MED_TAILLE_NOM+1]; - std::fill(nommaa,nommaa+MED_TAILLE_NOM,' '); nommaa[MED_TAILLE_NOM]='\0'; - strcpy(nommaa,f->getMesh()->getName()); - MEDchampEcr(fid,(char *)nommaa,(char *)f->getName(),(unsigned char*)pt,MED_FULL_INTERLACE,(*iter).getNbOfTuple(), - (char *)MED_NOGAUSS,MED_ALL,(char *)MED_NOPFL,MED_NO_PFLMOD,MED_MAILLE, - typmai3[(int)(*iter).getType()],numdt,(char *)"",dt,numo); - pt+=(*iter).getNbOfTuple()*nbComp; - } - break; - } - case ParaMEDMEM::ON_NODES: - { - int nbOfTuples=f->getArray()->getNumberOfTuples(); - MEDchampEcr(fid,(char *)f->getMesh()->getName(),(char *)f->getName(),(unsigned char*)pt,MED_FULL_INTERLACE,nbOfTuples,(char *)MED_NOGAUSS, - MED_ALL,(char *)MED_NOPFL,MED_NO_PFLMOD,MED_NOEUD,MED_NONE,numdt,(char *)"",dt,numo); - break; - } - default: - throw INTERP_KERNEL::Exception("Not managed this type of FIELD !"); - } - delete [] comp; - delete [] unit; - MEDfermer(fid); -} - -void MEDLoaderNS::prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCouplingFieldDouble *f, 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->checkConsecutiveCellTypes()) - 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; - 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)); - split.push_back(MEDLoader::MEDFieldDoublePerCellType(curType,0,nbComp,pt2-pt)); - pt=pt2; - } -} - -void MEDLoaderNS::writeFieldAndMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool forceFromScratch) -{ - 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()); - writeUMeshDirectly(fileName,mesh,forceFromScratch); - appendFieldDirectly(fileName,f); -} - -void MEDLoader::WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) -{ - 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); - 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::writeUMeshDirectly(fileName,mesh,true); - return ; - } - if(status==MEDLoaderBase::NOT_EXIST) - { - MEDLoaderNS::writeUMeshDirectly(fileName,mesh,true); - return; - } - else - { - std::vector meshNames=GetMeshNames(fileName); - std::string fileNameCpp(mesh->getName()); - if(std::find(meshNames.begin(),meshNames.end(),fileNameCpp)==meshNames.end()) - MEDLoaderNS::writeUMeshDirectly(fileName,mesh,false); - else - { - std::ostringstream oss; oss << "File \'" << fileName << "\' already exists and has already a mesh called \""; - oss << fileNameCpp << "\" !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } -} - -void MEDLoader::WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) -{ - 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 - { - std::ostringstream oss; oss << "File \'" << fileName << "\' already exists and has already a mesh called \""; - oss << fileNameCpp << "\" !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); - } - } -} - -void MEDLoader::WriteFieldUsingAlreadyWrittenMesh(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f) -{ - 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 cb2f74381..000000000 --- a/src/MEDLoader/MEDLoader.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 __MEDLOADER_HXX__ -#define __MEDLOADER_HXX__ - -#include "InterpKernelException.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -#include -#include - -namespace ParaMEDMEM -{ - class DataArrayInt; - class MEDCouplingUMesh; - class MEDCouplingFieldDouble; -} - -class 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); - 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); - 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; } - void releaseArray(); - private: - int _ntuple; - int _ncomp; - double *_values; - INTERP_KERNEL::NormalizedCellType _type; - }; - // - static std::vector GetMeshNames(const char *fileName); - static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName); - static std::vector GetMeshFamilyNames(const char *fileName, const char *meshName); - static std::vector GetCellFieldNamesOnMesh(const char *fileName, const char *meshName); - static std::vector GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName); - static std::vector< std::pair > GetCellFieldIterations(const char *fileName, const char *fieldName); - static std::vector< std::pair > GetNodeFieldIterations(const char *fileName, const char *fieldName); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& fams); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& grps); - 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 *ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); - static void WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch); - static void WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); - static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); -private: - MEDLoader(); -}; - -#endif diff --git a/src/MEDLoader/MEDLoaderBase.cxx b/src/MEDLoader/MEDLoaderBase.cxx deleted file mode 100644 index ec50466fd..000000000 --- a/src/MEDLoader/MEDLoaderBase.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 "MEDLoaderBase.hxx" -#include "InterpKernelException.hxx" - -#include - -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 !"); - } -} diff --git a/src/MEDLoader/MEDLoaderBase.hxx b/src/MEDLoader/MEDLoaderBase.hxx deleted file mode 100644 index 06df9422b..000000000 --- a/src/MEDLoader/MEDLoaderBase.hxx +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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__ - -class MEDLoaderBase -{ -public: - static int getStatusOfFile(const char *fileName); -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; -}; - -#endif diff --git a/src/MEDLoader/Makefile.am b/src/MEDLoader/Makefile.am deleted file mode 100755 index bc5acc7e0..000000000 --- a/src/MEDLoader/Makefile.am +++ /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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -if !MED_ENABLE_MICROMED - SUBDIRS = . Swig -endif - -#DIST_SUBDIRS = Swig - -lib_LTLIBRARIES = libmedloader.la - -salomeinclude_HEADERS= \ -MEDLoader.hxx MEDLoaderBase.hxx - -dist_libmedloader_la_SOURCES= \ -MEDLoader.cxx MEDLoaderBase.cxx - -libmedloader_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 - -# change motivated by the bug KERNEL4778. -libmedloader_la_LDFLAGS= ../MEDCoupling/libmedcoupling.la \ -../INTERP_KERNEL/libinterpkernel.la $(MPI_LIBS) $(MED2_LIBS) $(HDF5_LIBS) diff --git a/src/MEDLoader/Swig/Makefile.am b/src/MEDLoader/Swig/Makefile.am deleted file mode 100644 index eda6669e2..000000000 --- a/src/MEDLoader/Swig/Makefile.am +++ /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 -# - -# 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 - -SWIG_DEF = libMEDLoader_Swig.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 - diff --git a/src/MEDLoader/Swig/libMEDLoader_Swig.i b/src/MEDLoader/Swig/libMEDLoader_Swig.i deleted file mode 100644 index 5a5b6087a..000000000 --- a/src/MEDLoader/Swig/libMEDLoader_Swig.i +++ /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 -// - -%module libMEDLoader_Swig - -%include std_vector.i -%include std_string.i - -%include "MEDCouplingTypemaps.i" -%include "libMEDCoupling_Swig.i" - -%{ -#include "MEDLoader.hxx" -%} - -#if SWIG_VERSION >= 0x010329 -%template() std::vector; -#endif - -%newobject MEDLoader::ReadUMeshFromFile; -%newobject MEDLoader::ReadFieldDoubleCell; - -class MEDLoader -{ -public: - static std::vector GetMeshNames(const char *fileName); - static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName); - static std::vector GetMeshFamilyNames(const char *fileName, const char *meshName); - static std::vector GetCellFieldNamesOnMesh(const char *fileName, const char *meshName); - static std::vector GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName); - %extend - { - static PyObject *GetCellFieldIterations(const char *fileName, const char *fieldName) - { - std::vector< std::pair > res=MEDLoader::GetCellFieldIterations(fileName,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; - } - } - //std::vector< std::pair > GetNodeFieldIterations(const char *fileName, const char *fieldName); - 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 *ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); - static void WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch); - static void WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); - static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); -}; 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/ICoCoField.cxx b/src/ParaMEDMEM/ICoCoField.cxx deleted file mode 100644 index 973376921..000000000 --- a/src/ParaMEDMEM/ICoCoField.cxx +++ /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 -// - -////////////////////////////////////////////////////////////////////////////// -// File: ICoCoField.cpp -// Directory: $TRIO_U_ROOT/Kernel/ICoCo -// Version: /main/1 -////////////////////////////////////////////////////////////////////////////// - -#include -#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/ICoCoTrioField.cxx b/src/ParaMEDMEM/ICoCoTrioField.cxx deleted file mode 100644 index 1e5a14d22..000000000 --- a/src/ParaMEDMEM/ICoCoTrioField.cxx +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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: ICoCoTrioField.cpp -// Directory: $TRIO_U_ROOT/Kernel/Framework -// Version: -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include - -using namespace ICoCo; -using namespace std; - -TrioField::TrioField() : - _type(0), - _connectivity(0), - _coords(0), - _field(0), - _has_field_ownership(false) { } - -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; -} - -int TrioField::nb_values() const -{ - if (_type==0) - return _nb_elems; - else - if (_type==1) - return _nbnodes; - exit(-1); - return -1; - -} -void TrioField::save(ostream& os) const{ - os <> 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; -} - void TrioField::print() { - - } - -// After the call to set_standalone(), field ownership is true and field is allocated -// to the size _nb_field_components*_nb_elems. -// The values of the field have been copied if necessary. -void TrioField::set_standalone() { - if (!_field) { - _field=new double[_nb_field_components*_nb_elems]; - _has_field_ownership=true; - - } - else if (!_has_field_ownership) { - double *tmp_field=new double[_nb_field_components*_nb_elems]; - memcpy(tmp_field,_field,_nb_field_components*_nb_elems*sizeof(double)); - _field=tmp_field; - _has_field_ownership=true; - } -} - -// Used to simulate a 0D geometry (Cathare/Trio for example). -void TrioField::dummy_geom() { - _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]=1; - _connectivity[1]=2; - _connectivity[2]=3; - 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; - if (_field && _has_field_ownership) - delete[] _field; - _has_field_ownership=false; - _field=0; -} - -// Surcharge de l'operateur = pour la classe TrioField -// remplace les valeurs trouvee dans le TrioField donnee en parametre -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; - // std::string _name; // ?? Hérité de la classe mère - _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_elems*_nb_field_components]; - memcpy(_field,NewField._field,_nb_elems*_nb_field_components*sizeof(double)); - } - else - _field=NewField._field; - - return(*this); - -} - diff --git a/src/ParaMEDMEM/InterpKernelDEC.cxx b/src/ParaMEDMEM/InterpKernelDEC.cxx deleted file mode 100644 index 1eb5a243e..000000000 --- a/src/ParaMEDMEM/InterpKernelDEC.cxx +++ /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 -// - -#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 int *src_ids_bg, const int *src_ids_end, - const int *trg_ids_bg, const int *trg_ids_end, - const MPI_Comm& world_comm):DEC(src_ids_bg,src_ids_end,trg_ids_bg,trg_ids_end,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.setBoundingBoxAdjustment(getBoundingBoxAdjustment()); - - 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.setBoundingBoxAdjustment(getBoundingBoxAdjustment()); - - 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 908f21700..000000000 --- a/src/ParaMEDMEM/InterpKernelDEC.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 __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 int *src_ids_bg, const int *src_ids_end, - const int *trg_ids_bg, const int *trg_ids_end, - 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/IntersectionDEC.cxx b/src/ParaMEDMEM/IntersectionDEC.cxx new file mode 100644 index 000000000..fc209b47e --- /dev/null +++ b/src/ParaMEDMEM/IntersectionDEC.cxx @@ -0,0 +1,276 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "IntersectionDEC.hxx" +#include "ElementLocator.hxx" + + + +namespace ParaMEDMEM +{ + + /*! + \defgroup intersectiondec IntersectionDEC + + \section overview Overview + + The IntersectionDEC 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 IntersectionDEC 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 IntersectionDEC::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 IntersectionDEC class. + + \code + ... + IntersectionDEC 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 intersectiondec_options Options + On top of \ref dec_options, options supported by %IntersectionDEC objects are + related to the underlying Intersector class. + All the options available in the intersector objects are + available for the %IntersectionDEC object. The various options available for * intersectors can be reviewed in \ref InterpKerIntersectors. + + For instance : + \verbatim + IntersectionDEC 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 intersectiondec + @{ + */ + + IntersectionDEC::IntersectionDEC() + { + } + + /*! + This constructor creates an IntersectionDEC 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 + + */ + IntersectionDEC::IntersectionDEC(ProcessorGroup& source_group, ProcessorGroup& target_group): + DEC(source_group, target_group),_interpolation_matrix(0) + { + + } + + IntersectionDEC::~IntersectionDEC() + { + 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 IntersectionDEC::synchronize() + { + ParaMEDMEM::ParaMESH* para_mesh = _local_field->getSupport(); + //cout <<"size of Interpolation Matrix"<containsMyRank()) + { + //locate the distant meshes + ElementLocator locator(*para_mesh, *_target_group); + + //transfering option from IntersectionDEC to ElementLocator + locator.setBoundingBoxAdjustment(getBoundingBoxAdjustment()); + + MEDCouplingUMesh* distant_mesh=0; + int* distant_ids=0; + 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); + std::string distantMeth; + locator.exchangeMethod(_method,idistant_proc,distantMeth); + if (distant_mesh !=0) + { + //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; + } + } + } + + if (_target_group->containsMyRank()) + { + ElementLocator locator(*para_mesh, *_source_group); + //transfering option from IntersectionDEC to ElementLocator + locator.setBoundingBoxAdjustment(getBoundingBoxAdjustment()); + + MEDCouplingUMesh* 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->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 IntersectionDEC::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(); + } + } + + + /*! + 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 IntersectionDEC::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 IntersectionDEC::sendData() + { + if (_source_group->containsMyRank()) + { + + _interpolation_matrix->multiply(*_local_field->getField()); + if (getForcedRenormalization()) + renormalizeTargetField(); + + } + 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 IntersectionDEC::sendData( double time , double deltatime ) + { + _interpolation_matrix->getAccessDEC()->setTime(time,deltatime); + sendData() ; + } + + /*! + @} + */ + +} diff --git a/src/ParaMEDMEM/IntersectionDEC.hxx b/src/ParaMEDMEM/IntersectionDEC.hxx new file mode 100644 index 000000000..6659155c8 --- /dev/null +++ b/src/ParaMEDMEM/IntersectionDEC.hxx @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 __INTERSECTIONDEC_HXX__ +#define __INTERSECTIONDEC_HXX__ + +#include "DEC.hxx" +#include "MxN_Mapping.hxx" +#include "InterpolationOptions.hxx" + +namespace ParaMEDMEM +{ + class InterpolationMatrix; + + class IntersectionDEC : public DEC, public INTERP_KERNEL::InterpolationOptions + { + public: + IntersectionDEC(); + IntersectionDEC(ProcessorGroup& source_group, ProcessorGroup& target_group); + virtual ~IntersectionDEC(); + 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/MEDLoader/MEDLoader.cxx b/src/ParaMEDMEM/MEDLoader/MEDLoader.cxx new file mode 100644 index 000000000..2cabfb740 --- /dev/null +++ b/src/ParaMEDMEM/MEDLoader/MEDLoader.cxx @@ -0,0 +1,418 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "CellModel.hxx" +#include "ParaMESH.hxx" +#include "BlockTopology.hxx" +#include "MEDCouplingUMesh.hxx" + +extern "C" +{ +#include "med.h" +} + +#include +#include +#include +#include + +med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = { 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 }; + +INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE] = { INTERP_KERNEL::NORM_ERROR, + 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 }; + +using namespace ParaMEDMEM; + +const char WHITE_SPACES[]=" \n"; + +MEDLoader::MEDConnOfOneElemType::MEDConnOfOneElemType(INTERP_KERNEL::NormalizedCellType type, int *conn, int lgth):_lgth(lgth), + _conn(conn),_global(0), + _type(type) +{ +} + +void MEDLoader::MEDConnOfOneElemType::setGlobal(int *global) +{ + if(_global!=global) + { + if(_global) + delete [] _global; + _global=global; + } +} + +void MEDLoader::MEDConnOfOneElemType::releaseArray() +{ + delete [] _conn; + delete [] _global; +} + +std::string 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; +} + +namespace MEDLoader +{ + med_int getIdFromMeshName(med_idt fid, const char *meshName) throw(INTERP_KERNEL::Exception) + { + if(meshName==0) + return 1; + med_int n=MEDnMaa(fid); + if(n==0) + throw INTERP_KERNEL::Exception("No mesh in file."); + med_maillage type_maillage; + char maillage_description[MED_TAILLE_DESC+1]; + med_int dim; + char nommaa[MED_TAILLE_NOM+1]; + std::ostringstream os; + for(med_int i=1;i<=n;i++) + { + MEDmaaInfo(fid,i,nommaa,&dim,&type_maillage,maillage_description); + std::string cur=buildStringFromFortran(nommaa,sizeof(nommaa)); + if(cur==meshName) + return i; + os << "\'" << cur.c_str() << "\' "; + } + std::ostringstream os2; + os2 << "MeshName '" << meshName << "' not in file : meshes available : " << os.str(); + throw INTERP_KERNEL::Exception(os2.str().c_str()); + } + + void readUMeshDataInMedFile(med_idt fid, med_int meshId, double *&coords, int& nCoords, int& spaceDim, std::list& conn) + { + char nommaa[MED_TAILLE_NOM+1]; + char maillage_description[MED_TAILLE_DESC+1]; + char comp[3*MED_TAILLE_PNOM+1]; + char unit[3*MED_TAILLE_PNOM+1]; + med_maillage type_maillage; + med_int Mdim; + MEDmaaInfo(fid,meshId,nommaa,&Mdim,&type_maillage,maillage_description); + spaceDim=(int)Mdim; + nCoords=MEDnEntMaa(fid,nommaa,MED_COOR,MED_NOEUD,(med_geometrie_element)0,(med_connectivite)0); + coords=new double[nCoords*spaceDim]; + med_repere repere; + MEDcoordLire(fid,nommaa,Mdim,coords,MED_FULL_INTERLACE,MED_ALL,NULL,0,&repere,comp,unit); + med_booleen inoele, inuele; + for(int i=0;icurNbOfElemM) + { + curNbOfElem=curNbOfElemF; + whichEntity=MED_FACE; + } + else + { + curNbOfElem=curNbOfElemM; + whichEntity=MED_MAILLE; + } + if(curNbOfElem>0) + { + int *connTab=new int[(curMedType%100)*curNbOfElem]; + MEDLoader::MEDConnOfOneElemType elem(typmai2[i],connTab,curNbOfElem); + int *tmp=new int[curNbOfElem]; + int *fam=new int[curNbOfElem]; + char *noms=new char[MED_TAILLE_PNOM*curNbOfElem+1]; + MEDelementsLire(fid,nommaa,Mdim,connTab,MED_FULL_INTERLACE,noms,&inoele,tmp,&inuele,fam,curNbOfElem,whichEntity,curMedType,MED_NOD); + delete [] tmp; + delete [] fam; + delete [] noms; + //trying to read global numbering + int *globArr=new int[curNbOfElem]; + if(MEDglobalNumLire(fid,nommaa,globArr,curNbOfElem,whichEntity,curMedType)==0) + elem.setGlobal(globArr); + else + delete [] globArr; + conn.push_back(elem); + } + } + } +} + +unsigned MEDLoader::calculateHighestMeshDim(const std::list& conn) +{ + unsigned ret=0; + for(std::list::const_iterator iter=conn.begin();iter!=conn.end();iter++) + { + unsigned curDim=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()).getDimension(); + if(ret& conn, unsigned meshDim) +{ + for(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++; + } +} + +void MEDLoader::tradMEDFileCoreFrmt2MEDCouplingUMesh(const std::list& medConnFrmt, + DataArrayInt* &conn, + DataArrayInt* &connIndex) +{ + if(medConnFrmt.empty()) + { + conn=0; + connIndex=0; + return ; + } + std::list::const_iterator iter=medConnFrmt.begin(); + int totalNbOfCells=0; + int totalNbOfMedConn=0; + for(;iter!=medConnFrmt.end();iter++) + { + const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel((*iter).getType()); + totalNbOfCells+=(*iter).getLength(); + if(!cellMod.isDynamic()) + totalNbOfMedConn+=(*iter).getLength()*cellMod.getNumberOfNodes(); + else + throw INTERP_KERNEL::Exception("Polyg/polh not implemented yet !"); + } + 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(); + for(iter=medConnFrmt.begin();iter!=medConnFrmt.end();iter++) + { + INTERP_KERNEL::NormalizedCellType type=(*iter).getType(); + int *sourceConn=(*iter).getArray(); + const INTERP_KERNEL::CellModel& cellMod=INTERP_KERNEL::CellModel::getCellModel(type); + int nbOfCellsInCurType; + int nbOfNodesIn1Cell=cellMod.getNumberOfNodes(); + if(!cellMod.isDynamic()) + nbOfCellsInCurType=(*iter).getLength(); + else + throw INTERP_KERNEL::Exception("Polyg/polh not implemented yet !"); + if(!cellMod.isDynamic()) + { + for(int i=0;i(),1)); + connFillId+=nbOfNodesIn1Cell+1; + sourceConn+=nbOfNodesIn1Cell; + } + *connIdxPtr=connFillId; + } + } +} + +void MEDLoader::releaseMEDFileCoreFrmt(std::list& medConnFrmt) +{ + for(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'. + * @param conn input containing connectivity with MEDCoupling format. + * @param connIndex input containing connectivity index in MEDCoupling format. + * @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. + * @return nb of elements extracted. + */ +int MEDLoader::buildMEDSubConnectivityOfOneType(DataArrayInt *conn, DataArrayInt *connIndex, INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile) +{ + int ret=0; + int nbOfElem=connIndex->getNbOfElems()-1; + const int *connPtr=conn->getPointer(); + const int *connIdxPtr=connIndex->getPointer(); + for(int i=0;i(),1)); + return ret; +} + +MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax) throw(INTERP_KERNEL::Exception) +{ + //Extraction data from MED file. + med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); + med_int mid=getIdFromMeshName(fid,meshName); + unsigned meshDimExtract; + double *coords; + int nCoords; + int spaceDim; + std::list conn; + readUMeshDataInMedFile(fid,mid,coords,nCoords,spaceDim,conn); + meshDimExtract=calculateHighestMeshDim(conn); + meshDimExtract=meshDimExtract+meshDimRelToMax; + keepSpecifiedMeshDim(conn,meshDimExtract); + MEDfermer(fid); + //Put data in returned data structure. + MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); + ret->setName(meshName); + ret->setMeshDimension(meshDimExtract); + // + DataArrayDouble *coordsArr=DataArrayDouble::New(); + coordsArr->useArray(coords,true,ParaMEDMEM::CPP_DEALLOC,nCoords,spaceDim); + ret->setCoords(coordsArr); + coordsArr->decrRef(); + // + DataArrayInt *connArr,*connIndexArr; + tradMEDFileCoreFrmt2MEDCouplingUMesh(conn,connArr,connIndexArr); + ret->setConnectivity(connArr,connIndexArr); + //clean-up + if(connArr) + connArr->decrRef(); + if(connIndexArr) + connIndexArr->decrRef(); + releaseMEDFileCoreFrmt(conn); + return ret; +} + +void MEDLoader::writeUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh) +{ + med_idt fid=MEDouvrir((char *)fileName,MED_CREATION); + char maa[MED_TAILLE_NOM+1]; + std::fill(maa,maa+MED_TAILLE_NOM+1,'\0'); + const char *meshName=mesh->getName(); + strcpy(maa,meshName); + MEDmaaCr(fid,maa,mesh->getMeshDimension(),MED_NON_STRUCTURE,maa); + std::set allTypes(mesh->getAllTypes()); + DataArrayInt *conn=mesh->getNodalConnectivity(); + DataArrayInt *connIndex=mesh->getNodalConnectivityIndex(); + char familyName[MED_TAILLE_NOM+1]; + std::fill(familyName,familyName+MED_TAILLE_NOM+1,'\0'); + const char DftFamilyName[]="DftFamily"; + std::copy(DftFamilyName,DftFamilyName+sizeof(DftFamilyName),familyName); + for(int i=0;i medConn; + int nbOfElt=buildMEDSubConnectivityOfOneType(conn,connIndex,curType,medConn); + MEDconnEcr(fid,maa,mesh->getMeshDimension(),&medConn[0],MED_FULL_INTERLACE,nbOfElt,MED_MAILLE,curMedType,MED_NOD); + } + } + MEDfamCr(fid,maa,familyName,0,0,0,0,0,0,0); + DataArrayDouble *arr=mesh->getCoords(); + char comp[2*MED_TAILLE_PNOM+1]; + char unit[2*MED_TAILLE_PNOM+1]; + std::fill(comp,comp+2*MED_TAILLE_PNOM,' '); + comp[2*MED_TAILLE_PNOM]='\0'; + char *work=comp; + for(int i=0;igetSpaceDimension();i++,work+=3) + *work='X'+i; + std::fill(unit,unit+2*MED_TAILLE_PNOM+1,'\0'); + MEDcoordEcr(fid,maa,mesh->getSpaceDimension(),arr->getPointer(),MED_FULL_INTERLACE,mesh->getNumberOfNodes(),MED_CART,comp,unit); + MEDfermer(fid); +} + +/*! + * This method builds the master file 'fileName' of a parallel MED file defined in 'fileNames'. + */ +void MEDLoader::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;igetBlockTopology()->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()); + writeUMesh(fileNames[myRank].c_str(),mesh->getCellMesh()); +} + +void MEDLoader::writeParaField(const char *fileName, const char *meshName, ParaMEDMEM::ParaFIELD *f) +{ +} diff --git a/src/ParaMEDMEM/MEDLoader/MEDLoader.hxx b/src/ParaMEDMEM/MEDLoader/MEDLoader.hxx new file mode 100644 index 000000000..b5f7065da --- /dev/null +++ b/src/ParaMEDMEM/MEDLoader/MEDLoader.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "InterpKernelException.hxx" +#include "NormalizedUnstructuredMesh.hxx" + +#include +#include + +namespace ParaMEDMEM +{ + class ParaMESH; + class ParaFIELD; + class DataArrayInt; + class MEDCouplingUMesh; +} + +namespace MEDLoader +{ + class MEDConnOfOneElemType + { + public: + MEDConnOfOneElemType(INTERP_KERNEL::NormalizedCellType type, int *conn, int lgth); + INTERP_KERNEL::NormalizedCellType getType() const { return _type; } + int getLength() const { return _lgth; } + int *getArray() const { return _conn; } + void setGlobal(int *global); + void releaseArray(); + private: + int _lgth; + int *_conn; + int *_global; + INTERP_KERNEL::NormalizedCellType _type; + }; + unsigned calculateHighestMeshDim(const std::list& conn); + void keepSpecifiedMeshDim(std::list& conn, unsigned meshDim); + void tradMEDFileCoreFrmt2MEDCouplingUMesh(const std::list& medConnFrmt, + ParaMEDMEM::DataArrayInt* &conn, + ParaMEDMEM::DataArrayInt* &connIndex); + void releaseMEDFileCoreFrmt(std::list& medConnFrmt); + void writeMasterFile(const char *fileName, const std::vector& fileNames, const char *meshName); + int buildMEDSubConnectivityOfOneType(ParaMEDMEM::DataArrayInt *conn, ParaMEDMEM::DataArrayInt *connIndex, + INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile); + // + ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName=0, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); + void writeUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh); + void writeParaMesh(const char *fileName, ParaMEDMEM::ParaMESH *mesh); + void writeParaField(const char *fileName, const char *meshName, ParaMEDMEM::ParaFIELD *f); +} + +#endif diff --git a/src/ParaMEDMEM/MEDLoader/Makefile.am b/src/ParaMEDMEM/MEDLoader/Makefile.am new file mode 100755 index 000000000..372249430 --- /dev/null +++ b/src/ParaMEDMEM/MEDLoader/Makefile.am @@ -0,0 +1,39 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# 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= libparamedmemmedloader.la + +salomeinclude_HEADERS= \ +MEDLoader.hxx + +dist_libparamedmemmedloader_la_SOURCES= \ +MEDLoader.cxx + +#libmedmem_la_LDFLAGS= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome +libparamedmemmedloader_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)/../ + +# change motivated by the bug KERNEL4778. +libparamedmemmedloader_la_LDFLAGS= ../../MEDCoupling/libmedcoupling.la \ +../../INTERP_KERNEL/libinterpkernel.la $(MPI_LIBS) $(MED2_LIBS) $(HDF5_LIBS) diff --git a/src/ParaMEDMEM/Test/MPIAccessDECTest.cxx b/src/ParaMEDMEM/Test/MPIAccessDECTest.cxx new file mode 100644 index 000000000..f9ae283ac --- /dev/null +++ b/src/ParaMEDMEM/Test/MPIAccessDECTest.cxx @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/MPIAccessDECTest.hxx b/src/ParaMEDMEM/Test/MPIAccessDECTest.hxx new file mode 100644 index 000000000..9f14a40cb --- /dev/null +++ b/src/ParaMEDMEM/Test/MPIAccessDECTest.hxx @@ -0,0 +1,101 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/MPIAccessTest.cxx b/src/ParaMEDMEM/Test/MPIAccessTest.cxx new file mode 100644 index 000000000..e07a55e5f --- /dev/null +++ b/src/ParaMEDMEM/Test/MPIAccessTest.cxx @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/MPIAccessTest.hxx b/src/ParaMEDMEM/Test/MPIAccessTest.hxx new file mode 100644 index 000000000..308e6d2af --- /dev/null +++ b/src/ParaMEDMEM/Test/MPIAccessTest.hxx @@ -0,0 +1,104 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/MPIMainTest.hxx b/src/ParaMEDMEM/Test/MPIMainTest.hxx new file mode 100644 index 000000000..9d07ab32d --- /dev/null +++ b/src/ParaMEDMEM/Test/MPIMainTest.hxx @@ -0,0 +1,97 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 + +// ============================================================================ +/*! + * 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[]) +{ + 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 + +using namespace std; + + + +/*! + * Tool to remove temporary files. + * Allows automatique removal of temporary files in case of test failure. + */ +ParaMEDMEMTest_TmpFilesRemover::~ParaMEDMEMTest_TmpFilesRemover() +{ + 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 string theTmpFile) +{ + return (myTmpFiles.insert(theTmpFile)).second; +} diff --git a/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx new file mode 100644 index 000000000..baab1b7af --- /dev/null +++ b/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx @@ -0,0 +1,136 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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(testIntersectionDEC_2D); + CPPUNIT_TEST(testIntersectionDEC_2DP0P1); + + CPPUNIT_TEST(testSynchronousEqualIntersectionWithoutInterpNativeDEC_2D); + CPPUNIT_TEST(testSynchronousEqualIntersectionWithoutInterpDEC_2D); + CPPUNIT_TEST(testSynchronousEqualIntersectionDEC_2D); + CPPUNIT_TEST(testSynchronousFasterSourceIntersectionDEC_2D); + CPPUNIT_TEST(testSynchronousSlowerSourceIntersectionDEC_2D); + CPPUNIT_TEST(testSynchronousSlowSourceIntersectionDEC_2D); + CPPUNIT_TEST(testSynchronousFastSourceIntersectionDEC_2D); + CPPUNIT_TEST(testAsynchronousEqualIntersectionDEC_2D); + CPPUNIT_TEST(testAsynchronousFasterSourceIntersectionDEC_2D); + CPPUNIT_TEST(testAsynchronousSlowerSourceIntersectionDEC_2D); + CPPUNIT_TEST(testAsynchronousSlowSourceIntersectionDEC_2D); + CPPUNIT_TEST(testAsynchronousFastSourceIntersectionDEC_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_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 testIntersectionDEC_2D(); + void testIntersectionDEC_2DP0P1(); +#ifdef MED_ENABLE_FVM + void testNonCoincidentDEC_2D(); + void testNonCoincidentDEC_3D(); +#endif + void testStructuredCoincidentDEC(); + void testSynchronousEqualIntersectionWithoutInterpNativeDEC_2D(); + void testSynchronousEqualIntersectionWithoutInterpDEC_2D(); + void testSynchronousEqualIntersectionDEC_2D(); + void testSynchronousFasterSourceIntersectionDEC_2D(); + void testSynchronousSlowerSourceIntersectionDEC_2D(); + void testSynchronousSlowSourceIntersectionDEC_2D(); + void testSynchronousFastSourceIntersectionDEC_2D(); + + void testAsynchronousEqualIntersectionDEC_2D(); + void testAsynchronousFasterSourceIntersectionDEC_2D(); + void testAsynchronousSlowerSourceIntersectionDEC_2D(); + void testAsynchronousSlowSourceIntersectionDEC_2D(); + void testAsynchronousFastSourceIntersectionDEC_2D(); + + +private: + void testNonCoincidentDEC(const std::string& filename1, + const std::string& meshname1, + const std::string& filename2, + const std::string& meshname2, + int nbprocsource, double epsilon); + void testAsynchronousIntersectionDEC_2D(double dtA, double tmaxA, + double dtB, double tmaxB, + bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth); + void testIntersectionDEC_2D_(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/ParaMEDMEM/Test/ParaMEDMEMTest_BlockTopology.cxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest_BlockTopology.cxx new file mode 100644 index 000000000..f116ff2a7 --- /dev/null +++ b/src/ParaMEDMEM/Test/ParaMEDMEMTest_BlockTopology.cxx @@ -0,0 +1,122 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/ParaMEDMEMTest_IntersectionDEC.cxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest_IntersectionDEC.cxx new file mode 100644 index 000000000..144f888b7 --- /dev/null +++ b/src/ParaMEDMEM/Test/ParaMEDMEMTest_IntersectionDEC.cxx @@ -0,0 +1,541 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "MxN_Mapping.hxx" +#include "IntersectionDEC.hxx" +#include "ParaMESH.hxx" +#include "ParaFIELD.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; + +void ParaMEDMEMTest::testIntersectionDEC_2D() +{ + testIntersectionDEC_2D_("P0","P0"); +} + +void ParaMEDMEMTest::testIntersectionDEC_2DP0P1() +{ + //testIntersectionDEC_2D_("P0","P1"); +} + +/* + * Check methods defined in IntersectionDEC.hxx + * + IntersectionDEC(); + IntersectionDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group); + virtual ~IntersectionDEC(); + void synchronize(); + void recvData(); + void sendData(); +*/ + +void ParaMEDMEMTest::testIntersectionDEC_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 <getNumberOfCells(); + else + nb_local=mesh->getNumberOfNodes(); + // double * value= new double[nb_local]; + double *value=parafield->getField()->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_"<getNumberOfCells(); + else + nb_local=mesh->getNumberOfNodes(); + // double * value= new double[nb_local]; + double *value=parafield->getField()->getArray()->getPointer(); + for(int ielem=0; ielemcontainsMyRank()) + { + field_before_int = parafield->getVolumeIntegral(0); + dec.synchronize(); + cout<<"DEC usage"<myRank()==0) + aRemover.Register("./sourcesquareb"); + ostringstream filename; + filename<<"./sourcesquareb_"<myRank()+1; + aRemover.Register(filename.str().c_str()); + MEDLoader::writeParaField("./sourcesquareb","boundary",parafield); + + dec.recvData(); + cout <<"writing"<myRank()==0) + aRemover.Register("./sourcesquare"); + MEDLoader::writeParaField("./sourcesquare","boundary",parafield); + + + filename<<"./sourcesquare_"<myRank()+1; + aRemover.Register(filename.str().c_str()); + field_after_int = parafield->getVolumeIntegral(0); + + + // 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(); + MEDLoader::writeParaMesh("./targetsquareb",paramesh); + MEDLoader::writeParaField("./targetsquareb", "boundary",parafield); + if (target_group->myRank()==0) + aRemover.Register("./targetsquareb"); + ostringstream filename; + filename<<"./targetsquareb_"<myRank()+1; + aRemover.Register(filename.str().c_str()); + dec.sendData(); + MEDLoader::writeParaMesh("./targetsquare",paramesh); + MEDLoader::writeParaField("./targetsquare", "boundary",parafield); + + 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 IntersectionDEC_2D test"< self_procs; + set procs_source; + set procs_target; + + for (int i=0; icontainsMyRank()) + { + string master = filename_xml1; + + ostringstream strstream; + strstream <getNumberOfCells(); + else + nb_local=mesh->getNumberOfNodes(); + // double * value= new double[nb_local]; + double *value=parafield->getField()->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_"<getNumberOfCells(); + else + nb_local=mesh->getNumberOfNodes(); + + double *value=parafield->getField()->getArray()->getPointer(); + for(int ielem=0; ielemcontainsMyRank()) + { + 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); + cout << "testAsynchronousIntersectionDEC_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 << "testAsynchronousIntersectionDEC_2D" << rank << " MPI_Barrier " << endl ; + + if (Asynchronous) MPI_Barrier(MPI_COMM_WORLD); + cout << "end of IntersectionDEC_2D test"< +#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/ParaMEDMEM/Test/ParaMEDMEMTest_NonCoincidentDEC.cxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest_NonCoincidentDEC.cxx new file mode 100644 index 000000000..743d91b49 --- /dev/null +++ b/src/ParaMEDMEM/Test/ParaMEDMEMTest_NonCoincidentDEC.cxx @@ -0,0 +1,256 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "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 IntersectionDEC.hxx + * + IntersectionDEC(); + IntersectionDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group); + virtual ~IntersectionDEC(); + 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 data_dir = getenv("MED_ROOT_DIR") + "/share/salome/resources/med/"; + string tmp_dir = getenv("TMP"); + if (tmp_dir == "") + tmp_dir = "/tmp"; + string filename_xml1 = data_dir + filename1; + string filename_xml2 = data_dir + filename2; + string filename_seq_wr = tmp_dir + "/"; + string filename_seq_med = tmp_dir + "/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); + +} diff --git a/src/ParaMEDMEM/Test/ParaMEDMEMTest_StructuredCoincidentDEC.cxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest_StructuredCoincidentDEC.cxx new file mode 100644 index 000000000..c0abcf871 --- /dev/null +++ b/src/ParaMEDMEM/Test/ParaMEDMEMTest_StructuredCoincidentDEC.cxx @@ -0,0 +1,163 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 "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 data_dir = getenv("MED_ROOT_DIR"); + string tmp_dir = getenv("TMP"); + if (tmp_dir == "") + tmp_dir = "/tmp"; + string filename_xml1 = data_dir + + "/share/salome/resources/med/square1_split"; + string filename_2 = data_dir + "/share/salome/resources/med/square1.med"; + string filename_seq_wr = tmp_dir + "/"; + string filename_seq_med = tmp_dir + "/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; ielemgetNumberOfCells(); + double *value=parafield->getField()->getArray()->getPointer(); + for (int ielem=0; ielemgetField()->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/ParaMEDMEM/Test/TestMPIAccess.cxx b/src/ParaMEDMEM/Test/TestMPIAccess.cxx new file mode 100644 index 000000000..e71974e99 --- /dev/null +++ b/src/ParaMEDMEM/Test/TestMPIAccess.cxx @@ -0,0 +1,30 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/TestMPIAccessDEC.cxx b/src/ParaMEDMEM/Test/TestMPIAccessDEC.cxx new file mode 100644 index 000000000..80431cff1 --- /dev/null +++ b/src/ParaMEDMEM/Test/TestMPIAccessDEC.cxx @@ -0,0 +1,30 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/TestParaMEDMEM.cxx b/src/ParaMEDMEM/Test/TestParaMEDMEM.cxx new file mode 100644 index 000000000..6bddba11d --- /dev/null +++ b/src/ParaMEDMEM/Test/TestParaMEDMEM.cxx @@ -0,0 +1,30 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_AllToAllDEC.cxx b/src/ParaMEDMEM/Test/test_AllToAllDEC.cxx new file mode 100644 index 000000000..5b8d66896 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_AllToAllDEC.cxx @@ -0,0 +1,169 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_AllToAllTimeDEC.cxx b/src/ParaMEDMEM/Test/test_AllToAllTimeDEC.cxx new file mode 100644 index 000000000..f869374a7 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_AllToAllTimeDEC.cxx @@ -0,0 +1,266 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_AllToAllvDEC.cxx b/src/ParaMEDMEM/Test/test_AllToAllvDEC.cxx new file mode 100644 index 000000000..7a5c65f59 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_AllToAllvDEC.cxx @@ -0,0 +1,211 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_AllToAllvTimeDEC.cxx b/src/ParaMEDMEM/Test/test_AllToAllvTimeDEC.cxx new file mode 100644 index 000000000..e8bbb1f4d --- /dev/null +++ b/src/ParaMEDMEM/Test/test_AllToAllvTimeDEC.cxx @@ -0,0 +1,362 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 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 maxtime ; + double nextdeltatime = deltatime[myrank] ; + if ( UseMPI_Alltoallv ) { + maxtime = maxreq*nextdeltatime - 0.1 ; + } + else { + maxtime = maxreq ; + // MyMPIAccessDEC->InitTime( time , nextdeltatime , maxtime ) ; + } + time_t begintime = std::time(NULL) ; + // for ( time = 0 ; time <= maxtime ; time+=deltatime[myrank] ) { + for ( time = 0 ; time <= maxtime && nextdeltatime != 0 ; time+=nextdeltatime ) { + nextdeltatime = deltatime[myrank] ; + if ( time != 0 ) { + nextdeltatime = deltatime[myrank] ; + if ( time+nextdeltatime > maxtime ) { + nextdeltatime = 0 ; + } + // MyMPIAccessDEC->NextTime( nextdeltatime ) ; + } + MyMPIAccessDEC->setTime( time , 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 = time ; + // aSendTimeMessage->deltatime = deltatime[myrank] ; + aSendTimeMessage->deltatime = nextdeltatime ; + // aSendTimeMessage->maxtime = maxtime ; + aSendTimeMessage->tag = (int ) (time/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 = std::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 = std::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/ParaMEDMEM/Test/test_AllToAllvTimeDoubleDEC.cxx b/src/ParaMEDMEM/Test/test_AllToAllvTimeDoubleDEC.cxx new file mode 100644 index 000000000..81813e1a5 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_AllToAllvTimeDoubleDEC.cxx @@ -0,0 +1,336 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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 time[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++ ) { + time[i] = 0 ; + maxtime[i] = maxreq ; + nextdeltatime[i] = deltatime[i] ; + } + time_t begintime = std::time(NULL) ; + for ( time[myrank] = 0 ; time[myrank] <= maxtime[myrank] && nextdeltatime[myrank] != 0 ; + time[myrank]+=nextdeltatime[myrank] ) { +//local and target times + int target ; + for ( target = 0 ; target < size ; target++ ) { + nextdeltatime[target] = deltatime[target] ; + if ( time[target] != 0 ) { + if ( time[target]+nextdeltatime[target] > maxtime[target] ) { + nextdeltatime[target] = 0 ; + } + } + if ( target != myrank ) { + while ( time[myrank] >= time[target] ) { + time[target] += deltatime[target] ; + } + } + } + MyMPIAccessDEC->setTime( time[myrank] , nextdeltatime[myrank] ) ; + cout << "test" << myrank << "=====TIME " << time[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 + + (time[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 + + (time[target]/deltatime[target])*100 + j)) > 101) { + badrecvbuf = true ; + cout << "test_AllToAllvTimeDoubleDEC" << myrank << " target " << target << " time[target] " + << time[target] << " recvbuf[" << index << "] " << (int ) recvbuf[index] + << " # " << (int ) (target*1000000 + + myrank*10000 + (time[target]/deltatime[target])*100 + j) + << endl ; + } + else if ( badrecvbuf ) { + cout << "test_AllToAllvTimeDoubleDEC" << myrank << " recvbuf[" << index << "] " + << recvbuf[index] << " ~= " << (int ) (target*1000000 + + myrank*10000 + (time[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 = std::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 = std::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/ParaMEDMEM/Test/test_MPI_Access_Cancel.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Cancel.cxx new file mode 100644 index 000000000..2ac553f3e --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Cancel.cxx @@ -0,0 +1,320 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_Cyclic_ISend_IRecv.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Cyclic_ISend_IRecv.cxx new file mode 100644 index 000000000..d2a84289c --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Cyclic_ISend_IRecv.cxx @@ -0,0 +1,269 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_Cyclic_Send_Recv.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Cyclic_Send_Recv.cxx new file mode 100644 index 000000000..b825f90ef --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Cyclic_Send_Recv.cxx @@ -0,0 +1,186 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_IProbe.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_IProbe.cxx new file mode 100644 index 000000000..9d18c902d --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_IProbe.cxx @@ -0,0 +1,167 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_ISendRecv.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_ISendRecv.cxx new file mode 100644 index 000000000..6b5411249 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_ISendRecv.cxx @@ -0,0 +1,215 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv.cxx new file mode 100644 index 000000000..8d1a9306c --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv.cxx @@ -0,0 +1,220 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_BottleNeck.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_BottleNeck.cxx new file mode 100644 index 000000000..45cc5439f --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_BottleNeck.cxx @@ -0,0 +1,224 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length.cxx new file mode 100644 index 000000000..c6dc2743d --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length.cxx @@ -0,0 +1,233 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length_1.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length_1.cxx new file mode 100644 index 000000000..3d09f6d3c --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_ISend_IRecv_Length_1.cxx @@ -0,0 +1,304 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_Probe.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Probe.cxx new file mode 100644 index 000000000..2bce97e12 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Probe.cxx @@ -0,0 +1,143 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_SendRecv.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_SendRecv.cxx new file mode 100644 index 000000000..a93fa4af8 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_SendRecv.cxx @@ -0,0 +1,179 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_Send_Recv.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Send_Recv.cxx new file mode 100644 index 000000000..f7e556a97 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Send_Recv.cxx @@ -0,0 +1,165 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_Send_Recv_Length.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Send_Recv_Length.cxx new file mode 100644 index 000000000..fc55f26f6 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Send_Recv_Length.cxx @@ -0,0 +1,189 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_Time.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Time.cxx new file mode 100644 index 000000000..1a8eb185b --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Time.cxx @@ -0,0 +1,289 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/ParaMEDMEM/Test/test_MPI_Access_Time_0.cxx b/src/ParaMEDMEM/Test/test_MPI_Access_Time_0.cxx new file mode 100644 index 000000000..3da138565 --- /dev/null +++ b/src/ParaMEDMEM/Test/test_MPI_Access_Time_0.cxx @@ -0,0 +1,470 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// 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/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 da4e4873c..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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_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(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(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_2D(); - void testInterpKernelDEC2_2D(); - void testInterpKernelDEC_2DP0P1(); - void testInterpKernelDEC_3D(); - void testInterpKernelDECNonOverlapp_2D_P0P0(); - void testInterpKernelDECNonOverlapp_2D_P0P1P1P0(); - void testInterpKernelDEC2DM1D_P0P0(); - void testInterpKernelDECPartialProcs(); -#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 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: - void testNonCoincidentDEC(const std::string& filename1, - const std::string& meshname1, - const std::string& filename2, - const std::string& meshname2, - int nbprocsource, double epsilon); - 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/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 92c33f5b3..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx +++ /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 -// - -#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[1]={0}; - int procs_target[1]={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_source+1,procs_target,procs_target+1); - 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 099d30626..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"); -} - -/* - * 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); -} - -/*! - * 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)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,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::GetMeshFamilyNames(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(),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(),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::ReadFieldDoubleCell(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.,3.,3.,2.,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)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,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::ReadFieldDoubleCell(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.,6.,1.,1.,6.,0.,0.,5.,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)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,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(),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::ReadFieldDoubleNode(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::ReadFieldDoubleNode(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)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,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::ReadFieldDoubleNode(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)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); - CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); - CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,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(),fieldsName[0].c_str()); - CPPUNIT_ASSERT_EQUAL(1,(int)its0.size()); - MEDCouplingFieldDouble *field=MEDLoader::ReadFieldDoubleCell(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()); - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(i)); - for(int i=6;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i)); - for(int i=14;i<17;i++) - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i)); - 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::GetMeshFamilyNames(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 ee55782a8..000000000 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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 "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); - -} 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"< -#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 c06003951..000000000 --- a/src/RENUMBER/renumbering.cxx +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// 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_Med.hxx" -#include "MEDMEM_MedMeshDriver22.hxx" - -#include "RenumberingFactory.hxx" - -#include -using namespace MEDMEM; -using namespace std; -using namespace MED_EN; -using namespace MED_RENUMBER; - -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->getNumberOfElementsWithPoly(MED_FACE,MED_ALL_ELEMENTS); - int nb_edge = mesh->getNumberOfElementsWithPoly(MED_EDGE,MED_ALL_ELEMENTS); - nb_cell= mesh->getNumberOfElementsWithPoly(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) -{ - if(Type==MED_POLYHEDRA) - { - int *conn_face_index_init=(int*)mesh.getPolyhedronFacesIndex(); - int *conn_index_init=(int*)mesh.getPolyhedronIndex(MED_FULL_INTERLACE); - int *conn_init=(int*)mesh.getPolyhedronConnectivity(MED_FULL_INTERLACE); - - int *conn_index_renum=new int[nb_cell+1]; - int *conn_face_index_renum=new int[conn_index_init[nb_cell]]; - int *conn_renum=new int[conn_face_index_init[conn_index_init[nb_cell]-1]-1]; - - int i_cell,i_face,i_conn; - int iter_face=0; - int iter_conn=0; - int i2; - conn_index_renum[0]=1; - conn_face_index_renum[0]=1; - for(i_cell=0;i_cellsetNodal(conn_renum,MED_CELL,Type); - 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;j mesh_names,f_names; - nb_mesh=med_struct.getNumberOfMeshes(); - nb_fields=med_struct.getNumberOfFields(); - mesh_names=med_struct.getMeshNames(); - f_names=med_struct.getFieldNames(); - if(nb_mesh!=1) - { - cout << "There are many meshes in the file" << endl; - return -1; - } - if(mesh_names[0].c_str()!=meshname) - { - cout << "Mesh name does not match" << endl; - return -1; - } - vector field_names; - vector iternumber; - vector ordernumber; - vector types; - int nb_fields_tot=0; - for (int ifield = 0; ifield < nb_fields; ifield++) - { - deque dtit=med_struct.getFieldIteration(f_names[ifield]); - for (deque::const_iterator iter =dtit.begin(); iter!=dtit.end(); iter++) - { - field_names.push_back(f_names[ifield]); - iternumber.push_back(iter->dt); - ordernumber.push_back(iter->it); - ++nb_fields_tot; - FIELD_* field = med_struct.getField(f_names[ifield],iter->dt,iter->it); - if (dynamic_cast*>(field)) - types.push_back(1); - else - types.push_back(0); - - } - } - t_read_st=clock(); - - // Reading mesh - MESH myMesh; - myMesh.setName(meshname); - MED_MESH_RDONLY_DRIVER22 *drv22=new MED_MESH_RDONLY_DRIVER22(filename_in,&myMesh); - drv22->desactivateFacesComputation(); - int newDrv=myMesh.addDriver(*drv22); - delete drv22; - myMesh.read(newDrv); - int nb_type=myMesh.getNumberOfTypesWithPoly(MED_CELL); - if (nb_type!=1) - { - cout << "Mesh must have only one type of cell" << endl; - return -1; - } - medGeometryElement *Types = myMesh.getTypesWithPoly(MED_CELL); - medGeometryElement Type=Types[0]; - delete[] Types; - - 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; - for(int ifield=0;ifield myField(MED_DRIVER,filename_in,field_names[ifield],iternumber[ifield],ordernumber[ifield]); - 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