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);
  }
Esempio n. 2
0
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;
}