X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDPartitioner%2FMEDPARTITIONER_ConnectZone.cxx;h=3a1c9ce67c2624d8cf8d0d39f25cc7894d7ffb72;hb=4b4c848900cf2fb2cd8cb585c6ff21c7d284b87b;hp=eb60723b522b88d307b0c288be407fc297554d4b;hpb=8763c12d01e33d6845dd53be65b001514d00bd42;p=tools%2Fmedcoupling.git diff --git a/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx b/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx index eb60723b5..3a1c9ce67 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -19,8 +19,12 @@ #include "MEDPARTITIONER_ConnectZone.hxx" +#include "MEDCouplingSkyLineArray.hxx" + #include +using namespace MEDCoupling; + MEDPARTITIONER::ConnectZone::ConnectZone(): _name("") ,_description("") @@ -28,16 +32,16 @@ MEDPARTITIONER::ConnectZone::ConnectZone(): ,_distant_domain_number(0) ,_node_corresp(0) ,_face_corresp(0) + ,_local_mesh(0) + ,_distant_mesh(0) { } MEDPARTITIONER::ConnectZone::~ConnectZone() { - delete _node_corresp; - delete _face_corresp; - for(std::map < std::pair ,SkyLineArray * >::iterator iter=_entity_corresp.begin(); iter!=_entity_corresp.end();iter++) + for(std::map < std::pair ,MEDCouplingSkyLineArray * >::iterator iter=_entity_corresp.begin(); iter!=_entity_corresp.end();iter++) { - delete iter->second; + iter->second->decrRef(); } } @@ -49,6 +53,8 @@ MEDPARTITIONER::ConnectZone::ConnectZone(const ConnectZone & myConnectZone): ,_node_corresp(myConnectZone._node_corresp) ,_face_corresp(myConnectZone._face_corresp) ,_entity_corresp(myConnectZone._entity_corresp) + ,_local_mesh(0) + ,_distant_mesh(0) { } @@ -72,19 +78,19 @@ int MEDPARTITIONER::ConnectZone::getLocalDomainNumber() const return _local_domain_number; } -ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getLocalMesh() const +MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getLocalMesh() const { return _local_mesh; } -ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getDistantMesh() const +MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getDistantMesh() const { return _distant_mesh; } bool MEDPARTITIONER::ConnectZone::isEntityCorrespPresent(int localEntity, int distantEntity) const { - typedef std::map, SkyLineArray*>::const_iterator map_iter; + typedef std::map, MEDCouplingSkyLineArray*>::const_iterator map_iter; for(map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++) { if ((iter->first).first==localEntity && (iter->first).second==distantEntity) @@ -100,7 +106,7 @@ const int *MEDPARTITIONER::ConnectZone::getNodeCorrespIndex() const const int *MEDPARTITIONER::ConnectZone::getNodeCorrespValue() const { - return _node_corresp->getValue(); + return _node_corresp->getValues(); } int MEDPARTITIONER::ConnectZone::getNodeNumber() const @@ -108,6 +114,11 @@ int MEDPARTITIONER::ConnectZone::getNodeNumber() const return _node_corresp->getNumberOf(); } +const MEDCouplingSkyLineArray * MEDPARTITIONER::ConnectZone::getNodeCorresp() const +{ + return (const MEDCouplingSkyLineArray *)_node_corresp; +} + const int *MEDPARTITIONER::ConnectZone::getFaceCorrespIndex() const { return _face_corresp->getIndex(); @@ -115,7 +126,7 @@ const int *MEDPARTITIONER::ConnectZone::getFaceCorrespIndex() const const int *MEDPARTITIONER::ConnectZone::getFaceCorrespValue() const { - return _face_corresp->getValue(); + return _face_corresp->getValues(); } int MEDPARTITIONER::ConnectZone::getFaceNumber() const @@ -123,56 +134,88 @@ int MEDPARTITIONER::ConnectZone::getFaceNumber() const return _face_corresp->getNumberOf(); } +const MEDCouplingSkyLineArray * MEDPARTITIONER::ConnectZone::getFaceCorresp() const +{ + return _face_corresp; +} + const int *MEDPARTITIONER::ConnectZone::getEntityCorrespIndex(int localEntity, - int distantEntity) const + int distantEntity) const { - typedef std::map, SkyLineArray*>::const_iterator map_iter; + typedef std::map, MEDCouplingSkyLineArray*>::const_iterator map_iter; for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++) - { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getIndex(); - } + { + if ((iter->first).first==localEntity && (iter->first).second==distantEntity) + return iter->second->getIndex(); + } return 0; } const int *MEDPARTITIONER::ConnectZone::getEntityCorrespValue(int localEntity, - int distantEntity) const + int distantEntity) const { - typedef std::map, SkyLineArray*>::const_iterator map_iter; + typedef std::map, MEDCouplingSkyLineArray*>::const_iterator map_iter; for (map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++) - { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getValue(); - } + { + if ((iter->first).first==localEntity && (iter->first).second==distantEntity) + return iter->second->getValues(); + } return 0; } int MEDPARTITIONER::ConnectZone::getEntityCorrespNumber(int localEntity, - int distantEntity) const + int distantEntity) const { - typedef std::map, SkyLineArray*>::const_iterator map_iter; + typedef std::map, MEDCouplingSkyLineArray*>::const_iterator map_iter; for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++) - { - if((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getNumberOf(); - } + { + if((iter->first).first==localEntity && (iter->first).second==distantEntity) + return iter->second->getNumberOf(); + } return 0; } int MEDPARTITIONER::ConnectZone::getEntityCorrespLength(int localEntity, - int distantEntity) const + int distantEntity) const +{ + typedef std::map, MEDCouplingSkyLineArray*>::const_iterator map_iter; + + for (map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++) + { + if ((iter->first).first==localEntity && (iter->first).second==distantEntity) + return iter->second->getLength(); + } + return 0; +} + +const MEDCouplingSkyLineArray * +MEDPARTITIONER::ConnectZone::getEntityCorresp(int localEntity, int distantEntity) const { - typedef std::map, SkyLineArray*>::const_iterator map_iter; - + typedef std::map, MEDCouplingSkyLineArray*>::const_iterator map_iter; + for (map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++) + { + if ((iter->first).first==localEntity && (iter->first).second==distantEntity) + return iter->second; + } + return 0; +} + +std::vector< std::pair< int,int > > MEDPARTITIONER::ConnectZone::getEntities() const +{ + std::vector< std::pair< int,int > > types; + + std::map, MEDCouplingSkyLineArray*>::const_iterator + iter = _entity_corresp.begin(); + for ( ; iter != _entity_corresp.end(); iter++) { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getLength(); + types.push_back( iter->first ); } - return 0; + + return types; } void MEDPARTITIONER::ConnectZone::setName(const std::string& name) @@ -195,45 +238,56 @@ void MEDPARTITIONER::ConnectZone::setLocalDomainNumber(int localDomainNumber) _local_domain_number=localDomainNumber; } -void MEDPARTITIONER::ConnectZone::setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh) +void MEDPARTITIONER::ConnectZone::setLocalMesh(MEDCouplingUMesh * localMesh) { _local_mesh=localMesh; } -void MEDPARTITIONER::ConnectZone::setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh) +void MEDPARTITIONER::ConnectZone::setDistantMesh(MEDCouplingUMesh * distantMesh) { _distant_mesh=distantMesh; } /*! transforms an int array containing * the node-node connections - * to a SkyLineArray + * to a MEDCouplingSkyLineArray */ -void MEDPARTITIONER::ConnectZone::setNodeCorresp(int * nodeCorresp, int nbnode) +void MEDPARTITIONER::ConnectZone::setNodeCorresp(const int * nodeCorresp, int nbnode) { - std::vector index(nbnode+1),value(2*nbnode); + MCAuto indexArr( DataArrayInt::New() ); + MCAuto valueArr( DataArrayInt::New() ); + indexArr->alloc( nbnode+1 ); + valueArr->alloc( 2*nbnode ); + int * index = indexArr->getPointer(); + int * value = valueArr->getPointer(); for (int i=0; i arr(array); + _node_corresp = arr; } /*! transforms an int array containing * the face-face connections - * to a SkyLineArray + * to a MEDCouplingSkyLineArray */ -void MEDPARTITIONER::ConnectZone::setFaceCorresp(int * faceCorresp, int nbface) +void MEDPARTITIONER::ConnectZone::setFaceCorresp(const int * faceCorresp, int nbface) { - std::vector index(nbface+1),value(2*nbface); + MCAuto indexArr( DataArrayInt::New() ); + MCAuto valueArr( DataArrayInt::New() ); + indexArr->alloc( nbface+1 ); + valueArr->alloc( 2*nbface ); + int * index = indexArr->getPointer(); + int * value = valueArr->getPointer(); for (int i=0; i arr (array); + _face_corresp = arr; } /*! transforms an int array containing * the entity-entity connections - * to a SkyLineArray + * to a MEDCouplingSkyLineArray * - * the resulting SkyLineArray is put in the map + * the resulting MEDCouplingSkyLineArray is put in the map */ void MEDPARTITIONER::ConnectZone::setEntityCorresp(int localEntity, int distantEntity, - int *entityCorresp, int nbentity) + const int *entityCorresp, int nbentity) { - std::vector index(nbentity+1),value(2*nbentity); + MCAuto indexArr( DataArrayInt::New() ); + MCAuto valueArr( DataArrayInt::New() ); + indexArr->alloc( nbentity+1 ); + valueArr->alloc( 2*nbentity ); + int * index = indexArr->getPointer(); + int * value = valueArr->getPointer(); for (int i=0; i, MEDCouplingSkyLineArray * >::iterator it; + it = _entity_corresp.insert + ( std::make_pair( std::make_pair(localEntity,distantEntity), nullArray )).first; + if ( it->second != nullArray ) it->second->decrRef(); + it->second = array; } - - - - - - -