FEI Version of the Day
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 
00135     int addDOFs(int fieldID,
00136                 int idType,
00137                 int numIDs,
00138                 const int* IDs);
00139 
00159     int addDOFs(int idType,
00160                 int numIDs,
00161                 const int* IDs);
00162 
00182     int initSharedIDs(int numShared,
00183                       int idType,
00184                       const int* sharedIDs,
00185                       const int* numSharingProcsPerID,
00186                       const int* sharingProcs);
00187 
00207     int initSharedIDs(int numShared,
00208                       int idType,
00209                       const int* sharedIDs,
00210                       const int* numSharingProcsPerID,
00211                       const int* const* sharingProcs);
00212 
00215     int addVectorSpace(fei::VectorSpace* inputSpace);
00216 
00223     int initComplete();
00225 
00227 
00231     MPI_Comm getCommunicator() const;
00232 
00262     int getGlobalIndex(int idType,
00263                        int ID,
00264                        int fieldID,
00265                        int fieldOffset,
00266                        int whichComponentOfField,
00267                        int& globalIndex);
00268 
00289     int getGlobalIndex(int idType,
00290                        int ID,
00291                        int fieldID,
00292                        int& globalIndex);
00293 
00307     int getGlobalBlkIndex(int idType,
00308                           int ID,
00309                           int& globalBlkIndex);
00310 
00327     int getGlobalIndices(int numIDs,
00328                          const int* IDs,
00329                          int idType,
00330                          int fieldID,
00331                          int* globalIndices);
00332 
00348     int getGlobalBlkIndices(int numIDs,
00349                          const int* IDs,
00350                          int idType,
00351                          int* globalBlkIndices);
00352 
00371     int getGlobalIndices(int numIDs,
00372                          const int* IDs,
00373                          const int* idTypes,
00374                          const int* fieldIDs,                         
00375                          int* globalIndices);
00376 
00400     int getGlobalIndex(int idType,
00401                        int ID,
00402                        int& globalIndex);
00403 
00407     int getNumDegreesOfFreedom(int idType,
00408                                int ID);
00409 
00412     int getNumFields();
00413 
00418     void getFields(std::vector<int>& fieldIDs);
00419 
00423     int getNumFields(int idType, int ID);
00424 
00436     void getFields(int idType, int ID, std::vector<int>& fieldIDs);
00437 
00440     size_t getNumIDTypes();
00441 
00447     void getIDTypes(std::vector<int>& idTypes) const;
00448 
00457     void getGlobalIndexOffsets(std::vector<int>& globalOffsets) const;
00458 
00467     void getGlobalBlkIndexOffsets(std::vector<int>& globalBlkOffsets) const;
00468 
00473     int getOwnerProcPtIndex(int globalIndex);
00474 
00479     int getOwnerProcBlkIndex(int globalIndex);
00480 
00485     bool isLocal(int idType, int ID);
00486 
00490     bool isLocallyOwned(int idType, int ID);
00491 
00496     unsigned getFieldSize(int fieldID);
00497 
00499     int getNumOwnedAndSharedIDs(int idType);
00500 
00502     int getNumOwnedIDs(int idType);
00503 
00506     int getOwnedAndSharedIDs(int idtype,
00507                     int lenList,
00508                     int* IDs,
00509                     int& numLocalIDs);
00510 
00513     int getOwnedIDs(int idtype,
00514                            int lenList,
00515                            int* IDs,
00516                            int& numLocalIDs);
00517 
00522     int getNumIndices_SharedAndOwned() const;
00523 
00531     int getIndices_SharedAndOwned(std::vector<int>& globalIndices) const;
00532 
00537     int getNumBlkIndices_SharedAndOwned(int& numBlkIndices) const;
00538 
00554     int getBlkIndices_SharedAndOwned(int lenBlkIndices,
00555                                      int* globalBlkIndices,
00556                                      int* blkSizes,
00557                                      int& numBlkIndices);
00558 
00561     int getNumIndices_Owned() const;
00562 
00573     int getIndices_Owned(std::vector<int>& globalIndices) const;
00574     int getIndices_Owned(int lenIndices, int* globalIndices, int& numIndices) const;
00575 
00578     int getNumBlkIndices_Owned() const;
00579 
00593     int getBlkIndices_Owned(int lenBlkIndices,
00594                             int* globalBlkIndices,
00595                             int* blkSizes,
00596                             int& numBlkIndices);
00597 
00599     int getNumSharedIDs(int idType, int& numShared);
00600 
00603     int getGlobalNumIndices() const;
00604 
00607     int getGlobalNumBlkIndices() const;
00608 
00611     int getRecordCollection(int idType, snl_fei::RecordCollection*& records);
00612 
00615     int getRecordCollection(int idType, const snl_fei::RecordCollection*& records) const;
00616 
00619     std::vector<int>& getEqnNumbers();
00620 
00623     const std::vector<int>& getEqnNumbers() const;
00624 
00627     snl_fei::PointBlockMap* getPointBlockMap();
00628     const snl_fei::PointBlockMap* getPointBlockMap() const;
00629 
00630     fei::FieldDofMap<int>& getFieldDofMap();
00631 
00632     void getGlobalIndices(const fei::Pattern* pattern,
00633                           const fei::Record<int>*const* records,
00634                           std::vector<int>& indices);
00635 
00636     void getGlobalIndicesL(const fei::Pattern* pattern,
00637                           const int* 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 getGlobalIndicesL(int numRecords,
00653                           const snl_fei::RecordCollection*const* recordCollections,
00654                           const int* records,
00655                           int fieldID,
00656                           int fieldSize,
00657                           int indicesAllocLen,
00658                           int* indices,
00659                           int& numIndices);
00660 
00661     void getGlobalIndices(int numRecords,
00662                           const fei::Record<int>*const* records,
00663                           const int* numFieldsPerID,
00664                           const int* fieldIDs,
00665                           const int* fieldSizes,
00666                           int indicesAllocLen,
00667                           int* indices,
00668                           int& numIndices);
00669 
00670     void getGlobalIndicesL(int numRecords,
00671                           const snl_fei::RecordCollection*const* recordCollections,
00672                           const int* records,
00673                           const int* numFieldsPerID,
00674                           const int* fieldIDs,
00675                           const int* fieldSizes,
00676                           int indicesAllocLen,
00677                           int* indices,
00678                           int& numIndices);
00679 
00680     void getGlobalBlkIndices(int numRecords,
00681                              const fei::Record<int>*const* records,
00682                              int indicesAllocLen,
00683                              int* indices,
00684                              int& numIndices);
00685 
00686     void getGlobalBlkIndicesL(int numRecords,
00687                              const snl_fei::RecordCollection*const* recordCollections,
00688                              const int* records,
00689                              int indicesAllocLen,
00690                              int* indices,
00691                              int& numIndices);
00692 
00693     int addDOFs(int fieldID,
00694                             int idType,
00695                             int numIDs,
00696                             const int* IDs,
00697                             int* records);
00698 
00699     int addDOFs(int idType,
00700                             int numIDs,
00701                             const int* IDs,
00702                             int* records);
00703 
00704     std::vector<fei::FieldMask*> fieldMasks_;
00705 
00706     void getSendProcs(std::vector<int>& sendProcs) const;
00707 
00708   private:
00709     friend class fei::Lookup_Impl;
00710 
00711   private:
00712     VectorSpace(const VectorSpace& src);
00713     VectorSpace& operator=(const VectorSpace& src);
00714 
00715     void compute_shared_ids();
00716 
00717     inline void check_version() { fei::utils::version(); }
00718 
00719     void setOwners_lowestSharing();
00720 
00721     int calculateGlobalIndices();
00722 
00723     void runRecords(fei::Record_Operator<int>& record_op);
00724 
00725     int synchronizeSharedRecords();
00726 
00727     int setLocalEqnNumbers();
00728 
00729     int exchangeGlobalIndices();
00730 
00731     int exchangeFieldInfo(fei::comm_map* ownerPattern,
00732                           fei::comm_map* sharerPattern,
00733                           snl_fei::RecordCollection* recordCollection,
00734                           std::vector<fei::FieldMask*>& fieldMasks);
00735 
00736     fei::SharedIDs<int>& getSharedIDs_private(int idType);
00737 
00738     void setName(const char* name);
00739 
00740   private:
00741     MPI_Comm comm_;
00742 
00743     std::vector<int> idTypes_;
00744     std::map<int,unsigned> fieldDatabase_;
00745     fei::FieldDofMap<int> fieldDofMap_;
00746     int maxFieldSize_;
00747     std::vector<snl_fei::RecordCollection*> recordCollections_;
00748 
00749     std::map<int, fei::SharedIDs<int> > sharedIDTables_;
00750     std::map<int, fei::comm_map*> ownerPatterns_;
00751     std::map<int, fei::comm_map*> sharerPatterns_;
00752 
00753     bool sharedRecordsSynchronized_;
00754 
00755     snl_fei::PointBlockMap* ptBlkMap_;
00756 
00757     std::vector<int> globalOffsets_;
00758     std::vector<int> globalIDOffsets_;
00759 
00760     bool simpleProblem_;
00761 
00762     int firstLocalOffset_, lastLocalOffset_;
00763 
00764     std::vector<int> eqnNumbers_;
00765 
00766     bool newInitData_;
00767 
00768     std::string name_;
00769     std::string dbgprefix_;
00770     bool checkSharedIDs_;
00771   }; // class fei::VectorSpace
00772 
00773   inline std::vector<int>& VectorSpace::getEqnNumbers()
00774     {
00775       return( eqnNumbers_ );
00776     }
00777 
00778   inline const std::vector<int>& VectorSpace::getEqnNumbers() const
00779     {
00780       return( eqnNumbers_ );
00781     }
00782 
00783   inline snl_fei::PointBlockMap* VectorSpace::getPointBlockMap()
00784     {
00785       return( ptBlkMap_ );
00786     }
00787 
00788   inline const snl_fei::PointBlockMap* VectorSpace::getPointBlockMap() const
00789     {
00790       return( ptBlkMap_ );
00791     }
00792 
00793 } // namespace fei
00794 
00795 #endif // _fei_VectorSpace_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends