16 #ifndef dealii_hp_dof_handler_h 17 #define dealii_hp_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/iterator_range.h> 26 #include <deal.II/base/smartpointer.h> 27 #include <deal.II/base/template_constraints.h> 29 #include <deal.II/dofs/deprecated_function_map.h> 30 #include <deal.II/dofs/dof_accessor.h> 31 #include <deal.II/dofs/dof_iterator_selector.h> 32 #include <deal.II/dofs/number_cache.h> 34 #include <deal.II/hp/dof_faces.h> 35 #include <deal.II/hp/dof_level.h> 36 #include <deal.II/hp/fe_collection.h> 42 DEAL_II_NAMESPACE_OPEN
44 template <
int dim,
int spacedim>
49 namespace DoFHandlerImplementation
51 struct Implementation;
55 template <
int dim,
int spacedim>
57 struct Implementation;
65 namespace DoFHandlerImplementation
67 struct Implementation;
74 namespace DoFAccessorImplementation
76 struct Implementation;
79 namespace DoFCellAccessorImplementation
81 struct Implementation;
168 template <
int dim,
int spacedim = dim>
171 using ActiveSelector = ::internal::DoFHandlerImplementation::
172 Iterators<DoFHandler<dim, spacedim>,
false>;
173 using LevelSelector = ::internal::DoFHandlerImplementation::
174 Iterators<DoFHandler<dim, spacedim>,
true>;
177 using cell_accessor =
typename ActiveSelector::CellAccessor;
178 using face_accessor =
typename ActiveSelector::FaceAccessor;
180 using line_iterator =
typename ActiveSelector::line_iterator;
181 using active_line_iterator =
typename ActiveSelector::active_line_iterator;
183 using quad_iterator =
typename ActiveSelector::quad_iterator;
184 using active_quad_iterator =
typename ActiveSelector::active_quad_iterator;
186 using hex_iterator =
typename ActiveSelector::hex_iterator;
187 using active_hex_iterator =
typename ActiveSelector::active_hex_iterator;
200 using level_cell_iterator =
typename LevelSelector::cell_iterator;
225 using level_cell_accessor =
typename LevelSelector::CellAccessor;
226 using level_face_accessor =
typename LevelSelector::FaceAccessor;
228 using level_face_iterator =
typename LevelSelector::face_iterator;
233 static const unsigned int dimension = dim;
238 static const unsigned int space_dimension = spacedim;
341 set_active_fe_indices(
const std::vector<unsigned int> &active_fe_indices);
349 get_active_fe_indices(std::vector<unsigned int> &active_fe_indices)
const;
412 renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers);
432 max_couplings_between_dofs()
const;
447 max_couplings_between_boundary_dofs()
const;
457 begin(
const unsigned int level = 0)
const;
476 begin_active(
const unsigned int level = 0)
const;
490 end(
const unsigned int level)
const;
498 end_active(
const unsigned int level)
const;
515 cell_iterators()
const;
559 active_cell_iterators()
const;
577 cell_iterators_on_level(
const unsigned int level)
const;
595 active_cell_iterators_on_level(
const unsigned int level)
const;
637 n_dofs(
const unsigned int level)
const;
643 n_boundary_dofs()
const;
655 template <
typename number>
659 &boundary_ids)
const;
666 n_boundary_dofs(
const std::set<types::boundary_id> &boundary_ids)
const;
686 n_locally_owned_dofs()
const;
694 locally_owned_dofs()
const;
709 const std::vector<IndexSet> &
710 locally_owned_dofs_per_processor()
const;
727 const std::vector<types::global_dof_index> &
728 n_locally_owned_dofs_per_processor()
const;
737 locally_owned_mg_dofs(
const unsigned int level)
const;
745 const std::vector<IndexSet> &
746 locally_owned_mg_dofs_per_processor(
const unsigned int level)
const;
763 get_fe(
const unsigned int index)
const;
770 get_fe_collection()
const;
777 get_triangulation()
const;
788 memory_consumption()
const;
794 template <
class Archive>
796 save(Archive &ar,
const unsigned int version)
const;
802 template <
class Archive>
804 load(Archive &ar,
const unsigned int version);
806 BOOST_SERIALIZATION_SPLIT_MEMBER()
825 << "The matrix has the wrong dimension " << arg1);
834 types::global_dof_index,
835 << "The given list of new dof indices is not consecutive: "
836 << "the index " << arg1 << " does not exist.");
843 << "The mesh contains a cell with an active_fe_index of "
844 << arg1 << ", but the finite element collection only has "
845 << arg2 << " elements");
851 << "The given level " << arg1
852 << " is not in the valid range!");
862 << "You tried to do something on level " << arg1
863 << ", but this level is empty.");
881 std::unique_ptr<::
internal::DoFHandlerImplementation::Policy::
882 PolicyBase<dim, spacedim>>
890 setup_policy_and_listeners();
898 template <
int structdim>
899 types::global_dof_index
900 get_dof_index(const
unsigned int obj_level,
901 const
unsigned int obj_index,
902 const
unsigned int fe_index,
903 const
unsigned int local_index) const;
905 template <
int structdim>
907 set_dof_index(const
unsigned int obj_level,
908 const
unsigned int obj_index,
909 const
unsigned int fe_index,
910 const
unsigned int local_index,
911 const
types::global_dof_index global_index) const;
921 create_active_fe_table();
931 pre_refinement_action();
933 post_refinement_action();
954 ::
internal::DoFHandlerImplementation::NumberCache number_cache;
961 std::vector<::
internal::DoFHandlerImplementation::NumberCache>
990 std::vector<
unsigned int> vertex_dof_offsets;
998 std::vector<
std::unique_ptr<
std::vector<
bool>>> has_children;
1004 std::vector<
boost::signals2::connection> tria_listeners;
1009 template <
int, class,
bool>
1011 template <class,
bool>
1013 friend struct ::
internal::DoFAccessorImplementation::Implementation;
1014 friend struct ::
internal::DoFCellAccessorImplementation::
1023 friend struct ::
internal::
hp::DoFHandlerImplementation::
1025 friend struct ::
internal::DoFHandlerImplementation::Policy::
1038 template <
int dim,
int spacedim>
1039 template <
typename number>
1043 &boundary_ids)
const 1047 std::set<types::boundary_id> boundary_ids_only;
1050 p = boundary_ids.begin();
1051 p != boundary_ids.end();
1053 boundary_ids_only.insert(p->first);
1056 return n_boundary_dofs(boundary_ids_only);
1070 template <
int dim,
int spacedim>
1072 policy_to_string(const ::internal::DoFHandlerImplementation::Policy::
1073 PolicyBase<dim, spacedim> &policy);
1079 template <
int dim,
int spacedim>
1080 template <
class Archive>
1085 ar &vertex_dof_offsets;
1087 ar &mg_number_cache;
1092 const unsigned int n_levels = levels.size();
1094 for (
unsigned int i = 0; i < n_levels; ++i)
1100 bool faces_is_nullptr = (faces.get() ==
nullptr);
1101 ar & faces_is_nullptr;
1102 if (!faces_is_nullptr)
1106 const unsigned int n_has_children = has_children.size();
1107 ar & n_has_children;
1108 for (
unsigned int i = 0; i < n_has_children; ++i)
1109 ar &has_children[i];
1114 const unsigned int n_cells = tria->n_cells();
1115 std::string policy_name = ::internal::policy_to_string(*policy);
1117 ar &n_cells &policy_name;
1122 template <
int dim,
int spacedim>
1123 template <
class Archive>
1128 ar &vertex_dof_offsets;
1130 ar &mg_number_cache;
1137 has_children.clear();
1145 levels.resize(size);
1146 for (
unsigned int i = 0; i < size; ++i)
1148 std::unique_ptr<::internal::hp::DoFLevel> level;
1150 levels[i] = std::move(level);
1154 bool faces_is_nullptr =
true;
1155 ar & faces_is_nullptr;
1156 if (!faces_is_nullptr)
1161 has_children.resize(size);
1162 for (
unsigned int i = 0; i < size; ++i)
1164 std::unique_ptr<std::vector<bool>> has_children_on_level;
1165 ar & has_children_on_level;
1166 has_children[i] = std::move(has_children_on_level);
1171 unsigned int n_cells;
1172 std::string policy_name;
1174 ar &n_cells &policy_name;
1177 n_cells == tria->n_cells(),
1179 "The object being loaded into does not match the triangulation " 1180 "that has been stored previously."));
1181 AssertThrow(policy_name == ::internal::policy_to_string(*policy),
1183 "The policy currently associated with this DoFHandler (" +
1184 ::internal::policy_to_string(*policy) +
1185 ") does not match the one that was associated with the " 1186 "DoFHandler previously stored (" +
1187 policy_name +
")."));
1190 template <
int dim,
int spacedim>
1194 return number_cache.n_global_dofs;
1199 template <
int dim,
int spacedim>
1209 template <
int dim,
int spacedim>
1213 return number_cache.n_locally_owned_dofs;
1218 template <
int dim,
int spacedim>
1222 return number_cache.locally_owned_dofs;
1227 template <
int dim,
int spacedim>
1228 const std::vector<types::global_dof_index> &
1231 return number_cache.n_locally_owned_dofs_per_processor;
1236 template <
int dim,
int spacedim>
1237 const std::vector<IndexSet> &
1240 return number_cache.locally_owned_dofs_per_processor;
1245 template <
int dim,
int spacedim>
1248 const unsigned int level)
const 1252 Assert(level < this->get_triangulation().n_global_levels(),
1253 ExcMessage(
"invalid level in locally_owned_mg_dofs"));
1254 return mg_number_cache[0].locally_owned_dofs;
1258 template <
int dim,
int spacedim>
1259 const std::vector<IndexSet> &
1261 const unsigned int level)
const 1265 Assert(level < this->get_triangulation().n_global_levels(),
1266 ExcMessage(
"invalid level in locally_owned_mg_dofs_per_processor"));
1267 return mg_number_cache[0].locally_owned_dofs_per_processor;
1272 template <
int dim,
int spacedim>
1276 Assert(fe_collection.size() > 0,
1277 ExcMessage(
"No finite element collection is associated with " 1278 "this DoFHandler"));
1279 return fe_collection;
1284 template <
int dim,
int spacedim>
1288 Assert(fe_collection.size() > 0,
1289 ExcMessage(
"No finite element collection is associated with " 1290 "this DoFHandler"));
1291 return fe_collection[number];
1296 template <
int dim,
int spacedim>
1300 Assert(fe_collection.size() > 0,
1301 ExcMessage(
"No finite element collection is associated with " 1302 "this DoFHandler"));
1303 return fe_collection;
1308 template <
int dim,
int spacedim>
1313 ExcMessage(
"This DoFHandler object has not been associated " 1314 "with a triangulation."));
1322 DEAL_II_NAMESPACE_CLOSE
static const unsigned int invalid_unsigned_int
typename ActiveSelector::face_iterator face_iterator
#define DeclException2(Exception2, type1, type2, outsequence)
#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()
unsigned long long int global_dof_index
typename ActiveSelector::active_cell_iterator active_cell_iterator
static::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::cell_iterator cell_iterator
#define DeclException1(Exception1, type1, outsequence)
#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 IndexSet & locally_owned_mg_dofs(const unsigned int level) const
const std::vector< IndexSet > & locally_owned_mg_dofs_per_processor(const unsigned int level) const
void save(Archive &ar, const unsigned int version) const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
types::global_dof_index n_boundary_dofs() const
typename ActiveSelector::active_face_iterator active_face_iterator
void load(Archive &ar, const unsigned int version)
static::ExceptionBase & ExcInvalidBoundaryIndicator()
static::ExceptionBase & ExcNotImplemented()
const types::global_dof_index invalid_dof_index
const IndexSet & locally_owned_dofs() const
const std::vector< IndexSet > & locally_owned_dofs_per_processor() const
static::ExceptionBase & ExcNoFESelected()