// ========================================================================
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");
            }
        }
    }
}
示例#2
0
SideSet::SideSet(const Ioss::SideBlock &other)
{
  id                  = other.get_property("id").get_int();
  sideCount           = other.get_property("entity_count").get_int();
  dfCount             = other.get_property("distribution_factor_count").get_int();
  std::string io_name = other.name();
  std::strncpy(name, io_name.c_str(), MAX_STR_LENGTH);
  name[MAX_STR_LENGTH] = 0;
}