FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_MatrixGraph_Impl2.hpp
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_MatrixGraph_Impl2_hpp_
10 #define _fei_MatrixGraph_Impl2_hpp_
11 
12 #include <fei_macros.hpp>
13 #include <fei_SharedPtr.hpp>
14 #include <fei_VectorSpace.hpp>
15 #include <fei_Reducer.hpp>
16 #include <fei_Graph.hpp>
17 #include <snl_fei_Constraint.hpp>
18 #include <fei_Record.hpp>
19 #include <fei_Logger.hpp>
20 #include <fei_SparseRowGraph.hpp>
21 #include <fei_MatrixGraph.hpp>
22 
23 #include <vector>
24 #include <map>
25 
26 namespace fei {
27  class ConnectivityBlock;
28  class Pattern;
29 
34  public:
36  class Factory {
37  public:
39  virtual ~Factory(){}
40 
48  const char* name);
49  };
50 
58  const char* name = NULL);
59 
61  virtual ~MatrixGraph_Impl2();
62 
70  void setParameters(const fei::ParameterSet& params);
71 
79 
84 
92 
97 
117  int definePattern(int numIDs,
118  int idType);
119 
140  int definePattern(int numIDs,
141  int idType,
142  int fieldID);
143 
167  int definePattern(int numIDs,
168  int idType,
169  const int* numFieldsPerID,
170  const int* fieldIDs);
171 
194  int definePattern(int numIDs,
195  const int* idTypes,
196  const int* numFieldsPerID,
197  const int* fieldIDs);
198 
221  int initConnectivityBlock(int blockID,
222  int numConnectivityLists,
223  int patternID,
224  bool diagonal=false);
225 
248  int initConnectivityBlock(int numConnectivityLists,
249  int patternID,
250  bool diagonal=false);
251 
272  int initConnectivityBlock(int blockID,
273  int numConnectivityLists,
274  int rowPatternID,
275  int colPatternID);
276 
289  int initConnectivity(int blockID,
290  int connectivityID,
291  const int* connectedIdentifiers);
292 
307  int initConnectivity(int blockID,
308  int connectivityID,
309  const int* rowConnectedIdentifiers,
310  const int* colConnectedIdentifiers);
311 
323  int initConnectivity(int patternID,
324  const int* connectedIdentifiers);
325 
340  int initConnectivity(int rowPatternID,
341  const int* rowConnectedIdentifiers,
342  int colPatternID,
343  const int* colConnectedIdentifiers);
344 
360  int initConnectivity(int idType,
361  int numRows,
362  const int* rowIDs,
363  const int* rowOffsets,
364  const int* packedColumnIDs);
365 
383  int initConnectivity(int idType,
384  int fieldID,
385  int numRows,
386  const int* rowIDs,
387  const int* rowOffsets,
388  const int* packedColumnIDs);
389 
404  int initConnectivity(int idType,
405  int numRows,
406  const int* rowIDs,
407  const int* rowLengths,
408  const int*const* columnIDs);
409 
412  int initLagrangeConstraint(int constraintID,
413  int constraintIDType,
414  int numIDs,
415  const int* idTypes,
416  const int* IDs,
417  const int* fieldIDs);
418 
421  int initPenaltyConstraint(int constraintID,
422  int constraintIDType,
423  int numIDs,
424  const int* idTypes,
425  const int* IDs,
426  const int* fieldIDs);
427 
430  int initSlaveConstraint(int numIDs,
431  const int* idTypes,
432  const int* IDs,
433  const int* fieldIDs,
434  int offsetOfSlave,
435  int offsetIntoSlaveField,
436  const double* weights,
437  double rhsValue);
438 
439  bool newSlaveData();
440 
443  bool hasSlaveDof(int ID, int idType);
444 
449  int initComplete();
450 
463  createGraph(bool blockEntryGraph,
464  bool localRowGraph_includeSharedRows=false);
465 
469  int compareStructure(const fei::MatrixGraph& matrixGraph,
470  bool& equivalent) const;
471 
473  int getNumConnectivityBlocks() const;
474 
476  std::map<int,fei::ConnectivityBlock*>& getConnectivityBlocks();
477 
479  int getConnectivityBlockIDs(std::vector<int>& blockIDs) const;
480 
483  int getNumIDsPerConnectivityList(int blockID) const;
484 
488  int getConnectivityNumIndices(int blockID) const;
489 
494  int getConnectivityNumIndices(int blockID,
495  int& numRowIndices,
496  int& numColIndices);
497 
500  int getConnectivityIndices(int blockID,
501  int connectivityID,
502  int indicesAllocLen,
503  int* indices,
504  int& numIndices);
505 
509  int getConnectivityIndices(int blockID,
510  int connectivityID,
511  int rowIndicesAllocLen,
512  int* rowIndices,
513  int& numRowIndices,
514  int colIndicesAllocLen,
515  int* colIndices,
516  int& numColIndices);
517 
520  int getPatternNumIndices(int patternID,
521  int& numIndices);
522 
525  int getPatternIndices(int patternID,
526  const int* IDs,
527  std::vector<int>& indices);
528 
530  int getLocalNumLagrangeConstraints() const;
531 
534  int getGlobalNumSlaveConstraints() const;
535 
539  ConstraintType* getLagrangeConstraint(int constraintID);
540 
544  std::map<int, ConstraintType* >& getLagrangeConstraints();
545 
549  ConstraintType* getPenaltyConstraint(int constraintID);
550 
554  ConstraintType* getSlaveConstraint(int constraintID);
555 
560  std::vector<int>& globalIndices);
561 
565  const fei::ConnectivityBlock* getConnectivityBlock(int blockID) const;
566 
571 
573  void setIndicesMode(int mode);
574 
577 
581  fei::Pattern* getPattern(int patternID);
582 
584  int createSlaveMatrices();
585 
588 
591 
593  void getConstrainedIndices(std::vector<int>& crindices) const;
594 
595  private:
596  int createAlgebraicGraph(bool blockEntryGraph,
597  fei::Graph* graph,
598  bool gatherFromOverlap);
599 
600  int addBlockToGraph_multiField_symmetric(fei::Graph* graph,
601  fei::ConnectivityBlock* cblock);
602  int addBlockToGraph_multiField_nonsymmetric(fei::Graph* graph,
603  fei::ConnectivityBlock* cblock);
604  int addBlockToGraph_singleField_symmetric(fei::Graph* graph,
605  fei::ConnectivityBlock* cblock);
606  int addBlockToGraph_singleField_nonsymmetric(fei::Graph* graph,
607  fei::ConnectivityBlock* cblock);
608  int addBlockToGraph_noField_symmetric(fei::Graph* graph,
609  fei::ConnectivityBlock* cblock);
610  int addBlockToGraph_sparse(fei::Graph* graph,
611  fei::ConnectivityBlock* cblock);
612 
613  int addPattern(fei::Pattern* pattern);
614 
615  int getConnectivityIndices_multiField(const snl_fei::RecordCollection*const* recordCollections,
616  int* records, int numRecords,
617  const int* numFieldsPerID,
618  const int* fieldIDs,
619  const int* fieldSizes,
620  int indicesAllocLen,
621  int* indices,
622  int& numIndices);
623 
624  int getConnectivityIndices_singleField(const snl_fei::RecordCollection*const* recordCollections,
625  int* records, int numRecords,
626  int fieldID, int fieldSize,
627  int indicesAllocLen,
628  int* indices,
629  int& numIndices);
630 
631  int getConnectivityIndices_noField(const snl_fei::RecordCollection*const* recordCollections,
632  int* records,
633  int numRecords,
634  int indicesAllocLen,
635  int* indices,
636  int& numIndices);
637 
638  int getConnectivityRecords(fei::VectorSpace* vecSpace,
639  int idType,
640  int numIDs,
641  const int* IDs,
642  int* records);
643 
644  int getConnectivityRecords(fei::VectorSpace* vecSpace,
645  int idType,
646  int fieldID,
647  int numIDs,
648  const int* IDs,
649  int* records);
650 
651  int getConnectivityRecords(fei::Pattern* pattern,
652  fei::VectorSpace* solnSpace,
653  const int* connectedIdentifiers,
654  int* recordList);
655 
656  int exchangeBlkEqnSizes(fei::Graph* graph);
657 
658  int addLagrangeConstraintsToGraph(fei::Graph* graph);
659 
660  int addPenaltyConstraintsToGraph(fei::Graph* graph);
661 
662  void setName(const char* name);
663 
664  private:
665  int localProc_, numProcs_;
666 
667  MPI_Comm comm_;
668 
671  bool haveRowSpace_;
672  bool haveColSpace_;
673  bool symmetric_;
674 
675  fei::SharedPtr<fei::SparseRowGraph> remotelyOwnedGraphRows_;
676 
677  bool simpleProblem_;
678  bool blockEntryGraph_;
679 
680  std::map<int,fei::Pattern*> patterns_;
681 
682  std::map<int,fei::ConnectivityBlock*> connectivityBlocks_;
683  int arbitraryBlockCounter_;
684 
685  std::vector<fei::ConnectivityBlock*> sparseBlocks_;
686 
687  std::map<int, ConstraintType* >
688  lagrangeConstraints_, penaltyConstraints_, slaveConstraints_;
689 
690  bool ptEqualBlk_;
691 
692  bool newSlaveData_;
693 
694  int localNumSlaves_;
695  int globalNumSlaves_;
696 
699  bool g_nonzero_;
700 
702 
703  std::string name_;
704  std::string dbgprefix_;
705 
706  std::vector<int> tmpIntArray1_, tmpIntArray2_;
707 
708  int* vspcEqnPtr_;
709 
710  std::set<int> constrained_indices_;
711 
712  bool includeAllSlaveConstraints_;
713 };//class MatrixGraph_Impl2
714 
716  {
717  return(rowSpace_);
718  }
719 
721  {
722  return(colSpace_);
723  }
724 
725  inline std::map<int,fei::ConnectivityBlock*>& MatrixGraph_Impl2::getConnectivityBlocks()
726  {
727  return(connectivityBlocks_);
728  }
729 
731  {
732  return( globalNumSlaves_ );
733  }
734 
735  inline std::map<int, ConstraintType* >& MatrixGraph_Impl2::getLagrangeConstraints()
736  {
737  return( lagrangeConstraints_ );
738  }
739 }//namespace fei
740 
741 #endif
742 
int initLagrangeConstraint(int constraintID, int constraintIDType, int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs)
int definePattern(int numIDs, int idType)
fei::SharedPtr< fei::VectorSpace > getColSpace()
fei::SharedPtr< fei::SparseRowGraph > createGraph(bool blockEntryGraph, bool localRowGraph_includeSharedRows=false)
fei::Pattern * getPattern(int patternID)
int getConnectivityIndices(int blockID, int connectivityID, int indicesAllocLen, int *indices, int &numIndices)
std::map< int, fei::ConnectivityBlock * > & getConnectivityBlocks()
int initConnectivityBlock(int blockID, int numConnectivityLists, int patternID, bool diagonal=false)
int getConnectivityBlockIDs(std::vector< int > &blockIDs) const
fei::SharedPtr< FillableMat > getSlaveDependencyMatrix()
MatrixGraph_Impl2(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > colSpace, const char *name=NULL)
fei::SharedPtr< fei::VectorSpace > getRowSpace()
int getConnectivityNumIndices(int blockID) const
void setRowSpace(fei::SharedPtr< fei::VectorSpace > rowSpace)
const fei::ConnectivityBlock * getConnectivityBlock(int blockID) const
int initSlaveConstraint(int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs, int offsetOfSlave, int offsetIntoSlaveField, const double *weights, double rhsValue)
int getNumIDsPerConnectivityList(int blockID) const
virtual fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > columnSpace, const char *name)
ConstraintType * getPenaltyConstraint(int constraintID)
ConstraintType * getSlaveConstraint(int constraintID)
int getPatternNumIndices(int patternID, int &numIndices)
void getConstrainedIndices(std::vector< int > &crindices) const
int initConnectivity(int blockID, int connectivityID, const int *connectedIdentifiers)
int getPatternIndices(int patternID, const int *IDs, std::vector< int > &indices)
void setParameters(const fei::ParameterSet &params)
int compareStructure(const fei::MatrixGraph &matrixGraph, bool &equivalent) const
ConstraintType * getLagrangeConstraint(int constraintID)
int getConstraintConnectivityIndices(ConstraintType *cr, std::vector< int > &globalIndices)
fei::SharedPtr< fei::Reducer > getReducer()
int initPenaltyConstraint(int constraintID, int constraintIDType, int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs)
bool hasSlaveDof(int ID, int idType)
std::map< int, ConstraintType * > & getLagrangeConstraints()
fei::SharedPtr< fei::SparseRowGraph > getRemotelyOwnedGraphRows()
void setColumnSpace(fei::SharedPtr< fei::VectorSpace > columnSpace)