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