FEI Version of the Day
snl_fei_RecordCollection.hpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _snl_fei_RecordCollection_hpp_
00010 #define _snl_fei_RecordCollection_hpp_
00011 
00012 #include <fei_iosfwd.hpp>
00013 #include <fei_Pool_alloc.hpp>
00014 #include <fei_FieldMask.hpp>
00015 #include <fei_Record.hpp>
00016 
00017 #include <map>
00018 #include <vector>
00019 
00020 #undef fei_file
00021 #define fei_file "snl_fei_RecordCollection.hpp"
00022 
00023 #include <fei_ErrMacros.hpp>
00024 
00025 namespace fei {
00026   template<typename T> class SharedIDs;
00027 }
00028 
00029 namespace snl_fei {
00030 
00032   class RecordCollection {
00033   public:
00035     RecordCollection(int localProc);
00036 
00038     RecordCollection(const RecordCollection& src);
00039 
00041     virtual ~RecordCollection();
00042 
00043     void setIDMap(const int* localIDs_begin, const int* localIDs_end,
00044                   const int* globalIDs_begin, const int* globalIDs_end);
00045 
00047     void initRecords(int numIDs,
00048          const int* IDs,
00049          std::vector<fei::FieldMask*>& fieldMasks,
00050          int* recordLocalIDs=NULL);
00051 
00053     void initRecords(int fieldID,
00054         int fieldSize,
00055         int numIDs,
00056         const int* IDs,
00057         std::vector<fei::FieldMask*>& fieldMasks,
00058         int* recordLocalIDs=NULL);
00059 
00062     void setOwners_lowestSharing(fei::SharedIDs<int>& sharedIDs);
00063     void setOwners_local();
00064 
00066     size_t getNumRecords() const
00067     {
00068       return( m_records.size() );
00069     }
00070 
00072     std::map<int,int>& getGlobalToLocalMap()
00073     { return m_global_to_local; }
00074 
00075     const std::map<int,int>& getGlobalToLocalMap() const
00076     { return m_global_to_local; }
00077 
00079     std::vector<fei::Record<int> >& getRecords()
00080     {
00081       return( m_records );
00082     }
00083 
00085     const std::vector<fei::Record<int> >& getRecords() const
00086     {
00087       return( m_records );
00088     }
00089 
00091     fei::Record<int>* getRecordWithID(int ID);
00092 
00094     const fei::Record<int>* getRecordWithID(int ID) const;
00095 
00096     fei::Record<int>* getRecordWithLocalID(int lid)
00097     { return &m_records[lid]; }
00098 
00099     const fei::Record<int>* getRecordWithLocalID(int lid) const
00100     { return &m_records[lid]; }
00101 
00102     int getLocalID(int global_id) const
00103     {
00104       std::map<int,int>::const_iterator iter = m_global_to_local.find(global_id);
00105       if (iter == m_global_to_local.end()) {
00106         return -1;
00107       }
00108       return iter->second;
00109     }
00110 
00112     int getGlobalIndex(int ID,
00113         int fieldID,
00114         int fieldSize,
00115         int fieldOffset,
00116         int whichComponentOfField,
00117         const int* eqnNumbers);
00118 
00120     int getGlobalIndexLocalID(int localID,
00121         int fieldID,
00122         int fieldSize,
00123         int fieldOffset,
00124         int whichComponentOfField,
00125         const int* eqnNumbers);
00126 
00128     int getGlobalBlkIndex(int ID, int& globalBlkIndex);
00129 
00131     void setDebugOutput(FEI_OSTREAM* dbgOut)
00132     {
00133       dbgOut_ = dbgOut;
00134       debugOutput_ = true;
00135     }
00136 
00137     int getMinID() const { return m_minID; }
00138     int getMaxID() const { return m_maxID; }
00139 
00140   private:
00141 
00142     std::vector<fei::Record<int> > m_records;
00143     std::map<int,int> m_global_to_local;
00144 
00145     int m_minID, m_maxID;
00146 
00147     int localProc_;
00148 
00149     bool debugOutput_;
00150     FEI_OSTREAM* dbgOut_;
00151   };
00152 
00153 } //namespace snl_fei
00154 
00155 #undef fei_file
00156 
00157 #endif // _snl_fei_RecordCollection_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends