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


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

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


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

示例1: PostList

// ================================================ ====== ==== ==== == =
int ML_Epetra::RefMaxwellPreconditioner::SetEdgeSmoother(Teuchos::ParameterList &List){

  std::string smoother=List.get("smoother: type","Chebyshev");
  int smoother_sweeps=List.get("smoother: sweeps",2);
  int output=List.get("ML output",0);

  if(smoother == "Hiptmair"){
    /* Smoother info output */
    int NumGlobalRows=SM_Matrix_->NumGlobalRows();
    int NumGlobalNNZ=SM_Matrix_->NumGlobalNonzeros();
    if(verbose_ && !Comm_->MyPID()) {
      int edge_sweeps=List.get("subsmoother: edge sweeps",2);
      int node_sweeps=List.get("subsmoother: node sweeps",2);
      char msg[80];
      sprintf(msg,"%s","RefMaxwell (level 0) :");
      printf("%s # global rows = %d, # estim. global nnz = %d\n",msg,NumGlobalRows,NumGlobalNNZ);
      printf("%s %s %d (e=%d/n=%d)\n",msg,smoother.c_str(),smoother_sweeps,edge_sweeps,node_sweeps);
    }

    /* Setup Teuchos Lists - Hiptmair */
    int edge_sweeps=List.get("subsmoother: edge sweeps",2);
    int node_sweeps=List.get("subsmoother: node sweeps",2);

    Teuchos::ParameterList PreList;
    PreList.setName("refmaxwell: edge presmoother");
    PreList.set("coarse: type",smoother);
    PreList.set("coarse: sweeps",1);
    PreList.set("coarse: edge sweeps",smoother_sweeps*edge_sweeps);
    PreList.set("coarse: node sweeps",smoother_sweeps*node_sweeps);
    PreList.set("coarse: subsmoother type",List.get("subsmoother: type","symmetric Gauss-Seidel"));
    PreList.set("coarse: Chebyshev alpha",List.get("subsmoother: Chebyshev alpha",30.0));
    PreList.set("coarse: MLS alpha",List.get("subsmoother: MLS alpha",30.0));
    PreList.set("coarse: damping factor",List.get("subsmoother: SGS damping factor",1.0));
    PreList.set("smoother: Hiptmair efficient symmetric",true);
    PreList.set("PDE equations",1);
    PreList.set("max levels",1);

    Teuchos::ParameterList PostList(PreList);
    PostList.setName("refmaxwell: edge postsmoother");
    PreList.set("coarse: pre or post","pre");
    PreList.set("smoother: pre or post","pre");
    PreList.set("zero starting solution", true);
    PreList.set("ML label","(1,1) block fine pre-smoother");
    PreList.set("ML output",output);
    PostList.set("coarse: pre or post","post");
    PostList.set("smoother: pre or post","post");
    PostList.set("zero starting solution", false);
    PostList.set("ML label","(1,1) block fine post-smoother");
    PostList.set("ML output",output);

    if(HasOnlyDirichletNodes){
      if(PreList.get("coarse: type","dummy") == "Hiptmair"){
        smoother=PreList.get("coarse: subsmoother type","symmetric Gauss-Seidel");
        PreList.set("coarse: type",smoother);
        PostList.set("coarse: type",smoother);
      }/*end if*/
#ifdef HAVE_ML_IFPACK
      IfSmoother=ML_Gen_Smoother_Ifpack_Epetra(const_cast<Epetra_CrsMatrix*>(&*SM_Matrix_),0,List_,"RefMaxwell (level 0): ",verbose_);
#else
      PreEdgeSmoother  = new MultiLevelPreconditioner(*SM_Matrix_,PreList);
      PostEdgeSmoother = new MultiLevelPreconditioner(*SM_Matrix_,PostList);
#endif
    }/*end if*/
    else{
      PreEdgeSmoother  = new MultiLevelPreconditioner(*SM_Matrix_,*D0_Matrix_,*TMT_Matrix_,PreList,true,true);
      PostEdgeSmoother = new MultiLevelPreconditioner(*SM_Matrix_,*D0_Matrix_,*TMT_Matrix_,PostList,true,true);
    }/*end if*/
  }/*end if*/
#ifdef HAVE_ML_IFPACK
  else {
    IfSmoother=ML_Gen_Smoother_Ifpack_Epetra(const_cast<Epetra_CrsMatrix*>(&*SM_Matrix_),0,List_,"RefMaxwell (level 0): ",verbose_);
  }/*end else*/
#endif

  return 0;
}/*end SetEdgeSmoother*/
开发者ID:00liujj,项目名称:trilinos,代码行数:77,代码来源:ml_RefMaxwell.cpp

