25 template <
int dim,
int spacedim>
31 template <
int dim,
int spacedim>
33 const unsigned int n_properties_per_slot)
34 : n_properties(n_properties_per_slot)
39 template <
int dim,
int spacedim>
47 template <
int dim,
int spacedim>
53 const unsigned int n_open_handles =
54 properties.size() / n_properties - currently_available_handles.size();
57 ExcMessage(
"This property pool currently still holds " +
59 " open handles to memory that was allocated "
60 "via allocate_properties_array() but that has "
61 "not been returned via "
62 "deallocate_properties_array()."));
67 locations.shrink_to_fit();
69 reference_locations.clear();
70 reference_locations.shrink_to_fit();
76 properties.shrink_to_fit();
78 currently_available_handles.clear();
79 currently_available_handles.shrink_to_fit();
84 template <
int dim,
int spacedim>
88 Handle handle = invalid_handle;
89 if (currently_available_handles.size() > 0)
91 handle = currently_available_handles.back();
92 currently_available_handles.pop_back();
96 handle = locations.size();
98 locations.resize(locations.size() + 1);
99 reference_locations.resize(reference_locations.size() + 1);
100 ids.resize(ids.size() + 1);
101 properties.resize(properties.size() + n_properties);
109 for (
double &x : get_properties(handle))
117 template <
int dim,
int spacedim>
122 handle != invalid_handle,
124 "This handle is invalid and cannot be deallocated. This can happen if the "
125 "handle was deallocated already before calling this function."));
126 currently_available_handles.push_back(handle);
127 handle = invalid_handle;
132 if (currently_available_handles.size() == locations.size())
134 currently_available_handles.clear();
137 reference_locations.clear();
144 template <
int dim,
int spacedim>
149 reference_locations.reserve(size);
150 properties.reserve(size * n_properties);
156 template <
int dim,
int spacedim>
void reserve(const std::size_t size)
PropertyPool(const unsigned int n_properties_per_slot)
static const Handle invalid_handle
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
std::string to_string(const T &t)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
static const unsigned int invalid_unsigned_int