192 const std::vector<Handle> &handles_to_sort)
194 std::vector<Point<spacedim>> sorted_locations;
195 std::vector<Point<dim>> sorted_reference_locations;
196 std::vector<types::particle_index> sorted_ids;
197 std::vector<double> sorted_properties;
199 sorted_locations.reserve(locations.size());
200 sorted_reference_locations.reserve(reference_locations.size());
201 sorted_ids.reserve(ids.size());
202 sorted_properties.reserve(properties.size());
204 for (
const auto &handle : handles_to_sort)
206 Assert(handle != invalid_handle,
208 "Invalid handle detected during sorting particle memory."));
210 sorted_locations.push_back(locations[handle]);
211 sorted_reference_locations.push_back(reference_locations[handle]);
212 sorted_ids.push_back(ids[handle]);
214 for (
unsigned int j = 0; j < n_properties; ++j)
215 sorted_properties.push_back(properties[handle * n_properties + j]);
218 Assert(sorted_locations.size() ==
219 locations.size() - currently_available_handles.size(),
220 ExcMessage(
"Number of sorted property handles is not equal to "
221 "number of currently registered handles: " +
222 std::to_string(sorted_locations.size()) +
" vs " +
223 std::to_string(locations.size()) +
" - " +
224 std::to_string(currently_available_handles.size())));
226 locations = std::move(sorted_locations);
227 reference_locations = std::move(sorted_reference_locations);
228 ids = std::move(sorted_ids);
229 properties = std::move(sorted_properties);
231 currently_available_handles.clear();