34#include <boost/serialization/map.hpp>
35#include <boost/serialization/split_member.hpp>
36#include <boost/serialization/unique_ptr.hpp>
37#include <boost/serialization/vector.hpp>
38#include <boost/signals2.hpp>
53 "The name 'signals' is already defined. You are most likely using the QT library \
54and using the 'signals' keyword. You can either #include the Qt headers (or any conflicting headers) \
55*after* the deal.II headers or you can define the 'QT_NO_KEYWORDS' macro and use the 'Q_SIGNALS' macro."
60template <
int dim,
int spacedim>
76 template <
typename CellIterator>
77 struct PeriodicFacePair;
80template <
int,
int,
int>
82template <
int spacedim>
84template <
int,
int,
int>
89 namespace TriangulationImplementation
103 struct Implementation;
104 struct ImplementationMixedMesh;
107 namespace TriaAccessorImplementation
109 struct Implementation;
124 namespace TriangulationImplementation
183 std::shared_ptr<const Utilities::MPI::Partitioner>
189 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
202 memory_consumption()
const;
209 template <
class Archive>
260 memory_consumption()
const;
267 template <
class Archive>
319 memory_consumption()
const;
326 template <
class Archive>
336 template <
int dim,
int spacedim = dim>
375 template <
int dim,
int spacedim = dim>
386 static inline constexpr unsigned int version_number = 5;
407 const std::vector<cell_relation_t> &cell_relations,
410 &pack_callbacks_fixed,
413 &pack_callbacks_variable,
424 unpack_cell_status(std::vector<cell_relation_t> &cell_relations)
const;
440 const std::vector<cell_relation_t> &cell_relations,
441 const unsigned int handle,
445 const boost::iterator_range<std::vector<char>::const_iterator> &)>
446 &unpack_callback)
const;
463 save(
const unsigned int global_first_cell,
464 const unsigned int global_num_cells,
465 const std::string &file_basename,
466 const MPI_Comm &mpi_communicator)
const;
487 load(
const unsigned int global_first_cell,
488 const unsigned int global_num_cells,
489 const unsigned int local_num_cells,
490 const std::string &file_basename,
491 const unsigned int n_attached_deserialize_fixed,
492 const unsigned int n_attached_deserialize_variable,
1320template <
int dim,
int spacedim = dim>
1387 limit_level_difference_at_vertices = 0x1,
1408 eliminate_unrefined_islands = 0x2,
1424 patch_level_1 = 0x4,
1448 coarsest_level_1 = 0x8,
1473 allow_anisotropic_smoothing = 0x10,
1506 eliminate_refined_inner_islands = 0x100,
1511 eliminate_refined_boundary_islands = 0x200,
1517 do_not_produce_unrefined_islands = 0x400,
1523 smoothing_on_refinement =
1524 (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1529 smoothing_on_coarsening =
1530 (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1531 do_not_produce_unrefined_islands),
1538 maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1743 static constexpr
unsigned int dimension = dim;
1748 static constexpr
unsigned int space_dimension = spacedim;
1765 const
bool check_for_distorted_cells = false);
1817 get_communicator() const;
1825 global_active_cell_index_partitioner() const;
1833 global_level_cell_index_partitioner(const
unsigned int level) const;
1846 get_mesh_smoothing() const;
1871 set_manifold(const
types::manifold_id number,
1872 const
Manifold<dim, spacedim> &manifold_object);
1891 reset_manifold(const
types::manifold_id manifold_number);
1910 reset_all_manifolds();
1921 set_all_manifold_ids(const
types::manifold_id number);
1932 set_all_manifold_ids_on_boundary(const
types::manifold_id number);
1944 set_all_manifold_ids_on_boundary(const
types::boundary_id b_id,
1945 const
types::manifold_id number);
1959 get_manifold(const
types::manifold_id number) const;
1971 virtual
std::vector<
types::boundary_id>
1972 get_boundary_ids() const;
1986 virtual
std::vector<
types::manifold_id>
1987 get_manifold_ids() const;
2079 create_triangulation(
2081 &construction_data);
2092 flip_all_direction_flags();
2106 set_all_refine_flags();
2131 refine_global(const
unsigned int times = 1);
2146 coarsen_global(const
unsigned int times = 1);
2180 execute_coarsening_and_refinement();
2212 prepare_coarsening_and_refinement();
2264 template <typename T>
2269 template <
typename InputIterator>
2273 return std::accumulate(
first, last, T());
2337 boost::signals2::signal<void(
2347 boost::signals2::signal<void(
2357 boost::signals2::signal<void(
2424 const ::CellStatus),
3356 virtual unsigned int
3389 const std::vector<Point<spacedim>> &
3409 const std::vector<bool> &
3570 template <
class Archive>
3572 save(Archive &ar,
const unsigned int version)
const;
3591 template <
class Archive>
3593 load(Archive &ar,
const unsigned int version);
3605 save(
const std::string &file_basename)
const;
3611 load(
const std::string &file_basename);
3637 std::pair<cell_iterator, unsigned int>,
3638 std::pair<std::pair<cell_iterator, unsigned int>,
unsigned char>> &
3645 const std::vector<ReferenceCell> &
3678 template <
class Archive>
3684 BOOST_SERIALIZATION_SPLIT_MEMBER()
3801 const std::function<std::vector<char>(
const cell_iterator &,
3802 const ::CellStatus)>
3804 const bool returns_variable_size_data);
3857 const unsigned int handle,
3858 const std::function<
3861 const boost::iterator_range<std::vector<char>::const_iterator> &)>
3876 const unsigned int global_num_cells,
3877 const std::string &file_basename)
const;
3889 const unsigned int global_num_cells,
3890 const unsigned int local_num_cells,
3891 const std::string &file_basename,
3892 const unsigned int n_attached_deserialize_fixed,
3893 const unsigned int n_attached_deserialize_variable);
3912 std::vector<typename internal::CellAttachedDataSerializer<dim, spacedim>::
3935 <<
"You are requesting information from refinement level "
3937 <<
" of a triangulation, but this triangulation only has "
3938 << arg2 <<
" refinement levels. The given level " << arg1
3939 <<
" must be *less* than " << arg2 <<
'.');
3947 ExcTriangulationNotEmpty,
3950 <<
"You are trying to perform an operation on a triangulation "
3951 <<
"that is only allowed if the triangulation is currently empty. "
3952 <<
"However, it currently stores " << arg1 <<
" vertices and has "
3953 <<
"cells on " << arg2 <<
" levels.");
3972 <<
"You tried to do something on level " << arg1
3973 <<
", but this level is empty.");
3984 <<
"The given boundary_id " << arg1
3985 <<
" is not defined in this Triangulation!");
3993 ExcInconsistentCoarseningFlags,
3994 "A cell is flagged for coarsening, but either not all of its siblings "
3995 "are active or flagged for coarsening as well. Please clean up all "
3996 "coarsen flags on your triangulation via "
3997 "Triangulation::prepare_coarsening_and_refinement() beforehand!");
4029 const std::vector<bool> &v,
4030 const unsigned int magic_number2,
4039 std::vector<bool> &v,
4040 const unsigned int magic_number2,
4072 std::vector<GridTools::PeriodicFacePair<cell_iterator>>
4079 std::map<std::pair<cell_iterator, unsigned int>,
4080 std::pair<std::pair<cell_iterator, unsigned int>,
unsigned char>>
4426 virtual unsigned int
4445 const unsigned int coarse_cell_index)
const;
4452 std::unique_ptr<::internal::TriangulationImplementation::TriaLevel>>
4460 std::unique_ptr<::internal::TriangulationImplementation::TriaFaces>
4478 std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
4518 std::unique_ptr<std::map<unsigned int, types::boundary_id>>
4541 std::unique_ptr<std::map<unsigned int, types::manifold_id>>
4545 template <
int,
int,
int>
4547 template <
int,
int,
int>
4553 friend struct ::internal::TriaAccessorImplementation::Implementation;
4555 friend struct ::internal::TriangulationImplementation::Implementation;
4556 friend struct ::internal::TriangulationImplementation::
4557 ImplementationMixedMesh;
4559 friend class ::internal::TriangulationImplementation::TriaObjects;
4564 static_assert(dim <= spacedim,
4565 "The dimension <dim> of a Triangulation must be less than or "
4566 "equal to the space dimension <spacedim> in which it lives.");
4577 namespace TriangulationImplementation
4579 template <
class Archive>
4584 ar &n_lines &n_lines_level;
4585 ar &n_active_lines &n_active_lines_level;
4589 template <
class Archive>
4595 ar &n_quads &n_quads_level;
4596 ar &n_active_quads &n_active_quads_level;
4600 template <
class Archive>
4606 ar &n_hexes &n_hexes_level;
4607 ar &n_active_hexes &n_active_hexes_level;
4614template <
int dim,
int spacedim>
4617 const unsigned int index)
const
4620 return vertices_used[
index];
4625template <
int dim,
int spacedim>
4629 return number_cache.n_levels;
4632template <
int dim,
int spacedim>
4636 return number_cache.n_levels;
4640template <
int dim,
int spacedim>
4649template <
int dim,
int spacedim>
4651inline const std::vector<Point<spacedim>>
4658template <
int dim,
int spacedim>
4660template <
class Archive>
4667 unsigned int n_levels = levels.size();
4669 for (
const auto &
level : levels)
4675 bool faces_is_nullptr = (faces.get() ==
nullptr);
4676 ar &faces_is_nullptr;
4677 if (!faces_is_nullptr)
4683 ar &anisotropic_refinement;
4686 ar &check_for_distorted_cells;
4690 ar &vertex_to_boundary_id_map_1d;
4691 ar &vertex_to_manifold_id_map_1d;
4697template <
int dim,
int spacedim>
4699template <
class Archive>
4711 levels.resize(size);
4712 for (
auto &level_ : levels)
4714 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>
level;
4716 level_ = std::move(
level);
4720 bool faces_is_nullptr =
true;
4721 ar &faces_is_nullptr;
4722 if (!faces_is_nullptr)
4728 ar &anisotropic_refinement;
4735 for (
const auto &
level : levels)
4737 level->active_cell_indices.resize(
level->refine_flags.size());
4738 level->global_active_cell_indices.resize(
level->refine_flags.size());
4739 level->global_level_cell_indices.resize(
level->refine_flags.size());
4741 reset_cell_vertex_indices_cache();
4742 reset_active_cell_indices();
4743 reset_global_cell_indices();
4748 bool my_check_for_distorted_cells;
4749 ar &my_check_for_distorted_cells;
4751 Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4752 ExcMessage(
"The triangulation loaded into here must have the "
4753 "same setting with regard to reporting distorted "
4754 "cell as the one previously stored."));
4758 ar &vertex_to_boundary_id_map_1d;
4759 ar &vertex_to_manifold_id_map_1d;
4770template <
int dim,
int spacedim>
4781template <
int dim,
int spacedim>
4785 const unsigned int coarse_cell_index)
const
4787 return coarse_cell_index;
@ children_will_be_coarsened
unsigned int n_hexs(const unsigned int level) const
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
void save_user_flags_line(std::vector< bool > &v) const
virtual types::global_cell_index n_global_active_cells() const
quad_iterator begin_quad(const unsigned int level=0) const
typename IteratorSelector::raw_line_iterator raw_line_iterator
active_vertex_iterator begin_active_vertex() const
void load_user_indices_quad(const std::vector< unsigned int > &v)
unsigned int n_quads() const
void load_user_indices(const std::vector< unsigned int > &v)
std::vector< bool > vertices_used
bool anisotropic_refinement
std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, unsigned char > > periodic_face_map
active_quad_iterator begin_active_quad(const unsigned int level=0) const
bool get_anisotropic_refinement_flag() const
virtual types::coarse_cell_id n_global_coarse_cells() const
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
void save_user_pointers_quad(std::vector< void * > &v) const
void save_user_flags_hex(std::ostream &out) const
void clear_user_flags_quad()
unsigned int n_faces() const
active_hex_iterator begin_active_hex(const unsigned int level=0) const
static void read_bool_vector(const unsigned int magic_number1, std::vector< bool > &v, const unsigned int magic_number2, std::istream &in)
unsigned int n_active_lines(const unsigned int level) const
bool all_reference_cells_are_hyper_cube() const
void load_user_flags_line(std::istream &in)
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
const std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, unsigned char > > & get_periodic_face_map() const
void save_user_flags_line(std::ostream &out) const
active_cell_iterator last_active() const
void save(Archive &ar, const unsigned int version) const
std::vector< typename internal::CellAttachedDataSerializer< dim, spacedim >::cell_relation_t > local_cell_relations
const Triangulation< dim, spacedim > & get_triangulation() const
void reset_global_cell_indices()
virtual void save(const std::string &file_basename) const
face_iterator end_face() const
void reset_active_cell_indices()
cell_iterator create_cell_iterator(const CellId &cell_id) const
cell_iterator begin(const unsigned int level=0) const
virtual void load(const std::string &file_basename)
unsigned int n_active_cells(const unsigned int level) const
unsigned int n_cells(const unsigned int level) const
void save_user_pointers_line(std::vector< void * > &v) const
void save_user_flags_quad(std::vector< bool > &v) const
void load_refine_flags(std::istream &in)
void save_user_indices_line(std::vector< unsigned int > &v) const
raw_cell_iterator begin_raw(const unsigned int level=0) const
unsigned int n_lines() const
void load_coarsen_flags(const std::vector< bool > &v)
unsigned int n_raw_lines() const
virtual std::size_t memory_consumption() const
std::vector< Point< spacedim > > vertices
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
virtual types::subdomain_id locally_owned_subdomain() const
unsigned int n_raw_faces() const
unsigned int n_active_faces() const
const bool check_for_distorted_cells
raw_cell_iterator end_raw(const unsigned int level) const
line_iterator end_line() const
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
void load_user_flags_quad(std::istream &in)
unsigned int n_active_cells() const
virtual void update_reference_cells()
std::vector< ReferenceCell > reference_cells
void update_periodic_face_map()
unsigned int n_raw_lines(const unsigned int level) const
void clear_despite_subscriptions()
void save_user_flags(std::ostream &out) const
void load_user_flags_hex(std::istream &in)
const std::vector< Point< spacedim > > & get_vertices() const
void load_user_pointers_quad(const std::vector< void * > &v)
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
unsigned int n_used_vertices() const
void reset_cell_vertex_indices_cache()
unsigned int n_active_lines() const
unsigned int n_levels() const
void load_user_flags_hex(const std::vector< bool > &v)
void load_user_indices_line(const std::vector< unsigned int > &v)
void clear_user_flags_hex()
void save_user_pointers_hex(std::vector< void * > &v) const
const std::vector< ReferenceCell > & get_reference_cells() const
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
void load_user_pointers(const std::vector< void * > &v)
unsigned int register_data_attach(const std::function< std::vector< char >(const cell_iterator &, const ::CellStatus)> &pack_callback, const bool returns_variable_size_data)
::internal::TriangulationImplementation::NumberCache< dim > number_cache
void load_user_flags_quad(const std::vector< bool > &v)
void save_attached_data(const unsigned int global_first_cell, const unsigned int global_num_cells, const std::string &file_basename) const
void load_user_flags_line(const std::vector< bool > &v)
void save_user_indices_hex(std::vector< unsigned int > &v) const
DistortedCellList execute_refinement()
void update_cell_relations()
active_line_iterator begin_active_line(const unsigned int level=0) const
void save_user_indices_quad(std::vector< unsigned int > &v) const
void load_user_pointers_hex(const std::vector< void * > &v)
cell_iterator end() const
virtual bool has_hanging_nodes() const
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
unsigned int n_raw_cells(const unsigned int level) const
cell_iterator end(const unsigned int level) const
bool contains_cell(const CellId &cell_id) const
void load_attached_data(const unsigned int global_first_cell, const unsigned int global_num_cells, const unsigned int local_num_cells, const std::string &file_basename, const unsigned int n_attached_deserialize_fixed, const unsigned int n_attached_deserialize_variable)
virtual types::coarse_cell_id coarse_cell_index_to_coarse_cell_id(const unsigned int coarse_cell_index) const
unsigned int n_raw_quads(const unsigned int level) const
internal::CellAttachedData< dim, spacedim > cell_attached_data
void load_coarsen_flags(std::istream &out)
quad_iterator end_quad() const
line_iterator begin_line(const unsigned int level=0) const
unsigned int max_adjacent_cells() const
vertex_iterator begin_vertex() const
unsigned int n_hexs() const
vertex_iterator end_vertex() const
bool vertex_used(const unsigned int index) const
void load_user_pointers_line(const std::vector< void * > &v)
void save_user_flags(std::vector< bool > &v) const
hex_iterator end_hex() const
hex_iterator begin_hex(const unsigned int level=0) const
virtual unsigned int n_global_levels() const
active_cell_iterator end_active(const unsigned int level) const
bool is_mixed_mesh() const
cell_iterator last() const
unsigned int n_active_quads() const
void save_coarsen_flags(std::vector< bool > &v) const
void load_user_indices_hex(const std::vector< unsigned int > &v)
unsigned int n_raw_quads() const
void save_user_pointers(std::vector< void * > &v) const
face_iterator begin_face() const
unsigned int n_cells() const
virtual bool prepare_coarsening_and_refinement()
unsigned int n_active_quads(const unsigned int level) const
const std::vector< bool > & get_used_vertices() const
void load_user_flags(const std::vector< bool > &v)
typename IteratorSelector::raw_hex_iterator raw_hex_iterator
std::map< types::manifold_id, std::unique_ptr< const Manifold< dim, spacedim > > > manifolds
void serialize(Archive &archive, const unsigned int version)
void load_refine_flags(const std::vector< bool > &v)
MeshSmoothing smooth_grid
void save_refine_flags(std::ostream &out) const
std::unique_ptr< ::internal::TriangulationImplementation::Policy< dim, spacedim > > policy
Triangulation< dim, spacedim > & get_triangulation()
void save_user_flags_quad(std::ostream &out) const
internal::CellAttachedDataSerializer< dim, spacedim > data_serializer
unsigned int n_active_hexs(const unsigned int level) const
unsigned int n_vertices() const
void load(Archive &ar, const unsigned int version)
void save_user_indices(std::vector< unsigned int > &v) const
void notify_ready_to_unpack(const unsigned int handle, const std::function< void(const cell_iterator &, const ::CellStatus, const boost::iterator_range< std::vector< char >::const_iterator > &)> &unpack_callback)
void save_user_flags_hex(std::vector< bool > &v) const
bool all_reference_cells_are_simplex() const
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
unsigned int n_raw_hexs(const unsigned int level) const
unsigned int n_lines(const unsigned int level) const
unsigned int n_active_hexs() const
virtual unsigned int coarse_cell_id_to_coarse_cell_index(const types::coarse_cell_id coarse_cell_id) const
unsigned int n_quads(const unsigned int level) const
void load_user_flags(std::istream &in)
void save_coarsen_flags(std::ostream &out) const
active_face_iterator begin_active_face() const
void clear_user_flags_line()
raw_line_iterator begin_raw_line(const unsigned int level=0) const
static void write_bool_vector(const unsigned int magic_number1, const std::vector< bool > &v, const unsigned int magic_number2, std::ostream &out)
active_cell_iterator begin_active(const unsigned int level=0) const
void execute_coarsening()
void save_refine_flags(std::vector< bool > &v) const
std::vector< char > dest_data_variable
std::vector< char > src_data_fixed
std::vector< char > dest_data_fixed
bool variable_size_data_stored
std::vector< int > src_sizes_variable
std::vector< unsigned int > sizes_fixed_cumulative
typename std::pair< cell_iterator, CellStatus > cell_relation_t
std::vector< int > dest_sizes_variable
std::vector< char > src_data_variable
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
IteratorRange< active_face_iterator > active_face_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
IteratorRange< cell_iterator > cell_iterators() const
#define DeclException0(Exception0)
#define Assert(cond, exc)
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertIndexRange(index, range)
#define DeclExceptionMsg(Exception, defaulttext)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename IteratorSelector::hex_iterator hex_iterator
typename IteratorSelector::active_quad_iterator active_quad_iterator
typename IteratorSelector::active_hex_iterator active_hex_iterator
typename IteratorSelector::quad_iterator quad_iterator
typename IteratorSelector::line_iterator line_iterator
typename IteratorSelector::active_line_iterator active_line_iterator
global_cell_index coarse_cell_id
T operator()(InputIterator first, InputIterator last) const
virtual ~DistortedCellList() noexcept override
boost::signals2::signal< void()> mesh_movement
boost::signals2::signal< void()> post_distributed_load
boost::signals2::signal< void()> pre_distributed_save
boost::signals2::signal< unsigned int(const cell_iterator &, const ::CellStatus), CellWeightSum< unsigned int > > weight
boost::signals2::signal< void(const Triangulation< dim, spacedim > &destination_tria)> copy
boost::signals2::signal< void()> pre_distributed_refinement
boost::signals2::signal< void()> post_distributed_refinement
boost::signals2::signal< void()> pre_refinement
boost::signals2::signal< void()> any_change
boost::signals2::signal< void()> create
boost::signals2::signal< void()> clear
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> post_refinement_on_cell
boost::signals2::signal< void(const typename Triangulation< dim, spacedim >::cell_iterator &cell)> pre_coarsening_on_cell
boost::signals2::signal< void()> post_refinement
boost::signals2::signal< void()> pre_partition
boost::signals2::signal< void()> pre_distributed_repartition
boost::signals2::signal< void()> pre_distributed_load
boost::signals2::signal< void()> post_p4est_refinement
boost::signals2::signal< void()> post_distributed_repartition
boost::signals2::signal< void()> post_distributed_save
std::vector< pack_callback_t > pack_callbacks_variable
unsigned int n_attached_deserialize
std::vector< pack_callback_t > pack_callbacks_fixed
unsigned int n_attached_data_sets
std::function< std::vector< char >(cell_iterator, CellStatus)> pack_callback_t
std::vector< unsigned int > n_lines_level
unsigned int n_active_lines
std::shared_ptr< const Utilities::MPI::Partitioner > active_cell_index_partitioner
void serialize(Archive &ar, const unsigned int version)
std::vector< unsigned int > n_active_lines_level
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > level_cell_index_partitioners
std::vector< unsigned int > n_active_quads_level
unsigned int n_active_quads
void serialize(Archive &ar, const unsigned int version)
std::vector< unsigned int > n_quads_level
unsigned int n_active_hexes
void serialize(Archive &ar, const unsigned int version)
std::vector< unsigned int > n_hexes_level
std::vector< unsigned int > n_active_hexes_level