当前位置: 首页>>代码示例>>C++>>正文


C++ FEI_OSTRINGSTREAM类代码示例

本文整理汇总了C++中FEI_OSTRINGSTREAM的典型用法代码示例。如果您正苦于以下问题:C++ FEI_OSTRINGSTREAM类的具体用法?C++ FEI_OSTRINGSTREAM怎么用?C++ FEI_OSTRINGSTREAM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FEI_OSTRINGSTREAM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: catch

int
DirichletBCManager::getEqnNumber(int IDType, int ID, int fieldID, int offsetIntoField)
{
  int eqn = -1;
  try {
    if (vecSpace_.get() != NULL) {
      vecSpace_->getGlobalIndex(IDType, ID, fieldID, eqn);
    }
    else {
      if (structure_ == NULL) {
        throw std::runtime_error("fei::DirichletBCManager has NULL SNL_FEI_Structure.");
      }
      NodeDatabase& nodeDB = structure_->getNodeDatabase();
      const NodeDescriptor* node = NULL;
      nodeDB.getNodeWithID(ID, node);
      if (node == NULL) {
        throw std::runtime_error("fei::DirichletBCManager::getEqnNumber failed to get node.");
      }
      node->getFieldEqnNumber(fieldID, eqn);
    }
  }
  catch(std::runtime_error& exc) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "fei::DirichletBCManager::finalizeBCEqns caught exception: "
       << exc.what() << " BC IDType="<<IDType<<", ID="<<ID
       << ", fieldID="<<fieldID;
    fei::console_out() << osstr.str() << FEI_ENDL;
    ERReturn(-1);
  }

  return eqn + offsetIntoField;
}
开发者ID:00liujj,项目名称:trilinos,代码行数:32,代码来源:fei_DirichletBCManager.cpp

示例2: runtime_error

int snl_fei::RecordMsgHandler::packMaskIDs(int destProc, std::vector<int>& msg)
{
  fei::comm_map::row_type* ids = sendPattern_->getRow(destProc);
  int len = ids->size();

  msg.resize(len);

  fei::comm_map::row_type::const_iterator
    id_iter = ids->begin(),
    id_end = ids->end();

  int offset = 0;
  int* msgPtr = &msg[0];

  for(; id_iter != id_end; ++id_iter) {
    fei::Record<int>* rec = recordCollection_->getRecordWithID(*id_iter);
    if (rec == NULL) {
      FEI_OSTRINGSTREAM osstr;
      osstr << "RecordMsgHandler::packMaskIDs: proc " << localProc_
	   << " failed to find ID " << *id_iter;
      throw std::runtime_error(osstr.str());
    }

    msgPtr[offset++] = rec->getFieldMask()->getMaskID();
  }

  return(0);
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:28,代码来源:snl_fei_RecordMsgHandler.cpp

示例3: runtime_error

int
MatrixReducer::getRowLength(int row, int& length) const
{
  if (reducer_->isSlaveEqn(row)) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "fei::MatrixReducer::getRowLength ERROR, row="<<row<<" is a slave eqn. You can't get a slave row from the reduced matrix.";
    throw std::runtime_error(osstr.str());
  }

  int reducedrow = reducer_->translateToReducedEqn(row);
  return(target_->getRowLength(reducedrow, length));
}
开发者ID:haripandey,项目名称:trilinos,代码行数:12,代码来源:fei_MatrixReducer.cpp

示例4: add_macro_values

