26 template <
int dim,
int spacedim>
32 template <
int dim,
int spacedim>
40 template <
int dim,
int spacedim>
48 template <
int dim,
int spacedim>
52 const unsigned int n_open_handles =
55 Assert(n_open_handles == 0,
56 ExcMessage(
"This property pool currently still holds " +
57 std::to_string(n_open_handles) +
58 " open handles to memory that was allocated "
59 "via allocate_properties_array() but that has "
60 "not been returned via "
61 "deregister_particle()."));
82 template <
int dim,
int spacedim>
98 ids.resize(
ids.size() + 1);
115 template <
int dim,
int spacedim>
122 "This handle is invalid and cannot be deallocated. This can happen if the "
123 "handle was deallocated already before calling this function."));
128 "Trying to deallocate a particle when none are allocated. This can happen if all "
129 "handles were deallocated already before calling this function."));
149 template <
int dim,
int spacedim>
161 template <
int dim,
int spacedim>
170 template <
int dim,
int spacedim>
175 ExcMessage(
"Number of registered locations is not equal to number "
176 "of registered reference locations."));
179 ExcMessage(
"Number of registered locations is not equal to number "
180 "of registered ids."));
183 ExcMessage(
"Number of registered locations is not equal to number "
184 "of registered property slots."));
191 template <
int dim,
int spacedim>
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());
203 sorted_ids.reserve(
ids.size());
206 for (
const auto &handle : handles_to_sort)
210 "Invalid handle detected during sorting particle memory."));
212 sorted_locations.push_back(
locations[handle]);
214 sorted_ids.push_back(
ids[handle]);
220 Assert(sorted_locations.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()) +
" - " +
230 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)
constexpr unsigned int invalid_unsigned_int