// ======================================================================== // Bulk Data // ======================================================================== void process_nodeblocks(Ioss::Region ®ion, stk::mesh::BulkData &bulk) { // This must be called after the "process_element_blocks" call // since there may be nodes that exist in the database that are // not part of the analysis mesh due to subsetting of the element // blocks. const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); assert(node_blocks.size() == 1); Ioss::NodeBlock *nb = node_blocks[0]; std::vector<stk::mesh::Entity> nodes; stk::io::get_entity_list(nb, stk::topology::NODE_RANK, bulk, nodes); /** \todo REFACTOR Application would probably store this field * (and others) somewhere after the declaration instead of * looking it up each time it is needed. */ const stk::mesh::MetaData& meta = stk::mesh::MetaData::get(bulk); stk::mesh::Field<double,stk::mesh::Cartesian> *coord_field = meta.get_field<stk::mesh::Field<double,stk::mesh::Cartesian> >(stk::topology::NODE_RANK, "coordinates"); stk::io::field_data_from_ioss(bulk, coord_field, nodes, nb, "mesh_model_coordinates"); }
void process_input_request(Ioss::Region ®ion, stk::mesh::BulkData &bulk, int step) { region.begin_state(step); // Special processing for nodeblock (all nodes in model)... const stk::mesh::MetaData& meta = stk::mesh::MetaData::get(bulk); // ??? Get field data from nodeblock... get_field_data(bulk, meta.universal_part(), stk::topology::NODE_RANK, region.get_node_blocks()[0], Ioss::Field::TRANSIENT); const stk::mesh::PartVector & all_parts = meta.get_parts(); for ( stk::mesh::PartVector::const_iterator ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { stk::mesh::Part * const part = *ip; const stk::mesh::EntityRank part_rank = part->primary_entity_rank(); // Check whether this part should be output to results database. if (stk::io::is_part_io_part(*part)) { // Get Ioss::GroupingEntity corresponding to this part... Ioss::GroupingEntity *entity = region.get_entity(part->name()); if (entity != NULL) { if (entity->type() == Ioss::SIDESET) { Ioss::SideSet *sset = dynamic_cast<Ioss::SideSet*>(entity); assert(sset != NULL); int block_count = sset->block_count(); for (int i=0; i < block_count; i++) { Ioss::SideBlock *side_block = sset->get_block(i); /// \todo REFACTOR Need filtering mechanism. get_field_data(bulk, *part, part_rank, side_block, Ioss::Field::TRANSIENT); } } else { get_field_data(bulk, *part, part_rank, entity, Ioss::Field::TRANSIENT); } } else { /// \todo IMPLEMENT handle error... Possibly an assert since /// I think the corresponding entity should always exist... } } } region.end_state(step); }
// ======================================================================== void process_nodeblocks(Ioss::Region ®ion, stk::mesh::MetaData &meta) { const Ioss::NodeBlockContainer& node_blocks = region.get_node_blocks(); assert(node_blocks.size() == 1); Ioss::NodeBlock *nb = node_blocks[0]; assert(nb->field_exists("mesh_model_coordinates")); Ioss::Field coordinates = nb->get_field("mesh_model_coordinates"); int spatial_dim = coordinates.transformed_storage()->component_count(); stk::mesh::Field<double,stk::mesh::Cartesian> & coord_field = meta.declare_field<stk::mesh::Field<double,stk::mesh::Cartesian> >(stk::topology::NODE_RANK, "coordinates"); stk::mesh::put_field( coord_field, meta.universal_part(), spatial_dim); /** \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(nb, Ioss::Field::TRANSIENT, meta.universal_part(),stk::topology::NODE_RANK); }