本文整理汇总了C++中teuchos::RCP::NeighborhoodListSize方法的典型用法代码示例。如果您正苦于以下问题:C++ RCP::NeighborhoodListSize方法的具体用法?C++ RCP::NeighborhoodListSize怎么用?C++ RCP::NeighborhoodListSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::RCP
的用法示例。
在下文中一共展示了RCP::NeighborhoodListSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Teuchos::RCP<PeridigmNS::NeighborhoodData>
PeridigmNS::TextFileDiscretization::filterBonds(Teuchos::RCP<PeridigmNS::NeighborhoodData> unfilteredNeighborhoodData)
{
// Set up a block bonding matrix, which defines whether or not bonds should be formed across blocks
int numBlocks = getNumBlocks();
std::vector< std::vector<bool> > blockBondingMatrix(numBlocks);
for(int i=0 ; i<numBlocks ; ++i){
blockBondingMatrix[i].resize(numBlocks, true);
}
if(bondFilterCommand == "None"){
// All blocks are bonded, the blockBondingMatrix is unchanged
return unfilteredNeighborhoodData;
}
else if(bondFilterCommand == "All"){
// No blocks are bonded, the blockBondingMatrix is the identity matrix
for(int i=0 ; i<numBlocks ; ++i){
for(int j=0 ; j<numBlocks ; ++j){
if(i != j)
blockBondingMatrix[i][j] = false;
}
}
}
else{
string msg = "**** Error, unrecognized value for \"Omit Bonds Between Blocks\": ";
msg += bondFilterCommand + "\n";
msg += "**** Valid options are: All, None\n";
TEUCHOS_TEST_FOR_EXCEPT_MSG(true, msg);
}
// Create an overlap vector containing the block IDs of each cell
Teuchos::RCP<const Epetra_BlockMap> ownedMap = getGlobalOwnedMap(1);
Teuchos::RCP<const Epetra_BlockMap> overlapMap = getGlobalOverlapMap(1);
Epetra_Vector blockIDs(*overlapMap);
Epetra_Import importer(*overlapMap, *ownedMap);
Teuchos::RCP<Epetra_Vector> ownedBlockIDs = getBlockID();
blockIDs.Import(*ownedBlockIDs, importer, Insert);
// Apply the block bonding matrix and create a new NeighborhoodData
Teuchos::RCP<PeridigmNS::NeighborhoodData> neighborhoodData = Teuchos::rcp(new PeridigmNS::NeighborhoodData);
neighborhoodData->SetNumOwned(unfilteredNeighborhoodData->NumOwnedPoints());
memcpy(neighborhoodData->OwnedIDs(), unfilteredNeighborhoodData->OwnedIDs(), neighborhoodData->NumOwnedPoints()*sizeof(int));
vector<int> neighborhoodListVec;
neighborhoodListVec.reserve(unfilteredNeighborhoodData->NeighborhoodListSize());
int* const neighborhoodPtr = neighborhoodData->NeighborhoodPtr();
int numOwnedPoints = neighborhoodData->NumOwnedPoints();
int* const unfilteredNeighborhoodList = unfilteredNeighborhoodData->NeighborhoodList();
int unfilteredNeighborhoodListIndex(0);
for(int iID=0 ; iID<numOwnedPoints ; ++iID){
int blockID = static_cast<int>(blockIDs[iID]);
int numUnfilteredNeighbors = unfilteredNeighborhoodList[unfilteredNeighborhoodListIndex++];
unsigned int numNeighborsIndex = neighborhoodListVec.size();
neighborhoodListVec.push_back(-1); // placeholder for number of neighbors
int numNeighbors = 0;
for(int iNID=0 ; iNID<numUnfilteredNeighbors ; ++iNID){
int unfilteredNeighborID = unfilteredNeighborhoodList[unfilteredNeighborhoodListIndex++];
int unfilteredNeighborBlockID = static_cast<int>(blockIDs[unfilteredNeighborID]);
if(blockBondingMatrix[blockID-1][unfilteredNeighborBlockID-1] == true){
neighborhoodListVec.push_back(unfilteredNeighborID);
numNeighbors += 1;
}
}
neighborhoodListVec[numNeighborsIndex] = numNeighbors;
neighborhoodPtr[iID] = numNeighborsIndex;
}
neighborhoodData->SetNeighborhoodListSize(neighborhoodListVec.size());
memcpy(neighborhoodData->NeighborhoodList(), &neighborhoodListVec[0], neighborhoodListVec.size()*sizeof(int));
return neighborhoodData;
}
示例2: rcp
//.........这里部分代码省略.........
TEST_FLOATING_EQUALITY((*initialX)[4], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[5], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[6], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[7], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[8], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[9], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[10], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[11], 0.75, 1.0e-16);
}
if(rank == 1){
TEST_FLOATING_EQUALITY((*initialX)[0], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[1], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[2], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[3], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[4], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[5], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[6], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[7], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[8], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[9], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[10], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[11], 0.25, 1.0e-16);
}
// check cell volumes
Teuchos::RCP<Epetra_Vector> volume = discretization->getCellVolume();
TEST_ASSERT(volume->MyLength() == 4);
TEST_ASSERT(volume->GlobalLength() == 8);
for(int i=0 ; i<volume->MyLength() ; ++i)
TEST_FLOATING_EQUALITY((*volume)[i], 0.125, 1.0e-16);
// check the neighbor lists
Teuchos::RCP<PeridigmNS::NeighborhoodData> neighborhoodData = discretization->getNeighborhoodData();
TEST_ASSERT(neighborhoodData->NumOwnedPoints() == 4);
int* ownedIds = neighborhoodData->OwnedIDs();
TEST_ASSERT(ownedIds[0] == 0);
TEST_ASSERT(ownedIds[1] == 1);
TEST_ASSERT(ownedIds[2] == 2);
TEST_ASSERT(ownedIds[3] == 3);
TEST_ASSERT(neighborhoodData->NeighborhoodListSize() == 16);
int* neighborhood = neighborhoodData->NeighborhoodList();
int* neighborhoodPtr = neighborhoodData->NeighborhoodPtr();
// remember, these are local IDs on each processor,
// which includes both owned and ghost nodes (confusing!)
if(rank == 0){
TEST_ASSERT(neighborhoodPtr[0] == 0);
TEST_ASSERT(neighborhood[0] == 3);
TEST_ASSERT(neighborhood[1] == 4);
TEST_ASSERT(neighborhood[2] == 1);
TEST_ASSERT(neighborhood[3] == 2);
TEST_ASSERT(neighborhoodPtr[1] == 4);
TEST_ASSERT(neighborhood[4] == 3);
TEST_ASSERT(neighborhood[5] == 0);
TEST_ASSERT(neighborhood[6] == 5);
TEST_ASSERT(neighborhood[7] == 3);
TEST_ASSERT(neighborhoodPtr[2] == 8);
TEST_ASSERT(neighborhood[8] == 3);
TEST_ASSERT(neighborhood[9] == 0);
TEST_ASSERT(neighborhood[10] == 6);
TEST_ASSERT(neighborhood[11] == 3);
TEST_ASSERT(neighborhoodPtr[3] == 12);
TEST_ASSERT(neighborhood[12] == 3);
TEST_ASSERT(neighborhood[13] == 1);
TEST_ASSERT(neighborhood[14] == 2);
TEST_ASSERT(neighborhood[15] == 7);
}
if(rank == 1){
TEST_ASSERT(neighborhoodPtr[0] == 0);
TEST_ASSERT(neighborhood[0] == 3);
TEST_ASSERT(neighborhood[1] == 2);
TEST_ASSERT(neighborhood[2] == 6);
TEST_ASSERT(neighborhood[3] == 1);
TEST_ASSERT(neighborhoodPtr[1] == 4);
TEST_ASSERT(neighborhood[4] == 3);
TEST_ASSERT(neighborhood[5] == 3);
TEST_ASSERT(neighborhood[6] == 0);
TEST_ASSERT(neighborhood[7] == 7);
TEST_ASSERT(neighborhoodPtr[2] == 8);
TEST_ASSERT(neighborhood[8] == 3);
TEST_ASSERT(neighborhood[9] == 4);
TEST_ASSERT(neighborhood[10] == 3);
TEST_ASSERT(neighborhood[11] == 0);
TEST_ASSERT(neighborhoodPtr[3] == 12);
TEST_ASSERT(neighborhood[12] == 3);
TEST_ASSERT(neighborhood[13] == 2);
TEST_ASSERT(neighborhood[14] == 5);
TEST_ASSERT(neighborhood[15] == 1);
}
}