16 #ifndef dealii_dof_handler_h 17 #define dealii_dof_handler_h 40 #include <boost/serialization/split_member.hpp> 51 template <
int dim,
int spacedim>
53 template <
int dim,
int spacedim>
58 namespace DoFHandlerImplementation
60 struct Implementation;
64 template <
int dim,
int spacedim>
66 struct Implementation;
70 namespace DoFAccessorImplementation
72 struct Implementation;
75 namespace DoFCellAccessorImplementation
77 struct Implementation;
82 namespace DoFHandlerImplementation
84 struct Implementation;
93 template <
int dim,
int spacedim,
typename VectorType>
313 template <
int dim,
int spacedim = dim>
509 static const unsigned int dimension = dim;
514 static const unsigned int space_dimension = spacedim;
519 static const unsigned int default_fe_index = 0;
638 set_active_fe_indices(
const std::vector<unsigned int> &active_fe_indices);
702 distribute_mg_dofs();
708 has_hp_capabilities()
const;
716 has_level_dofs()
const;
733 has_active_dofs()
const;
742 initialize_local_block_info();
803 renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers);
810 renumber_dofs(
const unsigned int level,
811 const std::vector<types::global_dof_index> &new_numbers);
842 max_couplings_between_dofs()
const;
857 max_couplings_between_boundary_dofs()
const;
892 begin_active(
const unsigned int level = 0)
const;
906 end(
const unsigned int level)
const;
914 end_active(
const unsigned int level)
const;
921 begin_mg(
const unsigned int level = 0)
const;
928 end_mg(
const unsigned int level)
const;
952 cell_iterators()
const;
995 active_cell_iterators()
const;
1009 mg_cell_iterators()
const;
1027 cell_iterators_on_level(
const unsigned int level)
const;
1045 active_cell_iterators_on_level(
const unsigned int level)
const;
1063 mg_cell_iterators_on_level(
const unsigned int level)
const;
1107 n_dofs(
const unsigned int level)
const;
1114 n_boundary_dofs()
const;
1127 template <
typename number>
1131 &boundary_ids)
const;
1138 n_boundary_dofs(
const std::set<types::boundary_id> &boundary_ids)
const;
1178 n_locally_owned_dofs()
const;
1186 locally_owned_dofs()
const;
1193 locally_owned_mg_dofs(
const unsigned int level)
const;
1209 locally_owned_dofs_per_processor()
const;
1228 n_locally_owned_dofs_per_processor()
const;
1245 locally_owned_mg_dofs_per_processor(
const unsigned int level)
const;
1253 get_fe(
const unsigned int index = 0)
const;
1262 get_fe_collection()
const;
1268 get_triangulation()
const;
1274 get_communicator()
const;
1293 prepare_for_serialization_of_active_fe_indices();
1311 deserialize_active_fe_indices();
1329 template <
class Archive>
1331 save(Archive &ar,
const unsigned int version)
const;
1338 template <
class Archive>
1340 load(Archive &ar,
const unsigned int version);
1348 template <
class Archive>
1350 serialize(Archive &archive,
const unsigned int version);
1354 BOOST_SERIALIZATION_SPLIT_MEMBER()
1372 <<
"The given level " << arg1
1373 <<
" is not in the valid range!");
1380 <<
"The given list of new dof indices is not consecutive: " 1381 <<
"the index " << arg1 <<
" does not exist.");
1388 <<
"The mesh contains a cell with an active FE index of " 1389 << arg1 <<
", but the finite element collection only has " 1390 << arg2 <<
" elements");
1397 "The current function doesn't make sense when used with a " 1398 "DoFHandler without hp-capabilities.");
1405 "The current function has not yet been implemented for a " 1406 "DoFHandler with hp-capabilities.");
1429 init(
const unsigned int coarsest_level,
1430 const unsigned int finest_level,
1431 const unsigned int dofs_per_vertex);
1437 get_coarsest_level()
const;
1443 get_finest_level()
const;
1450 get_index(
const unsigned int level,
1451 const unsigned int dof_number,
1452 const unsigned int dofs_per_vertex)
const;
1459 set_index(
const unsigned int level,
1460 const unsigned int dof_number,
1461 const unsigned int dofs_per_vertex,
1484 std::unique_ptr<types::global_dof_index[]>
indices;
1526 parallel::distributed::
1527 CellDataTransfer<dim, spacedim, std::vector<unsigned int>>>
1559 std::unique_ptr<::internal::DoFHandlerImplementation::Policy::
1560 PolicyBase<dim, spacedim>>
1575 std::vector<::internal::DoFHandlerImplementation::NumberCache>
1583 mutable std::vector<std::vector<types::global_dof_index>>
1597 mutable std::vector<std::array<std::vector<types::global_dof_index>, dim + 1>>
1608 mutable std::vector<std::array<std::vector<offset_type>, dim + 1>>
1616 mutable std::array<std::vector<active_fe_index_type>, dim + 1>
1628 mutable std::vector<std::vector<active_fe_index_type>>
1635 mutable std::vector<std::vector<active_fe_index_type>>
1648 std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim>>>
1654 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim>>
1691 template <
int structdim>
1693 get_dof_index(
const unsigned int obj_level,
1694 const unsigned int obj_index,
1695 const unsigned int fe_index,
1696 const unsigned int local_index)
const;
1701 template <
int structdim>
1703 set_dof_index(
const unsigned int obj_level,
1704 const unsigned int obj_index,
1705 const unsigned int fe_index,
1706 const unsigned int local_index,
1719 connect_to_triangulation_signals();
1733 create_active_fe_table();
1748 update_active_fe_table();
1760 pre_transfer_action();
1771 post_transfer_action();
1782 pre_distributed_transfer_action();
1793 post_distributed_transfer_action();
1797 template <
int,
int,
int,
bool>
1798 friend class ::DoFAccessor;
1799 template <
int,
int,
bool>
1800 friend class ::DoFCellAccessor;
1801 friend struct ::internal::DoFAccessorImplementation::Implementation;
1802 friend struct ::internal::DoFCellAccessorImplementation::Implementation;
1806 friend struct ::internal::DoFHandlerImplementation::Implementation;
1807 friend struct ::internal::hp::DoFHandlerImplementation::Implementation;
1808 friend struct ::internal::DoFHandlerImplementation::Policy::
1813 #ifndef DEAL_II_MSVC 1814 static_assert(dim <= spacedim,
1815 "The dimension <dim> of a DoFHandler must be less than or " 1816 "equal to the space dimension <spacedim> in which it lives.");
1826 template <
int dim,
int spacedim>
1830 return hp_capability_enabled;
1835 template <
int dim,
int spacedim>
1839 return mg_number_cache.size() > 0;
1844 template <
int dim,
int spacedim>
1848 return number_cache.n_global_dofs > 0;
1853 template <
int dim,
int spacedim>
1857 return number_cache.n_global_dofs;
1862 template <
int dim,
int spacedim>
1868 "n_dofs(level) can only be called after distribute_mg_dofs()"));
1869 Assert(level < mg_number_cache.size(), ExcInvalidLevel(level));
1870 return mg_number_cache[
level].n_global_dofs;
1875 template <
int dim,
int spacedim>
1879 return number_cache.n_locally_owned_dofs;
1884 template <
int dim,
int spacedim>
1888 return number_cache.locally_owned_dofs;
1893 template <
int dim,
int spacedim>
1897 Assert(level < this->get_triangulation().n_global_levels(),
1898 ExcMessage(
"The given level index exceeds the number of levels " 1899 "present in the triangulation"));
1901 mg_number_cache.size() == this->get_triangulation().n_global_levels(),
1903 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1904 return mg_number_cache[
level].locally_owned_dofs;
1909 template <
int dim,
int spacedim>
1910 const std::vector<types::global_dof_index> &
1913 if (number_cache.n_locally_owned_dofs_per_processor.empty() &&
1914 number_cache.n_global_dofs > 0)
1920 &this->get_triangulation()));
1924 comm = MPI_COMM_SELF;
1928 .n_locally_owned_dofs_per_processor =
1931 return number_cache.n_locally_owned_dofs_per_processor;
1936 template <
int dim,
int spacedim>
1937 const std::vector<IndexSet> &
1940 if (number_cache.locally_owned_dofs_per_processor.empty() &&
1941 number_cache.n_global_dofs > 0)
1947 &this->get_triangulation()));
1951 comm = MPI_COMM_SELF;
1955 .locally_owned_dofs_per_processor =
1958 return number_cache.locally_owned_dofs_per_processor;
1963 template <
int dim,
int spacedim>
1964 const std::vector<IndexSet> &
1966 const unsigned int level)
const 1968 Assert(level < this->get_triangulation().n_global_levels(),
1969 ExcMessage(
"The given level index exceeds the number of levels " 1970 "present in the triangulation"));
1972 mg_number_cache.size() == this->get_triangulation().n_global_levels(),
1974 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1975 if (mg_number_cache[level].locally_owned_dofs_per_processor.empty() &&
1976 mg_number_cache[
level].n_global_dofs > 0)
1982 &this->get_triangulation()));
1986 comm = MPI_COMM_SELF;
1989 mg_number_cache[
level])
1990 .locally_owned_dofs_per_processor =
1991 mg_number_cache[level].get_locally_owned_dofs_per_processor(comm);
1998 template <
int dim,
int spacedim>
2002 Assert(fe_collection.size() > 0,
2003 ExcMessage(
"No finite element collection is associated with " 2004 "this DoFHandler"));
2005 return fe_collection[number];
2010 template <
int dim,
int spacedim>
2014 Assert(fe_collection.size() > 0,
2015 ExcMessage(
"No finite element collection is associated with " 2016 "this DoFHandler"));
2017 return fe_collection;
2022 template <
int dim,
int spacedim>
2027 ExcMessage(
"This DoFHandler object has not been associated " 2028 "with a triangulation."));
2034 template <
int dim,
int spacedim>
2039 ExcMessage(
"This DoFHandler object has not been associated " 2040 "with a triangulation."));
2041 return tria->get_communicator();
2046 template <
int dim,
int spacedim>
2050 Assert(this->hp_capability_enabled ==
false, ExcNotImplementedWithHP());
2052 return block_info_object;
2057 template <
int dim,
int spacedim>
2058 template <
typename number>
2062 &boundary_ids)
const 2064 Assert(!(dim == 2 && spacedim == 3) || this->hp_capability_enabled ==
false,
2065 ExcNotImplementedWithHP());
2069 std::set<types::boundary_id> boundary_ids_only;
2072 boundary_ids.begin();
2073 p != boundary_ids.end();
2075 boundary_ids_only.insert(p->first);
2078 return n_boundary_dofs(boundary_ids_only);
2092 template <
int dim,
int spacedim>
2095 PolicyBase<dim, spacedim> &policy);
2100 template <
int dim,
int spacedim>
2101 template <
class Archive>
2105 if (this->hp_capability_enabled)
2107 ar & this->object_dof_indices;
2108 ar & this->object_dof_ptr;
2110 ar & this->cell_dof_cache_indices;
2111 ar & this->cell_dof_cache_ptr;
2113 ar & this->hp_cell_active_fe_indices;
2114 ar & this->hp_cell_future_fe_indices;
2116 ar &hp_object_fe_ptr;
2117 ar &hp_object_fe_indices;
2121 ar &mg_number_cache;
2126 const unsigned int n_cells = this->tria->n_cells();
2127 std::string policy_name =
2130 ar &n_cells &policy_name;
2134 ar & this->block_info_object;
2137 ar & this->object_dof_indices;
2138 ar & this->object_dof_ptr;
2140 ar & this->cell_dof_cache_indices;
2141 ar & this->cell_dof_cache_ptr;
2146 unsigned int n_cells = this->tria->n_cells();
2147 std::string fe_name = this->get_fe(0).get_name();
2150 ar &n_cells &fe_name &policy_name;
2156 template <
int dim,
int spacedim>
2157 template <
class Archive>
2161 if (this->hp_capability_enabled)
2163 ar & this->object_dof_indices;
2164 ar & this->object_dof_ptr;
2166 ar & this->cell_dof_cache_indices;
2167 ar & this->cell_dof_cache_ptr;
2169 ar & this->hp_cell_active_fe_indices;
2170 ar & this->hp_cell_future_fe_indices;
2172 ar &hp_object_fe_ptr;
2173 ar &hp_object_fe_indices;
2177 ar &mg_number_cache;
2182 std::string policy_name;
2184 ar &n_cells &policy_name;
2187 n_cells == this->tria->n_cells(),
2189 "The object being loaded into does not match the triangulation " 2190 "that has been stored previously."));
2193 ExcMessage(
"The policy currently associated with this DoFHandler (" +
2195 ") does not match the one that was associated with the " 2196 "DoFHandler previously stored (" +
2197 policy_name +
")."));
2201 ar & this->block_info_object;
2204 object_dof_indices.clear();
2206 object_dof_ptr.clear();
2208 ar & this->object_dof_indices;
2209 ar & this->object_dof_ptr;
2211 ar & this->cell_dof_cache_indices;
2212 ar & this->cell_dof_cache_ptr;
2217 std::string fe_name;
2218 std::string policy_name;
2220 ar &n_cells &fe_name &policy_name;
2223 n_cells == this->tria->n_cells(),
2225 "The object being loaded into does not match the triangulation " 2226 "that has been stored previously."));
2228 fe_name == this->get_fe(0).get_name(),
2230 "The finite element associated with this DoFHandler does not match " 2231 "the one that was associated with the DoFHandler previously stored."));
2234 "The policy currently associated with this DoFHandler (" +
2236 ") does not match the one that was associated with the " 2237 "DoFHandler previously stored (" +
2238 policy_name +
")."));
2244 template <
int dim,
int spacedim>
2247 const unsigned int level,
2248 const unsigned int dof_number,
2249 const unsigned int dofs_per_vertex)
const 2251 Assert((level >= coarsest_level) && (level <= finest_level),
2252 ExcInvalidLevel(level));
2253 return indices[dofs_per_vertex * (level - coarsest_level) + dof_number];
2258 template <
int dim,
int spacedim>
2261 const unsigned int level,
2262 const unsigned int dof_number,
2263 const unsigned int dofs_per_vertex,
2266 Assert((level >= coarsest_level) && (level <= finest_level),
2267 ExcInvalidLevel(level));
2268 indices[dofs_per_vertex * (level - coarsest_level) + dof_number] = index;
std::vector< types::global_dof_index > get_n_locally_owned_dofs_per_processor(const MPI_Comm &mpi_communicator) const
std::vector< MGVertexDoFs > mg_vertex_dofs
static const unsigned int invalid_unsigned_int
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
typename ActiveSelector::FaceAccessor face_accessor
std::array< std::vector< offset_type >, dim+1 > hp_object_fe_ptr
#define DeclException2(Exception2, type1, type2, outsequence)
typename LevelSelector::face_iterator level_face_iterator
std::map< const cell_iterator, const unsigned int > coarsened_cells_fe_index
typename ActiveSelector::quad_iterator quad_iterator
unsigned short int active_fe_index_type
::internal::DoFHandlerImplementation::NumberCache number_cache
std::vector< std::array< std::vector< offset_type >, dim+1 > > object_dof_ptr
typename ActiveSelector::CellAccessor cell_accessor
#define AssertThrow(cond, exc)
std::vector< std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel< dim > > > mg_levels
void save(Archive &ar, const unsigned int version) const
std::vector< std::vector< active_fe_index_type > > hp_cell_future_fe_indices
typename ActiveSelector::face_iterator face_iterator
typename ActiveSelector::active_face_iterator active_face_iterator
MPI_Comm get_communicator() const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
std::vector< std::vector< types::global_dof_index > > cell_dof_cache_indices
std::map< const cell_iterator, const unsigned int > refined_cells_fe_index
BlockInfo block_info_object
virtual MPI_Comm get_communicator() const override
static ::ExceptionBase & ExcMessage(std::string arg1)
std::map< const cell_iterator, const unsigned int > persisting_cells_fe_index
unsigned int finest_level
#define DeclException1(Exception1, type1, outsequence)
typename LevelSelector::CellAccessor level_cell_accessor
typename ActiveSelector::hex_iterator hex_iterator
std::vector<::internal::DoFHandlerImplementation::NumberCache > mg_number_cache
bool has_active_dofs() const
#define Assert(cond, exc)
hp::FECollection< dim, spacedim > fe_collection
std::vector< IndexSet > get_locally_owned_dofs_per_processor(const MPI_Comm &mpi_communicator) const
types::global_dof_index n_dofs() const
std::unique_ptr< ActiveFEIndexTransfer > active_fe_index_transfer
std::vector< std::array< std::vector< types::global_dof_index >, dim+1 > > object_dof_indices
#define DeclExceptionMsg(Exception, defaulttext)
std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces< dim > > mg_faces
#define DeclException0(Exception0)
#define DEAL_II_NAMESPACE_CLOSE
SmartPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
VectorType::value_type * end(VectorType &V)
typename LevelSelector::cell_iterator level_cell_iterator
void load(Archive &ar, const unsigned int version)
std::unique_ptr<::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > > policy
void set_index(const unsigned int level, const unsigned int dof_number, const unsigned int dofs_per_vertex, const types::global_dof_index index)
std::unique_ptr< parallel::distributed::CellDataTransfer< dim, spacedim, std::vector< unsigned int > > > cell_data_transfer
std::vector< std::vector< active_fe_index_type > > hp_cell_active_fe_indices
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
typename LevelSelector::FaceAccessor level_face_accessor
std::vector< unsigned int > active_fe_indices
std::array< std::vector< active_fe_index_type >, dim+1 > hp_object_fe_indices
const IndexSet & locally_owned_dofs() const
typename ActiveSelector::active_line_iterator active_line_iterator
std::unique_ptr< types::global_dof_index[]> indices
std::string policy_to_string(const ::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > &policy)
bool has_hp_capabilities() const
*braid_SplitCommworld & comm
typename ActiveSelector::line_iterator line_iterator
const Triangulation< dim, spacedim > & get_triangulation() const
unsigned int coarsest_level
#define DEAL_II_NAMESPACE_OPEN
VectorType::value_type * begin(VectorType &V)
const std::vector< IndexSet > & locally_owned_dofs_per_processor() const
types::global_dof_index get_index(const unsigned int level, const unsigned int dof_number, const unsigned int dofs_per_vertex) const
types::global_dof_index n_boundary_dofs() const
std::vector< IndexSet > locally_owned_dofs_per_processor
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
typename ActiveSelector::cell_iterator cell_iterator
const std::vector< types::global_dof_index > & n_locally_owned_dofs_per_processor() const
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
typename ActiveSelector::active_cell_iterator active_cell_iterator
std::vector< boost::signals2::connection > tria_listeners
std::vector< boost::signals2::connection > tria_listeners_for_transfer
bool has_level_dofs() const
#define DEAL_II_DEPRECATED
const BlockInfo & block_info() const
static ::ExceptionBase & ExcNoFESelected()
bool hp_capability_enabled
const std::vector< IndexSet > & locally_owned_mg_dofs_per_processor(const unsigned int level) const
typename ActiveSelector::active_quad_iterator active_quad_iterator
types::global_dof_index n_locally_owned_dofs() const
std::vector< std::vector< offset_type > > cell_dof_cache_ptr
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
typename ActiveSelector::active_hex_iterator active_hex_iterator