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


C++ ParameterList::setParameters方法代码示例

本文整理汇总了C++中teuchos::ParameterList::setParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::setParameters方法的具体用法?C++ ParameterList::setParameters怎么用?C++ ParameterList::setParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在teuchos::ParameterList的用法示例。


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

示例1: setup_ml_operator

//---------------------------------------------------------------------------
int Solver_Belos::setup_ml_operator(AztecOO& azoo, Epetra_CrsMatrix* A)
{
#ifdef HAVE_FEI_ML
  if (ml_aztec_options_ == NULL) {
    ml_aztec_options_ = new int[AZ_OPTIONS_SIZE];
  }
  if (ml_aztec_params_ == NULL) {
    ml_aztec_params_ = new double[AZ_PARAMS_SIZE];
  }

  if (!ml_defaults_set_) {
    Teuchos::ParameterList mlparams;
    ML_Epetra::SetDefaults("SA", mlparams,ml_aztec_options_,ml_aztec_params_);
    mlparams.setParameters(*paramlist_);
    *paramlist_ = mlparams;
    ml_defaults_set_ = true;
  }

  if (ml_prec_ != NULL) {
    delete ml_prec_; ml_prec_ = NULL;
  }

  ml_prec_ = new ML_Epetra::MultiLevelPreconditioner(*A, *paramlist_, true);
  //azoo_->SetPrecOperator(ml_prec_);

#endif

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

示例2: getDefaultParameters

  ThrustGPUNode::ThrustGPUNode (Teuchos::ParameterList &pl)
  {
    using std::cout;
    using std::cerr;
    using std::endl;

    // get node parameters
    Teuchos::ParameterList params = getDefaultParameters ();
    params.setParameters (pl);
    int device = params.get<int>("Device Number");
    const int verbose = params.get<int>("Verbose");

    // set device
    int deviceCount; cudaGetDeviceCount(&deviceCount);
    TEUCHOS_TEST_FOR_EXCEPTION(
      deviceCount == 0, std::runtime_error,
      "Kokkos::ThrustGPUNode constructor: system has no CUDA devices."
    );
    if (device < 0 || device >= deviceCount) {
      cerr << "Kokkos::ThrustGPUNode constructor: The specified device number "
           << device << " is not valid. Using Device 0." << endl;
      device = 0;
    }
    cudaDeviceProp deviceProp;
    cudaSetDevice (device);
    cudaGetDeviceProperties (&deviceProp, device);
    // as of CUDA 2.1, device prop contains the following fields
    // char name[256];
    // size_t totalGlobalMem, sharedMemPerBlock;
    // int regsPerBlock, warpSize;
    // size_t memPitch;
    // int maxThreadsPerBlock, maxThreadsDim[3], maxGridSize[3];
    // size_t totalConstMem;
    // int major, minor;
    // int clockRate;
    // size_t textureAlignment;
    // int deviceOverlap;
    // int multiProcessorCount;
    // int kernelExecTimeoutEnabled;
    if (verbose) {
      cout << "Kokkos::ThrustGPUNode attached to device #" << device << " \""
           << deviceProp.name << "\", of compute capability "
           << deviceProp.major << "." << deviceProp.minor << endl;
    }
    totalMem_ = deviceProp.totalGlobalMem;

#if defined(HAVE_KOKKOSCLASSIC_KOKKOSCORE) && defined(KOKKOS_HAVE_CUDA)
    if (! Kokkos::Cuda::host_mirror_device_type::is_initialized ()) {
      Kokkos::Cuda::host_mirror_device_type::initialize ();
    }
    if (! Kokkos::Cuda::is_initialized ()) {
      Kokkos::Cuda::initialize (Kokkos::Cuda::SelectDevice (device));
    }
#endif
  }
开发者ID:00liujj,项目名称:trilinos,代码行数:55,代码来源:Kokkos_ThrustGPUNode.cpp

示例3: getDefaultParameters

 OpenMPNode::OpenMPNode (Teuchos::ParameterList &pl) :
   curNumThreads_ (-1), // Default: Let OpenMP pick the number of threads
   verbose_ (false)     // Default: No verbose status output
 {
   Teuchos::ParameterList params = getDefaultParameters();
   params.setParameters(pl);
   const int curNumThreads = params.get<int>("Num Threads");
   int verboseInt = params.get<int>("Verbose");
   bool verbose = (verboseInt != 0);
   if (verbose) {
     std::cout << "OpenMPNode initializing with \"Num Threads\" = "
               << curNumThreads << std::endl;
   }
   init (curNumThreads);
   curNumThreads_ = curNumThreads; // Now it's safe to set state.
   verbose_ = verbose;
 }
开发者ID:rainiscold,项目名称:trilinos,代码行数:17,代码来源:Kokkos_OpenMPNode.cpp

示例4: solve

//---------------------------------------------------------------------------
int Solver_Belos::solve(fei::LinearSystem* linearSystem,
			  fei::Matrix* preconditioningMatrix,
			  const fei::ParameterSet& parameterSet,
			  int& iterationsTaken,
			  int& status)
{
  std::string krylov_solver_name;
  parameterSet.getStringParamValue("krylov_solver", krylov_solver_name);

  Teuchos::RCP<Teuchos::ParameterList>& paramlist = paramlist_;

#ifdef HAVE_FEI_ML
  if (ml_aztec_options_ == NULL)
    ml_aztec_options_ = new int[AZ_OPTIONS_SIZE];
  if (ml_aztec_params_ == NULL)
    ml_aztec_params_ = new double[AZ_PARAMS_SIZE];

  if (!ml_defaults_set_ && useML_) {
    Teuchos::ParameterList mlparams;
    ML_Epetra::SetDefaults("SA", mlparams, ml_aztec_options_,ml_aztec_params_);
    mlparams.setParameters(*paramlist);
    *paramlist = mlparams;
    ml_defaults_set_ = true;
  }
#endif

  Trilinos_Helpers::copy_parameterset(parameterSet, *paramlist);

  fei::SharedPtr<fei::Matrix> feiA = linearSystem->getMatrix();
  fei::SharedPtr<fei::Vector> feix = linearSystem->getSolutionVector();
  fei::SharedPtr<fei::Vector> feib = linearSystem->getRHS();

  Epetra_MultiVector*    x = NULL;
  Epetra_MultiVector*    b = NULL;
  Epetra_Operator* epetra_op = 0;
  Epetra_CrsMatrix* crsA = NULL;

  Trilinos_Helpers::get_Epetra_pointers(feiA, feix, feib,
                                        crsA, epetra_op, x, b);

  Teuchos::RCP<Epetra_CrsMatrix> rcp_A(crsA);
  Teuchos::RCP<Epetra_MultiVector> rcp_x(x);
  Teuchos::RCP<Epetra_MultiVector> rcp_b(b);

  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);
//.........这里部分代码省略.........
开发者ID:KineticTheory,项目名称:Trilinos,代码行数:101,代码来源:fei_Solver_Belos.cpp

示例5: cloneVector


//.........这里部分代码省略.........
        std::string contDataFileName =
            outputList.get<string> ( "Continuation data file name" );
        // =========================================================================


        // ---------------------------------------------------------------------------
        Teuchos::ParameterList glParameters;
        Teuchos::RCP<ComplexVector> psi;
        Teuchos::RCP<Recti::Grid::Uniform> grid;

        Teuchos::ParameterList initialGuessList;
        initialGuessList = paramList->sublist ( "Initial guess", true );

        boost::filesystem::path inputGuessFile = initialGuessList.get<string> ( "File name" );
        if ( !inputGuessFile.empty() && inputGuessFile.root_directory().empty() ) // if inputGuessFile is a relative path
            inputGuessFile = xmlPath / inputGuessFile;

        TEUCHOS_ASSERT( !inputGuessFile.empty() );

        // For technical reasons, the reader can only accept ComplexMultiVectors.
        Teuchos::RCP<Ginla::FDM::State> state;
        Recti::Grid::Reader::read ( Comm,
                                    inputGuessFile.string(),
                                    state,
                                    grid,
                                    glParameters );

        // possibly overwrite the parameters
        Teuchos::ParameterList & overwriteParamsList = paramList->sublist ( "Overwrite parameter list", true );
        bool overwriteParameters = overwriteParamsList.get<bool> ( "Overwrite parameters" );
        if ( overwriteParameters )
        {
            Teuchos::ParameterList & overwritePList = overwriteParamsList.sublist( "Parameters", true );
            glParameters.setParameters( overwritePList );

            // possibly update the scaling of the grid
            grid->updateScaling( glParameters.get<double>("scaling") );
        }
        // ---------------------------------------------------------------------------

        Teuchos::RCP<Ginla::MagneticVectorPotential::Virtual> A =
            Teuchos::rcp ( new Ginla::MagneticVectorPotential::ZSquareSymmetric
                           ( glParameters.get<double> ( "H0" ),
                             glParameters.get<double> ( "scaling" )
                           )
                         );

        // create the operator
        Teuchos::RCP<Ginla::FDM::Operator::Virtual> glOperator =
            Teuchos::rcp ( new Ginla::FDM::Operator::BCCentral ( grid, A, psi->getMap(), psi->getMap() ) );

//     // create a perturbation
//     Teuchos::RCP<GL::Perturbation::Virtual> quadrantsPerturbation =
//       Teuchos::rcp ( new GL::Perturbation::Quadrants ( grid ) );

        // TODO: why not make glOperator depend upon perturbation instead?
//     GinzburgLandau glProblem = GinzburgLandau ( glOperator,
//                                                 quadrantsPerturbation );


        std::string fn = outputDirectory.string() + "/" + contDataFileName;
        Teuchos::RCP<Ginla::IO::StatsWriter> statsWriter =
            Teuchos::rcp( new Ginla::IO::StatsWriter( fn ) );

        Teuchos::RCP<Ginla::FDM::LocaSystem::Bordered> glsystem;
开发者ID:nschloe,项目名称:nosh,代码行数:66,代码来源:oneParameterContinuation.cpp

示例6: Reshape

void InverseOperator::Reshape(const Operator& Op, const string Type,
             Teuchos::ParameterList& List, Teuchos::ParameterList* pushlist)
{
  ResetTimer();
  StackPush();

  Op_ = Op;

  RCPRowMatrix_ = Op.GetRCPRowMatrix();

  // FIXME: to add overlap and level-of-fill
  int NumSweeps   = List.get("smoother: sweeps", 1);
  double Damping  = List.get("smoother: damping factor", 0.67); 
  int LOF_ilu     = List.get("smoother: ilu fill", 0);
  double LOF_ict  = List.get("smoother: ilut fill", 1.0);
  double LOF_ilut = List.get("smoother: ict fill", 1.0);
  string reorder  = List.get("schwarz: reordering type","rcm");

  Teuchos::ParameterList IFPACKList;

  // any parameters from the main list List are overwritten by the pushlist
  IFPACKList.set("relaxation: sweeps", NumSweeps);
  IFPACKList.set("relaxation: damping factor", Damping);
  IFPACKList.set("fact: level-of-fill", LOF_ilu);
  IFPACKList.set("fact: ict level-of-fill", LOF_ict);
  IFPACKList.set("fact: ilut level-of-fill", LOF_ilut);
  IFPACKList.set("relaxation: zero starting solution", false);
  IFPACKList.set("schwarz: reordering type",reorder);
  IFPACKList.set("fact: relative threshold",1.0);

  // if present, the pushlist is assumed to be a preconstructed ifpack list
  // that is copied straight to the ifpack list here
  // entries in pushlist overwrite previous list entries
  if (pushlist)
    IFPACKList.setParameters(*pushlist);


  bool verbose = false; //(GetMyPID() == 0 && GetPrintLevel() > 5);

  // the ML smoother
  RCPMLPrec_ = Teuchos::null;
  // The Ifpack smoother
  Ifpack_Preconditioner* Prec = NULL;

  if (Type == "Jacobi") {
    if (verbose) {
      cout << "Damping factor = " << Damping 
        << ", sweeps = " << NumSweeps << endl;
      cout << endl;
    }
    IFPACKList.set("relaxation: type", "Jacobi");
    Prec = new Ifpack_PointRelaxation(RowMatrix());
  }
  else if (Type == "Gauss-Seidel") {
    if (verbose) {
      cout << "Damping factor = " << Damping 
        << ", sweeps = " << NumSweeps << endl;
      cout << endl;
    }
    IFPACKList.set("relaxation: type", "Gauss-Seidel");
    Prec = new Ifpack_PointRelaxation(RowMatrix());
  }
  else if (Type == "symmetric Gauss-Seidel") {
    if (verbose) {
      cout << "Damping factor = " << Damping 
        << ", sweeps = " << NumSweeps << endl;
      cout << endl;
    }
    IFPACKList.set("relaxation: type", "symmetric Gauss-Seidel");

    Prec = new Ifpack_PointRelaxation(RowMatrix());
  }
  else if (Type == "ILU") {
    if (verbose) {
      cout << "ILU factorization, ov = 0, no reordering, LOF = "
        << LOF_ilu << endl;
      cout << endl;
    }
    
    // use the Additive Schwarz class because it does reordering
    Prec = new Ifpack_AdditiveSchwarz<Ifpack_ILU>(RowMatrix());
  }
  else if (Type == "ILUT") {
    if (verbose) {
      cout << "ILUT factorization, ov = 0, no reordering, LOF = "
        << LOF_ilu << endl;
      cout << endl;
    }
    Prec = new Ifpack_ILUT(RowMatrix());
  }
  else if (Type == "IC") {
    if (verbose) {
      cout << "IC factorization, ov = 0, no reordering, LOF = "
        << LOF_ilu << endl;
      cout << endl;
    }
    Prec = new Ifpack_IC(RowMatrix());
  }
  else if (Type == "ICT") {
    if (verbose) {
//.........这里部分代码省略.........
开发者ID:haripandey,项目名称:trilinos,代码行数:101,代码来源:MLAPI_InverseOperator.cpp

示例7: solve

//---------------------------------------------------------------------------
int Solver_AztecOO::solve(fei::LinearSystem* linearSystem,
			  fei::Matrix* preconditioningMatrix,
			  const fei::ParameterSet& parameterSet,
			  int& iterationsTaken,
			  int& status)
{
  std::string pcstring;
  parameterSet.getStringParamValue("AZ_precond", pcstring);
  if (pcstring == "ML_Op") {
    useML_ = true;
  }

  Teuchos::ParameterList& paramlist = get_ParameterList();

#ifdef HAVE_FEI_ML
  if (ml_aztec_options_ == NULL)
    ml_aztec_options_ = new int[AZ_OPTIONS_SIZE];
  if (ml_aztec_params_ == NULL)
    ml_aztec_params_ = new double[AZ_PARAMS_SIZE];

  if (!ml_defaults_set_ && useML_) {
    Teuchos::ParameterList mlparams;
    ML_Epetra::SetDefaults("SA", mlparams, ml_aztec_options_,ml_aztec_params_);
    mlparams.setParameters(paramlist);
    paramlist = mlparams;
    ml_defaults_set_ = true;
  }
#endif

  Trilinos_Helpers::copy_parameterset(parameterSet, paramlist);

  fei::SharedPtr<fei::Matrix> feiA = linearSystem->getMatrix();
  fei::SharedPtr<fei::Vector> feix = linearSystem->getSolutionVector();
  fei::SharedPtr<fei::Vector> feib = linearSystem->getRHS();

  Epetra_MultiVector*    x = NULL;
  Epetra_MultiVector*    b = NULL;
  Epetra_Operator* epetra_op = 0;
  Epetra_CrsMatrix* crsA = NULL;

  Trilinos_Helpers::get_Epetra_pointers(feiA, feix, feib,
                                        crsA, epetra_op, x, b);

  if (epetra_op == 0 || x == 0 || b == 0) {
    fei::console_out() << "Solver_AztecOO::solve Error, couldn't obtain Epetra objects"
     << " from fei container-objects."<<FEI_ENDL;
    return(-1);
  }

  //when we call azoo_->SetProblem, it will set some options. So we will
  //first take a copy of all options and params, then reset them after the
  //call to SetProblem. That way we preserve any options that have already
  //been set.

  std::vector<int> azoptions(AZ_OPTIONS_SIZE);
  std::vector<double> azparams(AZ_PARAMS_SIZE);

  const int* azoptionsptr = azoo_->GetAllAztecOptions();
  const double* azparamsptr = azoo_->GetAllAztecParams();

  int i;
  for(i=0; i<AZ_OPTIONS_SIZE; ++i) {
    azoptions[i] = azoptionsptr[i];
  }
  for(i=0; i<AZ_PARAMS_SIZE; ++i) {
    azparams[i] = azparamsptr[i];
  }

  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_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);
//.........这里部分代码省略.........
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:101,代码来源:fei_Solver_AztecOO.cpp


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