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 
00246    int initConnectivityBlock(int blockID,
00247                              int numConnectivityLists,
00248                              int rowPatternID,
00249                              int colPatternID);
00250 
00263    int initConnectivity(int blockID,
00264                         int connectivityID,
00265                         const int* connectedIdentifiers);
00266 
00281    int initConnectivity(int blockID,
00282                         int connectivityID,
00283                         const int* rowConnectedIdentifiers,
00284                         const int* colConnectedIdentifiers);
00285 
00297    int initConnectivity(int patternID,
00298                         const int* connectedIdentifiers);
00299 
00314    int initConnectivity(int rowPatternID,
00315                         const int* rowConnectedIdentifiers,
00316                         int colPatternID,
00317                         const int* colConnectedIdentifiers);
00318 
00334    int initConnectivity(int idType,
00335                         int numRows,
00336                         const int* rowIDs,
00337                         const int* rowOffsets,
00338                         const int* packedColumnIDs);
00339 
00357    int initConnectivity(int idType,
00358                         int fieldID,
00359                         int numRows,
00360                         const int* rowIDs,
00361                         const int* rowOffsets,
00362                         const int* packedColumnIDs);
00363 
00378    int initConnectivity(int idType,
00379                         int numRows,
00380                         const int* rowIDs,
00381                         const int* rowLengths,
00382                         const int*const* columnIDs);
00383 
00386    int initLagrangeConstraint(int constraintID,
00387                               int constraintIDType,
00388                               int numIDs,
00389                               const int* idTypes,
00390                               const int* IDs,
00391                               const int* fieldIDs);
00392 
00395    int initPenaltyConstraint(int constraintID,
00396                              int constraintIDType,
00397                              int numIDs,
00398                              const int* idTypes,
00399                              const int* IDs,
00400                              const int* fieldIDs);
00401 
00404    int initSlaveConstraint(int numIDs,
00405                            const int* idTypes,
00406                            const int* IDs,
00407                            const int* fieldIDs,
00408                            int offsetOfSlave,
00409                            int offsetIntoSlaveField,
00410                            const double* weights,
00411                            double rhsValue);
00412 
00413    bool newSlaveData();
00414 
00417    bool hasSlaveDof(int ID, int idType);
00418 
00423    int initComplete();
00424 
00436    fei::SharedPtr<fei::SparseRowGraph>
00437      createGraph(bool blockEntryGraph,
00438                  bool localRowGraph_includeSharedRows=false);
00439 
00443    int compareStructure(const fei::MatrixGraph& matrixGraph,
00444                         bool& equivalent) const;
00445 
00447    int getNumConnectivityBlocks() const;
00448 
00450    std::map<int,fei::ConnectivityBlock*>& getConnectivityBlocks();
00451 
00453    int getConnectivityBlockIDs(std::vector<int>& blockIDs) const;
00454 
00457    int getNumIDsPerConnectivityList(int blockID) const;
00458 
00462    int getConnectivityNumIndices(int blockID) const;
00463 
00468    int getConnectivityNumIndices(int blockID,
00469                                  int& numRowIndices,
00470                                  int& numColIndices);
00471 
00474    int getConnectivityIndices(int blockID,
00475                               int connectivityID,
00476                               int indicesAllocLen,
00477                               int* indices,
00478                               int& numIndices);
00479 
00483    int getConnectivityIndices(int blockID,
00484                               int connectivityID,
00485                               int rowIndicesAllocLen,
00486                               int* rowIndices,
00487                               int& numRowIndices,
00488                               int colIndicesAllocLen,
00489                               int* colIndices,
00490                               int& numColIndices);
00491 
00494    int getPatternNumIndices(int patternID,
00495                             int& numIndices);
00496 
00499    int getPatternIndices(int patternID,
00500                          const int* IDs,
00501                          std::vector<int>& indices);
00502 
00504    int getLocalNumLagrangeConstraints() const;
00505 
00508    int getGlobalNumSlaveConstraints() const;
00509 
00513    ConstraintType* getLagrangeConstraint(int constraintID);
00514 
00518    std::map<int, ConstraintType* >& getLagrangeConstraints();
00519 
00523    ConstraintType* getPenaltyConstraint(int constraintID);
00524 
00528    ConstraintType* getSlaveConstraint(int constraintID);
00529 
00533    int getConstraintConnectivityIndices(ConstraintType* cr,
00534                                         std::vector<int>& globalIndices);
00535 
00539    const fei::ConnectivityBlock* getConnectivityBlock(int blockID) const;
00540 
00544    fei::ConnectivityBlock* getConnectivityBlock(int blockID);
00545 
00547    void setIndicesMode(int mode);
00548 
00550    fei::SharedPtr<FillableMat> getSlaveDependencyMatrix();
00551 
00555    fei::Pattern* getPattern(int patternID);
00556 
00558    int createSlaveMatrices();
00559 
00561    fei::SharedPtr<fei::Reducer> getReducer();
00562 
00564    fei::SharedPtr<fei::SparseRowGraph> getRemotelyOwnedGraphRows();
00565 
00567    void getConstrainedIndices(std::vector<int>& crindices) const;
00568 
00569  private:
00570    int createAlgebraicGraph(bool blockEntryGraph,
00571                             fei::Graph* graph,
00572                             bool gatherFromOverlap);
00573 
00574    int addBlockToGraph_multiField_symmetric(fei::Graph* graph,
00575                                             fei::ConnectivityBlock* cblock);
00576    int addBlockToGraph_multiField_nonsymmetric(fei::Graph* graph,
00577                                             fei::ConnectivityBlock* cblock);
00578    int addBlockToGraph_singleField_symmetric(fei::Graph* graph,
00579                                              fei::ConnectivityBlock* cblock);
00580    int addBlockToGraph_singleField_nonsymmetric(fei::Graph* graph,
00581                                              fei::ConnectivityBlock* cblock);
00582    int addBlockToGraph_noField_symmetric(fei::Graph* graph,
00583                                          fei::ConnectivityBlock* cblock);
00584    int addBlockToGraph_sparse(fei::Graph* graph,
00585                               fei::ConnectivityBlock* cblock);
00586 
00587    int addPattern(fei::Pattern* pattern);
00588 
00589    int getConnectivityIndices_multiField(fei::Record** records, int numRecords,
00590                                          const int* numFieldsPerID,
00591                                          const int* fieldIDs,
00592                                          const int* fieldSizes,
00593                                          int indicesAllocLen,
00594                                          int* indices,
00595                                          int& numIndices);
00596 
00597    int getConnectivityIndices_singleField(fei::Record** records, int numRecords,
00598                                           int fieldID, int fieldSize,
00599                                           int indicesAllocLen,
00600                                           int* indices,
00601                                           int& numIndices);
00602 
00603    int getConnectivityIndices_singleField_unreduced(fei::Record** records,
00604                                                     int numRecords,
00605                                                     int* idTypes,
00606                                                     int fieldID, int fieldSize,
00607                                                     int indicesAllocLen,
00608                                                     int* indices,
00609                                                     int& numIndices);
00610 
00611    int getConnectivityIndices_noField(fei::Record** records,
00612                                       int numRecords,
00613                                       int indicesAllocLen,
00614                                       int* indices,
00615                                       int& numIndices);
00616 
00617    int getConnectivityRecords(fei::VectorSpace* vecSpace,
00618                               int idType,
00619                               int numIDs,
00620                               const int* IDs,
00621                               fei::Record** records);
00622 
00623    int getConnectivityRecords(fei::VectorSpace* vecSpace,
00624                               int idType,
00625                               int fieldID,
00626                               int numIDs,
00627                               const int* IDs,
00628                               fei::Record** records);
00629 
00630    int getConnectivityRecords(fei::Pattern* pattern,
00631                               fei::VectorSpace* solnSpace,
00632                               const int* connectedIdentifiers,
00633                               fei::Record** recordList);
00634 
00635    int exchangeBlkEqnSizes(fei::Graph* graph);
00636 
00637    int addLagrangeConstraintsToGraph(fei::Graph* graph);
00638 
00639    int addPenaltyConstraintsToGraph(fei::Graph* graph);
00640 
00641    void setName(const char* name);
00642 
00643  private:
00644    int localProc_, numProcs_;
00645 
00646    MPI_Comm comm_;
00647 
00648    fei::SharedPtr<fei::VectorSpace> rowSpace_;
00649    fei::SharedPtr<fei::VectorSpace> colSpace_;
00650    bool haveRowSpace_;
00651    bool haveColSpace_;
00652    bool symmetric_;
00653 
00654    fei::SharedPtr<fei::SparseRowGraph> remotelyOwnedGraphRows_;
00655 
00656    bool simpleProblem_;
00657    bool blockEntryGraph_;
00658 
00659    std::map<int,fei::Pattern*> patterns_;
00660 
00661    std::map<int,fei::ConnectivityBlock*> connectivityBlocks_;
00662    int arbitraryBlockCounter_;
00663 
00664    std::vector<fei::ConnectivityBlock*> sparseBlocks_;
00665 
00666    std::map<int, ConstraintType* >
00667      lagrangeConstraints_, penaltyConstraints_, slaveConstraints_;
00668 
00669    bool ptEqualBlk_;
00670 
00671    bool newSlaveData_;
00672 
00673    int localNumSlaves_;
00674    int globalNumSlaves_;
00675 
00676    fei::SharedPtr<FillableMat> D_;
00677    fei::SharedPtr<CSVec> g_;
00678    bool g_nonzero_;
00679 
00680    fei::SharedPtr<fei::Reducer> reducer_;
00681 
00682    std::string name_;
00683    std::string dbgprefix_;
00684 
00685    std::vector<int> tmpIntArray1_, tmpIntArray2_;
00686 
00687    int* vspcEqnPtr_;
00688 
00689    std::set<int> constrained_indices_;
00690 };//class MatrixGraph_Impl2
00691 
00692  inline fei::SharedPtr<fei::VectorSpace> MatrixGraph_Impl2::getRowSpace()
00693    {
00694      return(rowSpace_);
00695    }
00696 
00697  inline fei::SharedPtr<fei::VectorSpace> MatrixGraph_Impl2::getColSpace()
00698    {
00699      return(colSpace_);
00700    }
00701 
00702  inline std::map<int,fei::ConnectivityBlock*>& MatrixGraph_Impl2::getConnectivityBlocks()
00703    {
00704      return(connectivityBlocks_);
00705    }
00706 
00707  inline int MatrixGraph_Impl2::getGlobalNumSlaveConstraints() const
00708    {
00709      return( globalNumSlaves_ );
00710    }
00711 
00712  inline std::map<int, ConstraintType* >& MatrixGraph_Impl2::getLagrangeConstraints()
00713    {
00714      return( lagrangeConstraints_ );
00715    }
00716 }//namespace fei
00717 
00718 #endif
00719 

Generated on Wed May 12 21:30:41 2010 for FEI by  doxygen 1.4.7