16 #ifndef dealii_dof_handler_h 17 #define dealii_dof_handler_h 21 #include <deal.II/base/config.h> 23 #include <deal.II/base/exceptions.h> 24 #include <deal.II/base/function.h> 25 #include <deal.II/base/index_set.h> 26 #include <deal.II/base/iterator_range.h> 27 #include <deal.II/base/smartpointer.h> 29 #include <deal.II/dofs/block_info.h> 30 #include <deal.II/dofs/deprecated_function_map.h> 31 #include <deal.II/dofs/dof_faces.h> 32 #include <deal.II/dofs/dof_iterator_selector.h> 33 #include <deal.II/dofs/dof_levels.h> 34 #include <deal.II/dofs/number_cache.h> 36 #include <deal.II/hp/fe_collection.h> 38 #include <boost/serialization/split_member.hpp> 45 DEAL_II_NAMESPACE_OPEN
47 template <
int dim,
int spacedim>
49 template <
int dim,
int spacedim>
54 namespace DoFHandlerImplementation
56 struct Implementation;
60 template <
int dim,
int spacedim>
62 struct Implementation;
66 namespace DoFAccessorImplementation
68 struct Implementation;
71 namespace DoFCellAccessorImplementation
73 struct Implementation;
199 template <
int dim,
int spacedim = dim>
202 using ActiveSelector = ::internal::DoFHandlerImplementation::
203 Iterators<DoFHandler<dim, spacedim>,
false>;
204 using LevelSelector = ::internal::DoFHandlerImplementation::
205 Iterators<DoFHandler<dim, spacedim>,
true>;
208 using cell_accessor =
typename ActiveSelector::CellAccessor;
209 using face_accessor =
typename ActiveSelector::FaceAccessor;
211 using line_iterator =
typename ActiveSelector::line_iterator;
212 using active_line_iterator =
typename ActiveSelector::active_line_iterator;
214 using quad_iterator =
typename ActiveSelector::quad_iterator;
215 using active_quad_iterator =
typename ActiveSelector::active_quad_iterator;
217 using hex_iterator =
typename ActiveSelector::hex_iterator;
218 using active_hex_iterator =
typename ActiveSelector::active_hex_iterator;
301 using level_cell_accessor =
typename LevelSelector::CellAccessor;
302 using level_face_accessor =
typename LevelSelector::FaceAccessor;
304 using level_cell_iterator =
typename LevelSelector::cell_iterator;
305 using level_face_iterator =
typename LevelSelector::face_iterator;
311 static const unsigned int dimension = dim;
316 static const unsigned int space_dimension = spacedim;
342 static const unsigned int default_fe_index = 0;
445 distribute_mg_dofs();
453 has_level_dofs()
const;
470 has_active_dofs()
const;
479 initialize_local_block_info();
540 renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers);
547 renumber_dofs(
const unsigned int level,
548 const std::vector<types::global_dof_index> &new_numbers);
579 max_couplings_between_dofs()
const;
594 max_couplings_between_boundary_dofs()
const;
610 begin(
const unsigned int level = 0)
const;
629 begin_active(
const unsigned int level = 0)
const;
643 end(
const unsigned int level)
const;
651 end_active(
const unsigned int level)
const;
659 begin_mg(
const unsigned int level = 0)
const;
666 end_mg(
const unsigned int level)
const;
690 cell_iterators()
const;
733 active_cell_iterators()
const;
747 mg_cell_iterators()
const;
765 cell_iterators_on_level(
const unsigned int level)
const;
783 active_cell_iterators_on_level(
const unsigned int level)
const;
802 mg_cell_iterators_on_level(
const unsigned int level)
const;
846 n_dofs(
const unsigned int level)
const;
852 n_boundary_dofs()
const;
864 template <
typename number>
868 &boundary_ids)
const;
875 n_boundary_dofs(
const std::set<types::boundary_id> &boundary_ids)
const;
916 n_locally_owned_dofs()
const;
924 locally_owned_dofs()
const;
931 locally_owned_mg_dofs(
const unsigned int level)
const;
945 const std::vector<IndexSet> &
946 locally_owned_dofs_per_processor()
const;
963 const std::vector<types::global_dof_index> &
964 n_locally_owned_dofs_per_processor()
const;
977 const std::vector<IndexSet> &
978 locally_owned_mg_dofs_per_processor(
const unsigned int level)
const;
986 get_fe(
const unsigned int index = 0)
const;
995 get_fe_collection()
const;
1001 get_triangulation()
const;
1012 memory_consumption()
const;
1018 template <
class Archive>
1020 save(Archive &ar,
const unsigned int version)
const;
1026 template <
class Archive>
1028 load(Archive &ar,
const unsigned int version);
1030 BOOST_SERIALIZATION_SPLIT_MEMBER()
1047 types::global_dof_index,
1048 << "The given list of new dof indices is not consecutive: "
1049 << "the index " << arg1 << " does not exist.");
1056 << "The given level " << arg1
1057 << " is not in the valid range!");
1069 << "You tried to do something on level " << arg1
1070 << ", but this level is empty.");
1090 hp::FECollection<dim, spacedim> fe_collection;
1096 std::unique_ptr<::
internal::DoFHandlerImplementation::Policy::
1097 PolicyBase<dim, spacedim>>
1107 ::
internal::DoFHandlerImplementation::NumberCache number_cache;
1112 std::vector<::
internal::DoFHandlerImplementation::NumberCache>
1135 init(
const unsigned int coarsest_level,
1136 const unsigned int finest_level,
1137 const unsigned int dofs_per_vertex);
1143 get_coarsest_level()
const;
1149 get_finest_level()
const;
1156 get_index(
const unsigned int level,
1157 const unsigned int dof_number,
1158 const unsigned int dofs_per_vertex)
const;
1165 set_index(
const unsigned int level,
1166 const unsigned int dof_number,
1167 const unsigned int dofs_per_vertex,
1190 std::unique_ptr<types::global_dof_index[]>
indices;
1205 template <
int structdim>
1207 get_dof_index(
const unsigned int obj_level,
1208 const unsigned int obj_index,
1209 const unsigned int fe_index,
1210 const unsigned int local_index)
const;
1212 template <
int structdim>
1214 set_dof_index(
const unsigned int obj_level,
1215 const unsigned int obj_index,
1216 const unsigned int fe_index,
1217 const unsigned int local_index,
1236 std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim>>>
1240 std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim>>>
1248 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim>>
1251 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim>>
1257 template <
int,
class,
bool>
1259 template <
class,
bool>
1261 friend struct ::internal::DoFAccessorImplementation::Implementation;
1262 friend struct ::internal::DoFCellAccessorImplementation::Implementation;
1264 friend struct ::internal::DoFHandlerImplementation::Implementation;
1265 friend struct ::internal::DoFHandlerImplementation::Policy::
1270 #ifndef DEAL_II_MSVC 1272 "The dimension <dim> of a DoFHandler must be less than or " 1273 "equal to the space dimension <spacedim> in which it lives.");
1285 template <
int dim,
int spacedim>
1289 return mg_number_cache.size() > 0;
1294 template <
int dim,
int spacedim>
1298 return number_cache.n_global_dofs > 0;
1303 template <
int dim,
int spacedim>
1307 return number_cache.n_global_dofs;
1312 template <
int dim,
int spacedim>
1318 "n_dofs(level) can only be called after distribute_mg_dofs()"));
1319 Assert(level < mg_number_cache.size(), ExcInvalidLevel(level));
1320 return mg_number_cache[
level].n_global_dofs;
1325 template <
int dim,
int spacedim>
1329 return number_cache.n_locally_owned_dofs;
1334 template <
int dim,
int spacedim>
1338 return number_cache.locally_owned_dofs;
1343 template <
int dim,
int spacedim>
1348 ExcMessage(
"invalid level in locally_owned_mg_dofs"));
1352 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1353 return mg_number_cache[
level].locally_owned_dofs;
1358 template <
int dim,
int spacedim>
1359 const std::vector<types::global_dof_index> &
1362 return number_cache.n_locally_owned_dofs_per_processor;
1367 template <
int dim,
int spacedim>
1368 const std::vector<IndexSet> &
1371 return number_cache.locally_owned_dofs_per_processor;
1376 template <
int dim,
int spacedim>
1377 const std::vector<IndexSet> &
1379 const unsigned int level)
const 1382 ExcMessage(
"invalid level in locally_owned_mg_dofs_per_processor"));
1386 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1387 return mg_number_cache[
level].locally_owned_dofs_per_processor;
1392 template <
int dim,
int spacedim>
1399 "There is only one FiniteElement stored. The index must be zero!"));
1400 return get_fe_collection()[0];
1405 template <
int dim,
int spacedim>
1410 fe_collection.size() > 0,
1412 "You are trying to access the DoFHandler's FECollection object before it has been initialized."));
1413 return fe_collection;
1418 template <
int dim,
int spacedim>
1423 ExcMessage(
"This DoFHandler object has not been associated " 1424 "with a triangulation."));
1430 template <
int dim,
int spacedim>
1434 return block_info_object;
1439 template <
int dim,
int spacedim>
1440 template <
typename number>
1444 &boundary_ids)
const 1448 std::set<types::boundary_id> boundary_ids_only;
1451 boundary_ids.begin();
1452 p != boundary_ids.end();
1454 boundary_ids_only.insert(p->first);
1457 return n_boundary_dofs(boundary_ids_only);
1471 template <
int dim,
int spacedim>
1473 policy_to_string(const ::internal::DoFHandlerImplementation::Policy::
1474 PolicyBase<dim, spacedim> &policy);
1479 template <
int dim,
int spacedim>
1480 template <
class Archive>
1484 ar &block_info_object;
1491 unsigned int n_levels = levels.size();
1493 for (
unsigned int i = 0; i < levels.size(); ++i)
1499 bool faces_is_nullptr = (faces.get() ==
nullptr);
1500 ar & faces_is_nullptr;
1501 if (!faces_is_nullptr)
1507 unsigned int n_cells = tria->n_cells();
1508 std::string fe_name = this->get_fe(0).get_name();
1509 std::string policy_name = internal::policy_to_string(*policy);
1511 ar &n_cells &fe_name &policy_name;
1516 template <
int dim,
int spacedim>
1517 template <
class Archive>
1521 ar &block_info_object;
1537 levels.resize(size);
1538 for (
unsigned int i = 0; i < levels.size(); ++i)
1540 std::unique_ptr<internal::DoFHandlerImplementation::DoFLevel<dim>> level;
1542 levels[i] = std::move(level);
1546 bool faces_is_nullptr =
true;
1547 ar & faces_is_nullptr;
1548 if (!faces_is_nullptr)
1553 unsigned int n_cells;
1554 std::string fe_name;
1555 std::string policy_name;
1557 ar &n_cells &fe_name &policy_name;
1561 "The object being loaded into does not match the triangulation " 1562 "that has been stored previously."));
1564 fe_name == this->get_fe(0).get_name(),
1566 "The finite element associated with this DoFHandler does not match " 1567 "the one that was associated with the DoFHandler previously stored."));
1568 AssertThrow(policy_name == internal::policy_to_string(*policy),
1570 "The policy currently associated with this DoFHandler (" +
1571 internal::policy_to_string(*policy) +
1572 ") does not match the one that was associated with the " 1573 "DoFHandler previously stored (" +
1574 policy_name +
")."));
1579 template <
int dim,
int spacedim>
1582 const unsigned int level,
1583 const unsigned int dof_number,
1584 const unsigned int dofs_per_vertex)
const 1586 Assert((level >= coarsest_level) && (level <= finest_level),
1587 ExcInvalidLevel(level));
1588 return indices[dofs_per_vertex * (level - coarsest_level) + dof_number];
1593 template <
int dim,
int spacedim>
1596 const unsigned int level,
1597 const unsigned int dof_number,
1598 const unsigned int dofs_per_vertex,
1601 Assert((level >= coarsest_level) && (level <= finest_level),
1602 ExcInvalidLevel(level));
1603 indices[dofs_per_vertex * (level - coarsest_level) + dof_number] = index;
1609 DEAL_II_NAMESPACE_CLOSE
std::vector< MGVertexDoFs > mg_vertex_dofs
const BlockInfo & block_info() const
static const unsigned int spacedim
bool has_level_dofs() const
#define AssertThrow(cond, exc)
const Triangulation< dim, spacedim > & get_triangulation() const
const std::vector< types::global_dof_index > & n_locally_owned_dofs_per_processor() const
static::ExceptionBase & ExcFacesHaveNoLevel()
typename ActiveSelector::face_iterator face_iterator
typename ActiveSelector::active_face_iterator active_face_iterator
unsigned long long int global_dof_index
static::ExceptionBase & ExcMessage(std::string arg1)
unsigned int finest_level
#define DeclException1(Exception1, type1, outsequence)
const Triangulation< dim, spacedim > * tria
#define Assert(cond, exc)
types::global_dof_index n_dofs() const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
unsigned int n_locally_owned_dofs() const
#define DeclException0(Exception0)
const Triangulation< dim, spacedim > & get_triangulation() const
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<::internal::DoFHandlerImplementation::DoFFaces< dim > > faces
std::vector< std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel< dim > > > levels
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
std::unique_ptr< types::global_dof_index[]> indices
bool has_active_dofs() const
const std::vector< IndexSet > & locally_owned_mg_dofs_per_processor(const unsigned int level) const
static const unsigned int dim
void save(Archive &ar, const unsigned int version) const
types::global_dof_index get_index(const unsigned int level, const unsigned int dof_number, const unsigned int dofs_per_vertex) const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
types::global_dof_index n_boundary_dofs() const
unsigned int coarsest_level
void load(Archive &ar, const unsigned int version)
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
static::ExceptionBase & ExcInvalidBoundaryIndicator()
typename ActiveSelector::cell_iterator cell_iterator
typename ActiveSelector::active_cell_iterator active_cell_iterator
const types::global_dof_index invalid_dof_index
const IndexSet & locally_owned_dofs() const
const std::vector< IndexSet > & locally_owned_dofs_per_processor() const
std::vector< types::global_dof_index > vertex_dofs