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


C++ VectorType::createSpace方法代码示例

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


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

示例1: buildPartitionedSpace

  VectorSpace<Scalar> buildPartitionedSpace(
    int nTotalDofs,
    int lowestLocalDof,
    int nLocalDofs,
    const Array<int>& isBCIndex,
    const VectorType<Scalar>& internalType,
    const VectorType<Scalar>& bcType,
    const MPIComm& comm
    )
  {
    int nBCDofs = 0;
    for (int i=0; i<nLocalDofs; i++)
    {
      if (isBCIndex[i]) nBCDofs++;
    }

    /* sum number of BC Dofs over all processors */
    int nTotalBCDofs = nBCDofs;
    comm.allReduce(&nBCDofs, &nTotalBCDofs, 1, MPIComm::INT, MPIComm::SUM);
    int nTotalInteriorDofs = nTotalDofs - nTotalBCDofs;


    Array<int> interiorDofs(nLocalDofs - nBCDofs);
    Array<int> bcDofs(nBCDofs);
    int iBC = 0;
    int iIn = 0;

    for (int i=0; i<nLocalDofs; i++)
    {
      if (isBCIndex[i]) bcDofs[iBC++] = lowestLocalDof+i;
      else interiorDofs[iIn++] = lowestLocalDof+i;
    }

    int p = MPIComm::world().getRank();


    VectorSpace<double> bcSpace = bcType.createSpace(nTotalBCDofs, nBCDofs,
      &(bcDofs[0]), comm);
    VectorSpace<double> interiorSpace = internalType.createSpace(nTotalInteriorDofs, nLocalDofs-nBCDofs,
      &(interiorDofs[0]), comm);

    return productSpace<double>(interiorSpace, bcSpace);
  }
开发者ID:coyigg,项目名称:trilinos,代码行数:43,代码来源:TSFBCPartitionedVSBuilder.hpp

示例2: runTest

bool runTest(int nProc, int rank, const VectorType<double>& vecType)
{
  int n = 4;
  int seed = 12345;
  for (int i=0; i<rank; i++) seed = (seed * 371761) % 5476181;
  cout << "seed = " << seed << std::endl;
  srand48(seed);
   
  int dimension = nProc*n;
  int low = n*rank;
  std::vector<int> localRows(n);
  for (int i=0; i<n; i++)
  {
    localRows[i] = low + i;
  }
   
  VectorSpace<double> space = vecType.createSpace(dimension, n, 
    &(localRows[0]), MPIComm::world());
   
  VectorTester<double> tester(space, TestSpecifier<double>(true, 1.0e-13, 1.0e-10));
   
  bool allPass = tester.runAllTests();
  return allPass;
}
开发者ID:coyigg,项目名称:trilinos,代码行数:24,代码来源:VectorTest.cpp


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