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()"));
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>
1453 ExcMessage(
"invalid level in locally_owned_mg_dofs"));
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 1487 ExcMessage(
"invalid level in locally_owned_mg_dofs_per_processor"));
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
DoFHandler & operator=(const DoFHandler &)=delete
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
unsigned int max_couplings_between_dofs() const
std::vector< MGVertexDoFs > mg_vertex_dofs
const Triangulation< dim, spacedim > & get_triangulation() const
level_cell_iterator end_mg() const
typename ActiveSelector::FaceAccessor face_accessor
cell_iterator begin(const unsigned int level=0) const
typename ActiveSelector::quad_iterator quad_iterator
static const unsigned int dimension
static const unsigned int spacedim
static ::ExceptionBase & ExcInvalidLevel(int arg1)
const BlockInfo & block_info() const
cell_iterator end() const
::internal::DoFHandlerImplementation::NumberCache number_cache
const std::vector< IndexSet > & locally_owned_mg_dofs_per_processor(const unsigned int level) const
IteratorRange< level_cell_iterator > mg_cell_iterators_on_level(const unsigned int level) const
typename ActiveSelector::CellAccessor cell_accessor
#define AssertThrow(cond, exc)
virtual std::size_t memory_consumption() const
void initialize(const Triangulation< dim, spacedim > &tria, const FiniteElement< dim, spacedim > &fe)
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
typename ActiveSelector::face_iterator face_iterator
typename ActiveSelector::active_face_iterator active_face_iterator
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
active_cell_iterator begin_active(const unsigned int level=0) const
static const bool is_hp_dof_handler
BlockInfo block_info_object
unsigned int n_locally_owned_dofs() const
static ::ExceptionBase & ExcFacesHaveNoLevel()
const std::vector< types::global_dof_index > & n_locally_owned_dofs_per_processor() const
static ::ExceptionBase & ExcMessage(std::string arg1)
unsigned int finest_level
#define DeclException1(Exception1, type1, outsequence)
const Triangulation< dim, spacedim > * tria
typename ActiveSelector::hex_iterator hex_iterator
std::vector<::internal::DoFHandlerImplementation::NumberCache > mg_number_cache
bool has_active_dofs() const
virtual void distribute_mg_dofs()
#define Assert(cond, exc)
hp::FECollection< dim, spacedim > fe_collection
IteratorRange< active_cell_iterator > active_cell_iterators() const
static const unsigned int default_fe_index
active_cell_iterator end_active(const unsigned int level) const
static ::ExceptionBase & ExcGridsDoNotMatch()
#define DeclException0(Exception0)
types::global_dof_index n_boundary_dofs() const
SmartPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
types::global_dof_index n_dofs() const
level_cell_iterator begin_mg(const unsigned int level=0) const
std::unique_ptr<::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > > policy
const hp::FECollection< dim, spacedim > & get_fe_collection() const
virtual void set_fe(const FiniteElement< dim, spacedim > &fe)
const IndexSet & locally_owned_mg_dofs(const unsigned int level) 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
typename ActiveSelector::active_line_iterator active_line_iterator
void renumber_dofs(const std::vector< types::global_dof_index > &new_numbers)
std::unique_ptr< types::global_dof_index[]> indices
void initialize_local_block_info()
unsigned int global_dof_index
const Triangulation< dim, spacedim > & get_triangulation() const
static ::ExceptionBase & ExcEmptyLevel(int arg1)
static const unsigned int dim
const std::vector< IndexSet > & locally_owned_dofs_per_processor() const
IteratorRange< level_cell_iterator > mg_cell_iterators() const
typename ActiveSelector::line_iterator line_iterator
unsigned int coarsest_level
virtual void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
types::global_dof_index get_index(const unsigned int level, const unsigned int dof_number, const unsigned int dofs_per_vertex) const
void load(Archive &ar, const unsigned int version)
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
static ::ExceptionBase & ExcNewNumbersNotConsecutive(types::global_dof_index arg1)
typename ActiveSelector::cell_iterator cell_iterator
static const unsigned int space_dimension
unsigned int max_couplings_between_boundary_dofs() const
typename ActiveSelector::active_cell_iterator active_cell_iterator
const types::global_dof_index invalid_dof_index
virtual ~DoFHandler() override
const IndexSet & locally_owned_dofs() const
bool has_level_dofs() const
IteratorRange< cell_iterator > cell_iterators() const
typename ActiveSelector::active_quad_iterator active_quad_iterator
void save(Archive &ar, const unsigned int version) const
static const types::global_dof_index invalid_dof_index
std::vector< types::global_dof_index > vertex_dofs
typename ActiveSelector::active_hex_iterator active_hex_iterator