void setup_mesh_indices(const stk::mesh::BulkData& bulk, const stk::mesh::Selector& selector) { const stk::mesh::BucketVector& nodeBuckets = bulk.buckets(stk::topology::NODE_RANK); meshIndices = DeviceViewMeshIndicesType("DMeshIndices", bulk.get_size_of_entity_index_space()); constMeshIndices = meshIndices; hostMeshIndices = Kokkos::create_mirror_view(meshIndices); for(unsigned bktIndex = 0; bktIndex < nodeBuckets.size(); ++bktIndex) { const stk::mesh::Bucket& bucket = *nodeBuckets[bktIndex]; for(unsigned nodeIndex = 0; nodeIndex < bucket.size(); ++nodeIndex) { stk::mesh::Entity node = bucket[nodeIndex]; stk::mesh::FastMeshIndex meshIndex(bucket.bucket_id(), nodeIndex); hostMeshIndices(node.local_offset()) = meshIndex; } } const stk::mesh::BucketVector& elemBuckets = bulk.get_buckets(stk::topology::ELEM_RANK, selector); for(unsigned bktIndex = 0; bktIndex < elemBuckets.size(); ++bktIndex) { const stk::mesh::Bucket& bucket = *elemBuckets[bktIndex]; for(unsigned elemIndex = 0; elemIndex < bucket.size(); ++elemIndex) { stk::mesh::Entity elem = bucket[elemIndex]; stk::mesh::FastMeshIndex meshIndex(bucket.bucket_id(), elemIndex); hostMeshIndices(elem.local_offset()) = meshIndex; } } Kokkos::deep_copy(meshIndices, hostMeshIndices); }