std::string add_macro_values(const char* name)
{
  FEI_OSTRINGSTREAM osstr;
  osstr << name;

#if defined(FEI_PLATFORM) && defined(FEI_OPT_LEVEL)
  osstr << "_" << FEI_PLATFORM << "_" << FEI_OPT_LEVEL;
#else
  osstr << "_unknown_unknown";
#endif

  return(osstr.str());
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:13,代码来源:test_benchmarks.cpp

示例5: checkSolution

//----------------------------------------------------------------------------
int SolnCheck::checkSolution(int localProc, int numProcs,
			     const char* solnFileName,
			     const char* checkFileName,
			     const char* extension,
			     int solveCounter)
{
  if (localProc == 0) {
    fei::FillableMat soln, correctSoln;
    FEI_OSTRINGSTREAM fullSolnFileName;
    FEI_OSTRINGSTREAM fullCheckFileName;

    fullSolnFileName << solnFileName<<"."<<extension<<"."<<solveCounter;
    fullCheckFileName<< checkFileName<<"."<<extension<<".correct."<<solveCounter;

    std::string fullCheck_str = fullCheckFileName.str();
    const char* check_c_str = fullCheck_str.c_str();
    int err = SolnCheck::readSoln(check_c_str, 1, correctSoln);
    if (err != 0) {
      //If we failed to read the data for the "correct" solution, assume that
      //this is simply a portion of the solution (e.g., lagrange multipliers)
      //that this test isn't supposed to compare.
      //FEI_COUT << "FEI_tester: checkSolution: no check-file for '"<<extension
      //    << "' portion of solution, skipping..." << FEI_ENDL;
      return(0);
    }

    std::string fullSoln_str = fullSolnFileName.str();
    const char* soln_c_str = fullSoln_str.c_str();
    err = SolnCheck::readSoln(soln_c_str, numProcs, soln);
    if (err != 0) return(err);

    FEI_COUT << "FEI_tester:checkSolution: checking '"<<extension<<"' solution...";
    int solnCheckCode = SolnCheck::compareSoln(soln, correctSoln);

    if (solnCheckCode != 0) {
      FEI_COUT << "soln file-name: " << soln_c_str << FEI_ENDL;
      FEI_COUT << "soln-check failed, checkFileName="<<checkFileName<<FEI_ENDL;
      FEI_COUT << "soln: " << FEI_ENDL;
      fei::print(FEI_COUT, soln);
      FEI_COUT << "correctSoln file-name: " << check_c_str << FEI_ENDL;
      FEI_COUT << "correctSoln: " << FEI_ENDL;
      fei::print(FEI_COUT, correctSoln);
      return(-1);
    }
    FEI_COUT << " ok"<<FEI_ENDL;
  }
  return(0);
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:49,代码来源:SolnCheck.cpp

示例6: solve

//---------------------------------------------------------------------------
int Solver_Amesos::solve(fei::LinearSystem* linearSystem,
			  fei::Matrix* preconditioningMatrix,
			  const fei::ParameterSet& parameterSet,
			  int& iterationsTaken,
			  int& status)
{
  Trilinos_Helpers::copy_parameterset(parameterSet, *paramlist_);

  int numParams = 0;
  const char** paramStrings = NULL;
  std::vector<std::string> stdstrings;
  fei::utils::convert_ParameterSet_to_strings(&parameterSet, stdstrings);
  fei::utils::strings_to_char_ptrs(stdstrings, numParams, paramStrings);

  int err = solve(linearSystem, preconditioningMatrix, numParams, paramStrings,
		  iterationsTaken, status);

  int olevel = 0;
  parameterSet.getIntParamValue("outputLevel", olevel);

  std::string param2;
  parameterSet.getStringParamValue("FEI_OUTPUT_LEVEL", param2);

  if (olevel >= 3 || param2 == "MATRIX_FILES" || param2 == "ALL") {
    std::string param1;
    parameterSet.getStringParamValue("debugOutput", param1);

    FEI_OSTRINGSTREAM osstr;
    if (!param1.empty()) {
      osstr << param1 << "/";
    }
    else osstr << "./";

    static int counter = 1;
    osstr << "x_Amesos.vec.slv"<<counter++;
    fei::SharedPtr<fei::Vector> feix = linearSystem->getSolutionVector();
    feix->writeToFile(osstr.str().c_str());
  }

  delete [] paramStrings;
  
  return(err);
}
开发者ID:KineticTheory,项目名称:Trilinos,代码行数:44,代码来源:fei_Solver_Amesos.cpp

示例7: runtime_error

int
DirichletBCManager::finalizeBCEqns(fei::Matrix& matrix,
                                   bool throw_if_bc_slave_conflict)
{
  fei::SharedPtr<fei::Reducer> reducer = matrix.getMatrixGraph()->getReducer();
  bool haveSlaves = reducer.get()!=NULL;

  //copy the boundary-condition prescribed values into the matrix, in
  //an equation-number obtained by using the matrix' VectorSpace to map
  //from the BC's idtype,id,fieldID,component to an equation-number. The
  //bc values will go on the diagonal of the matrix, i.e., column-index
  //will be the same equation-number.

  bc_map::iterator iter = bcs_.begin(), iter_end = bcs_.end();

  for(; iter!=iter_end; ++iter) {

    int eqn = iter->first;

    if (haveSlaves) {
      if (reducer->isSlaveEqn(eqn)) {
        if (throw_if_bc_slave_conflict) {
          FEI_OSTRINGSTREAM osstr;
          osstr << "fei BCManager::finalizeBCeqns ERROR, eqn="<<eqn
            << " is both a BC eqn and slave-constraint eqn.";
          throw std::runtime_error(osstr.str());
        }
        continue;
      }
    }

    double* ptr = &iter->second;

    CHK_ERR( matrix.copyIn(1, &eqn, 1, &eqn, &ptr) );
  }

  bcs_.clear();
  return(0);
}
开发者ID:00liujj,项目名称:trilinos,代码行数:39,代码来源:fei_DirichletBCManager.cpp

示例8: test_MatrixGraph_test7

void test_MatrixGraph_test7(MPI_Comm comm, int numProcs, int localProc)
{
  fei::SharedPtr<fei::VectorSpace> rowspace(new fei::VectorSpace(comm));
  fei::SharedPtr<fei::VectorSpace> colspace(new fei::VectorSpace(comm));

  int rowfield = 0, rowfieldsize = 1;
  int colfield = 1, colfieldsize = 3;
  rowspace->defineFields(1, &rowfield, &rowfieldsize);
  colspace->defineFields(1, &colfield, &colfieldsize);

  fei::MatrixGraph_Impl2 mgraph(rowspace, colspace);

  int pID = mgraph.definePattern(4, 0, colfield);
  fei::Pattern* pattern = mgraph.getPattern(pID);

  if (pattern->getNumIndices() != 4*colfieldsize) {
    FEI_COUT << "getNumIndices: " << pattern->getNumIndices()<<", colfieldsize: " << colfieldsize<<FEI_ENDL;
    FEI_OSTRINGSTREAM osstr;
    osstr << "test_MatrixGraph_test7, line "<<__LINE__<<FEI_ENDL;
    throw std::runtime_error(osstr.str());
  }
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:22,代码来源:test_MatrixGraph.cpp

示例9: test_MatrixGraph_test8

void test_MatrixGraph_test8(MPI_Comm comm, int numProcs, int localProc)
{
  FEI_COUT << "testing matrix-graph with 'diagonal' connectivity block...";

  try {

  fei::SharedPtr<fei::VectorSpace> rowspace(new fei::VectorSpace(comm));
  fei::SharedPtr<fei::VectorSpace> colspace;

  int rowfield = 0, rowfieldsize = 1;
  rowspace->defineFields(1, &rowfield, &rowfieldsize);
  int idType = 0;
  rowspace->defineIDTypes(1, &idType);

  fei::MatrixGraph_Impl2 mgraph(rowspace, colspace);

  int numIDs = 4;
  int patternID = mgraph.definePattern(numIDs, idType, rowfield);
  fei::Pattern* pattern = mgraph.getPattern(patternID);

  if (pattern->getNumIndices() != 4*rowfieldsize) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "test_MatrixGraph_test8, line "<<__LINE__<<FEI_ENDL;
    throw std::runtime_error(osstr.str());
  }

  int blockID = 0;
  int numConnLists = 1;
  bool diagonal = true;
  mgraph.initConnectivityBlock(blockID, numConnLists, patternID, diagonal);

  std::vector<int> ids(numIDs);
  for(int i=0; i<numIDs; ++i) {
    ids[i] = i;
  }

  mgraph.initConnectivity(blockID, 0, &ids[0]);

  mgraph.initComplete();

  fei::SharedPtr<fei::SparseRowGraph> localSRGraph =
    mgraph.createGraph(false);

  if ((int)localSRGraph->packedColumnIndices.size() != numIDs) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "test_MatrixGraph_test8, line "<<__LINE__<<FEI_ENDL;
    throw std::runtime_error(osstr.str());
  }

  }
  catch(std::runtime_error& exc) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "test_MatrixGraph_test8, caught exception: " << exc.what();
    throw std::runtime_error(osstr.str());
  }

  FEI_COUT << "ok" << FEI_ENDL;
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:58,代码来源:test_MatrixGraph.cpp

示例10: readSoln

//==============================================================================
int SolnCheck::readSoln(const char* baseName, int np, fei::FillableMat& solution)
{
  for(int i=0; i<np; i++) {
    FEI_OSTRINGSTREAM osstr;
    osstr << baseName << "." << np << "." << i;
    FEI_IFSTREAM infile(osstr.str().c_str());
    if (!infile || infile.bad()) return(-1);

    int node, numDOF;
    double tmpValue;
    infile >> node;
    while(!infile.eof()) {
      infile >> numDOF;

      for(int j=0; j<numDOF; j++) {
        infile >> tmpValue;
        solution.putCoef(node,j,tmpValue);
      }
      infile >> node;
    }
  }

  return(0);
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:25,代码来源:SolnCheck.cpp

示例11: getRecordWithLocalID

//----------------------------------------------------------------------------
int snl_fei::RecordCollection::getGlobalIndexLocalID(int localID,
                                              int fieldID,
                                              int fieldSize,
                                              int fieldOffset,
                                              int whichComponentOfField,
                                              const int* eqnNumbers)
{
  fei::Record<int>* record = getRecordWithLocalID(localID);
  if (record == NULL) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "snl_fei::RecordCollection::getGlobalIndexLocalID ERROR, no record with "
       << "localID=" << localID;
    throw std::runtime_error(osstr.str());
  }

  fei::FieldMask* mask = record->getFieldMask();
  int offset = 0;
  try {
    mask->getFieldEqnOffset(fieldID, offset);
  }
  catch (...) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "failed to get eqn-offset for fieldID " << fieldID
          << " on record with localID " << localID << ".";
    throw std::runtime_error(osstr.str());
  }

  const int* eqnNums = eqnNumbers + record->getOffsetIntoEqnNumbers();
  if (eqnNums == NULL) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "snl_fei::RecordCollection::getGlobalIndex ERROR: null pointer,"
         << " possibly because initComplete() hasn't been called yet?";
    throw std::runtime_error(osstr.str());
  }

  int globalIndex = -1;
  if (fieldOffset > 0) {
    globalIndex = eqnNums[offset + fieldOffset*fieldSize + whichComponentOfField];
  }
  else {
    globalIndex = eqnNums[offset + whichComponentOfField];
  }

  return(globalIndex);
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:46,代码来源:snl_fei_RecordCollection.cpp