示例2: main

int main(int argc, char *argv[]) {

  Teuchos::GlobalMPISession mpiSession(&argc, &argv);

  // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
  int iprint     = argc - 1;
  Teuchos::RCP<std::ostream> outStream;
  Teuchos::oblackholestream bhs; // outputs nothing
  if (iprint > 0)
    outStream = Teuchos::rcp(&std::cout, false);
  else
    outStream = Teuchos::rcp(&bhs, false);

  int errorFlag  = 0;

  // *** Example body.

  try {

    int dim = 10;

    Teuchos::ParameterList parlist;

    std::string jsonFileName("parameters.json");
    parlist.setName("Imported from " + jsonFileName);
    
    // Load json parameters into a Teuchos::ParameterList  
    ROL::JSON_Parameters(jsonFileName,parlist);

    Teuchos::RCP<ROL::Step<RealT> > step;
    ROL::stepFactory<RealT>(parlist,step);

    // Define Status Test
    RealT gtol  = parlist.get("Gradient Tolerance",1e-12); 
    RealT stol  = parlist.get("Step Tolerance",1e-14);  
    int   maxit = parlist.get("Maximum Number of Iterations",100); 
    ROL::StatusTest<RealT> status(gtol, stol, maxit);           

    ROL::DefaultAlgorithm<RealT> algo(*step,status,false);

    Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(new std::vector<RealT> (dim, 1.0) );
    Teuchos::RCP<std::vector<RealT> > k_rcp = Teuchos::rcp(new std::vector<RealT> (dim, 0.0) );

    ROL::StdVector<RealT> x(x_rcp);
    Teuchos::RCP<ROL::Vector<RealT> > k = Teuchos::rcp(new ROL::StdVector<RealT>(k_rcp) );

    for(int i=0;i<dim;++i) {
        (*k_rcp)[i] = i+1.0;
    }
 
    ROL::ZOO::Objective_Zakharov<RealT> obj(k);

    // Run Algorithm
    std::vector<std::string> output = algo.run(x, obj, false);
    for ( unsigned i = 0; i < output.size(); i++ ) {
      std::cout << output[i];
    }

    // Get True Solution
    Teuchos::RCP<std::vector<RealT> > xtrue_rcp = Teuchos::rcp( new std::vector<RealT> (dim, 0.0) );
    ROL::StdVector<RealT> xtrue(xtrue_rcp);

    // Compute Error
    x.axpy(-1.0, xtrue);
    RealT abserr = x.norm();
    *outStream << std::scientific << "\n   Absolute Error: " << abserr;
    if ( abserr > sqrt(ROL::ROL_EPSILON) ) {
      errorFlag += 1;
    }

    // Make an XML file containing the supplied parameters
    Teuchos::writeParameterListToXmlFile(parlist,"parameters.xml");
 
 }
  catch (std::logic_error err) {
    *outStream << err.what() << "\n";
    errorFlag = -1000;
  }; // end try

  if (errorFlag != 0)
    std::cout << "End Result: TEST FAILED\n";
  else
    std::cout << "End Result: TEST PASSED\n";

  return 0;

}
开发者ID:rainiscold,项目名称:trilinos,代码行数:87,代码来源:example_01.cpp


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