16 #include <deal.II/base/memory_consumption.h> 17 #include <deal.II/grid/tria_objects.h> 18 #include <deal.II/grid/tria.h> 19 #include <deal.II/grid/tria_iterator.h> 20 #include <deal.II/grid/tria_accessor.h> 27 DEAL_II_NAMESPACE_OPEN
31 namespace TriangulationImplementation
36 const unsigned int new_objects_single)
42 reverse_order_next_free_single=
false;
46 unsigned int n_objects=0;
47 unsigned int n_unused_pairs=0;
48 unsigned int n_unused_singles=0;
49 for (
unsigned int i=0; i<used.size(); ++i)
53 else if (i+1<used.size())
58 if (next_free_single==0)
64 if (next_free_pair==0)
72 Assert(n_objects+2*n_unused_pairs+n_unused_singles==used.size(),
77 const int additional_single_objects=
78 new_objects_single-n_unused_singles;
80 unsigned int new_size=
81 used.size() + new_objects_in_pairs - 2*n_unused_pairs;
82 if (additional_single_objects>0)
83 new_size+=additional_single_objects;
86 if (new_size>cells.size())
88 cells.reserve (new_size);
89 cells.insert (cells.end(),
90 new_size-cells.size(),
93 used.reserve (new_size);
94 used.insert (used.end(),
98 user_flags.reserve (new_size);
99 user_flags.insert (user_flags.end(),
100 new_size-user_flags.size(),
104 children.reserve (factor*new_size);
105 children.insert (children.end(),
106 factor*new_size-children.size(),
109 if (G::dimension > 1)
111 refinement_cases.reserve (new_size);
112 refinement_cases.insert (refinement_cases.end(),
113 new_size - refinement_cases.size(),
119 boundary_or_material_id.reserve (new_size);
120 boundary_or_material_id.resize (new_size);
122 user_data.reserve (new_size);
123 user_data.resize (new_size);
125 manifold_id.reserve (new_size);
126 manifold_id.insert (manifold_id.end(),
127 new_size-manifold_id.size(),
132 if (n_unused_singles==0)
134 next_free_single=new_size-1;
135 reverse_order_next_free_single=
true;
141 template <
int dim,
int spacedim>
142 typename ::Triangulation<dim,spacedim>::raw_hex_iterator
144 const unsigned int level)
148 int pos=next_free_pair,
150 for (; pos<last; ++pos)
159 return tria.end_hex();
161 next_free_pair=pos+2;
163 return typename ::Triangulation<dim,spacedim>::raw_hex_iterator(&tria,level,pos);
170 const unsigned int new_size = new_hexes +
171 std::count_if (
used.begin(),
173 std::bind (std::equal_to<bool>(), std::placeholders::_1,
true));
176 if (new_size>
cells.size())
178 cells.reserve (new_size);
180 new_size-
cells.size(),
183 used.reserve (new_size);
185 new_size-
used.size(),
241 const unsigned int new_quads_single)
251 unsigned int n_quads=0;
252 unsigned int n_unused_pairs=0;
253 unsigned int n_unused_singles=0;
254 for (
unsigned int i=0; i<
used.size(); ++i)
258 else if (i+1<
used.size())
277 Assert(n_quads+2*n_unused_pairs+n_unused_singles==
used.size(),
281 const int additional_single_quads=
282 new_quads_single-n_unused_singles;
284 unsigned int new_size=
285 used.size() + new_quads_in_pairs - 2*n_unused_pairs;
286 if (additional_single_quads>0)
287 new_size+=additional_single_quads;
290 if (new_size>
cells.size())
302 if (n_unused_singles==0)
314 Assert (cells.size() == used.size(),
315 ExcMemoryInexact (cells.size(), used.size()));
316 Assert (cells.size() == user_flags.size(),
317 ExcMemoryInexact (cells.size(), user_flags.size()));
318 Assert (cells.size() == children.size(),
319 ExcMemoryInexact (cells.size(), children.size()));
320 Assert (cells.size() == boundary_or_material_id.size(),
321 ExcMemoryInexact (cells.size(), boundary_or_material_id.size()));
322 Assert (cells.size() == manifold_id.size(),
323 ExcMemoryInexact (cells.size(), manifold_id.size()));
324 Assert (cells.size() == user_data.size(),
325 ExcMemoryInexact (cells.size(), user_data.size()));
331 TriaObjects<TriaObject<2> >::monitor_memory (
const unsigned int)
const 333 Assert (cells.size() == used.size(),
334 ExcMemoryInexact (cells.size(), used.size()));
335 Assert (cells.size() == user_flags.size(),
336 ExcMemoryInexact (cells.size(), user_flags.size()));
337 Assert (2*cells.size() == children.size(),
338 ExcMemoryInexact (cells.size(), children.size()));
339 Assert (cells.size() == refinement_cases.size(),
340 ExcMemoryInexact (cells.size(), refinement_cases.size()));
341 Assert (cells.size() == boundary_or_material_id.size(),
342 ExcMemoryInexact (cells.size(), boundary_or_material_id.size()));
343 Assert (cells.size() == manifold_id.size(),
344 ExcMemoryInexact (cells.size(), manifold_id.size()));
345 Assert (cells.size() == user_data.size(),
346 ExcMemoryInexact (cells.size(), user_data.size()));
395 template <
typename G>
401 refinement_cases.clear();
404 boundary_or_material_id.clear();
407 user_data_type = data_unknown;
429 template <
typename G>
440 user_data.capacity() *
sizeof(UserData) +
sizeof(user_data));
467 #include "tria_objects.inst" 471 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()