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


C++ Tpetra_Vector::getGlobalLength方法代码示例

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


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

示例1: Scalar

void 
twoD_diffusion_problem<Scalar,MeshScalar,BasisScalar,LocalOrdinal,GlobalOrdinal,
		       Node>::
computeResponse(const Tpetra_Vector& x,
		const Tpetra_Vector& p,
		Tpetra_Vector& g)
{
  // g = average of x
  Teuchos::ArrayRCP<Scalar> g_view = g.get1dViewNonConst();
  x.meanValue(g_view());
  g_view[0] *= Scalar(x.getGlobalLength()) / Scalar(mesh.size());
}
开发者ID:00liujj,项目名称:trilinos,代码行数:12,代码来源:twoD_diffusion_problem_tpetra_def.hpp

示例2:

void
Albany::SolutionAverageResponseFunction::
evaluateTangentT(const double alpha, 
		const double beta,
		const double omega,
		const double current_time,
		bool sum_derivs,
		const Tpetra_Vector* xdotT,
		const Tpetra_Vector* xdotdotT,
		const Tpetra_Vector& xT,
		const Teuchos::Array<ParamVec>& p,
		ParamVec* deriv_p,
		const Tpetra_MultiVector* VxdotT,
		const Tpetra_MultiVector* VxdotdotT,
		const Tpetra_MultiVector* VxT,
		const Tpetra_MultiVector* VpT,
		Tpetra_Vector* gT,
		Tpetra_MultiVector* gxT,
		Tpetra_MultiVector* gpT)
{
  // Evaluate response g
  if (gT != NULL) {
    ST mean = xT.meanValue();
    Teuchos::ArrayRCP<ST> gT_nonconstView = gT->get1dViewNonConst();
    gT_nonconstView[0] = mean; 
  }

  // Evaluate tangent of g = dg/dx*Vx + dg/dxdot*Vxdot + dg/dp*Vp
  // If Vx == NULL, Vx is the identity
  if (gxT != NULL) {
    Teuchos::ArrayRCP<ST> gxT_nonconstView;
    if (VxT != NULL) {
       Teuchos::Array<ST> means; 
       means.resize(VxT->getNumVectors());
       VxT->meanValue(means());  
      for (int j=0; j<VxT->getNumVectors(); j++) {  
        gxT_nonconstView = gxT->getDataNonConst(j); 
        gxT_nonconstView[0] = means[j];  
      }
    }
    else {
      gxT->putScalar(1.0/xT.getGlobalLength());
    }
    gxT->scale(alpha);
  }
  
  if (gpT != NULL)
    gpT->putScalar(0.0);
}
开发者ID:Sam-MSU,项目名称:Albany,代码行数:49,代码来源:Albany_SolutionAverageResponseFunction.cpp

示例3:

void
Albany::SolutionMaxValueResponseFunction::
computeMaxValueT(const Tpetra_Vector& xT, double& global_max, int& global_index)
{
  //The following is needed b/c Epetra_MaxDouble comes from Trilinos Epetra package.
  double Tpetra_MaxDouble = 1.0E+100; 
  double my_max = -Tpetra_MaxDouble;
  int my_index = -1, index;
  
  Teuchos::ArrayRCP<const ST> xT_constView = xT.get1dView();
  
  // Loop over nodes to find max value for equation eq
  int num_my_nodes = xT.getLocalLength() / neq;
  for (int node=0; node<num_my_nodes; node++) {
    if (interleavedOrdering)  index = node*neq+eq;
    else                      index = node + eq*num_my_nodes;
    if (xT_constView[index] > my_max) {
      my_max = xT_constView[index];
      my_index = index;
    }
  }

  // Check remainder (AGS: NOT SURE HOW THIS CODE GETS CALLED?)
  if (num_my_nodes*neq+eq < xT.getLocalLength()) {
    if (interleavedOrdering)  index = num_my_nodes*neq+eq;
    else                      index = num_my_nodes + eq*num_my_nodes;
    if (xT_constView[index] > my_max) {
      my_max = xT_constView[index];
      my_index = index;
    }
  }

  Teuchos::RCP<const Teuchos::Comm<int> > commT = xT.getMap()->getComm(); 
  // Get max value across all proc's
  Teuchos::reduceAll(*commT, Teuchos::REDUCE_MAX, my_max, Teuchos::ptr(&global_max)); 

  // Compute min of all global indices equal to max value
  if (my_max == global_max)
    my_index = xT.getMap()->getGlobalElement(my_index);
  else
    my_index = xT.getGlobalLength();
  Teuchos::reduceAll(*commT, Teuchos::REDUCE_MIN, my_index, Teuchos::ptr(&global_index)); 
}
开发者ID:ImmutableLtd,项目名称:Albany,代码行数:43,代码来源:Albany_SolutionMaxValueResponseFunction.cpp


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