fei_VectorSpace.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 _fei_VectorSpace_hpp_
00010 #define _fei_VectorSpace_hpp_
00011 
00012 #include <fei_macros.hpp>
00013 #include <fei_constants.hpp>
00014 #include <fei_fwd.hpp>
00015 #include <fei_SharedPtr.hpp>
00016 #include <fei_Logger.hpp>
00017 #include <fei_utils.hpp>
00018 #include <fei_CommUtils.hpp>
00019 #include <fei_FieldDofMap.hpp>
00020 #include <fei_ctg_set.hpp>
00021 #include <snl_fei_RaggedTable.hpp>
00022 
00023 namespace fei {
00024   class FieldMask;
00025   class Lookup_Impl;
00026   class Pattern;
00027   template<typename GlobalIDType> class Record;
00028   template<typename GlobalIDType> class Record_Operator;
00029   template<typename GlobalIDType> class SharedIDs;
00030 
00062   class VectorSpace : private fei::Logger {
00063   public:
00065     class Factory {
00066     public:
00068       virtual ~Factory(){}
00069 
00071      virtual fei::SharedPtr<VectorSpace> createVectorSpace(MPI_Comm,
00072                                                            const char* name);
00073     };
00074 
00080     VectorSpace(MPI_Comm comm, const char* name = NULL);
00081 
00083     virtual ~VectorSpace();
00084 
00086 
00091     void setParameters(const fei::ParameterSet& paramset);
00092 
00105     void defineFields(int numFields,
00106                       const int* fieldIDs,
00107                       const int* fieldSizes,
00108                       const int* fieldTypes = NULL);
00109 
00119     void defineIDTypes(int numIDTypes,
00120                        const int* idTypes);
00121 
00138     int addDOFs(int fieldID,
00139                 int numInstancesOfThisFieldPerID,
00140                 int idType,
00141                 int numIDs,
00142                 const int* IDs);
00143 
00163     int addDOFs(int idType,
00164                 int numIDs,
00165                 const int* IDs);
00166 
00186     int initSharedIDs(int numShared,
00187                       int idType,
00188                       const int* sharedIDs,
00189                       const int* numSharingProcsPerID,
00190                       const int* sharingProcs);
00191 
00211     int initSharedIDs(int numShared,
00212                       int idType,
00213                       const int* sharedIDs,
00214                       const int* numSharingProcsPerID,
00215                       const int* const* sharingProcs);
00216 
00219     int addVectorSpace(fei::VectorSpace* inputSpace);
00220 
00227     int initComplete();
00229 
00231 
00235     MPI_Comm getCommunicator() const;
00236 
00266     int getGlobalIndex(int idType,
00267                        int ID,
00268                        int fieldID,
00269                        int fieldOffset,
00270                        int whichComponentOfField,
00271                        int& globalIndex);
00272 
00293     int getGlobalIndex(int idType,
00294                        int ID,
00295                        int fieldID,
00296                        int& globalIndex);
00297 
00311     int getGlobalBlkIndex(int idType,
00312                           int ID,
00313                           int& globalBlkIndex);
00314 
00331     int getGlobalIndices(int numIDs,
00332                          const int* IDs,
00333                          int idType,
00334                          int fieldID,
00335                          int* globalIndices);
00336 
00352     int getGlobalBlkIndices(int numIDs,
00353                          const int* IDs,
00354                          int idType,
00355                          int* globalBlkIndices);
00356 
00375     int getGlobalIndices(int numIDs,
00376                          const int* IDs,
00377                          const int* idTypes,
00378                          const int* fieldIDs,                         
00379                          int* globalIndices);
00380 
00404     int getGlobalIndex(int idType,
00405                        int ID,
00406                        int& globalIndex);
00407 
00411     int getNumDegreesOfFreedom(int idType,
00412                                int ID);
00413 
00416     int getNumFields();
00417 
00422     void getFields(std::vector<int>& fieldIDs);
00423 
00427     int getNumFields(int idType, int ID);
00428 
00440     void getFields(int idType, int ID, std::vector<int>& fieldIDs);
00441 
00444     size_t getNumIDTypes();
00445 
00451     void getIDTypes(std::vector<int>& idTypes) const;
00452 
00461     void getGlobalIndexOffsets(std::vector<int>& globalOffsets) const;
00462 
00471     void getGlobalBlkIndexOffsets(std::vector<int>& globalBlkOffsets) const;
00472 
00477     int getOwnerProcPtIndex(int globalIndex);
00478 
00483     int getOwnerProcBlkIndex(int globalIndex);
00484 
00489     bool isLocal(int idType, int ID);
00490 
00494     bool isLocallyOwned(int idType, int ID);
00495 
00500     unsigned getFieldSize(int fieldID);
00501 
00503     int getNumOwnedAndSharedIDs(int idType);
00504 
00506     int getNumOwnedIDs(int idType);
00507 
00510     int getOwnedAndSharedIDs(int idtype,
00511                     int lenList,
00512                     int* IDs,
00513                     int& numLocalIDs);
00514 
00517     int getOwnedIDs(int idtype,
00518                            int lenList,
00519                            int* IDs,
00520                            int& numLocalIDs);
00521 
00526     int getNumIndices_SharedAndOwned() const;
00527 
00535     int getIndices_SharedAndOwned(std::vector<int>& globalIndices) const;
00536 
00541     int getNumBlkIndices_SharedAndOwned(int& numBlkIndices) const;
00542 
00558     int getBlkIndices_SharedAndOwned(int lenBlkIndices,
00559                                      int* globalBlkIndices,
00560                                      int* blkSizes,
00561                                      int& numBlkIndices);
00562 
00565     int getNumIndices_Owned() const;
00566 
00577     int getIndices_Owned(std::vector<int>& globalIndices) const;
00578     int getIndices_Owned(int lenIndices, int* globalIndices, int& numIndices) const;
00579 
00582     int getNumBlkIndices_Owned() const;
00583 
00597     int getBlkIndices_Owned(int lenBlkIndices,
00598                             int* globalBlkIndices,
00599                             int* blkSizes,
00600                             int& numBlkIndices);
00601 
00603     int getNumSharedIDs(int idType, int& numShared);
00604 
00607     int getGlobalNumIndices() const;
00608 
00611     int getGlobalNumBlkIndices() const;
00612 
00615     int getRecordCollection(int idType, snl_fei::RecordCollection*& records);
00616 
00619     int getRecordCollection(int idType, const snl_fei::RecordCollection*& records) const;
00620 
00623     std::vector<int>& getEqnNumbers();
00624 
00627     const std::vector<int>& getEqnNumbers() const;
00628 
00631     snl_fei::PointBlockMap* getPointBlockMap();
00632     const snl_fei::PointBlockMap* getPointBlockMap() const;
00633 
00634     fei::FieldDofMap<int>& getFieldDofMap();
00635 
00636     void getGlobalIndices(const fei::Pattern* pattern,
00637                           const fei::Record<int>*const* records,
00638                           std::vector<int>& indices);
00639 
00640     void getGlobalBlkIndices(const fei::Pattern* pattern,
00641                              const fei::Record<int>*const* records,
00642                              std::vector<int>& indices);
00643 
00644     void getGlobalIndices(int numRecords,
00645                           const fei::Record<int>*const* records,
00646                           int fieldID,
00647                           int fieldSize,
00648                           int indicesAllocLen,
00649                           int* indices,
00650                           int& numIndices);
00651 
00652     void getGlobalIndices(int numRecords,
00653                           const fei::Record<int>*const* records,
00654                           const int* numFieldsPerID,
00655                           const int* fieldIDs,
00656                           const int* fieldSizes,
00657                           int indicesAllocLen,
00658                           int* indices,
00659                           int& numIndices);
00660 
00661     void getGlobalBlkIndices(int numRecords,
00662                              const fei::Record<int>*const* records,
00663                              int indicesAllocLen,
00664                              int* indices,
00665                              int& numIndices);
00666 
00667     int addDOFs(int fieldID,
00668                             int numInstancesOfThisFieldPerID,
00669                             int idType,
00670                             int numIDs,
00671                             const int* IDs,
00672                             fei::Record<int>** records);
00673 
00674     int addDOFs(int idType,
00675                             int numIDs,
00676                             const int* IDs,
00677                             fei::Record<int>** records);
00678 
00679     std::vector<fei::FieldMask*> fieldMasks_;
00680 
00681   private:
00682     friend class fei::Lookup_Impl;
00683 
00684   private:
00685     VectorSpace(const VectorSpace& src);
00686     VectorSpace& operator=(const VectorSpace& src);
00687 
00688     void compute_shared_ids();
00689 
00690     inline void check_version() { fei::utils::version(); }
00691 
00692     void setOwners_lowestSharing();
00693 
00694     int calculateGlobalIndices();
00695 
00696     void runRecords(fei::Record_Operator<int>& record_op);
00697 
00698     int synchronizeSharedRecords();
00699 
00700     int setLocalEqnNumbers();
00701 
00702     int exchangeGlobalIndices();
00703 
00704     int exchangeFieldInfo(fei::comm_map* ownerPattern,
00705                           fei::comm_map* sharerPattern,
00706                           snl_fei::RecordCollection* recordCollection,
00707                           std::vector<fei::FieldMask*>& fieldMasks);
00708 
00709     fei::SharedIDs<int>& getSharedIDs_private(int idType);
00710 
00711     void setName(const char* name);
00712 
00713   private:
00714     MPI_Comm comm_;
00715 
00716     std::vector<int> idTypes_;
00717     std::map<int,unsigned> fieldDatabase_;
00718     fei::FieldDofMap<int> fieldDofMap_;
00719     int maxFieldSize_;
00720     std::vector<snl_fei::RecordCollection*> recordCollections_;
00721 
00722     std::map<int, fei::SharedIDs<int> > sharedIDTables_;
00723     std::map<int, fei::comm_map*> ownerPatterns_;
00724     std::map<int, fei::comm_map*> sharerPatterns_;
00725 
00726     bool sharedRecordsSynchronized_;
00727 
00728     snl_fei::PointBlockMap* ptBlkMap_;
00729 
00730     std::vector<int> globalOffsets_;
00731     std::vector<int> globalIDOffsets_;
00732 
00733     bool simpleProblem_;
00734 
00735     int firstLocalOffset_, lastLocalOffset_;
00736 
00737     std::vector<int> eqnNumbers_;
00738 
00739     bool newInitData_;
00740 
00741     std::string name_;
00742     std::string dbgprefix_;
00743     bool checkSharedIDs_;
00744   }; // class fei::VectorSpace
00745 
00746   inline std::vector<int>& VectorSpace::getEqnNumbers()
00747     {
00748       return( eqnNumbers_ );
00749     }
00750 
00751   inline const std::vector<int>& VectorSpace::getEqnNumbers() const
00752     {
00753       return( eqnNumbers_ );
00754     }
00755 
00756   inline snl_fei::PointBlockMap* VectorSpace::getPointBlockMap()
00757     {
00758       return( ptBlkMap_ );
00759     }
00760 
00761   inline const snl_fei::PointBlockMap* VectorSpace::getPointBlockMap() const
00762     {
00763       return( ptBlkMap_ );
00764     }
00765 
00766 } // namespace fei
00767 
00768 #endif // _fei_VectorSpace_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:24 2011 for FEI by  doxygen 1.6.3