FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fei_VectorSpace.hpp
Go to the documentation of this file.
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #ifndef _fei_VectorSpace_hpp_
10 #define _fei_VectorSpace_hpp_
11 
12 #include <fei_macros.hpp>
13 #include <fei_constants.hpp>
14 #include <fei_fwd.hpp>
15 #include <fei_SharedPtr.hpp>
16 #include <fei_Logger.hpp>
17 #include <fei_utils.hpp>
18 #include <fei_CommUtils.hpp>
19 #include <fei_FieldDofMap.hpp>
20 #include <fei_ctg_set.hpp>
21 #include <snl_fei_RaggedTable.hpp>
22 
23 namespace fei {
24  class FieldMask;
25  class Lookup_Impl;
26  class Pattern;
27  template<typename GlobalIDType> class Record;
28  template<typename GlobalIDType> class Record_Operator;
29  template<typename GlobalIDType> class SharedIDs;
30 
62  class VectorSpace : private fei::Logger {
63  public:
65  class Factory {
66  public:
68  virtual ~Factory(){}
69 
72  const char* name);
73  };
74 
80  VectorSpace(MPI_Comm comm, const char* name = NULL);
81 
83  virtual ~VectorSpace();
84 
86 
91  void setParameters(const fei::ParameterSet& paramset);
92 
105  void defineFields(int numFields,
106  const int* fieldIDs,
107  const int* fieldSizes,
108  const int* fieldTypes = NULL);
109 
119  void defineIDTypes(int numIDTypes,
120  const int* idTypes);
121 
122  void setIDMap(int idType,
123  const int* localIDs_begin, const int* localIDs_end,
124  const int* globalIDs_begin, const int* globalIDs_end);
125 
139  int addDOFs(int fieldID,
140  int idType,
141  int numIDs,
142  const int* IDs);
143 
163  int addDOFs(int idType,
164  int numIDs,
165  const int* IDs);
166 
186  int initSharedIDs(int numShared,
187  int idType,
188  const int* sharedIDs,
189  const int* numSharingProcsPerID,
190  const int* sharingProcs);
191 
211  int initSharedIDs(int numShared,
212  int idType,
213  const int* sharedIDs,
214  const int* numSharingProcsPerID,
215  const int* const* sharingProcs);
216 
217  int setOwners(int numShared, int idType, const int* sharedIDs, const int* owners);
218 
221  int addVectorSpace(fei::VectorSpace* inputSpace);
222 
229  int initComplete();
230 
234 
236 
238 
242  MPI_Comm getCommunicator() const;
243 
273  int getGlobalIndex(int idType,
274  int ID,
275  int fieldID,
276  int fieldOffset,
277  int whichComponentOfField,
278  int& globalIndex);
279 
300  int getGlobalIndex(int idType,
301  int ID,
302  int fieldID,
303  int& globalIndex);
304 
318  int getGlobalBlkIndex(int idType,
319  int ID,
320  int& globalBlkIndex);
321 
338  int getGlobalIndices(int numIDs,
339  const int* IDs,
340  int idType,
341  int fieldID,
342  int* globalIndices);
343 
360  int getGlobalIndicesLocalIDs(int numIDs,
361  const int* localIDs,
362  int idType,
363  int fieldID,
364  int* globalIndices);
365 
381  int getGlobalBlkIndices(int numIDs,
382  const int* IDs,
383  int idType,
384  int* globalBlkIndices);
385 
404  int getGlobalIndices(int numIDs,
405  const int* IDs,
406  const int* idTypes,
407  const int* fieldIDs,
408  int* globalIndices);
409 
433  int getGlobalIndex(int idType,
434  int ID,
435  int& globalIndex);
436 
440  int getNumDegreesOfFreedom(int idType,
441  int ID);
442 
445  int getNumFields();
446 
451  void getFields(std::vector<int>& fieldIDs);
452 
456  int getNumFields(int idType, int ID);
457 
469  void getFields(int idType, int ID, std::vector<int>& fieldIDs);
470 
473  size_t getNumIDTypes();
474 
480  void getIDTypes(std::vector<int>& idTypes) const;
481 
490  void getGlobalIndexOffsets(std::vector<int>& globalOffsets) const;
491 
500  void getGlobalBlkIndexOffsets(std::vector<int>& globalBlkOffsets) const;
501 
506  int getOwnerProcPtIndex(int globalIndex);
507 
512  int getOwnerProcBlkIndex(int globalIndex);
513 
518  bool isLocal(int idType, int ID);
519 
523  bool isLocallyOwned(int idType, int ID);
524 
529  unsigned getFieldSize(int fieldID);
530 
532  int getNumOwnedAndSharedIDs(int idType);
533 
535  int getNumOwnedIDs(int idType);
536 
539  int getOwnedAndSharedIDs(int idtype,
540  int lenList,
541  int* IDs,
542  int& numOwnedAndSharedIDs);
543 
546  int getOwnedIDs(int idtype,
547  int lenList,
548  int* IDs,
549  int& numLocalIDs);
550 
555  int getNumIndices_SharedAndOwned() const;
556 
564  int getIndices_SharedAndOwned(std::vector<int>& globalIndices) const;
565 
570  int getNumBlkIndices_SharedAndOwned(int& numBlkIndices) const;
571 
587  int getBlkIndices_SharedAndOwned(int lenBlkIndices,
588  int* globalBlkIndices,
589  int* blkSizes,
590  int& numBlkIndices);
591 
594  int getNumIndices_Owned() const;
595 
606  int getIndices_Owned(std::vector<int>& globalIndices) const;
607  int getIndices_Owned(int lenIndices, int* globalIndices, int& numIndices) const;
608 
611  int getNumBlkIndices_Owned() const;
612 
626  int getBlkIndices_Owned(int lenBlkIndices,
627  int* globalBlkIndices,
628  int* blkSizes,
629  int& numBlkIndices);
630 
632  int getNumSharedIDs(int idType, int& numShared);
633 
636  int getGlobalNumIndices() const;
637 
640  int getGlobalNumBlkIndices() const;
641 
644  int getRecordCollection(int idType, snl_fei::RecordCollection*& records);
645 
648  int getRecordCollection(int idType, const snl_fei::RecordCollection*& records) const;
649 
652  std::vector<int>& getEqnNumbers();
653 
656  const std::vector<int>& getEqnNumbers() const;
657 
662 
664 
665  void getGlobalIndices(const fei::Pattern* pattern,
666  const fei::Record<int>*const* records,
667  std::vector<int>& indices);
668 
669  void getGlobalIndicesL(const fei::Pattern* pattern,
670  const int* records,
671  std::vector<int>& indices);
672 
673  void getGlobalBlkIndices(const fei::Pattern* pattern,
674  const fei::Record<int>*const* records,
675  std::vector<int>& indices);
676 
677  void getGlobalIndices(int numRecords,
678  const fei::Record<int>*const* records,
679  int fieldID,
680  int fieldSize,
681  int indicesAllocLen,
682  int* indices,
683  int& numIndices);
684 
685  void getGlobalIndicesL(int numRecords,
686  const snl_fei::RecordCollection*const* recordCollections,
687  const int* records,
688  int fieldID,
689  int fieldSize,
690  int indicesAllocLen,
691  int* indices,
692  int& numIndices);
693 
694  void getGlobalIndices(int numRecords,
695  const fei::Record<int>*const* records,
696  const int* numFieldsPerID,
697  const int* fieldIDs,
698  const int* fieldSizes,
699  int indicesAllocLen,
700  int* indices,
701  int& numIndices);
702 
703  void getGlobalIndicesL(int numRecords,
704  const snl_fei::RecordCollection*const* recordCollections,
705  const int* records,
706  const int* numFieldsPerID,
707  const int* fieldIDs,
708  const int* fieldSizes,
709  int indicesAllocLen,
710  int* indices,
711  int& numIndices);
712 
713  void getGlobalBlkIndices(int numRecords,
714  const fei::Record<int>*const* records,
715  int indicesAllocLen,
716  int* indices,
717  int& numIndices);
718 
719  void getGlobalBlkIndicesL(int numRecords,
720  const snl_fei::RecordCollection*const* recordCollections,
721  const int* records,
722  int indicesAllocLen,
723  int* indices,
724  int& numIndices);
725 
726  int addDOFs(int fieldID,
727  int idType,
728  int numIDs,
729  const int* IDs,
730  int* records);
731 
732  int addDOFs(int idType,
733  int numIDs,
734  const int* IDs,
735  int* records);
736 
737  std::vector<fei::FieldMask*> fieldMasks_;
738 
739  void getSendProcs(std::vector<int>& sendProcs) const;
740 
741  fei::SharedIDs<int>& getSharedIDs(int idType);
742 
743  private:
744  friend class fei::Lookup_Impl;
745 
746  private:
747  VectorSpace(const VectorSpace& src);
748  VectorSpace& operator=(const VectorSpace& src);
749 
750  void compute_shared_ids(const std::vector<int>& global_min, const std::vector<int>& global_max);
751 
752  inline void check_version() { fei::utils::version(); }
753 
754  void setOwners_shared();
755 
757 
758  void runRecords(fei::Record_Operator<int>& record_op);
759 
760  void runRecords(fei::Record_Operator<int>& record_op, int recordIndex);
761 
763 
764  int setLocalEqnNumbers();
765 
766  int exchangeGlobalIndices();
767 
768  int exchangeFieldInfo(fei::comm_map* ownerPattern,
769  fei::comm_map* sharerPattern,
770  snl_fei::RecordCollection* recordCollection,
771  std::vector<fei::FieldMask*>& fieldMasks);
772 
773  void setName(const char* name);
774 
775  private:
777 
778  std::vector<int> idTypes_;
779  std::map<int,unsigned> fieldDatabase_;
782  std::vector<snl_fei::RecordCollection*> recordCollections_;
783 
784  std::map<int, fei::SharedIDs<int> > sharedIDTables_;
785  std::map<int, fei::comm_map*> ownerPatterns_;
786  std::map<int, fei::comm_map*> sharerPatterns_;
787 
789 
791 
792  std::vector<int> globalOffsets_;
793  std::vector<int> globalIDOffsets_;
794 
796 
798 
799  std::vector<int> eqnNumbers_;
800 
803 
804  std::string name_;
805  std::string dbgprefix_;
807  }; // class fei::VectorSpace
808 
809  inline std::vector<int>& VectorSpace::getEqnNumbers()
810  {
811  return( eqnNumbers_ );
812  }
813 
814  inline const std::vector<int>& VectorSpace::getEqnNumbers() const
815  {
816  return( eqnNumbers_ );
817  }
818 
820  {
821  return( ptBlkMap_ );
822  }
823 
825  {
826  return( ptBlkMap_ );
827  }
828 
829 } // namespace fei
830 
831 #endif // _fei_VectorSpace_hpp_
int getGlobalNumBlkIndices() const
MPI_Comm getCommunicator() const
int getGlobalIndicesLocalIDs(int numIDs, const int *localIDs, int idType, int fieldID, int *globalIndices)
int initSharedIDs(int numShared, int idType, const int *sharedIDs, const int *numSharingProcsPerID, const int *sharingProcs)
int getBlkIndices_Owned(int lenBlkIndices, int *globalBlkIndices, int *blkSizes, int &numBlkIndices)
VectorSpace(MPI_Comm comm, const char *name=NULL)
int getGlobalNumIndices() const
std::vector< snl_fei::RecordCollection * > recordCollections_
int getIndices_SharedAndOwned(std::vector< int > &globalIndices) const
std::string dbgprefix_
void compute_shared_ids(const std::vector< int > &global_min, const std::vector< int > &global_max)
int getOwnedIDs(int idtype, int lenList, int *IDs, int &numLocalIDs)
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
std::map< int, unsigned > fieldDatabase_
fei::FieldDofMap< int > & getFieldDofMap()
int addDOFs(int fieldID, int idType, int numIDs, const int *IDs)
int getBlkIndices_SharedAndOwned(int lenBlkIndices, int *globalBlkIndices, int *blkSizes, int &numBlkIndices)
#define MPI_Comm
Definition: fei_mpi.h:56
void setParameters(const fei::ParameterSet &paramset)
std::vector< int > globalOffsets_
virtual fei::SharedPtr< VectorSpace > createVectorSpace(MPI_Comm, const char *name)
int addVectorSpace(fei::VectorSpace *inputSpace)
std::map< int, fei::comm_map * > sharerPatterns_
int getGlobalIndex(int idType, int ID, int fieldID, int fieldOffset, int whichComponentOfField, int &globalIndex)
void getIDTypes(std::vector< int > &idTypes) const
int getGlobalIndices(int numIDs, const int *IDs, int idType, int fieldID, int *globalIndices)
int setOwners(int numShared, int idType, const int *sharedIDs, const int *owners)
int getOwnedAndSharedIDs(int idtype, int lenList, int *IDs, int &numOwnedAndSharedIDs)
void getGlobalBlkIndicesL(int numRecords, const snl_fei::RecordCollection *const *recordCollections, const int *records, int indicesAllocLen, int *indices, int &numIndices)
int getNumOwnedIDs(int idType)
int getOwnerProcBlkIndex(int globalIndex)
std::vector< int > globalIDOffsets_
int getNumBlkIndices_SharedAndOwned(int &numBlkIndices) const
void defineIDTypes(int numIDTypes, const int *idTypes)
bool isLocallyOwned(int idType, int ID)
std::vector< int > eqnNumbers_
fei::SharedIDs< int > & getSharedIDs(int idType)
int getOwnerProcPtIndex(int globalIndex)
std::map< int, fei::comm_map * > ownerPatterns_
void getGlobalBlkIndexOffsets(std::vector< int > &globalBlkOffsets) const
std::vector< fei::FieldMask * > fieldMasks_
int getNumSharedIDs(int idType, int &numShared)
bool initCompleteAlreadyCalled() const
int getGlobalBlkIndex(int idType, int ID, int &globalBlkIndex)
int getIndices_Owned(std::vector< int > &globalIndices) const
snl_fei::PointBlockMap * getPointBlockMap()
void getFields(std::vector< int > &fieldIDs)
void getGlobalIndexOffsets(std::vector< int > &globalOffsets) const
std::map< int, fei::SharedIDs< int > > sharedIDTables_
VectorSpace & operator=(const VectorSpace &src)
void runRecords(fei::Record_Operator< int > &record_op)
void setName(const char *name)
int getNumBlkIndices_Owned() const
int getNumOwnedAndSharedIDs(int idType)
void setIDMap(int idType, const int *localIDs_begin, const int *localIDs_end, const int *globalIDs_begin, const int *globalIDs_end)
const char * version()
Definition: fei_utils.hpp:53
int getNumIndices_SharedAndOwned() const
unsigned getFieldSize(int fieldID)
std::vector< int > idTypes_
void getGlobalIndicesL(const fei::Pattern *pattern, const int *records, std::vector< int > &indices)
void getSendProcs(std::vector< int > &sendProcs) const
int getNumDegreesOfFreedom(int idType, int ID)
int getRecordCollection(int idType, snl_fei::RecordCollection *&records)
snl_fei::PointBlockMap * ptBlkMap_
int getGlobalBlkIndices(int numIDs, const int *IDs, int idType, int *globalBlkIndices)
std::vector< int > & getEqnNumbers()
fei::FieldDofMap< int > fieldDofMap_
int getNumIndices_Owned() const
int exchangeFieldInfo(fei::comm_map *ownerPattern, fei::comm_map *sharerPattern, snl_fei::RecordCollection *recordCollection, std::vector< fei::FieldMask * > &fieldMasks)
bool isLocal(int idType, int ID)