13#ifndef dealii_dof_handler_h
14#define dealii_dof_handler_h
36#include <boost/serialization/split_member.hpp>
37#include <boost/signals2/connection.hpp>
48template <
int dim,
int spacedim>
50template <
int dim,
int spacedim>
62 template <
int dim,
int spacedim>
91 template <
int dim,
int spacedim,
typename VectorType>
96template <
int structdim,
int dim,
int spacedim,
bool level_dof_access>
99template <
int dimension_,
int space_dimension_,
bool level_dof_access>
320template <
int dim,
int spacedim = dim>
606 std::vector<types::fe_index>
635 std::vector<types::fe_index>
801 const std::vector<types::global_dof_index> &new_numbers);
861 begin(
const unsigned int level = 0)
const;
894 end(
const unsigned int level)
const;
1115 template <
typename number>
1119 &boundary_ids)
const;
1215 "Access the MPI communicator with get_mpi_communicator() instead.")
1272 template <class Archive>
1274 save(Archive &ar, const
unsigned int version) const;
1281 template <class Archive>
1283 load(Archive &ar, const
unsigned int version);
1291 template <
class Archive>
1297 BOOST_SERIALIZATION_SPLIT_MEMBER()
1315 <<
"The given level " << arg1
1316 <<
" is not in the valid range!");
1323 <<
"The given list of new dof indices is not consecutive: "
1324 <<
"the index " << arg1 <<
" does not exist.");
1331 <<
"The mesh contains a cell with an active FE index of "
1332 << arg1 <<
", but the finite element collection only has "
1333 << arg2 <<
" elements");
1340 "The current function doesn't make sense when used with a "
1341 "DoFHandler without hp-capabilities.");
1348 "The current function has not yet been implemented for a "
1349 "DoFHandler with hp-capabilities.");
1374 const unsigned int dofs_per_vertex);
1394 const unsigned int dof_number,
1395 const unsigned int dofs_per_vertex);
1417 std::unique_ptr<types::global_dof_index[]>
indices;
1432 std::vector<std::pair<const cell_iterator, const types::fe_index>>
1439 std::vector<std::pair<const cell_iterator, const types::fe_index>>
1446 std::map<const cell_iterator, const types::fe_index>
1462 parallel::distributed::
1463 CellDataTransfer<dim, spacedim, std::vector<types::fe_index>>>
1495 std::unique_ptr<::internal::DoFHandlerImplementation::Policy::
1496 PolicyBase<dim, spacedim>>
1511 std::vector<::internal::DoFHandlerImplementation::NumberCache>
1519 mutable std::vector<std::array<std::vector<types::global_dof_index>, dim + 1>>
1530 mutable std::vector<std::array<std::vector<offset_type>, dim + 1>>
1538 mutable std::array<std::vector<types::fe_index>, dim + 1>
1568 std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim>>>
1574 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim>>
1696 template <
int,
int,
int,
bool>
1697 friend class ::DoFAccessor;
1698 template <
int,
int,
bool>
1699 friend class ::DoFCellAccessor;
1700 friend struct ::internal::DoFAccessorImplementation::Implementation;
1701 friend struct ::internal::DoFCellAccessorImplementation::Implementation;
1705 friend struct ::internal::DoFHandlerImplementation::Implementation;
1706 friend struct ::internal::hp::DoFHandlerImplementation::Implementation;
1707 friend struct ::internal::DoFHandlerImplementation::Policy::
1713 static_assert(dim <= spacedim,
1714 "The dimension <dim> of a DoFHandler must be less than or "
1715 "equal to the space dimension <spacedim> in which it lives.");
1736 template <
int dim,
int spacedim>
1764 template <
int dim,
int spacedim = dim>
1774 "No FiniteElement has been found in your FECollection that is "
1775 "dominated by all children of a cell you are trying to coarsen!");
1786template <
int dim,
int spacedim>
1790 return hp_capability_enabled;
1795template <
int dim,
int spacedim>
1799 return mg_number_cache.size() > 0;
1804template <
int dim,
int spacedim>
1808 return number_cache.n_global_dofs > 0;
1813template <
int dim,
int spacedim>
1817 return number_cache.n_global_dofs;
1822template <
int dim,
int spacedim>
1829 "n_dofs(level) can only be called after distribute_mg_dofs()"));
1830 Assert(level < mg_number_cache.size(), ExcInvalidLevel(level));
1831 return mg_number_cache[level].n_global_dofs;
1836template <
int dim,
int spacedim>
1840 return number_cache.n_locally_owned_dofs;
1845template <
int dim,
int spacedim>
1849 return number_cache.locally_owned_dofs;
1854template <
int dim,
int spacedim>
1857 const unsigned int level)
const
1859 Assert(level < this->get_triangulation().n_global_levels(),
1860 ExcMessage(
"The given level index exceeds the number of levels "
1861 "present in the triangulation"));
1863 mg_number_cache.size() == this->get_triangulation().n_global_levels(),
1865 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1866 return mg_number_cache[level].locally_owned_dofs;
1871template <
int dim,
int spacedim>
1876 Assert(fe_collection.size() > 0,
1877 ExcMessage(
"No finite element collection is associated with "
1878 "this DoFHandler"));
1879 return fe_collection[number];
1884template <
int dim,
int spacedim>
1889 return fe_collection;
1894template <
int dim,
int spacedim>
1900 ExcMessage(
"This DoFHandler object has not been associated "
1901 "with a triangulation."));
1907template <
int dim,
int spacedim>
1912 ExcMessage(
"This DoFHandler object has not been associated "
1913 "with a triangulation."));
1914 return tria->get_mpi_communicator();
1919template <
int dim,
int spacedim>
1923 return get_mpi_communicator();
1928template <
int dim,
int spacedim>
1932 Assert(this->hp_capability_enabled ==
false, ExcNotImplementedWithHP());
1934 return block_info_object;
1939template <
int dim,
int spacedim>
1941template <
typename number>
1944 &boundary_ids)
const
1946 Assert(!(dim == 2 && spacedim == 3) || this->hp_capability_enabled ==
false,
1947 ExcNotImplementedWithHP());
1951 std::set<types::boundary_id> boundary_ids_only;
1954 boundary_ids.begin();
1955 p != boundary_ids.end();
1957 boundary_ids_only.insert(p->first);
1960 return n_boundary_dofs(boundary_ids_only);
1974 template <
int dim,
int spacedim>
1977 PolicyBase<dim, spacedim> &policy);
1982template <
int dim,
int spacedim>
1984template <
class Archive>
1987 if (this->hp_capability_enabled)
1989 ar &this->object_dof_indices;
1990 ar &this->object_dof_ptr;
1992 ar &this->hp_cell_active_fe_indices;
1993 ar &this->hp_cell_future_fe_indices;
1995 ar &hp_object_fe_ptr;
1996 ar &hp_object_fe_indices;
2000 ar &mg_number_cache;
2005 const unsigned int n_cells = this->tria->n_cells();
2006 std::string policy_name =
2013 ar &this->block_info_object;
2016 ar &this->object_dof_indices;
2017 ar &this->object_dof_ptr;
2022 unsigned int n_cells = this->tria->n_cells();
2023 std::string fe_name = this->get_fe(0).get_name();
2026 ar &
n_cells &fe_name &policy_name;
2032template <
int dim,
int spacedim>
2034template <
class Archive>
2037 if (this->hp_capability_enabled)
2039 ar &this->object_dof_indices;
2040 ar &this->object_dof_ptr;
2042 ar &this->hp_cell_active_fe_indices;
2043 ar &this->hp_cell_future_fe_indices;
2045 ar &hp_object_fe_ptr;
2046 ar &hp_object_fe_indices;
2050 ar &mg_number_cache;
2055 std::string policy_name;
2060 n_cells == this->tria->n_cells(),
2062 "The object being loaded into does not match the triangulation "
2063 "that has been stored previously."));
2066 ExcMessage(
"The policy currently associated with this DoFHandler (" +
2068 ") does not match the one that was associated with the "
2069 "DoFHandler previously stored (" +
2070 policy_name +
")."));
2074 ar &this->block_info_object;
2077 object_dof_indices.clear();
2079 object_dof_ptr.clear();
2081 ar &this->object_dof_indices;
2082 ar &this->object_dof_ptr;
2087 std::string fe_name;
2088 std::string policy_name;
2090 ar &
n_cells &fe_name &policy_name;
2093 n_cells == this->tria->n_cells(),
2095 "The object being loaded into does not match the triangulation "
2096 "that has been stored previously."));
2098 fe_name == this->get_fe(0).get_name(),
2100 "The finite element associated with this DoFHandler does not match "
2101 "the one that was associated with the DoFHandler previously stored."));
2104 "The policy currently associated with this DoFHandler (" +
2106 ") does not match the one that was associated with the "
2107 "DoFHandler previously stored (" +
2108 policy_name +
")."));
2114template <
int dim,
int spacedim>
2118 const unsigned int level,
2119 const unsigned int dof_number,
2120 const unsigned int dofs_per_vertex)
2139# ifndef DEAL_II_BUILDING_CXX20_MODULE
*Â *Â const_iterator()=default
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
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
cell_iterator end() const
void pre_distributed_transfer_action()
void post_transfer_action()
::internal::DoFHandlerImplementation::Iterators< dim, spacedim, true > LevelSelector
virtual std::size_t memory_consumption() const
std::vector< types::fe_index > get_future_fe_indices() const
unsigned int max_couplings_between_dofs() 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()
static constexpr unsigned int dimension
static const types::fe_index default_fe_index
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
void set_active_fe_indices(const std::vector< unsigned int > &active_fe_indices)
BlockInfo block_info_object
bool has_active_dofs() const
std::vector< boost::signals2::connection > tria_listeners_for_transfer
level_cell_iterator end_mg() const
void renumber_dofs(const std::vector< types::global_dof_index > &new_numbers)
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
static constexpr unsigned int space_dimension
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
void renumber_dofs(const unsigned int level, const std::vector< types::global_dof_index > &new_numbers)
level_cell_iterator begin_mg(const unsigned int level=0) 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()
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
active_cell_iterator begin_active(const unsigned int level=0) const
std::vector< types::fe_index > get_active_fe_indices() const
void distribute_mg_dofs()
active_cell_iterator end_active(const unsigned int level) const
bool hp_capability_enabled
bool has_hp_capabilities() const
void initialize_local_block_info()
types::global_dof_index n_dofs() const
void update_active_fe_table()
level_cell_iterator end_mg(const unsigned int level) const
cell_iterator end(const unsigned int level) const
typename LevelSelector::cell_iterator level_cell_iterator
void prepare_for_serialization_of_active_fe_indices()
std::vector<::internal::DoFHandlerImplementation::NumberCache > mg_number_cache
void load(Archive &ar, const unsigned int version)
typename LevelSelector::face_iterator level_face_iterator
cell_iterator begin(const unsigned int level=0) const
MPI_Comm get_mpi_communicator() const
std::array< std::vector< offset_type >, dim+1 > hp_object_fe_ptr
MPI_Comm get_communicator() const
void distribute_dofs(const hp::FECollection< dim, spacedim > &fe)
types::global_dof_index n_boundary_dofs(const std::map< types::boundary_id, const Function< spacedim, number > * > &boundary_ids) const
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
types::global_dof_index n_dofs(const unsigned int level) const
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)
unsigned int max_couplings_between_boundary_dofs() const
types::global_dof_index n_locally_owned_dofs() const
::internal::DoFHandlerImplementation::Iterators< dim, spacedim, false > ActiveSelector
void deserialize_active_fe_indices()
types::global_dof_index n_boundary_dofs(const std::set< types::boundary_id > &boundary_ids) 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
friend class ObserverPointer
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DEPRECATED_WITH_COMMENT(comment)
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< level_cell_iterator > mg_cell_iterators() const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
IteratorRange< cell_iterator > cell_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
IteratorRange< level_cell_iterator > mg_cell_iterators_on_level(const unsigned int level) const
#define DeclException0(Exception0)
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
static ::ExceptionBase & ExcOnlyAvailableWithHP()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplementedWithHP()
static ::ExceptionBase & ExcNewNumbersNotConsecutive(types::global_dof_index arg1)
static ::ExceptionBase & ExcInvalidFEIndex(int arg1, int arg2)
#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 & ExcNoFESelected()
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
unsigned int global_dof_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