示例12: runtime_error

//----------------------------------------------------------------------------
void
snl_fei::Factory::parameters(const fei::ParameterSet& parameterset)
{
  fei::Factory::parameters(parameterset);

  int err = 0;
  if (lsc_.get() != NULL || feData_.get() != NULL) {
    int numParams = 0;
    const char** paramStrings = NULL;
    std::vector<std::string> stdstrings;
    fei::utils::convert_ParameterSet_to_strings(&parameterset, stdstrings);
    fei::utils::strings_to_char_ptrs(stdstrings, numParams, paramStrings);
    char** nc_paramStrings = const_cast<char**>(paramStrings);
    if (lsc_.get() != NULL) {
      err += lsc_->parameters(numParams, nc_paramStrings);
    }
    if (feData_.get() != NULL) {
      err += feData_->parameters(numParams, nc_paramStrings);
    }

    delete [] paramStrings;

    if (err != 0) {
      FEI_OSTRINGSTREAM osstr;
      osstr << "snl_fei::Factory::parameters received err="<<err
            << " from either feiData_->parameters or lsc_->parameters.";
      throw std::runtime_error(osstr.str());
    }
  }

  parameterset.getIntParamValue("outputLevel", outputLevel_);

  const fei::Param* param = 0;
  fei::Param::ParamType ptype = fei::Param::BAD_TYPE;

  param = parameterset.get("BLOCK_GRAPH");
  ptype = param != NULL ? param->getType() : fei::Param::BAD_TYPE;
  if (ptype != fei::Param::BAD_TYPE) {
    blockMatrix_ = true;
  }

  param = parameterset.get("BLOCK_MATRIX");
  ptype = param != NULL ? param->getType() : fei::Param::BAD_TYPE;
  if (ptype != fei::Param::BAD_TYPE) {
    if (ptype == fei::Param::BOOL) {
      blockMatrix_ = param->getBoolValue();
    }
    else {
      blockMatrix_ = true;
    }
  }

  param = parameterset.get("AZ_matrix_type");
  ptype = param != NULL ? param->getType() : fei::Param::BAD_TYPE;
  if (ptype != fei::Param::BAD_TYPE) {
    if (ptype == fei::Param::STRING) {
      if (param->getStringValue() == "AZ_VBR_MATRIX") {
        blockMatrix_ = true;
      }
    }
  }
}
开发者ID:00liujj,项目名称:trilinos,代码行数:63,代码来源:snl_fei_Factory.cpp

