Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Zoltan2_HyperGraphModel.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Zoltan2: A package of combinatorial algorithms for scientific computing
4 //
5 // Copyright 2012 NTESS and the Zoltan2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
14 #ifndef _ZOLTAN2_HYPERGRAPHMODEL_HPP_
15 #define _ZOLTAN2_HYPERGRAPHMODEL_HPP_
16 
17 #include <Zoltan2_Model.hpp>
18 #include <Zoltan2_ModelHelpers.hpp>
19 #include <Zoltan2_InputTraits.hpp>
21 #include <Zoltan2_GraphAdapter.hpp>
24 #include <Zoltan2_StridedData.hpp>
25 #include <Zoltan2_MeshAdapter.hpp>
26 
27 #include <vector>
28 #include <unordered_map>
29 #include <queue>
30 #include <Teuchos_Hashtable.hpp>
31 
32 namespace Zoltan2 {
33 
41 };
42 
44 
53 template <typename Adapter>
54 class HyperGraphModel : public Model<Adapter>
55 {
56 public:
57 
58 #ifndef DOXYGEN_SHOULD_SKIP_THIS
59  typedef typename Adapter::scalar_t scalar_t;
60  typedef typename Adapter::offset_t offset_t;
61  typedef typename Adapter::gno_t gno_t;
62  typedef typename Adapter::lno_t lno_t;
63  typedef typename Adapter::node_t node_t;
64  typedef typename Adapter::user_t user_t;
65  typedef typename Adapter::userCoord_t userCoord_t;
66  typedef Tpetra::Map<lno_t, gno_t> map_t;
67  typedef StridedData<lno_t, scalar_t> input_t;
68 #endif
69 
72 
85  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm,
86  modelFlag_t &modelFlags, CentricView view)
87  {
88  throw std::runtime_error("Building HyperGraphModel from MatrixAdapter not implemented yet");
89  }
90 
92  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm,
93  modelFlag_t &modelFlags, CentricView view)
94  {
95  throw std::runtime_error("Building HyperGraphModel from GraphAdapter not implemented yet");
96  }
97 
98  HyperGraphModel(const RCP<const MeshAdapter<user_t> > &ia,
99  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm,
100  modelFlag_t &modelflags, CentricView view);
101 
103  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm,
104  modelFlag_t &flags, CentricView view)
105  {
106  throw std::runtime_error("cannot build HyperGraphModel from VectorAdapter");
107  }
108 
110  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm,
111  modelFlag_t &flags, CentricView view)
112  {
113  throw std::runtime_error("cannot build HyperGraphModel from IdentifierAdapter");
114  }
115 
116 
119  CentricView getCentricView() const {return view_;}
120 
123  bool areVertexIDsUnique() const {return unique;}
124 
127  size_t getLocalNumVertices() const { return numLocalVertices_; }
128 
131  size_t getLocalNumOwnedVertices() const { return numOwnedVertices_; }
132 
135  size_t getGlobalNumVertices() const { return numGlobalVertices_; }
136 
141  size_t getLocalNumHyperEdges() const { return numLocalEdges_; }
142 
145  size_t getGlobalNumHyperEdges() const { return numGlobalEdges_; }
146 
149  size_t getLocalNumPins() const {return numLocalPins_; }
150 
153  int getNumWeightsPerVertex() const { return numWeightsPerVertex_; }
154 
157  int getNumWeightsPerHyperEdge() const { return nWeightsPerEdge_; }
158 
161  int getNumWeightesPerPin() const {return nWeightsPerPin_;}
162 
165  int getCoordinateDim() const { return vCoordDim_; }
166 
175  ArrayView<const gno_t> &Ids,
176  ArrayView<input_t> &wgts) const
177  {
178  size_t nv = gids_.size();
179  Ids = gids_(0, nv);
180  wgts = vWeights_.view(0, numWeightsPerVertex_);
181  return nv;
182  }
183 
189  size_t getVertexCoords(ArrayView<input_t> &xyz) const
190  {
191  size_t nv = gids_.size();
192  xyz = vCoords_.view(0, vCoordDim_);
193  return nv;
194  }
195 
202  size_t getOwnedList(ArrayView<bool> &isOwner) const
203  {
204  size_t nv = isOwner_.size();
205  isOwner = isOwner_(0, nv);
206  return nv;
207  }
208 
216  void getVertexMaps(Teuchos::RCP<const map_t>& copiesMap,
217  Teuchos::RCP<const map_t>& onetooneMap) const
218  {
219  copiesMap = mapWithCopies;
220  onetooneMap = oneToOneMap;
221  }
222 
230  size_t getEdgeList(
231  ArrayView<const gno_t> &Ids,
232  ArrayView<input_t> &wgts) const
233  {
234  size_t nv = edgeGids_.size();
235  Ids = edgeGids_(0, nv);
236  wgts = eWeights_.view(0, nWeightsPerEdge_);
237  return nv;
238  }
239 
252  size_t getPinList( ArrayView<const gno_t> &pinIds,
253  ArrayView<const offset_t> &offsets,
254  ArrayView<input_t> &wgts) const
255  {
256  pinIds = pinGids_(0, numLocalPins_);
257  offsets = offsets_.view(0, offsets_.size());
258  wgts = pWeights_.view(0, nWeightsPerPin_);
259  return pinGids_.size();
260  }
261 
262 
264  // The Model interface.
266 
267  size_t getLocalNumObjects() const { return numLocalVertices_; }
268 
269  size_t getGlobalNumObjects() const { return numGlobalVertices_; }
270 
271 private:
272 
273  struct GhostCell {
274  lno_t lid; //Assumes lno_t is signed (-1 corresponds to not on this process)
275  gno_t gid;
276  unsigned int dist;
277  GhostCell(lno_t l,gno_t g, unsigned int d) {lid=l;gid=g;dist=d;}
278  bool operator<(const struct GhostCell& other) const {return dist>other.dist;}
279  };
280  template <typename AdapterWithCoords>
281  void shared_GetVertexCoords(const AdapterWithCoords *ia);
282 
283 
284  const RCP<const Environment > env_;
285  const RCP<const Comm<int> > comm_;
286 
287  CentricView view_;
288  bool unique;
289  ArrayRCP<const gno_t> gids_; // vertices of input graph
290 
291  ArrayRCP<bool> isOwner_;
292 
293  int numWeightsPerVertex_;
294  ArrayRCP<input_t> vWeights_;
295 
296  int vCoordDim_;
297  ArrayRCP<input_t> vCoords_;
298 
299  ArrayRCP<const gno_t> edgeGids_;
300 
301  int nWeightsPerEdge_;
302  ArrayRCP<input_t> eWeights_;
303 
304  ArrayRCP<const gno_t> pinGids_;
305  ArrayRCP<const offset_t> offsets_;
306 
307  int nWeightsPerPin_;
308  ArrayRCP<input_t> pWeights_;
309 
310  // For convenience
311 
312  size_t numLocalVertices_;
313  size_t numOwnedVertices_;
314  size_t numGlobalVertices_;
315  size_t numLocalEdges_;
316  size_t numGlobalEdges_;
317  size_t numLocalPins_;
318 
319  // For unique mapping
320  Teuchos::RCP<const map_t> mapWithCopies;
321  Teuchos::RCP<const map_t> oneToOneMap;
322 
323  // For debugging
324  void print();
325 
326 };
327 
328 
330 
332 //TODO get the weights hyperedges
333 //GFD Do we need weights for pins too?
334 template <typename Adapter>
336  const RCP<const MeshAdapter<user_t> > &ia,
337  const RCP<const Environment> &env,
338  const RCP<const Comm<int> > &comm,
339  modelFlag_t &modelFlags,
340  CentricView view):
341  env_(env),
342  comm_(comm),
343  view_(view),
344  gids_(),
345  isOwner_(),
346  numWeightsPerVertex_(0),
347  vWeights_(),
348  vCoordDim_(0),
349  vCoords_(),
350  edgeGids_(),
351  nWeightsPerEdge_(0),
352  eWeights_(),
353  pinGids_(),
354  offsets_(),
355  nWeightsPerPin_(0),
356  pWeights_(),
357  numLocalVertices_(0),
358  numGlobalVertices_(0),
359  numLocalEdges_(0),
360  numGlobalEdges_(0),
361  numLocalPins_(0)
362 {
363  env_->timerStart(MACRO_TIMERS, "HyperGraphModel constructed from MeshAdapter");
364  //Model Type is either traditional or ghosting
365  // Traditional:
366  // vertices == ia->getPrimaryEntityType()
367  // hyperedges == ia->getAdjacencyEntityType()
368  // pins == first adjacency between primary and adjacency types
369  // Ghosting:
370  // vertices == ia->getPrimaryEntityType()
371  // hyperedges == ia->getPrimaryEntityType()
372  // pins == k layers of second adjacency from primary through second adjacency types
373  std::string model_type("traditional");
374  const Teuchos::ParameterList &pl = env->getParameters();
375  const Teuchos::ParameterEntry *pe2 = pl.getEntryPtr("hypergraph_model_type");
376  if (pe2){
377  model_type = pe2->getValue<std::string>(&model_type);
378  }
379 
380  // Get the hypergraph types from adapter
381  Zoltan2::MeshEntityType primaryEType = ia->getPrimaryEntityType();
382  Zoltan2::MeshEntityType adjacencyEType = ia->getAdjacencyEntityType();
383 
384  // Get the IDs of the primary entity type; these are hypergraph vertices
385  gno_t const *vtxIds=NULL;
386  try {
387  numLocalVertices_ = ia->getLocalNumOf(primaryEType);
388  ia->getIDsViewOf(primaryEType, vtxIds);
389  size_t maxId = *(std::max_element(vtxIds,vtxIds+numLocalVertices_));
390  reduceAll(*comm_,Teuchos::REDUCE_MAX,1,&maxId,&numGlobalVertices_);
391  // TODO: KDD 1/17 The above computation of numGlobalVertices_ is
392  // TODO: correct only when the vertices are consecutively numbered
393  // TODO: starting at ID 1. Github #1024
394  }
396 
397  gids_ = arcp<const gno_t>(vtxIds, 0, numLocalVertices_, false);
398 
399  //A mapping from gids to lids for efficiency
400  std::unordered_map<gno_t,lno_t> lid_mapping;
401  for (size_t i=0;i<numLocalVertices_;i++)
402  lid_mapping[gids_[i]]=i;
403 
404  // Define owners for each hypergraph vertex using Tpetra
405  // one to one map. This defines each hypergraph vertex to
406  // one process in the case that the adapter has copied
407  // primary entity types
408  //If the mesh adapter knows the entities are unique we can optimize out the ownership
409  unique = ia->areEntityIDsUnique(ia->getPrimaryEntityType());
410  numOwnedVertices_=numLocalVertices_;
411  isOwner_ = ArrayRCP<bool>(numLocalVertices_,true);
412  if (!unique) {
413 
414  Tpetra::global_size_t numGlobalCoords =
415  Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid();
416  mapWithCopies = rcp(new map_t(numGlobalCoords, gids_(), 0, comm));
417  // TODO KDD 1/17 It would be better to use minimum GID rather than
418  // TODO zero in the above Tpetra::Map constructor. Github #1024
419  oneToOneMap = Tpetra::createOneToOne<lno_t, gno_t>(mapWithCopies);
420 
421  numOwnedVertices_=oneToOneMap->getLocalNumElements();
422  for (size_t i=0;i<numLocalVertices_;i++) {
423  isOwner_[i] = oneToOneMap->isNodeGlobalElement(gids_[i]);
424  }
425  }
426 
427 
428  if (model_type=="traditional") {
429  // Traditional: Get the IDs of the adjacency entity type;
430  // these are hypergraph hyperedges
431 
432  gno_t const *edgeIds=NULL;
433  try {
434  numLocalEdges_ = ia->getLocalNumOf(adjacencyEType);
435  ia->getIDsViewOf(adjacencyEType, edgeIds);
436  size_t maxId = *(std::max_element(edgeIds,edgeIds+numLocalEdges_));
437  reduceAll(*comm_,Teuchos::REDUCE_MAX,1,&maxId,&numGlobalEdges_);
438  }
440 
441  edgeGids_ = arcp<const gno_t>(edgeIds, 0, numLocalEdges_, false);
442  }
443  else if (model_type=="ghosting") {
444  // Ghosting: Use the vertices as the hyperedges as well
445  numLocalEdges_ = numLocalVertices_;
446  edgeGids_ = arcp<const gno_t>(vtxIds, 0, numLocalVertices_, false);
447  numGlobalEdges_ = numGlobalVertices_;
448  }
449 
450  //Define the entity types to use for the pins based on the centric view
451  Zoltan2::MeshEntityType primaryPinType = primaryEType;
452  Zoltan2::MeshEntityType adjacencyPinType = adjacencyEType;
453  size_t numPrimaryPins = numLocalVertices_;
454  if (view_==HYPEREDGE_CENTRIC) {
455  primaryPinType = adjacencyEType;
456  adjacencyPinType = primaryEType;
457  numPrimaryPins = numLocalEdges_;
458  }
459  if (model_type=="traditional") {
460  //Get the pins from using the traditional method of first adjacency
461  gno_t const *nborIds=NULL;
462  offset_t const *offsets=NULL;
463 
464  try {
465  ia->getAdjsView(primaryPinType,adjacencyPinType,offsets,nborIds);
466  }
468 
469  numLocalPins_ = offsets[numPrimaryPins];
470 
471  pinGids_ = arcp<const gno_t>(nborIds, 0, numLocalPins_, false);
472  offsets_ = arcp<const offset_t>(offsets, 0, numPrimaryPins + 1, false);
473  }
474  else if (model_type=="ghosting") {
475  // set the view to either since it doesn't matter
476  // vertices==hyperedges
477  view_ = VERTEX_CENTRIC;
478  // unique set of global ids for the ghosts
479  typedef std::set<gno_t> ghost_t;
480 
481  // mapping from global id to the set of ghosts
482  typedef std::unordered_map<gno_t,ghost_t> ghost_map_t;
483 
484  primaryPinType=primaryEType;
485  adjacencyPinType =ia->getSecondAdjacencyEntityType();
486 
487  // number of layers of ghosting to do
488  unsigned int layers=2;
489  const Teuchos::ParameterEntry *pe3 = pl.getEntryPtr("ghost_layers");
490  if (pe3){
491  int l;
492  l = pe3->getValue<int>(&l);
493  layers = static_cast<unsigned int>(l);
494  }
495 
496  typedef int nonzero_t; // adjacency matrix doesn't need scalar_t
497  typedef Tpetra::CrsMatrix<nonzero_t,lno_t,gno_t,node_t> sparse_matrix_type;
498 
499  // Get an adjacency matrix representing the graph on the mesh
500  // using second adjacencies. If second adjacencies are not
501  // provided build the matrix from first adjacencies.
502  RCP<sparse_matrix_type> secondAdj;
503  if (!ia->avail2ndAdjs(primaryPinType,adjacencyPinType)) {
504  secondAdj=Zoltan2::get2ndAdjsMatFromAdjs<user_t>(ia,comm_,primaryPinType, adjacencyPinType);
505  }
506  else {
507  const offset_t* offsets;
508  const gno_t* adjacencyIds;
509  ia->get2ndAdjsView(primaryPinType,adjacencyPinType,offsets,adjacencyIds);
510  if (unique) {
511  Tpetra::global_size_t numGlobalCoords =
512  Teuchos::OrdinalTraits<Tpetra::global_size_t>::invalid();
513  oneToOneMap = rcp(new map_t(numGlobalCoords, gids_(), 0, comm));
514  // TODO KDD 1/17 It would be better to use minimum GID rather than
515  // TODO zero in the above Tpetra::Map constructor. Github #1024
516  }
517  Teuchos::Array<size_t> nPerRow(numLocalVertices_);
518  size_t rowcnt = 0;
519  for (size_t i=0; i<numLocalVertices_;i++) {
520  if (!isOwner_[i])
521  continue;
522  nPerRow[rowcnt++] = offsets[i+1]-offsets[i];
523  }
524  secondAdj = rcp(new sparse_matrix_type(oneToOneMap,nPerRow(0,rowcnt)));
525  for (size_t i=0; i<numLocalVertices_;i++) {
526  if (!isOwner_[i])
527  continue;
528  gno_t row = gids_[i];
529  offset_t num_adjs = offsets[i+1]-offsets[i];
530  ArrayRCP<nonzero_t> ones(num_adjs,1);
531  ArrayRCP<const gno_t> cols(adjacencyIds,offsets[i],num_adjs,false);
532  secondAdj->insertGlobalValues(row,cols(),ones());
533  }
534  secondAdj->fillComplete();
535  }
536 
537  //The mapping of the ghosts per hypergraph vertex
538  ghost_map_t ghosts;
539 
540  //Read the 1 layer ghosts from the second adjacency matrix
541  for (unsigned int i=0;i<numLocalEdges_;i++) {
542  if (!isOwner_[i])
543  continue;
544  gno_t gid = edgeGids_[i];
545  size_t NumEntries = secondAdj->getNumEntriesInGlobalRow (gid);
546  typename sparse_matrix_type::nonconst_global_inds_host_view_type Indices("Indices", NumEntries);
547  typename sparse_matrix_type::nonconst_values_host_view_type Values("Values", NumEntries);
548  secondAdj->getGlobalRowCopy(gid,Indices,Values,NumEntries);
549  for (size_t j = 0; j < NumEntries; ++j) {
550  if(gid != Indices[j]) {
551  ghosts[gid].insert(Indices[j]);
552  }
553  }
554  }
555 
556  // The ith power of the second adjacency matrix is the ith layer of ghosts.
557  // Here we compute the ith power of the matrix and add the ith layer ghosts
558  // from the new matrix.
559  RCP<sparse_matrix_type> mat_old = secondAdj;
560  for (unsigned int i=1;i<layers;i++) {
561  RCP<sparse_matrix_type> mat_new =
562  rcp (new sparse_matrix_type(secondAdj->getRowMap(),0));
563  Tpetra::MatrixMatrix::Multiply(*mat_old,false,*secondAdj,false,*mat_new);
564  for (unsigned int j=0;j<numLocalEdges_;j++) {
565  if (!isOwner_[j])
566  continue;
567  gno_t gid = edgeGids_[j];
568  size_t NumEntries = mat_new->getNumEntriesInGlobalRow (gid);
569  typename sparse_matrix_type::nonconst_global_inds_host_view_type Indices("Indices", NumEntries);
570  typename sparse_matrix_type::nonconst_values_host_view_type Values("Values", NumEntries);
571  mat_new->getGlobalRowCopy(gid,Indices,Values,NumEntries);
572  for (size_t k = 0; k < NumEntries; ++k)
573  if(gid != Indices[k])
574  ghosts[gid].insert(Indices[k]);
575 
576  }
577  mat_old = mat_new;
578  }
579 
580  //Make the pins from the ghosts
581  for (size_t i=0;i<numLocalVertices_;i++) {//for each local entity
582  numLocalPins_+=ghosts[gids_[i]].size();
583  }
584  gno_t* temp_pins = new gno_t[numLocalPins_];
585  offset_t* temp_offsets = new offset_t[numLocalVertices_+1];
586  gno_t j=0;
587  for (size_t i=0;i<numLocalVertices_;i++) {//for each local entity
588  temp_offsets[i]=j;
589  if (!isOwner_[i])
590  continue;
591  typename ghost_t::iterator itr;
592  for (itr=ghosts[gids_[i]].begin();itr!=ghosts[gids_[i]].end();itr++) { //for each ghost of this entity
593  temp_pins[j]=*itr;
594  j++;
595 
596  }
597  }
598  temp_offsets[numLocalVertices_]=numLocalPins_;
599  pinGids_ = arcp<const gno_t>(temp_pins,0,numLocalPins_,true);
600  offsets_ = arcp<const offset_t>(temp_offsets,0,numLocalVertices_+1,true);
601 
602  //==============================Ghosting complete=================================
603  }
604 
605 
606  //Get the vertex weights
607  numWeightsPerVertex_ = ia->getNumWeightsPerID();
608 
609  if (numWeightsPerVertex_ > 0){
610  input_t *weightInfo = new input_t [numWeightsPerVertex_];
611  env_->localMemoryAssertion(__FILE__, __LINE__, numWeightsPerVertex_,
612  weightInfo);
613 
614  for (int idx=0; idx < numWeightsPerVertex_; idx++){
615  bool useNumNZ = ia->useDegreeAsWeight(idx);
616  if (useNumNZ){
617  scalar_t *wgts = new scalar_t [numLocalVertices_];
618  env_->localMemoryAssertion(__FILE__, __LINE__, numLocalVertices_, wgts);
619  ArrayRCP<const scalar_t> wgtArray =
620  arcp(wgts, 0, numLocalVertices_, true);
621  for (size_t i=0; i < numLocalVertices_; i++){
622  wgts[i] = offsets_[i+1] - offsets_[i];
623  }
624  weightInfo[idx] = input_t(wgtArray, 1);
625  }
626  else{
627  const scalar_t *weights=NULL;
628  int stride=0;
629  ia->getWeightsView(weights, stride, idx);
630  ArrayRCP<const scalar_t> wgtArray = arcp(weights, 0,
631  stride*numLocalVertices_,
632  false);
633  weightInfo[idx] = input_t(wgtArray, stride);
634  }
635  }
636 
637  vWeights_ = arcp<input_t>(weightInfo, 0, numWeightsPerVertex_, true);
638  }
639 
640  //TODO get the weights for edges, and pins(?)
641 
642  //Get the vertex coordinates from the primary types
643  typedef MeshAdapter<user_t> adapterWithCoords_t;
644  shared_GetVertexCoords<adapterWithCoords_t>(&(*ia));
645 
646  env_->timerStop(MACRO_TIMERS, "HyperGraphModel constructed from MeshAdapter");
647  print();
648 }
649 
651 
652 template <typename Adapter>
653 template <typename AdapterWithCoords>
655 {
656  // get Vertex coordinates from input adapter
657 
658  vCoordDim_ = ia->getDimension();
659 
660  if (vCoordDim_ > 0){
661  input_t *coordInfo = new input_t [vCoordDim_];
662  env_->localMemoryAssertion(__FILE__, __LINE__, vCoordDim_, coordInfo);
663 
664  for (int dim=0; dim < vCoordDim_; dim++){
665  const scalar_t *coords=NULL;
666  int stride=0;
667  ia->getCoordinatesView(coords, stride, dim);
668  ArrayRCP<const scalar_t> coordArray = arcp(coords, 0,
669  stride*numLocalVertices_,
670  false);
671  coordInfo[dim] = input_t(coordArray, stride);
672  }
673 
674  vCoords_ = arcp<input_t>(coordInfo, 0, vCoordDim_, true);
675  }
676 }
677 
679 template <typename Adapter>
680 void HyperGraphModel<Adapter>::print()
681 {
682  //only prints the model if debug status is verbose
683  if (env_->getDebugLevel() < VERBOSE_DETAILED_STATUS)
684  return;
685 
686  std::ostream *os = env_->getDebugOStream();
687 
688  int me = comm_->getRank();
689  std::string fn(" ");
690 
691  *os << me << fn
692  << " Nvtx " << gids_.size()
693  << " Nedge " << edgeGids_.size()
694  << " NPins " << numLocalPins_
695  << " NVWgt " << numWeightsPerVertex_
696  << " NEWgt " << nWeightsPerEdge_
697  << " NPWgt " << nWeightsPerPin_
698  << " CDim " << vCoordDim_
699  << std::endl;
700 
701  for (lno_t i = 0; i < gids_.size(); i++) {
702  *os << me << fn << i << " VTXGID " << gids_[i]<<" isOwner: "<<isOwner_[i];
703  if (numWeightsPerVertex_==1)
704  *os << " weight: " << vWeights_[0][i];
705  if (view_==VERTEX_CENTRIC) {
706  *os <<" pins:";
707  for (offset_t j = offsets_[i]; j< offsets_[i+1];j++)
708  *os <<" "<<pinGids_[j];
709  }
710  *os << std::endl;
711  }
712  for (lno_t i = 0; i<edgeGids_.size();i++) {
713  *os << me << fn << i << " EDGEGID " << edgeGids_[i];
714  if (view_==HYPEREDGE_CENTRIC) {
715  *os <<":";
716  for (offset_t j = offsets_[i]; j< offsets_[i+1];j++)
717  *os <<" "<<pinGids_[j];
718  }
719  *os << std::endl;
720  }
721  if (vCoordDim_) {
722  for (lno_t i = 0; i < gids_.size(); i++) {
723  *os << me << fn << i << " COORDS " << gids_[i] << ": ";
724  for (int j = 0; j < vCoordDim_; j++)
725  *os << vCoords_[j][i] << " ";
726  *os << std::endl;
727  }
728  }
729  else
730  *os << me << fn << "NO COORDINATES AVAIL " << std::endl;
731 }
732 
733 } // namespace Zoltan2
734 
735 
736 #endif
737 
Time an algorithm (or other entity) as a whole.
IdentifierAdapter defines the interface for identifiers.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
MatrixAdapter defines the adapter interface for matrices.
Defines the Model interface.
size_t getVertexCoords(ArrayView< input_t > &xyz) const
Sets pointers to this process&#39; vertex coordinates, if available.
static ArrayRCP< ArrayRCP< zscalar_t > > weights
GraphAdapter defines the interface for graph-based user data.
int getNumWeightsPerHyperEdge() const
Returns the number (0 or greater) of weights per edge.
Defines the MeshAdapter interface.
CentricView getCentricView() const
Returns the centric view of the hypergraph.
MeshAdapter defines the interface for mesh input.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
HyperGraphModel(const RCP< const VectorAdapter< userCoord_t > > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm, modelFlag_t &flags, CentricView view)
map_t::global_ordinal_type gno_t
Definition: mapRemotes.cpp:27
size_t getLocalNumObjects() const
Return the local number of objects.
Defines the IdentifierAdapter interface.
Defines the VectorAdapter interface.
HyperGraphModel(const RCP< const MatrixAdapter< user_t, userCoord_t > > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm, modelFlag_t &modelFlags, CentricView view)
Constructor.
typename Zoltan2::InputTraits< ztcrsmatrix_t >::node_t node_t
HyperGraphModel(const RCP< const GraphAdapter< user_t, userCoord_t > > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm, modelFlag_t &modelFlags, CentricView view)
size_t getOwnedList(ArrayView< bool > &isOwner) const
Sets pointer to the ownership of this processes vertices.
Defines helper functions for use in the models.
bool areVertexIDsUnique() const
Returns true if the vertices are unique false otherwise.
size_t getEdgeList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
Sets pointers to this process&#39; hyperedge Ids and their weights.
int getNumWeightesPerPin() const
Returns the number (0 or greater) of weights per pins.
size_t getLocalNumHyperEdges() const
Returns the number of hyper edges on this process. These are all hyper edges that have an adjacency t...
VectorAdapter defines the interface for vector input.
Tpetra::Map map_t
Definition: mapRemotes.cpp:25
The StridedData class manages lists of weights or coordinates.
Traits for application input objects.
map_t::local_ordinal_type lno_t
Definition: mapRemotes.cpp:26
size_t getGlobalNumObjects() const
Return the global number of objects.
size_t getLocalNumPins() const
Returns the local number of pins.
size_t getVertexList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
Sets pointers to this process&#39; vertex Ids and their weights.
int getCoordinateDim() const
Returns the dimension (0 to 3) of vertex coordinates.
CentricView
Enumerate the views for the pins: HYPEREDGE_CENTRIC: pins are the global ids of the vertices as seen ...
MeshEntityType
Enumerate entity types for meshes: Regions, Faces, Edges, or Vertices.
Defines the MatrixAdapter interface.
The base class for all model classes.
size_t getPinList(ArrayView< const gno_t > &pinIds, ArrayView< const offset_t > &offsets, ArrayView< input_t > &wgts) const
Sets pointers to this process&#39; pins global Ids based on the centric view given by getCentricView() ...
Tpetra::global_size_t global_size_t
size_t getGlobalNumHyperEdges() const
Returns the global number hyper edges.
size_t getLocalNumVertices() const
Returns the number vertices on this process.
Defines the GraphAdapter interface.
include more detail about sub-steps
HyperGraphModel defines the interface required for hyper graph models.
size_t getGlobalNumVertices() const
Returns the global number vertices.
void getVertexMaps(Teuchos::RCP< const map_t > &copiesMap, Teuchos::RCP< const map_t > &onetooneMap) const
Sets pointers to the vertex map with copies and the vertex map without copies Note: the pointers will...
int getNumWeightsPerVertex() const
Returns the number (0 or greater) of weights per vertex.
size_t getLocalNumOwnedVertices() const
Returns the number vertices on this process that are owned.
virtual void getCoordinatesView(const scalar_t *&coords, int &stride, int coordDim) const =0
This file defines the StridedData class.
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t
Definition: Metric.cpp:39
HyperGraphModel(const RCP< const IdentifierAdapter< user_t > > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm, modelFlag_t &flags, CentricView view)