13#ifndef dealii_dof_handler_h
14#define dealii_dof_handler_h
37#include <boost/serialization/split_member.hpp>
38#include <boost/signals2/connection.hpp>
49template <
int dim,
int spacedim>
51template <
int dim,
int spacedim>
57 namespace DoFHandlerImplementation
59 struct Implementation;
63 template <
int dim,
int spacedim>
65 struct Implementation;
69 namespace DoFAccessorImplementation
71 struct Implementation;
74 namespace DoFCellAccessorImplementation
76 struct Implementation;
81 namespace DoFHandlerImplementation
83 struct Implementation;
92 template <
int dim,
int spacedim,
typename VectorType>
97template <
int structdim,
int dim,
int spacedim,
bool level_dof_access>
100template <
int dimension_,
int space_dimension_,
bool level_dof_access>
321template <
int dim,
int spacedim = dim>
598 std::vector<types::fe_index>
627 std::vector<types::fe_index>
725 DEAL_II_DEPRECATED_EARLY_WITH_COMMENT(
"Use an external BlockInfo instead.")
727 initialize_local_block_info();
788 renumber_dofs(const
std::vector<
types::global_dof_index> &new_numbers);
795 renumber_dofs(const
unsigned int level,
796 const
std::vector<
types::global_dof_index> &new_numbers);
827 max_couplings_between_dofs() const;
842 max_couplings_between_boundary_dofs() const;
875 begin_active(const
unsigned int level = 0) const;
897 end_active(const
unsigned int level) const;
904 begin_mg(const
unsigned int level = 0) const;
911 end_mg(const
unsigned int level) const;
937 cell_iterators() const;
980 active_cell_iterators() const;
994 mg_cell_iterators() const;
1012 cell_iterators_on_level(const
unsigned int level) const;
1030 active_cell_iterators_on_level(const
unsigned int level) const;
1048 mg_cell_iterators_on_level(const
unsigned int level) const;
1079 types::global_dof_index
1089 types::global_dof_index
1096 types::global_dof_index
1097 n_boundary_dofs() const;
1110 template <typename number>
1111 types::global_dof_index
1114 &boundary_ids) const;
1120 types::global_dof_index
1121 n_boundary_dofs(const
std::
set<
types::boundary_id> &boundary_ids) const;
1140 DEAL_II_DEPRECATED_EARLY_WITH_COMMENT("Use an external
BlockInfo instead.")
1163 types::global_dof_index
1164 n_locally_owned_dofs() const;
1179 locally_owned_dofs() const;
1186 locally_owned_mg_dofs(const
unsigned int level) const;
1200 get_fe_collection() const;
1206 get_triangulation() const;
1212 get_mpi_communicator() const;
1231 prepare_for_serialization_of_active_fe_indices();
1249 deserialize_active_fe_indices();
1260 memory_consumption() const;
1267 template <class Archive>
1269 save(Archive &ar, const
unsigned int version) const;
1276 template <class Archive>
1278 load(Archive &ar, const
unsigned int version);
1286 template <
class Archive>
1292 BOOST_SERIALIZATION_SPLIT_MEMBER()
1310 <<
"The given level " << arg1
1311 <<
" is not in the valid range!");
1318 <<
"The given list of new dof indices is not consecutive: "
1319 <<
"the index " << arg1 <<
" does not exist.");
1326 <<
"The mesh contains a cell with an active FE index of "
1327 << arg1 <<
", but the finite element collection only has "
1328 << arg2 <<
" elements");
1335 "The current function doesn't make sense when used with a "
1336 "DoFHandler without hp-capabilities.");
1343 "The current function has not yet been implemented for a "
1344 "DoFHandler with hp-capabilities.");
1367 init(
const unsigned int coarsest_level,
1368 const unsigned int finest_level,
1369 const unsigned int dofs_per_vertex);
1389 const unsigned int dof_number,
1390 const unsigned int dofs_per_vertex);
1412 std::unique_ptr<types::global_dof_index[]>
indices;
1427 std::vector<std::pair<const cell_iterator, const types::fe_index>>
1434 std::vector<std::pair<const cell_iterator, const types::fe_index>>
1441 std::map<const cell_iterator, const types::fe_index>
1457 parallel::distributed::
1458 CellDataTransfer<dim, spacedim, std::vector<types::fe_index>>>
1496 std::unique_ptr<::internal::DoFHandlerImplementation::Policy::
1497 PolicyBase<dim, spacedim>>
1512 std::vector<::internal::DoFHandlerImplementation::NumberCache>
1520 mutable std::vector<std::array<std::vector<types::global_dof_index>, dim + 1>>
1531 mutable std::vector<std::array<std::vector<offset_type>, dim + 1>>
1539 mutable std::array<std::vector<types::fe_index>, dim + 1>
1569 std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim>>>
1575 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim>>
1697 template <
int,
int,
int,
bool>
1698 friend class ::DoFAccessor;
1699 template <
int,
int,
bool>
1700 friend class ::DoFCellAccessor;
1701 friend struct ::internal::DoFAccessorImplementation::Implementation;
1702 friend struct ::internal::DoFCellAccessorImplementation::Implementation;
1706 friend struct ::internal::DoFHandlerImplementation::Implementation;
1707 friend struct ::internal::hp::DoFHandlerImplementation::Implementation;
1708 friend struct ::internal::DoFHandlerImplementation::Policy::
1714 static_assert(dim <= spacedim,
1715 "The dimension <dim> of a DoFHandler must be less than or "
1716 "equal to the space dimension <spacedim> in which it lives.");
1724 namespace DoFHandlerImplementation
1737 template <
int dim,
int spacedim>
1765 template <
int dim,
int spacedim = dim>
1775 "No FiniteElement has been found in your FECollection that is "
1776 "dominated by all children of a cell you are trying to coarsen!");
1787template <
int dim,
int spacedim>
1791 return hp_capability_enabled;
1796template <
int dim,
int spacedim>
1800 return mg_number_cache.size() > 0;
1805template <
int dim,
int spacedim>
1809 return number_cache.n_global_dofs > 0;
1814template <
int dim,
int spacedim>
1818 return number_cache.n_global_dofs;
1823template <
int dim,
int spacedim>
1830 "n_dofs(level) can only be called after distribute_mg_dofs()"));
1832 return mg_number_cache[
level].n_global_dofs;
1837template <
int dim,
int spacedim>
1842 return number_cache.n_locally_owned_dofs;
1847template <
int dim,
int spacedim>
1851 return number_cache.locally_owned_dofs;
1856template <
int dim,
int spacedim>
1859 const unsigned int level)
const
1861 Assert(level < this->get_triangulation().n_global_levels(),
1862 ExcMessage(
"The given level index exceeds the number of levels "
1863 "present in the triangulation"));
1865 mg_number_cache.size() == this->get_triangulation().n_global_levels(),
1867 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1868 return mg_number_cache[
level].locally_owned_dofs;
1873template <
int dim,
int spacedim>
1878 Assert(fe_collection.size() > 0,
1879 ExcMessage(
"No finite element collection is associated with "
1880 "this DoFHandler"));
1881 return fe_collection[number];
1886template <
int dim,
int spacedim>
1891 return fe_collection;
1896template <
int dim,
int spacedim>
1902 ExcMessage(
"This DoFHandler object has not been associated "
1903 "with a triangulation."));
1909template <
int dim,
int spacedim>
1914 ExcMessage(
"This DoFHandler object has not been associated "
1915 "with a triangulation."));
1916 return tria->get_mpi_communicator();
1921template <
int dim,
int spacedim>
1925 return block_info_object.value_or_initialize(
1926 [&,
this]() {
return this->compute_block_info(); });
1931template <
int dim,
int spacedim>
1933template <
typename number>
1936 &boundary_ids)
const
1938 Assert(!(dim == 2 && spacedim == 3) || this->hp_capability_enabled ==
false,
1939 ExcNotImplementedWithHP());
1943 std::set<types::boundary_id> boundary_ids_only;
1946 boundary_ids.begin();
1947 p != boundary_ids.end();
1949 boundary_ids_only.insert(p->first);
1952 return n_boundary_dofs(boundary_ids_only);
1966 template <
int dim,
int spacedim>
1969 PolicyBase<dim, spacedim> &policy);
1974template <
int dim,
int spacedim>
1976template <
class Archive>
1979 if (this->hp_capability_enabled)
1981 ar &this->object_dof_indices;
1982 ar &this->object_dof_ptr;
1984 ar &this->hp_cell_active_fe_indices;
1985 ar &this->hp_cell_future_fe_indices;
1987 ar &hp_object_fe_ptr;
1988 ar &hp_object_fe_indices;
1992 ar &mg_number_cache;
1997 const unsigned int n_cells = this->tria->n_cells();
1998 std::string policy_name =
2008 ar &this->object_dof_indices;
2009 ar &this->object_dof_ptr;
2014 unsigned int n_cells = this->tria->n_cells();
2015 std::string fe_name = this->get_fe(0).get_name();
2018 ar &
n_cells &fe_name &policy_name;
2024template <
int dim,
int spacedim>
2026template <
class Archive>
2029 if (this->hp_capability_enabled)
2031 ar &this->object_dof_indices;
2032 ar &this->object_dof_ptr;
2034 ar &this->hp_cell_active_fe_indices;
2035 ar &this->hp_cell_future_fe_indices;
2037 ar &hp_object_fe_ptr;
2038 ar &hp_object_fe_indices;
2042 ar &mg_number_cache;
2047 std::string policy_name;
2052 n_cells == this->tria->n_cells(),
2054 "The object being loaded into does not match the triangulation "
2055 "that has been stored previously."));
2058 ExcMessage(
"The policy currently associated with this DoFHandler (" +
2060 ") does not match the one that was associated with the "
2061 "DoFHandler previously stored (" +
2062 policy_name +
")."));
2069 object_dof_indices.clear();
2071 object_dof_ptr.clear();
2073 ar &this->object_dof_indices;
2074 ar &this->object_dof_ptr;
2079 std::string fe_name;
2080 std::string policy_name;
2082 ar &
n_cells &fe_name &policy_name;
2085 n_cells == this->tria->n_cells(),
2087 "The object being loaded into does not match the triangulation "
2088 "that has been stored previously."));
2090 fe_name == this->get_fe(0).get_name(),
2092 "The finite element associated with this DoFHandler does not match "
2093 "the one that was associated with the DoFHandler previously stored."));
2096 "The policy currently associated with this DoFHandler (" +
2098 ") does not match the one that was associated with the "
2099 "DoFHandler previously stored (" +
2100 policy_name +
")."));
2106template <
int dim,
int spacedim>
2110 const unsigned int level,
2111 const unsigned int dof_number,
2112 const unsigned int dofs_per_vertex)
2131# ifndef DEAL_II_BUILDING_CXX20_MODULE
* x_component_mask set(0, true)
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
static constexpr unsigned int space_dimension
static constexpr unsigned int dimension
const FiniteElement< dimension_, space_dimension_ > & get_fe() const
static const unsigned int dim
static const unsigned int spacedim
unsigned int coarsest_level
types::global_dof_index & access_index(const unsigned int level, const unsigned int dof_number, const unsigned int dofs_per_vertex)
void init(const unsigned int coarsest_level, const unsigned int finest_level, const unsigned int dofs_per_vertex)
unsigned int get_finest_level() const
std::unique_ptr< types::global_dof_index[]> indices
unsigned int finest_level
unsigned int get_coarsest_level() const
void pre_distributed_transfer_action()
void post_transfer_action()
std::vector< types::fe_index > get_future_fe_indices() const
std::vector< std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel< dim > > > mg_levels
std::unique_ptr< ActiveFEIndexTransfer > active_fe_index_transfer
hp::FECollection< dim, spacedim > fe_collection
void create_active_fe_table()
std::vector< std::vector< types::fe_index > > hp_cell_future_fe_indices
const hp::FECollection< dim, spacedim > & get_fe_collection() const
void save(Archive &ar, const unsigned int version) const
bool has_active_dofs() const
std::vector< boost::signals2::connection > tria_listeners_for_transfer
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
types::global_dof_index n_boundary_dofs() const
DoFHandler(const Triangulation< dim, spacedim > &tria)
void connect_to_triangulation_signals()
std::vector< std::vector< types::fe_index > > hp_cell_active_fe_indices
std::vector< MGVertexDoFs > mg_vertex_dofs
std::vector< boost::signals2::connection > tria_listeners
void post_distributed_transfer_action()
std::vector< std::array< std::vector< types::global_dof_index >, dim+1 > > object_dof_indices
const Triangulation< dim, spacedim > & get_triangulation() const
typename LevelSelector::CellAccessor level_cell_accessor
void pre_transfer_action()
BlockInfo compute_block_info() const
const IndexSet & locally_owned_dofs() const
void reinit(const Triangulation< dim, spacedim > &tria)
std::vector< std::array< std::vector< offset_type >, dim+1 > > object_dof_ptr
std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces< dim > > mg_faces
void serialize(Archive &archive, const unsigned int version)
DoFHandler & operator=(const DoFHandler &)=delete
DoFHandler(const DoFHandler &)=delete
std::vector< types::fe_index > get_active_fe_indices() const
void distribute_mg_dofs()
bool hp_capability_enabled
bool has_hp_capabilities() const
types::global_dof_index n_dofs() const
void update_active_fe_table()
Lazy< BlockInfo > block_info_object
typename LevelSelector::cell_iterator level_cell_iterator
std::vector<::internal::DoFHandlerImplementation::NumberCache > mg_number_cache
void load(Archive &ar, const unsigned int version)
typename LevelSelector::face_iterator level_face_iterator
MPI_Comm get_mpi_communicator() const
std::array< std::vector< offset_type >, dim+1 > hp_object_fe_ptr
void distribute_dofs(const hp::FECollection< dim, spacedim > &fe)
ObserverPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
bool has_level_dofs() const
std::unique_ptr<::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > > policy
typename LevelSelector::FaceAccessor level_face_accessor
std::array< std::vector< types::fe_index >, dim+1 > hp_object_fe_indices
void set_active_fe_indices(const std::vector< types::fe_index > &active_fe_indices)
types::global_dof_index n_locally_owned_dofs() const
const BlockInfo & block_info() const
::internal::DoFHandlerImplementation::NumberCache number_cache
void set_future_fe_indices(const std::vector< types::fe_index > &future_fe_indices)
virtual ~DoFHandler() override
#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 DeclExceptionMsg(Exception, defaulttext)
static ::ExceptionBase & ExcNoDominatedFiniteElementOnChildren()
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcInvalidLevel(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
typename ActiveSelector::FaceAccessor face_accessor
typename ActiveSelector::cell_iterator cell_iterator
typename ActiveSelector::line_iterator line_iterator
typename ActiveSelector::face_iterator face_iterator
typename ActiveSelector::active_line_iterator active_line_iterator
typename ActiveSelector::active_cell_iterator active_cell_iterator
typename ActiveSelector::CellAccessor cell_accessor
typename ActiveSelector::quad_iterator quad_iterator
typename ActiveSelector::active_hex_iterator active_hex_iterator
typename ActiveSelector::active_quad_iterator active_quad_iterator
typename ActiveSelector::hex_iterator hex_iterator
typename ActiveSelector::active_face_iterator active_face_iterator
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
unsigned int dominated_future_fe_on_children(const typename DoFHandler< dim, spacedim >::cell_iterator &parent)
void communicate_future_fe_indices(DoFHandler< dim, spacedim > &dof_handler)
std::string policy_to_string(const ::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > &policy)
unsigned short int fe_index
std::vector< std::pair< const cell_iterator, const types::fe_index > > refined_cells_fe_index
std::vector< std::pair< const cell_iterator, const types::fe_index > > persisting_cells_fe_index
std::vector< types::fe_index > active_fe_indices
std::map< const cell_iterator, const types::fe_index > coarsened_cells_fe_index
std::unique_ptr< parallel::distributed::CellDataTransfer< dim, spacedim, std::vector< types::fe_index > > > cell_data_transfer