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_fwd.hpp>
00014 #include <fei_SharedPtr.hpp>
00015 #include <fei_Logger.hpp>
00016 #include <fei_utils.hpp>
00017 #include <fei_CommUtils.hpp>
00018 #include <fei_ctg_set.hpp>
00019 #include <snl_fei_RaggedTable.hpp>
00020 
00021 namespace fei {
00022   class FieldMask;
00023   class Lookup_Impl;
00024   class Pattern;
00025   template<typename GlobalIDType> class Record;
00026   template<typename GlobalIDType> class Record_Operator;
00027   template<typename GlobalIDType> class SharedIDs;
00028 
00060   class VectorSpace : private fei::Logger {
00061   public:
00063     class Factory {
00064     public:
00066       virtual ~Factory(){}
00067 
00069      virtual fei::SharedPtr<VectorSpace> createVectorSpace(MPI_Comm,
00070                                                            const char* name);
00071     };
00072 
00078     VectorSpace(MPI_Comm comm, const char* name = NULL);
00079 
00081     virtual ~VectorSpace();
00082 
00084 
00089     void setParameters(const fei::ParameterSet& paramset);
00090 
00103     void defineFields(int numFields,
00104                       const int* fieldIDs,
00105                       const int* fieldSizes);
00106 
00116     void defineIDTypes(int numIDTypes,
00117                        const int* idTypes);
00118 
00135     int addDOFs(int fieldID,
00136                 int numInstancesOfThisFieldPerID,
00137                 int idType,
00138                 int numIDs,
00139                 const int* IDs);
00140 
00160     int addDOFs(int idType,
00161                 int numIDs,
00162                 const int* IDs);
00163 
00183     int initSharedIDs(int numShared,
00184                       int idType,
00185                       const int* sharedIDs,
00186                       const int* numSharingProcsPerID,
00187                       const int* sharingProcs);
00188 
00208     int initSharedIDs(int numShared,
00209                       int idType,
00210                       const int* sharedIDs,
00211                       const int* numSharingProcsPerID,
00212                       const int* const* sharingProcs);
00213 
00216     int addVectorSpace(fei::VectorSpace* inputSpace);
00217 
00224     int initComplete();
00226 
00228 
00232     MPI_Comm getCommunicator() const;
00233 
00263     int getGlobalIndex(int idType,
00264                        int ID,
00265                        int fieldID,
00266                        int fieldOffset,
00267                        int whichComponentOfField,
00268                        int& globalIndex);
00269 
00290     int getGlobalIndex(int idType,
00291                        int ID,
00292                        int fieldID,
00293                        int& globalIndex);
00294 
00308     int getGlobalBlkIndex(int idType,
00309                           int ID,
00310                           int& globalBlkIndex);
00311 
00328     int getGlobalIndices(int numIDs,
00329                          const int* IDs,
00330                          int idType,
00331                          int fieldID,
00332                          int* globalIndices);
00333 
00349     int getGlobalBlkIndices(int numIDs,
00350                          const int* IDs,
00351                          int idType,
00352                          int* globalBlkIndices);
00353 
00372     int getGlobalIndices(int numIDs,
00373                          const int* IDs,
00374                          const int* idTypes,
00375                          const int* fieldIDs,                         
00376                          int* globalIndices);
00377 
00401     int getGlobalIndex(int idType,
00402                        int ID,
00403                        int& globalIndex);
00404 
00408     int getNumDegreesOfFreedom(int idType,
00409                                int ID);
00410 
00413     int getNumFields();
00414 
00419     void getFields(std::vector<int>& fieldIDs);
00420 
00424     int getNumFields(int idType, int ID);
00425 
00437     void getFields(int idType, int ID, std::vector<int>& fieldIDs);
00438 
00441     size_t getNumIDTypes();
00442 
00448     void getIDTypes(std::vector<int>& idTypes) const;
00449 
00458     void getGlobalIndexOffsets(std::vector<int>& globalOffsets) const;
00459 
00468     void getGlobalBlkIndexOffsets(std::vector<int>& globalBlkOffsets) const;
00469 
00474     int getOwnerProcPtIndex(int globalIndex);
00475 
00480     int getOwnerProcBlkIndex(int globalIndex);
00481 
00486     bool isLocal(int idType, int ID);
00487 
00491     bool isLocallyOwned(int idType, int ID);
00492 
00497     unsigned getFieldSize(int fieldID);
00498 
00500     int getNumOwnedAndSharedIDs(int idType);
00501 
00503     int getNumOwnedIDs(int idType);
00504 
00507     int getOwnedAndSharedIDs(int idtype,
00508                     int lenList,
00509                     int* IDs,
00510                     int& numLocalIDs);
00511 
00514     int getOwnedIDs(int idtype,
00515                            int lenList,
00516                            int* IDs,
00517                            int& numLocalIDs);
00518 
00523     int getNumIndices_SharedAndOwned() const;
00524 
00532     int getIndices_SharedAndOwned(std::vector<int>& globalIndices) const;
00533 
00538     int getNumBlkIndices_SharedAndOwned(int& numBlkIndices) const;
00539 
00555     int getBlkIndices_SharedAndOwned(int lenBlkIndices,
00556                                      int* globalBlkIndices,
00557                                      int* blkSizes,
00558                                      int& numBlkIndices);
00559 
00562     int getNumIndices_Owned() const;
00563 
00574     int getIndices_Owned(std::vector<int>& globalIndices) const;
00575     int getIndices_Owned(int lenIndices, int* globalIndices, int& numIndices) const;
00576 
00579     int getNumBlkIndices_Owned() const;
00580 
00594     int getBlkIndices_Owned(int lenBlkIndices,
00595                             int* globalBlkIndices,
00596                             int* blkSizes,
00597                             int& numBlkIndices);
00598 
00600     int getNumSharedIDs(int idType, int& numShared);
00601 
00604     int getGlobalNumIndices() const;
00605 
00608     int getGlobalNumBlkIndices() const;
00609 
00612     int getRecordCollection(int idType, snl_fei::RecordCollection*& records);
00613 
00616     int getRecordCollection(int idType, const snl_fei::RecordCollection*& records) const;
00617 
00620     std::vector<int>& getEqnNumbers();
00621 
00624     const std::vector<int>& getEqnNumbers() const;
00625 
00628     snl_fei::PointBlockMap* getPointBlockMap();
00629     const snl_fei::PointBlockMap* getPointBlockMap() const;
00630 
00631     void getGlobalIndices(const fei::Pattern* pattern,
00632                           const fei::Record<int>*const* records,
00633                           std::vector<int>& indices);
00634 
00635     void getGlobalBlkIndices(const fei::Pattern* pattern,
00636                              const fei::Record<int>*const* records,
00637                              std::vector<int>& indices);
00638 
00639     void getGlobalIndices(int numRecords,
00640                           const fei::Record<int>*const* records,
00641                           int fieldID,
00642                           int fieldSize,
00643                           int indicesAllocLen,
00644                           int* indices,
00645                           int& numIndices);
00646 
00647     void getGlobalIndices(int numRecords,
00648                           const fei::Record<int>*const* records,
00649                           const int* numFieldsPerID,
00650                           const int* fieldIDs,
00651                           const int* fieldSizes,
00652                           int indicesAllocLen,
00653                           int* indices,
00654                           int& numIndices);
00655 
00656     void getGlobalBlkIndices(int numRecords,
00657                              const fei::Record<int>*const* records,
00658                              int indicesAllocLen,
00659                              int* indices,
00660                              int& numIndices);
00661 
00662     int addDOFs(int fieldID,
00663                             int numInstancesOfThisFieldPerID,
00664                             int idType,
00665                             int numIDs,
00666                             const int* IDs,
00667                             fei::Record<int>** records);
00668 
00669     int addDOFs(int idType,
00670                             int numIDs,
00671                             const int* IDs,
00672                             fei::Record<int>** records);
00673 
00674     std::vector<fei::FieldMask*> fieldMasks_;
00675 
00676   private:
00677     friend class fei::Lookup_Impl;
00678 
00679   private:
00680     VectorSpace(const VectorSpace& src);
00681     VectorSpace& operator=(const VectorSpace& src);
00682 
00683     void compute_shared_ids();
00684 
00685     inline void check_version() { fei::utils::version(); }
00686 
00687     void setOwners_lowestSharing();
00688 
00689     int calculateGlobalIndices();
00690 
00691     void runRecords(fei::Record_Operator<int>& record_op);
00692 
00693     int synchronizeSharedRecords();
00694 
00695     int setLocalEqnNumbers();
00696 
00697     int exchangeGlobalIndices();
00698 
00699     int exchangeFieldInfo(fei::comm_map* ownerPattern,
00700                           fei::comm_map* sharerPattern,
00701                           snl_fei::RecordCollection* recordCollection,
00702                           std::vector<fei::FieldMask*>& fieldMasks);
00703 
00704     fei::SharedIDs<int>& getSharedIDs_private(int idType);
00705 
00706     void setName(const char* name);
00707 
00708   private:
00709     MPI_Comm comm_;
00710 
00711     std::vector<int> idTypes_;
00712     std::map<int,unsigned> fieldDatabase_;
00713     int maxFieldSize_;
00714     std::vector<snl_fei::RecordCollection*> recordCollections_;
00715 
00716     std::map<int, fei::SharedIDs<int> > sharedIDTables_;
00717     std::map<int, fei::comm_map*> ownerPatterns_;
00718     std::map<int, fei::comm_map*> sharerPatterns_;
00719 
00720     bool sharedRecordsSynchronized_;
00721 
00722     snl_fei::PointBlockMap* ptBlkMap_;
00723 
00724     std::vector<int> globalOffsets_;
00725     std::vector<int> globalIDOffsets_;
00726 
00727     bool simpleProblem_;
00728 
00729     int firstLocalOffset_, lastLocalOffset_;
00730 
00731     std::vector<int> eqnNumbers_;
00732 
00733     bool newInitData_;
00734 
00735     std::string name_;
00736     std::string dbgprefix_;
00737     bool checkSharedIDs_;
00738   }; // class fei::VectorSpace
00739 
00740   inline std::vector<int>& VectorSpace::getEqnNumbers()
00741     {
00742       return( eqnNumbers_ );
00743     }
00744 
00745   inline const std::vector<int>& VectorSpace::getEqnNumbers() const
00746     {
00747       return( eqnNumbers_ );
00748     }
00749 
00750   inline snl_fei::PointBlockMap* VectorSpace::getPointBlockMap()
00751     {
00752       return( ptBlkMap_ );
00753     }
00754 
00755   inline const snl_fei::PointBlockMap* VectorSpace::getPointBlockMap() const
00756     {
00757       return( ptBlkMap_ );
00758     }
00759 
00760 } // namespace fei
00761 
00762 #endif // _fei_VectorSpace_hpp_

Generated on Tue Jul 13 09:27:46 2010 for FEI by  doxygen 1.4.7