本文整理汇总了C++中stk::mesh::BulkData::buckets方法的典型用法代码示例。如果您正苦于以下问题:C++ BulkData::buckets方法的具体用法?C++ BulkData::buckets怎么用?C++ BulkData::buckets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stk::mesh::BulkData
的用法示例。
在下文中一共展示了BulkData::buckets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performNodalMeshReduction
void performNodalMeshReduction(
stk::mesh::Part &samplePart,
stk::mesh::BulkData& bulkData)
{
const stk::mesh::EntityRank nodeEntityRank(0);
const stk::mesh::MetaData &metaData = stk::mesh::MetaData::get(bulkData);
std::vector<stk::mesh::Entity *> sampleNodes;
stk::mesh::get_selected_entities(samplePart, bulkData.buckets(nodeEntityRank), sampleNodes);
const stk::mesh::Selector locallyOwned = stk::mesh::MetaData::get(bulkData).locally_owned_part();
std::vector<stk::mesh::Entity *> relatedEntities;
typedef boost::indirect_iterator<std::vector<stk::mesh::Entity *>::const_iterator> EntityIterator;
for (EntityIterator it(sampleNodes.begin()), it_end(sampleNodes.end()); it != it_end; ++it) {
const stk::mesh::PairIterRelation relations = it->relations();
typedef stk::mesh::PairIterRelation::first_type RelationIterator;
for (RelationIterator rel_it = relations.first, rel_it_end = relations.second; rel_it != rel_it_end; ++rel_it) {
const Teuchos::Ptr<stk::mesh::Entity> relatedEntity(rel_it->entity());
if (Teuchos::nonnull(relatedEntity) && locallyOwned(*relatedEntity)) {
relatedEntities.push_back(relatedEntity.get());
}
}
}
std::sort(relatedEntities.begin(), relatedEntities.end(), stk::mesh::EntityLess());
relatedEntities.erase(
std::unique(relatedEntities.begin(), relatedEntities.end(), stk::mesh::EntityEqual()),
relatedEntities.end());
std::vector<stk::mesh::Entity *> sampleClosure;
stk::mesh::find_closure(bulkData, relatedEntities, sampleClosure);
// Keep only the closure, remove the rest, by decreasing entityRanks
{
const stk::mesh::Selector ownedOrShared = metaData.locally_owned_part() | metaData.globally_shared_part();
typedef boost::indirect_iterator<std::vector<stk::mesh::Entity *>::const_iterator> EntityIterator;
EntityIterator allKeepersEnd(sampleClosure.end());
const EntityIterator allKeepersBegin(sampleClosure.begin());
for (stk::mesh::EntityRank candidateRankCount = metaData.entity_rank_count(); candidateRankCount > 0; --candidateRankCount) {
const stk::mesh::EntityRank candidateRank = candidateRankCount - 1;
const EntityIterator keepersBegin = std::lower_bound(allKeepersBegin, allKeepersEnd,
stk::mesh::EntityKey(candidateRank, 0),
stk::mesh::EntityLess());
const EntityIterator keepersEnd = allKeepersEnd;
std::vector<stk::mesh::Entity *> candidates;
stk::mesh::get_selected_entities(ownedOrShared, bulkData.buckets(candidateRank), candidates);
{
BulkModification modification(bulkData);
std::set_difference(candidates.begin(), candidates.end(),
keepersBegin.base(), keepersEnd.base(),
EntityDestructor(modification),
stk::mesh::EntityLess());
}
allKeepersEnd = keepersBegin;
}
}
}
示例2: performNodalMeshReduction
void performNodalMeshReduction(
stk::mesh::Part &samplePart,
stk::mesh::BulkData& bulkData)
{
const stk::mesh::MetaData &metaData = stk::mesh::MetaData::get(bulkData);
std::vector<stk::mesh::Entity> sampleNodes;
stk::mesh::get_selected_entities(samplePart, bulkData.buckets(stk::topology::NODE_RANK), sampleNodes);
const stk::mesh::Selector locallyOwned = stk::mesh::MetaData::get(bulkData).locally_owned_part();
std::vector<stk::mesh::Entity> relatedEntities;
typedef std::vector<stk::mesh::Entity>::const_iterator EntityIterator;
for (EntityIterator it(sampleNodes.begin()), it_end(sampleNodes.end()); it != it_end; ++it) {
for (stk::mesh::EntityRank r = stk::topology::NODE_RANK; r < metaData.entity_rank_count(); ++r) {
stk::mesh::Entity const* relations = bulkData.begin(*it, r);
const int num_rels = bulkData.num_connectivity(*it, r);
for (int i = 0; i < num_rels; ++i) {
stk::mesh::Entity relatedEntity = relations[i];
if (bulkData.is_valid(relatedEntity) && locallyOwned(bulkData.bucket(relatedEntity))) {
relatedEntities.push_back(relatedEntity);
}
}
}
}
std::sort(relatedEntities.begin(), relatedEntities.end(), stk::mesh::EntityLess(bulkData));
relatedEntities.erase(
std::unique(relatedEntities.begin(), relatedEntities.end()),
relatedEntities.end());
std::vector<stk::mesh::Entity> sampleClosure;
stk::mesh::find_closure(bulkData, relatedEntities, sampleClosure);
// Keep only the closure, remove the rest, by decreasing entityRanks
{
const stk::mesh::Selector ownedOrShared = metaData.locally_owned_part() | metaData.globally_shared_part();
EntityIterator allKeepersEnd(sampleClosure.end());
const EntityIterator allKeepersBegin(sampleClosure.begin());
for (size_t candidateRankCount = metaData.entity_rank_count(); candidateRankCount > 0; --candidateRankCount) {
const stk::mesh::EntityRank candidateRank = static_cast<stk::mesh::EntityRank>(candidateRankCount - 1);
const EntityIterator keepersBegin = std::lower_bound(allKeepersBegin, allKeepersEnd,
stk::mesh::EntityKey(candidateRank, 0),
stk::mesh::EntityLess(bulkData));
const EntityIterator keepersEnd = allKeepersEnd;
std::vector<stk::mesh::Entity> candidates;
stk::mesh::get_selected_entities(ownedOrShared, bulkData.buckets(candidateRank), candidates);
{
BulkModification modification(bulkData);
std::set_difference(candidates.begin(), candidates.end(),
keepersBegin.base(), keepersEnd.base(),
EntityDestructor(modification),
stk::mesh::EntityLess(bulkData));
}
allKeepersEnd = keepersBegin;
}
}
}
示例3:
void stk::app::use_case_14_initialize_nodal_data(stk::mesh::BulkData & mesh ,
const CartesianField & model_coordinates ,
const CartesianField & coordinates ,
const CartesianField & velocity,
double dt)
{
const std::vector<stk::mesh::Bucket*> & buckets = mesh.buckets( stk::mesh::fem::FEMMetaData::NODE_RANK);
for ( std::vector<stk::mesh::Bucket*>::const_iterator k = buckets.begin() ; k != buckets.end() ; ++k ) {
stk::mesh::Bucket & bucket = **k ;
const unsigned length = bucket.size();
double * X = stk::mesh::field_data( model_coordinates , bucket.begin() );
double * coord = stk::mesh::field_data( coordinates , bucket.begin() );
double * v = stk::mesh::field_data( velocity , bucket.begin() );
for ( unsigned i = 0 ; i < length ; ++i ) {
v[0] = X[0];
v[1] = X[1];
v[2] = X[2];
coord[0] = X[0] + dt * v[0];
coord[1] = X[1] + dt * v[1];
coord[2] = X[2] + dt * v[2];
X += 3;
v += 3;
coord += 3;
}
}
}
示例4: createBoundingBoxesForElementsInElementBlocks
inline void createBoundingBoxesForElementsInElementBlocks(const stk::mesh::BulkData &bulk, FlaotBoxVector& domainBoxes)
{
stk::mesh::EntityVector elements;
stk::mesh::get_selected_entities(bulk.mesh_meta_data().locally_owned_part(), bulk.buckets(stk::topology::ELEM_RANK), elements);
size_t numberBoundingBoxes = elements.size();
domainBoxes.resize(numberBoundingBoxes);
stk::mesh::FieldBase const * coords = bulk.mesh_meta_data().coordinate_field();
std::vector<double> boxCoordinates(6);
for(size_t i=0;i<elements.size();++i)
{
unsigned num_nodes = bulk.num_nodes(elements[i]);
std::vector<double> coordinates(3*num_nodes,0);
const stk::mesh::Entity* nodes = bulk.begin_nodes(elements[i]);
for(unsigned j=0;j<num_nodes;++j)
{
double* data = static_cast<double*>(stk::mesh::field_data(*coords, nodes[j]));
coordinates[3*j] = data[0];
coordinates[3*j+1] = data[1];
coordinates[3*j+2] = data[2];
}
findBoundingBoxCoordinates(coordinates, boxCoordinates);
unsigned id = bulk.identifier(elements[i]);
Ident domainBoxId(id, bulk.parallel_rank());
domainBoxes[i] = std::make_pair(FloatBox(boxCoordinates[0], boxCoordinates[1], boxCoordinates[2],
boxCoordinates[3], boxCoordinates[4], boxCoordinates[5]),
domainBoxId);
}
}
示例5: use_case_5_initialize_data
void use_case_5_initialize_data(
stk::mesh::BulkData & mesh ,
const VectorFieldType & node_coord ,
const VectorFieldType & node_displ ,
const VectorFieldType & node_rotat )
{
const std::vector<stk::mesh::Bucket*> & buckets = mesh.buckets( stk::mesh::fem::FEMMetaData::NODE_RANK );
for ( std::vector<stk::mesh::Bucket*>::const_iterator
k = buckets.begin() ; k != buckets.end() ; ++k ) {
stk::mesh::Bucket & bucket = **k ;
const unsigned length = bucket.size();
const unsigned length_3 = length * 3 ;
double * const coord = stk::mesh::field_data( node_coord , bucket.begin() );
double * const displ = stk::mesh::field_data( node_displ , bucket.begin() );
double * const rotat = stk::mesh::field_data( node_rotat , bucket.begin() );
for ( unsigned i = 0 ; i < length_3 ; ++i ) {
displ[i] = 0.1 * coord[i] ;
}
if ( rotat ) {
for ( unsigned i = 0 ; i < length_3 ; ++i ) {
rotat[i] = 0.01 * coord[i] ;
}
}
}
}
示例6: setup_node_coords
void setup_node_coords(const stk::mesh::BulkData& bulk, const CoordFieldType& coords, const stk::mesh::Selector& selector)
{
const stk::mesh::BucketVector& nodeBuckets = bulk.buckets(stk::topology::NODE_RANK);
bucketCapacity = nodeBuckets[0]->capacity();
unsigned nodeAllocSize = nodeBuckets.size()*bucketCapacity;
nodeCoords = DeviceViewMatrixType("DNodeCoords", nodeAllocSize, bulk.mesh_meta_data().spatial_dimension());
constNodeCoords = nodeCoords;
hostNodeCoords = Kokkos::create_mirror_view(nodeCoords);
for(unsigned bktIndex = 0; bktIndex < nodeBuckets.size(); ++bktIndex)
{
const stk::mesh::Bucket& bucket = *nodeBuckets[bktIndex];
for(unsigned nodeIndex = 0; nodeIndex < bucket.size(); ++nodeIndex)
{
stk::mesh::Entity node = bucket[nodeIndex];
double *node_coords = stk::mesh::field_data(coords, node);
unsigned nodeCoordIndex = host_get_index(node);
for(unsigned k=0; k<bulk.mesh_meta_data().spatial_dimension(); ++k)
{
hostNodeCoords(nodeCoordIndex, k) = node_coords[k];
}
}
}
Kokkos::deep_copy(nodeCoords, hostNodeCoords);
}
示例7: setup_mesh_indices
void setup_mesh_indices(const stk::mesh::BulkData& bulk, const stk::mesh::Selector& selector)
{
const stk::mesh::BucketVector& nodeBuckets = bulk.buckets(stk::topology::NODE_RANK);
meshIndices = DeviceViewMeshIndicesType("DMeshIndices", bulk.get_size_of_entity_index_space());
constMeshIndices = meshIndices;
hostMeshIndices = Kokkos::create_mirror_view(meshIndices);
for(unsigned bktIndex = 0; bktIndex < nodeBuckets.size(); ++bktIndex)
{
const stk::mesh::Bucket& bucket = *nodeBuckets[bktIndex];
for(unsigned nodeIndex = 0; nodeIndex < bucket.size(); ++nodeIndex)
{
stk::mesh::Entity node = bucket[nodeIndex];
stk::mesh::FastMeshIndex meshIndex(bucket.bucket_id(), nodeIndex);
hostMeshIndices(node.local_offset()) = meshIndex;
}
}
const stk::mesh::BucketVector& elemBuckets = bulk.get_buckets(stk::topology::ELEM_RANK, selector);
for(unsigned bktIndex = 0; bktIndex < elemBuckets.size(); ++bktIndex)
{
const stk::mesh::Bucket& bucket = *elemBuckets[bktIndex];
for(unsigned elemIndex = 0; elemIndex < bucket.size(); ++elemIndex)
{
stk::mesh::Entity elem = bucket[elemIndex];
stk::mesh::FastMeshIndex meshIndex(bucket.bucket_id(), elemIndex);
hostMeshIndices(elem.local_offset()) = meshIndex;
}
}
Kokkos::deep_copy(meshIndices, hostMeshIndices);
}
示例8:
stk::parallel::DistributedIndex::KeyTypeVector get_all_local_keys(const stk::mesh::BulkData & bulkData)
{
stk::parallel::DistributedIndex::KeyTypeVector localKeys;
for(stk::mesh::EntityRank rank = stk::topology::NODE_RANK;rank < bulkData.mesh_meta_data().entity_rank_count();++rank)
{
stk::mesh::EntityVector entities;
stk::mesh::get_selected_entities(get_owned_or_shared_selector(bulkData), bulkData.buckets(rank), entities);
for(stk::mesh::Entity entity: entities)
localKeys.push_back(bulkData.entity_key(entity));
}
return localKeys;
}
示例9: bucket_part_memberships_match
bool bucket_part_memberships_match(const stk::mesh::BulkData& bulk, stk::EnvData& env_data)
{
int numGlobalDiffs = bucket_counts_match(bulk, env_data);
if(numGlobalDiffs > 0)
{
for(size_t irank = 0; irank < bulk.mesh_meta_data().entity_rank_count(); ++irank)
{
stk::CommSparse comm(env_data.m_worldComm);
stk::CommBuffer &buff = stk::diff::get_comm_buffer_for_destination_proc(comm);
stk::mesh::EntityRank rank = static_cast<stk::mesh::EntityRank>(irank);
stk::mesh::EntityVector entities;
stk::mesh::get_entities(bulk, rank, entities);
for(int iphase = 0; iphase < 2; ++iphase)
{
for(size_t i=0;i<entities.size();++i)
{
const stk::mesh::PartVector& parts = bulk.bucket(entities[i]).supersets();
std::string part_names_for_entity = create_string_from_parts(parts);
std::string string_to_send;
if(irank != 1 && irank != 2)
{
string_to_send = std::to_string(bulk.identifier(entities[i])) + " " + part_names_for_entity;
}
else
{
string_to_send = part_names_for_entity;
}
stk::diff::pack_string(buff, string_to_send);
}
stk::diff::allocate_or_communicate(iphase, comm);
}
}
}
for(size_t irank = 0; irank < bulk.mesh_meta_data().entity_rank_count(); ++irank)
{
stk::CommSparse comm(env_data.m_worldComm);
stk::mesh::EntityRank rank = static_cast<stk::mesh::EntityRank>(irank);
const stk::mesh::BucketVector& buckets = bulk.buckets(rank);
for(int iphase = 0; iphase < 2; ++iphase)
{
pack_buckets_parts(buckets, stk::diff::get_comm_buffer_for_destination_proc(comm));
stk::diff::allocate_or_communicate(iphase, comm);
}
}
numGlobalDiffs += get_global_bucket_part_membership_differences(env_data.m_worldComm, 0);
return numGlobalDiffs == 0;
}
示例10: createBoundingBoxesForSidesInSidesets
inline void createBoundingBoxesForSidesInSidesets(const stk::mesh::BulkData& bulk, std::vector<FloatBox>& domainBoxes)
{
stk::mesh::ExodusTranslator exoTranslator(bulk);
size_t numberBoundingBoxes = 0;
std::vector<int64_t> sidesetIds;
exoTranslator.fill_side_set_ids(sidesetIds);
for (size_t i=0;i<sidesetIds.size();i++)
{
numberBoundingBoxes += exoTranslator.get_local_num_entities_for_id(sidesetIds[i], bulk.mesh_meta_data().side_rank());
}
domainBoxes.resize(numberBoundingBoxes);
stk::mesh::FieldBase const * coords = bulk.mesh_meta_data().coordinate_field();
size_t boxCounter = 0;
std::vector<double> boxCoordinates(6);
for (size_t ssetCounter=0;ssetCounter<sidesetIds.size();ssetCounter++)
{
const stk::mesh::Part* sideset = exoTranslator.get_exodus_part_of_rank(sidesetIds[ssetCounter], bulk.mesh_meta_data().side_rank());
stk::mesh::EntityVector sides;
stk::mesh::Selector sel = bulk.mesh_meta_data().locally_owned_part() & *sideset;
stk::mesh::get_selected_entities(sel, bulk.buckets(bulk.mesh_meta_data().side_rank()), sides);
for(size_t j=0;j<sides.size();++j)
{
unsigned num_nodes_per_side = bulk.num_nodes(sides[j]);
const stk::mesh::Entity* nodes = bulk.begin_nodes(sides[j]);
std::vector<double> coordinates(3*num_nodes_per_side,0);
for(unsigned k=0;k<num_nodes_per_side;++k)
{
double *data = static_cast<double*>(stk::mesh::field_data(*coords, nodes[k]));
coordinates[3*k] = data[0];
coordinates[3*k+1] = data[1];
coordinates[3*k+2] = data[2];
}
findBoundingBoxCoordinates(coordinates, boxCoordinates);
domainBoxes[boxCounter].set_box(boxCoordinates[0], boxCoordinates[1], boxCoordinates[2],
boxCoordinates[3], boxCoordinates[4], boxCoordinates[5]);
boxCounter++;
}
}
ThrowRequireMsg(boxCounter == numberBoundingBoxes, "Program error. Please contact sierra-help for support");
}
示例11: bucket_counts_match
int bucket_counts_match(const stk::mesh::BulkData& bulk, stk::EnvData& env_data)
{
stk::CommSparse comm(env_data.m_worldComm);
int destinationProc = getDestinationProc(env_data.m_worldComm);
stk::CommBuffer& buf = comm.send_buffer(destinationProc);
for(int iphase = 0; iphase < 2; ++iphase)
{
for(size_t irank = 0; irank < bulk.mesh_meta_data().entity_rank_count(); ++irank)
{
stk::mesh::EntityRank rank = static_cast<stk::mesh::EntityRank>(irank);
const stk::mesh::BucketVector& buckets = bulk.buckets(rank);
buf.pack<size_t>(buckets.size());
}
allocate_or_communicate(iphase, comm);
}
int num_diffs = 0;
return get_global_bucket_count_differences(env_data.m_worldComm, num_diffs);
}
示例12: testGoldValues
void testGoldValues(stk::mesh::MetaData &stkMeshMetaData, stk::mesh::BulkData &stkMeshBulkData, double alpha, double beta, double gamma)
{
double goldX = initial_value1[0] * (alpha + beta + gamma);
double goldY = initial_value1[1] * (alpha + beta + gamma);
double goldZ = initial_value1[2] * (alpha + beta + gamma);
stk::mesh::Field<double, stk::mesh::Cartesian3d> &force_field = *stkMeshMetaData.get_field<stk::mesh::Field<double, stk::mesh::Cartesian3d> >(stk::topology::NODE_RANK, "force");
double tol = 1.0e-4;
const stk::mesh::BucketVector& buckets = stkMeshBulkData.buckets(stk::topology::NODE_RANK);
for(size_t bucketIndex = 0; bucketIndex < buckets.size(); ++bucketIndex)
{
const stk::mesh::Bucket &bucket = *buckets[bucketIndex];
double *force = stk::mesh::field_data(force_field, bucket);
for(size_t nodeIndex = 0; nodeIndex < 3 * bucket.size(); nodeIndex += 3)
{
EXPECT_NEAR(goldX, force[nodeIndex+0], tol);
EXPECT_NEAR(goldY, force[nodeIndex+1], tol);
EXPECT_NEAR(goldZ, force[nodeIndex+2], tol);
}
}
}
示例13: get_entities
inline
size_t get_entities(stk::mesh::Part &part,
stk::mesh::EntityRank type,
const stk::mesh::BulkData &bulk,
stk::mesh::EntityVector &entities,
bool include_shared,
const stk::mesh::Selector *subset_selector)
{
stk::mesh::MetaData & meta = stk::mesh::MetaData::get(part);
stk::mesh::Selector own_share = meta.locally_owned_part();
if(include_shared)
own_share |= meta.globally_shared_part();
stk::mesh::Selector selector = part & own_share;
if(subset_selector)
selector &= *subset_selector;
get_selected_entities(selector, bulk.buckets(type), entities);
return entities.size();
}
示例14: nodeKeys
stk::mesh::EntityVector fill_shared_entities_that_need_fixing(const stk::mesh::BulkData& bulkData)
{
stk::mesh::EntityVector sides;
stk::mesh::get_selected_entities(bulkData.mesh_meta_data().locally_owned_part(), bulkData.buckets(bulkData.mesh_meta_data().side_rank()), sides);
stk::mesh::EntityVector sidesThatNeedFixing;
for(stk::mesh::Entity side : sides)
if(bulkData.state(side) == stk::mesh::Created)
{
unsigned num_nodes = bulkData.num_nodes(side);
const stk::mesh::Entity* nodes = bulkData.begin_nodes(side);
std::vector<stk::mesh::EntityKey> nodeKeys(num_nodes);
for(unsigned int i=0;i<num_nodes;++i)
nodeKeys[i] = bulkData.entity_key(nodes[i]);
std::vector<int> shared_procs;
bulkData.shared_procs_intersection(nodeKeys, shared_procs);
if(!shared_procs.empty())
sidesThatNeedFixing.push_back(side);
}
return sidesThatNeedFixing;
}
示例15: find_ghosted_nodes_that_need_to_be_shared
void find_ghosted_nodes_that_need_to_be_shared(const stk::mesh::BulkData & bulk, stk::mesh::EntityVector& ghosted_nodes_that_are_now_shared)
{
stk::mesh::EntityRank endRank = static_cast<stk::mesh::EntityRank>(bulk.mesh_meta_data().entity_rank_count());
if (endRank >= stk::topology::END_RANK)
{
endRank = stk::topology::END_RANK;
}
for (stk::mesh::EntityRank rank=stk::topology::EDGE_RANK; rank<endRank; ++rank)
{
const stk::mesh::BucketVector& entity_buckets = bulk.buckets(rank);
for(size_t i=0; i<entity_buckets.size(); ++i)
{
const stk::mesh::Bucket& bucket = *entity_buckets[i];
if ( bucket.owned() )
{
for(size_t n=0; n<bucket.size(); ++n)
{
const stk::mesh::Entity * nodes = bulk.begin_nodes(bucket[n]);
unsigned num_nodes = bulk.num_nodes(bucket[n]);
for (unsigned j=0;j<num_nodes;++j)
{
if (bulk.in_receive_ghost(bulk.entity_key(nodes[j])))
{
ghosted_nodes_that_are_now_shared.push_back(nodes[j]);
}
}
}
}
}
}
std::sort(ghosted_nodes_that_are_now_shared.begin(), ghosted_nodes_that_are_now_shared.end());
stk::mesh::EntityVector::iterator iter = std::unique(ghosted_nodes_that_are_now_shared.begin(), ghosted_nodes_that_are_now_shared.end());
ghosted_nodes_that_are_now_shared.erase(iter, ghosted_nodes_that_are_now_shared.end());
}