本文整理汇总了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);
}
示例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;
}