//! @brief Sets the size of the system from the number of vertices in the graph. int XC::BandArpackSOE::setSize(Graph &theGraph) { int result = 0; size= checkSize(theGraph); // determine the number of superdiagonals and subdiagonals theGraph.getBand(numSubD,numSuperD); const int newSize = size * (2*numSubD + numSuperD +1); if(newSize > A.Size()) A.resize(newSize); A.Zero(); factored = false; // invoke setSize() on the XC::Solver EigenSolver *theSolvr = this->getSolver(); int solverOK = theSolvr->setSize(); if(solverOK < 0) { std::cerr << "WARNING: BandArpackSOE::setSize :"; std::cerr << " solver failed setSize()\n"; return solverOK; } return result; }
int SymArpackSOE::setSize(Graph &theGraph) { int result = 0; int oldSize = size; size = theGraph.getNumVertex(); // fist itearte through the vertices of the graph to get nnz Vertex *theVertex; int newNNZ = 0; VertexIter &theVertices = theGraph.getVertices(); while ((theVertex = theVertices()) != 0) { const ID &theAdjacency = theVertex->getAdjacency(); newNNZ += theAdjacency.Size(); } nnz = newNNZ; if (colA != 0) delete [] colA; colA = new int[newNNZ]; if (colA == 0) { opserr << "WARNING SymArpackSOE::SymArpackSOE :"; opserr << " ran out of memory for colA with nnz = "; opserr << newNNZ << " \n"; size = 0; nnz = 0; result = -1; } factored = false; if (rowStartA != 0) delete [] rowStartA; rowStartA = new int[size+1]; if (rowStartA == 0) { opserr << "SymArpackSOE::ran out of memory for rowStartA." << endln; result = -1; } // fill in rowStartA and colA if (size != 0) { rowStartA[0] = 0; int startLoc = 0; int lastLoc = 0; for (int a=0; a<size; a++) { theVertex = theGraph.getVertexPtr(a); if (theVertex == 0) { opserr << "WARNING:SymArpackSOE::setSize :"; opserr << " vertex " << a << " not in graph! - size set to 0\n"; size = 0; return -1; } const ID &theAdjacency = theVertex->getAdjacency(); int idSize = theAdjacency.Size(); // now we have to place the entries in the ID into order in colA for (int i=0; i<idSize; i++) { int row = theAdjacency(i); bool foundPlace = false; for (int j=startLoc; j<lastLoc; j++) if (colA[j] > row) { // move the entries already there one further on // and place col in current location for (int k=lastLoc; k>j; k--) colA[k] = colA[k-1]; colA[j] = row; foundPlace = true; j = lastLoc; } if (foundPlace == false) // put in at the end colA[lastLoc] = row; lastLoc++; } rowStartA[a+1] = lastLoc;; startLoc = lastLoc; } } // begin to choose different ordering schema. // cout << "Enter DOF Numberer Type: \n"; // cout << "[1] Minimum Degree, [2] Nested Dissection, [3] RCM: "; int LSPARSE = 1; // cin >> LSPARSE; // call "C" function to form elimination tree and do the symbolic factorization. // nblks = symFactorization(rowStartA, colA, size, LSPARSE); nblks = symFactorization(rowStartA, colA, size, LSPARSE, &xblk, &invp, &rowblks, &begblk, &first, &penv, &diag); // invoke setSize() on the Solver EigenSolver *theSolvr = this->getSolver(); int solverOK = theSolvr->setSize(); if (solverOK < 0) { opserr << "WARNING:BandArpackSOE::setSize :"; opserr << " solver failed setSize()\n"; return solverOK; } return result; }