LAMA
/home/brandes/workspace/LAMA/src/lama/distribution/GeneralDistribution.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_GENERALDISTRIBUTION_HPP_
00034 #define LAMA_GENERALDISTRIBUTION_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // others
00040 #include <lama/LAMATypes.hpp>
00041 
00042 #include <lama/distribution/Distribution.hpp>
00043 
00044 #include <vector>
00045 
00046 #if (BOOST_VERSION < 103600)
00047 #include <map>
00048 #else //(BOOST_VERSION >= 103600)
00049 #include <boost/unordered_map.hpp>
00050 #endif //(BOOST_VERSION < 103600)
00051 
00052 
00053 namespace lama
00054 {
00055 
00064 class LAMA_DLL_IMPORTEXPORT GeneralDistribution: public Distribution
00065 {
00066 public:
00067 
00077     GeneralDistribution(
00078         const IndexType globalSize,
00079         const std::vector<IndexType>& myGlobalIndexes,
00080         const CommunicatorPtr communicator);
00081 
00082     explicit GeneralDistribution( const Distribution& other );
00083 
00084 //    GeneralDistribution(const GeneralDistribution& other);
00085 
00086     virtual ~GeneralDistribution();
00087 
00088     virtual bool isLocal(const IndexType index) const;
00089 
00090     virtual IndexType getLocalSize() const;
00091 
00092     virtual std::vector<IndexType>& getLocalRows();
00093 
00094     virtual IndexType local2global(const IndexType localIndex) const;
00095 
00096     virtual IndexType global2local(const IndexType globalIndex) const;
00097 
00098     virtual bool isEqual(const Distribution& other) const;
00099 
00100     virtual void writeAt(std::ostream& stream) const;
00101 
00102     void getDistributionVector( std::vector<IndexType>& row2Partition ) const;
00103 
00104     void printDistributionVector( std::string name ) const;
00105 
00106 protected:
00107 
00108     GeneralDistribution(const IndexType globalSize,
00109         const CommunicatorPtr communicator);
00110 
00111     //TODO: Evaluate which one is faster
00112 #if (BOOST_VERSION < 103600)
00113     typedef std::map<IndexType, IndexType> Global2LocalMapType;
00114 #else //(BOOST_VERSION >= 103600)
00115     typedef boost::unordered_map<IndexType,IndexType> Global2LocalMapType;
00116 #endif //(BOOST_VERSION < 103600)
00117 
00118     Global2LocalMapType mGlobal2Local;
00119     std::vector<IndexType> mLocal2Global;
00120 
00121 private:
00122 
00123     GeneralDistribution();
00124 
00125     GeneralDistribution& operator=( const GeneralDistribution& other);
00126 
00127     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00128 };
00129 
00130 typedef boost::shared_ptr<GeneralDistribution> GeneralDistributionPtr;
00131 
00132 }
00133 
00134 #endif // LAMA_GENERALDISTRIBUTION_HPP_