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 
00044     void initRecords(int numIDs,
00045          const int* IDs,
00046          std::vector<fei::FieldMask*>& fieldMasks,
00047          int* recordLocalIDs=NULL);
00048 
00050     void initRecords(int fieldID,
00051         int fieldSize,
00052         int numIDs,
00053         const int* IDs,
00054         std::vector<fei::FieldMask*>& fieldMasks,
00055         int* recordLocalIDs=NULL);
00056 
00059     void setOwners_lowestSharing(fei::SharedIDs<int>& sharedIDs);
00060 
00062     size_t getNumRecords() const
00063     {
00064       return( m_records.size() );
00065     }
00066 
00068     std::map<int,int>& getGlobalToLocalMap()
00069     { return m_global_to_local; }
00070 
00071     const std::map<int,int>& getGlobalToLocalMap() const
00072     { return m_global_to_local; }
00073 
00075     std::vector<fei::Record<int> >& getRecords()
00076     {
00077       return( m_records );
00078     }
00079 
00081     const std::vector<fei::Record<int> >& getRecords() const
00082     {
00083       return( m_records );
00084     }
00085 
00087     fei::Record<int>* getRecordWithID(int ID);
00088 
00090     const fei::Record<int>* getRecordWithID(int ID) const;
00091 
00092     fei::Record<int>* getRecordWithLocalID(int lid)
00093     { return &m_records[lid]; }
00094 
00095     const fei::Record<int>* getRecordWithLocalID(int lid) const
00096     { return &m_records[lid]; }
00097 
00098     int getLocalID(int global_id) const
00099     {
00100       std::map<int,int>::const_iterator iter = m_global_to_local.find(global_id);
00101       if (iter == m_global_to_local.end()) {
00102         return -1;
00103       }
00104       return iter->second;
00105     }
00106 
00108     int getGlobalIndex(int ID,
00109         int fieldID,
00110         int fieldSize,
00111         int fieldOffset,
00112         int whichComponentOfField,
00113         const int* eqnNumbers);
00114 
00116     int getGlobalBlkIndex(int ID, int& globalBlkIndex);
00117 
00119     void setDebugOutput(FEI_OSTREAM* dbgOut)
00120     {
00121       dbgOut_ = dbgOut;
00122       debugOutput_ = true;
00123     }
00124 
00125   private:
00126 
00127     std::vector<fei::Record<int> > m_records;
00128     std::map<int,int> m_global_to_local;
00129 
00130     int localProc_;
00131 
00132     bool debugOutput_;
00133     FEI_OSTREAM* dbgOut_;
00134   };
00135 
00136 } //namespace snl_fei
00137 
00138 #undef fei_file
00139 
00140 #endif // _snl_fei_RecordCollection_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends