9 #ifndef _snl_fei_Broker_LinSysCore_hpp_ 
   10 #define _snl_fei_Broker_LinSysCore_hpp_ 
   12 #include <fei_macros.hpp> 
   14 #include <fei_CommUtils.hpp> 
   15 #include <snl_fei_Broker.hpp> 
   16 #include <fei_LinearSystemCore.hpp> 
   17 #include <fei_VectorSpace.hpp> 
   18 #include <fei_Lookup_Impl.hpp> 
   19 #include <fei_MatrixGraph.hpp> 
   20 #include <fei_SparseRowGraph.hpp> 
   21 #include <fei_Vector_Impl.hpp> 
   22 #include <fei_Matrix_Impl.hpp> 
   23 #include <fei_MatrixReducer.hpp> 
   24 #include <fei_VectorReducer.hpp> 
   25 #include <fei_Reducer.hpp> 
   26 #include <snl_fei_LinearSystem_General.hpp> 
   29 #define fei_file "snl_fei_Broker_LinSysCore.hpp" 
   30 #include <fei_ErrMacros.hpp> 
   60         if (matrixGraph_.
get() == NULL) 
return(vptr);
 
   61         if (setGlobalOffsets() != 0) 
return(vptr);
 
   70         if (reducer_.
get() != NULL) {
 
   71           vec.
reset(
new fei::VectorReducer(reducer_, tmpvec, isSolutionVector));
 
   85         if (matrixGraph_.
get() == NULL) 
return(mptr);
 
   87         if (setMatrixStructure() != 0) 
return(mptr);
 
   89         bool zeroSharedRows = 
true;
 
   90         if (reducer_.
get() != NULL) {
 
   91           zeroSharedRows = 
false;
 
   96                                                            numLocalEqns_, zeroSharedRows));
 
   98         if (reducer_.
get() != NULL) {
 
   99           matptr.
reset(
new fei::MatrixReducer(reducer_, tmpmat));
 
  113         if (matrixGraph_.
get() == NULL) 
return(lsptr);
 
  115         if (setMatrixStructure() != 0) 
return(lsptr);
 
  124       { matrixGraph_ = matrixGraph; }
 
  127     int setGlobalOffsets()
 
  130         if (setGlobalOffsets_) 
return(0);
 
  132         if (matrixGraph_.
get() == NULL) 
return(-1);
 
  138         std::vector<int> globalOffsets;
 
  139         std::vector<int> globalBlkOffsets;
 
  141         if (reducer_.
get() != NULL) {
 
  142           int localsize = reducer_->getLocalReducedEqns().size();
 
  143           numLocalEqns_ = localsize;
 
  144           std::vector<int> lsizes(num_procs, 0);
 
  145           std::vector<int> gsizes(num_procs, 0);
 
  146           lsizes[local_proc] = localsize;
 
  148           globalOffsets.resize(num_procs+1);
 
  150           for(
int p=0; p<num_procs; ++p) {
 
  151             globalOffsets[p] = offset;
 
  154           globalOffsets[num_procs] = offset;
 
  155           globalBlkOffsets = globalOffsets;
 
  164           numLocalEqns_ = globalOffsets[local_proc+1]-globalOffsets[local_proc];
 
  168                                               &globalBlkOffsets[0],
 
  170                                               &globalBlkOffsets[0]));
 
  172         setGlobalOffsets_ = 
true;
 
  176     int setMatrixStructure()
 
  179         if (setMatrixStructure_) 
return(0);
 
  181         if (matrixGraph_.
get() == NULL) 
return(-1);
 
  185         CHK_ERR( linsyscore_->
setLookup(*lookup_) );
 
  187         CHK_ERR( setGlobalOffsets() );
 
  194         std::vector<int>& rowNumbers = localSRGraph->
rowNumbers;
 
  195         int numLocalRows = rowNumbers.size();
 
  196         int* rowOffsets = &(localSRGraph->
rowOffsets[0]);
 
  200         int numGlobalNonzeros = 0;
 
  203         std::vector<int*> colPtrs(numLocalRows);
 
  204         std::vector<int> ptRowsPerBlkRow(numLocalRows, 1);
 
  205         std::vector<int> rowLengths(numLocalRows);
 
  206         int* rowLengthsPtr = &rowLengths[0];
 
  208         for(
int i=0; i<numLocalRows; ++i) {
 
  209           colPtrs[i] = &(nonzeros[rowOffsets[i]]);
 
  210           rowLengthsPtr[i] = rowOffsets[i+1]-rowOffsets[i];
 
  211           if (blockMatrix_ == 
true) {
 
  220                                                  &ptRowsPerBlkRow[0]));
 
  222         setMatrixStructure_ = 
true;
 
  233     bool setGlobalOffsets_;
 
  235     bool setMatrixStructure_;
 
  240 #endif // _snl_fei_Broker_LinSysCore_hpp_ 
int GlobalSum(MPI_Comm comm, std::vector< T > &local, std::vector< T > &global)
MPI_Comm getCommunicator() const 
fei::SharedPtr< fei::Matrix > createMatrix()
virtual int setLookup(Lookup &lookup)=0
std::vector< int > rowNumbers
virtual int getBlkEqnSize(int blkEqn)=0
virtual fei::SharedPtr< fei::SparseRowGraph > createGraph(bool blockEntryGraph, bool localRowGraph_includeSharedRows=false)=0
std::vector< int > packedColumnIndices
virtual ~Broker_LinSysCore()
std::vector< int > rowOffsets
fei::SharedPtr< fei::LinearSystem > createLinearSystem()
virtual int setGlobalOffsets(int len, int *nodeOffsets, int *eqnOffsets, int *blkEqnOffsets)=0
virtual fei::SharedPtr< fei::VectorSpace > getRowSpace()=0
virtual int setMatrixStructure(int **ptColIndices, int *ptRrowLengths, int **blkColIndices, int *blkRowLengths, int *ptRowsPerBlkRow)=0
void getGlobalBlkIndexOffsets(std::vector< int > &globalBlkOffsets) const 
void setMatrixGraph(fei::SharedPtr< fei::MatrixGraph > matrixGraph)
void getGlobalIndexOffsets(std::vector< int > &globalOffsets) const 
int GlobalMax(MPI_Comm comm, std::vector< T > &local, std::vector< T > &global)
int localProc(MPI_Comm comm)
fei::SharedPtr< fei::Vector > createVector(bool isSolutionVector=false)
int numProcs(MPI_Comm comm)
Broker_LinSysCore(fei::SharedPtr< LinearSystemCore > lsc, fei::SharedPtr< fei::MatrixGraph > matrixGraph, fei::SharedPtr< fei::Reducer > reducer, bool blockMatrix)