//---------------------------------------------------------------------------//
// Return the Cartesian bounding box around an entity.
void STKMeshEntityImpl::boundingBox( Teuchos::Tuple<double,6>& bounds ) const
{
    DTK_REQUIRE( Teuchos::nonnull(d_bulk_data) );

    Intrepid::FieldContainer<double> node_coords =
	STKMeshHelpers::getEntityNodeCoordinates(
	    Teuchos::Array<stk::mesh::Entity>(1,d_extra_data->d_stk_entity), 
	    *d_bulk_data );
    DTK_CHECK( node_coords.rank() == 3 );
    DTK_CHECK( node_coords.dimension(0) == 1 );

    double max = std::numeric_limits<double>::max();
    bounds = Teuchos::tuple( max, max, max, -max, -max, -max );
    Teuchos::Array<stk::mesh::Entity>::const_iterator entity_node_it;
    for ( int n = 0; n < node_coords.dimension(1); ++n )
    {
	for ( int d = 0; d < node_coords.dimension(2); ++d )
	{
	    bounds[d] = std::min( bounds[d], node_coords(0,n,d) );
	    bounds[d+3] = std::max( bounds[d+3], node_coords(0,n,d) );
	}
    }
}
bool Morkon_Manager<DeviceType, DIM, FACE_TYPE>::internalize_interfaces()
{
  // Count up the numbers of nodes, faces, and interfaces.  Fill in the following
  // on the host side, then migrate the data to the device.

  local_to_global_idx_dvt                  node_to_global_id("node_to_global_id");
  local_to_global_idx_dvt                  face_to_global_id("face_to_global_id");
  face_to_interface_and_side_dvt  face_to_interface_and_side("face_to_interface_and_side");
  face_to_num_nodes_dvt                    face_to_num_nodes("face_to_num_nodes");
  face_to_nodes_dvt                            face_to_nodes("face_to_nodes");
  points_dvt                                     node_coords("node_coords");
  points_dvt                           predicted_node_coords("predicted_node_coords");
  on_boundary_table_dvt                  is_node_on_boundary("is_node_on_boundary");

  size_t num_nodes = 0;
  size_t num_faces = 0;
  count_global_node_and_face_ids(num_nodes, num_faces);

  node_to_global_id.resize(num_nodes);
  node_coords.resize(num_nodes);
  predicted_node_coords.resize(num_nodes);
  is_node_on_boundary.resize(num_nodes);
  face_to_global_id.resize(num_faces);
  face_to_interface_and_side.resize(num_faces);
  face_to_num_nodes.resize(num_faces);
  face_to_nodes.resize(num_faces);

  copy_data_from_interfaces_to_dualview_hostsides(node_to_global_id,
                                                  node_coords, predicted_node_coords, is_node_on_boundary,
                                                  face_to_global_id, face_to_interface_and_side,
                                                  face_to_num_nodes, face_to_nodes);

  // Now that the data is ready to move to the device side, commit it to there.
  return migrate_to_device(node_to_global_id, face_to_global_id,
                           face_to_interface_and_side, face_to_num_nodes, face_to_nodes,
                           node_coords, predicted_node_coords, is_node_on_boundary);
}