1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include "MEDSPLITTER_Graph.hxx"
25 #include "MEDSPLITTER_SCOTCHGraph.hxx"
27 using namespace MEDSPLITTER;
29 SCOTCHGraph::SCOTCHGraph():Graph()
33 SCOTCHGraph::SCOTCHGraph(MEDMEM::MEDSKYLINEARRAY* graph, int* edgeweight):Graph(graph,edgeweight)
37 SCOTCHGraph::~SCOTCHGraph()
41 void SCOTCHGraph::partGraph(int ndomain, const string& options_string, ParaDomainSelector* sel)
43 // number of graph vertices
44 int n = m_graph->getNumberOf();
47 int * xadj=const_cast<int*>(m_graph->getIndex());
48 int * adjncy = const_cast<int*>(m_graph->getValue());
54 int* partition = new int[n+1];
56 SCOTCH_Graph scotch_graph;
58 SCOTCH_graphInit(&scotch_graph);
61 SCOTCH_graphBuild(&scotch_graph,
63 n, // nb of graph nodes
66 m_cellweight, //graph vertices loads
68 xadj[n], // number of edges
72 SCOTCH_Strat scotch_strategy;
73 SCOTCH_stratInit(&scotch_strategy);
75 //!user-defined options for the strategy
76 if (options_string!="")
77 SCOTCH_stratGraphMap(&scotch_strategy,options_string.c_str());
81 SCOTCH_graphPart(&scotch_graph,nparts,&scotch_strategy,partition);
83 // partition for 1 subdomain
84 for (int i=0; i<n+1; i++)
87 SCOTCH_stratExit(&scotch_strategy);
88 SCOTCH_graphExit(&scotch_graph);
90 int* index=new int [n+1];
92 for (int i=0; i<n; i++)
94 index[i+1]=index[i]+1;
97 //creating a skylinearray with no copy of the index and partition array
98 // the fifth argument true specifies that only the pointers are passed
100 m_partition = new MEDMEM::MEDSKYLINEARRAY(n,n, index, partition, true);