16 #include <deal.II/base/memory_consumption.h> 17 #include <deal.II/base/std_cxx11/bind.h> 18 #include <deal.II/grid/tria_objects.h> 19 #include <deal.II/grid/tria.h> 20 #include <deal.II/grid/tria_iterator.h> 21 #include <deal.II/grid/tria_accessor.h> 28 DEAL_II_NAMESPACE_OPEN
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(),
91 new_size-cells.size(),
94 used.reserve (new_size);
95 used.insert (used.end(),
99 user_flags.reserve (new_size);
100 user_flags.insert (user_flags.end(),
101 new_size-user_flags.size(),
105 children.reserve (factor*new_size);
106 children.insert (children.end(),
107 factor*new_size-children.size(),
110 if (G::dimension > 1)
112 refinement_cases.reserve (new_size);
113 refinement_cases.insert (refinement_cases.end(),
114 new_size - refinement_cases.size(),
120 boundary_or_material_id.reserve (new_size);
121 boundary_or_material_id.resize (new_size);
123 user_data.reserve (new_size);
124 user_data.resize (new_size);
126 manifold_id.reserve (new_size);
127 manifold_id.insert (manifold_id.end(),
128 new_size-manifold_id.size(),
133 if (n_unused_singles==0)
135 next_free_single=new_size-1;
136 reverse_order_next_free_single=
true;
142 template <
int dim,
int spacedim>
143 typename ::Triangulation<dim,spacedim>::raw_hex_iterator
145 const unsigned int level)
149 int pos=next_free_pair,
151 for (; pos<last; ++pos)
160 return tria.end_hex();
162 next_free_pair=pos+2;
164 return typename ::Triangulation<dim,spacedim>::raw_hex_iterator(&tria,level,pos);
171 const unsigned int new_size = new_hexes +
172 std::count_if (
used.begin(),
174 std_cxx11::bind (std::equal_to<bool>(), std_cxx11::_1,
true));
177 if (new_size>
cells.size())
179 cells.reserve (new_size);
181 new_size-
cells.size(),
184 used.reserve (new_size);
186 new_size-
used.size(),
242 const unsigned int new_quads_single)
252 unsigned int n_quads=0;
253 unsigned int n_unused_pairs=0;
254 unsigned int n_unused_singles=0;
255 for (
unsigned int i=0; i<
used.size(); ++i)
259 else if (i+1<
used.size())
278 Assert(n_quads+2*n_unused_pairs+n_unused_singles==
used.size(),
282 const int additional_single_quads=
283 new_quads_single-n_unused_singles;
285 unsigned int new_size=
286 used.size() + new_quads_in_pairs - 2*n_unused_pairs;
287 if (additional_single_quads>0)
288 new_size+=additional_single_quads;
291 if (new_size>
cells.size())
303 if (n_unused_singles==0)
315 Assert (cells.size() == used.size(),
316 ExcMemoryInexact (cells.size(), used.size()));
317 Assert (cells.size() == user_flags.size(),
318 ExcMemoryInexact (cells.size(), user_flags.size()));
319 Assert (cells.size() == children.size(),
320 ExcMemoryInexact (cells.size(), children.size()));
321 Assert (cells.size() == boundary_or_material_id.size(),
322 ExcMemoryInexact (cells.size(), boundary_or_material_id.size()));
323 Assert (cells.size() == manifold_id.size(),
324 ExcMemoryInexact (cells.size(), manifold_id.size()));
325 Assert (cells.size() == user_data.size(),
326 ExcMemoryInexact (cells.size(), user_data.size()));
332 TriaObjects<TriaObject<2> >::monitor_memory (
const unsigned int)
const 334 Assert (cells.size() == used.size(),
335 ExcMemoryInexact (cells.size(), used.size()));
336 Assert (cells.size() == user_flags.size(),
337 ExcMemoryInexact (cells.size(), user_flags.size()));
338 Assert (2*cells.size() == children.size(),
339 ExcMemoryInexact (cells.size(), children.size()));
340 Assert (cells.size() == refinement_cases.size(),
341 ExcMemoryInexact (cells.size(), refinement_cases.size()));
342 Assert (cells.size() == boundary_or_material_id.size(),
343 ExcMemoryInexact (cells.size(), boundary_or_material_id.size()));
344 Assert (cells.size() == manifold_id.size(),
345 ExcMemoryInexact (cells.size(), manifold_id.size()));
346 Assert (cells.size() == user_data.size(),
347 ExcMemoryInexact (cells.size(), user_data.size()));
396 template <
typename G>
402 refinement_cases.clear();
405 boundary_or_material_id.clear();
408 user_data_type = data_unknown;
441 user_data.capacity() *
sizeof(UserData) +
sizeof(user_data));
468 #include "tria_objects.inst" 472 DEAL_II_NAMESPACE_CLOSE
const types::manifold_id flat_manifold_id
std::vector< UserData > user_data
std::size_t memory_consumption() const
static ::ExceptionBase & ExcMemoryInexact(int arg1, int arg2)
void reserve_space(const unsigned int new_quads_in_pairs, const unsigned int new_quads_single=0)
std::vector< bool > line_orientations
unsigned int next_free_single
unsigned int next_free_pair
std::vector< int > children
std::vector< bool > face_flips
#define Assert(cond, exc)
std::vector< RefinementCase< TriaObject< 3 > ::dimension > > refinement_cases
bool reverse_order_next_free_single
void reserve_space(const unsigned int new_objs)
void monitor_memory(const unsigned int true_dimension) const
std::vector< bool > face_orientations
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::vector< BoundaryOrMaterialId > boundary_or_material_id
void monitor_memory(const unsigned int true_dimension) const
std::size_t memory_consumption() const
std::size_t memory_consumption() const
std::vector< types::manifold_id > manifold_id
std::vector< bool > user_flags
std::vector< TriaObject< 3 > > cells
void reserve_space(const unsigned int new_objs_in_pairs, const unsigned int new_objs_single=0)
std::vector< bool > face_rotations
static ::ExceptionBase & ExcInternalError()