24 template <
int dim,
int spacedim>
30 template <
int dim,
int spacedim>
38 template <
int dim,
int spacedim>
46 template <
int dim,
int spacedim>
50 const unsigned int n_open_handles =
53 Assert(n_open_handles == 0,
54 ExcMessage(
"This property pool currently still holds " +
55 std::to_string(n_open_handles) +
56 " open handles to memory that was allocated "
57 "via allocate_properties_array() but that has "
58 "not been returned via "
59 "deregister_particle()."));
80 template <
int dim,
int spacedim>
96 ids.resize(
ids.size() + 1);
113 template <
int dim,
int spacedim>
120 "This handle is invalid and cannot be deallocated. This can happen if the "
121 "handle was deallocated already before calling this function."));
126 "Trying to deallocate a particle when none are allocated. This can happen if all "
127 "handles were deallocated already before calling this function."));
147 template <
int dim,
int spacedim>
159 template <
int dim,
int spacedim>
168 template <
int dim,
int spacedim>
173 ExcMessage(
"Number of registered locations is not equal to number "
174 "of registered reference locations."));
177 ExcMessage(
"Number of registered locations is not equal to number "
178 "of registered ids."));
181 ExcMessage(
"Number of registered locations is not equal to number "
182 "of registered property slots."));
189 template <
int dim,
int spacedim>
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());
201 sorted_ids.reserve(
ids.size());
204 for (
const auto &handle : handles_to_sort)
208 "Invalid handle detected during sorting particle memory."));
210 sorted_locations.push_back(
locations[handle]);
212 sorted_ids.push_back(
ids[handle]);
218 Assert(sorted_locations.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()) +
" - " +
228 ids = std::move(sorted_ids);
static const Handle invalid_handle
std::vector< Point< dim > > reference_locations
unsigned int n_properties_per_slot() const
unsigned int n_registered_slots() const
const unsigned int n_properties
void deregister_particle(Handle &handle)
void set_id(const Handle handle, const types::particle_index &new_id)
void set_reference_location(const Handle handle, const Point< dim > &new_reference_location)
void reserve(const std::size_t size)
void set_location(const Handle handle, const Point< spacedim > &new_location)
PropertyPool(const unsigned int n_properties_per_slot)
void sort_memory_slots(const std::vector< Handle > &handles_to_sort)
std::vector< Point< spacedim > > locations
std::vector< types::particle_index > ids
ArrayView< double, ::MemorySpace::Host > get_properties(const Handle handle)
Handle register_particle()
std::vector< Handle > currently_available_handles
std::vector< double > properties
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
static const unsigned int invalid_unsigned_int