本文整理汇总了C++中stk::mesh::BulkData::get_entity方法的典型用法代码示例。如果您正苦于以下问题:C++ BulkData::get_entity方法的具体用法?C++ BulkData::get_entity怎么用?C++ BulkData::get_entity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stk::mesh::BulkData
的用法示例。
在下文中一共展示了BulkData::get_entity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupKeyholeMesh2D_case2
inline
void setupKeyholeMesh2D_case2(stk::mesh::BulkData& bulk)
{
//
// proc 0 proc 1
// |
// | block_2 block_3
// |
// block_1 | 12---11
// | | 4 |
// 4----3 | 3----6 6----10
// | 1 | | | 2 |
// 1----2 | 2----5 5----9
// | | 3 |
// | 7----8
// |
//
//nodes 5 and 6 are ghosts (aura) on proc 0,
//and should be members of block_2 and block_3 on proc 0
//if edges are added, the edge between nodes 5 and 6 should
//be a member of block_2 not block_3.
//
stk::mesh::MetaData& meta = bulk.mesh_meta_data();
stk::mesh::Part& block_1 = meta.declare_part_with_topology("block_1", stk::topology::QUAD_4_2D);
stk::mesh::Part& block_2 = meta.declare_part_with_topology("block_2", stk::topology::QUAD_4_2D);
stk::mesh::Part& block_3 = meta.declare_part_with_topology("block_3", stk::topology::QUAD_4_2D);
meta.commit();
bulk.modification_begin();
stk::mesh::EntityIdVector elem1_nodes {1, 2, 3, 4};
stk::mesh::EntityIdVector elem2_nodes {2, 5, 6, 3};
stk::mesh::EntityIdVector elem3_nodes {7, 8, 9, 5};
stk::mesh::EntityIdVector elem4_nodes {6, 10, 11, 12};
stk::mesh::EntityId elemId = 1;
if (bulk.parallel_rank() == 0) {
stk::mesh::declare_element(bulk, block_1, elemId, elem1_nodes);
stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, 2);
stk::mesh::Entity node3 = bulk.get_entity(stk::topology::NODE_RANK, 3);
bulk.add_node_sharing(node2, 1);
bulk.add_node_sharing(node3, 1);
}
else if (bulk.parallel_rank() == 1) {
elemId = 2;
stk::mesh::declare_element(bulk, block_2, elemId, elem2_nodes);
elemId = 3;
stk::mesh::declare_element(bulk, block_3, elemId, elem3_nodes);
elemId = 4;
stk::mesh::declare_element(bulk, block_3, elemId, elem4_nodes);
stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, 2);
stk::mesh::Entity node3 = bulk.get_entity(stk::topology::NODE_RANK, 3);
bulk.add_node_sharing(node2, 0);
bulk.add_node_sharing(node3, 0);
}
bulk.modification_end();
}
示例2: process_surface_entity
// ========================================================================
void process_surface_entity(const Ioss::SideSet* sset ,
stk::mesh::BulkData & bulk)
{
assert(sset->type() == Ioss::SIDESET);
const stk::mesh::MetaData& meta = stk::mesh::MetaData::get(bulk);
const stk::mesh::EntityRank element_rank = stk::topology::ELEMENT_RANK;
int block_count = sset->block_count();
for (int i=0; i < block_count; i++) {
Ioss::SideBlock *block = sset->get_block(i);
if (stk::io::include_entity(block)) {
std::vector<int> side_ids ;
std::vector<int> elem_side ;
stk::mesh::Part * const side_block_part = meta.get_part(block->name());
stk::mesh::EntityRank side_rank = side_block_part->primary_entity_rank();
block->get_field_data("ids", side_ids);
block->get_field_data("element_side", elem_side);
assert(side_ids.size() * 2 == elem_side.size());
stk::mesh::PartVector add_parts( 1 , side_block_part );
size_t side_count = side_ids.size();
std::vector<stk::mesh::Entity> sides(side_count);
for(size_t is=0; is<side_count; ++is) {
stk::mesh::Entity const elem = bulk.get_entity(element_rank, elem_side[is*2]);
// If NULL, then the element was probably assigned to an
// element block that appears in the database, but was
// subsetted out of the analysis mesh. Only process if
// non-null.
if (bulk.is_valid(elem)) {
// Ioss uses 1-based side ordinal, stk::mesh uses 0-based.
// Hence the '-1' in the following line.
int side_ordinal = elem_side[is*2+1] - 1 ;
stk::mesh::Entity side = stk::mesh::Entity();
if (side_rank == 2) {
side = stk::mesh::declare_element_side(bulk, side_ids[is], elem, side_ordinal);
} else {
side = stk::mesh::declare_element_edge(bulk, side_ids[is], elem, side_ordinal);
}
bulk.change_entity_parts( side, add_parts );
sides[is] = side;
} else {
sides[is] = stk::mesh::Entity();
}
}
const stk::mesh::FieldBase *df_field = stk::io::get_distribution_factor_field(*side_block_part);
if (df_field != NULL) {
stk::io::field_data_from_ioss(bulk, df_field, sides, block, "distribution_factors");
}
}
}
}
示例3: if
inline stk::mesh::Entity get_face_between_element_ids(stk::mesh::ElemElemGraph& graph, stk::mesh::BulkData& bulkData, stk::mesh::EntityId elem1Id, stk::mesh::EntityId elem2Id)
{
stk::mesh::Entity elem1 = bulkData.get_entity(stk::topology::ELEM_RANK, elem1Id);
stk::mesh::Entity elem2 = bulkData.get_entity(stk::topology::ELEM_RANK, elem2Id);
bool isElem1LocallyOwnedAndValid = bulkData.is_valid(elem1) && bulkData.bucket(elem1).owned();
bool isElem2LocallyOwnedAndValid = bulkData.is_valid(elem2) && bulkData.bucket(elem2).owned();
stk::mesh::Entity face_between_elem1_and_elem2;
if(isElem1LocallyOwnedAndValid && isElem2LocallyOwnedAndValid)
{
int side = graph.get_side_from_element1_to_locally_owned_element2(elem1, elem2);
EXPECT_TRUE(side != -1);
face_between_elem1_and_elem2 = stk::mesh::impl::get_side_for_element(bulkData, elem1, side);
}
else if(isElem1LocallyOwnedAndValid)
{
int side = graph.get_side_from_element1_to_remote_element2(elem1, elem2Id);
EXPECT_TRUE(side != -1);
face_between_elem1_and_elem2 = stk::mesh::impl::get_side_for_element(bulkData, elem1, side);
}
else if(isElem2LocallyOwnedAndValid)
{
int side = graph.get_side_from_element1_to_remote_element2(elem2, elem1Id);
EXPECT_TRUE(side != -1);
face_between_elem1_and_elem2 = stk::mesh::impl::get_side_for_element(bulkData, elem2, side);
}
return face_between_elem1_and_elem2;
}
示例4: convert_elem_sides_pairs_into_sideset
void convert_elem_sides_pairs_into_sideset(const stk::mesh::BulkData& bulk, const std::vector<int>& elem_side, stk::mesh::SideSet& sideset)
{
for(size_t is=0; is<elem_side.size() / 2; ++is)
{
stk::mesh::Entity const elem = bulk.get_entity(stk::topology::ELEMENT_RANK, elem_side[is*2]);
if (bulk.is_valid(elem))
sideset.push_back(add_elem_side_pair(elem, elem_side[is*2+1]));
}
}
示例5: test_num_faces_on_this_element
inline void test_num_faces_on_this_element(const stk::mesh::BulkData& bulkData, stk::mesh::EntityId id, size_t gold_num_faces_this_elem)
{
stk::mesh::Entity element = bulkData.get_entity(stk::topology::ELEM_RANK, id);
if(bulkData.is_valid(element))
{
unsigned num_faces_this_elem = bulkData.num_faces(element);
EXPECT_EQ(gold_num_faces_this_elem, num_faces_this_elem);
}
}
示例6: heterogeneous_mesh_bulk_data
void heterogeneous_mesh_bulk_data(
stk::mesh::BulkData & bulk_data ,
const VectorFieldType & node_coord )
{
static const char method[] =
"stk_mesh::fixtures::heterogenous_mesh_bulk_data" ;
bulk_data.modification_begin();
const stk::mesh::MetaData & meta_data = stk::mesh::MetaData::get(bulk_data);
stk::mesh::Part & hex_block = * meta_data.get_part("hexes",method);
stk::mesh::Part & wedge_block = * meta_data.get_part("wedges",method);
stk::mesh::Part & tetra_block = * meta_data.get_part("tets",method);
stk::mesh::Part & pyramid_block = * meta_data.get_part("pyramids",method);
stk::mesh::Part & quad_shell_block = * meta_data.get_part("quad_shells",method);
stk::mesh::Part & tri_shell_block = * meta_data.get_part("tri_shells",method);
unsigned elem_id = 1 ;
for ( unsigned i = 0 ; i < number_hex ; ++i , ++elem_id ) {
stk::mesh::declare_element( bulk_data, hex_block, elem_id, hex_node_ids[i] );
}
for ( unsigned i = 0 ; i < number_wedge ; ++i , ++elem_id ) {
stk::mesh::declare_element( bulk_data, wedge_block, elem_id, wedge_node_ids[i] );
}
for ( unsigned i = 0 ; i < number_tetra ; ++i , ++elem_id ) {
stk::mesh::declare_element( bulk_data, tetra_block, elem_id, tetra_node_ids[i] );
}
for ( unsigned i = 0 ; i < number_pyramid ; ++i , ++elem_id ) {
stk::mesh::declare_element( bulk_data, pyramid_block, elem_id, pyramid_node_ids[i] );
}
for ( unsigned i = 0 ; i < number_shell_quad ; ++i , ++elem_id ) {
stk::mesh::declare_element( bulk_data, quad_shell_block, elem_id, shell_quad_node_ids[i]);
}
for ( unsigned i = 0 ; i < number_shell_tri ; ++i , ++elem_id ) {
stk::mesh::declare_element( bulk_data, tri_shell_block, elem_id, shell_tri_node_ids[i] );
}
for ( unsigned i = 0 ; i < node_count ; ++i ) {
stk::mesh::Entity const node = bulk_data.get_entity( stk::topology::NODE_RANK , i + 1 );
double * const coord = stk::mesh::field_data( node_coord , node );
coord[0] = node_coord_data[i][0] ;
coord[1] = node_coord_data[i][1] ;
coord[2] = node_coord_data[i][2] ;
}
bulk_data.modification_end();
}
示例7: setupKeyholeMesh3D_case2
inline
void setupKeyholeMesh3D_case2(stk::mesh::BulkData& bulk)
{
ThrowRequire(bulk.parallel_size() == 3);
stk::io::fill_mesh("generated:3x1x3", bulk);
stk::mesh::EntityProcVec elementProcChanges;
if (bulk.parallel_rank() == 1) {
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,4),2));
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,6),2));
}
bulk.change_entity_owner(elementProcChanges);
bulk.modification_begin();
if (bulk.parallel_rank() == 1) {
stk::mesh::Entity local_element5 = bulk.get_entity(stk::topology::ELEM_RANK,5);
const bool delete_success = bulk.destroy_entity(local_element5);
ThrowRequire(delete_success);
}
bulk.modification_end();
}
示例8: get_non_unique_key_messages
std::string get_non_unique_key_messages(const stk::mesh::BulkData& bulkData, const std::vector<stk::mesh::EntityKeyProc> &badKeyProcs)
{
std::ostringstream os;
for(const stk::mesh::EntityKeyProc& keyProc : badKeyProcs)
{
stk::mesh::Entity entity = bulkData.get_entity(keyProc.first);
os << "[" << bulkData.parallel_rank() << "] Key " << keyProc.first <<
get_topology(bulkData.bucket(entity).topology()) << "is also present (inappropriately) on processor " <<
keyProc.second << "." << std::endl;
}
return os.str();
}
示例9: setupKeyholeMesh3D_case1
// element ids / proc_id:
// |-------|-------|-------|
// | | | |
// | 1/0 | 4/2 | 7/2 |
// | | | |
// |-------|-------|-------|
// | | | |
// | 2/0 | 5/1 | 8/2 |
// | | | |
// |-------|-------|-------|
// | | | |
// | 3/0 | 6/2 | 9/2 |
// | | | |
// |-------|-------|-------|
inline
void setupKeyholeMesh3D_case1(stk::mesh::BulkData& bulk)
{
ThrowRequire(bulk.parallel_size() == 3);
stk::io::fill_mesh("generated:3x1x3", bulk);
stk::mesh::EntityProcVec elementProcChanges;
if (bulk.parallel_rank() == 1) {
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,4u),2));
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,6u),2));
}
bulk.change_entity_owner(elementProcChanges);
}
示例10: ThrowRequireWithSierraHelpMsg
stk::mesh::GraphEdge unpack_edge(stk::CommSparse& comm, const stk::mesh::BulkData& bulkData, const ElemElemGraph& graph, int proc_id)
{
stk::mesh::EntityId id1 = 0, id2 = 0;
unsigned side1 = 0, side2 = 0;
comm.recv_buffer(proc_id).unpack<stk::mesh::EntityId>(id1);
comm.recv_buffer(proc_id).unpack<unsigned>(side1);
comm.recv_buffer(proc_id).unpack<stk::mesh::EntityId>(id2);
comm.recv_buffer(proc_id).unpack<unsigned>(side2);
stk::mesh::Entity element = bulkData.get_entity(stk::topology::ELEM_RANK, id2);
ThrowRequireWithSierraHelpMsg(bulkData.is_valid(element));
stk::mesh::impl::LocalId localId2 = graph.get_local_element_id(element);
stk::mesh::GraphEdge edge(localId2, side2, -id1, side1);
return edge;
}
示例11: addNodesToPart
void addNodesToPart(
const Teuchos::ArrayView<const stk::mesh::EntityId> &nodeIds,
stk::mesh::Part &samplePart,
stk::mesh::BulkData& bulkData)
{
const stk::mesh::PartVector samplePartVec(1, &samplePart);
const stk::mesh::Selector locallyOwned = stk::mesh::MetaData::get(bulkData).locally_owned_part();
BulkModification mod(bulkData);
typedef Teuchos::ArrayView<const stk::mesh::EntityId>::const_iterator Iter;
for (Iter it = nodeIds.begin(), it_end = nodeIds.end(); it != it_end; ++it) {
stk::mesh::Entity node = bulkData.get_entity(stk::topology::NODE_RANK, *it);
if (bulkData.is_valid(node) && locallyOwned(bulkData.bucket(node))) {
bulkData.change_entity_parts(node, samplePartVec);
}
}
}
示例12: addNodesToPart
void addNodesToPart(
const Teuchos::ArrayView<const stk::mesh::EntityId> &nodeIds,
stk::mesh::Part &samplePart,
stk::mesh::BulkData& bulkData)
{
const stk::mesh::EntityRank nodeEntityRank(0);
const stk::mesh::PartVector samplePartVec(1, &samplePart);
const stk::mesh::Selector locallyOwned = stk::mesh::MetaData::get(bulkData).locally_owned_part();
BulkModification mod(bulkData);
typedef Teuchos::ArrayView<const stk::mesh::EntityId>::const_iterator Iter;
for (Iter it = nodeIds.begin(), it_end = nodeIds.end(); it != it_end; ++it) {
const Teuchos::Ptr<stk::mesh::Entity> node(bulkData.get_entity(nodeEntityRank, *it));
if (Teuchos::nonnull(node) && locallyOwned(*node)) {
bulkData.change_entity_parts(*node, samplePartVec);
}
}
}
示例13: get_message_for_split_coincident_elements
std::string get_message_for_split_coincident_elements(const stk::mesh::BulkData& bulkData, const std::map<stk::mesh::EntityId, std::pair<stk::mesh::EntityId, int> > & splitCoincidentElements)
{
std::ostringstream out;
for(const auto& item : splitCoincidentElements) {
stk::mesh::Entity element = bulkData.get_entity(stk::topology::ELEM_RANK,item.first);
const stk::mesh::PartVector& elementParts = bulkData.bucket(element).supersets();
std::string blockNames;
blockNames = "{";
for (const stk::mesh::Part* part : elementParts) {
if (stk::mesh::impl::is_element_block(*part)) {
blockNames += " " + part->name();
}
}
blockNames += " }";
out << "[" << bulkData.parallel_rank() << "] Element " << item.first << " (" << bulkData.bucket(element).topology() << ") in blocks " << blockNames << " is coincident with element " << item.second.first << " on processor " << item.second.second << std::endl;
}
return out.str();
}
示例14: process_nodesets
// ========================================================================
void process_nodesets(Ioss::Region ®ion, stk::mesh::BulkData &bulk)
{
// Should only process nodes that have already been defined via the element
// blocks connectivity lists.
const Ioss::NodeSetContainer& node_sets = region.get_nodesets();
for(Ioss::NodeSetContainer::const_iterator it = node_sets.begin();
it != node_sets.end(); ++it) {
Ioss::NodeSet *entity = *it;
if (stk::io::include_entity(entity)) {
const std::string & name = entity->name();
const stk::mesh::MetaData& meta = stk::mesh::MetaData::get(bulk);
stk::mesh::Part* const part = meta.get_part(name);
STKIORequire(part != NULL);
stk::mesh::PartVector add_parts( 1 , part );
std::vector<int> node_ids ;
int node_count = entity->get_field_data("ids", node_ids);
std::vector<stk::mesh::Entity> nodes(node_count);
for(int i=0; i<node_count; ++i) {
nodes[i] = bulk.get_entity( stk::topology::NODE_RANK, node_ids[i] );
if (bulk.is_valid(nodes[i])) {
bulk.declare_entity(stk::topology::NODE_RANK, node_ids[i], add_parts );
}
}
/** \todo REFACTOR Application would probably store this field
* (and others) somewhere after the declaration instead of
* looking it up each time it is needed.
*/
stk::mesh::Field<double> *df_field =
meta.get_field<stk::mesh::Field<double> >(stk::topology::NODE_RANK, "distribution_factors");
if (df_field != NULL) {
stk::io::field_data_from_ioss(bulk, df_field, nodes, entity, "distribution_factors");
}
}
}
}
示例15: setupKeyholeMesh2D_case1
inline
void setupKeyholeMesh2D_case1(stk::mesh::BulkData& bulk)
{
//
// proc 0 proc 1
// |
// | block_2 block_3
// |
// block_1 | 10---9 9----12
// | | 3 | | 4 |
// 4----3 | 3----8 8----11
// | 1 | |
// 1----2 | 2----7
// | | 2 |
// | 5----6
// |
//
//shared nodes 2 and 3 should be members of block_1 and block_2 on both procs
//nodes 8 and 9 are ghosts on proc 0, and should be members of block_2 and block_3
//
//if edges are added, the edge between nodes 2 and 3 should be a member of block_1 not block_2.
//
//also, the edge between nodes 8 and 9 should be a member of block_2 and block_3 on both procs.
stk::mesh::MetaData& meta = bulk.mesh_meta_data();
stk::mesh::Part& block_1 = meta.declare_part_with_topology("block_1", stk::topology::QUAD_4_2D);
stk::mesh::Part& block_2 = meta.declare_part_with_topology("block_2", stk::topology::QUAD_4_2D);
stk::mesh::Part& block_3 = meta.declare_part_with_topology("block_3", stk::topology::QUAD_4_2D);
meta.commit();
bulk.modification_begin();
stk::mesh::EntityIdVector elem1_nodes {1, 2, 3, 4};
stk::mesh::EntityIdVector elem2_nodes {5, 6, 7, 2};
stk::mesh::EntityIdVector elem3_nodes {3, 8, 9, 10};
stk::mesh::EntityIdVector elem4_nodes {8, 11, 12, 9};
stk::mesh::EntityId elemId = 1;
if (bulk.parallel_rank() == 0) {
stk::mesh::declare_element(bulk, block_1, elemId, elem1_nodes);
stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, 2);
stk::mesh::Entity node3 = bulk.get_entity(stk::topology::NODE_RANK, 3);
bulk.add_node_sharing(node2, 1);
bulk.add_node_sharing(node3, 1);
}
else if (bulk.parallel_rank() == 1) {
elemId = 2;
stk::mesh::declare_element(bulk, block_2, elemId, elem2_nodes);
elemId = 3;
stk::mesh::declare_element(bulk, block_2, elemId, elem3_nodes);
elemId = 4;
stk::mesh::declare_element(bulk, block_3, elemId, elem4_nodes);
stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, 2);
stk::mesh::Entity node3 = bulk.get_entity(stk::topology::NODE_RANK, 3);
bulk.add_node_sharing(node2, 0);
bulk.add_node_sharing(node3, 0);
}
bulk.modification_end();
}