FEI Version of the Day
snl_fei_RecordCollection.hpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 
00044 #ifndef _snl_fei_RecordCollection_hpp_
00045 #define _snl_fei_RecordCollection_hpp_
00046 
00047 #include <fei_iosfwd.hpp>
00048 #include <fei_MapType.hpp>
00049 #include <fei_Pool_alloc.hpp>
00050 #include <fei_FieldMask.hpp>
00051 #include <fei_Record.hpp>
00052 
00053 #include <map>
00054 #include <vector>
00055 
00056 #undef fei_file
00057 #define fei_file "snl_fei_RecordCollection.hpp"
00058 
00059 #include <fei_ErrMacros.hpp>
00060 
00061 namespace fei {
00062   template<typename T> class SharedIDs;
00063 }
00064 
00065 namespace snl_fei {
00066 
00068   class RecordCollection {
00069   public:
00071     RecordCollection(int localProc);
00072 
00074     RecordCollection(const RecordCollection& src);
00075 
00077     virtual ~RecordCollection();
00078 
00079     void setIDMap(const int* localIDs_begin, const int* localIDs_end,
00080                   const int* globalIDs_begin, const int* globalIDs_end);
00081 
00083     void initRecords(int numIDs,
00084          const int* IDs,
00085          std::vector<fei::FieldMask*>& fieldMasks,
00086          int* recordLocalIDs=NULL);
00087 
00089     void initRecords(int fieldID,
00090         int fieldSize,
00091         int numIDs,
00092         const int* IDs,
00093         std::vector<fei::FieldMask*>& fieldMasks,
00094         int* recordLocalIDs=NULL);
00095 
00098     void setOwners_lowestSharing(fei::SharedIDs<int>& sharedIDs);
00099 
00101     size_t getNumRecords() const
00102     {
00103       return( m_records.size() );
00104     }
00105 
00107     std::vector<fei::Record<int> >& getRecords()
00108     {
00109       return( m_records );
00110     }
00111 
00113     const std::vector<fei::Record<int> >& getRecords() const
00114     {
00115       return( m_records );
00116     }
00117 
00119     fei::Record<int>* getRecordWithID(int ID);
00120 
00122     const fei::Record<int>* getRecordWithID(int ID) const;
00123 
00124     fei::Record<int>* getRecordWithLocalID(int lid)
00125     { return &m_records[lid]; }
00126 
00127     const fei::Record<int>* getRecordWithLocalID(int lid) const
00128     { return &m_records[lid]; }
00129 
00130     int getLocalID(int global_id) const
00131     {
00132       fei::MapIntInt::const_iterator iter = m_global_to_local.find(global_id);
00133       if (iter == m_global_to_local.end()) {
00134         return -1;
00135       }
00136       return iter->second;
00137     }
00138 
00140     int getGlobalIndex(int ID,
00141         int fieldID,
00142         int fieldSize,
00143         int fieldOffset,
00144         int whichComponentOfField,
00145         const int* eqnNumbers);
00146 
00148     int getGlobalIndexLocalID(int localID,
00149         int fieldID,
00150         int fieldSize,
00151         int fieldOffset,
00152         int whichComponentOfField,
00153         const int* eqnNumbers);
00154 
00156     int getGlobalBlkIndex(int ID, int& globalBlkIndex);
00157 
00159     void setDebugOutput(FEI_OSTREAM* dbgOut)
00160     {
00161       dbgOut_ = dbgOut;
00162       debugOutput_ = true;
00163     }
00164 
00165     int getMinID() const { return m_minID; }
00166     int getMaxID() const { return m_maxID; }
00167 
00168   private:
00169 
00170     std::vector<fei::Record<int> > m_records;
00173     fei::MapIntInt m_global_to_local;
00174 
00175     int m_minID;
00176     int m_maxID;
00177 
00178     int localProc_;
00179 
00180     bool debugOutput_;
00181     FEI_OSTREAM* dbgOut_;
00182   };
00183 
00184 } //namespace snl_fei
00185 
00186 #undef fei_file
00187 
00188 #endif // _snl_fei_RecordCollection_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends