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   class Record;
00026   class Record_Operator;
00027   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(int lenIndices,
00575                          int* globalIndices,
00576                          int& numIndices) const;
00577 
00580     int getNumBlkIndices_Owned() const;
00581 
00595     int getBlkIndices_Owned(int lenBlkIndices,
00596                             int* globalBlkIndices,
00597                             int* blkSizes,
00598                             int& numBlkIndices);
00599 
00601     int getNumSharedIDs(int idType, int& numShared);
00602 
00605     int getGlobalNumIndices() const;
00606 
00609     int getGlobalNumBlkIndices() const;
00610 
00613     int getRecordCollection(int idType, snl_fei::RecordCollection*& records);
00614 
00617     int getRecordCollection(int idType, const snl_fei::RecordCollection*& records) const;
00618 
00621     std::vector<int>& getEqnNumbers();
00622 
00625     const std::vector<int>& getEqnNumbers() const;
00626 
00629     snl_fei::PointBlockMap* getPointBlockMap();
00630     const snl_fei::PointBlockMap* getPointBlockMap() const;
00631 
00632     void getGlobalIndices(const fei::Pattern* pattern,
00633                           const fei::Record*const* records,
00634                           std::vector<int>& indices);
00635 
00636     void getGlobalBlkIndices(const fei::Pattern* pattern,
00637                              const fei::Record*const* records,
00638                              std::vector<int>& indices);
00639 
00640     void getGlobalIndices(int numRecords,
00641                           const fei::Record*const* records,
00642                           int fieldID,
00643                           int fieldSize,
00644                           int indicesAllocLen,
00645                           int* indices,
00646                           int& numIndices);
00647 
00648     void getGlobalIndices(int numRecords,
00649                           const fei::Record*const* records,
00650                           const int* numFieldsPerID,
00651                           const int* fieldIDs,
00652                           const int* fieldSizes,
00653                           int indicesAllocLen,
00654                           int* indices,
00655                           int& numIndices);
00656 
00657     void getGlobalBlkIndices(int numRecords,
00658                              const fei::Record*const* records,
00659                              int indicesAllocLen,
00660                              int* indices,
00661                              int& numIndices);
00662 
00663     int addDOFs(int fieldID,
00664                             int numInstancesOfThisFieldPerID,
00665                             int idType,
00666                             int numIDs,
00667                             const int* IDs,
00668                             fei::Record** records);
00669 
00670     int addDOFs(int idType,
00671                             int numIDs,
00672                             const int* IDs,
00673                             fei::Record** records);
00674 
00675     std::vector<fei::FieldMask*> fieldMasks_;
00676 
00677   private:
00678     friend class fei::Lookup_Impl;
00679 
00680   private:
00681     VectorSpace(const VectorSpace& src);
00682     VectorSpace& operator=(const VectorSpace& src);
00683 
00684     inline void check_version() { fei::utils::version(); }
00685 
00686     int setOwners_lowestSharing();
00687 
00688     int calculateGlobalIndices();
00689 
00690     void runRecords(fei::Record_Operator& record_op);
00691 
00692     int synchronizeSharedRecords();
00693 
00694     int setLocalEqnNumbers();
00695 
00696     int exchangeGlobalIndices();
00697 
00698     int exchangeFieldInfo(fei::comm_map* ownerPattern,
00699                           fei::comm_map* sharerPattern,
00700                           snl_fei::RecordCollection* recordCollection,
00701                           std::vector<fei::FieldMask*>& fieldMasks);
00702 
00703     void getSharedIDs_private(int idType, fei::SharedIDs*& shIDs);
00704 
00705     void setName(const char* name);
00706 
00707   private:
00708     MPI_Comm comm_;
00709 
00710     std::vector<int> idTypes_;
00711     std::map<int,unsigned> fieldDatabase_;
00712     int maxFieldSize_;
00713     std::vector<snl_fei::RecordCollection*> recordCollections_;
00714 
00715     std::vector<int> sharedIDTypes_;
00716     std::vector<fei::SharedIDs*> sharedIDTables_;
00717     std::vector<fei::comm_map*> ownerPatterns_;
00718     std::vector<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 Wed May 12 21:30:42 2010 for FEI by  doxygen 1.4.7