示例13: while


//.........这里部分代码省略.........
    }
  }

  int firstBCeqn = bcEqns[0];
  int lastBCeqn = bcEqns[numBCeqns-1];

  std::vector<double> coefs;
  std::vector<int> indices;

  int insertPoint;

  int nextBCeqnOffset = 0;
  int nextBCeqn = bcEqns[nextBCeqnOffset];

  for(int i=firstLocalOffset_; i<=lastLocalOffset_; ++i) {
    if (haveSlaves) {
      if (reducer->isSlaveEqn(i)) continue;
    }

    bool should_continue = false;
    if (i >= nextBCeqn) {
      if (i == nextBCeqn) {
	++nextBCeqnOffset;
	if (nextBCeqnOffset < numBCeqns) {
	  nextBCeqn = bcEqns[nextBCeqnOffset];
	}
	else {
	  nextBCeqn = lastLocalOffset_+1;
	}

	should_continue = true;
      }
      else {
	while(nextBCeqn <= i) {
	  if (nextBCeqn == i) should_continue = true;
	  ++nextBCeqnOffset;
	  if (nextBCeqnOffset < numBCeqns) {
	    nextBCeqn = bcEqns[nextBCeqnOffset];
	  }
	  else {
	    nextBCeqn = lastLocalOffset_+1;
	  }
	}
      }
    }

    if (should_continue) continue;

    int err = getMatrixRow(matrix_.get(), i, coefs, indices);
    if (err != 0 || indices.size() < 1) {
      continue;
    }

    int numIndices = indices.size();
    int* indicesPtr = &indices[0];
    double* coefsPtr = &coefs[0];
    bool modifiedCoef = false;

    fei::insertion_sort_with_companions(numIndices, indicesPtr, coefsPtr);

    if (indicesPtr[0] > lastBCeqn || indicesPtr[numIndices-1] < firstBCeqn) {
      continue;
    }

    double value = 0.0;
    int offset = 0;

    for(int j=0; j<numIndices; ++j) {
      int idx = indicesPtr[j];
      offset = fei::binarySearch(idx, bcEqns, numBCeqns,
				     insertPoint);
      if (offset > -1) {
	value -= bcCoefs[offset]*coefsPtr[j];

	coefsPtr[j] = 0.0;
	modifiedCoef = true;
      }
    }

    if (modifiedCoef) {
      err = matrix_->copyIn(1, &i, numIndices, indicesPtr, &coefsPtr);
      if (err != 0) {
	FEI_OSTRINGSTREAM osstr;
	osstr <<"snl_fei::LinearSystem_General::enforceEssentialBC_step_2 ERROR: "
	      << "err="<<err<<" returned from matrix_->copyIn, row="<<i;
	throw std::runtime_error(osstr.str());
      }
    }

    const double fei_eps = 1.e-49;
    if (std::abs(value) > fei_eps) {
      rhs_->sumIn(1, &i, &value);

      if (output_level_ >= fei::FULL_LOGS && output_stream_ != 0) {
	FEI_OSTREAM& os = *output_stream_;
	os << "enfEssBC_step2: rhs["<<i<<"] += "<<value<<FEI_ENDL;
      }
    }
  }
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:101,代码来源:snl_fei_LinearSystem_General.cpp

