23 globalAssembleCalled_(false),
24 changedSinceMark_(false)
33 if (target_core == NULL) {
34 throw std::runtime_error(
"fei::MatrixReducer ERROR, target matrix not dynamic_cast-able to fei::Matrix_core.");
76 osstr <<
"fei::MatrixReducer::getRowLength ERROR, row="<<row<<
" is a slave eqn. You can't get a slave row from the reduced matrix.";
77 throw std::runtime_error(osstr.str());
89 osstr <<
"fei::MatrixReducer::copyOutRow ERROR, requested row ("<<row
90 <<
") is a slave eqn. You can't get a slave row from the reduced matrix.";
91 throw std::runtime_error(osstr.str());
96 for(
int i=0; i<len; ++i) {
104 int numCols,
const int* cols,
105 const double*
const* values,
109 values,
true, *
target_, format);
115 int numCols,
const int* cols,
116 const double*
const* values,
120 values,
false, *
target_, format);
129 const double*
const* data,
138 std::vector<int> indices(fieldSize*2);
139 int* rowIndices = &indices[0];
140 int* colIndices = rowIndices+fieldSize;
146 throw std::runtime_error(
"MatrixReducer: bad format");
150 fieldSize, colIndices,
168 std::vector<const double*> data_2d(fieldSize);
169 for(
unsigned i=0; i<fieldSize; ++i) {
170 data_2d[i] = &data[i*fieldSize];
173 return(
sumInFieldData(fieldID, idType, rowID, colID, &data_2d[0], format));
178 const double*
const* values,
182 int numRowIndices, numColIndices, dummy;
185 std::vector<int> indices(numRowIndices+numColIndices);
186 int* rowIndices = &indices[0];
187 int* colIndices = rowIndices+numRowIndices;
190 numRowIndices, rowIndices, dummy,
191 numColIndices, colIndices, dummy);
193 return(
sumIn(numRowIndices, rowIndices, numColIndices, colIndices,
215 bool matrixMarketFormat)
217 static char mmbanner[] =
"%%MatrixMarket matrix coordinate real general";
219 int localNumRows = localrows.size();
224 for(
int i=0; i<localNumRows; ++i) {
233 int globalNumRows = 0;
236 int globalNumCols = globalNumRows;
246 if (matrixMarketFormat) {
248 ofs <<globalNumRows<<
" " <<globalNumCols<<
" " <<globalNNZ<<
FEI_ENDL;
251 ofs <<globalNumRows<<
" " <<globalNumCols<<
FEI_ENDL;
257 outFile->precision(13);
261 std::vector<int> work_indices;
262 std::vector<double> work_data1D;
264 for(
int i=0; i<localNumRows; ++i) {
265 int row = localrows[i];
268 work_indices.resize(rowLength);
269 work_data1D.resize(rowLength);
271 int* indPtr = &work_indices[0];
272 double* coefPtr = &work_data1D[0];
276 for(
int j=0; j<rowLength; ++j) {
277 if (matrixMarketFormat) {
278 ofs << row+1 <<
" "<<indPtr[j]+1<<
" "<<coefPtr[j]<<
FEI_ENDL;
281 ofs << row <<
" "<<indPtr[j]<<
" "<<coefPtr[j]<<
FEI_ENDL;
293 bool matrixMarketFormat)
int GlobalSum(MPI_Comm comm, std::vector< T > &local, std::vector< T > &global)
virtual int multiply(fei::Vector *x, fei::Vector *y)=0
MPI_Comm getCommunicator() const
int getGlobalNumIndices() const
int addMatrixValues(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, bool sum_into, fei::Matrix &feimat, int format)
void assembleReducedMatrix(fei::Matrix &matrix)
int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)
virtual void setMatrixGraph(fei::SharedPtr< fei::MatrixGraph > matrixGraph)=0
virtual void markState()=0
int translateToReducedEqn(int unreducedEqn) const
int getRowLength(int row, int &length) const
void Barrier(MPI_Comm comm)
virtual void setCommSizes()=0
virtual int getConnectivityNumIndices(int blockID) const =0
int getGlobalIndices(int numIDs, const int *IDs, int idType, int fieldID, int *globalIndices)
virtual fei::SharedPtr< fei::VectorSpace > getRowSpace()=0
int putScalar(double scalar)
int sumIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)
int sumInFieldData(int fieldID, int idType, int rowID, int colID, const double *const *data, int format=0)
virtual int getConnectivityIndices(int blockID, int connectivityID, int indicesAllocLen, int *indices, int &numIndices)=0
virtual fei::SharedPtr< fei::VectorSpace > getColSpace()=0
void setMatrixGraph(fei::SharedPtr< fei::MatrixGraph > matrixGraph)
virtual int getRowLength(int row, int &length) const =0
int getGlobalNumRows() const
int multiply(fei::Vector *x, fei::Vector *y)
virtual fei::SharedPtr< fei::MatrixGraph > getMatrixGraph() const =0
virtual bool changedSinceMark()=0
int parameters(const fei::ParameterSet ¶mset)
int translateFromReducedEqn(int reduced_eqn) const
void setEqnComm(fei::SharedPtr< fei::EqnComm > eqnComm)
std::vector< int > & getLocalReducedEqns()
int localProc(MPI_Comm comm)
int gatherFromOverlap(bool accumulate=true)
fei::SharedPtr< fei::Matrix > target_
virtual int globalAssemble()=0
int writeToFile(const char *filename, bool matrixMarketFormat=true)
int copyOutRow(int row, int len, double *coefs, int *indices) const
int copyIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)
unsigned getFieldSize(int fieldID)
int getLocalNumRows() const
bool isSlaveEqn(int unreducedEqn) const
fei::SharedPtr< fei::Reducer > reducer_
virtual int gatherFromOverlap(bool accumulate=true)=0
virtual int putScalar(double scalar)=0
#define FEI_OSTRINGSTREAM
virtual int parameters(const fei::ParameterSet ¶mset)=0
MatrixReducer(fei::SharedPtr< fei::Reducer > reducer, fei::SharedPtr< fei::Matrix > target)
virtual int copyOutRow(int row, int len, double *coefs, int *indices) const =0
int numProcs(MPI_Comm comm)
int getNumIndices_Owned() const
fei::SharedPtr< fei::MatrixGraph > getMatrixGraph() const
virtual int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)=0