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;
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;
3324 virtual unsigned int
3357 const std::vector<Point<spacedim>> &
3377 const std::vector<bool> &
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>>> &
3599 const std::vector<ReferenceCell> &
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!");
3754 const std::vector<bool> &v,
3755 const unsigned int magic_number2,
3756 std::ostream & out);
3764 std::vector<bool> &v,
3765 const unsigned int magic_number2,
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>>>
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>
4312 NumberCache<1>::serialize(Archive &ar,
const unsigned int)
4315 ar &n_lines &n_lines_level;
4316 ar &n_active_lines &n_active_lines_level;
4320 template <
class Archive>
4322 NumberCache<2>::serialize(Archive &ar,
const unsigned int version)
4324 this->NumberCache<1>::serialize(ar, version);
4326 ar &n_quads &n_quads_level;
4327 ar &n_active_quads &n_active_quads_level;
4331 template <
class Archive>
4333 NumberCache<3>::serialize(Archive &ar,
const unsigned int version)
4335 this->NumberCache<2>::serialize(ar, version);
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)
boost::signals2::slot< signature_type, slot_function_type > slot_type
std::size_t num_slots() const
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)
unsigned int(const cell_iterator &, const CellStatus) signature_type
boost::signals2::connection base_weight
void disconnect(const S &connection)
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
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
void save_user_flags_line(std::ostream &out) const
active_cell_iterator last_active() const
void save(Archive &ar, const unsigned int version) const
const Triangulation< dim, spacedim > & get_triangulation() const
void reset_global_cell_indices()
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
std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > periodic_face_map
unsigned int n_active_cells(const unsigned int level) const
const std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > & get_periodic_face_map() 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)
::internal::TriangulationImplementation::NumberCache< dim > number_cache
void load_user_flags_quad(const std::vector< bool > &v)
void load_user_flags_line(const std::vector< bool > &v)
void save_user_indices_hex(std::vector< unsigned int > &v) const
DistortedCellList execute_refinement()
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
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
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
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 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
#define DEAL_II_DEPRECATED
#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)
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