16 #include <deal.II/base/memory_consumption.h> 18 #include <deal.II/grid/tria.h> 19 #include <deal.II/grid/tria_accessor.h> 20 #include <deal.II/grid/tria_iterator.h> 21 #include <deal.II/grid/tria_objects.h> 28 DEAL_II_NAMESPACE_OPEN
32 namespace TriangulationImplementation
37 const unsigned int new_objects_single)
43 reverse_order_next_free_single =
false;
47 unsigned int n_objects = 0;
48 unsigned int n_unused_pairs = 0;
49 unsigned int n_unused_singles = 0;
50 for (
unsigned int i = 0; i < used.size(); ++i)
54 else if (i + 1 < used.size())
59 if (next_free_single == 0)
65 if (next_free_pair == 0)
73 Assert(n_objects + 2 * n_unused_pairs + n_unused_singles == used.size(),
78 const int additional_single_objects =
79 new_objects_single - n_unused_singles;
81 unsigned int new_size =
82 used.size() + new_objects_in_pairs - 2 * n_unused_pairs;
83 if (additional_single_objects > 0)
84 new_size += additional_single_objects;
87 if (new_size > cells.size())
89 cells.reserve(new_size);
90 cells.insert(cells.end(), new_size - cells.size(), G());
92 used.reserve(new_size);
93 used.insert(used.end(), new_size - used.size(),
false);
95 user_flags.reserve(new_size);
96 user_flags.insert(user_flags.end(),
97 new_size - user_flags.size(),
100 const unsigned int factor =
102 children.reserve(factor * new_size);
103 children.insert(children.end(),
104 factor * new_size - children.size(),
107 if (G::dimension > 1)
109 refinement_cases.reserve(new_size);
110 refinement_cases.insert(
111 refinement_cases.end(),
112 new_size - refinement_cases.size(),
118 boundary_or_material_id.reserve(new_size);
119 boundary_or_material_id.resize(new_size);
121 user_data.reserve(new_size);
122 user_data.resize(new_size);
124 manifold_id.reserve(new_size);
125 manifold_id.insert(manifold_id.end(),
126 new_size - manifold_id.size(),
130 if (n_unused_singles == 0)
132 next_free_single = new_size - 1;
133 reverse_order_next_free_single =
true;
139 template <
int dim,
int spacedim>
140 typename ::Triangulation<dim, spacedim>::raw_hex_iterator
142 const ::Triangulation<dim, spacedim> &tria,
143 const unsigned int level)
148 int pos = next_free_pair, last = used.size() - 1;
149 for (; pos < last; ++pos)
158 return tria.end_hex();
160 next_free_pair = pos + 2;
163 typename ::Triangulation<dim, spacedim>::raw_hex_iterator(&tria,
172 const unsigned int new_size =
173 new_hexes + std::count_if(
used.begin(),
175 std::bind(std::equal_to<bool>(),
176 std::placeholders::_1,
180 if (new_size >
cells.size())
182 cells.reserve(new_size);
185 used.reserve(new_size);
239 const unsigned int new_quads_single)
249 unsigned int n_quads = 0;
250 unsigned int n_unused_pairs = 0;
251 unsigned int n_unused_singles = 0;
252 for (
unsigned int i = 0; i <
used.size(); ++i)
256 else if (i + 1 <
used.size())
275 Assert(n_quads + 2 * n_unused_pairs + n_unused_singles ==
used.size(),
279 const int additional_single_quads = new_quads_single - n_unused_singles;
281 unsigned int new_size =
282 used.size() + new_quads_in_pairs - 2 * n_unused_pairs;
283 if (additional_single_quads > 0)
284 new_size += additional_single_quads;
287 if (new_size >
cells.size())
300 if (n_unused_singles == 0)
312 Assert(cells.size() == used.size(),
313 ExcMemoryInexact(cells.size(), used.size()));
314 Assert(cells.size() == user_flags.size(),
315 ExcMemoryInexact(cells.size(), user_flags.size()));
316 Assert(cells.size() == children.size(),
317 ExcMemoryInexact(cells.size(), children.size()));
318 Assert(cells.size() == boundary_or_material_id.size(),
319 ExcMemoryInexact(cells.size(), boundary_or_material_id.size()));
320 Assert(cells.size() == manifold_id.size(),
321 ExcMemoryInexact(cells.size(), manifold_id.size()));
322 Assert(cells.size() == user_data.size(),
323 ExcMemoryInexact(cells.size(), user_data.size()));
329 TriaObjects<TriaObject<2>>::monitor_memory(
const unsigned int)
const 331 Assert(cells.size() == used.size(),
332 ExcMemoryInexact(cells.size(), used.size()));
333 Assert(cells.size() == user_flags.size(),
334 ExcMemoryInexact(cells.size(), user_flags.size()));
335 Assert(2 * cells.size() == children.size(),
336 ExcMemoryInexact(cells.size(), children.size()));
337 Assert(cells.size() == refinement_cases.size(),
338 ExcMemoryInexact(cells.size(), refinement_cases.size()));
339 Assert(cells.size() == boundary_or_material_id.size(),
340 ExcMemoryInexact(cells.size(), boundary_or_material_id.size()));
341 Assert(cells.size() == manifold_id.size(),
342 ExcMemoryInexact(cells.size(), manifold_id.size()));
343 Assert(cells.size() == user_data.size(),
344 ExcMemoryInexact(cells.size(), user_data.size()));
392 template <
typename G>
398 refinement_cases.clear();
401 boundary_or_material_id.clear();
404 user_data_type = data_unknown;
426 template <
typename G>
437 user_data.capacity() *
sizeof(UserData) +
sizeof(user_data));
464 #include "tria_objects.inst" 468 DEAL_II_NAMESPACE_CLOSE
void reserve_space(const unsigned int new_objs)
const types::manifold_id flat_manifold_id
std::vector< bool > line_orientations
static ::ExceptionBase & ExcMemoryInexact(int arg1, int arg2)
std::size_t memory_consumption() const
unsigned int next_free_single
unsigned int next_free_pair
std::size_t memory_consumption() const
std::vector< bool > face_rotations
std::size_t memory_consumption() const
bool reverse_order_next_free_single
std::vector< int > children
void monitor_memory(const unsigned int true_dimension) const
std::vector< BoundaryOrMaterialId > boundary_or_material_id
void monitor_memory(const unsigned int true_dimension) const
std::vector< bool > user_flags
std::vector< UserData > user_data
#define Assert(cond, exc)
std::vector< bool > face_orientations
void reserve_space(const unsigned int new_objs_in_pairs, const unsigned int new_objs_single=0)
std::vector< RefinementCase< TriaObject< 3 > ::dimension > > refinement_cases
std::vector< bool > face_flips
void reserve_space(const unsigned int new_quads_in_pairs, const unsigned int new_quads_single=0)
std::vector< types::manifold_id > manifold_id
std::vector< TriaObject< 3 > > cells
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static ::ExceptionBase & ExcInternalError()