X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDPartitioner%2FMEDPARTITIONER_Utils.hxx;h=839364fd0a96dc50be9a2ba97d603cbf830fa4a1;hb=8411b13fec372c7635bf04d2bb81a869dc038fdd;hp=02b74cf2855573bfb6055a2b0108e6725dea3601;hpb=10f37bf6f33a762626d7f1093b2f5450c1688667;p=tools%2Fmedcoupling.git diff --git a/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx b/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx index 02b74cf28..839364fd0 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, 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 @@ -23,6 +23,7 @@ #include "MEDPARTITIONER.hxx" #include "MEDCouplingUMesh.hxx" +#include "BBTree.txx" #include #include @@ -44,7 +45,7 @@ namespace MEDPARTITIONER MEDPARTITIONER_EXPORT std::string ReprVectorOfString(const std::vector& vec); MEDPARTITIONER_EXPORT std::string ReprVectorOfString(const std::vector& vec, const std::string separator); - MEDPARTITIONER_EXPORT std::string ReprMapOfStringInt(const std::map& mymap); + MEDPARTITIONER_EXPORT std::string ReprMapOfStringInt(const std::map& mymap); MEDPARTITIONER_EXPORT std::string ReprMapOfStringVectorOfString(const std::map< std::string,std::vector >& mymap); MEDPARTITIONER_EXPORT std::string ReprFieldDescriptions(const std::vector& vec,const std::string separator); @@ -53,8 +54,8 @@ namespace MEDPARTITIONER MEDPARTITIONER_EXPORT std::vector DeserializeToVectorOfString(const std::string& str); MEDPARTITIONER_EXPORT std::string EraseTagSerialized(const std::string& fromStr, const std::string& tag); - MEDPARTITIONER_EXPORT std::vector VectorizeFromMapOfStringInt(const std::map& mymap); - MEDPARTITIONER_EXPORT std::map DevectorizeToMapOfStringInt(const std::vector& vec); + MEDPARTITIONER_EXPORT std::vector VectorizeFromMapOfStringInt(const std::map& mymap); + MEDPARTITIONER_EXPORT std::map DevectorizeToMapOfStringInt(const std::vector& vec); MEDPARTITIONER_EXPORT std::vector VectorizeFromMapOfStringVectorOfString(const std::map< std::string,std::vector >& mymap); MEDPARTITIONER_EXPORT std::map< std::string,std::vector > DevectorizeToMapOfStringVectorOfString(const std::vector& vec); @@ -74,21 +75,24 @@ namespace MEDPARTITIONER int& idomain, std::string& fileName, std::string& meshName, std::string& fieldName, int& typeField, int& DT, int& IT); MEDPARTITIONER_EXPORT void FieldShortDescriptionToData(const std::string& description, - std::string& fieldName, int& typeField, int& entity, int& DT, int& IT); - - ParaMEDMEM::DataArrayInt *CreateDataArrayIntFromVector(const std::vector& v); - ParaMEDMEM::DataArrayInt *CreateDataArrayIntFromVector(const std::vector& v, const int nbComponents); - ParaMEDMEM::DataArrayDouble *CreateDataArrayDoubleFromVector(const std::vector& v); + std::string& fieldName, int& typeField, int& entity, int& DT, int& IT); + + MEDCoupling::DataArrayIdType *CreateDataArrayIntFromVector(const std::vector& v); + MEDCoupling::DataArrayIdType *CreateDataArrayIntFromVector(const std::vector& v, const int nbComponents); + MEDCoupling::DataArrayDouble *CreateDataArrayDoubleFromVector(const std::vector& v); - ParaMEDMEM::MEDCouplingUMesh *CreateEmptyMEDCouplingUMesh(); + MEDCoupling::MEDCouplingUMesh *CreateEmptyMEDCouplingUMesh(); - std::vector BrowseFieldDouble(const ParaMEDMEM::MEDCouplingFieldDouble* fd); + std::vector BrowseFieldDouble(const MEDCoupling::MEDCouplingFieldDouble* fd); std::vector BrowseAllFields(const std::string& myfile); std::vector BrowseAllFieldsOnMesh(const std::string& myfile, const std::string& mymesh, const int idomain); std::vector GetInfosOfField(const char *fileName, const char *meshName, const int idomain ); -#ifdef HAVE_MPI2 - //not adviced, interblocking, use sendAndReceive + MEDCoupling::MCAuto< MEDCoupling::DataArrayInt32 > FromIdTypeVec( const std::vector< mcIdType >& vec ); + + +#ifdef HAVE_MPI + //not advised, interblocking, use sendAndReceive //void SendVectorOfString(const std::vector& vec, const int target); //std::vector RecvVectorOfString(const int source); //TODO void sendRecvVectorOfString(const std::vector& vec, const int source, const int target); @@ -99,14 +103,14 @@ namespace MEDPARTITIONER std::vector *RecvDoubleVec(const int source); void RecvDoubleVec(std::vector& vec, const int source); - void SendIntVec(const std::vector& vec, const int target); + void SendIntVec(const std::vector& vec, const int target); std::vector* RecvIntVec(int source); - void RecvIntVec(std::vector& vec, const int source); + void RecvIntVec(std::vector& vec, const int source); - void SendDataArrayInt(const ParaMEDMEM::DataArrayInt* da, const int target); - ParaMEDMEM::DataArrayInt *RecvDataArrayInt(const int source); - void SendDataArrayDouble(const ParaMEDMEM::DataArrayDouble* da, const int target); - ParaMEDMEM::DataArrayDouble *RecvDataArrayDouble(const int source); + void SendDataArrayInt(const MEDCoupling::DataArrayInt* da, const int target); + MEDCoupling::DataArrayInt *RecvDataArrayInt(const int source); + void SendDataArrayDouble(const MEDCoupling::DataArrayDouble* da, const int target); + MEDCoupling::DataArrayDouble *RecvDataArrayDouble(const int source); void TestVectorOfStringMpi(); void TestMapOfStringIntMpi(); @@ -125,7 +129,8 @@ namespace MEDPARTITIONER static int _World_Size; static int _Randomize; static int _Atomize; - static int _Creates_Boundary_Faces; + static int _Create_Boundary_Faces; + static int _Create_Joints; static int _Is0verbose; //trace cout if rank 0 and verbose static std::vector _File_Names; //on [iold] static std::vector _Mesh_Names; //on [iold] @@ -133,5 +138,44 @@ namespace MEDPARTITIONER /*! used for descriptions of components of fields for example...*/ static std::vector _General_Informations; }; + + + + /*! + * \brief Class encapsulating BBTree of dimension given at construction and + * providing all features of BBTree + */ + class BBTreeOfDim + { + void * _tree; + void (BBTreeOfDim::*_PgetElementsAroundPoint)( const double* coordsPtr, + std::vector& elems ) const; + void (BBTreeOfDim::*_PgetIntersectingElems)( const double* bb, + std::vector& elems ) const; + + template< int dim> + void _getElementsAroundPoint( const double* coordsPtr, + std::vector& elems ) const + { + ((BBTree*)_tree)->getElementsAroundPoint( coordsPtr, elems ); + } + template< int dim> + void _getIntersectingElems(const double* bb, + std::vector& elems) const + { + ((BBTree*)_tree)->getIntersectingElems( bb, elems ); + } + public: + + BBTreeOfDim( std::size_t dim, + const double* bbs, + mcIdType* elems, + int level, + mcIdType nbelems, + double epsilon=1e-12); + ~BBTreeOfDim(); + void getElementsAroundPoint(const double* coordsPtr, std::vector& elems ) const; + void getIntersectingElems (const double* bb, std::vector& elems) const; + }; } #endif