47 localUnreducedEqns_(),
54 firstLocalReducedEqn_(0),
55 lastLocalReducedEqn_(0),
56 lowestGlobalSlaveEqn_(0),
57 highestGlobalSlaveEqn_(0),
61 dbgprefix_(
"Reducer: "),
71 csrD_ = *globalSlaveDependencyMatrix;
72 if (g_vector.
get() != NULL) {
89 for(
size_t i=0; i<
csg_.
size(); ++i) {
105 int nonslave_counter = 0;
107 int num_consecutive = 0;
111 nonslaves_[nonslave_counter] = slavesPtr_[slaveOffset]+1;
127 for(
int i=1; i<nonslave_counter; ++i) {
144 throw std::runtime_error(
"ERROR: don't use fei::Reducer when numGlobalSlaves==0. Report to Alan Williams.");
163 localUnreducedEqns_(),
170 firstLocalReducedEqn_(0),
171 lastLocalReducedEqn_(0),
172 lowestGlobalSlaveEqn_(0),
173 highestGlobalSlaveEqn_(0),
177 dbgprefix_(
"Reducer: "),
189 std::vector<int> indices;
208 os <<
dbgprefix_<<
"setLocalUnreducedEqns, numLocalEqns="
209 <<localUnreducedEqns.size() <<
FEI_ENDL;
240 for(
int j=0; j<rowlen; ++j) {
241 os << indices[j] <<
" ";
249 int num_slaves_on_lower_procs = 0;
255 std::vector<int> procNumLocalSlaves(
numProcs_);
261 num_slaves_on_lower_procs += procNumLocalSlaves[p];
267 unsigned first_non_slave_offset = 0;
270 ++first_non_slave_offset;
274 - num_slaves_on_lower_procs - first_non_slave_offset;
315 std::vector<int>& rowNumbers = matrixGraph->
rowNumbers;
316 std::vector<int>& rowOffsets = matrixGraph->
rowOffsets;
319 for(
unsigned i=0; i<rowNumbers.size(); ++i) {
320 int row = rowNumbers[i];
324 int rowLength = rowOffsets[i+1]-rowOffsets[i];
325 int* cols = &packedCols[rowOffsets[i]];
331 for(
int j=0; j<rowLength; ++j) {
349 for(
int j=0; j<rowLength; ++j) {
380 int numCols,
const int* cols,
385 bool no_slave_cols =
true;
386 for(
int i=0; i<numCols; ++i) {
391 for(
int i=0; i<numRows; ++i) {
398 for(
int j=0; j<numCols; ++j) {
414 unsigned num_non_slave_cols = 0;
416 for(
int j=0; j<numCols; ++j) {
426 if (num_non_slave_cols > 0) {
444 for(
int i=0; i<numIndices; ++i) {
613 std::vector<int>::iterator iter =
614 std::lower_bound(rows.begin(), rows.end(), slaveEqn);
616 if (iter == rows.end() || *iter != slaveEqn) {
620 size_t offset = iter - rows.begin();
626 for(
int j=rowBegin; j<rowEnd; ++j) {
627 masterEqns.push_back(cols[j]);
655 if (foundOffset >= 0) {
656 throw std::runtime_error(
"Reducer::translateToReducedEqn ERROR, input is slave eqn.");
676 int adjustment = reduced_eqn -
reverse_[index-1];
683 int numCols,
const int* cols,
684 const double*
const* values,
696 const double** myvalues =
const_cast<const double**
>(values);
699 throw std::runtime_error(
"fei::Reducer::addMatrixValues ERROR, submatrix format must be either FEI_DENSE_ROW or FEI_DENSE_COL. Other formats not supported with slave constraints.");
707 bool no_slave_cols =
true;
708 unsigned num_non_slave_cols = 0;
709 for(
int j=0; j<numCols; ++j) {
715 bool no_slave_rows =
true;
716 for(
int i=0; i<numRows; ++i) {
722 if (no_slave_rows && no_slave_cols) {
735 for(
int i=0; i<numRows; ++i) {
742 for(
int j=0; j<numCols; ++j) {
744 add_entry(*Kdd_row, cols[j], myvalues[i][j]);
747 add_entry(*Kdi_row, cols[j], myvalues[i][j]);
755 const double* rowvals = myvalues[i];
772 for(
int j=0; j<numCols; ++j) {
774 add_entry(*Kid_row, cols[j], myvalues[i][j]);
782 if (num_non_slave_cols > 0) {
805 const int* globalIndices,
806 const double* values,
817 for(
int i=0; i<numValues; ++i) {
820 if (!soln_vector)
add_entry(
fd_, globalIndices[i], values[i]);
823 if (!soln_vector)
put_entry(
fd_, globalIndices[i], values[i]);
831 feivec.
sumIn(1, &reduced_index, &values[i], vectorIndex);
834 feivec.
copyIn(1, &reduced_index, &values[i], vectorIndex);
861 if (vec.
size() > 0) {
870 int which_vector = 0;
877 if (vec_i.
size() > 0) {
881 int which_vector = 0;
893 const int* globalIndices,
906 std::vector<int> reduced_indices;
907 std::vector<int> offsets;
909 for(
int i=0; i<numValues; ++i) {
912 offsets.push_back(i);
916 feivec.
copyOut(1, &reduced_idx, &values[i], vectorIndex);
928 int* reduced_indices_ptr = reduced_indices.empty() ? NULL : &reduced_indices[0];
936 for(
size_t ii=0; ii<
csg_.
size(); ++ii) {
945 for(
unsigned ii=0; ii<offsets.size(); ++ii) {
946 int index = globalIndices[offsets[ii]];
952 values[offsets[ii]] = coefs[idx];
MPI_Comm getCommunicator() const
Reducer(fei::SharedPtr< FillableMat > globalSlaveDependencyMatrix, fei::SharedPtr< CSVec > g_vector, MPI_Comm comm)
std::vector< const double * > work_2D_
std::vector< double > work_1D_
void translate_to_reduced_eqns(const fei::Reducer &reducer, fei::CSRMat &mat)
int highestGlobalSlaveEqn_
int lowestGlobalSlaveEqn_
int addMatrixValues(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, bool sum_into, fei::Matrix &feimat, int format)
virtual int copyIn(int numValues, const int *indices, const double *values, int vectorIndex=0)=0
void multiply_CSRMat_CSRMat(const CSRMat &A, const CSRMat &B, CSRMat &C, bool storeResultZeros)
unsigned getNumRows() const
void assembleReducedMatrix(fei::Matrix &matrix)
std::vector< int > reverse_
void subtract(const CSVec &rhs)
void assembleReducedVector(bool soln_vector, fei::Vector &feivec)
CSVec * create_or_getRow(int row)
std::vector< int > & indices()
int translateToReducedEqn(int unreducedEqn) const
int firstLocalReducedEqn_
std::vector< int > rowNumbers
virtual int gatherFromOverlap()=0
void multiply_trans_CSRMat_CSVec(const CSRMat &A, const CSVec &x, CSVec &y)
void getSlaveMasterEqns(int slaveEqn, std::vector< int > &masterEqns)
void addGraphEntries(fei::SharedPtr< fei::SparseRowGraph > matrixGraph)
void add_to_matrix(const fei::CSRMat &inmat, bool sum_into, fei::Matrix &matrix)
int copyOutVectorValues(int numValues, const int *globalIndices, double *values, bool soln_vector, int vectorIndex, fei::Vector &feivec)
void expand_work_arrays(int size)
void addGraphIndices(int numRows, const int *rows, int numCols, const int *cols, fei::Graph &graph)
std::vector< int > packedColumnIndices
std::vector< int > rowOffsets
void put_entry(CSVec &vec, int eqn, double coef)
virtual int addIndices(int row, int len, const int *indices)=0
virtual fei::SharedPtr< fei::VectorSpace > getRowSpace()=0
int binarySearch(const T &item, const T *list, int len)
std::vector< int > localReducedEqns_
unsigned rhs_vec_counter_
virtual int sumIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)=0
void setLocalUnreducedEqns(const std::vector< int > &localUnreducedEqns)
virtual int sumIn(int numValues, const int *indices, const double *values, int vectorIndex=0)=0
void add_to_graph(const fei::CSRMat &inmat, fei::Graph &graph)
OutputLevel output_level_
int getIndices_Owned(std::vector< int > &globalIndices) const
SparseRowGraph & getGraph()
static void copyTransposeToWorkArrays(int numRows, int numCols, const double *const *values, std::vector< double > &work_1D, std::vector< const double * > &work_2D)
int translateFromReducedEqn(int reduced_eqn) const
FEI_OSTREAM * output_stream_
void multiply_trans_CSRMat_CSRMat(const CSRMat &A, const CSRMat &B, CSRMat &C, bool storeResultZeros)
int addVectorValues(int numValues, const int *globalIndices, const double *values, bool sum_into, bool soln_vector, int vectorIndex, fei::Vector &feivec)
std::vector< int > & getLocalReducedEqns()
void assembleReducedGraph(fei::Graph *graph, bool global_gather=true)
void addSymmetricGraphIndices(int numIndices, const int *indices, bool diagonal, fei::Graph &graph)
void add_entry(CSVec &vec, int eqn, double coef)
void multiply_CSRMat_CSVec(const CSRMat &A, const CSVec &x, CSVec &y)
virtual int copyIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)=0
std::vector< int > nonslaves_
bool isSlaveCol(int unreducedEqn) const
void copyToSparseRowGraph(snl_fei::RaggedTable< MAP_TYPE, SET_TYPE > &table, fei::SparseRowGraph &srg)
bool isSlaveEqn(int unreducedEqn) const
std::vector< int > localUnreducedEqns_
table_type * getLocalGraph()
virtual int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const =0
std::vector< double > & coefs()