-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : MEDPARTITIONER.hxx
-// Author : Alexander A. BORODIN
-// Module : MED
-// Exporting/Importing defines for Windows Platform
-//
-#ifndef MEDPARTITIONER_HXX_
-#define MEDPARTITIONER_HXX_
+#ifndef __MEDPARTITIONER_HXX__
+#define __MEDPARTITIONER_HXX__
#ifdef WNT
# if defined MEDPARTITIONER_EXPORTS || defined medsplitter_EXPORTS
# define MEDPARTITIONER_EXPORT
#endif
-#endif //MEDPARTITIONER_HXX_
+#endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// few Med Memory include files
-#include "MEDCouplingUMesh.hxx"
-#include "MEDPARTITIONER_SkyLineArray.hxx"
#include "MEDPARTITIONER_ConnectZone.hxx"
-// few STL include files
#include <map>
using namespace MEDPARTITIONER;
-CONNECTZONE::CONNECTZONE():
+ConnectZone::ConnectZone():
_name("")
,_description("")
,_distantDomainNumber(0)
_entityCorresp.clear();
}
-CONNECTZONE::~CONNECTZONE(){
+ConnectZone::~ConnectZone(){
if (_nodeCorresp !=0) delete _nodeCorresp;
if (_faceCorresp !=0) delete _faceCorresp;
- for (std::map < std::pair <int, int>,MEDPARTITIONER::MEDSKYLINEARRAY * >::iterator
+ for (std::map < std::pair <int, int>,MEDPARTITIONER::SkyLineArray * >::iterator
iter = _entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
{
delete iter->second;
}
}
-CONNECTZONE::CONNECTZONE(const CONNECTZONE & myConnectZone):
+ConnectZone::ConnectZone(const ConnectZone & myConnectZone):
_name(myConnectZone._name)
,_description(myConnectZone._description)
,_distantDomainNumber(myConnectZone._distantDomainNumber)
,_entityCorresp(myConnectZone._entityCorresp)
{
}
-std::string CONNECTZONE::getName() const
+
+std::string ConnectZone::getName() const
{
return _name;
}
-std::string CONNECTZONE::getDescription() const
+
+std::string ConnectZone::getDescription() const
{
return _description;
}
-int CONNECTZONE::getDistantDomainNumber() const
+
+int ConnectZone::getDistantDomainNumber() const
{
return _distantDomainNumber;
}
-int CONNECTZONE::getLocalDomainNumber() const
+
+int ConnectZone::getLocalDomainNumber() const
{
return _localDomainNumber;
}
-ParaMEDMEM::MEDCouplingUMesh* CONNECTZONE::getLocalMesh() const
+ParaMEDMEM::MEDCouplingUMesh* ConnectZone::getLocalMesh() const
{
return _localMesh;
}
-ParaMEDMEM::MEDCouplingUMesh * CONNECTZONE::getDistantMesh() const
+ParaMEDMEM::MEDCouplingUMesh * ConnectZone::getDistantMesh() const
{
return _distantMesh;
}
-bool CONNECTZONE::isEntityCorrespPresent(int localEntity,
+bool ConnectZone::isEntityCorrespPresent(int localEntity,
int distantEntity) const
{
- typedef std::map<std::pair<int,int>, MEDPARTITIONER::MEDSKYLINEARRAY*>::const_iterator map_iter;
-
+ typedef std::map<std::pair<int,int>, MEDPARTITIONER::SkyLineArray*>::const_iterator map_iter;
+
for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
{
if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
return true;
}
return false;
-}
+}
-const int * CONNECTZONE::getNodeCorrespIndex() const
+const int * ConnectZone::getNodeCorrespIndex() const
{
return _nodeCorresp->getIndex();
}
-const int * CONNECTZONE::getNodeCorrespValue() const
+const int * ConnectZone::getNodeCorrespValue() const
{
return _nodeCorresp->getValue();
}
-int CONNECTZONE::getNodeNumber() const
+
+int ConnectZone::getNodeNumber() const
{
return _nodeCorresp->getNumberOf();
}
-const int * CONNECTZONE::getFaceCorrespIndex() const
+
+const int * ConnectZone::getFaceCorrespIndex() const
{
return _faceCorresp->getIndex();
}
-const int * CONNECTZONE::getFaceCorrespValue() const
+const int * ConnectZone::getFaceCorrespValue() const
{
return _faceCorresp->getValue();
}
-int CONNECTZONE::getFaceNumber() const
+
+int ConnectZone::getFaceNumber() const
{
return _faceCorresp->getNumberOf();
}
-const int * CONNECTZONE::getEntityCorrespIndex(int localEntity,
+
+const int * ConnectZone::getEntityCorrespIndex(int localEntity,
int distantEntity) const
{
- typedef std::map<std::pair<int,int>, MEDPARTITIONER::MEDSKYLINEARRAY*>::const_iterator map_iter;
-
+ typedef std::map<std::pair<int,int>, MEDPARTITIONER::SkyLineArray*>::const_iterator map_iter;
+
for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
{
if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
return iter->second->getIndex();
}
- return 0;
+ return 0;
}
-const int * CONNECTZONE::getEntityCorrespValue(int localEntity,
+const int * ConnectZone::getEntityCorrespValue(int localEntity,
int distantEntity) const
{
- typedef std::map<std::pair<int,int>, MEDPARTITIONER::MEDSKYLINEARRAY*>::const_iterator map_iter;
-
+ typedef std::map<std::pair<int,int>, MEDPARTITIONER::SkyLineArray*>::const_iterator map_iter;
+
for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
{
if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
return iter->second->getValue();
}
- return 0;
+ return 0;
}
-int CONNECTZONE::getEntityCorrespNumber(int localEntity,
+int ConnectZone::getEntityCorrespNumber(int localEntity,
int distantEntity) const
{
- typedef std::map<std::pair<int,int>, MEDPARTITIONER::MEDSKYLINEARRAY*>::const_iterator map_iter;
-
+ typedef std::map<std::pair<int,int>, MEDPARTITIONER::SkyLineArray*>::const_iterator map_iter;
+
for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
{
if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
return iter->second->getNumberOf();
}
- return 0;
+ return 0;
}
-
-int CONNECTZONE::getEntityCorrespLength(int localEntity,
+int ConnectZone::getEntityCorrespLength(int localEntity,
int distantEntity) const
{
- typedef std::map<std::pair<int,int>, MEDPARTITIONER::MEDSKYLINEARRAY*>::const_iterator map_iter;
+ typedef std::map<std::pair<int,int>, MEDPARTITIONER::SkyLineArray*>::const_iterator map_iter;
for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
{
if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
return iter->second->getLength();
}
- return 0;
+ return 0;
}
-void CONNECTZONE::setName(std::string name)
+void ConnectZone::setName(std::string name)
{
_name=name;
}
-void CONNECTZONE::setDescription(std::string description)
+
+void ConnectZone::setDescription(std::string description)
{
_description=description;
}
-void CONNECTZONE::setDistantDomainNumber(int distantDomainNumber)
+
+void ConnectZone::setDistantDomainNumber(int distantDomainNumber)
{
_distantDomainNumber=distantDomainNumber;
}
-void CONNECTZONE::setLocalDomainNumber(int localDomainNumber)
+
+void ConnectZone::setLocalDomainNumber(int localDomainNumber)
{
_localDomainNumber=localDomainNumber;
}
-void CONNECTZONE::setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh)
+
+void ConnectZone::setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh)
{
_localMesh=localMesh;
}
-void CONNECTZONE::setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh)
+void ConnectZone::setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh)
{
_distantMesh=distantMesh;
}
/*! transforms an int array containing
* the node-node connections
- * to a MEDSKYLINEARRAY
+ * to a SkyLineArray
*/
-void CONNECTZONE::setNodeCorresp(int * nodeCorresp, int nbnode)
+void ConnectZone::setNodeCorresp(int * nodeCorresp, int nbnode)
{
std::vector<int> index(nbnode+1),value(2*nbnode);
for (int i=0; i<nbnode; i++)
value[2*i+1]=nodeCorresp[2*i+1];
}
index[nbnode]=2*nbnode;
- _nodeCorresp = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
+ _nodeCorresp = new MEDPARTITIONER::SkyLineArray(index,value);
}
-void CONNECTZONE::setNodeCorresp(MEDPARTITIONER::MEDSKYLINEARRAY* array)
+void ConnectZone::setNodeCorresp(MEDPARTITIONER::SkyLineArray* array)
{
_nodeCorresp = array;
}
+
/*! transforms an int array containing
* the face-face connections
- * to a MEDSKYLINEARRAY
+ * to a SkyLineArray
*/
-void CONNECTZONE::setFaceCorresp(int * faceCorresp, int nbface)
+void ConnectZone::setFaceCorresp(int * faceCorresp, int nbface)
{
std::vector<int> index(nbface+1),value(2*nbface);
for (int i=0; i<nbface; i++)
value[2*i+1]=faceCorresp[2*i+1];
}
index[nbface]=2*nbface;
- _faceCorresp = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
+ _faceCorresp = new MEDPARTITIONER::SkyLineArray(index,value);
}
-void CONNECTZONE::setFaceCorresp(MEDPARTITIONER::MEDSKYLINEARRAY* array)
+void ConnectZone::setFaceCorresp(MEDPARTITIONER::SkyLineArray* array)
{
_faceCorresp = array;
}
/*! transforms an int array containing
* the entity-entity connections
- * to a MEDSKYLINEARRAY
+ * to a SkyLineArray
*
- * the resulting MEDSKYLINEARRAY is put in the map
+ * the resulting SkyLineArray is put in the map
*/
-void CONNECTZONE::setEntityCorresp(int localEntity,
+void ConnectZone::setEntityCorresp(int localEntity,
int distantEntity,
int * entityCorresp, int nbentity)
{
value[2*i+1]=entityCorresp[2*i+1];
}
index[nbentity]=2*nbentity;
- _entityCorresp[std::make_pair(localEntity,distantEntity)] = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
+ _entityCorresp[std::make_pair(localEntity,distantEntity)] = new MEDPARTITIONER::SkyLineArray(index,value);
}
-
-void CONNECTZONE::setEntityCorresp(int localEntity,
+void ConnectZone::setEntityCorresp(int localEntity,
int distantEntity,
- MEDPARTITIONER::MEDSKYLINEARRAY* array)
+ MEDPARTITIONER::SkyLineArray* array)
{
_entityCorresp[std::make_pair(localEntity,distantEntity)]=array;
}
-
+
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File: MEDMEM_ConnectZone.hxx Author: Nadir Bouhamou (CEA Saclay)
-//
-# ifndef __MEDPARTITIONER_CONNECTZONE_HXX__
-# define __MEDPARTITIONER_CONNECTZONE_HXX__
+#ifndef __MEDPARTITIONER_CONNECTZONE_HXX__
+#define __MEDPARTITIONER_CONNECTZONE_HXX__
#include "MEDPARTITIONER.hxx"
+#include "MEDCouplingUMesh.hxx"
#include "MEDPARTITIONER_SkyLineArray.hxx"
-// few STL include files
#include <map>
#include <string>
-namespace MEDPARTITIONER {
-class MEDPARTITIONER_EXPORT CONNECTZONE
+namespace MEDPARTITIONER
{
-private :
- std::string _name;
- std::string _description;
- int _localDomainNumber;
- int _distantDomainNumber;
+ class MEDPARTITIONER_EXPORT ConnectZone
+ {
+ private :
+ std::string _name;
+ std::string _description;
+ int _localDomainNumber;
+ int _distantDomainNumber;
- ParaMEDMEM::MEDCouplingUMesh * _localMesh;
- ParaMEDMEM::MEDCouplingUMesh * _distantMesh;
+ ParaMEDMEM::MEDCouplingUMesh * _localMesh;
+ ParaMEDMEM::MEDCouplingUMesh * _distantMesh;
- MEDPARTITIONER::MEDSKYLINEARRAY * _nodeCorresp;
- MEDPARTITIONER::MEDSKYLINEARRAY * _faceCorresp;
+ MEDPARTITIONER::SkyLineArray * _nodeCorresp;
+ MEDPARTITIONER::SkyLineArray * _faceCorresp;
- std::map < std::pair <int,int>, MEDPARTITIONER::MEDSKYLINEARRAY * > _entityCorresp;
+ std::map < std::pair <int,int>, MEDPARTITIONER::SkyLineArray * > _entityCorresp;
-public :
- CONNECTZONE();
- ~CONNECTZONE();
- CONNECTZONE(const CONNECTZONE & myConnectZone);
+ public :
+ ConnectZone();
+ ~ConnectZone();
+ ConnectZone(const ConnectZone & myConnectZone);
- std::string getName() const ;
- std::string getDescription() const ;
- int getDistantDomainNumber() const ;
- int getLocalDomainNumber() const ;
- ParaMEDMEM::MEDCouplingUMesh * getLocalMesh() const ;
- ParaMEDMEM::MEDCouplingUMesh * getDistantMesh() const ;
+ std::string getName() const ;
+ std::string getDescription() const ;
+ int getDistantDomainNumber() const ;
+ int getLocalDomainNumber() const ;
+ ParaMEDMEM::MEDCouplingUMesh * getLocalMesh() const ;
+ ParaMEDMEM::MEDCouplingUMesh * getDistantMesh() const ;
- bool isEntityCorrespPresent(int localEntity,int distantEntity) const;
- const int * getNodeCorrespIndex() const;
- const int * getNodeCorrespValue() const;
- int getNodeNumber() const;
- const int * getFaceCorrespIndex() const;
- const int * getFaceCorrespValue() const;
- int getFaceNumber() const;
- const int * getEntityCorrespIndex(int localEntity,
- int distantEntity) const;
- const int * getEntityCorrespValue(int localEntity,
- int distantEntity) const;
- int getEntityCorrespNumber(int localEntity,
- int distantEntity) const;
- int getEntityCorrespLength(int localEntity,
- int distantEntity) const;
- void setName(std::string name) ;
- void setDescription(std::string description) ;
- void setDistantDomainNumber(int distantDomainNumber) ;
- void setLocalDomainNumber(int distantDomainNumber) ;
- void setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh) ;
- void setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh) ;
+ bool isEntityCorrespPresent(int localEntity,int distantEntity) const;
+ const int * getNodeCorrespIndex() const;
+ const int * getNodeCorrespValue() const;
+ int getNodeNumber() const;
+ const int * getFaceCorrespIndex() const;
+ const int * getFaceCorrespValue() const;
+ int getFaceNumber() const;
+ const int * getEntityCorrespIndex(int localEntity,
+ int distantEntity) const;
+ const int * getEntityCorrespValue(int localEntity,
+ int distantEntity) const;
+ int getEntityCorrespNumber(int localEntity,
+ int distantEntity) const;
+ int getEntityCorrespLength(int localEntity,
+ int distantEntity) const;
+ void setName(std::string name) ;
+ void setDescription(std::string description) ;
+ void setDistantDomainNumber(int distantDomainNumber) ;
+ void setLocalDomainNumber(int distantDomainNumber) ;
+ void setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh) ;
+ void setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh) ;
- void setNodeCorresp(int * nodeCorresp, int nbnode);
- void setNodeCorresp(MEDPARTITIONER::MEDSKYLINEARRAY* array);
- void setFaceCorresp(int * faceCorresp, int nbface);
- void setFaceCorresp(MEDPARTITIONER::MEDSKYLINEARRAY* array);
- void setEntityCorresp(int localEntity,
- int distantEntity,
- int * entityCorresp, int nbentity);
- void setEntityCorresp(int localEntity,
- int distantEntity,
- MEDPARTITIONER::MEDSKYLINEARRAY* array);
-};
+ void setNodeCorresp(int * nodeCorresp, int nbnode);
+ void setNodeCorresp(MEDPARTITIONER::SkyLineArray* array);
+ void setFaceCorresp(int * faceCorresp, int nbface);
+ void setFaceCorresp(MEDPARTITIONER::SkyLineArray* array);
+ void setEntityCorresp(int localEntity,
+ int distantEntity,
+ int * entityCorresp, int nbentity);
+ void setEntityCorresp(int localEntity,
+ int distantEntity,
+ MEDPARTITIONER::SkyLineArray* array);
+ };
}
# endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDPARTITIONER_Graph.hxx"
using namespace MEDPARTITIONER;
-Graph::Graph(MEDPARTITIONER::MEDSKYLINEARRAY* array, int* edgeweight):_graph(array),_partition(0),_edgeweight(edgeweight),_cellweight(0)
+Graph::Graph(MEDPARTITIONER::SkyLineArray* array, int* edgeweight):_graph(array),_partition(0),_edgeweight(edgeweight),_cellweight(0)
{
}
Graph::~Graph()
{
if (_partition)
- {
- delete _partition;
- _partition=0;
- }
+ {
+ delete _partition;
+ _partition=0;
+ }
if (_graph)
- {
- delete _graph;
- _graph=0;
- }
+ {
+ delete _graph;
+ _graph=0;
+ }
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef MEDPARTITIONER_GRAPH_HXX_
-#define MEDPARTITIONER_GRAPH_HXX_
+#ifndef __MEDPARTITIONER_GRAPH_HXX__
+#define __MEDPARTITIONER_GRAPH_HXX__
#include "MEDPARTITIONER.hxx"
#include "MEDPARTITIONER_SkyLineArray.hxx"
+
#include <string>
-namespace MEDPARTITIONER {
-
-class ParaDomainSelector;
-class MEDPARTITIONER_EXPORT Graph
+
+namespace MEDPARTITIONER
{
+ class ParaDomainSelector;
+ class MEDPARTITIONER_EXPORT Graph
+ {
public:
typedef enum {METIS,SCOTCH} splitter_type;
- Graph(){};
-
+ Graph()
+ {
+ }
//creates a graph from a SKYLINEARRAY
- Graph(MEDPARTITIONER::MEDSKYLINEARRAY* graph, int* edgeweight=0);
-
+ Graph(MEDPARTITIONER::SkyLineArray* graph, int* edgeweight=0);
virtual ~Graph();
void setEdgesWeights(int* edgeweight){_edgeweight=edgeweight;}
void setVerticesWeights(int* cellweight){_cellweight=cellweight;}
-
+
//computes partitioning of the graph
- virtual void partGraph(int ndomain, const std::string&, ParaDomainSelector* sel=0)=0;
-
- //! returns the partitioning
+ virtual void partGraph(int ndomain, const std::string&, ParaDomainSelector* sel=0) = 0;
+
+ //returns the partitioning
const int* getPart() const {return _partition->getValue();}
-
- //! returns the number of graph vertices (which can correspond to the cells in the mesh!)
+
+ //returns the number of graph vertices (which can correspond to the cells in the mesh!)
int nbVertices() const {return _graph->getNumberOf();}
-
- const MEDPARTITIONER::MEDSKYLINEARRAY* getGraph() const {return _graph;}
+
+ const MEDPARTITIONER::SkyLineArray* getGraph() const {return _graph;}
protected:
-
- MEDPARTITIONER::MEDSKYLINEARRAY* _graph;
-
- MEDPARTITIONER::MEDSKYLINEARRAY* _partition;
-
+ MEDPARTITIONER::SkyLineArray* _graph;
+ MEDPARTITIONER::SkyLineArray* _partition;
int* _edgeweight;
-
int* _cellweight;
};
-
}
-#endif /*GRAPH_HXX_*/
+#endif
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// 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 "MEDPARTITIONER_JointFinder.hxx"
-#include "MEDPARTITIONER_MESHCollection.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
#include "MEDPARTITIONER_Topology.hxx"
#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+
#include "MEDCouplingUMesh.hxx"
-#include "MEDPARTITIONER_utils.hxx"
#include "BBTree.txx"
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDPARTITIONER;
/*! Method contributing to the distant cell graph
*/
-using namespace MEDPARTITIONER;
-JointFinder::JointFinder(const MESHCollection& mc):_mesh_collection(mc), _topology(mc.getTopology()),_domain_selector(mc.getParaDomainSelector())
+JointFinder::JointFinder(const MeshCollection& mc):_mesh_collection(mc), _topology(mc.getTopology()),_domain_selector(mc.getParaDomainSelector())
{
}
JointFinder::~JointFinder()
{
- //if (MyGlobals::_is0verbose>100) cout<<"TODO ~JointFinder"<<endl;
+ //if (MyGlobals::_Is0verbose>100) cout<<"TODO ~JointFinder"<<endl;
}
void JointFinder::findCommonDistantNodes()
_distant_node_cell.resize(nbdomain);
_node_node.resize(nbdomain);
for (int i=0; i<nbdomain; i++)
- {
- _distant_node_cell[i].resize(nbdomain);
- _node_node[i].resize(nbdomain);
- }
+ {
+ _distant_node_cell[i].resize(nbdomain);
+ _node_node[i].resize(nbdomain);
+ }
int nbproc=_domain_selector->nbProcs();
std::vector<BBTree<3>* > bbtree(nbdomain,(BBTree<3>*) 0);
std::vector<ParaMEDMEM::DataArrayInt*> rev(nbdomain,(DataArrayInt*) 0);
//init rev and revIndx and bbtree for my domain (of me:proc n)
for (int mydomain=0; mydomain<nbdomain; mydomain++)
- {
- if(!_domain_selector->isMyDomain(mydomain)) continue;
- const ParaMEDMEM::MEDCouplingUMesh* myMesh=_mesh_collection.getMesh(mydomain);
- meshDim=myMesh->getMeshDimension();
- spaceDim= myMesh->getSpaceDimension();
- rev[mydomain] = ParaMEDMEM::DataArrayInt::New();
- revIndx[mydomain] = ParaMEDMEM::DataArrayInt::New();
- myMesh->getReverseNodalConnectivity(rev[mydomain],revIndx[mydomain]);
- double* bbx=new double[2*spaceDim*myMesh->getNumberOfNodes()];
- for (int i=0; i<myMesh->getNumberOfNodes()*spaceDim; i++)
{
- const double* coords=myMesh->getCoords()->getConstPointer();
- bbx[2*i]=(coords[i])-1e-12;
- bbx[2*i+1]=bbx[2*i]+2e-12;
+ if(!_domain_selector->isMyDomain(mydomain)) continue;
+ const ParaMEDMEM::MEDCouplingUMesh* myMesh=_mesh_collection.getMesh(mydomain);
+ meshDim=myMesh->getMeshDimension();
+ spaceDim= myMesh->getSpaceDimension();
+ rev[mydomain] = ParaMEDMEM::DataArrayInt::New();
+ revIndx[mydomain] = ParaMEDMEM::DataArrayInt::New();
+ myMesh->getReverseNodalConnectivity(rev[mydomain],revIndx[mydomain]);
+ double* bbx=new double[2*spaceDim*myMesh->getNumberOfNodes()];
+ for (int i=0; i<myMesh->getNumberOfNodes()*spaceDim; i++)
+ {
+ const double* coords=myMesh->getCoords()->getConstPointer();
+ bbx[2*i]=(coords[i])-1e-12;
+ bbx[2*i+1]=bbx[2*i]+2e-12;
+ }
+ bbtree[mydomain]=new BBTree<3> (bbx,0,0,myMesh->getNumberOfNodes(),-1e-12);
+ delete[] bbx;
}
- bbtree[mydomain]=new BBTree<3> (bbx,0,0,myMesh->getNumberOfNodes(),-1e-12);
- delete[] bbx;
- }
//send my domains to other proc an receive other domains from other proc
for (int isource=0; isource<nbdomain; isource++)
- {
- for (int itarget=0; itarget<nbdomain; itarget++)
{
- const ParaMEDMEM::MEDCouplingUMesh* sourceMesh=_mesh_collection.getMesh(isource);
- if (_domain_selector->isMyDomain(isource)&&_domain_selector->isMyDomain(itarget)) continue;
- if (_domain_selector->isMyDomain(isource))
- {
- //preparing data for treatment on target proc
- int targetProc = _domain_selector->getProcessorID(itarget);
+ for (int itarget=0; itarget<nbdomain; itarget++)
+ {
+ const ParaMEDMEM::MEDCouplingUMesh* sourceMesh=_mesh_collection.getMesh(isource);
+ if (_domain_selector->isMyDomain(isource)&&_domain_selector->isMyDomain(itarget)) continue;
+ if (_domain_selector->isMyDomain(isource))
+ {
+ //preparing data for treatment on target proc
+ int targetProc = _domain_selector->getProcessorID(itarget);
- std::vector<double> vec(spaceDim*sourceMesh->getNumberOfNodes());
- //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : numberOfNodes "<<sourceMesh->getNumberOfNodes()<<endl;
- std::copy(sourceMesh->getCoords()->getConstPointer(),sourceMesh->getCoords()->getConstPointer()+sourceMesh->getNumberOfNodes()*spaceDim,&vec[0]);
- sendDoubleVec(vec,targetProc);
+ std::vector<double> vec(spaceDim*sourceMesh->getNumberOfNodes());
+ //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : numberOfNodes "<<sourceMesh->getNumberOfNodes()<<endl;
+ std::copy(sourceMesh->getCoords()->getConstPointer(),sourceMesh->getCoords()->getConstPointer()+sourceMesh->getNumberOfNodes()*spaceDim,&vec[0]);
+ SendDoubleVec(vec,targetProc);
- //retrieving target data for storage in commonDistantNodes array
- std::vector<int> localCorrespondency;
- recvIntVec(localCorrespondency, targetProc);
- //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : nodeCellCorrespondency ";
- for (int i=0; i<localCorrespondency.size()/2; i++)
- {
- _distant_node_cell[isource][itarget].insert(std::make_pair(localCorrespondency[2*i],localCorrespondency[2*i+1]));
- //cvw cout<<" "<<localCorrespondency[2*i]<<"/"<<localCorrespondency[2*i+1];
- }
+ //retrieving target data for storage in commonDistantNodes array
+ std::vector<int> localCorrespondency;
+ RecvIntVec(localCorrespondency, targetProc);
+ //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : nodeCellCorrespondency ";
+ for (int i=0; i<localCorrespondency.size()/2; i++)
+ {
+ _distant_node_cell[isource][itarget].insert(std::make_pair(localCorrespondency[2*i],localCorrespondency[2*i+1]));
+ //cvw cout<<" "<<localCorrespondency[2*i]<<"/"<<localCorrespondency[2*i+1];
+ }
- }
- if (_domain_selector->isMyDomain(itarget))
- {
- //receiving data from source proc
- int sourceProc = isource%nbproc;
- std::vector<double> recvVec;
- recvDoubleVec(recvVec,sourceProc);
- std::map<int,int> commonNodes; // (local nodes, distant nodes) list
- //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : commonNodes ";
- for (int inode=0; inode<(recvVec.size()/meshDim); inode++)
- {
- double* bbox=new double[2*spaceDim];
- for (int i=0; i<spaceDim; i++)
- {
- bbox[2*i]=recvVec[inode*spaceDim+i]-1e-12;
- bbox[2*i+1]=bbox[2*i]+2e-12;
- }
- std::vector<int> inodes;
- bbtree[itarget]->getIntersectingElems(bbox,inodes);
- delete[] bbox;
+ }
+ if (_domain_selector->isMyDomain(itarget))
+ {
+ //receiving data from source proc
+ int sourceProc = isource%nbproc;
+ std::vector<double> recvVec;
+ RecvDoubleVec(recvVec,sourceProc);
+ std::map<int,int> commonNodes; // (local nodes, distant nodes) list
+ //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : commonNodes ";
+ for (int inode=0; inode<(recvVec.size()/meshDim); inode++)
+ {
+ double* bbox=new double[2*spaceDim];
+ for (int i=0; i<spaceDim; i++)
+ {
+ bbox[2*i]=recvVec[inode*spaceDim+i]-1e-12;
+ bbox[2*i+1]=bbox[2*i]+2e-12;
+ }
+ std::vector<int> inodes;
+ bbtree[itarget]->getIntersectingElems(bbox,inodes);
+ delete[] bbox;
- if (inodes.size()>0)
- {
- commonNodes.insert(std::make_pair(inodes[0],inode));
- //cvw cout<<" "<<inodes[0]<<"/"<<inode;
- }
+ if (inodes.size()>0)
+ {
+ commonNodes.insert(std::make_pair(inodes[0],inode));
+ //cvw cout<<" "<<inodes[0]<<"/"<<inode;
+ }
+ }
+ std::vector<int> nodeCellCorrespondency;
+ for (std::map<int,int>::iterator iter=commonNodes.begin(); iter!=commonNodes.end(); iter++)
+ {
+ _node_node[itarget][isource].push_back(std::make_pair(iter->first, iter->second));//storing node pairs in a vector
+ const int* revIndxPtr=revIndx[itarget]->getConstPointer();
+ const int* revPtr=rev[itarget]->getConstPointer();
+ for (int icell=revIndxPtr[iter->first]; icell<revIndxPtr[iter->first+1]; icell++)
+ {
+ nodeCellCorrespondency.push_back(iter->second); //
+ int globalCell=_topology->convertCellToGlobal(itarget,revPtr[icell]);
+ nodeCellCorrespondency.push_back(globalCell);
+ //nodeCellCorrespondency.push_back(revPtr[icell]); //need to set at global numerotation
+ //cout<<"processor "<<MyGlobals::_Rank<<" : isource "<<isource<<" itarget "<<itarget<<
+ // " node "<<iter->second<<" cellLoc "<<revPtr[icell]<<" cellGlob "<<globalCell<<endl;
+ }
+ }
+ //std::cout<<"proc "<<_domain_selector->rank()<<" : JointFinder SendIntVec "<<_domain_selector->rank()<<std::endl; //cvwdebug
+ SendIntVec(nodeCellCorrespondency, sourceProc); //itarget proc send to other (otherLocalNode-itargetGlobalCell)
+ }
}
- std::vector<int> nodeCellCorrespondency;
- for (std::map<int,int>::iterator iter=commonNodes.begin(); iter!=commonNodes.end(); iter++)
- {
- _node_node[itarget][isource].push_back(std::make_pair(iter->first, iter->second));//storing node pairs in a vector
- const int* revIndxPtr=revIndx[itarget]->getConstPointer();
- const int* revPtr=rev[itarget]->getConstPointer();
- for (int icell=revIndxPtr[iter->first]; icell<revIndxPtr[iter->first+1]; icell++)
- {
- nodeCellCorrespondency.push_back(iter->second); //
- int globalCell=_topology->convertCellToGlobal(itarget,revPtr[icell]);
- nodeCellCorrespondency.push_back(globalCell);
- //nodeCellCorrespondency.push_back(revPtr[icell]); //need to set at global numerotation
- //cout<<"processor "<<MyGlobals::_rank<<" : isource "<<isource<<" itarget "<<itarget<<
- // " node "<<iter->second<<" cellLoc "<<revPtr[icell]<<" cellGlob "<<globalCell<<endl;
- }
- }
- //std::cout<<"proc "<<_domain_selector->rank()<<" : JointFinder sendIntVec "<<_domain_selector->rank()<<std::endl; //cvwdebug
- sendIntVec(nodeCellCorrespondency, sourceProc); //itarget proc send to other (otherLocalNode-itargetGlobalCell)
- }
- }
}
- //free rev(nbdomain) revIndx(nbdomain) bbtree(nbdomain)
- for (int i=0; i<nbdomain; i++)
+ //free rev(nbdomain) revIndx(nbdomain) bbtree(nbdomain)
+ for (int i=0; i<nbdomain; i++)
{
if (rev[i]!=0) rev[i]->decrRef();
if (revIndx[i]!=0) revIndx[i]->decrRef();
if (bbtree[i]!=0) delete bbtree[i];
}
- if (MyGlobals::_verbose>100)
- std::cout<<"proc "<<_domain_selector->rank()<<" : end JointFinder::findCommonDistantNodes"<<std::endl;
+ if (MyGlobals::_Verbose>100)
+ std::cout<<"proc "<<_domain_selector->rank()<<" : end JointFinder::findCommonDistantNodes"<<std::endl;
}
std::vector<std::vector<std::multimap<int,int> > > & JointFinder::getDistantNodeCell()
void JointFinder::print()
//it is for debug on small arrays under mpi 2,3 cpus
{
- int nbdomain=_topology->nbDomain();
- //MPI_Barrier(MPI_COMM_WORLD);
- if (MyGlobals::_is0verbose>0)
- cout<<"\nJointFinder print node-node (nn)iproc|itarget|isource|i|inodefirst-inodesecond\n\n"<<
- "JointFinder print distantNode=cell (nc)iproc|itarget|isource|inode=icell\n\n";
- for (int isource=0; isource<nbdomain; isource++)
- {
- for (int itarget=0; itarget<nbdomain; itarget++)
- {
- for (int i=0; i<_node_node[itarget][isource].size(); i++)
- cout<<" nn"<<_domain_selector->rank()<<itarget<<"|"<<isource<<"|"<<i<<"|"<<
- _node_node[itarget][isource][i].first<<"-"<<
- _node_node[itarget][isource][i].second;
- }
- }
- cout<<endl;
- //MPI_Barrier(MPI_COMM_WORLD);
+ int nbdomain=_topology->nbDomain();
+ //MPI_Barrier(MPI_COMM_WORLD);
+ if (MyGlobals::_Is0verbose>0)
+ cout<<"\nJointFinder print node-node (nn)iproc|itarget|isource|i|inodefirst-inodesecond\n\n"<<
+ "JointFinder print distantNode=cell (nc)iproc|itarget|isource|inode=icell\n\n";
+ for (int isource=0; isource<nbdomain; isource++)
+ {
+ for (int itarget=0; itarget<nbdomain; itarget++)
+ {
+ for (int i=0; i<_node_node[itarget][isource].size(); i++)
+ cout<<" nn"<<_domain_selector->rank()<<itarget<<"|"<<isource<<"|"<<i<<"|"<<
+ _node_node[itarget][isource][i].first<<"-"<<
+ _node_node[itarget][isource][i].second;
+ }
+ }
+ cout<<endl;
+ //MPI_Barrier(MPI_COMM_WORLD);
- //cout<<"proc "<<_domain_selector->rank()<<" : JointFinder _distant_node_cell itarget/isource/inode=icell"<<endl;
- for (int isource=0; isource<nbdomain; isource++)
- {
- for (int itarget=0; itarget<nbdomain; itarget++)
- {
- std::multimap<int,int>::iterator it;
- for (it=_distant_node_cell[isource][itarget].begin() ; it!=_distant_node_cell[isource][itarget].end(); it++)
- {
- cout<<" nc"<<_domain_selector->rank()<<"|"<<itarget<<"|"<<isource<<"|"<<(*it).first<<"="<<(*it).second;
- }
- }
- }
- cout<<endl;
- //MPI_Barrier(MPI_COMM_WORLD);
+ //cout<<"proc "<<_domain_selector->rank()<<" : JointFinder _distant_node_cell itarget/isource/inode=icell"<<endl;
+ for (int isource=0; isource<nbdomain; isource++)
+ {
+ for (int itarget=0; itarget<nbdomain; itarget++)
+ {
+ std::multimap<int,int>::iterator it;
+ for (it=_distant_node_cell[isource][itarget].begin() ; it!=_distant_node_cell[isource][itarget].end(); it++)
+ {
+ cout<<" nc"<<_domain_selector->rank()<<"|"<<itarget<<"|"<<isource<<"|"<<(*it).first<<"="<<(*it).second;
+ }
+ }
+ }
+ cout<<endl;
+ //MPI_Barrier(MPI_COMM_WORLD);
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#ifndef __MEDPARTITIONER_JOINTFINDER_HXX__
-#define __MEDPARTITIONER_JOINTFINDER_HXX__
+#define __MEDPARTITIONER_JOINTFINDER_HXX__
-#include <vector>
+#include <vector>
#include <map>
+
namespace MEDPARTITIONER {
- class MESHCollection;
+ class MeshCollection;
class ParaDomainSelector;
class Topology;
-class JointFinder
-{
-public:
- JointFinder(const MESHCollection& mc);
- ~JointFinder();
- void findCommonDistantNodes();
- void print();
- std::vector<std::vector<std::multimap<int,int> > >& getDistantNodeCell();
- std::vector<std::vector<std::vector<std::pair<int,int> > > >& getNodeNode();
- std::vector<std::vector<std::multimap<int,int> > > _distant_node_cell;
-private:
- const MESHCollection& _mesh_collection;
- const ParaDomainSelector* _domain_selector;
- const Topology* _topology;
- //std::vector<std::vector<std::multimap<int,int> > > _distant_node_cell;
- std::vector<std::vector<std::vector<std::pair<int,int> > > > _node_node;
-};
-};
+ class JointFinder
+ {
+ public:
+ JointFinder(const MeshCollection& mc);
+ ~JointFinder();
+ void findCommonDistantNodes();
+ void print();
+ std::vector<std::vector<std::multimap<int,int> > >& getDistantNodeCell();
+ std::vector<std::vector<std::vector<std::pair<int,int> > > >& getNodeNode();
+
+ std::vector<std::vector<std::multimap<int,int> > > _distant_node_cell;
+ private:
+ const MeshCollection& _mesh_collection;
+ const ParaDomainSelector* _domain_selector;
+ const Topology* _topology;
+ std::vector<std::vector<std::vector<std::pair<int,int> > > > _node_node;
+ };
+}
#endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : MEDSPLITTER_ParaDomainSelector.cxx
-// Created : Wed Jun 24 12:39:59 2009
-// Author : Edward AGAPOV (eap)
-#include "MEDCouplingUMesh.hxx"
#include "MEDPARTITIONER_ParaDomainSelector.hxx"
#include "MEDPARTITIONER_UserGraph.hxx"
-#include "MEDPARTITIONER_utils.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+
+#include "MEDCouplingUMesh.hxx"
#include <iostream>
#include <numeric>
#include <sys/sysinfo.h>
#endif
-//using namespace MED_EN;
using namespace std;
using namespace MEDPARTITIONER;
-//================================================================================
/*!
* \brief Constructor. Find out my rank and world size
*/
-//================================================================================
-
ParaDomainSelector::ParaDomainSelector(bool mesure_memory)
:_rank(0),_world_size(1), _nb_result_domains(-1), _mesure_memory(mesure_memory),
_init_time(0.0), _init_memory(0), _max_memory(0)
evaluateMemory();
}
-//================================================================================
-/*!
- * \brief Destructor
- */
-//================================================================================
-
ParaDomainSelector::~ParaDomainSelector()
{
}
-//================================================================================
/*!
* \brief Return true if is running on different hosts
*/
-//================================================================================
-
bool ParaDomainSelector::isOnDifferentHosts() const
{
evaluateMemory();
//bug: (isOnDifferentHosts here and there) is not (isOnDifferentHosts somewhere)
//return string(name_here) != string(name_there);
- int sum_same=-1;
- int same=1;
+ int sum_same = -1;
+ int same = 1;
if (string(name_here) != string(name_there)) same=0;
MPI_Allreduce( &same, &sum_same, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
//cout<<"proc "<<rank()<<" : sum_same "<<sum_same<<endl;
#endif
}
-//================================================================================
/*!
* \brief Return true if the domain with domainIndex is to be loaded on this proc
* \param domainIndex - index of mesh domain
* \retval bool - to load or not
*/
-//================================================================================
-
bool ParaDomainSelector::isMyDomain(int domainIndex) const
{
evaluateMemory();
return (_rank == getProcessorID( domainIndex ));
}
-//================================================================================
/*!
* \brief Return processor id where the domain with domainIndex resides
* \param domainIndex - index of mesh domain
* \retval int - processor id
*/
-//================================================================================
-
int ParaDomainSelector::getProcessorID(int domainIndex) const
{
evaluateMemory();
return ( domainIndex % _world_size );
}
-//================================================================================
/*!
* \brief Gather info on nb of cell entities on each processor and return total nb.
*
* 1) for MED_CELL to know global id shift for domains at graph construction;
* 2) for sub-entity to know total nb of sub-entities before creating those of joints
*/
-//================================================================================
-
void ParaDomainSelector::gatherNbOf(const vector<ParaMEDMEM::MEDCouplingUMesh*>& domain_meshes)
{
evaluateMemory();
// get nb of elems of each domain mesh
int nb_domains=domain_meshes.size();
- //cout<<"proc "<<MyGlobals::_rank<<" : gatherNbOf "<<nb_domains<<endl;
+ //cout<<"proc "<<MyGlobals::_Rank<<" : gatherNbOf "<<nb_domains<<endl;
vector<int> nb_elems(nb_domains*2, 0); //NumberOfCells & NumberOfNodes
for (int i=0; i<nb_domains; ++i)
if ( domain_meshes[i] )
- {
- nb_elems[i*2] = domain_meshes[i]->getNumberOfCells();
- nb_elems[i*2+1] = domain_meshes[i]->getNumberOfNodes();
- }
+ {
+ nb_elems[i*2] = domain_meshes[i]->getNumberOfCells();
+ nb_elems[i*2+1] = domain_meshes[i]->getNumberOfNodes();
+ }
// receive nb of elems from other procs
vector<int> all_nb_elems( nb_domains*2 );
#ifdef HAVE_MPI2
#endif
int total_nb_cells=0, total_nb_nodes=0;
for (int i=0; i<nb_domains; ++i)
- {
- total_nb_cells+=all_nb_elems[i*2];
- total_nb_nodes+=all_nb_elems[i*2+1];
- }
+ {
+ total_nb_cells+=all_nb_elems[i*2];
+ total_nb_nodes+=all_nb_elems[i*2+1];
+ }
- if (MyGlobals::_is0verbose>10)
+ if (MyGlobals::_Is0verbose>10)
cout<<"totalNbCells "<<total_nb_cells<<" totalNbNodes "<<total_nb_nodes<<endl;
vector<int>& cell_shift_by_domain=_cell_shift_by_domain;
for (int iproc=0; iproc<nbProcs(); ++iproc)
for (int idomain=0; idomain<nb_domains; ++idomain)
if (getProcessorID( idomain )==iproc)
- {
- domain_order[idomain] = ordered_nbs_cell.size() - 1;
- ordered_nbs_cell.push_back( ordered_nbs_cell.back() + all_nb_elems[idomain*2] );
- ordered_nbs_node.push_back( ordered_nbs_node.back() + all_nb_elems[idomain*2+1] );
- }
+ {
+ domain_order[idomain] = ordered_nbs_cell.size() - 1;
+ ordered_nbs_cell.push_back( ordered_nbs_cell.back() + all_nb_elems[idomain*2] );
+ ordered_nbs_node.push_back( ordered_nbs_node.back() + all_nb_elems[idomain*2+1] );
+ }
cell_shift_by_domain.resize( nb_domains+1, 0 );
node_shift_by_domain.resize( nb_domains+1, 0 );
face_shift_by_domain.resize( nb_domains+1, 0 );
for (int idomain=0; idomain<nb_domains; ++idomain)
- {
- cell_shift_by_domain[ idomain ] = ordered_nbs_cell[ domain_order[ idomain ]];
- node_shift_by_domain[ idomain ] = ordered_nbs_node[ domain_order[ idomain ]];
- }
+ {
+ cell_shift_by_domain[ idomain ] = ordered_nbs_cell[ domain_order[ idomain ]];
+ node_shift_by_domain[ idomain ] = ordered_nbs_node[ domain_order[ idomain ]];
+ }
cell_shift_by_domain.back() = ordered_nbs_cell.back(); // to know total nb of elements
node_shift_by_domain.back() = ordered_nbs_node.back(); // to know total nb of elements
- if (MyGlobals::_is0verbose>300)
- {
- cout<<"proc "<<MyGlobals::_rank<<" : cellShiftByDomain ";
- for (int i=0; i<=nb_domains; ++i) cout<<cell_shift_by_domain[i]<<"|";
- cout<<endl;
- cout<<"proc "<<MyGlobals::_rank<<" : nodeShiftBy_domain ";
- for (int i=0; i<=nb_domains; ++i) cout<<node_shift_by_domain[i]<<"|";
- cout<<endl;
- }
+ if (MyGlobals::_Is0verbose>300)
+ {
+ cout<<"proc "<<MyGlobals::_Rank<<" : cellShiftByDomain ";
+ for (int i=0; i<=nb_domains; ++i) cout<<cell_shift_by_domain[i]<<"|";
+ cout<<endl;
+ cout<<"proc "<<MyGlobals::_Rank<<" : nodeShiftBy_domain ";
+ for (int i=0; i<=nb_domains; ++i) cout<<node_shift_by_domain[i]<<"|";
+ cout<<endl;
+ }
// fill _nb_vert_of_procs (is Vtxdist)
_nb_vert_of_procs.resize(_world_size+1);
_nb_vert_of_procs[0] = 0; // base = 0
for (int i=0; i<nb_domains; ++i)
- {
- int rank = getProcessorID(i);
- _nb_vert_of_procs[rank+1] += all_nb_elems[i*2];
- }
+ {
+ int rank = getProcessorID(i);
+ _nb_vert_of_procs[rank+1] += all_nb_elems[i*2];
+ }
for (int i=1; i<_nb_vert_of_procs.size(); ++i)
_nb_vert_of_procs[i] += _nb_vert_of_procs[i-1]; // to CSR format : cumulated
- if (MyGlobals::_is0verbose>200)
- {
- cout<<"proc "<<MyGlobals::_rank<<" : gatherNbOf : vtxdist is ";
- for (int i = 0; i <= _world_size; ++i) cout<<_nb_vert_of_procs[i]<<" ";
- cout<<endl;
- }
+ if (MyGlobals::_Is0verbose>200)
+ {
+ cout<<"proc "<<MyGlobals::_Rank<<" : gatherNbOf : vtxdist is ";
+ for (int i = 0; i <= _world_size; ++i) cout<<_nb_vert_of_procs[i]<<" ";
+ cout<<endl;
+ }
evaluateMemory();
return;
}
-//================================================================================
/*!
* \brief Return distribution of the graph vertices among the processors
* \retval int* - array containing nb of vertices (=cells) on all processors
* The result array is to be used as the first arg of ParMETIS_V3_PartKway() and
* is freed by ParaDomainSelector.
*/
-//================================================================================
-
int* ParaDomainSelector::getProcVtxdist() const
{
evaluateMemory();
if (_nb_vert_of_procs.empty()) throw INTERP_KERNEL::Exception(LOCALIZED("_nb_vert_of_procs not set"));
return (int*) & _nb_vert_of_procs[0];
}
-//================================================================================
+
/*!
* \brief Return nb of cells in domains with lower index.
*
* gatherNbOf() must be called before.
* Result added to local id on given domain gives id in the whole distributed mesh
*/
-//================================================================================
-
int ParaDomainSelector::getDomainCellShift(int domainIndex) const
{
evaluateMemory();
return _node_shift_by_domain[domainIndex];
}
-//================================================================================
/*!
* \brief Return nb of nodes on processors with lower rank.
*
* gatherNbOf() must be called before.
* Result added to global id on this processor gives id in the whole distributed mesh
*/
-//================================================================================
-
int ParaDomainSelector::getProcNodeShift() const
{
evaluateMemory();
return _nb_vert_of_procs[_rank];
}
-//================================================================================
/*!
* \brief Gather graphs from all processors into one
*/
-//================================================================================
-
auto_ptr<Graph> ParaDomainSelector::gatherGraph(const Graph* graph) const
{
Graph* glob_graph = 0;
// get sizes of graph values on each proc by the got indices of graphs
vector< int > value_size_of_proc( nbProcs() ), proc_value_displacement(1,0);
for ( int i = 0; i < nbProcs(); ++i )
- {
- if ( index_size_of_proc[i] > 0 )
- value_size_of_proc[i] = graph_index[ proc_index_displacement[ i+1 ]-1 ] - graph_index[0];
- else
- value_size_of_proc[i] = 0;
- proc_value_displacement.push_back( proc_value_displacement.back() + value_size_of_proc[i] );
- }
+ {
+ if ( index_size_of_proc[i] > 0 )
+ value_size_of_proc[i] = graph_index[ proc_index_displacement[ i+1 ]-1 ] - graph_index[0];
+ else
+ value_size_of_proc[i] = 0;
+ proc_value_displacement.push_back( proc_value_displacement.back() + value_size_of_proc[i] );
+ }
// update graph_index
for ( int i = 1; i < nbProcs(); ++i )
- {
- int shift = graph_index[ proc_index_displacement[i]-1 ]-graph_index[0];
- for ( int j = proc_index_displacement[i]; j < proc_index_displacement[i+1]; ++j )
- graph_index[ j ] += shift;
- }
+ {
+ int shift = graph_index[ proc_index_displacement[i]-1 ]-graph_index[0];
+ for ( int j = proc_index_displacement[i]; j < proc_index_displacement[i+1]; ++j )
+ graph_index[ j ] += shift;
+ }
// --------------
// Gather values
// Make graph
// -----------
-// MEDPARTITIONER::MEDSKYLINEARRAY* array =
-// new MEDPARTITIONER::MEDSKYLINEARRAY( index_size-1, value_size, graph_index, graph_value, true );
+ // MEDPARTITIONER::SkyLineArray* array =
+ // new MEDPARTITIONER::SkyLineArray( index_size-1, value_size, graph_index, graph_value, true );
-// glob_graph = new UserGraph( array, partition, index_size-1 );
+ // glob_graph = new UserGraph( array, partition, index_size-1 );
evaluateMemory();
}
-//================================================================================
/*!
* \brief Set nb of cell/cell pairs in a joint between domains
*/
-//================================================================================
-
void ParaDomainSelector::setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain )
{
// This method is needed for further computing global numbers of faces in joint.
// Store if both domains are on this proc else on one of procs only
if ( isMyDomain( dist_domain ) || dist_domain < loc_domain )
- {
- if ( _nb_cell_pairs_by_joint.empty() )
- _nb_cell_pairs_by_joint.resize( _nb_result_domains*(_nb_result_domains+1), 0);
+ {
+ if ( _nb_cell_pairs_by_joint.empty() )
+ _nb_cell_pairs_by_joint.resize( _nb_result_domains*(_nb_result_domains+1), 0);
- int joint_id = jointId( loc_domain, dist_domain );
- _nb_cell_pairs_by_joint[ joint_id ] = nb_cell_pairs;
- }
+ int joint_id = jointId( loc_domain, dist_domain );
+ _nb_cell_pairs_by_joint[ joint_id ] = nb_cell_pairs;
+ }
evaluateMemory();
}
#endif
}
-//================================================================================
/*!
* \brief Evaluate current memory usage and return the maximal one in KB
*/
-//================================================================================
-
int ParaDomainSelector::evaluateMemory() const
{
if ( _mesure_memory )
- {
- int used_memory = 0;
+ {
+ int used_memory = 0;
#ifndef WIN32
- struct sysinfo si;
- int err = sysinfo( &si );
- if ( !err )
- used_memory =
- (( si.totalram - si.freeram + si.totalswap - si.freeswap ) * si.mem_unit ) / 1024;
+ struct sysinfo si;
+ int err = sysinfo( &si );
+ if ( !err )
+ used_memory =
+ (( si.totalram - si.freeram + si.totalswap - si.freeswap ) * si.mem_unit ) / 1024;
#endif
- if ( used_memory > _max_memory )
- ((ParaDomainSelector*) this)->_max_memory = used_memory;
+ if ( used_memory > _max_memory )
+ ((ParaDomainSelector*) this)->_max_memory = used_memory;
- if ( !_init_memory )
- ((ParaDomainSelector*) this)->_init_memory = used_memory;
- }
+ if ( !_init_memory )
+ ((ParaDomainSelector*) this)->_init_memory = used_memory;
+ }
return _max_memory - _init_memory;
}
/*!
-Sends content of \a mesh to processor \a target. To be used with \a recvMesh method.
-\param mesh mesh to be sent
-\param target processor id of the target
+ Sends content of \a mesh to processor \a target. To be used with \a recvMesh method.
+ \param mesh mesh to be sent
+ \param target processor id of the target
*/
void ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int target) const
{
- if (MyGlobals::_verbose>600) cout<<"proc "<<_rank<<" : sendMesh '"<<mesh.getName()<<"' size "<<mesh.getNumberOfCells()<<" to "<<target<<endl;
- // First stage : sending sizes
- // ------------------------------
- vector<int> tinyInfoLocal;
- vector<string> tinyInfoLocalS;
- vector<double> tinyInfoLocalD;
- //Getting tiny info of local mesh to allow the distant proc to initialize and allocate
- //the transmitted mesh.
- mesh.getTinySerializationInformation(tinyInfoLocalD,tinyInfoLocal,tinyInfoLocalS);
- //cout<<"sendMesh getTinySerializationInformation "<<mesh.getName()<<endl;
- tinyInfoLocal.push_back(mesh.getNumberOfCells());
- #ifdef HAVE_MPI2
- int tinySize=tinyInfoLocal.size();
- //cout<<"MPI_Send cvw11 "<<tinySize<<endl;
- MPI_Send(&tinySize, 1, MPI_INT, target, 1113, MPI_COMM_WORLD);
- //cout<<"MPI_Send cvw22 "<<tinyInfoLocal.size()<<endl;
- MPI_Send(&tinyInfoLocal[0], tinyInfoLocal.size(), MPI_INT, target, 1112, MPI_COMM_WORLD);
+ if (MyGlobals::_Verbose>600) cout<<"proc "<<_rank<<" : sendMesh '"<<mesh.getName()<<"' size "<<mesh.getNumberOfCells()<<" to "<<target<<endl;
+ // First stage : sending sizes
+ // ------------------------------
+ vector<int> tinyInfoLocal;
+ vector<string> tinyInfoLocalS;
+ vector<double> tinyInfoLocalD;
+ //Getting tiny info of local mesh to allow the distant proc to initialize and allocate
+ //the transmitted mesh.
+ mesh.getTinySerializationInformation(tinyInfoLocalD,tinyInfoLocal,tinyInfoLocalS);
+ //cout<<"sendMesh getTinySerializationInformation "<<mesh.getName()<<endl;
+ tinyInfoLocal.push_back(mesh.getNumberOfCells());
+#ifdef HAVE_MPI2
+ int tinySize=tinyInfoLocal.size();
+ //cout<<"MPI_Send cvw11 "<<tinySize<<endl;
+ MPI_Send(&tinySize, 1, MPI_INT, target, 1113, MPI_COMM_WORLD);
+ //cout<<"MPI_Send cvw22 "<<tinyInfoLocal.size()<<endl;
+ MPI_Send(&tinyInfoLocal[0], tinyInfoLocal.size(), MPI_INT, target, 1112, MPI_COMM_WORLD);
#endif
- if (mesh.getNumberOfCells()>0) //no sends if empty
+ if (mesh.getNumberOfCells()>0) //no sends if empty
{
ParaMEDMEM::DataArrayInt *v1Local=0;
ParaMEDMEM::DataArrayDouble *v2Local=0;
int nbLocalElems=0;
int* ptLocal=0;
if(v1Local) //cvw if empty getNbOfElems() is 1!
- {
- nbLocalElems=v1Local->getNbOfElems(); //cvw if empty be 1!
- ptLocal=v1Local->getPointer();
- }
+ {
+ nbLocalElems=v1Local->getNbOfElems(); //cvw if empty be 1!
+ ptLocal=v1Local->getPointer();
+ }
#ifdef HAVE_MPI2
MPI_Send(ptLocal, nbLocalElems, MPI_INT, target, 1111, MPI_COMM_WORLD);
#endif
int nbLocalElems2=0;
double *ptLocal2=0;
if(v2Local) //cvw if empty be 0!
- {
- nbLocalElems2=v2Local->getNbOfElems();
- ptLocal2=v2Local->getPointer();
- }
+ {
+ nbLocalElems2=v2Local->getNbOfElems();
+ ptLocal2=v2Local->getPointer();
+ }
#ifdef HAVE_MPI2
MPI_Send(ptLocal2, nbLocalElems2, MPI_DOUBLE, target, 1110, MPI_COMM_WORLD);
#endif
if(v1Local) v1Local->decrRef();
if(v2Local) v2Local->decrRef();
}
- else
+ else
{
//cout<<"sendMesh empty Mesh cvw3344 "<<endl;
}
- //cout<<"end sendMesh "<<mesh.getName()<<endl;
+ //cout<<"end sendMesh "<<mesh.getName()<<endl;
}
/*! Receives messages from proc \a source to fill mesh \a mesh.
-To be used with \a sendMesh method.
-\param mesh pointer to mesh that is filled
-\param source processor id of the incoming messages
- */
+ To be used with \a sendMesh method.
+ \param mesh pointer to mesh that is filled
+ \param source processor id of the incoming messages
+*/
void ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int source)const
{
- // First stage : exchanging sizes
- // ------------------------------
- vector<int> tinyInfoDistant;
- vector<string> tinyInfoLocalS;
- vector<double> tinyInfoDistantD(1);
- //Getting tiny info of local mesh to allow the distant proc to initialize and allocate
- //the transmitted mesh.
+ // First stage : exchanging sizes
+ // ------------------------------
+ vector<int> tinyInfoDistant;
+ vector<string> tinyInfoLocalS;
+ vector<double> tinyInfoDistantD(1);
+ //Getting tiny info of local mesh to allow the distant proc to initialize and allocate
+ //the transmitted mesh.
#ifdef HAVE_MPI2
- MPI_Status status;
- int tinyVecSize;
- MPI_Recv(&tinyVecSize, 1, MPI_INT, source, 1113, MPI_COMM_WORLD, &status);
- tinyInfoDistant.resize(tinyVecSize);
+ MPI_Status status;
+ int tinyVecSize;
+ MPI_Recv(&tinyVecSize, 1, MPI_INT, source, 1113, MPI_COMM_WORLD, &status);
+ tinyInfoDistant.resize(tinyVecSize);
#endif
- std::fill(tinyInfoDistant.begin(),tinyInfoDistant.end(),0);
+ std::fill(tinyInfoDistant.begin(),tinyInfoDistant.end(),0);
#ifdef HAVE_MPI2
- MPI_Recv(&tinyInfoDistant[0], tinyVecSize, MPI_INT,source,1112,MPI_COMM_WORLD, &status);
+ MPI_Recv(&tinyInfoDistant[0], tinyVecSize, MPI_INT,source,1112,MPI_COMM_WORLD, &status);
#endif
- //there was tinyInfoLocal.push_back(mesh.getNumberOfCells());
- int NumberOfCells=tinyInfoDistant[tinyVecSize-1];
- //cout<<"recvMesh NumberOfCells "<<NumberOfCells<<endl;
- if (NumberOfCells>0)
+ //there was tinyInfoLocal.push_back(mesh.getNumberOfCells());
+ int NumberOfCells=tinyInfoDistant[tinyVecSize-1];
+ //cout<<"recvMesh NumberOfCells "<<NumberOfCells<<endl;
+ if (NumberOfCells>0)
{
ParaMEDMEM::DataArrayInt *v1Distant=ParaMEDMEM::DataArrayInt::New();
ParaMEDMEM::DataArrayDouble *v2Distant=ParaMEDMEM::DataArrayDouble::New();
//Building the right instance of copy of distant mesh.
ParaMEDMEM::MEDCouplingPointSet *distant_mesh_tmp=
ParaMEDMEM::MEDCouplingPointSet::BuildInstanceFromMeshType(
- (ParaMEDMEM::MEDCouplingMeshType) tinyInfoDistant[0]);
+ (ParaMEDMEM::MEDCouplingMeshType) tinyInfoDistant[0]);
std::vector<std::string> unusedTinyDistantSts;
mesh=dynamic_cast<ParaMEDMEM::MEDCouplingUMesh*> (distant_mesh_tmp);
int nbDistElem=0;
int *ptDist=0;
if(v1Distant)
- {
- nbDistElem=v1Distant->getNbOfElems();
- ptDist=v1Distant->getPointer();
- }
+ {
+ nbDistElem=v1Distant->getNbOfElems();
+ ptDist=v1Distant->getPointer();
+ }
#ifdef HAVE_MPI2
MPI_Recv(ptDist, nbDistElem, MPI_INT, source,1111, MPI_COMM_WORLD, &status);
#endif
double *ptDist2=0;
nbDistElem=0;
if(v2Distant)
- {
- nbDistElem=v2Distant->getNbOfElems();
- ptDist2=v2Distant->getPointer();
- }
+ {
+ nbDistElem=v2Distant->getNbOfElems();
+ ptDist2=v2Distant->getPointer();
+ }
#ifdef HAVE_MPI2
MPI_Recv(ptDist2, nbDistElem, MPI_DOUBLE,source, 1110, MPI_COMM_WORLD, &status);
#endif
if(v1Distant) v1Distant->decrRef();
if(v2Distant) v2Distant->decrRef();
}
- else
+ else
{
- mesh=createEmptyMEDCouplingUMesh();
+ mesh=CreateEmptyMEDCouplingUMesh();
}
- if (MyGlobals::_verbose>600) cout<<"proc "<<_rank<<" : recvMesh '"<<mesh->getName()<<"' size "<<mesh->getNumberOfCells()<<" from "<<source<<endl;
+ if (MyGlobals::_Verbose>600) cout<<"proc "<<_rank<<" : recvMesh '"<<mesh->getName()<<"' size "<<mesh->getNumberOfCells()<<" from "<<source<<endl;
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : MEDPARTITIONER_ParaDomainSelector.hxx
-// Created : Wed Jun 24 12:18:58 2009
-// Author : Edward AGAPOV (eap)
-
-#ifndef __MEDPARTITIONER_ParaDomainSelector_HXX__
-#define __MEDPARTITIONER_ParaDomainSelector_HXX__
+#ifndef __MEDPARTITIONER_PARADOMAINSELECTOR_HXX__
+#define __MEDPARTITIONER_PARADOMAINSELECTOR_HXX__
#include "MEDPARTITIONER.hxx"
class Graph;
class JointExchangeData;
-/*!
- * \brief Communication helper in parallel mode
- */
-class MEDPARTITIONER_EXPORT ParaDomainSelector
-{
-
-public:
-
- ParaDomainSelector(bool mesure_memory=false);
- ~ParaDomainSelector();
-
- // return processor rank
- int rank() const { return _rank; }
- // return number of processors
- int nbProcs() const { return _world_size; }
- // Return true if is running on different hosts
- bool isOnDifferentHosts() const;
- // Return true if the domain with domainIndex is to be loaded on this proc
- bool isMyDomain(int domainIndex) const;
- // Return processor id where the domain with domainIndex resides
- int getProcessorID(int domainIndex) const;
- //Set nb of required domains. (Used to sort joints via jointId())
- void setNbDomains(int nb) { _nb_result_domains = nb; }
- // Return identifier for a joint
- int jointId( int local_domain, int distant_domain ) const;
+ /*!
+ * \brief Communication helper in parallel mode
+ */
+ class MEDPARTITIONER_EXPORT ParaDomainSelector
+ {
+
+ public:
+
+ ParaDomainSelector(bool mesure_memory=false);
+ ~ParaDomainSelector();
+
+ //processor rank
+ int rank() const { return _rank; }
+ //number of processors
+ int nbProcs() const { return _world_size; }
+ //true if is running on different hosts
+ bool isOnDifferentHosts() const;
+ //true if the domain with domainIndex is to be loaded on this proc
+ bool isMyDomain(int domainIndex) const;
+ //processor id where the domain with domainIndex resides
+ int getProcessorID(int domainIndex) const;
+ //Set nb of required domains. (Used to sort joints via jointId())
+ void setNbDomains(int nb) { _nb_result_domains = nb; }
+ //identifier for a joint
+ int jointId( int local_domain, int distant_domain ) const;
- int getNbTotalCells() { return _cell_shift_by_domain.back(); }
- int getNbTotalNodes() { return _node_shift_by_domain.back(); };
- int getNbTotalFaces() { return _face_shift_by_domain.back(); };
+ int getNbTotalCells() { return _cell_shift_by_domain.back(); }
+ int getNbTotalNodes() { return _node_shift_by_domain.back(); };
+ int getNbTotalFaces() { return _face_shift_by_domain.back(); };
- // Return domain order
- //int getDomainOrder(int domainIndex, int nb_domains) const;
-
- // Collect nb of entities on procs
- void gatherNbOf(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>& domain_meshes);
+ //Collect nb of entities on procs
+ void gatherNbOf(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>& domain_meshes);
- // Return distribution of the graph vertices among the processors
- int* getProcVtxdist() const;
-
- // Return nb of nodes on processors with lower rank
- int getProcNodeShift() const;
- // Return nb of cells in domains with lower index
- int getDomainCellShift(int domainIndex) const;
- // Return nb of nodes in domains with lower index
- int getDomainNodeShift(int domainIndex) const;
-
- // Gather graphs from all processors into one
- std::auto_ptr<Graph> gatherGraph(const Graph* graph) const;
-
- // Set nb of cell/cell pairs in a joint between domains
- void setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain );
- // Gather size of each proc/proc joint
- void gatherNbCellPairs();
- // Return nb of cell/cell pairs in a joint between domains on different procs
- int getNbCellPairs( int dist_domain, int loc_domain ) const;
-
- // Send-receive joint data
- // void exchangeJoint( JointExchangeData* joint ) const;
-
- // Return the first global id of sub-entity for the joint
- int getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const;
- // Send-receive local ids of joint faces
- int* exchangeSubentityIds( int loc_domain, int dist_domain,
- const std::vector<int>& loc_ids_here ) const;
- // Return time passed from construction in seconds
- double getPassedTime() const;
-
- // Evaluate current memory usage and return the maximal one in KB
- int evaluateMemory() const;
-
- void sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int target) const;
- void recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int source) const;
+ //distribution of the graph vertices among the processors
+ int* getProcVtxdist() const;
+
+ //nb of nodes on processors with lower rank
+ int getProcNodeShift() const;
+ //nb of cells in domains with lower index
+ int getDomainCellShift(int domainIndex) const;
+ //nb of nodes in domains with lower index
+ int getDomainNodeShift(int domainIndex) const;
+
+ //Gather graphs from all processors into one
+ std::auto_ptr<Graph> gatherGraph(const Graph* graph) const;
+
+ //Set nb of cell/cell pairs in a joint between domains
+ void setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain );
+ //Gather size of each proc/proc joint
+ void gatherNbCellPairs();
+ //nb of cell/cell pairs in a joint between domains on different procs
+ int getNbCellPairs( int dist_domain, int loc_domain ) const;
+
+ //get the first global id of sub-entity for the joint
+ int getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const;
+ //Send-receive local ids of joint faces
+ int* exchangeSubentityIds( int loc_domain, int dist_domain,
+ const std::vector<int>& loc_ids_here ) const;
+ //time passed from construction in seconds
+ double getPassedTime() const;
+
+ //Evaluate current memory usage and return the maximal one in KB
+ int evaluateMemory() const;
+
+ void sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int target) const;
+ void recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int source) const;
-private:
-
- int _rank, _world_size; // my rank and nb of processors
- int _nb_result_domains; // required nb of domains
-
- //int _total_nb_faces; // nb of faces in the whole mesh without proc/proc joint faces
-
- std::vector< int > _nb_cell_pairs_by_joint;
- std::vector< int > _nb_vert_of_procs; // graph vertices
- std::vector< int > _cell_shift_by_domain;
- std::vector< int > _node_shift_by_domain;
- std::vector< int > _face_shift_by_domain;
-
- double _init_time;
- bool _mesure_memory;
- int _init_memory, _max_memory;
-};
+ private:
+ int _rank, _world_size; //my rank and nb of processors
+ int _nb_result_domains; //required nb of domains
+
+ std::vector< int > _nb_cell_pairs_by_joint;
+ std::vector< int > _nb_vert_of_procs; //graph vertices
+ std::vector< int > _cell_shift_by_domain;
+ std::vector< int > _node_shift_by_domain;
+ std::vector< int > _face_shift_by_domain;
+
+ double _init_time;
+ bool _mesure_memory;
+ int _init_memory, _max_memory;
+ };
}
-
#endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <set>
-#include <map>
-#include <vector>
-#include <iostream>
-#include "InterpKernelHashMap.hxx"
-#include "MEDPARTITIONER_MESHCollection.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
#include "MEDPARTITIONER_Topology.hxx"
#include "MEDPARTITIONER_Graph.hxx"
#include "MEDPARTITIONER_ParallelTopology.hxx"
#include "MEDPARTITIONER_ConnectZone.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
#include "MEDCouplingUMesh.hxx"
-#include "MEDPARTITIONER_utils.hxx"
+#include "InterpKernelHashMap.hxx"
+
+#include <set>
+#include <map>
+#include <vector>
+#include <iostream>
#ifdef HAVE_MPI2
#include <mpi.h>
using namespace MEDPARTITIONER;
using namespace std;
-//empty constructor
ParallelTopology::ParallelTopology():_nb_domain(0),_mesh_dimension(0)
-{}
+{
+}
-//!constructing topology according to mesh collection without global numerotation (use setGlobalNumerotation later)
+//constructing topology according to mesh collection without global numerotation (use setGlobalNumerotation later)
ParallelTopology::ParallelTopology(const vector<ParaMEDMEM::MEDCouplingUMesh*>& meshes)
{
_nb_domain=meshes.size();
_nb_nodes.resize(_nb_domain);
// _nb_faces.resize(_nb_domain);
- if (MyGlobals::_is0verbose>100) cout<<"new ParallelTopology\n";
+ if (MyGlobals::_Is0verbose>100) cout<<"new ParallelTopology\n";
_loc_to_glob.resize(0); //precaution, need gatherNbOf() setGlobalNumerotation()
_node_loc_to_glob.resize(0); //precaution, need gatherNbOf() setGlobalNumerotation()
//_face_loc_to_glob.resize(_nb_domain);
for (int idomain=0; !parallel_mode && idomain<_nb_domain; idomain++)
parallel_mode = (!meshes[idomain]);
- if (MyGlobals::_is0verbose>20 && !parallel_mode) cout<<"WARNING : ParallelTopology contructor without parallel_mode"<<endl;
+ if (MyGlobals::_Is0verbose>20 && !parallel_mode) cout<<"WARNING : ParallelTopology contructor without parallel_mode"<<endl;
for (int idomain=0; idomain<_nb_domain; idomain++)
- {
- if ( !meshes[idomain] ) continue;
- if (_mesh_dimension==-1)
{
- _mesh_dimension = meshes[idomain]->getMeshDimension();
- }
- else
- {
- if (_mesh_dimension!=meshes[idomain]->getMeshDimension())
- throw INTERP_KERNEL::Exception(LOCALIZED("meshes dimensions incompatible"));
+ if ( !meshes[idomain] ) continue;
+ if (_mesh_dimension==-1)
+ {
+ _mesh_dimension = meshes[idomain]->getMeshDimension();
+ }
+ else
+ {
+ if (_mesh_dimension!=meshes[idomain]->getMeshDimension())
+ throw INTERP_KERNEL::Exception(LOCALIZED("meshes dimensions incompatible"));
+ }
+ _nb_cells[idomain]=meshes[idomain]->getNumberOfCells();
+ _nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
+ //note: in parallel mode _nb_cells and _nb_nodes are not complete now, needs gatherNbOf()
}
- _nb_cells[idomain]=meshes[idomain]->getNumberOfCells();
- _nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
- //note: in parallel mode _nb_cells and _nb_nodes are not complete now, needs gatherNbOf()
- }
}
-//!constructing _loc_to_glob etc by default, needs gatherNbOf() done
+//constructing _loc_to_glob etc by default, needs gatherNbOf() done
void ParallelTopology::setGlobalNumerotationDefault(ParaDomainSelector* domainSelector)
{
- if (MyGlobals::_is0verbose>100) cout<<"setGlobalNumerotationDefault on "<<_nb_domain<<" domains\n";
+ if (MyGlobals::_Is0verbose>100) cout<<"setGlobalNumerotationDefault on "<<_nb_domain<<" domains\n";
if (_loc_to_glob.size()!=0) throw INTERP_KERNEL::Exception(LOCALIZED("a global numerotation is done yet"));
_loc_to_glob.resize(_nb_domain);
_node_loc_to_glob.resize(_nb_domain);
//warning because _nb_cells[idomain] is 0 if not my domain(s)
//we set loc_to_glob etc.. only for my domain(s)
- if (MyGlobals::_is0verbose>500) cout<<"(c)idomain|ilocalCell|iglobalCell"<<endl;
+ if (MyGlobals::_Is0verbose>500) cout<<"(c)idomain|ilocalCell|iglobalCell"<<endl;
for (int idomain=0; idomain<_nb_domain; idomain++)
- {
- _loc_to_glob[idomain].resize(_nb_cells[idomain]);
- int domainCellShift=domainSelector->getDomainCellShift(idomain);
- for (int i=0; i<_nb_cells[idomain]; i++)
{
- int global=domainCellShift+i ;
- _glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
- _loc_to_glob[idomain][i]=global;
- if (MyGlobals::_verbose>500) cout<<"c"<<idomain<<"|"<<i<<"|"<<global<<" ";
+ _loc_to_glob[idomain].resize(_nb_cells[idomain]);
+ int domainCellShift=domainSelector->getDomainCellShift(idomain);
+ for (int i=0; i<_nb_cells[idomain]; i++)
+ {
+ int global=domainCellShift+i ;
+ _glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
+ _loc_to_glob[idomain][i]=global;
+ if (MyGlobals::_Verbose>500) cout<<"c"<<idomain<<"|"<<i<<"|"<<global<<" ";
+ }
}
- }
- if (MyGlobals::_verbose>500) MPI_Barrier(MPI_COMM_WORLD);
- if (MyGlobals::_is0verbose>500) cout<<endl;
+ if (MyGlobals::_Verbose>500) MPI_Barrier(MPI_COMM_WORLD);
+ if (MyGlobals::_Is0verbose>500) cout<<endl;
- if (MyGlobals::_is0verbose>500) cout<<"(n)idomain|ilocalNode|iglobalNode"<<endl;
+ if (MyGlobals::_Is0verbose>500) cout<<"(n)idomain|ilocalNode|iglobalNode"<<endl;
for (int idomain=0; idomain<_nb_domain; idomain++)
- {
- _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]);
- int domainNodeShift=domainSelector->getDomainNodeShift(idomain);
- for (int i=0; i<_nb_nodes[idomain]; i++)
{
- int global=domainNodeShift+i ;
- _node_glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
- _node_loc_to_glob[idomain][i]=global;
- if (MyGlobals::_verbose>500) cout<<"n"<<idomain<<"|"<<i<<"|"<<global<<" ";
+ _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]);
+ int domainNodeShift=domainSelector->getDomainNodeShift(idomain);
+ for (int i=0; i<_nb_nodes[idomain]; i++)
+ {
+ int global=domainNodeShift+i ;
+ _node_glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
+ _node_loc_to_glob[idomain][i]=global;
+ if (MyGlobals::_Verbose>500) cout<<"n"<<idomain<<"|"<<i<<"|"<<global<<" ";
+ }
}
- }
- if (MyGlobals::_verbose>500) MPI_Barrier(MPI_COMM_WORLD);
- if (MyGlobals::_is0verbose>500) cout<<endl;
+ if (MyGlobals::_Verbose>500) MPI_Barrier(MPI_COMM_WORLD);
+ if (MyGlobals::_Is0verbose>500) cout<<endl;
_nb_total_cells=domainSelector->getNbTotalCells();
_nb_total_nodes=domainSelector->getNbTotalNodes();
_nb_total_faces=domainSelector->getNbTotalFaces();
- if (MyGlobals::_is0verbose>200) cout<<"globalNumerotation default done meshDimension "<<_mesh_dimension<<" nbTotalCells "<<_nb_total_cells<<" nbTotalNodes "<<_nb_total_nodes<<endl;
+ if (MyGlobals::_Is0verbose>200) cout<<"globalNumerotation default done meshDimension "<<_mesh_dimension<<" nbTotalCells "<<_nb_total_cells<<" nbTotalNodes "<<_nb_total_nodes<<endl;
}
-//!constructing topology according to mesh collection
+//constructing topology according to mesh collection
ParallelTopology::ParallelTopology(const vector<ParaMEDMEM::MEDCouplingUMesh*>& meshes,
- const vector<MEDPARTITIONER::CONNECTZONE*>& cz,
+ const vector<MEDPARTITIONER::ConnectZone*>& cz,
vector<int*>& cellglobal,
vector<int*>& nodeglobal,
vector<int*>& faceglobal)
parallel_mode = (!meshes[idomain]);
for (int idomain=0; idomain<_nb_domain; idomain++)
- {
- if ( !meshes[idomain] ) continue;
- _mesh_dimension = meshes[idomain]->getMeshDimension();
+ {
+ if ( !meshes[idomain] ) continue;
+ _mesh_dimension = meshes[idomain]->getMeshDimension();
- //creating cell maps
- _nb_cells[idomain]=meshes[idomain]->getNumberOfCells();
- // cout << "Nb cells (domain "<<idomain<<") = "<<_nb_cells[idomain];
- _loc_to_glob[idomain].resize(_nb_cells[idomain]);
+ //creating cell maps
+ _nb_cells[idomain]=meshes[idomain]->getNumberOfCells();
+ // cout << "Nb cells (domain "<<idomain<<") = "<<_nb_cells[idomain];
+ _loc_to_glob[idomain].resize(_nb_cells[idomain]);
- if (cellglobal[idomain]==0 || parallel_mode)
- {
- //int cellDomainShift=_cell_shift_by_domain[idomain];
- //creating global numbering from scratch
- for (int i=0; i<_nb_cells[idomain]; i++)
- {
- int global=i ;//cellDomainShift+i;
- _glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
- _loc_to_glob[idomain][i]=global;
- //cvw cout<<idomain<<"|"<<i<<"|"<<global<<" ";
- index_global++;
- }
- }
- //using global numbering coming from a previous numbering
- else
- {
- for (int i=0; i<_nb_cells[idomain]; i++)
- {
- int global=cellglobal[idomain][i];
- _glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
- //_loc_to_glob[make_pair(idomain,i+1)]=global;
- _loc_to_glob[idomain][i]=global;
- index_global++;
- // cout<<"glob:"<<global<<" --> ("<<idomain<<","<<i+1<<")"<<endl;
- }
- }
+ if (cellglobal[idomain]==0 || parallel_mode)
+ {
+ //int cellDomainShift=_cell_shift_by_domain[idomain];
+ //creating global numbering from scratch
+ for (int i=0; i<_nb_cells[idomain]; i++)
+ {
+ int global=i ;//cellDomainShift+i;
+ _glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
+ _loc_to_glob[idomain][i]=global;
+ //cvw cout<<idomain<<"|"<<i<<"|"<<global<<" ";
+ index_global++;
+ }
+ }
+ //using global numbering coming from a previous numbering
+ else
+ {
+ for (int i=0; i<_nb_cells[idomain]; i++)
+ {
+ int global=cellglobal[idomain][i];
+ _glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
+ //_loc_to_glob[make_pair(idomain,i+1)]=global;
+ _loc_to_glob[idomain][i]=global;
+ index_global++;
+ // cout<<"glob:"<<global<<" --> ("<<idomain<<","<<i+1<<")"<<endl;
+ }
+ }
- //cas sequentiel
- if (_nb_domain==1)
- {
- _nb_total_cells=index_global;
- _nb_cells[0]=index_global;
- _node_loc_to_glob[idomain].resize(meshes[idomain]->getNumberOfNodes());
- for (int i=0; i<meshes[idomain]->getNumberOfNodes(); i++)
- {
- _node_glob_to_loc.insert(make_pair(i,make_pair(0,i)));
- _node_loc_to_glob[0][i]=i;
- }
- _nb_total_nodes=meshes[idomain]->getNumberOfNodes();
- _nb_nodes[0]=_nb_total_nodes;
- return;
- }
+ //cas sequentiel
+ if (_nb_domain==1)
+ {
+ _nb_total_cells=index_global;
+ _nb_cells[0]=index_global;
+ _node_loc_to_glob[idomain].resize(meshes[idomain]->getNumberOfNodes());
+ for (int i=0; i<meshes[idomain]->getNumberOfNodes(); i++)
+ {
+ _node_glob_to_loc.insert(make_pair(i,make_pair(0,i)));
+ _node_loc_to_glob[0][i]=i;
+ }
+ _nb_total_nodes=meshes[idomain]->getNumberOfNodes();
+ _nb_nodes[0]=_nb_total_nodes;
+ return;
+ }
- //creating node maps
- _nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
- INTERP_KERNEL::HashMap <int,pair<int,int> > local2distant;
- _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]);
- for (int icz=0; icz<cz.size(); icz++)
- {
- if (cz[icz]->getLocalDomainNumber() == idomain &&
- cz[icz]->getLocalDomainNumber()>cz[icz]->getDistantDomainNumber())
- {
- int nb_node= cz[icz]->getNodeNumber();
- const int* node_corresp=cz[icz]->getNodeCorrespValue();
- int distant_ip = cz[icz]->getDistantDomainNumber();
- for (int i=0; i< nb_node; i++)
+ //creating node maps
+ _nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
+ INTERP_KERNEL::HashMap <int,pair<int,int> > local2distant;
+ _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]);
+ for (int icz=0; icz<cz.size(); icz++)
{
- int local= node_corresp[i*2];
- int distant = node_corresp[i*2+1];
- local2distant.insert(make_pair(local, make_pair(distant_ip,distant)));
+ if (cz[icz]->getLocalDomainNumber() == idomain &&
+ cz[icz]->getLocalDomainNumber()>cz[icz]->getDistantDomainNumber())
+ {
+ int nb_node= cz[icz]->getNodeNumber();
+ const int* node_corresp=cz[icz]->getNodeCorrespValue();
+ int distant_ip = cz[icz]->getDistantDomainNumber();
+ for (int i=0; i< nb_node; i++)
+ {
+ int local= node_corresp[i*2];
+ int distant = node_corresp[i*2+1];
+ local2distant.insert(make_pair(local, make_pair(distant_ip,distant)));
+ }
+ }
}
- }
- }
- // setting mappings for all nodes
- if (nodeglobal[idomain]==0)
- {
- for (int inode=0; inode<_nb_nodes[idomain]; inode++)
- {
- if (local2distant.find(inode)==local2distant.end())
+ // setting mappings for all nodes
+ if (nodeglobal[idomain]==0)
{
- index_node_global++;
- _node_glob_to_loc.insert(make_pair(index_node_global,make_pair(idomain,inode)));
- //_node_loc_to_glob[make_pair(idomain,inode+1)]=index_node_global;
- _node_loc_to_glob[idomain][inode]=index_node_global;
- }
- else
+ for (int inode=0; inode<_nb_nodes[idomain]; inode++)
+ {
+ if (local2distant.find(inode)==local2distant.end())
+ {
+ index_node_global++;
+ _node_glob_to_loc.insert(make_pair(index_node_global,make_pair(idomain,inode)));
+ //_node_loc_to_glob[make_pair(idomain,inode+1)]=index_node_global;
+ _node_loc_to_glob[idomain][inode]=index_node_global;
+ }
+ else
+ {
+ int ip = (local2distant.find(inode)->second).first;
+ int distant = (local2distant.find(inode)->second).second;
+ int global_number=_loc_to_glob[ip][distant];
+ _node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode)));
+ _node_loc_to_glob[idomain][inode]=global_number;
+ }
+ }
+ }
+ //using former node numbering
+ else
{
- int ip = (local2distant.find(inode)->second).first;
- int distant = (local2distant.find(inode)->second).second;
- int global_number=_loc_to_glob[ip][distant];
- _node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode)));
- _node_loc_to_glob[idomain][inode]=global_number;
- }
- }
- }
- //using former node numbering
- else
- {
- for (int inode=0; inode<_nb_nodes[idomain]; inode++)
- {
- int global_number=nodeglobal[idomain][inode];
- _node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode)));
- _node_loc_to_glob[idomain][inode]=global_number;
- }
+ for (int inode=0; inode<_nb_nodes[idomain]; inode++)
+ {
+ int global_number=nodeglobal[idomain][inode];
+ _node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode)));
+ _node_loc_to_glob[idomain][inode]=global_number;
+ }
+ }
}
- }
_nb_total_cells=index_global;
_nb_total_nodes=index_node_global;
}
-//!constructing ParallelTopology from an old topology and a graph
+//constructing ParallelTopology from an old topology and a graph
ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_domain, int mesh_dimension)
{
//cvw !!whatisit! _nb_cells=graph->nbVertices();
_mesh_dimension=mesh_dimension;
- if (MyGlobals::_verbose>200)
- cout<<"proc "<<MyGlobals::_rank<<" : new topology oldNbDomain "<<
- oldTopology->nbDomain()<<" newNbDomain "<<_nb_domain<<endl;
+ if (MyGlobals::_Verbose>200)
+ cout<<"proc "<<MyGlobals::_Rank<<" : new topology oldNbDomain "<<
+ oldTopology->nbDomain()<<" newNbDomain "<<_nb_domain<<endl;
_nb_cells.resize(_nb_domain,0);
_nb_nodes.resize(_nb_domain,0);
_nb_faces.resize(_nb_domain,0);
const int* part=graph->getPart(); //all cells for this proc (may be more domains)
_nb_total_cells=graph->nbVertices(); //all cells for this proc (may be more domains)
- if (MyGlobals::_verbose>300)
- cout<<"proc "<<MyGlobals::_rank<<" : topology from partition, nbTotalCells "<<_nb_total_cells<<endl;
+ if (MyGlobals::_Verbose>300)
+ cout<<"proc "<<MyGlobals::_Rank<<" : topology from partition, nbTotalCells "<<_nb_total_cells<<endl;
int icellProc=0; //all cells of my domains are concatenated in part
for (int iold=0; iold<oldTopology->nbDomain(); iold++)
- {
- int ioldNbCell=oldTopology->getCellNumber(iold);
- //cout<<"proc "<<MyGlobals::_rank<<" : cell number old domain "<<iold<<" : "<<ioldNbCell<<endl;
- //if not my old domains getCellNumber is 0
- std::vector<int> globalids(ioldNbCell);
- oldTopology->getCellList(iold, &globalids[0]); //unique global numerotation
- for (int icell=0; icell<ioldNbCell; icell++)
{
- int idomain=part[icellProc];
- _nb_cells[idomain]++;
- icellProc++;
- int iGlobalCell=globalids[icell];
- _loc_to_glob[idomain].push_back(iGlobalCell);
- _glob_to_loc.insert(make_pair(iGlobalCell, make_pair(idomain, _nb_cells[idomain])));
+ int ioldNbCell=oldTopology->getCellNumber(iold);
+ //cout<<"proc "<<MyGlobals::_Rank<<" : cell number old domain "<<iold<<" : "<<ioldNbCell<<endl;
+ //if not my old domains getCellNumber is 0
+ std::vector<int> globalids(ioldNbCell);
+ oldTopology->getCellList(iold, &globalids[0]); //unique global numerotation
+ for (int icell=0; icell<ioldNbCell; icell++)
+ {
+ int idomain=part[icellProc];
+ _nb_cells[idomain]++;
+ icellProc++;
+ int iGlobalCell=globalids[icell];
+ _loc_to_glob[idomain].push_back(iGlobalCell);
+ _glob_to_loc.insert(make_pair(iGlobalCell, make_pair(idomain, _nb_cells[idomain])));
+ }
}
- }
- if (MyGlobals::_verbose>300)
+ if (MyGlobals::_Verbose>300)
for (int idomain=0; idomain<_nb_domain; idomain++)
- cout<<"proc "<<MyGlobals::_rank<<" : nbCells in new domain "<<idomain<<" : "<<_nb_cells[idomain]<<endl;
+ cout<<"proc "<<MyGlobals::_Rank<<" : nbCells in new domain "<<idomain<<" : "<<_nb_cells[idomain]<<endl;
}
-//!constructing ParallelTopology from an old topology and a graph
-/*
-ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_domain, int mesh_dimension)
-{
-
- _nb_domain=nb_domain;
- //cvw !!whatisit! _nb_cells=graph->nbVertices();
- _mesh_dimension=mesh_dimension;
-
- cout<<"proc "<<MyGlobals::_rank<<" : new topology from partition old nbDomain "<<
- oldTopology->nbDomain()<<" new nbDomain "<<_nb_domain<<endl;
- _nb_cells.resize(_nb_domain);
- _nb_nodes.resize(_nb_domain);
- _nb_faces.resize(_nb_domain);
-
- _loc_to_glob.resize(_nb_domain);
- _node_loc_to_glob.resize(_nb_domain);
- _face_loc_to_glob.resize(_nb_domain);
-
- // used in parallel mode only
- _cell_loc_to_glob_fuse.resize(_nb_domain);
- _face_loc_to_glob_fuse.resize(_nb_domain);
-
- for (int i=0; i<_nb_domain; i++) _nb_cells[i]=0;
-
- const int* part=graph->getPart();
- _nb_total_cells=graph->nbVertices();
-
- cout<<"proc "<<MyGlobals::_rank<<" : topology from partition, _nb_total_cells "<<_nb_total_cells<<endl;
-
- for (int icell=0; icell<_nb_total_cells; icell++)
- {
- int idomain = part[icell];
- _nb_cells[idomain]++;
- //cvw problem _nb_cells[idomain] is not only on this proc...
- //cout<<"proc "<<MyGlobals::_rank<<" : topology from partition, houston! there is a bug in _loc_to_glob and _glob_to_loc"<<endl;
- _loc_to_glob[idomain].push_back(icell);
- _glob_to_loc.insert(make_pair(icell, make_pair(idomain, _nb_cells[idomain])));
- cout<<"proc "<<MyGlobals::_rank<<" : glob_to_loc.insert : "<<icell<<" "<<idomain<<" "<<_nb_cells[idomain]<<endl;
- }
- for (int idomain=0; idomain<_nb_domain; idomain++)
- cout<<"proc "<<MyGlobals::_rank<<" : Nb cells in new domain "<<idomain<<" : "<<_nb_cells[idomain]<<endl;
-}
-*/
-
ParallelTopology::~ParallelTopology()
{
}
if (_node_glob_to_loc.empty())
throw INTERP_KERNEL::Exception(LOCALIZED("Node mapping has not yet been built"));
for (int i=0; i< nbnode; i++)
- {
- pair<int,int> local_node = _node_glob_to_loc.find(node_list[i])->second;
- ip[i]=local_node.first;
- local[i]=local_node.second;
- }
+ {
+ pair<int,int> local_node = _node_glob_to_loc.find(node_list[i])->second;
+ ip[i]=local_node.first;
+ local[i]=local_node.second;
+ }
}
/*!Converts a list of global node numbers on domain ip
throw INTERP_KERNEL::Exception(LOCALIZED("Node mapping has not yet been built"));
for (int i=0; i< nbnode; i++)
- {
- typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=_node_glob_to_loc.equal_range(node_list[i]);
- for (mmiter it=range.first; it !=range.second; it++)
- {
- int ipfound=(it->second).first;
- if (ipfound==ip)
- local[i]=(it->second).second;
+ {
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
+ pair<mmiter,mmiter> range=_node_glob_to_loc.equal_range(node_list[i]);
+ for (mmiter it=range.first; it !=range.second; it++)
+ {
+ int ipfound=(it->second).first;
+ if (ipfound==ip)
+ local[i]=(it->second).second;
+ }
}
- }
}
/*!Converts a list of global node numbers
size=0;
for (int i=0; i< nbnode; i++)
- {
- int count= _node_glob_to_loc.count(node_list[i]);
- // if (count > 1)
- // cout << "noeud " << node_list[i]<< " doublon d'ordre " << count<<endl;
- size+=count;
- }
+ {
+ int count= _node_glob_to_loc.count(node_list[i]);
+ // if (count > 1)
+ // cout << "noeud " << node_list[i]<< " doublon d'ordre " << count<<endl;
+ size+=count;
+ }
int index=0;
ip=new int[size];
local=new int[size];
full_array=new int[size];
for (int i=0; i< nbnode; i++)
- {
- typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=_node_glob_to_loc.equal_range(node_list[i]);
- for (mmiter it=range.first; it !=range.second; it++)
- {
- ip[index]=(it->second).first;
- local[index]=(it->second).second;
- full_array [index]=node_list[i];
- index++;
- }
+ {
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
+ pair<mmiter,mmiter> range=_node_glob_to_loc.equal_range(node_list[i]);
+ for (mmiter it=range.first; it !=range.second; it++)
+ {
+ ip[index]=(it->second).first;
+ local[index]=(it->second).second;
+ full_array [index]=node_list[i];
+ index++;
+ }
- }
+ }
}
/*!Converts a list of global face numbers
{
size=0;
for (int i=0; i< nbface; i++)
- {
- //int count = _face_glob_to_loc.count(face_list[i]);
- //if (count >1) MESSAGE_MED("face en doublon "<<face_list[i]);
- size+= _face_glob_to_loc.count(face_list[i]);
- }
+ {
+ //int count = _face_glob_to_loc.count(face_list[i]);
+ //if (count >1) MESSAGE_MED("face en doublon "<<face_list[i]);
+ size+= _face_glob_to_loc.count(face_list[i]);
+ }
int index=0;
ip=new int[size];
local=new int[size];
full_array=new int[size];
for (int i=0; i< nbface; i++)
- {
- typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=_face_glob_to_loc.equal_range(face_list[i]);
- for (mmiter it=range.first; it !=range.second; it++)
- {
- ip[index]=(it->second).first;
- local[index]=(it->second).second;
- full_array[index]=face_list[i];
- index++;
- }
+ {
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
+ pair<mmiter,mmiter> range=_face_glob_to_loc.equal_range(face_list[i]);
+ for (mmiter it=range.first; it !=range.second; it++)
+ {
+ ip[index]=(it->second).first;
+ local[index]=(it->second).second;
+ full_array[index]=face_list[i];
+ index++;
+ }
- }
+ }
}
//!converts a list of global cell numbers
void ParallelTopology::convertGlobalCellList(const int* cell_list, int nbcell, int* local, int* ip)
{
for (int i=0; i<nbcell; i++)
- {
- //cvw INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = _glob_to_loc.find(cell_list[i]);
- INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = _glob_to_loc.find(cell_list[i]);
- if (iter == _glob_to_loc.end())
- {
- cerr<<"proc "<<MyGlobals::_rank<<" : KO cell_list["<<i<<"] : "<<cell_list[i]<<endl;
- throw INTERP_KERNEL::Exception(LOCALIZED("ParallelTopology::convertGlobalCellList : Cell not found"));
- }
- else
{
- ip[i]=(iter->second).first; //no domain
- local[i]=(iter->second).second; //no local cell
- //cout<<"proc "<<MyGlobals::_rank<<" : OK cell_list["<<i<<"] : "<<cell_list[i]<<" "<<ip[i]<<" "<<local[i]<<endl;
+ //cvw INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = _glob_to_loc.find(cell_list[i]);
+ INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = _glob_to_loc.find(cell_list[i]);
+ if (iter == _glob_to_loc.end())
+ {
+ cerr<<"proc "<<MyGlobals::_Rank<<" : KO cell_list["<<i<<"] : "<<cell_list[i]<<endl;
+ throw INTERP_KERNEL::Exception(LOCALIZED("ParallelTopology::convertGlobalCellList : Cell not found"));
+ }
+ else
+ {
+ ip[i]=(iter->second).first; //no domain
+ local[i]=(iter->second).second; //no local cell
+ //cout<<"proc "<<MyGlobals::_Rank<<" : OK cell_list["<<i<<"] : "<<cell_list[i]<<" "<<ip[i]<<" "<<local[i]<<endl;
+ }
}
- }
}
/*!Converts a list of global face numbers
void ParallelTopology::convertGlobalFaceList(const int* face_list, int nbface, int* local, int* ip)
{
for (int i=0; i< nbface; i++)
- {
- INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = _face_glob_to_loc.find(face_list[i]);
- if (iter == _face_glob_to_loc.end())
{
- throw INTERP_KERNEL::Exception(LOCALIZED("ParallelTopology::convertGlobalFaceList : Face not found"));
+ INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = _face_glob_to_loc.find(face_list[i]);
+ if (iter == _face_glob_to_loc.end())
+ {
+ throw INTERP_KERNEL::Exception(LOCALIZED("ParallelTopology::convertGlobalFaceList : Face not found"));
+ }
+ ip[i]=(iter->second).first;
+ local[i]=(iter->second).second;
+ // cout << " in convertGlobalFAceList face global "<<face_list[i]<<" -> ("<<ip[i]<<","<<local[i]<<")"<<endl;
}
- ip[i]=(iter->second).first;
- local[i]=(iter->second).second;
- // cout << " in convertGlobalFAceList face global "<<face_list[i]<<" -> ("<<ip[i]<<","<<local[i]<<")"<<endl;
- }
}
/*!Converts a list of global node numbers on domain ip
* If a node in the list is represented on several domains,
* only the value with domain ip is returned
*
- * */
+ */
void ParallelTopology::convertGlobalFaceList(const int* face_list, int nbface, int* local, int ip)
{
for (int i=0; i< nbface; i++)
- {
- typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=_face_glob_to_loc.equal_range(face_list[i]);
- for (mmiter it=range.first; it !=range.second; it++)
- {
- int ipfound=(it->second).first;
- if (ipfound==ip)
- local[i]=(it->second).second;
+ {
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
+ pair<mmiter,mmiter> range=_face_glob_to_loc.equal_range(face_list[i]);
+ for (mmiter it=range.first; it !=range.second; it++)
+ {
+ int ipfound=(it->second).first;
+ if (ipfound==ip)
+ local[i]=(it->second).second;
+ }
}
- }
}
//replacing a table of global numbering with a table with local numberings
void ParallelTopology::convertToLocal2ndVersion(int* nodes, int nbnodes, int idomain)
{
for (int inode=0; inode<nbnodes; inode++)
- {
- // cout <<" inode :"<<inode<< " global = "<<type_connectivity[type][inode];
- int global = nodes[inode];
- typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=_node_glob_to_loc.equal_range(global);
- for (mmiter it=range.first; it !=range.second; it++)
{
- if ((it->second).first==idomain)
- nodes[inode]=(it->second).second;
+ // cout <<" inode :"<<inode<< " global = "<<type_connectivity[type][inode];
+ int global = nodes[inode];
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
+ pair<mmiter,mmiter> range=_node_glob_to_loc.equal_range(global);
+ for (mmiter it=range.first; it !=range.second; it++)
+ {
+ if ((it->second).first==idomain)
+ nodes[inode]=(it->second).second;
+ }
}
- }
}
-//================================================================================
/*!
* \brief Return max global face number
*/
-//================================================================================
int ParallelTopology::getMaxGlobalFace() const
{
int max = 0;
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef __PARALLELTOPOLOGY_HXX__
-#define __PARALLELTOPOLOGY_HXX__
-#include <set>
-#include <vector>
-#include "InterpKernelHashMap.hxx"
+#ifndef __MEDPARTITIONER_PARALLELTOPOLOGY_HXX__
+#define __MEDPARTITIONER_PARALLELTOPOLOGY_HXX__
#include "MEDPARTITIONER_Topology.hxx"
#include "MEDPARTITIONER_ParaDomainSelector.hxx"
-/*
-namespace INTERP_KERNEL
-{
- template<> struct hash< std::pair<int,int> >
- {
- size_t operator()( const std::pair<int,int>& x ) const
- {
- return hash< int >()( x.first*1000000+x.second );
- }
- };
-}*/
+#include "InterpKernelHashMap.hxx"
+
+#include <set>
+#include <vector>
namespace MEDPARTITIONER {
class Graph;
- class MESHCollection;
+ class MeshCollection;
class MEDPARTITIONER_FaceModel;
- class ParallelTopology:public Topology
+ class ParallelTopology : public Topology
{
public:
ParallelTopology();
-
ParallelTopology(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>&);
ParallelTopology(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>&,
- const std::vector<MEDPARTITIONER::CONNECTZONE*>&,
+ const std::vector<MEDPARTITIONER::ConnectZone*>&,
std::vector<int*>&,
std::vector<int*>&,
std::vector<int*>&);
-
ParallelTopology(Graph* graph, Topology* oldTopology, int nbdomain, int mesh_dimension);
-
~ParallelTopology();
void setGlobalNumerotationDefault(ParaDomainSelector* domainSelector);
- //!converts a list of global cell numbers
- //!to a distributed array with local cell numbers
+ //converts a list of global cell numbers
+ //to a distributed array with local cell numbers
void convertGlobalNodeList(const int*, int,int*,int*);
void convertGlobalNodeList(const int*, int,int*,int);
void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size);
- //!converts a list of global node numbers
- //!to a distributed array with local cell numbers
+ //converts a list of global node numbers
+ //to a distributed array with local cell numbers
void convertGlobalCellList(const int*, int , int*, int *);
- //!converts a list of global face numbers
- //!to a distributed array with local face numbers
+ //converts a list of global face numbers
+ //to a distributed array with local face numbers
void convertGlobalFaceList(const int*, int , int*, int *);
void convertGlobalFaceList(const int*, int , int*, int);
void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array,int& size);
-// //!converting node global numberings to local numberings
+ //converting node global numberings to local numberings
void convertToLocal2ndVersion(int* nodes, int nbnodes, int idomain);
- //!converting node local numbering to global
- inline int convertNodeToGlobal(int ip,int icell) const
+ //converting node local numbering to global
+ inline int convertNodeToGlobal(int ip,int icell) const
{
//return _node_loc_to_glob.find(make_pair(ip,icell))->second;
return _node_loc_to_glob[ip][icell];
}
- //!converting face local numbering to global
- inline int convertFaceToGlobal(int ip,int iface) const
+ //converting face local numbering to global
+ inline int convertFaceToGlobal(int ip,int iface) const
{
// if (_face_loc_to_glob.find(make_pair(ip,icell))==_face_loc_to_glob.end())
// return -1;
}
//converting cell global numbering to local
- inline int convertCellToGlobal(int ip,int icell) const
+ inline int convertCellToGlobal(int ip,int icell) const
{
// if (_loc_to_glob.find(make_pair(ip,icell))==_loc_to_glob.end())
// return -1;
return _loc_to_glob[ip][icell];
}
- inline void convertNodeToGlobal(int ip, const int* local, int n, int* global)const
+ inline void convertNodeToGlobal(int ip, const int* local, int n, int* global)const
{
for (int i=0; i<n; i++)
global[i]=_node_loc_to_glob[ip][local[i]];
}
- inline void convertCellToGlobal(int ip, const int* local, int n, int* global)const
+ inline void convertCellToGlobal(int ip, const int* local, int n, int* global)const
{
for (int i=0; i<n; i++)
global[i]=_loc_to_glob[ip][local[i]];
}
- inline void convertFaceToGlobal(int ip, const int* local, int n, int* global)const
+ inline void convertFaceToGlobal(int ip, const int* local, int n, int* global)const
{
for (int i=0; i<n; i++)
global[i]=_face_loc_to_glob[ip][local[i]];
}
- inline int nbDomain() const
+ inline int nbDomain() const
{
return _nb_domain;
}
return _nb_total_nodes;
}
- inline int nbCells( int idomain) const
+ inline int nbCells( int idomain) const
{
return _nb_cells[idomain];
}
- //!retrieving number of nodes
- inline int getNodeNumber(int idomain) const
+ //retrieving number of nodes
+ inline int getNodeNumber(int idomain) const
{
return _nb_nodes[idomain];
}
- inline int getNodeNumber() const
+ inline int getNodeNumber() const
{
if (_node_glob_to_loc.empty()) return 0;
std::set <int> keys;
return keys.size();
}
- //!retrieving list of nodes in global numbers
- inline void getNodeList(int idomain, int* list) const
+ //retrieving list of nodes in global numbers
+ inline void getNodeList(int idomain, int* list) const
{
for (int i=0; i<_nb_nodes[idomain]; i++)
list[i]=_node_loc_to_glob[idomain][i];
}
- //!< retrieving cell numbers after fusing in parallel mode
+ //retrieving cell numbers after merging in parallel mode
std::vector<int> & getFusedCellNumbers(int idomain)
{
return _cell_loc_to_glob_fuse[idomain];
return _cell_loc_to_glob_fuse[idomain];
}
- //!< retrieving face numbers after fusing in parallel mode
+ //retrieving face numbers after merging in parallel mode
std::vector<int> & getFusedFaceNumbers(int idomain)
{
return _face_loc_to_glob_fuse[idomain];
}
- //!retrieving number of nodes
+ //retrieving number of nodes
inline int getCellNumber(int idomain) const
{
return _nb_cells[idomain];
return (_glob_to_loc.find(global)->second).first;
}
- //!retrieving list of nodes in global numbers
+ //retrieving list of nodes in global numbers
inline void getCellList(int idomain, int* list) const
{
for (int i=0; i<_nb_cells[idomain];i++)
}
- //!retrieving list of faces in global numbers
+ //retrieving list of faces in global numbers
inline void getFaceList(int idomain, int* list) const
{
for (int i=0; i<_nb_faces[idomain];i++)
list[i]=_face_loc_to_glob[idomain][i];
}
- //! converting a global cell number to a local representation (domain + local number)
+ //converting a global cell number to a local representation (domain + local number)
inline std::pair<int,int> convertGlobalCell(int iglobal) const
{
return _glob_to_loc.find(iglobal)->second;
typedef INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator MMiter;
std::pair<MMiter,MMiter> eq = _node_glob_to_loc.equal_range(iglobal);
for (MMiter it=eq.first; it != eq.second; it++)
- {
- if (it->second.first == idomain) return it->second.second;
- }
+ {
+ if (it->second.first == idomain) return it->second.second;
+ }
return -1;
}
- //!adding a face to the topology
+ //adding a face to the topology
inline void appendFace(int idomain, int ilocal, int iglobal)
{
_face_loc_to_glob[idomain].push_back(iglobal);
int getMaxGlobalFace() const;
private:
- bool hasCellWithNodes( const MESHCollection&, int dom, const std::set<int>& nodes );
+ bool hasCellWithNodes( const MeshCollection&, int dom, const std::set<int>& nodes );
private:
- //!mapping global -> local
+ //mapping global -> local
typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2DomainLoc;
TGlob2DomainLoc _glob_to_loc;
-
std::vector<std::vector<int> > _loc_to_glob;
-
INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > _node_glob_to_loc;
- //!mapping local -> global
+ //mapping local -> global
std::vector<std::vector <int> > _node_loc_to_glob;
// global numbers in parallel mode
- std::vector<std::vector <int> > _cell_loc_to_glob_fuse; // glob nums after fusing
- std::vector<std::vector <int> > _face_loc_to_glob_fuse; // glob nums after fusing
+ std::vector<std::vector <int> > _cell_loc_to_glob_fuse; // glob nums after merging
+ std::vector<std::vector <int> > _face_loc_to_glob_fuse; // glob nums after merging
- //!mapping global -> local
+ //mapping global -> local
typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2LocsMap;
TGlob2LocsMap _face_glob_to_loc;
- //!mapping local -> global
+ //mapping local -> global
std::vector<std::vector <int> > _face_loc_to_glob;
std::vector<int> _nb_cells;
std::vector<int> _nb_nodes;
int _nb_domain;
int _mesh_dimension;
};
-
-
}
-#endif /*PARALLELTOPOLOGY_HXX_*/
+#endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDPARTITIONER_SkyLineArray.hxx"
-#include <vector>
+#include <vector>
using namespace MEDPARTITIONER;
-MEDSKYLINEARRAY::MEDSKYLINEARRAY()
+SkyLineArray::SkyLineArray()
{
- //MESSAGE_MED("Constructeur MEDSKYLINEARRAY sans parametre");
}
-MEDSKYLINEARRAY::MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray)
+SkyLineArray::SkyLineArray(const SkyLineArray &myArray)
{
_index=myArray._index;
_value=myArray._value;
}
-MEDSKYLINEARRAY::~MEDSKYLINEARRAY()
+SkyLineArray::~SkyLineArray()
{
- //MESSAGE_MED("Destructeur ~MEDSKYLINEARRAY");
-
- //if (_index != NULL) delete [] _index;
- //if (_value != NULL) delete [] _value;
}
-MEDSKYLINEARRAY::MEDSKYLINEARRAY(const std::vector<int>& index, const std::vector<int>& value)
+SkyLineArray::SkyLineArray(const std::vector<int>& index, const std::vector<int>& value)
{
_value=value;
_index=index;
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-# ifndef __MEDPARTITIONER_MEDSKYLINEARRAY_H__
-# define __MEDPARTITIONER_MEDSKYLINEARRAY_H__
+#ifndef __MEDPARTITIONER_MEDSKYLINEARRAY_H__
+#define __MEDPARTITIONER_MEDSKYLINEARRAY_H__
#include "MEDPARTITIONER.hxx"
#include <vector>
-namespace MEDPARTITIONER {
-class MEDPARTITIONER_EXPORT MEDSKYLINEARRAY
-{
-private :
- std::vector<int> _index;
- std::vector<int> _value;
-
-public :
- // Attention, avec ce constructeur, il n'est possible de remplir le MEDSKYLINEARRAY
- MEDSKYLINEARRAY();
-
- // Constructeur par recopie
- MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
-
- // Avec ce constructeur la m�moire pour le tableau de valeur et le
- // tableau d'index est r�serv�e. Il suffit d'effectuer les s�quences
- // d'appels suivantes pour initialiser le MEDSKYLINEARRAY
- // 1) setIndex(index) puis <count> fois setI(i,&listValeurN�I) avec i dans 1..count
- // rem : listValeurN�I est dupliqu�e
- // 2) appeler <length> fois setIJ(i,j,valeur) avec i dans 1..count et avec j dans 1..count
- MEDSKYLINEARRAY( const std::vector<int>& index, const std::vector<int>& value );
-
- ~MEDSKYLINEARRAY();
- //void setMEDSKYLINEARRAY( const int count, const int length, int* index , int* value ) ;
-
- inline int getNumberOf() const;
- inline int getLength() const;
- inline const int* getIndex() const;
- inline const int* getValue() const;
-};
-
-// ---------------------------------------
-// Methodes Inline
-// ---------------------------------------
-inline int MEDSKYLINEARRAY::getNumberOf() const
-{
- return _index.size()-1;
-}
-inline int MEDSKYLINEARRAY::getLength() const
-{
- return _value.size() ;
-}
-inline const int* MEDSKYLINEARRAY::getIndex() const
-{
- return (const int*)(&_index[0]) ;
-}
-inline const int* MEDSKYLINEARRAY::getValue() const
+namespace MEDPARTITIONER
{
- return (const int*)(&_value[0]) ;
-}
+ class MEDPARTITIONER_EXPORT SkyLineArray
+ {
+ private :
+ std::vector<int> _index;
+ std::vector<int> _value;
+
+ public :
+ SkyLineArray(); //if used SkyLineArray will keep empty
+ SkyLineArray( const SkyLineArray &myArray );
+ SkyLineArray( const std::vector<int>& index, const std::vector<int>& value );
+ ~SkyLineArray();
+
+ inline int getNumberOf() const
+ {
+ return _index.size()-1;
+ }
+
+ inline int getLength() const
+ {
+ return _value.size() ;
+ }
+
+ inline const int* getIndex() const
+ {
+ return (const int*)(&_index[0]) ;
+ }
+
+ inline const int* getValue() const
+ {
+ return (const int*)(&_value[0]) ;
+ }
+ };
}
# endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef MEDPARTITIONER_TOPOLOGY_HXX_
-#define MEDPARTITIONER_TOPOLOGY_HXX_
-//#include "boost/shared_ptr.hpp"
+#ifndef __MEDPARTITIONER_TOPOLOGY_HXX__
+#define __MEDPARTITIONER_TOPOLOGY_HXX__
-#include <map>
#include <vector>
+#include <map>
namespace MEDPARTITIONER
{
- class CONNECTZONE;
- class MEDSKYLINEARRAY;
+ class ConnectZone;
+ class SkyLineArray;
}
namespace ParaMEDMEM {
class MEDCouplingUMesh;
}
namespace MEDPARTITIONER {
-
class Graph;
- class MESHCollection;
+ class MeshCollection;
class MEDPARTITIONER_FaceModel;
-
- // typedef std::map<MED_EN::medGeometryElement, std::vector<MEDPARTITIONER_FaceModel*> > TGeom2Faces;
- // typedef std::vector< TGeom2Faces > TGeom2FacesByDomain;
-
+
class Topology
{
public:
- Topology(){}
- Topology(std::vector<ParaMEDMEM::MEDCouplingUMesh*>, std::vector<MEDPARTITIONER::CONNECTZONE*>){}
-
- virtual ~Topology(){}
-
- //!converts a list of global cell numbers
- //!to a distributed array with local cell numbers
- virtual void convertGlobalNodeList(const int* list, int nb, int* local, int*ip)=0;
- virtual void convertGlobalNodeList(const int* list, int nb, int* local, int ip)=0;
- //!converts a list of global node numbers
- //!to a distributed array with local cell numbers
- virtual void convertGlobalCellList(const int*list , int nb, int* local, int*ip)=0;
-
- //!converts a list of global face numbers
- //!to a distributed array with local face numbers
- virtual void convertGlobalFaceList(const int*list , int nb, int* local, int*ip)=0;
- virtual void convertGlobalFaceList(const int*list , int nb, int* local, int ip)=0;
- virtual void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array, int& size)=0;
- virtual void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size)=0;
-
-
+ Topology()
+ {
+ }
+ Topology(std::vector<ParaMEDMEM::MEDCouplingUMesh*>, std::vector<MEDPARTITIONER::ConnectZone*>)
+ {
+ }
+ virtual ~Topology()
+ {
+ }
+
+ //converts a list of global cell numbers
+ //to a distributed array with local cell numbers
+ virtual void convertGlobalNodeList(const int* list, int nb, int* local, int*ip) = 0;
+ virtual void convertGlobalNodeList(const int* list, int nb, int* local, int ip) = 0;
+ //converts a list of global node numbers
+ //to a distributed array with local cell numbers
+ virtual void convertGlobalCellList(const int*list , int nb, int* local, int*ip) = 0;
+
+ //converts a list of global face numbers
+ //to a distributed array with local face numbers
+ virtual void convertGlobalFaceList(const int*list , int nb, int* local, int*ip) = 0;
+ virtual void convertGlobalFaceList(const int*list , int nb, int* local, int ip) = 0;
+ virtual void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array, int& size) = 0;
+ virtual void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size) = 0;
//number of doamins
- virtual int nbDomain() const =0;
-
+ virtual int nbDomain() const = 0;
//number of cells
- virtual int nbCells() const=0;
-
+ virtual int nbCells() const = 0;
//number of nodes
- virtual int nbNodes() const=0;
-
+ virtual int nbNodes() const = 0;
//number of cells on a specific domain
- virtual int nbCells(int idomain) const=0;
-
- // ////creating node mapping
- // virtual void createNodeMapping(std::map<MED_EN::medGeometryElement,int*>& type_connectivity,
- // std::map<MED_EN::medGeometryElement,int>& present_type_numbers,
- // std::vector<int>& polygon_conn,
-// std::vector<int>& polygon_conn_index,
-// std::vector<int>& polyhedron_conn,
-// std::vector<int>& polyhedron_conn_index,
-// std::vector<int>& polyhedron_face_index,
-// int domain)=0;
-
- ////creating face mapping
- // virtual void createFaceMapping(std::map<MED_EN::medGeometryElement,int*>& type_connectivity,
- // std::map<MED_EN::medGeometryElement,int>& present_type_numbers,int domain)=0;
- //
- // virtual void createFaceMapping(const MESHCollection&,const MESHCollection&)=0;
-
- // //converting node global numberings to local numberings
- // virtual void convertToLocal(std::map<MED_EN::medGeometryElement,int*>& type_connectivity,
- // std::map<MED_EN::medGeometryElement,int>& present_type_numbers,
- // int idomain,
- // MED_EN::medEntityMesh entity)=0;
+ virtual int nbCells(int idomain) const = 0;
//converting node global numberings to local numberings
- virtual void convertToLocal2ndVersion(int*,int,int)=0;
-
- virtual int convertNodeToGlobal(int ip,int icell)const=0;
- virtual int convertFaceToGlobal(int ip,int icell)const=0;
- virtual int convertCellToGlobal(int ip,int icell)const=0;
-
- virtual void convertNodeToGlobal(int ip,const int* local, int n, int* global)const=0 ;
- virtual void convertCellToGlobal(int ip,const int* local, int n, int* global)const=0 ;
- virtual void convertFaceToGlobal(int ip,const int* local, int n, int* global)const=0 ;
-
+ virtual void convertToLocal2ndVersion(int*,int,int) = 0;
+ virtual int convertNodeToGlobal(int ip,int icell) const = 0;
+ virtual int convertFaceToGlobal(int ip,int icell) const = 0;
+ virtual int convertCellToGlobal(int ip,int icell) const = 0;
+ virtual void convertNodeToGlobal(int ip,const int* local, int n, int* global) const = 0 ;
+ virtual void convertCellToGlobal(int ip,const int* local, int n, int* global) const = 0 ;
+ virtual void convertFaceToGlobal(int ip,const int* local, int n, int* global) const = 0 ;
//retrieving number of nodes
- virtual int getNodeNumber(int idomain) const =0;
- virtual int getNodeNumber() const=0;
+ virtual int getNodeNumber(int idomain) const = 0;
+ virtual int getNodeNumber() const = 0;
//retrieving list of nodes
- virtual void getNodeList(int idomain, int* list) const =0;
-
+ virtual void getNodeList(int idomain, int* list) const = 0;
virtual std::vector<int> & getFusedCellNumbers(int idomain) = 0;
virtual const std::vector<int> & getFusedCellNumbers(int idomain) const = 0;
-
virtual std::vector<int> & getFusedFaceNumbers(int idomain) = 0;
virtual const std::vector<int> & getFusedFaceNumbers(int idomain) const = 0;
-
//retrieving number of nodes
- virtual int getCellNumber(int idomain) const =0;
-
+ virtual int getCellNumber(int idomain) const = 0;
//retrieving list of nodes
- virtual void getCellList(int idomain, int* list) const =0;
-
+ virtual void getCellList(int idomain, int* list) const = 0;
//retrieving number of faces
- virtual int getFaceNumber(int idomain) const =0;
- virtual int getFaceNumber()const =0;
-
+ virtual int getFaceNumber(int idomain) const = 0;
+ virtual int getFaceNumber()const = 0;
//retrieving list of nodes
- virtual void getFaceList(int idomain, int* list) const =0;
-
+ virtual void getFaceList(int idomain, int* list) const = 0;
//adding a face to the mapping
- virtual void appendFace(int idomain, int ilocal, int iglobal)=0;
-
+ virtual void appendFace(int idomain, int ilocal, int iglobal) = 0;
//return max global face number
- virtual int getMaxGlobalFace()const=0;
-
- //return next free global face number
- //virtual int nextGlobalFace(int start_num) const=0;
-
- //!converting a global cell number to a local representation
- virtual std::pair<int,int> convertGlobalCell(int iglobal) const =0;
-
+ virtual int getMaxGlobalFace() const = 0;
+ //converting a global cell number to a local representation
+ virtual std::pair<int,int> convertGlobalCell(int iglobal) const = 0;
//converting a global face number to a local representation
- virtual int convertGlobalFace(int iglobal, int idomain)=0;
-
+ virtual int convertGlobalFace(int iglobal, int idomain) = 0;
//converting a global node number to a local representation
- virtual int convertGlobalNode(int iglobal, int idomain)=0;
-
- //! computing arrays with node/node correspondencies
- // virtual void computeNodeNodeCorrespondencies(int nbdomain, std::vector<MEDPARTITIONER::MEDSKYLINEARRAY*>&) const =0;
-
- //! computing arrays with cell/cell correspondencies
- // virtual void computeCellCellCorrespondencies(int nbdomain, std::vector<MEDPARTITIONER::MEDSKYLINEARRAY*>&, const Graph*) const =0;
-
-
- //!recreating a face mapping from scratch
- // virtual void recreateFaceMapping(const TGeom2FacesByDomain& )=0;
-
- //!recreating cell and node mapping after send-reveive and fusion of domain meshes
- // virtual void recreateMappingAfterFusion(const std::vector<ParaMEDMEM::MEDCouplingUMesh*>& ) = 0;
+ virtual int convertGlobalNode(int iglobal, int idomain) = 0;
};
}
-
-#endif /*TOPOLOGY_HXX_*/
+#endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "MEDPARTITIONER_Graph.hxx"
#include "MEDPARTITIONER_UserGraph.hxx"
+
#include <iostream>
#include <vector>
+
using namespace MEDPARTITIONER;
/*! constructor that allows to specify the desired partition
* (domain numbers range from 0 to ndomain-1
* \param n number of cells in the mesh
*/
-UserGraph::UserGraph(MEDPARTITIONER::MEDSKYLINEARRAY* array, const int* partition, int n):Graph(array,0)
+UserGraph::UserGraph(MEDPARTITIONER::SkyLineArray* array, const int* partition, int n):Graph(array,0)
{
std::vector<int> index(n+1),value(n);
index[0]=0;
for (int i=0; i<n; i++)
- {
- index[i+1]=index[i]+1;
- value[i]=partition[i];
- }
+ {
+ index[i+1]=index[i]+1;
+ value[i]=partition[i];
+ }
- _partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
+ _partition = new MEDPARTITIONER::SkyLineArray(index,value);
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef MEDPARTITIONER_USERGRAPH_HXX_
-#define MEDPARTITIONER_USERGRAPH_HXX_
+
+#ifndef __MEDPARTITIONER_USERGRAPH_HXX__
+#define __MEDPARTITIONER_USERGRAPH_HXX__
#include "MEDPARTITIONER.hxx"
#include "MEDPARTITIONER_Graph.hxx"
+
#include <string>
+
namespace MEDPARTITIONER
{
- class MEDSKYLINEARRAY;
+ class SkyLineArray;
class ParaDomainSelector;
class MEDPARTITIONER_EXPORT UserGraph : public Graph
{
public:
- UserGraph(MEDPARTITIONER::MEDSKYLINEARRAY*, const int*, int);
+ UserGraph(MEDPARTITIONER::SkyLineArray*, const int*, int);
virtual ~UserGraph();
void partGraph(int, const std::string& options=std::string(""), ParaDomainSelector* sel=0);
};
}
-
-#endif /*MEDPARTITIONER_USERGRAPH_HXX_*/
+#endif
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// MED medsplitter : tool to split n MED files into p separate
-// MED files with a partitioning specified
-// by an external tool
-// File : medsplitter.cxx
-// Module : MED
-//
-
/*
-examples of launch
-rm ttmp* tttmp*
-export verb=11
-mpirun -np 2 medpartitioner_para --input-file=blade.med --output-file=ttmp1_ --ndomains=2 --dump-cpu-memory --verbose=$verb
-mpirun -np 5 medpartitioner_para --input-file=blade.med --output-file=ttmp1_ --ndomains=2 --dump-cpu-memory --verbose=$verb
-mpirun -np 4 medpartitioner_para --input-file=ttmp1_.xml --output-file=tttmp1_ --ndomains=4 --verbose=$verb
+ examples of launch
+ rm ttmp* tttmp*
+ export verb=11
+ mpirun -np 2 medpartitioner_para --input-file=blade.med --output-file=ttmp1_ --ndomains=2 --dump-cpu-memory --verbose=$verb
+ mpirun -np 5 medpartitioner_para --input-file=blade.med --output-file=ttmp1_ --ndomains=2 --dump-cpu-memory --verbose=$verb
+ mpirun -np 4 medpartitioner_para --input-file=ttmp1_.xml --output-file=tttmp1_ --ndomains=4 --verbose=$verb
-mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMesh_20x30x50.med --output-file=ttmp2_ --verbose=$verb
-mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=ttmp2_.xml --output-file=ttmp3_ --verbose=$verb
+ mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMesh_20x30x50.med --output-file=ttmp2_ --verbose=$verb
+ mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=ttmp2_.xml --output-file=ttmp3_ --verbose=$verb
-mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMeshWithFaces_20x30x50.med --output-file=ttmp2_ --verbose=$verb
-mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=ttmp2_.xml --output-file=ttmp3_ --verbose=$verb
+ mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMeshWithFaces_20x30x50.med --output-file=ttmp2_ --verbose=$verb
+ mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=ttmp2_.xml --output-file=ttmp3_ --verbose=$verb
-mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMesh_20x30x50_WithVecFieldOnCells.med --output-file=ttmp2_ --verbose=$verb
-mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMesh_20x30x50_WithVecFieldOnNodes.med --output-file=ttmp2_ --verbose=$verb
-mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=ttmp2_.xml --output-file=ttmp3_ --verbose=$verb
+ mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMesh_20x30x50_WithVecFieldOnCells.med --output-file=ttmp2_ --verbose=$verb
+ mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=tmp_testMesh_20x30x50_WithVecFieldOnNodes.med --output-file=ttmp2_ --verbose=$verb
+ mpirun -np 2 medpartitioner_para --ndomains=2 --input-file=ttmp2_.xml --output-file=ttmp3_ --verbose=$verb
-mpirun -np 4 medpartitioner_para --ndomains=4 --input-file=tmp_testMeshHuge_20x30x50_6.xml --output-file=ttmp3_ --verbose=1
+ mpirun -np 4 medpartitioner_para --ndomains=4 --input-file=tmp_testMeshHuge_20x30x50_6.xml --output-file=ttmp3_ --verbose=1
*/
-#include "MEDPARTITIONER_MESHCollection.hxx"
-//#include "MEDPARTITIONER_Topology.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
#include "MEDPARTITIONER_ParallelTopology.hxx"
#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+
#include "MEDLoader.hxx"
-#include "MEDPARTITIONER_utils.hxx"
#include <fstream>
#include <iostream>
#include <mpi.h>
#endif
-#ifdef BOOST_PROGRAM_OPTIONS_LIB
-#include <boost/program_options.hpp>
-namespace po=boost::program_options;
-#endif
-
using namespace std;
using namespace MEDPARTITIONER;
// Defining options
// by parsing the command line
- //bool xml_output_master=true;
+
bool split_family=false;
bool empty_groups=false;
bool mesure_memory=false;
int help=0;
int test=0;
MPI_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD, &MyGlobals::_world_size);
- MPI_Comm_rank(MPI_COMM_WORLD, &MyGlobals::_rank);
- //cout<<"proc "<<MyGlobals::_rank<<" of "<<MyGlobals::_world_size<<endl; //cvw for debug
- //testVectorOfStringMPI(); //cvw
- //testRandomize();
+ MPI_Comm_size(MPI_COMM_WORLD, &MyGlobals::_World_Size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &MyGlobals::_Rank);
+
+ //cout<<"proc "<<MyGlobals::_Rank<<" of "<<MyGlobals::_World_Size<<endl; //cvw for debug
+ //TestVectorOfStringMpi(); //cvw
+ //TestRandomize();
// Primitive parsing of command-line options
- string desc ("Available options of medpartitioner_para V1.0:\n"
+ string desc ("Available options of medpartitioner_para V1.0.3:\n"
"\t--help : produces this help message\n"
"\t--verbose : echoes arguments\n"
"\t--input-file=<string> : name of the input .med file or .xml master file\n"
#endif
#endif
"\t--creates-boundary-faces : creates boundary faces mesh in the output files\n"
- //"\t--family-splitting : preserves the family names instead of focusing on the groups\n"
"\t--dump-cpu-memory : dumps passed CPU time and maximal increase of used memory\n"
//"\t--randomize=<number> : random seed for other partitionning (only on one proc)\n"
//"\t--atomize : do the opposite of a good partitionner (only on one proc)\n"
if (argc<=1) help=1;
string value;
for (int i = 1; i < argc; i++)
- {
- if (strlen(argv[i]) < 3)
{
- if (MyGlobals::_rank==0) cerr << "bad argument : "<< argv[i] << endl;
- MPI_Finalize(); return 1;
- }
+ if (strlen(argv[i]) < 3)
+ {
+ if (MyGlobals::_Rank==0) cerr << "bad argument : "<< argv[i] << endl;
+ MPI_Finalize(); return 1;
+ }
- if (testArg(argv[i],"--verbose",value))
- {
- MyGlobals::_verbose=1;
- if (value!="") MyGlobals::_verbose = atoi(value.c_str());
+ if (TestArg(argv[i],"--verbose",value))
+ {
+ MyGlobals::_Verbose=1;
+ if (value!="") MyGlobals::_Verbose = atoi(value.c_str());
+ }
+ else if (TestArg(argv[i],"--help",value)) help=1;
+ else if (TestArg(argv[i],"--test",value)) test=1;
+ else if (TestArg(argv[i],"--input-file",value)) input=value;
+ else if (TestArg(argv[i],"--output-file",value)) output=value;
+ else if (TestArg(argv[i],"--split-method",value)) library=value;
+ else if (TestArg(argv[i],"--ndomains",value)) ndomains=atoi(value.c_str());
+ else if (TestArg(argv[i],"--randomize",value)) MyGlobals::_Randomize=atoi(value.c_str());
+ else if (TestArg(argv[i],"--atomize",value)) MyGlobals::_Atomize=atoi(value.c_str());
+ else if (TestArg(argv[i],"--creates-boundary-faces",value)) MyGlobals::_Creates_Boundary_Faces=1;
+ else if (TestArg(argv[i],"--dump-cpu-memory",value)) mesure_memory=true;
+ else
+ {
+ if (MyGlobals::_Rank==0) cerr << "unknown argument : "<< argv[i] << endl;
+ MPI_Finalize(); return 1;
+ }
}
- else if (testArg(argv[i],"--help",value)) help=1;
- else if (testArg(argv[i],"--test",value)) test=1;
- else if (testArg(argv[i],"--input-file",value)) input=value;
- else if (testArg(argv[i],"--output-file",value)) output=value;
- else if (testArg(argv[i],"--split-method",value)) library=value;
- //else if (testArg(argv[i],"--family-splitting",value)) split_family=true;
- else if (testArg(argv[i],"--ndomains",value)) ndomains=atoi(value.c_str());
- else if (testArg(argv[i],"--randomize",value)) MyGlobals::_randomize=atoi(value.c_str());
- else if (testArg(argv[i],"--atomize",value)) MyGlobals::_atomize=atoi(value.c_str());
- else if (testArg(argv[i],"--creates-boundary-faces",value)) MyGlobals::_creates_boundary_faces=1;
- //else if (testArg(argv[i],"--empty-groups",value)) empty_groups=true;
- else if (testArg(argv[i],"--dump-cpu-memory",value)) mesure_memory=true;
- else
- {
- if (MyGlobals::_rank==0) cerr << "unknown argument : "<< argv[i] << endl;
- MPI_Finalize(); return 1;
- }
- }
- if (MyGlobals::_randomize!=0 && MyGlobals::_world_size!=1)
- {
- if (MyGlobals::_rank==0) cerr << "randomize only available on 1 proc (mpirun -np 1)" << endl;
- MyGlobals::_randomize=0;
- }
+ if (MyGlobals::_Randomize!=0 && MyGlobals::_World_Size!=1)
+ {
+ if (MyGlobals::_Rank==0) cerr << "randomize only available on 1 proc (mpirun -np 1)" << endl;
+ MyGlobals::_Randomize=0;
+ }
#ifdef ENABLE_PARMETIS
#ifndef ENABLE_PTSCOTCH
#endif
if (help==1)
- {
- if (MyGlobals::_rank==0) cout<<desc<<"\n";
- MPI_Finalize(); return 0;
- }
+ {
+ if (MyGlobals::_Rank==0) cout<<desc<<"\n";
+ MPI_Finalize(); return 0;
+ }
- MyGlobals::_is0verbose=0;
- if (MyGlobals::_rank==0) MyGlobals::_is0verbose=MyGlobals::_verbose;
- //MyGlobals::_is0verbose=((MyGlobals::_rank==0) && MyGlobals::_verbose);
+ MyGlobals::_Is0verbose=0;
+ if (MyGlobals::_Rank==0) MyGlobals::_Is0verbose=MyGlobals::_Verbose;
+ //MyGlobals::_Is0verbose=((MyGlobals::_Rank==0) && MyGlobals::_Verbose);
if (test==1) //only for debugger
- {
- if (MyGlobals::_is0verbose>0) cout<<"tests on "<<MyGlobals::_atomize<<" "<<ndomains<<endl;
- //testPersistantMpi0To1(MyGlobals::_atomize, ndomains);
- //testPersistantMpiRing(MyGlobals::_atomize, ndomains);
- testPersistantMpiRingOnCommSplit(MyGlobals::_atomize, ndomains);
- //MPI_Barrier(MPI_COMM_WORLD);
- MPI_Finalize();
- return 0;
- testVectorOfStringMPI();
- testMapOfStringIntMPI();
- testMapOfStringVectorOfStringMPI();
- testDataArrayMPI();
- MPI_Finalize();
- return 1;
- }
+ {
+ if (MyGlobals::_Is0verbose>0) cout<<"tests on "<<MyGlobals::_Atomize<<" "<<ndomains<<endl;
+ //TestPersistantMpi0To1(MyGlobals::_Atomize, ndomains);
+ //TestPersistantMpiRing(MyGlobals::_Atomize, ndomains);
+ TestPersistantMpiRingOnCommSplit(MyGlobals::_Atomize, ndomains);
+ //MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Finalize();
+ return 0;
+ TestVectorOfStringMpi();
+ TestMapOfStringIntMpi();
+ TestMapOfStringVectorOfStringMpi();
+ TestDataArrayMpi();
+ MPI_Finalize();
+ return 1;
+ }
- if (MyGlobals::_is0verbose)
- {
- cout << "medpartitioner_para V1.0 :" << endl;
- cout << " input-file = " << input << endl;
- cout << " output-file = " << output << endl;
- cout << " split-method = " << library << endl;
- //cout << " family-splitting = " << split_family << endl;
- cout << " ndomains = " << ndomains << endl;
- //cout << " xml_output_master = " << xml_output_master << endl;
- cout << " creates_boundary_faces = " << MyGlobals::_creates_boundary_faces << endl;
- //cout << " empty_groups = " << empty_groups<< endl;
- cout << " dump-cpu-memory = " << mesure_memory<< endl;
- cout << " verbose = " << MyGlobals::_verbose << endl;
- //cout << " randomize = " << MyGlobals::_randomize << endl;
- cout << " verbose = " << MyGlobals::_verbose << endl;
- }
+ if (MyGlobals::_Is0verbose)
+ {
+ cout << "medpartitioner_para V1.0 :" << endl;
+ cout << " input-file = " << input << endl;
+ cout << " output-file = " << output << endl;
+ cout << " split-method = " << library << endl;
+ cout << " ndomains = " << ndomains << endl;
+ cout << " creates_boundary_faces = " << MyGlobals::_Creates_Boundary_Faces << endl;
+ cout << " dump-cpu-memory = " << mesure_memory<< endl;
+ cout << " verbose = " << MyGlobals::_Verbose << endl;
+ }
//testing whether it is possible to write a file at the specified location
- if (MyGlobals::_rank==0)
- {
- string outputtest = output + ".testioms.";
- ofstream testfile (outputtest.c_str());
- if (testfile.fail())
- {
- cerr << "output-file directory does not exist or is in read-only access" << endl;
- MPI_Finalize(); return 1;
+ if (MyGlobals::_Rank==0)
+ {
+ string outputtest = output + ".testioms.";
+ ofstream testfile (outputtest.c_str());
+ if (testfile.fail())
+ {
+ cerr << "output-file directory does not exist or is in read-only access" << endl;
+ MPI_Finalize(); return 1;
+ }
+ //deletes test file
+ remove(outputtest.c_str());
}
- //deletes test file
- remove(outputtest.c_str());
- }
// Beginning of the computation
// Loading the mesh collection
- if (MyGlobals::_is0verbose) cout << "Reading input files "<<endl;
+ if (MyGlobals::_Is0verbose) cout << "Reading input files "<<endl;
try
- {
- MEDPARTITIONER::ParaDomainSelector parallelizer(mesure_memory);
- MEDPARTITIONER::MESHCollection collection(input,parallelizer); //cvwat01
- MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology();
- aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector());
- //int nbfiles=MyGlobals::_fileMedNames->size(); //nb domains
- //to have unique valid fields names/pointers/descriptions for partitionning
- collection.prepareFieldDescriptions();
- //int nbfields=collection.getFieldDescriptions().size(); //on all domains
- //cout<<reprVectorOfString(collection.getFieldDescriptions());
-
- if (MyGlobals::_is0verbose)
{
- cout<<"fileNames :"<<endl
- <<reprVectorOfString(MyGlobals::_fileNames);
- cout<<"fieldDescriptions :"<<endl
- <<reprFieldDescriptions(collection.getFieldDescriptions()," "); //cvwat07
- cout<<"familyInfo :\n"
- <<reprMapOfStringInt(collection.getFamilyInfo())<<endl;
- cout<<"groupInfo :\n"
- <<reprMapOfStringVectorOfString(collection.getGroupInfo())<<endl;
- }
+ MEDPARTITIONER::ParaDomainSelector parallelizer(mesure_memory);
+ MEDPARTITIONER::MeshCollection collection(input,parallelizer); //cvwat01
+ MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology();
+ aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector());
+ //int nbfiles=MyGlobals::_fileMedNames->size(); //nb domains
+ //to have unique valid fields names/pointers/descriptions for partitionning
+ collection.prepareFieldDescriptions();
+ //int nbfields=collection.getFieldDescriptions().size(); //on all domains
+ //cout<<ReprVectorOfString(collection.getFieldDescriptions());
+
+ if (MyGlobals::_Is0verbose)
+ {
+ cout<<"fileNames :"<<endl
+ <<ReprVectorOfString(MyGlobals::_File_Names);
+ cout<<"fieldDescriptions :"<<endl
+ <<ReprFieldDescriptions(collection.getFieldDescriptions()," "); //cvwat07
+ cout<<"familyInfo :\n"
+ <<ReprMapOfStringInt(collection.getFamilyInfo())<<endl;
+ cout<<"groupInfo :\n"
+ <<ReprMapOfStringVectorOfString(collection.getGroupInfo())<<endl;
+ }
- // Creating the graph and partitioning it
- if (MyGlobals::_is0verbose) cout << "Computing partition "<<endl; //cvw
+ // Creating the graph and partitioning it
+ if (MyGlobals::_Is0verbose) cout << "Computing partition "<<endl; //cvw
- auto_ptr< MEDPARTITIONER::Topology > new_topo;
- if (library == "metis") //cvwat06
- new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::METIS));
- else
- new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH));
- parallelizer.evaluateMemory();
+ auto_ptr< MEDPARTITIONER::Topology > new_topo;
+ if (library == "metis") //cvwat06
+ new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::METIS));
+ else
+ new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH));
+ parallelizer.evaluateMemory();
- // Creating a new mesh collection from the partitioning
- if (MyGlobals::_is0verbose) cout << "Creating new meshes"<<endl; //cvwat04
- MEDPARTITIONER::MESHCollection new_collection(collection,new_topo.get(),split_family,empty_groups);
- //cout<<"proc "<<MyGlobals::_rank<<" : new_collection done"<<endl;
- parallelizer.evaluateMemory();
+ // Creating a new mesh collection from the partitioning
+ if (MyGlobals::_Is0verbose) cout << "Creating new meshes"<<endl; //cvwat04
+ MEDPARTITIONER::MeshCollection new_collection(collection,new_topo.get(),split_family,empty_groups);
+ //cout<<"proc "<<MyGlobals::_Rank<<" : new_collection done"<<endl;
+ parallelizer.evaluateMemory();
- //if (!xml_output_master) new_collection.setDriverType(MEDPARTITIONER::MedAscii);
- if (filter_face) new_collection.filterFaceOnCell();
+ //if (!xml_output_master) new_collection.setDriverType(MEDPARTITIONER::MedAscii);
+ if (filter_face) new_collection.filterFaceOnCell();
- //to get infos on all procs
+ //to get infos on all procs
- //see meshName
- vector<string> finalInformations;
- vector<string> r1,r2;
- r1=allgathervVectorOfString(MyGlobals::_generalInformations);
- //if (MyGlobals::_is0verbose>1000) cout << "generalInformations : \n"<<reprVectorOfString(r1);
- r2=selectTagsInVectorOfString(r1,"ioldDomain=");
- r2=selectTagsInVectorOfString(r2,"meshName=");
- if (r2.size()==(collection.getMesh()).size())
- {
- for (int i=0; i<r2.size(); i++) r2[i]=eraseTagSerialized(r2[i],"ioldDomain=");
- r2=deleteDuplicatesInVectorOfString(r2);
- if (r2.size()==1)
- {
- string finalMesh="finalMeshName="+extractFromDescription(r2[0], "meshName=");
- finalInformations.push_back(serializeFromString(finalMesh));
- }
- }
- if (finalInformations.size()==0)
- {
- if (MyGlobals::_rank==0)
- cerr<<"Problem on final meshName : set at 'Merge'"<<endl;
- finalInformations.push_back("finalMeshName=Merge");
- }
+ //see meshName
+ vector<string> finalInformations;
+ vector<string> r1,r2;
+ r1=AllgathervVectorOfString(MyGlobals::_General_Informations);
+ //if (MyGlobals::_Is0verbose>1000) cout << "generalInformations : \n"<<ReprVectorOfString(r1);
+ r2=SelectTagsInVectorOfString(r1,"ioldDomain=");
+ r2=SelectTagsInVectorOfString(r2,"meshName=");
+ if (r2.size()==(collection.getMesh()).size())
+ {
+ for (int i=0; i<r2.size(); i++) r2[i]=EraseTagSerialized(r2[i],"ioldDomain=");
+ r2=DeleteDuplicatesInVectorOfString(r2);
+ if (r2.size()==1)
+ {
+ string finalMesh="finalMeshName="+ExtractFromDescription(r2[0], "meshName=");
+ finalInformations.push_back(SerializeFromString(finalMesh));
+ }
+ }
+ if (finalInformations.size()==0)
+ {
+ if (MyGlobals::_Rank==0)
+ cerr<<"Problem on final meshName : set at 'Merge'"<<endl;
+ finalInformations.push_back("finalMeshName=Merge");
+ }
- //see field info nbComponents & componentInfo (if fields present)
- r2=selectTagsInVectorOfString(r1,"fieldName=");
- r2=selectTagsInVectorOfString(r2,"nbComponents=");
- //may be yes? or not?
- for (int i=0; i<r2.size(); i++) r2[i]=eraseTagSerialized(r2[i],"ioldFieldDouble=");
- r2=deleteDuplicatesInVectorOfString(r2);
- for (int i=0; i<r2.size(); i++) finalInformations.push_back(r2[i]);
+ //see field info nbComponents & componentInfo (if fields present)
+ r2=SelectTagsInVectorOfString(r1,"fieldName=");
+ r2=SelectTagsInVectorOfString(r2,"nbComponents=");
+ //may be yes? or not?
+ for (int i=0; i<r2.size(); i++) r2[i]=EraseTagSerialized(r2[i],"ioldFieldDouble=");
+ r2=DeleteDuplicatesInVectorOfString(r2);
+ for (int i=0; i<r2.size(); i++) finalInformations.push_back(r2[i]);
- MyGlobals::_generalInformations=finalInformations;
- if (MyGlobals::_is0verbose)
- cout << "generalInformations : \n"<<reprVectorOfString(finalInformations);
+ MyGlobals::_General_Informations=finalInformations;
+ if (MyGlobals::_Is0verbose)
+ cout << "generalInformations : \n"<<ReprVectorOfString(finalInformations);
- //new_collection.setSubdomainBoundaryCreates(creates_boundary_faces);
- if (MyGlobals::_is0verbose) cout << "Writing "<<ndomains<<" output files "<<output<<"xx.med"<<" and "<<output<<".xml"<<endl;
- new_collection.write(output);
+ //new_collection.setSubdomainBoundaryCreates(creates_boundary_faces);
+ if (MyGlobals::_Is0verbose) cout << "Writing "<<ndomains<<" output files "<<output<<"xx.med"<<" and "<<output<<".xml"<<endl;
+ new_collection.write(output);
- if ( mesure_memory )
- if ( parallelizer.isOnDifferentHosts() || MyGlobals::_rank==0 )
- {
- cout << "Elapsed time = " << parallelizer.getPassedTime()
- << ", max memory usage = " << parallelizer.evaluateMemory() << " KB"
- << endl;
- }
- // Casting the fields on the new collection
- // if (!mesh_only)
- // new_collection.castAllFields(*collection);
- MPI_Barrier(MPI_COMM_WORLD);
- if (MyGlobals::_is0verbose>0) cout<<"OK END"<< endl;
- MPI_Finalize();
- return 0;
- }
+ if ( mesure_memory )
+ if ( parallelizer.isOnDifferentHosts() || MyGlobals::_Rank==0 )
+ {
+ cout << "Elapsed time = " << parallelizer.getPassedTime()
+ << ", max memory usage = " << parallelizer.evaluateMemory() << " KB"
+ << endl;
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (MyGlobals::_Is0verbose>0) cout<<"OK END"<< endl;
+ MPI_Finalize();
+ return 0;
+ }
catch(const char *mess)
- {
- cerr<<"proc "<<MyGlobals::_rank<<" : "<<mess<<endl;
- fflush(stderr);
- MPI_Finalize();
- return 1;
- }
+ {
+ cerr<<"proc "<<MyGlobals::_Rank<<" : "<<mess<<endl;
+ fflush(stderr);
+ MPI_Finalize();
+ return 1;
+ }
catch(INTERP_KERNEL::Exception& e)
- {
- cerr<<"proc "<<MyGlobals::_rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
- fflush(stderr);
- MPI_Finalize();
- return 1;
- }
+ {
+ cerr<<"proc "<<MyGlobals::_Rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
+ fflush(stderr);
+ MPI_Finalize();
+ return 1;
+ }
catch(std::exception& e)
- {
- cerr<<"proc "<<MyGlobals::_rank<<" : std_Exception : "<<e.what()<<endl;
- fflush(stderr);
- MPI_Finalize();
- return 1;
- }
+ {
+ cerr<<"proc "<<MyGlobals::_Rank<<" : std_Exception : "<<e.what()<<endl;
+ fflush(stderr);
+ MPI_Finalize();
+ return 1;
+ }
catch(...)
- {
- cerr<<"proc "<<MyGlobals::_rank<<" : an unknown type exception error was occured"<<endl;
- fflush(stderr);
- MPI_Finalize();
- return 1;
- }
+ {
+ cerr<<"proc "<<MyGlobals::_Rank<<" : an unknown type exception error was occured"<<endl;
+ fflush(stderr);
+ MPI_Finalize();
+ return 1;
+ }
}