using namespace MEDPARTITIONER;
-Graph::Graph(MEDPARTITIONER::MEDSKYLINEARRAY* array, int* edgeweight):m_graph(array),m_partition(0),m_edgeweight(edgeweight),m_cellweight(0)
+Graph::Graph(MEDPARTITIONER::MEDSKYLINEARRAY* array, int* edgeweight):_graph(array),_partition(0),_edgeweight(edgeweight),_cellweight(0)
{
}
Graph::~Graph()
{
- if (m_partition)
+ if (_partition)
{
- delete m_partition;
- m_partition=0;
+ delete _partition;
+ _partition=0;
}
- if (m_graph)
+ if (_graph)
{
- delete m_graph;
- m_graph=0;
+ delete _graph;
+ _graph=0;
}
}
virtual ~Graph();
- void setEdgesWeights(int* edgeweight){m_edgeweight=edgeweight;}
- void setVerticesWeights(int* cellweight){m_cellweight=cellweight;}
+ 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
- const int* getPart() const {return m_partition->getValue();}
+ const int* getPart() const {return _partition->getValue();}
//! returns the number of graph vertices (which can correspond to the cells in the mesh!)
- int nbVertices() const {return m_graph->getNumberOf();}
+ int nbVertices() const {return _graph->getNumberOf();}
- const MEDPARTITIONER::MEDSKYLINEARRAY* getGraph() const {return m_graph;}
+ const MEDPARTITIONER::MEDSKYLINEARRAY* getGraph() const {return _graph;}
protected:
- MEDPARTITIONER::MEDSKYLINEARRAY* m_graph;
+ MEDPARTITIONER::MEDSKYLINEARRAY* _graph;
- MEDPARTITIONER::MEDSKYLINEARRAY* m_partition;
+ MEDPARTITIONER::MEDSKYLINEARRAY* _partition;
- int* m_edgeweight;
+ int* _edgeweight;
- int* m_cellweight;
+ int* _cellweight;
};
}
--- /dev/null
+#include "MEDPARTITIONER_JointFinder.hxx"
+#include "MEDPARTITIONER_MESHCollection.hxx"
+#include "MEDPARTITIONER_Topology.hxx"
+#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "BBTree.txx"
+
+
+/*! 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())
+{
+}
+
+void JointFinder::findCommonDistantNodes()
+{
+ int nbdomain=_topology->nbDomain();
+ _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);
+ }
+ int nbproc=_domain_selector->nbProcs();
+ std::vector<BBTree<3>* > bbtree(nbdomain);
+ std::vector<ParaMEDMEM::DataArrayInt*> rev(nbdomain);
+ std::vector<ParaMEDMEM::DataArrayInt*>revIndx(nbdomain);
+ int meshDim;
+ int spaceDim;
+
+ 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;
+ }
+ bbtree[mydomain]=new BBTree<3> (bbx,0,0,myMesh->getNumberOfNodes(),-1e-12);
+ }
+
+ 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);
+
+ std::vector<double> vec(spaceDim*sourceMesh->getNumberOfNodes());
+ std::copy(sourceMesh->getCoords()->getConstPointer(),sourceMesh->getCoords()->getConstPointer()+sourceMesh->getNumberOfNodes()*spaceDim,&vec[0]);
+ _domain_selector->sendDoubleVec (vec,targetProc);
+
+ //retrieving target data for storage in commonDistantNodes array
+ std::vector<int> localCorrespondency;
+ _domain_selector->recvIntVec(localCorrespondency, targetProc);
+ 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]));
+
+ }
+ if (_domain_selector->isMyDomain(itarget))
+ {
+ //receiving data from source proc
+ int sourceProc = isource%nbproc;
+ std::vector<double> recvVec;
+ _domain_selector->recvDoubleVec(recvVec,sourceProc);
+ std::map<int,int> commonNodes; // (local nodes, distant nodes) list
+ 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));
+ }
+ 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);
+ nodeCellCorrespondency.push_back(revPtr[icell]);
+ }
+ }
+ _domain_selector->sendIntVec(nodeCellCorrespondency, sourceProc);
+ }
+ }
+
+}
+std::vector<std::vector<std::multimap<int,int> > > & JointFinder::getDistantNodeCell()
+{
+ return _distant_node_cell;
+}
+
+std::vector<std::vector<std::vector<std::pair<int,int> > > >& JointFinder::getNodeNode()
+{
+ return _node_node;
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __MEDPARTITIONER_JOINTFINDER_HXX__
+#define __MEDPARTITIONER_JOINTFINDER_HXX__
+
+#include <vector>
+#include <map>
+namespace MEDPARTITIONER {
+ class MESHCollection;
+ class ParaDomainSelector;
+ class Topology;
+class JointFinder
+{
+public:
+ JointFinder(const MESHCollection& mc);
+ void findCommonDistantNodes();
+ std::vector<std::vector<std::multimap<int,int> > >& getDistantNodeCell();
+ std::vector<std::vector<std::vector<std::pair<int,int> > > >& getNodeNode();
+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;
+};
+};
+#endif
ParaDomainSelector* parallelizer)
{
// number of graph vertices
- int n = m_graph->getNumberOf();
+ int n = _graph->getNumberOf();
//graph
- int * xadj=const_cast<int*>(m_graph->getIndex());
- int * adjncy = const_cast<int*>(m_graph->getValue());
+ int * xadj=const_cast<int*>(_graph->getIndex());
+ int * adjncy = const_cast<int*>(_graph->getValue());
//constraints
- int * vwgt=m_cellweight;
- int * adjwgt=m_edgeweight;
- int wgtflag=(m_edgeweight!=0)?1:0+(m_cellweight!=0)?2:0;
+ int * vwgt=_cellweight;
+ int * adjwgt=_edgeweight;
+ int wgtflag=(_edgeweight!=0)?1:0+(_cellweight!=0)?2:0;
//base 0 or 1
int base=0;
// the fifth argument true specifies that only the pointers are passed
//to the object
- m_partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
+ _partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
}
using namespace MEDPARTITIONER;
//empty constructor
-ParallelTopology::ParallelTopology():m_nb_domain(0),m_mesh_dimension(0)
+ParallelTopology::ParallelTopology():_nb_domain(0),_mesh_dimension(0)
{}
//!constructing topology according to mesh collection
const vector<MEDPARTITIONER::CONNECTZONE*>& cz,
vector<int*>& cellglobal,
vector<int*>& nodeglobal,
- vector<int*>& faceglobal):m_nb_domain(meshes.size())/*,m_mesh_dimension(meshes[0]->getMeshDimension())*/
+ vector<int*>& faceglobal):_nb_domain(meshes.size())/*,_mesh_dimension(meshes[0]->getMeshDimension())*/
{
int index_global=0;
int index_node_global=0;
int index_face_global=0;
- m_nb_cells.resize(m_nb_domain);
- m_nb_nodes.resize(m_nb_domain);
- // m_nb_faces.resize(m_nb_domain);
+ _nb_cells.resize(_nb_domain);
+ _nb_nodes.resize(_nb_domain);
+ // _nb_faces.resize(_nb_domain);
- m_loc_to_glob.resize(m_nb_domain);
- m_node_loc_to_glob.resize(m_nb_domain);
- // m_face_loc_to_glob.resize(m_nb_domain);
+ _loc_to_glob.resize(_nb_domain);
+ _node_loc_to_glob.resize(_nb_domain);
+ // _face_loc_to_glob.resize(_nb_domain);
//MED_EN::medEntityMesh constituent_entity;
bool parallel_mode = false;
- for (int idomain=0; !parallel_mode && idomain<m_nb_domain; idomain++)
+ for (int idomain=0; !parallel_mode && idomain<_nb_domain; idomain++)
parallel_mode = (!meshes[idomain]);
- for (int idomain=0; idomain<m_nb_domain; idomain++)
+ for (int idomain=0; idomain<_nb_domain; idomain++)
{
if ( !meshes[idomain] )
continue;
- m_mesh_dimension = meshes[idomain]->getMeshDimension();
- //constituent_entity = (m_mesh_dimension == 3 ? MED_EN::MED_FACE : MED_EN::MED_EDGE );
+ _mesh_dimension = meshes[idomain]->getMeshDimension();
+ //constituent_entity = (_mesh_dimension == 3 ? MED_EN::MED_FACE : MED_EN::MED_EDGE );
//creating cell maps
- m_nb_cells[idomain]=meshes[idomain]->getNumberOfCells();
- // cout << "Nb cells (domain "<<idomain<<") = "<<m_nb_cells[idomain];
- m_loc_to_glob[idomain].resize(m_nb_cells[idomain]);
+ _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)
{
MESSAGE_MED("Creating global numbering");
//creating global numbering from scratch
- for (int i=0; i<m_nb_cells[idomain]; i++)
+ for (int i=0; i<_nb_cells[idomain]; i++)
{
- m_glob_to_loc.insert(make_pair(index_global,make_pair(idomain,i+1)));
- m_loc_to_glob[idomain][i]=index_global;
+ _glob_to_loc.insert(make_pair(index_global,make_pair(idomain,i+1)));
+ _loc_to_glob[idomain][i]=index_global;
// cout<<"glob:"<<index_global<<" --> ("<<idomain<<","<<i+1<<")"<<endl;
index_global++;
}
else
{
MESSAGE_MED("Using former global numbering");
- for (int i=0; i<m_nb_cells[idomain]; i++)
+ for (int i=0; i<_nb_cells[idomain]; i++)
{
int global=cellglobal[idomain][i];
- m_glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
- //m_loc_to_glob[make_pair(idomain,i+1)]=global;
- m_loc_to_glob[idomain][i]=global;
+ _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 (m_nb_domain==1)
+ if (_nb_domain==1)
{
- m_nb_total_cells=index_global;
- m_nb_cells[0]=index_global;
- m_node_loc_to_glob[idomain].resize(meshes[idomain]->getNumberOfNodes());
+ _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++)
{
- m_node_glob_to_loc.insert(make_pair(i,make_pair(0,i)));
- m_node_loc_to_glob[0][i]=i;
+ _node_glob_to_loc.insert(make_pair(i,make_pair(0,i)));
+ _node_loc_to_glob[0][i]=i;
}
- m_nb_total_nodes=meshes[idomain]->getNumberOfNodes();
- m_nb_nodes[0]=m_nb_total_nodes;
+ _nb_total_nodes=meshes[idomain]->getNumberOfNodes();
+ _nb_nodes[0]=_nb_total_nodes;
- MESSAGE_MED ("nb total cells "<< m_nb_total_cells);
- MESSAGE_MED("nb total nodes "<< m_nb_total_nodes);
+ MESSAGE_MED ("nb total cells "<< _nb_total_cells);
+ MESSAGE_MED("nb total nodes "<< _nb_total_nodes);
return;
}
//creating node maps
- m_nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
+ _nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
INTERP_KERNEL::HashMap <int,pair<int,int> > local2distant;
- m_node_loc_to_glob[idomain].resize(m_nb_nodes[idomain]);
+ _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]);
for (int icz=0; icz<cz.size(); icz++)
{
if (cz[icz]->getLocalDomainNumber() == idomain &&
// setting mappings for all nodes
if (nodeglobal[idomain]==0)
{
- for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
+ for (int inode=0; inode<_nb_nodes[idomain]; inode++)
{
if (local2distant.find(inode)==local2distant.end())
{
index_node_global++;
- m_node_glob_to_loc.insert(make_pair(index_node_global,make_pair(idomain,inode)));
- //m_node_loc_to_glob[make_pair(idomain,inode+1)]=index_node_global;
- m_node_loc_to_glob[idomain][inode]=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=m_loc_to_glob[ip][distant];
- m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode)));
- m_node_loc_to_glob[idomain][inode]=global_number;
+ 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<m_nb_nodes[idomain]; inode++)
+ for (int inode=0; inode<_nb_nodes[idomain]; inode++)
{
int global_number=nodeglobal[idomain][inode];
- m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode)));
- m_node_loc_to_glob[idomain][inode]=global_number;
+ _node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode)));
+ _node_loc_to_glob[idomain][inode]=global_number;
}
}
}
- m_nb_total_cells=index_global;
- m_nb_total_nodes=index_node_global;
- m_nb_total_faces=index_face_global;
- SCRUTE_MED(m_nb_total_cells);
- SCRUTE_MED(m_nb_total_faces);
- SCRUTE_MED(m_nb_total_nodes);
+ _nb_total_cells=index_global;
+ _nb_total_nodes=index_node_global;
+ _nb_total_faces=index_face_global;
+ SCRUTE_MED(_nb_total_cells);
+ SCRUTE_MED(_nb_total_faces);
+ SCRUTE_MED(_nb_total_nodes);
}
//!constructing ParallelTopology from an old topology and a graph
ParallelTopology::ParallelTopology(Graph* graph, int nb_domain, int mesh_dimension):
- m_nb_domain(nb_domain),
- m_nb_cells(graph->nbVertices()),
- m_mesh_dimension(mesh_dimension)
+ _nb_domain(nb_domain),
+ _nb_cells(graph->nbVertices()),
+ _mesh_dimension(mesh_dimension)
{
- m_nb_cells.resize(m_nb_domain);
- m_nb_nodes.resize(m_nb_domain);
- m_nb_faces.resize(m_nb_domain);
+ _nb_cells.resize(_nb_domain);
+ _nb_nodes.resize(_nb_domain);
+ _nb_faces.resize(_nb_domain);
- m_loc_to_glob.resize(m_nb_domain);
- m_node_loc_to_glob.resize(m_nb_domain);
- m_face_loc_to_glob.resize(m_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
- m_cell_loc_to_glob_fuse.resize(m_nb_domain);
- m_face_loc_to_glob_fuse.resize(m_nb_domain);
+ _cell_loc_to_glob_fuse.resize(_nb_domain);
+ _face_loc_to_glob_fuse.resize(_nb_domain);
- for (int i=0; i<m_nb_domain; i++)
- m_nb_cells[i]=0;
+ for (int i=0; i<_nb_domain; i++)
+ _nb_cells[i]=0;
const int* part = graph-> getPart();
- m_nb_total_cells= graph->nbVertices();
+ _nb_total_cells= graph->nbVertices();
- for (int icell=0; icell<m_nb_total_cells; icell++)
+ for (int icell=0; icell<_nb_total_cells; icell++)
{
int idomain = part[icell];
- m_nb_cells[idomain]++;
- //m_loc_to_glob[make_pair(idomain,m_nb_cells[idomain])]=icell+1;
- m_loc_to_glob[idomain].push_back(icell);
- m_glob_to_loc.insert(make_pair(icell,make_pair(idomain,m_nb_cells[idomain])));
+ _nb_cells[idomain]++;
+ //_loc_to_glob[make_pair(idomain,_nb_cells[idomain])]=icell+1;
+ _loc_to_glob[idomain].push_back(icell);
+ _glob_to_loc.insert(make_pair(icell,make_pair(idomain,_nb_cells[idomain])));
}
- for (int idomain=0; idomain<m_nb_domain; idomain++)
- MESSAGE_MED("Nombre de cellules dans le domaine "<< idomain <<" : "<<m_nb_cells[idomain]);
+ for (int idomain=0; idomain<_nb_domain; idomain++)
+ MESSAGE_MED("Nombre de cellules dans le domaine "<< idomain <<" : "<<_nb_cells[idomain]);
- SCRUTE_MED(m_nb_total_cells);
+ SCRUTE_MED(_nb_total_cells);
}
* */
void ParallelTopology::convertGlobalNodeList(const int* node_list, int nbnode, int* local, int* ip)
{
- if (m_node_glob_to_loc.empty())
+ if (_node_glob_to_loc.empty())
throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - Node mapping has not yet been built");
for (int i=0; i< nbnode; i++)
{
- pair<int,int> local_node = m_node_glob_to_loc.find(node_list[i])->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;
}
* */
void ParallelTopology::convertGlobalNodeList(const int* node_list, int nbnode, int* local, int ip)
{
- if (m_node_glob_to_loc.empty())
+ if (_node_glob_to_loc.empty())
throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - 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=m_node_glob_to_loc.equal_range(node_list[i]);
+ 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;
* */
void ParallelTopology::convertGlobalNodeListWithTwins(const int* node_list, int nbnode, int*& local, int*& ip,int*& full_array, int& size)
{
- if (m_node_glob_to_loc.empty())
+ if (_node_glob_to_loc.empty())
throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - Node mapping has not yet been built");
size=0;
for (int i=0; i< nbnode; i++)
{
- int count= m_node_glob_to_loc.count(node_list[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;
for (int i=0; i< nbnode; i++)
{
typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(node_list[i]);
+ 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;
size=0;
for (int i=0; i< nbface; i++)
{
- //int count = m_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+= m_face_glob_to_loc.count(face_list[i]);
+ size+= _face_glob_to_loc.count(face_list[i]);
}
int index=0;
ip=new int[size];
for (int i=0; i< nbface; i++)
{
typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=m_face_glob_to_loc.equal_range(face_list[i]);
+ 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;
{
for (int i=0; i< nbcell; i++)
{
- INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = m_glob_to_loc.find(cell_list[i]);
+ INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = _glob_to_loc.find(cell_list[i]);
ip[i]=(iter->second).first;
local[i]=(iter->second).second;
}
{
for (int i=0; i< nbface; i++)
{
- INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = m_face_glob_to_loc.find(face_list[i]);
- if (iter == m_face_glob_to_loc.end())
+ 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 MED_EXCEPTION("convertGlobalFaceList - Face not found");
}
for (int i=0; i< nbface; i++)
{
typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
- pair<mmiter,mmiter> range=m_face_glob_to_loc.equal_range(face_list[i]);
+ 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;
// 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=m_node_glob_to_loc.equal_range(global);
+ 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)
int ParallelTopology::getMaxGlobalFace() const
{
int max = 0;
- TGlob2LocsMap::const_iterator g_l_l = m_face_glob_to_loc.begin();
- for ( ; g_l_l != m_face_glob_to_loc.end(); ++g_l_l )
+ TGlob2LocsMap::const_iterator g_l_l = _face_glob_to_loc.begin();
+ for ( ; g_l_l != _face_glob_to_loc.end(); ++g_l_l )
if ( g_l_l->first > max )
max = g_l_l->first;
return max;
//!converting node local numbering to global
inline int convertNodeToGlobal(int ip,int icell) const
{
- //return m_node_loc_to_glob.find(make_pair(ip,icell))->second;
- return m_node_loc_to_glob[ip][icell];
+ //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
{
- // if (m_face_loc_to_glob.find(make_pair(ip,icell))==m_face_loc_to_glob.end())
+ // if (_face_loc_to_glob.find(make_pair(ip,icell))==_face_loc_to_glob.end())
// return -1;
// else
- //return m_face_loc_to_glob.find(make_pair(ip,icell))->second;
- return m_face_loc_to_glob[ip][iface];
+ //return _face_loc_to_glob.find(make_pair(ip,icell))->second;
+ return _face_loc_to_glob[ip][iface];
}
//converting cell global numbering to local
inline int convertCellToGlobal(int ip,int icell) const
{
- // if (m_loc_to_glob.find(make_pair(ip,icell))==m_loc_to_glob.end())
+ // if (_loc_to_glob.find(make_pair(ip,icell))==_loc_to_glob.end())
// return -1;
// else
- //return m_loc_to_glob.find(make_pair(ip,icell))->second;
- return m_loc_to_glob[ip][icell];
+ //return _loc_to_glob.find(make_pair(ip,icell))->second;
+ return _loc_to_glob[ip][icell];
}
inline void convertNodeToGlobal(int ip, const int* local, int n, int* global)const
{
for (int i=0; i<n; i++)
- global[i]=m_node_loc_to_glob[ip][local[i]];
+ global[i]=_node_loc_to_glob[ip][local[i]];
}
inline void convertCellToGlobal(int ip, const int* local, int n, int* global)const
{
for (int i=0; i<n; i++)
- global[i]=m_loc_to_glob[ip][local[i]];
+ global[i]=_loc_to_glob[ip][local[i]];
}
inline void convertFaceToGlobal(int ip, const int* local, int n, int* global)const
{
for (int i=0; i<n; i++)
- global[i]=m_face_loc_to_glob[ip][local[i]];
+ global[i]=_face_loc_to_glob[ip][local[i]];
}
inline int nbDomain() const
{
- return m_nb_domain;
+ return _nb_domain;
}
int nbCells() const
{
- return m_nb_total_cells;
+ return _nb_total_cells;
}
int nbNodes() const
- {return m_nb_total_nodes;}
+ {return _nb_total_nodes;}
inline int nbCells( int idomain) const
{
- return m_nb_cells[idomain];
+ return _nb_cells[idomain];
}
//!retrieving number of nodes
inline int getNodeNumber(int idomain) const
{
- return m_nb_nodes[idomain];
+ return _nb_nodes[idomain];
}
inline int getNodeNumber() const
{
- if (m_node_glob_to_loc.empty()) return 0;
+ if (_node_glob_to_loc.empty()) return 0;
std::set <int> keys;
- for (INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator iter= m_node_glob_to_loc.begin();
- iter!=m_node_glob_to_loc.end();
+ for (INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator iter= _node_glob_to_loc.begin();
+ iter!=_node_glob_to_loc.end();
iter++) {
keys.insert(iter->first);
}
//!retrieving list of nodes in global numbers
inline void getNodeList(int idomain, int* list) const
{
- for (int i=0; i<m_nb_nodes[idomain];i++)
- list[i]=m_node_loc_to_glob[idomain][i];
+ 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
std::vector<int> & getFusedCellNumbers(int idomain)
{
- return m_cell_loc_to_glob_fuse[idomain];
+ return _cell_loc_to_glob_fuse[idomain];
}
const std::vector<int> & getFusedCellNumbers(int idomain) const
{
- return m_cell_loc_to_glob_fuse[idomain];
+ return _cell_loc_to_glob_fuse[idomain];
}
//!< retrieving face numbers after fusing in parallel mode
std::vector<int> & getFusedFaceNumbers(int idomain)
{
- return m_face_loc_to_glob_fuse[idomain];
+ return _face_loc_to_glob_fuse[idomain];
}
const std::vector<int> & getFusedFaceNumbers(int idomain) const
{
- return m_face_loc_to_glob_fuse[idomain];
+ return _face_loc_to_glob_fuse[idomain];
}
//!retrieving number of nodes
inline int getCellNumber(int idomain) const
{
- return m_nb_cells[idomain];
+ return _nb_cells[idomain];
}
inline int getCellDomainNumber(int global) const
{
- return (m_glob_to_loc.find(global)->second).first;
+ return (_glob_to_loc.find(global)->second).first;
}
//!retrieving list of nodes in global numbers
inline void getCellList(int idomain, int* list) const
{
- for (int i=0; i<m_nb_cells[idomain];i++)
- list[i]=m_loc_to_glob[idomain][i];
+ for (int i=0; i<_nb_cells[idomain];i++)
+ list[i]=_loc_to_glob[idomain][i];
}
inline int getFaceNumber(int idomain) const
{
- return m_nb_faces[idomain];
+ return _nb_faces[idomain];
}
inline int getFaceNumber() const
{
- if (m_face_glob_to_loc.empty()) return 0;
+ if (_face_glob_to_loc.empty()) return 0;
std::set <int> keys;
- for (INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator iter= m_face_glob_to_loc.begin();
- iter!=m_face_glob_to_loc.end();
+ for (INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator iter= _face_glob_to_loc.begin();
+ iter!=_face_glob_to_loc.end();
iter++) {
keys.insert(iter->first);
}
//!retrieving list of faces in global numbers
inline void getFaceList(int idomain, int* list) const
{
- for (int i=0; i<m_nb_faces[idomain];i++)
- list[i]=m_face_loc_to_glob[idomain][i];
+ 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)
inline std::pair<int,int> convertGlobalCell(int iglobal) const
{
- return m_glob_to_loc.find(iglobal)->second;
+ return _glob_to_loc.find(iglobal)->second;
}
inline int convertGlobalFace(int iglobal, int idomain)
{
typedef INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator MMiter;
- std::pair<MMiter,MMiter> eq = m_face_glob_to_loc.equal_range(iglobal);
+ std::pair<MMiter,MMiter> eq = _face_glob_to_loc.equal_range(iglobal);
for (MMiter it=eq.first; it != eq.second; it++)
if (it->second.first == idomain) return it->second.second;
return -1;
inline int convertGlobalNode(int iglobal, int idomain)
{
typedef INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator MMiter;
- std::pair<MMiter,MMiter> eq = m_node_glob_to_loc.equal_range(iglobal);
+ 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;
//!adding a face to the topology
inline void appendFace(int idomain, int ilocal, int iglobal)
{
- m_face_loc_to_glob[idomain].push_back(iglobal);
- m_face_glob_to_loc.insert(std::make_pair(iglobal,std::make_pair(idomain,ilocal)));
+ _face_loc_to_glob[idomain].push_back(iglobal);
+ _face_glob_to_loc.insert(std::make_pair(iglobal,std::make_pair(idomain,ilocal)));
}
//return max global face number
//!mapping global -> local
typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2DomainLoc;
- TGlob2DomainLoc m_glob_to_loc;
+ TGlob2DomainLoc _glob_to_loc;
- std::vector<std::vector<int> > m_loc_to_glob;
+ std::vector<std::vector<int> > _loc_to_glob;
- INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > m_node_glob_to_loc;
+ INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > _node_glob_to_loc;
//!mapping local -> global
- std::vector<std::vector <int> > m_node_loc_to_glob;
+ std::vector<std::vector <int> > _node_loc_to_glob;
// global numbers in parallel mode
- std::vector<std::vector <int> > m_cell_loc_to_glob_fuse; // glob nums after fusing
- std::vector<std::vector <int> > m_face_loc_to_glob_fuse; // glob nums after fusing
+ 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
//!mapping global -> local
typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2LocsMap;
- TGlob2LocsMap m_face_glob_to_loc;
+ TGlob2LocsMap _face_glob_to_loc;
//!mapping local -> global
- std::vector<std::vector <int> > m_face_loc_to_glob;
+ std::vector<std::vector <int> > _face_loc_to_glob;
- std::vector<int> m_nb_cells;
+ std::vector<int> _nb_cells;
- std::vector<int> m_nb_nodes;
+ std::vector<int> _nb_nodes;
- std::vector<int> m_nb_faces;
+ std::vector<int> _nb_faces;
- int m_nb_total_cells;
+ int _nb_total_cells;
- int m_nb_total_nodes;
+ int _nb_total_nodes;
- int m_nb_total_faces;
+ int _nb_total_faces;
- int m_nb_domain;
+ int _nb_domain;
- int m_mesh_dimension;
+ int _mesh_dimension;
};
void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* sel)
{
// number of graph vertices
- int n = m_graph->getNumberOf();
+ int n = _graph->getNumberOf();
//graph
- int * xadj=const_cast<int*>(m_graph->getIndex());
- int * adjncy = const_cast<int*>(m_graph->getValue());
+ int * xadj=const_cast<int*>(_graph->getIndex());
+ int * adjncy = const_cast<int*>(_graph->getValue());
//ndomain
int nparts = ndomain;
n, // nb of graph nodes
xadj,
0,
- m_cellweight, //graph vertices loads
+ _cellweight, //graph vertices loads
0,
xadj[n], // number of edges
adjncy,
- m_edgeweight);
+ _edgeweight);
SCOTCH_Strat scotch_strategy;
SCOTCH_stratInit(&scotch_strategy);
// the fifth argument true specifies that only the pointers are passed
//to the object
- m_partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
+ _partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
}
SCOTCHGraph(MEDPARTITIONER::MEDSKYLINEARRAY*, int* edgeweight=0);
virtual ~SCOTCHGraph();
void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0);
- //private:
- // const MEDMEM::MEDSKYLINEARRAY* m_graph;
};
}
#endif /*SCOTCHGRAPH_HXX_*/
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "MEDMEM_SkyLineArray.hxx"
-#include "MEDMEM_ConnectZone.hxx"
-#include "MEDMEM_DriversDef.hxx"
-#include "MEDMEM_Mesh.hxx"
-#include "MEDMEM_Exception.hxx"
-
-#include "MEDPARTITIONER_Topology.hxx"
-#include "MEDPARTITIONER_SequentialTopology.hxx"
-
-using namespace MEDPARTITIONER;
-
-SequentialTopology::SequentialTopology(){throw MEDEXCEPTION("SequentialTopology - not implemented yet");}
-
-SequentialTopology::SequentialTopology(std::vector<MEDMEM::MESH*>, std::vector<MEDMEM::CONNECTZONE*>){throw MEDEXCEPTION("SequentialTopology - not implemented yet");}
-
-//!converts a list of global cell numbers
-//!to a distributed array with local cell numbers
-void SequentialTopology::convertGlobalNodeList(const int*, int,int*,int*){}
-
-//!converts a list of global node numbers
-//!to a distributed array with local cell numbers
-void SequentialTopology::convertGlobalCellList(const int*, int , int*, int *){}
-
-//number of doamins
-int SequentialTopology::nbDomain() const
-{
- return 0;
-}
-
-//number of cells
-int SequentialTopology::nbCells() const
-{
- return 0;
-}
-
-//number of cells on a specific domain
-int SequentialTopology::nbCells(int idomain) const
-{
- return 0;
-}
-
-//!creating node mapping
-void SequentialTopology::createNodeMapping(vector<int*> type_connectivity,int* present_type_numbers, int idomain){}
-
-//!converting node global numberings to local numberings
-void SequentialTopology::convertToLocal(vector<int*> type_connectivity,int* present_type_numbers){}
-
-//!retrieving number of nodes
-int SequentialTopology::getNodeNumber(int idomain) const
-{
- return 0;
-}
-
-//!retrieving list of nodes
-void SequentialTopology::getNodeList(int idomain, int* list) const{}
-
-//!retrieving number of cells
-int SequentialTopology::getCellNumber(int idomain) const
-{
- return 0;
-}
-
-//!retrieving list of cells
-void SequentialTopology::getCellList(int idomain, int* list) const{}
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef SequentialTOPOLOGY_HXX_
-#define SequentialTOPOLOGY_HXX_
-
-#include "MEDPARTITIONER.hxx"
-
-namespace MEDPARTITIONER {
- class SequentialTopology:public Topology
- {
-
- public:
-
- SequentialTopology();
- SequentialTopology(std::vector<ParaMEDMEM::MEDCouplingUMesh*>, std::vector<MEDPARTITIONER::CONNECTZONE*>);
-
- //!converts a list of global cell numbers
- //!to a distributed array with local cell numbers
- void convertGlobalNodeList(const int*, int,int*,int*);
-
- //!converts a list of global node numbers
- //!to a distributed array with local cell numbers
- void convertGlobalCellList(const int*, int , int*, int *);
-
- //number of doamins
- int nbDomain() const;
-
- //number of cells
- int nbCells() const;
-
- //number of cells on a specific domain
- int nbCells(int idomain) const;
-
- //!creating node mapping
- void createNodeMapping(vector<int*> type_connectivity,int* present_type_numbers, int idomain);
-
- //!converting node global numberings to local numberings
- void convertToLocal(vector<int*> type_connectivity,int* present_type_numbers);
-
- //!retrieving number of nodes
- int getNodeNumber(int idomain) const ;
-
- //!retrieving list of nodes
- void getNodeList(int idomain, int* list) const;
-
- //!retrieving number of cells
- int getCellNumber(int idomain) const ;
-
- //!retrieving list of cells
- void getCellList(int idomain, int* list) const;
-
- private:
- //!mapping global -> local
- map<int,pair<int,int> > m_glob_to_loc;
-
- //!mapping local -> global
- map<pair<int,int>,int> m_loc_to_glob;
-
- //!mapping global -> local
- multimap<int,pair<int,int> > m_node_glob_to_loc;
-
- //!mapping local -> global
- map<pair<int,int>,int> m_node_loc_to_glob;
-
- vector<int> m_nb_cells;
-
- vector<int> m_nb_nodes;
-
- int m_nb_total_cells;
-
- int m_nb_total_nodes;
- };
-}
-#endif /*SequentialTOPOLOGY_HXX_*/
value[i]=partition[i];
}
- m_partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
+ _partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
}