fei_MatrixGraph_Impl2.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_MatrixGraph_Impl2_hpp_
00010 #define _fei_MatrixGraph_Impl2_hpp_
00011 
00012 #include <fei_macros.hpp>
00013 #include <fei_SharedPtr.hpp>
00014 #include <fei_VectorSpace.hpp>
00015 #include <fei_Reducer.hpp>
00016 #include <fei_Graph.hpp>
00017 #include <snl_fei_Constraint.hpp>
00018 #include <fei_Record.hpp>
00019 #include <fei_Logger.hpp>
00020 #include <fei_SparseRowGraph.hpp>
00021 #include <fei_MatrixGraph.hpp>
00022 
00023 #include <vector>
00024 #include <map>
00025 
00026 namespace fei {
00027   class ConnectivityBlock;
00028   class Pattern;
00029 
00033 class MatrixGraph_Impl2 : public fei::MatrixGraph, private fei::Logger {
00034  public:
00036   class Factory {
00037   public:
00039     virtual ~Factory(){}
00040 
00045     virtual fei::SharedPtr<fei::MatrixGraph>
00046                  createMatrixGraph(fei::SharedPtr<fei::VectorSpace> rowSpace,
00047                                    fei::SharedPtr<fei::VectorSpace> columnSpace,
00048                                    const char* name);
00049   };
00050 
00056   MatrixGraph_Impl2(fei::SharedPtr<fei::VectorSpace> rowSpace,
00057               fei::SharedPtr<fei::VectorSpace> colSpace,
00058               const char* name = NULL);
00059 
00061   virtual ~MatrixGraph_Impl2();
00062 
00070   void setParameters(const fei::ParameterSet& params);
00071 
00078   void setRowSpace(fei::SharedPtr<fei::VectorSpace> rowSpace);
00079 
00083   fei::SharedPtr<fei::VectorSpace> getRowSpace();
00084 
00091   void setColumnSpace(fei::SharedPtr<fei::VectorSpace> columnSpace);
00092 
00096   fei::SharedPtr<fei::VectorSpace> getColSpace();
00097 
00117   int definePattern(int numIDs,
00118                     int idType);
00119 
00140   int definePattern(int numIDs,
00141                     int idType,
00142                     int fieldID);
00143 
00167    int definePattern(int numIDs,
00168                      int idType,
00169                      const int* numFieldsPerID,
00170                      const int* fieldIDs);
00171 
00194    int definePattern(int numIDs,
00195                      const int* idTypes,
00196                      const int* numFieldsPerID,
00197                      const int* fieldIDs);
00198 
00221    int initConnectivityBlock(int blockID,
00222                              int numConnectivityLists,
00223                              int patternID,
00224                              bool diagonal=false);
00225 
00248    int initConnectivityBlock(int numConnectivityLists,
00249                              int patternID,
00250                              bool diagonal=false);
00251 
00272    int initConnectivityBlock(int blockID,
00273                              int numConnectivityLists,
00274                              int rowPatternID,
00275                              int colPatternID);
00276 
00289    int initConnectivity(int blockID,
00290                         int connectivityID,
00291                         const int* connectedIdentifiers);
00292 
00307    int initConnectivity(int blockID,
00308                         int connectivityID,
00309                         const int* rowConnectedIdentifiers,
00310                         const int* colConnectedIdentifiers);
00311 
00323    int initConnectivity(int patternID,
00324                         const int* connectedIdentifiers);
00325 
00340    int initConnectivity(int rowPatternID,
00341                         const int* rowConnectedIdentifiers,
00342                         int colPatternID,
00343                         const int* colConnectedIdentifiers);
00344 
00360    int initConnectivity(int idType,
00361                         int numRows,
00362                         const int* rowIDs,
00363                         const int* rowOffsets,
00364                         const int* packedColumnIDs);
00365 
00383    int initConnectivity(int idType,
00384                         int fieldID,
00385                         int numRows,
00386                         const int* rowIDs,
00387                         const int* rowOffsets,
00388                         const int* packedColumnIDs);
00389 
00404    int initConnectivity(int idType,
00405                         int numRows,
00406                         const int* rowIDs,
00407                         const int* rowLengths,
00408                         const int*const* columnIDs);
00409 
00412    int initLagrangeConstraint(int constraintID,
00413                               int constraintIDType,
00414                               int numIDs,
00415                               const int* idTypes,
00416                               const int* IDs,
00417                               const int* fieldIDs);
00418 
00421    int initPenaltyConstraint(int constraintID,
00422                              int constraintIDType,
00423                              int numIDs,
00424                              const int* idTypes,
00425                              const int* IDs,
00426                              const int* fieldIDs);
00427 
00430    int initSlaveConstraint(int numIDs,
00431                            const int* idTypes,
00432                            const int* IDs,
00433                            const int* fieldIDs,
00434                            int offsetOfSlave,
00435                            int offsetIntoSlaveField,
00436                            const double* weights,
00437                            double rhsValue);
00438 
00439    bool newSlaveData();
00440 
00443    bool hasSlaveDof(int ID, int idType);
00444 
00449    int initComplete();
00450 
00462    fei::SharedPtr<fei::SparseRowGraph>
00463      createGraph(bool blockEntryGraph,
00464                  bool localRowGraph_includeSharedRows=false);
00465 
00469    int compareStructure(const fei::MatrixGraph& matrixGraph,
00470                         bool& equivalent) const;
00471 
00473    int getNumConnectivityBlocks() const;
00474 
00476    std::map<int,fei::ConnectivityBlock*>& getConnectivityBlocks();
00477 
00479    int getConnectivityBlockIDs(std::vector<int>& blockIDs) const;
00480 
00483    int getNumIDsPerConnectivityList(int blockID) const;
00484 
00488    int getConnectivityNumIndices(int blockID) const;
00489 
00494    int getConnectivityNumIndices(int blockID,
00495                                  int& numRowIndices,
00496                                  int& numColIndices);
00497 
00500    int getConnectivityIndices(int blockID,
00501                               int connectivityID,
00502                               int indicesAllocLen,
00503                               int* indices,
00504                               int& numIndices);
00505 
00509    int getConnectivityIndices(int blockID,
00510                               int connectivityID,
00511                               int rowIndicesAllocLen,
00512                               int* rowIndices,
00513                               int& numRowIndices,
00514                               int colIndicesAllocLen,
00515                               int* colIndices,
00516                               int& numColIndices);
00517 
00520    int getPatternNumIndices(int patternID,
00521                             int& numIndices);
00522 
00525    int getPatternIndices(int patternID,
00526                          const int* IDs,
00527                          std::vector<int>& indices);
00528 
00530    int getLocalNumLagrangeConstraints() const;
00531 
00534    int getGlobalNumSlaveConstraints() const;
00535 
00539    ConstraintType* getLagrangeConstraint(int constraintID);
00540 
00544    std::map<int, ConstraintType* >& getLagrangeConstraints();
00545 
00549    ConstraintType* getPenaltyConstraint(int constraintID);
00550 
00554    ConstraintType* getSlaveConstraint(int constraintID);
00555 
00559    int getConstraintConnectivityIndices(ConstraintType* cr,
00560                                         std::vector<int>& globalIndices);
00561 
00565    const fei::ConnectivityBlock* getConnectivityBlock(int blockID) const;
00566 
00570    fei::ConnectivityBlock* getConnectivityBlock(int blockID);
00571 
00573    void setIndicesMode(int mode);
00574 
00576    fei::SharedPtr<FillableMat> getSlaveDependencyMatrix();
00577 
00581    fei::Pattern* getPattern(int patternID);
00582 
00584    int createSlaveMatrices();
00585 
00587    fei::SharedPtr<fei::Reducer> getReducer();
00588 
00590    fei::SharedPtr<fei::SparseRowGraph> getRemotelyOwnedGraphRows();
00591 
00593    void getConstrainedIndices(std::vector<int>& crindices) const;
00594 
00595  private:
00596    int createAlgebraicGraph(bool blockEntryGraph,
00597                             fei::Graph* graph,
00598                             bool gatherFromOverlap);
00599 
00600    int addBlockToGraph_multiField_symmetric(fei::Graph* graph,
00601                                             fei::ConnectivityBlock* cblock);
00602    int addBlockToGraph_multiField_nonsymmetric(fei::Graph* graph,
00603                                             fei::ConnectivityBlock* cblock);
00604    int addBlockToGraph_singleField_symmetric(fei::Graph* graph,
00605                                              fei::ConnectivityBlock* cblock);
00606    int addBlockToGraph_singleField_nonsymmetric(fei::Graph* graph,
00607                                              fei::ConnectivityBlock* cblock);
00608    int addBlockToGraph_noField_symmetric(fei::Graph* graph,
00609                                          fei::ConnectivityBlock* cblock);
00610    int addBlockToGraph_sparse(fei::Graph* graph,
00611                               fei::ConnectivityBlock* cblock);
00612 
00613    int addPattern(fei::Pattern* pattern);
00614 
00615    int getConnectivityIndices_multiField(fei::Record<int>** records, int numRecords,
00616                                          const int* numFieldsPerID,
00617                                          const int* fieldIDs,
00618                                          const int* fieldSizes,
00619                                          int indicesAllocLen,
00620                                          int* indices,
00621                                          int& numIndices);
00622 
00623    int getConnectivityIndices_singleField(fei::Record<int>** records, int numRecords,
00624                                           int fieldID, int fieldSize,
00625                                           int indicesAllocLen,
00626                                           int* indices,
00627                                           int& numIndices);
00628 
00629    int getConnectivityIndices_singleField_unreduced(fei::Record<int>** records,
00630                                                     int numRecords,
00631                                                     int* idTypes,
00632                                                     int fieldID, int fieldSize,
00633                                                     int indicesAllocLen,
00634                                                     int* indices,
00635                                                     int& numIndices);
00636 
00637    int getConnectivityIndices_noField(fei::Record<int>** records,
00638                                       int numRecords,
00639                                       int indicesAllocLen,
00640                                       int* indices,
00641                                       int& numIndices);
00642 
00643    int getConnectivityRecords(fei::VectorSpace* vecSpace,
00644                               int idType,
00645                               int numIDs,
00646                               const int* IDs,
00647                               fei::Record<int>** records);
00648 
00649    int getConnectivityRecords(fei::VectorSpace* vecSpace,
00650                               int idType,
00651                               int fieldID,
00652                               int numIDs,
00653                               const int* IDs,
00654                               fei::Record<int>** records);
00655 
00656    int getConnectivityRecords(fei::Pattern* pattern,
00657                               fei::VectorSpace* solnSpace,
00658                               const int* connectedIdentifiers,
00659                               fei::Record<int>** recordList);
00660 
00661    int exchangeBlkEqnSizes(fei::Graph* graph);
00662 
00663    int addLagrangeConstraintsToGraph(fei::Graph* graph);
00664 
00665    int addPenaltyConstraintsToGraph(fei::Graph* graph);
00666 
00667    void setName(const char* name);
00668 
00669  private:
00670    int localProc_, numProcs_;
00671 
00672    MPI_Comm comm_;
00673 
00674    fei::SharedPtr<fei::VectorSpace> rowSpace_;
00675    fei::SharedPtr<fei::VectorSpace> colSpace_;
00676    bool haveRowSpace_;
00677    bool haveColSpace_;
00678    bool symmetric_;
00679 
00680    fei::SharedPtr<fei::SparseRowGraph> remotelyOwnedGraphRows_;
00681 
00682    bool simpleProblem_;
00683    bool blockEntryGraph_;
00684 
00685    std::map<int,fei::Pattern*> patterns_;
00686 
00687    std::map<int,fei::ConnectivityBlock*> connectivityBlocks_;
00688    int arbitraryBlockCounter_;
00689 
00690    std::vector<fei::ConnectivityBlock*> sparseBlocks_;
00691 
00692    std::map<int, ConstraintType* >
00693      lagrangeConstraints_, penaltyConstraints_, slaveConstraints_;
00694 
00695    bool ptEqualBlk_;
00696 
00697    bool newSlaveData_;
00698 
00699    int localNumSlaves_;
00700    int globalNumSlaves_;
00701 
00702    fei::SharedPtr<FillableMat> D_;
00703    fei::SharedPtr<CSVec> g_;
00704    bool g_nonzero_;
00705 
00706    fei::SharedPtr<fei::Reducer> reducer_;
00707 
00708    std::string name_;
00709    std::string dbgprefix_;
00710 
00711    std::vector<int> tmpIntArray1_, tmpIntArray2_;
00712 
00713    int* vspcEqnPtr_;
00714 
00715    std::set<int> constrained_indices_;
00716 };//class MatrixGraph_Impl2
00717 
00718  inline fei::SharedPtr<fei::VectorSpace> MatrixGraph_Impl2::getRowSpace()
00719    {
00720      return(rowSpace_);
00721    }
00722 
00723  inline fei::SharedPtr<fei::VectorSpace> MatrixGraph_Impl2::getColSpace()
00724    {
00725      return(colSpace_);
00726    }
00727 
00728  inline std::map<int,fei::ConnectivityBlock*>& MatrixGraph_Impl2::getConnectivityBlocks()
00729    {
00730      return(connectivityBlocks_);
00731    }
00732 
00733  inline int MatrixGraph_Impl2::getGlobalNumSlaveConstraints() const
00734    {
00735      return( globalNumSlaves_ );
00736    }
00737 
00738  inline std::map<int, ConstraintType* >& MatrixGraph_Impl2::getLagrangeConstraints()
00739    {
00740      return( lagrangeConstraints_ );
00741    }
00742 }//namespace fei
00743 
00744 #endif
00745 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:24 2011 for FEI by  doxygen 1.6.3