void HexFixture::generate_mesh(std::vector<EntityId> & element_ids_on_this_processor, const CoordinateMapping & coordMap) { { //sort and unique the input elements std::vector<EntityId>::iterator ib = element_ids_on_this_processor.begin(); std::vector<EntityId>::iterator ie = element_ids_on_this_processor.end(); std::sort( ib, ie); ib = std::unique( ib, ie); element_ids_on_this_processor.erase(ib, ie); } m_bulk_data.modification_begin(); { // Declare the elements that belong on this process std::vector<EntityId>::iterator ib = element_ids_on_this_processor.begin(); const std::vector<EntityId>::iterator ie = element_ids_on_this_processor.end(); stk::mesh::EntityIdVector elem_nodes(8); for (; ib != ie; ++ib) { EntityId entity_id = *ib; size_t ix = 0, iy = 0, iz = 0; elem_x_y_z(entity_id, ix, iy, iz); elem_nodes[0] = node_id( ix , iy , iz ); elem_nodes[1] = node_id( ix+1 , iy , iz ); elem_nodes[2] = node_id( ix+1 , iy+1 , iz ); elem_nodes[3] = node_id( ix , iy+1 , iz ); elem_nodes[4] = node_id( ix , iy , iz+1 ); elem_nodes[5] = node_id( ix+1 , iy , iz+1 ); elem_nodes[6] = node_id( ix+1 , iy+1 , iz+1 ); elem_nodes[7] = node_id( ix , iy+1 , iz+1 ); stk::mesh::declare_element( m_bulk_data, m_elem_parts, elem_id( ix , iy , iz ) , elem_nodes); for (size_t i = 0; i<8; ++i) { EntityId node_id = elem_nodes[i]; stk::mesh::Entity const node = m_bulk_data.get_entity( stk::topology::NODE_RANK , node_id ); m_bulk_data.change_entity_parts(node, m_node_parts); DoAddNodeSharings(m_bulk_data, m_nodes_to_procs, node_id, node); ThrowRequireMsg( m_bulk_data.is_valid(node), "This process should know about the nodes that make up its element"); // Compute and assign coordinates to the node size_t nx = 0, ny = 0, nz = 0; node_x_y_z(elem_nodes[i], nx, ny, nz); Scalar * data = stk::mesh::field_data( m_coord_field , node ); coordMap.getNodeCoordinates(data, nx, ny, nz); } } } m_bulk_data.modification_end(); }
/** * Thinking in terms of a 3D grid of elements, get the elements in the * (x, y, z) position. Return NULL if this process doesn't know about this * element. */ Entity elem( size_t x , size_t y , size_t z ) const { return m_bulk_data.get_entity( stk::topology::ELEMENT_RANK, elem_id(x, y, z) ); }
Entity * elem( unsigned ix , unsigned iy , unsigned iz ) const { return bulk_data.get_entity( top_data.element_rank , elem_id(ix,iy,iz) ); }
/** * Thinking in terms of rows and columns of elements, get the element in * the (x, y) position. Return NULL if this process doesn't know about * this element. */ Entity elem( unsigned x , unsigned y ) const { return m_bulk_data.get_entity( stk::topology::ELEMENT_RANK, elem_id(x, y)); }