示例14: get_ParameterList


//.........这里部分代码省略.........
    if (snl_epetra_crs != NULL) {
      precond = snl_epetra_crs->getMatrix().get();
    }
    else if (snl_epetra_vbr != NULL) {
      precond = snl_epetra_vbr->getMatrix().get();
    }
    else {
      fei::console_out() << "Solver_AztecOO::solve: ERROR getting epetra row matrix"
	       << " from preconditioningMatrix."<<FEI_ENDL;
      return(-1);
    }
  }

  if (precond != NULL) {
    Epetra_LinearProblem * newlinProb = new Epetra_LinearProblem(epetra_op,x,b);
    azoo_->SetProblem(*newlinProb);
    delete linProb;
    linProb = newlinProb;

    azoo_->SetAllAztecOptions(&(azoptions[0]));
    azoo_->SetAllAztecParams(&(azparams[0]));

    azoo_->SetUseAdaptiveDefaultsTrue();

    azoo_->SetPrecMatrix(precond);
  }

  bool needNewPreconditioner = false;

  if (feiA->changedSinceMark()) {
    feiA->markState();
    needNewPreconditioner = true;
  }

  if (needNewPreconditioner) {
    Epetra_LinearProblem * newlinProb = new Epetra_LinearProblem(epetra_op,x,b);
    azoo_->SetProblem(*newlinProb);
    delete linProb;
    linProb = newlinProb;

    azoo_->SetAllAztecOptions(&(azoptions[0]));
    azoo_->SetAllAztecParams(&(azparams[0]));

    azoo_->SetUseAdaptiveDefaultsTrue();

    if (useML_) {
#ifdef HAVE_FEI_ML
      setup_ml_operator(*azoo_, crsA);
#else
      fei::console_out() <<"Solver_AztecOO::solve ERROR, ML requested but HAVE_FEI_ML not defined."
	       << FEI_ENDL;
      return(-1);
#endif
    }
    else {
      azoo_->SetAztecOption(AZ_pre_calc, AZ_calc);
      azoo_->SetAztecOption(AZ_keep_info, 1);
    }
  }
  else {
    if (!useML_) {
      azoo_->SetAztecOption(AZ_pre_calc, AZ_reuse);
    }
  }

  epetra_op->SetUseTranspose(useTranspose_);

  azoo_->SetParameters(paramlist);

  maxIters_ = azoptionsptr[AZ_max_iter];
  tolerance_= azparamsptr[AZ_tol];

  status = azoo_->Iterate(maxIters_,
			 //2,//maxSolveAttempts
			 tolerance_);

  iterationsTaken = azoo_->NumIters();

  int olevel = 0;
  parameterSet.getIntParamValue("outputLevel", olevel);

  std::string param2;
  parameterSet.getStringParamValue("FEI_OUTPUT_LEVEL", param2);

  if (olevel >= 3 || param2 == "MATRIX_FILES" || param2 == "ALL") {
    std::string param1;
    parameterSet.getStringParamValue("debugOutput", param1);

    FEI_OSTRINGSTREAM osstr;
    if (!param1.empty()) {
      osstr << param1 << "/";
    }
    else osstr << "./";

    osstr << "x_AztecOO.vec";
    feix->writeToFile(osstr.str().c_str());
  }

  return(0);
}
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:101,代码来源:fei_Solver_AztecOO.cpp

