Epetra_MapColoring.h

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 /*
00004 ************************************************************************
00005 
00006               Epetra: Linear Algebra Services Package 
00007                 Copyright (2001) Sandia Corporation
00008 
00009 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 license for use of this work by or on behalf of the U.S. Government.
00011 
00012 This library is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as
00014 published by the Free Software Foundation; either version 2.1 of the
00015 License, or (at your option) any later version.
00016  
00017 This library is distributed in the hope that it will be useful, but
00018 WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 Lesser General Public License for more details.
00021  
00022 You should have received a copy of the GNU Lesser General Public
00023 License along with this library; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 USA
00026 Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00027 
00028 ************************************************************************
00029 */
00030 //@HEADER
00031 
00032 #ifndef EPETRA_MAPCOLORING_H
00033 #define EPETRA_MAPCOLORING_H
00034 #include "Epetra_DistObject.h"
00035 #include "Epetra_BlockMap.h"
00036 #include "Epetra_Distributor.h"
00037 class Epetra_HashTable;
00038 class Epetra_Map;
00039 
00041 
00090 class Epetra_MapColoring: public Epetra_DistObject {
00091     
00092   public:
00093 
00095 
00096 
00097 
00108   Epetra_MapColoring(const Epetra_BlockMap& Map, const int DefaultColor = 0);
00109 
00111 
00129   Epetra_MapColoring(const Epetra_BlockMap& Map, int * ElementColors, const int DefaultColor = 0);
00130 
00132   
00133   Epetra_MapColoring(const Epetra_MapColoring& Source);
00134   
00136   
00137   virtual ~Epetra_MapColoring();
00139   
00141 
00142   
00144 
00147   int& operator [] (int LID) {ListsAreValid_ = false; return ElementColors_[LID];};
00148   
00150 
00155   int& operator () (int GID) {ListsAreValid_ = false; return ElementColors_[Map().LID(GID)];};
00157   
00159 
00160 
00161 
00164   const int& operator [] (int LID) const { return ElementColors_[LID];};
00165   
00167 
00172   const int& operator () (int GID) const {return ElementColors_[Map().LID(GID)];};
00174   
00176 
00177 
00178   int NumColors() const {if (!ListsAreValid_) GenerateLists(); return(NumColors_);};
00179   
00181   int MaxNumColors() const;
00182   
00184 
00188   int * ListOfColors() const {if (!ListsAreValid_) GenerateLists(); return(ListOfColors_);};
00189   
00191   int DefaultColor() const {return(DefaultColor_);};
00192   
00194   int NumElementsWithColor(int Color) const;
00195   
00197 
00201   int * ColorLIDList(int Color) const;
00202   
00204 
00207   int * ElementColors() const{if (!ListsAreValid_) GenerateLists(); return(ElementColors_);};
00208   
00210 
00211 
00212 
00213 
00219   Epetra_Map * GenerateMap(int Color) const;
00220   
00222 
00229   Epetra_BlockMap * GenerateBlockMap(int Color) const;
00231   
00233 
00234   
00236   virtual void Print(ostream & os) const;
00238   
00239  private:
00240   int Allocate(int * ElementColors, int Increment);
00241   int GenerateLists() const;
00242   int DeleteLists() const;
00243   bool InItemList(int ColorValue) const;
00244   
00245    // Routines to implement Epetra_DistObject virtual methods
00246 
00247   int CheckSizes(const Epetra_SrcDistObject& A);
00248   int CopyAndPermute(const Epetra_SrcDistObject & Source, 
00249                      int NumSameIDs, 
00250                      int NumPermuteIDs,
00251                      int * PermuteToLIDs,
00252                      int * PermuteFromLIDs,
00253                      const Epetra_OffsetIndex * Indexor);
00254 
00255   int PackAndPrepare(const Epetra_SrcDistObject & Source,
00256                      int NumExportIDs,
00257                      int * ExportLIDs,
00258                      int & LenExports,
00259                      char * & Exports,
00260                      int & SizeOfPacket,
00261                      int * Sizes,
00262                      bool & VarSizes,
00263                      Epetra_Distributor & Distor);
00264   
00265   int UnpackAndCombine(const Epetra_SrcDistObject & Source,
00266            int NumImportIDs,
00267                        int * ImportLIDs, 
00268                        int LenImports,
00269            char * Imports,
00270                        int & SizeOfPacket, 
00271            Epetra_Distributor & Distor,
00272                        Epetra_CombineMode CombineMode,
00273                        const Epetra_OffsetIndex * Indexor );
00274 
00275 
00276   struct ListItem {
00277     int ItemValue;
00278     ListItem * NextItem;
00279     
00280     ListItem( const int itemValue = 0, ListItem * nextItem = 0)
00281       : ItemValue(itemValue), NextItem(nextItem){}
00282 
00283     // Constructors commented out due to Intel v.7.1 compiler error (4/2005).
00284     //ListItem(const Epetra_MapColoring::ListItem & Item); // Make these inaccessible
00285     //ListItem & operator=(const Epetra_MapColoring::ListItem & Item);
00286   };
00287   
00288   int DefaultColor_;
00289   mutable Epetra_HashTable * ColorIDs_;
00290   mutable ListItem * FirstColor_;
00291   mutable int NumColors_;
00292   mutable int * ListOfColors_;
00293   mutable int * ColorCount_;
00294   mutable int * ElementColors_;
00295   mutable int ** ColorLists_;
00296   bool Allocated_;
00297   mutable bool ListsAreGenerated_;
00298   mutable bool ListsAreValid_;
00299   
00300   Epetra_MapColoring & operator=(const Epetra_MapColoring & Coloring); // Make these inaccessible
00301 
00302   
00303   
00304 };
00305 
00306 #endif /* EPETRA_MAPCOLORING_H */

Generated on Thu Sep 18 12:37:57 2008 for Epetra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1