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>
1134template <
int dim,
int spacedim = dim>
1201 limit_level_difference_at_vertices = 0x1,
1222 eliminate_unrefined_islands = 0x2,
1238 patch_level_1 = 0x4,
1262 coarsest_level_1 = 0x8,
1287 allow_anisotropic_smoothing = 0x10,
1320 eliminate_refined_inner_islands = 0x100,
1325 eliminate_refined_boundary_islands = 0x200,
1331 do_not_produce_unrefined_islands = 0x400,
1337 smoothing_on_refinement =
1338 (limit_level_difference_at_vertices | eliminate_unrefined_islands),
1343 smoothing_on_coarsening =
1344 (eliminate_refined_inner_islands | eliminate_refined_boundary_islands |
1345 do_not_produce_unrefined_islands),
1352 maximum_smoothing = 0xffff ^ allow_anisotropic_smoothing
1557 static constexpr
unsigned int dimension = dim;
1562 static constexpr
unsigned int space_dimension = spacedim;
1579 const
bool check_for_distorted_cells = false);
1631 get_communicator() const;
1638 virtual const
std::weak_ptr<const
Utilities::MPI::Partitioner>
1639 global_active_cell_index_partitioner() const;
1646 virtual const
std::weak_ptr<const
Utilities::MPI::Partitioner>
1647 global_level_cell_index_partitioner(const
unsigned int level) const;
1661 get_mesh_smoothing() const;
1686 set_manifold(const
types::manifold_id number,
1687 const
Manifold<dim, spacedim> &manifold_object);
1702 reset_manifold(const
types::manifold_id manifold_number);
1716 reset_all_manifolds();
1727 set_all_manifold_ids(const
types::manifold_id number);
1738 set_all_manifold_ids_on_boundary(const
types::manifold_id number);
1750 set_all_manifold_ids_on_boundary(const
types::boundary_id b_id,
1751 const
types::manifold_id number);
1765 get_manifold(const
types::manifold_id number) const;
1779 virtual
std::vector<
types::boundary_id>
1780 get_boundary_ids() const;
1794 virtual
std::vector<
types::manifold_id>
1795 get_manifold_ids() const;
1824 copy_triangulation(const
Triangulation<dim, spacedim> &other_tria);
1891 create_triangulation(
1893 &construction_data);
1905 create_triangulation_compatibility(
1917 flip_all_direction_flags();
1931 set_all_refine_flags();
1956 refine_global(const
unsigned int times = 1);
1971 coarsen_global(const
unsigned int times = 1);
2005 execute_coarsening_and_refinement();
2037 prepare_coarsening_and_refinement();
2082 template <
typename T>
2087 template <
typename InputIterator>
2091 return std::accumulate(
first, last, T());
2155 boost::signals2::signal<void(
2165 boost::signals2::signal<void(
2175 boost::signals2::signal<void(
2251 : cell_weight(weight)
2266 boost::signals2::slot<signature_type, slot_function_type>;
2272 boost::signals2::signal<signature_type, combiner_type> &new_signal)
2273 : new_signal(new_signal)
2281 base_weight.disconnect();
2291 boost::signals2::connection
2294 boost::signals2::connect_position position = boost::signals2::at_back)
2296 if (base_weight.connected() ==
false)
2298 base_weight = new_signal.connect(
2302 Assert(base_weight.connected() && new_signal.num_slots() == 1,
2306 return new_signal.connect(slot, position);
2317 return new_signal.num_slots() -
2318 static_cast<std::size_t
>(base_weight.connected());
2328 if (num_slots() == 0)
2342 template <
typename S>
2346 new_signal.disconnect(connection);
2348 if (num_slots() == 0)
2350 Assert(base_weight.connected() && new_signal.num_slots() == 1,
2352 new_signal.disconnect(base_weight);
2363 return new_signal(iterator, status);
2375 boost::signals2::signal<signature_type, combiner_type> &
new_signal;
2495 save_refine_flags(std::ostream &out)
const;
2501 save_refine_flags(std::vector<bool> &v)
const;
2507 load_refine_flags(std::istream &in);
2513 load_refine_flags(
const std::vector<bool> &v);
2519 save_coarsen_flags(std::ostream &out)
const;
2525 save_coarsen_flags(std::vector<bool> &v)
const;
2531 load_coarsen_flags(std::istream &out);
2537 load_coarsen_flags(
const std::vector<bool> &v);
2544 get_anisotropic_refinement_flag()
const;
2568 save_user_flags(std::ostream &out)
const;
2576 save_user_flags(std::vector<bool> &v)
const;
2583 load_user_flags(std::istream &in);
2590 load_user_flags(
const std::vector<bool> &v);
2597 clear_user_flags_line();
2604 save_user_flags_line(std::ostream &out)
const;
2612 save_user_flags_line(std::vector<bool> &v)
const;
2619 load_user_flags_line(std::istream &in);
2626 load_user_flags_line(
const std::vector<bool> &v);
2633 clear_user_flags_quad();
2640 save_user_flags_quad(std::ostream &out)
const;
2648 save_user_flags_quad(std::vector<bool> &v)
const;
2655 load_user_flags_quad(std::istream &in);
2662 load_user_flags_quad(
const std::vector<bool> &v);
2670 clear_user_flags_hex();
2677 save_user_flags_hex(std::ostream &out)
const;
2685 save_user_flags_hex(std::vector<bool> &v)
const;
2692 load_user_flags_hex(std::istream &in);
2699 load_user_flags_hex(
const std::vector<bool> &v);
2715 save_user_indices(std::vector<unsigned int> &v)
const;
2722 load_user_indices(
const std::vector<unsigned int> &v);
2730 save_user_pointers(std::vector<void *> &v)
const;
2737 load_user_pointers(
const std::vector<void *> &v);
2745 save_user_indices_line(std::vector<unsigned int> &v)
const;
2752 load_user_indices_line(
const std::vector<unsigned int> &v);
2760 save_user_indices_quad(std::vector<unsigned int> &v)
const;
2767 load_user_indices_quad(
const std::vector<unsigned int> &v);
2775 save_user_indices_hex(std::vector<unsigned int> &v)
const;
2782 load_user_indices_hex(
const std::vector<unsigned int> &v);
2789 save_user_pointers_line(std::vector<void *> &v)
const;
2796 load_user_pointers_line(
const std::vector<void *> &v);
2804 save_user_pointers_quad(std::vector<void *> &v)
const;
2811 load_user_pointers_quad(
const std::vector<void *> &v);
2819 save_user_pointers_hex(std::vector<void *> &v)
const;
2826 load_user_pointers_hex(
const std::vector<void *> &v);
2855 begin(
const unsigned int level = 0)
const;
2888 begin_active(
const unsigned int level = 0)
const;
2916 end(
const unsigned int level)
const;
2938 end_active(
const unsigned int level)
const;
2951 last_active()
const;
2966 create_cell_iterator(
const CellId &cell_id)
const;
2983 cell_iterators()
const;
3021 active_cell_iterators()
const;
3039 cell_iterators_on_level(
const unsigned int level)
const;
3057 active_cell_iterators_on_level(
const unsigned int level)
const;
3080 begin_active_face()
const;
3108 active_face_iterators()
const;
3126 begin_vertex()
const;
3134 begin_active_vertex()
const;
3172 n_lines(
const unsigned int level)
const;
3178 n_active_lines()
const;
3184 n_active_lines(
const unsigned int level)
const;
3196 n_quads(
const unsigned int level)
const;
3202 n_active_quads()
const;
3208 n_active_quads(
const unsigned int level)
const;
3221 n_hexs(
const unsigned int level)
const;
3227 n_active_hexs()
const;
3234 n_active_hexs(
const unsigned int level)
const;
3248 n_cells(
const unsigned int level)
const;
3255 n_active_cells()
const;
3265 n_global_active_cells()
const;
3273 n_active_cells(
const unsigned int level)
const;
3280 n_global_coarse_cells()
const;
3296 n_active_faces()
const;
3324 virtual unsigned int
3337 has_hanging_nodes()
const;
3357 const std::vector<Point<spacedim>> &
3365 n_used_vertices()
const;
3377 const std::vector<bool> &
3378 get_used_vertices()
const;
3392 max_adjacent_cells()
const;
3401 locally_owned_subdomain()
const;
3413 get_triangulation();
3420 get_triangulation()
const;
3442 n_raw_lines()
const;
3454 n_raw_lines(
const unsigned int level)
const;
3466 n_raw_quads()
const;
3490 n_raw_hexs(
const unsigned int level)
const;
3502 n_raw_cells(
const unsigned int level)
const;
3516 n_raw_faces()
const;
3531 memory_consumption()
const;
3542 template <
class Archive>
3544 save(Archive &ar,
const unsigned int version)
const;
3563 template <
class Archive>
3565 load(Archive &ar,
const unsigned int version);
3591 std::pair<cell_iterator, unsigned int>,
3592 std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>> &
3593 get_periodic_face_map()
const;
3599 const std::vector<ReferenceCell> &
3600 get_reference_cells()
const;
3607 all_reference_cells_are_hyper_cube()
const;
3614 all_reference_cells_are_simplex()
const;
3622 is_mixed_mesh()
const;
3630 template <
class Archive>
3636 BOOST_SERIALIZATION_SPLIT_MEMBER()
3652 <<
"You are requesting information from refinement level "
3654 <<
" of a triangulation, but this triangulation only has "
3655 << arg2 <<
" refinement levels. The given level " << arg1
3656 <<
" must be *less* than " << arg2 <<
'.');
3664 ExcTriangulationNotEmpty,
3667 <<
"You are trying to perform an operation on a triangulation "
3668 <<
"that is only allowed if the triangulation is currently empty. "
3669 <<
"However, it currently stores " << arg1 <<
" vertices and has "
3670 <<
"cells on " << arg2 <<
" levels.");
3689 <<
"You tried to do something on level " << arg1
3690 <<
", but this level is empty.");
3707 <<
"The given boundary_id " << arg1
3708 <<
" is not defined in this Triangulation!");
3716 ExcInconsistentCoarseningFlags,
3717 "A cell is flagged for coarsening, but either not all of its siblings "
3718 "are active or flagged for coarsening as well. Please clean up all "
3719 "coarsen flags on your triangulation via "
3720 "Triangulation::prepare_coarsening_and_refinement() beforehand!");
3753 write_bool_vector(
const unsigned int magic_number1,
3754 const std::vector<bool> &v,
3755 const unsigned int magic_number2,
3756 std::ostream & out);
3763 read_bool_vector(
const unsigned int magic_number1,
3764 std::vector<bool> &v,
3765 const unsigned int magic_number2,
3773 update_periodic_face_map();
3779 update_reference_cells();
3797 std::vector<GridTools::PeriodicFacePair<cell_iterator>>
3804 std::map<std::pair<cell_iterator, unsigned int>,
3805 std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3>>>
3835 begin_raw(
const unsigned int level = 0)
const;
3842 end_raw(
const unsigned int level)
const;
3860 begin_raw_line(
const unsigned int level = 0)
const;
3880 begin_line(
const unsigned int level = 0)
const;
3900 begin_active_line(
const unsigned int level = 0)
const;
3938 begin_raw_quad(
const unsigned int level = 0)
const;
3958 begin_quad(
const unsigned int level = 0)
const;
3978 begin_active_quad(
const unsigned int level = 0)
const;
4015 begin_raw_hex(
const unsigned int level = 0)
const;
4035 begin_hex(
const unsigned int level = 0)
const;
4055 begin_active_hex(
const unsigned int level = 0)
const;
4083 clear_despite_subscriptions();
4098 reset_active_cell_indices();
4104 reset_global_cell_indices();
4110 reset_cell_vertex_indices_cache();
4126 execute_refinement();
4135 execute_coarsening();
4142 fix_coarsen_flags();
4157 virtual unsigned int
4176 const unsigned int coarse_cell_index)
const;
4183 std::unique_ptr<::internal::TriangulationImplementation::TriaLevel>>
4191 std::unique_ptr<::internal::TriangulationImplementation::TriaFaces>
4209 std::map<types::manifold_id, std::unique_ptr<const Manifold<dim, spacedim>>>
4249 std::unique_ptr<std::map<unsigned int, types::boundary_id>>
4272 std::unique_ptr<std::map<unsigned int, types::manifold_id>>
4276 template <
int,
int,
int>
4278 template <
int,
int,
int>
4284 friend struct ::internal::TriaAccessorImplementation::Implementation;
4286 friend struct ::internal::TriangulationImplementation::Implementation;
4287 friend struct ::internal::TriangulationImplementation::
4288 ImplementationMixedMesh;
4290 friend class ::internal::TriangulationImplementation::TriaObjects;
4295 static_assert(dim <= spacedim,
4296 "The dimension <dim> of a Triangulation must be less than or "
4297 "equal to the space dimension <spacedim> in which it lives.");
4308 namespace TriangulationImplementation
4310 template <
class Archive>
4315 ar &n_lines &n_lines_level;
4316 ar &n_active_lines &n_active_lines_level;
4320 template <
class Archive>
4326 ar &n_quads &n_quads_level;
4327 ar &n_active_quads &n_active_quads_level;
4331 template <
class Archive>
4337 ar &n_hexes &n_hexes_level;
4338 ar &n_active_hexes &n_active_hexes_level;
4345template <
int dim,
int spacedim>
4348 const unsigned int index)
const
4351 return vertices_used[
index];
4356template <
int dim,
int spacedim>
4360 return number_cache.n_levels;
4363template <
int dim,
int spacedim>
4367 return number_cache.n_levels;
4371template <
int dim,
int spacedim>
4380template <
int dim,
int spacedim>
4382inline const std::vector<Point<spacedim>>
4389template <
int dim,
int spacedim>
4391template <
class Archive>
4398 unsigned int n_levels = levels.size();
4400 for (
const auto &
level : levels)
4406 bool faces_is_nullptr = (faces.get() ==
nullptr);
4407 ar & faces_is_nullptr;
4408 if (!faces_is_nullptr)
4414 ar &anisotropic_refinement;
4417 ar &check_for_distorted_cells;
4421 ar &vertex_to_boundary_id_map_1d;
4422 ar &vertex_to_manifold_id_map_1d;
4428template <
int dim,
int spacedim>
4430template <
class Archive>
4442 levels.resize(size);
4443 for (
auto &level_ : levels)
4445 std::unique_ptr<internal::TriangulationImplementation::TriaLevel>
level;
4447 level_ = std::move(
level);
4451 bool faces_is_nullptr =
true;
4452 ar & faces_is_nullptr;
4453 if (!faces_is_nullptr)
4459 ar &anisotropic_refinement;
4466 for (
auto &
level : levels)
4468 level->active_cell_indices.resize(
level->refine_flags.size());
4469 level->global_active_cell_indices.resize(
level->refine_flags.size());
4470 level->global_level_cell_indices.resize(
level->refine_flags.size());
4472 reset_cell_vertex_indices_cache();
4473 reset_active_cell_indices();
4474 reset_global_cell_indices();
4479 bool my_check_for_distorted_cells;
4480 ar & my_check_for_distorted_cells;
4482 Assert(my_check_for_distorted_cells == check_for_distorted_cells,
4483 ExcMessage(
"The triangulation loaded into here must have the "
4484 "same setting with regard to reporting distorted "
4485 "cell as the one previously stored."));
4489 ar &vertex_to_boundary_id_map_1d;
4490 ar &vertex_to_manifold_id_map_1d;
4501template <
int dim,
int spacedim>
4512template <
int dim,
int spacedim>
4516 const unsigned int coarse_cell_index)
const
4518 return coarse_cell_index;
unsigned int operator()(const cell_iterator &iterator, const CellStatus status)
std::size_t num_slots() const
unsigned int(const cell_iterator &, const CellStatus) signature_type
boost::signals2::slot< signature_type, slot_function_type > slot_type
boost::function< signature_type > slot_function_type
boost::signals2::connection connect(const slot_type &slot, boost::signals2::connect_position position=boost::signals2::at_back)
boost::signals2::signal< signature_type, combiner_type > & new_signal
LegacySignal(boost::signals2::signal< signature_type, combiner_type > &new_signal)
boost::signals2::connection base_weight
void disconnect(const S &connection)
typename IteratorSelector::raw_line_iterator raw_line_iterator
unsigned int n_quads() const
std::vector< bool > vertices_used
bool anisotropic_refinement
std::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
void save(Archive &ar, const unsigned int version) const
std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > periodic_face_map
std::vector< Point< spacedim > > vertices
const bool check_for_distorted_cells
std::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
std::vector< ReferenceCell > reference_cells
const std::vector< Point< spacedim > > & get_vertices() const
std::unique_ptr<::internal::TriangulationImplementation::TriaFaces > faces
unsigned int n_levels() const
typename IteratorSelector::raw_quad_iterator raw_quad_iterator
::internal::TriangulationImplementation::NumberCache< dim > number_cache
std::vector< GridTools::PeriodicFacePair< cell_iterator > > periodic_face_pairs_level_0
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
unsigned int max_adjacent_cells() const
unsigned int n_hexs() const
bool vertex_used(const unsigned int index) const
virtual unsigned int n_global_levels() const
unsigned int n_active_quads() const
virtual bool prepare_coarsening_and_refinement()
unsigned int n_raw_quads() const
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)
MeshSmoothing smooth_grid
std::unique_ptr< ::internal::TriangulationImplementation::Policy< dim, spacedim > > policy
unsigned int n_vertices() const
void load(Archive &ar, const unsigned int version)
std::vector< std::unique_ptr<::internal::TriangulationImplementation::TriaLevel > > levels
unsigned int n_raw_hexs(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
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
#define Assert(cond, exc)
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertIndexRange(index, range)
#define DeclExceptionMsg(Exception, defaulttext)
static ::ExceptionBase & ExcInternalError()
#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< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > weight
boost::signals2::signal< void()> mesh_movement
boost::signals2::signal< void()> post_distributed_load
boost::signals2::signal< void()> pre_distributed_save
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< 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
const ::Triangulation< dim, spacedim > & tria