// ======================================================================== 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"); } } } }
inline void deactivate_elements(const stk::mesh::EntityVector &deactivated_elems, stk::mesh::BulkData &bulkData, stk::mesh::Part& active) { bulkData.modification_begin(); for(size_t i = 0; i < deactivated_elems.size(); ++i) { bulkData.change_entity_parts(deactivated_elems[i], stk::mesh::PartVector(), stk::mesh::PartVector(1, &active)); } bulkData.modification_end(); }
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); } } }
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); } } }