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


C++ RCP::Broadcast方法代码示例

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


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

示例1: random

Real random(const Teuchos::RCP<Epetra_Comm> &comm) {
  Real val = 0.0;
  if ( comm->MyPID()==0 ) {
    val = (Real)rand()/(Real)RAND_MAX;
  }
  comm->Broadcast(&val,1,0);
  return val;
}
开发者ID:abhishek4747,项目名称:trilinos,代码行数:8,代码来源:test_01.cpp

示例2: main


//.........这里部分代码省略.........
      
    if (globalData->locaUtils->isPrintType(NOX::Utils::TestDetails))
      globalData->locaUtils->out() 
	<< std::endl 
	<< "***** Checking solution statistics *****" 
	<< std::endl;
      
    // Check number of continuation steps
    int numSteps = stepper.getStepNumber();
    int numSteps_expected = 3;
    ierr += testCompare.testValue(numSteps, numSteps_expected, 0.0,
				  "number of continuation steps",
				  NOX::TestCompare::Absolute);
      
    // Check number of failed steps
    int numFailedSteps = stepper.getNumFailedSteps();
    int numFailedSteps_expected = 0;
    ierr += testCompare.testValue(numFailedSteps, numFailedSteps_expected, 0.0,
				  "number of failed continuation steps",
				  NOX::TestCompare::Absolute);
      
    // Check final value of continuation parameter
    double beta_final = finalGroup->getParam("beta");
    double beta_expected = 2.0;
    ierr += testCompare.testValue(beta_final, beta_expected, 1.0e-14,
				  "final value of continuation parameter", 
				  NOX::TestCompare::Relative);
      
    // Check final value of ||F||
    double Fnorm_final = (const_cast<Teuchos::ParameterList&>(*stepper.getList()).sublist("NOX").sublist("Output").get("2-Norm of Residual",1.0e+10));
    double Fnorm_expected = 0.0;
    ierr += testCompare.testValue(Fnorm_final, Fnorm_expected, 1.0e-8,
				  "final value of ||F||", 
				  NOX::TestCompare::Absolute);
      
    // Check number of nonlinear iterations on last continuation step
    int nonlin_final = (const_cast<Teuchos::ParameterList&>(*stepper.getList()).sublist("NOX").
			sublist("Output").get("Nonlinear Iterations",MAX_NEWTON_ITERS));
    int nonlin_expected = 4;
    ierr += testCompare.testValue(nonlin_final, nonlin_expected, 0.0,
				  "number of nonlinear iterations on last continuation step", 
				  NOX::TestCompare::Absolute);
      
      
    // initialize solution comparison norm on all procs
    double solution_diff_norm = 0.0;
      
    // Compute norm of difference of computed solution - expected solution
    if (globalComm->MyPID() == (globalComm->NumProc()-1)) {
      // Get solution at last time step
      ixyzt->getSolution().ExtractBlockValues(soln, 
					      (globalComm->NumTimeStepsOnDomain() + 
					       globalComm->FirstTimeStepOnDomain() - 1));
	
      // Check final solution at final time step
      NOX::Epetra::Vector final_solution(soln);
      NOX::Epetra::Vector final_x_expected(final_solution);
      for (int i=0; i<NumGlobalNodes; i++) {
	final_x_expected.getEpetraVector()[2*i] = alpha;
	final_x_expected.getEpetraVector()[2*i+1] = beta_final/alpha;
      }
      solution_diff_norm = testCompare.computeVectorNorm(final_solution, 
							 final_x_expected, 
							 1.0e-4, 
							 1.0e-4);
	
    }
      
    // Check final solution at final time step on all procs
    globalComm->Broadcast(&solution_diff_norm, 1, globalComm->NumProc()-1);
    double solution_diff_norm_expected = 0.0;
    ierr += testCompare.testValue(solution_diff_norm, solution_diff_norm_expected, 1.0e-4,
				  "inf norm of (solution_final - solution_expected) at last time step", 
				  NOX::TestCompare::Absolute);
            
    LOCA::destroyGlobalData(globalData);
        
  }
  catch (std::exception& e) {
    std::cout << e.what() << std::endl;
    ierr = 1;
  }
  catch (const char *s) {
    std::cout << s << std::endl;
    ierr = 1;
  }
  catch (...) {
    std::cout << "Caught unknown exception!" << std::endl;
    ierr = 1;
  }

  if (MyPID == 0) {
    if (ierr == 0)
      std::cout << "All tests passed!" << std::endl;
    else
      std::cout << ierr << " test(s) failed!" << std::endl;
  }

  return ierr;
}
开发者ID:haripandey,项目名称:trilinos,代码行数:101,代码来源:brussXYZT_bdsdt.C


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