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
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>;
385 using level_cell_accessor =
typename LevelSelector::CellAccessor;
386 using level_face_accessor =
typename LevelSelector::FaceAccessor;
388 using level_cell_iterator =
typename LevelSelector::cell_iterator;
389 using level_face_iterator =
typename LevelSelector::face_iterator;
644 renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers);
652 const std::vector<types::global_dof_index> &new_numbers);
714 begin(
const unsigned int level = 0)
const;
747 end(
const unsigned int level)
const;
763 begin_mg(
const unsigned int level = 0)
const;
770 end_mg(
const unsigned int level)
const;
950 n_dofs(
const unsigned int level)
const;
968 template <
typename number>
972 &boundary_ids)
const;
979 n_boundary_dofs(
const std::set<types::boundary_id> &boundary_ids)
const;
1049 const std::vector<IndexSet> &
1068 const std::vector<types::global_dof_index> &
1082 const std::vector<IndexSet> &
1091 get_fe(
const unsigned int index = 0)
const;
1123 template <
class Archive>
1125 save(Archive &ar,
const unsigned int version)
const;
1131 template <
class Archive>
1133 load(Archive &ar,
const unsigned int version);
1135 BOOST_SERIALIZATION_SPLIT_MEMBER()
1152 types::global_dof_index,
1153 << "The given list of new dof indices is not consecutive: "
1154 << "the index " << arg1 << " does not exist.");
1161 << "The given level " << arg1
1162 << " is not in the valid range!");
1174 << "You tried to do something on level " << arg1
1175 << ", but this level is empty.");
1201 std::unique_ptr<::
internal::DoFHandlerImplementation::Policy::
1202 PolicyBase<dim, spacedim>>
1217 std::vector<::
internal::DoFHandlerImplementation::NumberCache>
1240 init(
const unsigned int coarsest_level,
1241 const unsigned int finest_level,
1242 const unsigned int dofs_per_vertex);
1248 get_coarsest_level()
const;
1254 get_finest_level()
const;
1261 get_index(
const unsigned int level,
1262 const unsigned int dof_number,
1263 const unsigned int dofs_per_vertex)
const;
1270 set_index(
const unsigned int level,
1271 const unsigned int dof_number,
1272 const unsigned int dofs_per_vertex,
1295 std::unique_ptr<types::global_dof_index[]>
indices;
1310 template <
int structdim>
1312 get_dof_index(
const unsigned int obj_level,
1313 const unsigned int obj_index,
1314 const unsigned int fe_index,
1315 const unsigned int local_index)
const;
1317 template <
int structdim>
1319 set_dof_index(
const unsigned int obj_level,
1320 const unsigned int obj_index,
1321 const unsigned int fe_index,
1322 const unsigned int local_index,
1341 std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim>>>
1345 std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim>>>
1353 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim>>
1356 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim>>
1362 template <
int,
class,
bool>
1364 template <
class,
bool>
1366 friend struct ::internal::DoFAccessorImplementation::Implementation;
1367 friend struct ::internal::DoFCellAccessorImplementation::Implementation;
1369 friend struct ::internal::DoFHandlerImplementation::Implementation;
1370 friend struct ::internal::DoFHandlerImplementation::Policy::
1375 #ifndef DEAL_II_MSVC
1377 "The dimension <dim> of a DoFHandler must be less than or "
1378 "equal to the space dimension <spacedim> in which it lives.");
1390 template <
int dim,
int spacedim>
1394 return mg_number_cache.size() > 0;
1399 template <
int dim,
int spacedim>
1403 return number_cache.n_global_dofs > 0;
1408 template <
int dim,
int spacedim>
1412 return number_cache.n_global_dofs;
1417 template <
int dim,
int spacedim>
1423 "n_dofs(level) can only be called after distribute_mg_dofs()"));
1424 Assert(level < mg_number_cache.size(), ExcInvalidLevel(level));
1425 return mg_number_cache[level].n_global_dofs;
1430 template <
int dim,
int spacedim>
1434 return number_cache.n_locally_owned_dofs;
1439 template <
int dim,
int spacedim>
1443 return number_cache.locally_owned_dofs;
1448 template <
int dim,
int spacedim>
1452 Assert(level < this->get_triangulation().n_global_levels(),
1453 ExcMessage(
"invalid level in locally_owned_mg_dofs"));
1455 mg_number_cache.size() == this->get_triangulation().n_global_levels(),
1457 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1458 return mg_number_cache[level].locally_owned_dofs;
1463 template <
int dim,
int spacedim>
1464 const std::vector<types::global_dof_index> &
1467 return number_cache.n_locally_owned_dofs_per_processor;
1472 template <
int dim,
int spacedim>
1473 const std::vector<IndexSet> &
1476 return number_cache.locally_owned_dofs_per_processor;
1481 template <
int dim,
int spacedim>
1482 const std::vector<IndexSet> &
1484 const unsigned int level)
const
1486 Assert(level < this->get_triangulation().n_global_levels(),
1487 ExcMessage(
"invalid level in locally_owned_mg_dofs_per_processor"));
1489 mg_number_cache.size() == this->get_triangulation().n_global_levels(),
1491 "The level dofs are not set up properly! Did you call distribute_mg_dofs()?"));
1492 return mg_number_cache[level].locally_owned_dofs_per_processor;
1497 template <
int dim,
int spacedim>
1504 "There is only one FiniteElement stored. The index must be zero!"));
1505 return get_fe_collection()[0];
1510 template <
int dim,
int spacedim>
1515 fe_collection.size() > 0,
1517 "You are trying to access the DoFHandler's FECollection object before it has been initialized."));
1518 return fe_collection;
1523 template <
int dim,
int spacedim>
1528 ExcMessage(
"This DoFHandler object has not been associated "
1529 "with a triangulation."));
1535 template <
int dim,
int spacedim>
1539 return block_info_object;
1544 template <
int dim,
int spacedim>
1545 template <
typename number>
1549 &boundary_ids)
const
1553 std::set<types::boundary_id> boundary_ids_only;
1556 boundary_ids.begin();
1557 p != boundary_ids.end();
1559 boundary_ids_only.insert(p->first);
1562 return n_boundary_dofs(boundary_ids_only);
1576 template <
int dim,
int spacedim>
1578 policy_to_string(const ::internal::DoFHandlerImplementation::Policy::
1579 PolicyBase<dim, spacedim> &policy);
1584 template <
int dim,
int spacedim>
1585 template <
class Archive>
1589 ar &block_info_object;
1596 unsigned int n_levels = levels.size();
1598 for (
unsigned int i = 0; i < levels.size(); ++i)
1604 bool faces_is_nullptr = (faces.get() ==
nullptr);
1605 ar & faces_is_nullptr;
1606 if (!faces_is_nullptr)
1612 unsigned int n_cells = tria->n_cells();
1613 std::string fe_name = this->get_fe(0).get_name();
1614 std::string policy_name = internal::policy_to_string(*policy);
1616 ar &n_cells &fe_name &policy_name;
1621 template <
int dim,
int spacedim>
1622 template <
class Archive>
1626 ar &block_info_object;
1642 levels.resize(size);
1643 for (
unsigned int i = 0; i < levels.size(); ++i)
1645 std::unique_ptr<internal::DoFHandlerImplementation::DoFLevel<dim>> level;
1647 levels[i] = std::move(level);
1651 bool faces_is_nullptr =
true;
1652 ar & faces_is_nullptr;
1653 if (!faces_is_nullptr)
1658 unsigned int n_cells;
1659 std::string fe_name;
1660 std::string policy_name;
1662 ar &n_cells &fe_name &policy_name;
1666 "The object being loaded into does not match the triangulation "
1667 "that has been stored previously."));
1669 fe_name == this->get_fe(0).get_name(),
1671 "The finite element associated with this DoFHandler does not match "
1672 "the one that was associated with the DoFHandler previously stored."));
1673 AssertThrow(policy_name == internal::policy_to_string(*policy),
1675 "The policy currently associated with this DoFHandler (" +
1676 internal::policy_to_string(*policy) +
1677 ") does not match the one that was associated with the "
1678 "DoFHandler previously stored (" +
1679 policy_name +
")."));
1684 template <
int dim,
int spacedim>
1687 const unsigned int level,
1688 const unsigned int dof_number,
1689 const unsigned int dofs_per_vertex)
const
1698 template <
int dim,
int spacedim>
1701 const unsigned int level,
1702 const unsigned int dof_number,
1703 const unsigned int dofs_per_vertex,
1706 Assert((level >= coarsest_level) && (level <= finest_level),
1708 indices[dofs_per_vertex * (level - coarsest_level) + dof_number] = index;
1714 DEAL_II_NAMESPACE_CLOSE