fei_Aztec_Map.hpp

00001 #ifndef _fei_Aztec_Map_hpp_
00002 #define _fei_Aztec_Map_hpp_
00003 
00004 /*--------------------------------------------------------------------*/
00005 /*    Copyright 2005 Sandia Corporation.                              */
00006 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00007 /*    non-exclusive license for use of this work by or on behalf      */
00008 /*    of the U.S. Government.  Export of this program may require     */
00009 /*    a license from the United States Government.                    */
00010 /*--------------------------------------------------------------------*/
00011 
00012 #include <vector>
00013 
00014 //
00015 // Aztec_Map is a wrapper that encapsulates the general
00016 // information needed to describe the layout of an Aztec matrix or
00017 // vector structure. It is a companion/support class that goes with
00018 // the three data class wrappers Aztec_LSVector, AztecDMSR_Matrix and
00019 // AztecDVBR_Matrix (the Aztec_BlockMap specialization is also
00020 // required for DVBR).
00021 //
00022 // Aztec_Map allows the storage and retrieval of information such as
00023 // local and global sizes, the MPI communicator, and the proc_config array.
00024 //
00025 namespace fei_trilinos {
00026 
00027 class Aztec_Map {
00028     
00029   public:
00030     Aztec_Map(int globalSize, int N_update, const int* update, int localOffset,
00031               MPI_Comm comm);
00032 
00033     Aztec_Map(const Aztec_Map& map);            // copy constructor    
00034     virtual ~Aztec_Map(void);
00035 
00036     virtual const int& localSize() const {return(localSize_);}
00037     virtual const int& globalSize() const {return(globalSize_);}
00038     virtual const int& localOffset() const {return(localOffset_);}
00039 
00040     int* getUpdate()
00041     {
00042       return update.size()>0 ? &update[0] : NULL;
00043     }
00044 
00045     virtual MPI_Comm getCommunicator() const {return(comm_);}
00046 
00047     virtual int* getProcConfig()
00048     {
00049       return proc_config.size()>0 ? &proc_config[0] : NULL;
00050     }
00051 
00052     std::vector<int> proc_config;
00053     std::vector<int> update;
00054     int* external;
00055     int* update_index;
00056     int* extern_index;
00057     int* data_org;
00058     std::vector<int> orderingUpdate;
00059 
00060     bool az_transformed;
00061 
00062     int getTransformedEqn(int eqn) const {
00063       if (az_transformed == true) {
00064         return eqn<N_update_ ? update[orderingUpdate[eqn]] : external[eqn-N_update_];
00065       }
00066       return eqn;
00067     }
00068 
00069     bool inUpdate(int globalIndex, int& localIndex) const
00070     {
00071       localIndex = globalIndex - localOffset_;
00072       if (localIndex<0 || localIndex>=localSize_) {
00073         localIndex = -1;
00074         return false;
00075       }
00076       if (az_transformed == true) {
00077         localIndex = update_index[localIndex];
00078       }
00079       return true;
00080     }
00081 
00082   private:
00083     void checkInput();
00084 
00085     int globalSize_;
00086     int localSize_;
00087     int localOffset_;
00088     int N_update_;
00089 
00090     MPI_Comm comm_;
00091 };
00092 
00093 }//namespace fei_trilinos
00094 
00095 #endif
00096 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:23 2011 for FEI by  doxygen 1.6.3