Epetra Package Browser (Single Doxygen Collection) Development
Epetra_BasicDirectory.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2011 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_BASICDIRECTORY_H
00045 #define EPETRA_BASICDIRECTORY_H
00046 
00047 #include "Epetra_ConfigDefs.h"
00048 #include "Epetra_Object.h"
00049 #include "Epetra_Directory.h"
00050 #include "Epetra_Map.h"
00051 
00053 
00063 class Epetra_BasicDirectory: public virtual Epetra_Directory {
00064     
00065   public:
00066 
00068 
00069 
00070   Epetra_BasicDirectory(const Epetra_BlockMap & Map );
00071   
00073   
00074   Epetra_BasicDirectory(const Epetra_BasicDirectory& Directory);
00075   
00077   
00078   virtual ~Epetra_BasicDirectory(void);
00080   
00082 
00083 
00084 
00112 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00113   int GetDirectoryEntries( const Epetra_BlockMap& Map,
00114          const int NumEntries,
00115          const int * GlobalEntries,
00116          int * Procs,
00117          int * LocalEntries,
00118          int * EntrySizes,
00119          bool high_rank_sharing_procs=false) const;
00120 #endif
00121 
00122 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00123   int GetDirectoryEntries( const Epetra_BlockMap& Map,
00124          const int NumEntries,
00125          const long long * GlobalEntries,
00126          int * Procs,
00127          int * LocalEntries,
00128          int * EntrySizes,
00129          bool high_rank_sharing_procs=false) const;
00130 #endif
00131 
00133 
00135   bool GIDsAllUniquelyOwned() const;
00137 
00139 
00140 
00141   virtual void Print(std::ostream & os) const;
00143 
00144  private:
00145   Epetra_BasicDirectory& operator=(const Epetra_BasicDirectory& src);
00146 
00147   void create_ProcListArrays();
00148 
00149   void addProcToList(int proc, int LID);
00150 
00152   template<typename int_type>
00153   int Generate(const Epetra_BlockMap& Map);
00154 
00156   const Epetra_Map & DirectoryMap() const {return(*DirectoryMap_);};
00157 
00158   Epetra_Map* DirectoryMap_;
00159 
00160   //ProcList_ is a list containing the associated processor for each
00161   //directory entry. If any directory entry has more than one associated
00162   //processor, then the corresponding ProcList_ entry will be the lowest-
00163   //numbered of those processors. In that case, refer to ProcListLists_
00164   //for more info.
00165 
00166   int * ProcList_;
00167 
00168   //ProcListLists_ will usually be unallocated, and set to NULL. But if
00169   //at least one directory entry is associcated with more than one proc,
00170   //then ProcListLists_ is a list of lists -- it holds, for each
00171   //directory-entry, a list of processors.
00172   //But even then, it will have a NULL list for all directory entries that
00173   //are associated with only one processor.
00174   //
00175   //Each list's length will be stored in ProcListLens_.
00176   //Example:
00177   //
00178   //if (numProcLists_ > 0) {
00179   //  int entry_LID = DirectoryMap_->LID(GID);
00180   //
00181   //  for(int i=0; i<ProcListLens_[entry_LID]; ++i) {
00182   //    cout << "entry "<<GID<<" associated with proc "
00183   //          <<ProcListLists_[entry_LID][i]<<endl;
00184   //  }
00185   //}
00186   int** ProcListLists_;
00187   int* ProcListLens_;
00188   int numProcLists_;
00189 
00190   //true if any directory entry appears on multiple processors
00191   bool entryOnMultipleProcs_;
00192 
00193   int * LocalIndexList_;
00194   int * SizeList_;
00195   bool SizeIsConst_;
00196 
00197 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00198   int * AllMinGIDs_int_;
00199 #endif
00200 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00201   long long * AllMinGIDs_LL_;
00202 #endif
00203   
00204   template<typename int_type>
00205   const int_type * AllMinGIDs() const;
00206 
00207   template<typename int_type>
00208   int GetDirectoryEntries( const Epetra_BlockMap& Map,
00209             const int NumEntries,
00210             const int_type * GlobalEntries,
00211             int * Procs,
00212             int * LocalEntries,
00213             int * EntrySizes,
00214             bool high_rank_sharing_procs) const;
00215 
00216 };
00217 
00218 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00219 template<> inline const int * Epetra_BasicDirectory::AllMinGIDs() const
00220 {
00221   return AllMinGIDs_int_;
00222 }
00223 #endif
00224 
00225 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00226 template<> inline const long long * Epetra_BasicDirectory::AllMinGIDs() const
00227 {
00228   return AllMinGIDs_LL_;
00229 }
00230 #endif
00231 
00232 #endif /* EPETRA_BASICDIRECTORY_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines