47 #ifdef HAVE_FEI_EPETRA
80 if (ownedGlobalRows == ownedRows_) {
84 if (!ownedRows_.empty()) {
85 throw std::runtime_error(
"setRowDistribution called multiple times with different distributions. not allowed.");
88 int* rows =
const_cast<int*
>(&ownedGlobalRows[0]);
89 epetra_rowmap_.reset(
new Epetra_Map(-1, ownedGlobalRows.size(),
101 if (fei_srgraph_.get() != NULL) {
102 if (*fei_srgraph_ != *matrixGraph) {
103 throw std::runtime_error(
"setMatrixGraph called multiple times with different graphs. not allowed.");
108 fei_srgraph_ = matrixGraph;
111 if (epetra_rowmap_.get() == NULL) {
115 if ((
int)fei_srgraph_->rowNumbers.size() != epetra_rowmap_->NumMyElements()) {
116 throw std::runtime_error(
"setMatrixGraph: num-rows not consistent with value from setRowDistribution");
121 std::vector<int>& rowNumbers = fei_srgraph_->rowNumbers;
122 std::vector<int>& rowOffsets = fei_srgraph_->rowOffsets;
125 std::vector<int> numIndicesPerRow; numIndicesPerRow.reserve(rowNumbers.size());
129 for(i=0; i<numIndicesPerRow.size(); ++i) {
130 numIndicesPerRow.push_back(rowOffsets[i+1] - rowOffsets[i]);
133 bool static_profile =
true;
136 &numIndicesPerRow[0], static_profile));
140 std::vector<int>& colIndices = fei_srgraph_->packedColumnIndices;
141 for(i=0; i<rowNumbers.size(); ++i) {
142 int offset = rowOffsets[i];
143 err = crsgraph_->InsertGlobalIndices(rowNumbers[i], numIndicesPerRow[i],
144 &colIndices[offset]);
146 throw std::runtime_error(
"setMatrixGraph: err from Epetra_CrsGraph::InsertGlobalIndices.");
150 err = crsgraph_->FillComplete();
152 throw std::runtime_error(
"setMatrixGraph: err from Epetra_CrsGraph::FillComplete.");
163 throw std::runtime_error(
"error in Epetra_CrsMatrix->PutScalar");
170 int err = soln_vector ?
171 x_->PutScalar(scalar) :
b_->PutScalar(scalar);
173 throw std::runtime_error(
"error in Epetra_MultiVector->PutScalar");
186 if (
A_.
get() == NULL)
return(-1);
192 double* coefs,
int* indices)
199 int numCols,
const int* cols,
200 const double*
const* values,
203 int* nc_cols =
const_cast<int*
>(cols);
204 double** nc_values =
const_cast<double**
>(values);
207 for(
int i=0; i<numRows; ++i) {
215 for(
int i=0; i<numRows; ++i) {
226 const int* globalIndices,
227 const double* values,
232 double* localvaluesptr = soln_vector ?
233 x_->Pointers()[vectorIndex] :
b_->Pointers()[vectorIndex];
239 for(
int i=0; i<numValues; ++i) {
240 int offset = globalIndices[i] - min_my_gid;
245 localvaluesptr[offset] += values[i];
249 for(
int i=0; i<numValues; ++i) {
250 int offset = globalIndices[i] - min_my_gid;
255 localvaluesptr[offset] = values[i];
263 const int* globalIndices,
268 double* localvaluesptr = soln_vector ?
269 x_->Pointers()[vectorIndex] :
b_->Pointers()[vectorIndex];
273 for(
int i=0; i<numValues; ++i) {
274 int offset = globalIndices[i] - min_my_gid;
275 values[i] = localvaluesptr[offset];
283 double* localvaluesptr = soln_vector ?
284 x_->Pointers()[vectorIndex] :
b_->Pointers()[vectorIndex];
286 return(localvaluesptr);
void setMatrixGraph(fei::SharedPtr< fei::SparseRowGraph > matrixGraph)
int NumGlobalEntries(long long Row) const
void setRowDistribution(const std::vector< int > &ownedGlobalRows)
LinProbMgr_EpetraBasic(MPI_Comm comm)
bool StorageOptimized() const
int ExtractGlobalRowCopy(int_type Row, int Length, int &NumEntries, double *values, int_type *Indices) const
fei::SharedPtr< Epetra_MultiVector > x_
virtual ~LinProbMgr_EpetraBasic()
fei::SharedPtr< Epetra_CrsMatrix > get_A_matrix()
double * getLocalVectorValuesPtr(bool soln_vector, int vectorIndex=0)
virtual int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
std::vector< int > rowNumbers
int FillComplete(bool OptimizeDataStorage=true)
int copyOutVectorValues(int numValues, const int *globalIndices, double *values, bool soln_vector, int vectorIndex=0)
fei::SharedPtr< Epetra_Map > epetra_rowmap_
int PutScalar(double ScalarConstant)
int NumMyElements() const
void setMatrixValues(double scalar)
int insertMatrixValues(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, bool sum_into)
fei::SharedPtr< Epetra_MultiVector > get_rhs_vector()
int getRowLength(int row)
fei::SharedPtr< Epetra_CrsMatrix > A_
int copyOutMatrixRow(int row, int len, double *coefs, int *indices)
fei::SharedPtr< Epetra_MultiVector > b_
int insertVectorValues(int numValues, const int *globalIndices, const double *values, bool sum_into, bool soln_vector, int vectorIndex=0)
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
void setVectorValues(double scalar, bool soln_vector)
fei::SharedPtr< Epetra_MultiVector > get_solution_vector()