示例15: rcp_A


//.........这里部分代码省略.........
  if (epetra_op == 0 || x == 0 || b == 0) {
    fei::console_out() << "Solver_Belos::solve Error, couldn't obtain Epetra objects"
     << " from fei container-objects."<<FEI_ENDL;
    return(-1);
  }

  Epetra_RowMatrix* precond = NULL;
  if (preconditioningMatrix != NULL) {
    fei::Matrix_Impl<Epetra_CrsMatrix>* snl_epetra_crs =
      dynamic_cast<fei::Matrix_Impl<Epetra_CrsMatrix>*>(preconditioningMatrix);
    fei::Matrix_Impl<Epetra_VbrMatrix>* snl_epetra_vbr =
      dynamic_cast<fei::Matrix_Impl<Epetra_VbrMatrix>*>(preconditioningMatrix);
    if (snl_epetra_crs != NULL) {
      precond = snl_epetra_crs->getMatrix().get();
    }
    else if (snl_epetra_vbr != NULL) {
      precond = snl_epetra_vbr->getMatrix().get();
    }
    else {
      fei::console_out() << "Solver_Belos::solve: ERROR getting epetra row matrix"
	       << " from preconditioningMatrix."<<FEI_ENDL;
      return(-1);
    }
  }

  if (precond != NULL) {
//TODO: set up preconditioner for Belos here
  }

  bool needNewPreconditioner = false;

  if (feiA->changedSinceMark()) {
    feiA->markState();
    needNewPreconditioner = true;
  }

  if (needNewPreconditioner) {
//
//    if (useML_) {
#ifdef HAVE_FEI_ML
//      setup_ml_operator(*azoo_, crsA);
#else
//      fei::console_out() <<"Solver_Belos::solve ERROR, ML requested but HAVE_FEI_ML not defined."
//	       << FEI_ENDL;
//      return(-1);
#endif
//    }
//    else {
//      azoo_->SetAztecOption(AZ_pre_calc, AZ_calc);
//      azoo_->SetAztecOption(AZ_keep_info, 1);
//    }
  }
  else {
//    if (!useML_) {
//      azoo_->SetAztecOption(AZ_pre_calc, AZ_reuse);
//    }
  }

  epetra_op->SetUseTranspose(useTranspose_);

  Belos::SolverFactory<double,Epetra_MultiVector,Epetra_Operator> belos_factory;
  belos_solver_manager_ = belos_factory.create(krylov_solver_name, paramlist);

  Teuchos::RCP<Belos::LinearProblem<double,Epetra_MultiVector,Epetra_Operator> > belos_lin_prob = Teuchos::rcp(new Belos::LinearProblem<double,Epetra_MultiVector,Epetra_Operator>(rcp_A, rcp_x, rcp_b));

  belos_lin_prob->setProblem();

  belos_solver_manager_->setProblem(belos_lin_prob);

  belos_solver_manager_->solve();
  status = 0;

  iterationsTaken = belos_solver_manager_->getNumIters();

  rcp_A.release();
  rcp_x.release();
  rcp_b.release();

  int olevel = 0;
  parameterSet.getIntParamValue("outputLevel", olevel);

  std::string param2;
  parameterSet.getStringParamValue("FEI_OUTPUT_LEVEL", param2);

  if (olevel >= 3 || param2 == "MATRIX_FILES" || param2 == "ALL") {
    std::string param1;
    parameterSet.getStringParamValue("debugOutput", param1);

    FEI_OSTRINGSTREAM osstr;
    if (!param1.empty()) {
      osstr << param1 << "/";
    }
    else osstr << "./";

    osstr << "x_Belos.vec";
    feix->writeToFile(osstr.str().c_str());
  }

  return(0);
}
开发者ID:KineticTheory,项目名称:Trilinos,代码行数:101,代码来源:fei_Solver_Belos.cpp


注:本文中的FEI_OSTRINGSTREAM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。