// ========================================================================
void process_surface_entity(Ioss::SideSet *sset, stk::mesh::MetaData &meta,
                            stk::mesh::EntityRank sset_rank)
{
    assert(sset->type() == Ioss::SIDESET);
    Ioss::SideSet *fs = dynamic_cast<Ioss::SideSet *>(sset);
    assert(fs != NULL);
    const Ioss::SideBlockContainer& blocks = fs->get_side_blocks();
    stk::io::default_part_processing(blocks, meta, sset_rank);

    stk::mesh::Part* const fs_part = meta.get_part(sset->name());
    STKIORequire(fs_part != NULL);

    stk::mesh::Field<double, stk::mesh::ElementNode> *distribution_factors_field = NULL;
    bool surface_df_defined = false; // Has the surface df field been defined yet?


    int block_count = sset->block_count();
    for (int i=0; i < block_count; i++) {
        Ioss::SideBlock *side_block = sset->get_block(i);
        if (stk::io::include_entity(side_block)) {
            stk::mesh::Part * const side_block_part = meta.get_part(side_block->name());
            STKIORequire(side_block_part != NULL);
            meta.declare_part_subset(*fs_part, *side_block_part);

            const stk::mesh::EntityRank part_rank = side_block_part->primary_entity_rank();

            if (side_block->field_exists("distribution_factors")) {
                if (!surface_df_defined) {
                    std::string field_name = sset->name() + "_distribution_factors";
                    distribution_factors_field =
                        &meta.declare_field<stk::mesh::Field<double, stk::mesh::ElementNode> >(static_cast<stk::topology::rank_t>(part_rank), field_name);
                    stk::io::set_distribution_factor_field(*fs_part, *distribution_factors_field);
                    surface_df_defined = true;
                }
                stk::io::set_distribution_factor_field(*side_block_part, *distribution_factors_field);
                int side_node_count = side_block->topology()->number_nodes();
                stk::mesh::put_field(*distribution_factors_field,
                                     *side_block_part, side_node_count);
            }

            /** \todo IMPLEMENT truly handle fields... For this case we
             * are just defining a field for each transient field that is
             * present in the mesh...
             */
            stk::io::define_io_fields(side_block, Ioss::Field::TRANSIENT,
                                      *side_block_part,
                                      part_rank);
        }
    }
}
Esempio n. 2
0
void copy_part_supersets(const stk::mesh::Part &oldPart, stk::mesh::Part &newPart, stk::mesh::MetaData &newMeta)
{
    stk::mesh::OrdinalVector oldSupersets = get_part_supersets(oldPart);
    for(stk::mesh::PartOrdinal partOrd : oldSupersets)
        newMeta.declare_part_subset(newMeta.get_part(partOrd), newPart);
}