コード例 #1
0
MatrixReducer::MatrixReducer(fei::SharedPtr<fei::Reducer> reducer,
                             fei::SharedPtr<fei::Matrix> target)
 : reducer_(reducer),
   target_(target),
   globalAssembleCalled_(false),
   changedSinceMark_(false)
{
  fei::SharedPtr<fei::VectorSpace> vspace =
    target->getMatrixGraph()->getRowSpace();
  MPI_Comm comm = vspace->getCommunicator();
  int numLocal = reducer_->getLocalReducedEqns().size();
  fei::SharedPtr<fei::EqnComm> eqnComm(new fei::EqnComm(comm, numLocal));
  fei::Matrix_core* target_core =
    dynamic_cast<fei::Matrix_core*>(target_.get());
    if (target_core == NULL) {
    throw std::runtime_error("fei::MatrixReducer ERROR, target matrix not dynamic_cast-able to fei::Matrix_core.");
  }

  target_core->setEqnComm(eqnComm);
}
コード例 #2
0
ファイル: test_Matrix.cpp プロジェクト: 00liujj/trilinos
void test_Matrix::matrix_test1(fei::SharedPtr<fei::Matrix> mat)
{
  if (localProc_==0)
    FEI_COUT << "  matrix_test1: testing fei::Matrix with type '"
	   << mat->typeName() << "':"<<FEI_ENDL;

  fei::SharedPtr<fei::MatrixGraph> mgraph = mat->getMatrixGraph();

  fei::SharedPtr<fei::VectorSpace> rspace = mgraph->getRowSpace();

  if (localProc_==0)
    FEI_COUT << "   testing get{Global/Local}NumRows,getRowLength...";

  int mglobalrows = mat->getGlobalNumRows();
  int vglobaleqns = rspace->getGlobalNumIndices();

  if (mglobalrows != vglobaleqns) {
    throw std::runtime_error("mat reports different num rows than vector-space eqns");
  }

  std::vector<int> global_offsets;
  rspace->getGlobalIndexOffsets(global_offsets);

  int my_num_rows = mat->getLocalNumRows();
  if (my_num_rows != global_offsets[localProc_+1]-global_offsets[localProc_]) {
    throw std::runtime_error("num-local-rows mis-match between mat and vector-space");
  }

  int i, my_first_row = global_offsets[localProc_];
  std::vector<int> row_lengths(my_num_rows);

  for(i=0; i<my_num_rows; ++i) {
    int errcode = mat->getRowLength(i+my_first_row, row_lengths[i]);
    if (errcode != 0) {
      throw std::runtime_error("nonzero errcode from mat->getRowLength");
    }
  }

  if (localProc_==0) FEI_COUT << "ok" << FEI_ENDL;
}