-// Copyright (C) 2007-2013 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
// 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
#include "MEDPARTITIONER_ConnectZone.hxx"
+#include "MEDCouplingSkyLineArray.hxx"
+
#include <map>
+using namespace MEDCoupling;
+
MEDPARTITIONER::ConnectZone::ConnectZone():
_name("")
,_description("")
{
delete _node_corresp;
delete _face_corresp;
- for(std::map < std::pair <int, int>,SkyLineArray * >::iterator iter=_entity_corresp.begin(); iter!=_entity_corresp.end();iter++)
+ for(std::map < std::pair <int, int>,MEDCouplingSkyLineArray * >::iterator iter=_entity_corresp.begin(); iter!=_entity_corresp.end();iter++)
{
delete iter->second;
}
return _local_domain_number;
}
-ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getLocalMesh() const
+MEDCoupling::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getLocalMesh() const
{
return _local_mesh;
}
-ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getDistantMesh() const
+MEDCoupling::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getDistantMesh() const
{
return _distant_mesh;
}
bool MEDPARTITIONER::ConnectZone::isEntityCorrespPresent(int localEntity, int distantEntity) const
{
- typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
+ typedef std::map<std::pair<int,int>, 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 _node_corresp->getNumberOf();
}
+const MEDCoupling::MEDCouplingSkyLineArray * MEDPARTITIONER::ConnectZone::getNodeCorresp() const
+{
+ return _node_corresp;
+}
+
const int *MEDPARTITIONER::ConnectZone::getFaceCorrespIndex() const
{
return _face_corresp->getIndex();
return _face_corresp->getNumberOf();
}
+const MEDCoupling::MEDCouplingSkyLineArray * MEDPARTITIONER::ConnectZone::getFaceCorresp() const
+{
+ return _face_corresp;
+}
+
const int *MEDPARTITIONER::ConnectZone::getEntityCorrespIndex(int localEntity,
- int distantEntity) const
+ int distantEntity) const
{
- typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
+ typedef std::map<std::pair<int,int>, 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<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
+ typedef std::map<std::pair<int,int>, 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->getValue();
+ }
return 0;
}
int MEDPARTITIONER::ConnectZone::getEntityCorrespNumber(int localEntity,
- int distantEntity) const
+ int distantEntity) const
{
- typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
+ typedef std::map<std::pair<int,int>, 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<std::pair<int,int>, 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 MEDCoupling::MEDCouplingSkyLineArray *
+MEDPARTITIONER::ConnectZone::getEntityCorresp(int localEntity, int distantEntity) const
{
- typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
-
+ typedef std::map<std::pair<int,int>, 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<std::pair<int,int>, 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)
_local_domain_number=localDomainNumber;
}
-void MEDPARTITIONER::ConnectZone::setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh)
+void MEDPARTITIONER::ConnectZone::setLocalMesh(MEDCoupling::MEDCouplingUMesh * localMesh)
{
_local_mesh=localMesh;
}
-void MEDPARTITIONER::ConnectZone::setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh)
+void MEDPARTITIONER::ConnectZone::setDistantMesh(MEDCoupling::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<int> index(nbnode+1),value(2*nbnode);
+ MCAuto<DataArrayInt> indexArr( DataArrayInt::New() );
+ MCAuto<DataArrayInt> valueArr( DataArrayInt::New() );
+ indexArr->alloc( nbnode+1 );
+ valueArr->alloc( 2*nbnode );
+ int * index = indexArr->getPointer();
+ int * value = valueArr->getPointer();
for (int i=0; i<nbnode; i++)
{
index[i]=2*i;
- value[2*i]=nodeCorresp[2*i];
+ value[2*i ]=nodeCorresp[2*i];
value[2*i+1]=nodeCorresp[2*i+1];
}
index[nbnode]=2*nbnode;
- _node_corresp = new SkyLineArray(index,value);
+ setNodeCorresp( new MEDCouplingSkyLineArray( indexArr, valueArr ));
}
-void MEDPARTITIONER::ConnectZone::setNodeCorresp(SkyLineArray* array)
+void MEDPARTITIONER::ConnectZone::setNodeCorresp(MEDCouplingSkyLineArray* array)
{
+ if ( _node_corresp ) delete _node_corresp;
_node_corresp = array;
}
/*! 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<int> index(nbface+1),value(2*nbface);
+ MCAuto<DataArrayInt> indexArr( DataArrayInt::New() );
+ MCAuto<DataArrayInt> valueArr( DataArrayInt::New() );
+ indexArr->alloc( nbface+1 );
+ valueArr->alloc( 2*nbface );
+ int * index = indexArr->getPointer();
+ int * value = valueArr->getPointer();
for (int i=0; i<nbface; i++)
{
index[i]=2*i;
value[2*i+1]=faceCorresp[2*i+1];
}
index[nbface]=2*nbface;
- _face_corresp = new MEDPARTITIONER::SkyLineArray(index,value);
+ setFaceCorresp( new MEDCouplingSkyLineArray( indexArr, valueArr ));
}
-void MEDPARTITIONER::ConnectZone::setFaceCorresp(SkyLineArray* array)
+void MEDPARTITIONER::ConnectZone::setFaceCorresp(MEDCouplingSkyLineArray* array)
{
+ if ( _face_corresp ) delete _face_corresp;
_face_corresp = array;
}
/*! 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<int> index(nbentity+1),value(2*nbentity);
+ MCAuto<DataArrayInt> indexArr( DataArrayInt::New() );
+ MCAuto<DataArrayInt> valueArr( DataArrayInt::New() );
+ indexArr->alloc( nbentity+1 );
+ valueArr->alloc( 2*nbentity );
+ int * index = indexArr->getPointer();
+ int * value = valueArr->getPointer();
for (int i=0; i<nbentity; i++)
{
index[i]=2*i;
- value[2*i]=entityCorresp[2*i];
+ value[2*i ]=entityCorresp[2*i];
value[2*i+1]=entityCorresp[2*i+1];
}
index[nbentity]=2*nbentity;
- _entity_corresp[std::make_pair(localEntity,distantEntity)] = new SkyLineArray(index,value);
+ setEntityCorresp( localEntity, distantEntity, new MEDCouplingSkyLineArray(indexArr,valueArr));
}
void MEDPARTITIONER::ConnectZone::setEntityCorresp(int localEntity, int distantEntity,
- SkyLineArray *array)
+ MEDCouplingSkyLineArray *array)
{
- _entity_corresp[std::make_pair(localEntity,distantEntity)]=array;
+ MEDCoupling::MEDCouplingSkyLineArray * nullArray = 0;
+ std::map < std::pair <int,int>, MEDCoupling::MEDCouplingSkyLineArray * >::iterator it;
+ it = _entity_corresp.insert
+ ( std::make_pair( std::make_pair(localEntity,distantEntity), nullArray )).first;
+ if ( it->second != nullArray ) delete it->second;
+ it->second = array;
}
-
-
-
-
-
-
-