Reference documentation for deal.II version 8.5.1
tria_levels.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2015 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__tria_levels_h
17 #define dealii__tria_levels_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <vector>
22 #include <deal.II/grid/tria_object.h>
23 #include <deal.II/base/point.h>
24 #include <deal.II/grid/tria_objects.h>
25 
26 #include <boost/serialization/utility.hpp>
27 
28 DEAL_II_NAMESPACE_OPEN
29 
30 namespace internal
31 {
32  namespace Triangulation
33  {
53  template <int dim>
54  class TriaLevel
55  {
56  public:
65  std::vector<unsigned char> refine_flags;
66 
71  std::vector<bool> coarsen_flags;
72 
73 
79  std::vector<unsigned int> active_cell_indices;
80 
114  std::vector<std::pair<int,int> > neighbors;
115 
122  std::vector<types::subdomain_id> subdomain_ids;
123 
127  std::vector<types::subdomain_id> level_subdomain_ids;
128 
138  std::vector<int> parents;
139 
147  std::vector<bool> direction_flags;
148 
153 
154 
166  void reserve_space (const unsigned int total_cells,
167  const unsigned int dimension,
168  const unsigned int space_dimension);
169 
175  void monitor_memory (const unsigned int true_dimension) const;
176 
181  std::size_t memory_consumption () const;
182 
187  template <class Archive>
188  void serialize(Archive &ar,
189  const unsigned int version);
190 
195  char *, int, int,
196  << "The container " << arg1 << " contains "
197  << arg2 << " elements, but it`s capacity is "
198  << arg3 << ".");
203  int, int,
204  << "The containers have sizes " << arg1 << " and "
205  << arg2 << ", which is not as expected.");
206  };
207 
208 //TODO: Replace TriaObjectsHex to avoid this specialization
209 
215  template<>
216  class TriaLevel<3>
217  {
218  public:
219  std::vector<unsigned char> refine_flags;
220  std::vector<bool> coarsen_flags;
221  std::vector<unsigned int> active_cell_indices;
222  std::vector<std::pair<int,int> > neighbors;
223  std::vector<types::subdomain_id> subdomain_ids;
224  std::vector<types::subdomain_id> level_subdomain_ids;
225  std::vector<int> parents;
226 
227  // The following is not used
228  // since we don't support
229  // codim=1 meshes in 3d; only
230  // needed to allow
231  // compilation
232  // TODO[TH]: this is no longer true and might be a bug.
233  std::vector<bool> direction_flags;
234 
236 
237 
238  void reserve_space (const unsigned int total_cells,
239  const unsigned int dimension,
240  const unsigned int space_dimension);
241  void monitor_memory (const unsigned int true_dimension) const;
242  std::size_t memory_consumption () const;
243 
248  template <class Archive>
249  void serialize(Archive &ar,
250  const unsigned int version);
251 
256  char *, int, int,
257  << "The container " << arg1 << " contains "
258  << arg2 << " elements, but it`s capacity is "
259  << arg3 << ".");
264  int, int,
265  << "The containers have sizes " << arg1 << " and "
266  << arg2 << ", which is not as expected.");
267  };
268 
269 
270 
271  template <int dim>
272  template <class Archive>
273  void TriaLevel<dim>::serialize(Archive &ar,
274  const unsigned int)
275  {
276  ar &refine_flags &coarsen_flags;
277 
278  // do not serialize 'active_cell_indices' here. instead of storing them
279  // to the stream and re-reading them again later, we just rebuild them
280  // in Triangulation::load()
281 
282  ar &neighbors;
283  ar &subdomain_ids;
284  ar &level_subdomain_ids;
285  ar &parents;
286  ar &direction_flags;
287  ar &cells;
288  }
289 
290 
291 
292  template <class Archive>
293  void TriaLevel<3>::serialize(Archive &ar,
294  const unsigned int)
295  {
297 
298  // do not serialize 'active_cell_indices' here. instead of storing them
299  // to the stream and re-reading them again later, we just rebuild them
300  // in Triangulation::load()
301 
302  ar &neighbors;
303  ar &subdomain_ids;
305  ar &parents;
306  ar &direction_flags;
307  ar &cells;
308  }
309 
310  }
311 }
312 
313 
314 
315 DEAL_II_NAMESPACE_CLOSE
316 
317 #endif
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:576
std::size_t memory_consumption() const
Definition: tria_levels.cc:102
static ::ExceptionBase & ExcMemoryWasted(char *arg1, int arg2, int arg3)
std::vector< bool > direction_flags
Definition: tria_levels.h:147
static ::ExceptionBase & ExcMemoryInexact(int arg1, int arg2)
std::vector< unsigned char > refine_flags
Definition: tria_levels.h:65
void monitor_memory(const unsigned int true_dimension) const
Definition: tria_levels.cc:90
std::vector< bool > coarsen_flags
Definition: tria_levels.h:71
void serialize(Archive &ar, const unsigned int version)
Definition: tria_levels.h:273
std::vector< types::subdomain_id > subdomain_ids
Definition: tria_levels.h:122
std::vector< std::pair< int, int > > neighbors
Definition: tria_levels.h:114
std::vector< unsigned int > active_cell_indices
Definition: tria_levels.h:79
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:588
std::vector< types::subdomain_id > level_subdomain_ids
Definition: tria_levels.h:127
void reserve_space(const unsigned int total_cells, const unsigned int dimension, const unsigned int space_dimension)
Definition: tria_levels.cc:28
TriaObjects< TriaObject< dim > > cells
Definition: tria_levels.h:152