//============================================================================== int Ifpack_CrsRiluk::BlockGraph2PointGraph(const Epetra_CrsGraph & BG, Epetra_CrsGraph & PG, bool Upper) { if (!BG.IndicesAreLocal()) {EPETRA_CHK_ERR(-1);} // Must have done FillComplete on BG int * ColFirstPointInElementList = BG.RowMap().FirstPointInElementList(); int * ColElementSizeList = BG.RowMap().ElementSizeList(); if (BG.Importer()!=0) { ColFirstPointInElementList = BG.ImportMap().FirstPointInElementList(); ColElementSizeList = BG.ImportMap().ElementSizeList(); } int Length = (BG.MaxNumIndices()+1) * BG.ImportMap().MaxMyElementSize(); vector<int> tmpIndices(Length); int BlockRow, BlockOffset, NumEntries; int NumBlockEntries; int * BlockIndices; int NumMyRows_tmp = PG.NumMyRows(); for (int i=0; i<NumMyRows_tmp; i++) { EPETRA_CHK_ERR(BG.RowMap().FindLocalElementID(i, BlockRow, BlockOffset)); EPETRA_CHK_ERR(BG.ExtractMyRowView(BlockRow, NumBlockEntries, BlockIndices)); int * ptr = &tmpIndices[0]; // Set pointer to beginning of buffer int RowDim = BG.RowMap().ElementSize(BlockRow); NumEntries = 0; // This next line make sure that the off-diagonal entries in the block diagonal of the // original block entry matrix are included in the nonzero pattern of the point graph if (Upper) { int jstart = i+1; int jstop = EPETRA_MIN(NumMyRows_tmp,i+RowDim-BlockOffset); for (int j= jstart; j< jstop; j++) {*ptr++ = j; NumEntries++;} } for (int j=0; j<NumBlockEntries; j++) { int ColDim = ColElementSizeList[BlockIndices[j]]; NumEntries += ColDim; assert(NumEntries<=Length); // Sanity test int Index = ColFirstPointInElementList[BlockIndices[j]]; for (int k=0; k < ColDim; k++) *ptr++ = Index++; } // This next line make sure that the off-diagonal entries in the block diagonal of the // original block entry matrix are included in the nonzero pattern of the point graph if (!Upper) { int jstart = EPETRA_MAX(0,i-RowDim+1); int jstop = i; for (int j = jstart; j < jstop; j++) {*ptr++ = j; NumEntries++;} } EPETRA_CHK_ERR(PG.InsertMyIndices(i, NumEntries, &tmpIndices[0])); } SetAllocated(true); return(0); }
void Table3D::Allocate() { getMem1D(&x1, 0, n1-1, "Chemtable::Load x1", true); getMem1D(&x2, 0, n2-1, "Chemtable::Load x2", true); getMem1D(&x3, 0, n3-1, "Chemtable::Load x3", true); getMem4D(&Data, 0, n1-1, 0, n2-1, 0, n3-1, 0, nvar-1, "Chemtable::Load Data", true); SetAllocated(); }
//============================================================================== int Ifpack_CrsRiluk::AllocateCrs() { // Allocate Epetra_CrsMatrix using ILUK graphs L_ = Teuchos::rcp( new Epetra_CrsMatrix(Copy, Graph_.L_Graph()) ); U_ = Teuchos::rcp( new Epetra_CrsMatrix(Copy, Graph_.U_Graph()) ); D_ = Teuchos::rcp( new Epetra_Vector(Graph_.L_Graph().RowMap()) ); L_Graph_ = Teuchos::null; U_Graph_ = Teuchos::null; SetAllocated(true); return(0); }
//============================================================================== int Ifpack_CrsIct::Allocate() { // Allocate Epetra_CrsMatrix using ILUK graphs if (LevelOverlap_==0) { U_ = Teuchos::rcp( new Epetra_CrsMatrix(Copy, A_.RowMatrixRowMap(), A_.RowMatrixRowMap(), 0) ); D_ = Teuchos::rcp( new Epetra_Vector(A_.RowMatrixRowMap()) ); } else { EPETRA_CHK_ERR(-1); // LevelOverlap > 0 not implemented yet // U_ = new Epetra_CrsMatrix(Copy, OverlapRowMap()); // D_ = new Epetra_Vector(OverlapRowMap()); } SetAllocated(true); return(0); }
//============================================================================== int Ifpack_CrsRiluk::AllocateVbr() { // First we need to create a set of Epetra_Maps that has the same number of points as the // Epetra_BlockMaps associated with the Overlap Graph. EPETRA_CHK_ERR(BlockMap2PointMap(Graph_.L_Graph().RowMap(), &IlukRowMap_)); EPETRA_CHK_ERR(BlockMap2PointMap(Graph_.U_Graph().DomainMap(), &IlukDomainMap_)); EPETRA_CHK_ERR(BlockMap2PointMap(Graph_.L_Graph().RangeMap(), &IlukRangeMap_)); // Set L range map and U domain map U_DomainMap_ = IlukDomainMap_; L_RangeMap_ = IlukRangeMap_; // If there is fill, then pre-build the L and U structures from the Block version of L and U. if (Graph().LevelFill()) { L_Graph_ = Teuchos::rcp( new Epetra_CrsGraph(Copy, *IlukRowMap_, *IlukRowMap_, 0) ); U_Graph_ = Teuchos::rcp( new Epetra_CrsGraph(Copy, *IlukRowMap_, *IlukRowMap_, 0) ); EPETRA_CHK_ERR(BlockGraph2PointGraph(Graph_.L_Graph(), *L_Graph_, false)); EPETRA_CHK_ERR(BlockGraph2PointGraph(Graph_.U_Graph(), *U_Graph_, true)); L_Graph_->FillComplete(*IlukRowMap_, *IlukRangeMap_); U_Graph_->FillComplete(*IlukDomainMap_, *IlukRowMap_); L_ = Teuchos::rcp( new Epetra_CrsMatrix(Copy, *L_Graph_) ); U_ = Teuchos::rcp( new Epetra_CrsMatrix(Copy, *U_Graph_) ); D_ = Teuchos::rcp( new Epetra_Vector(*IlukRowMap_) ); } else { // Allocate Epetra_CrsMatrix using ILUK graphs L_ = Teuchos::rcp( new Epetra_CrsMatrix(Copy, *IlukRowMap_, *IlukRowMap_, 0) ); U_ = Teuchos::rcp( new Epetra_CrsMatrix(Copy, *IlukRowMap_, *IlukRowMap_, 0) ); D_ = Teuchos::rcp( new Epetra_Vector(*IlukRowMap_) ); L_Graph_ = Teuchos::null; U_Graph_ = Teuchos::null; } SetAllocated(true); return(0); }
bool Table3D::IsAllocated() { SetAllocated(); return Allocated; }