Ifpack_UserPartitioner.cpp

00001 #include "Ifpack_ConfigDefs.h"
00002 #ifdef HAVE_IFPACK_TEUCHOS
00003 #include "Ifpack_Partitioner.h"
00004 #include "Ifpack_OverlappingPartitioner.h"
00005 #include "Ifpack_UserPartitioner.h"
00006 #include "Epetra_CrsGraph.h"
00007 #include <vector>
00008 
00009 //==============================================================================
00010 int Ifpack_UserPartitioner::ComputePartitions()
00011 {
00012   
00013   if (Map_ == 0)
00014     IFPACK_CHK_ERR(-1);
00015 
00016   // simply copy user's vector
00017   for (int i = 0 ; i < NumMyRows() ; ++i) {
00018     Partition_[i] = Map_[i];
00019   }
00020 
00021   // put together all partitions composed by 1 one vertex
00022   // (if any)
00023   vector<int> singletons(NumLocalParts());
00024   for (unsigned int i = 0 ; i < singletons.size() ; ++i) {
00025     singletons[i] = 0;
00026   }
00027 
00028 #if 0
00029   // may want to uncomment the following to ensure that no
00030   // partitions are in fact singletons
00031   for (int i = 0 ; i < NumMyRows() ; ++i) {
00032     ++singletons[Partition_[i]];
00033   }
00034   
00035   int count = 0;
00036   for (unsigned int i = 0 ; i < singletons.size() ; ++i) {
00037     if (singletons[i] == 1)
00038       ++count;
00039   }
00040 
00041   int index = -1;
00042   for (int i = 0 ; i < NumMyRows() ; ++i) {
00043     int j = Partition_[i];
00044     if (singletons[j] == 1) {
00045       if (index == -1)
00046         index = j;
00047       else
00048         Partition_[i] = index;
00049     }
00050   }
00051 #endif
00052 
00053   return(0);
00054 }
00055 #endif // HAVE_IFPACK_TEUCHOS

Generated on Thu Sep 18 12:37:08 2008 for IFPACK by doxygen 1.3.9.1