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);
213 new_size * GeometryInfo<3>::faces_per_cell -
222 face_flips.reserve(new_size * GeometryInfo<3>::faces_per_cell);
224 new_size * GeometryInfo<3>::faces_per_cell -
227 face_rotations.reserve(new_size * GeometryInfo<3>::faces_per_cell);
229 new_size * GeometryInfo<3>::faces_per_cell -
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())
294 line_orientations.insert(line_orientations.end(),
295 new_size * GeometryInfo<2>::lines_per_cell -
296 line_orientations.size(),
300 if (n_unused_singles == 0)
385 line_orientations.size(),
387 line_orientations.size()));
392 template <
typename G>
422 line_orientations.clear();
426 template <
typename G>
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
static::ExceptionBase & ExcMemoryInexact(int arg1, int arg2)
unsigned int next_free_single
unsigned int next_free_pair
std::vector< bool > face_rotations
bool reverse_order_next_free_single
std::vector< int > children
std::size_t memory_consumption() const
std::size_t memory_consumption() const
std::vector< BoundaryOrMaterialId > boundary_or_material_id
std::vector< bool > user_flags
std::vector< UserData > user_data
#define Assert(cond, exc)
std::vector< bool > face_orientations
void monitor_memory(const unsigned int true_dimension) const
std::size_t memory_consumption() const
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
void monitor_memory(const unsigned int true_dimension) const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
UserDataType user_data_type
static::ExceptionBase & ExcInternalError()