16 #ifndef dealii_hp_dof_handler_h 17 #define dealii_hp_dof_handler_h 21 #include <deal.II/base/config.h> 22 #include <deal.II/base/exceptions.h> 23 #include <deal.II/base/template_constraints.h> 24 #include <deal.II/base/smartpointer.h> 25 #include <deal.II/base/iterator_range.h> 26 #include <deal.II/dofs/function_map.h> 27 #include <deal.II/dofs/dof_accessor.h> 28 #include <deal.II/dofs/dof_iterator_selector.h> 29 #include <deal.II/dofs/number_cache.h> 30 #include <deal.II/hp/fe_collection.h> 31 #include <deal.II/hp/dof_faces.h> 32 #include <deal.II/hp/dof_level.h> 38 DEAL_II_NAMESPACE_OPEN
44 namespace DoFHandlerImplementation
46 struct Implementation;
50 template <
int dim,
int spacedim>
class PolicyBase;
51 struct Implementation;
59 namespace DoFHandlerImplementation
61 struct Implementation;
68 namespace DoFAccessorImplementation
70 struct Implementation;
73 namespace DoFCellAccessorImplementation
75 struct Implementation;
163 template <
int dim,
int spacedim=dim>
166 typedef ::internal::DoFHandlerImplementation::Iterators<DoFHandler<dim,spacedim>,
false> ActiveSelector;
167 typedef ::internal::DoFHandlerImplementation::Iterators<DoFHandler<dim,spacedim>,
true> LevelSelector;
169 typedef typename ActiveSelector::CellAccessor cell_accessor;
170 typedef typename ActiveSelector::FaceAccessor face_accessor;
172 typedef typename ActiveSelector::line_iterator line_iterator;
173 typedef typename ActiveSelector::active_line_iterator active_line_iterator;
175 typedef typename ActiveSelector::quad_iterator quad_iterator;
176 typedef typename ActiveSelector::active_quad_iterator active_quad_iterator;
178 typedef typename ActiveSelector::hex_iterator hex_iterator;
179 typedef typename ActiveSelector::active_hex_iterator active_hex_iterator;
191 typedef typename LevelSelector::cell_iterator level_cell_iterator;
215 typedef typename LevelSelector::CellAccessor level_cell_accessor;
216 typedef typename LevelSelector::FaceAccessor level_face_accessor;
218 typedef typename LevelSelector::face_iterator level_face_iterator;
340 virtual void clear ();
394 void renumber_dofs (
const std::vector<types::global_dof_index> &new_numbers);
621 template <
typename number>
630 n_boundary_dofs (
const std::set<types::boundary_id> &boundary_ids)
const;
672 const std::vector<IndexSet> &
691 const std::vector<types::global_dof_index> &
708 const std::vector<IndexSet> &
725 get_fe (
const unsigned int index)
const;
753 template <
class Archive>
754 void save(Archive &ar,
const unsigned int version)
const;
760 template <
class Archive>
761 void load(Archive &ar,
const unsigned int version);
763 BOOST_SERIALIZATION_SPLIT_MEMBER()
782 << "The matrix has the wrong
dimension " << arg1);
791 types::global_dof_index,
792 << "The given list of new dof indices is not consecutive: "
793 << "the index " << arg1 << " does not exist.");
799 << "The mesh contains a cell with an active_fe_index of "
800 << arg1 << ", but the finite element collection only has "
801 << arg2 << " elements");
807 << "The given level " << arg1
808 << " is not in the valid range!");
818 << "You tried to do something on level " << arg1
819 << ", but this level is empty.");
837 std::unique_ptr<::
internal::DoFHandlerImplementation::Policy::PolicyBase<dim,spacedim> >
policy;
850 template <
int structdim>
851 types::global_dof_index get_dof_index (const
unsigned int obj_level,
852 const
unsigned int obj_index,
853 const
unsigned int fe_index,
854 const
unsigned int local_index) const;
856 template <
int structdim>
857 void set_dof_index (const
unsigned int obj_level,
858 const
unsigned int obj_index,
859 const
unsigned int fe_index,
860 const
unsigned int local_index,
861 const
types::global_dof_index global_index) const;
880 void post_refinement_action ();
957 friend struct ::
internal::DoFAccessorImplementation::Implementation;
958 friend struct ::
internal::DoFCellAccessorImplementation::Implementation;
964 template <
int> friend class ::
internal::
hp::DoFIndicesOnFacesOrEdges;
965 friend struct ::
internal::
hp::DoFHandlerImplementation::Implementation;
966 friend struct ::
internal::DoFHandlerImplementation::Policy::Implementation;
977 template <
int dim,
int spacedim>
978 template <
typename number>
983 std::set<types::boundary_id> boundary_ids_only;
985 p = boundary_ids.begin();
986 p != boundary_ids.end(); ++p)
987 boundary_ids_only.insert (p->first);
1004 template <
int dim,
int spacedim>
1005 std::string policy_to_string(const ::internal::DoFHandlerImplementation::Policy::PolicyBase<dim,spacedim> &policy);
1011 template <
int dim,
int spacedim>
1012 template <
class Archive>
1016 ar &vertex_dof_offsets;
1018 ar &mg_number_cache;
1023 const unsigned int n_levels = levels.size();
1025 for (
unsigned int i = 0; i < n_levels; ++i)
1031 bool faces_is_nullptr = (faces.get()==
nullptr);
1032 ar &faces_is_nullptr;
1033 if (!faces_is_nullptr)
1037 const unsigned int n_has_children = has_children.size();
1039 for (
unsigned int i = 0; i < n_has_children; ++i)
1040 ar &has_children[i];
1045 const unsigned int n_cells = tria->n_cells();
1046 std::string policy_name = ::internal::policy_to_string(*policy);
1048 ar &n_cells &policy_name;
1053 template <
int dim,
int spacedim>
1054 template <
class Archive>
1058 ar &vertex_dof_offsets;
1060 ar &mg_number_cache;
1067 has_children.clear ();
1075 levels.resize(size);
1076 for (
unsigned int i = 0; i < size; ++i)
1078 std::unique_ptr<::internal::hp::DoFLevel> level;
1080 levels[i] = std::move(level);
1084 bool faces_is_nullptr =
true;
1085 ar &faces_is_nullptr;
1086 if (!faces_is_nullptr)
1091 has_children.resize(size);
1092 for (
unsigned int i = 0; i < size; ++i)
1094 std::unique_ptr<std::vector<bool> > has_children_on_level;
1095 ar &has_children_on_level;
1096 has_children[i] = std::move(has_children_on_level);
1101 unsigned int n_cells;
1102 std::string policy_name;
1104 ar &n_cells &policy_name;
1107 ExcMessage (
"The object being loaded into does not match the triangulation " 1108 "that has been stored previously."));
1109 AssertThrow (policy_name == ::internal::policy_to_string(*policy),
1110 ExcMessage (
"The policy currently associated with this DoFHandler (" 1111 + ::internal::policy_to_string(*policy)
1112 +
") does not match the one that was associated with the " 1113 "DoFHandler previously stored (" 1118 template <
int dim,
int spacedim>
1123 return number_cache.n_global_dofs;
1128 template <
int dim,
int spacedim>
1139 template <
int dim,
int spacedim>
1143 return number_cache.n_locally_owned_dofs;
1148 template <
int dim,
int spacedim>
1152 return number_cache.locally_owned_dofs;
1157 template <
int dim,
int spacedim>
1158 const std::vector<types::global_dof_index> &
1161 return number_cache.n_locally_owned_dofs_per_processor;
1166 template <
int dim,
int spacedim>
1167 const std::vector<IndexSet> &
1170 return number_cache.locally_owned_dofs_per_processor;
1175 template <
int dim,
int spacedim>
1181 Assert(level < this->get_triangulation().n_global_levels(),
1182 ExcMessage(
"invalid level in locally_owned_mg_dofs"));
1183 return mg_number_cache[0].locally_owned_dofs;
1187 template <
int dim,
int spacedim>
1188 const std::vector<IndexSet> &
1193 Assert(level < this->get_triangulation().n_global_levels(),
1194 ExcMessage(
"invalid level in locally_owned_mg_dofs_per_processor"));
1195 return mg_number_cache[0].locally_owned_dofs_per_processor;
1200 template <
int dim,
int spacedim>
1205 Assert (fe_collection.size() > 0,
1206 ExcMessage (
"No finite element collection is associated with " 1207 "this DoFHandler"));
1208 return fe_collection;
1213 template <
int dim,
int spacedim>
1217 (
const unsigned int number)
const 1219 Assert (fe_collection.size() > 0,
1220 ExcMessage (
"No finite element collection is associated with " 1221 "this DoFHandler"));
1222 return fe_collection[number];
1227 template <
int dim,
int spacedim>
1232 Assert (fe_collection.size() > 0,
1233 ExcMessage (
"No finite element collection is associated with " 1234 "this DoFHandler"));
1235 return fe_collection;
1240 template <
int dim,
int spacedim>
1246 ExcMessage(
"This DoFHandler object has not been associated " 1247 "with a triangulation."));
1255 DEAL_II_NAMESPACE_CLOSE
cell_iterator begin(const unsigned int level=0) const
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
void get_active_fe_indices(std::vector< unsigned int > &active_fe_indices) const
const std::vector< IndexSet > & locally_owned_mg_dofs_per_processor(const unsigned int level) const
types::global_dof_index n_locally_owned_dofs() const
virtual void distribute_dofs(const hp::FECollection< dim, spacedim > &fe)
static const unsigned int invalid_unsigned_int
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcInvalidFEIndex(int arg1, int arg2)
void renumber_dofs(const std::vector< types::global_dof_index > &new_numbers)
std::vector<::internal::DoFHandlerImplementation::NumberCache > mg_number_cache
virtual std::size_t memory_consumption() const
void set_active_fe_indices(const std::vector< unsigned int > &active_fe_indices)
::internal::DoFHandlerImplementation::NumberCache number_cache
static ::ExceptionBase & ExcGridsDoNotMatch()
std::vector< std::unique_ptr<::internal::hp::DoFLevel > > levels
const std::vector< types::global_dof_index > & n_locally_owned_dofs_per_processor() const
std::vector< std::unique_ptr< std::vector< bool > > > has_children
void pre_refinement_action()
active_cell_iterator begin_active(const unsigned int level=0) const
std::unique_ptr<::internal::hp::DoFIndicesOnFaces< dim > > faces
static ::ExceptionBase & ExcFunctionNotUseful()
void setup_policy_and_listeners()
static ::ExceptionBase & ExcNewNumbersNotConsecutive(types::global_dof_index arg1)
std::unique_ptr<::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > > policy
#define AssertThrow(cond, exc)
std::vector< boost::signals2::connection > tria_listeners
hp::FECollection< dim, spacedim > fe_collection
static const unsigned int dimension
ActiveSelector::active_cell_iterator active_cell_iterator
static const unsigned int default_fe_index
const hp::FECollection< dim, spacedim > & get_fe() const
static ::ExceptionBase & ExcNoFESelected()
static ::ExceptionBase & ExcMessage(std::string arg1)
static const unsigned int space_dimension
#define DeclException1(Exception1, type1, outsequence)
unsigned int global_dof_index
#define Assert(cond, exc)
static ::ExceptionBase & ExcFacesHaveNoLevel()
IteratorRange< active_cell_iterator > active_cell_iterators() const
const IndexSet & locally_owned_dofs() const
ActiveSelector::face_iterator face_iterator
void save(Archive &ar, const unsigned int version) const
const std::vector< IndexSet > & locally_owned_dofs_per_processor() const
#define DeclException0(Exception0)
unsigned int max_couplings_between_boundary_dofs() const
ActiveSelector::cell_iterator cell_iterator
static ::ExceptionBase & ExcInvalidLevel(int arg1)
const hp::FECollection< dim, spacedim > & get_fe_collection() const
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
types::global_dof_index n_boundary_dofs() const
active_cell_iterator end_active(const unsigned int level) const
SmartPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
ActiveSelector::active_face_iterator active_face_iterator
void initialize(const Triangulation< dim, spacedim > &tria, const hp::FECollection< dim, spacedim > &fe)
const Triangulation< dim, spacedim > & get_triangulation() const
unsigned int max_couplings_between_dofs() const
void load(Archive &ar, const unsigned int version)
static ::ExceptionBase & ExcMatrixHasWrongSize(int arg1)
types::global_dof_index n_dofs() const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
static ::ExceptionBase & ExcNotImplemented()
const types::global_dof_index invalid_dof_index
void create_active_fe_table()
std::vector< types::global_dof_index > vertex_dofs
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
cell_iterator end() const
IteratorRange< cell_iterator > cell_iterators() const
std::vector< unsigned int > vertex_dof_offsets
static ::ExceptionBase & ExcEmptyLevel(int arg1)
DoFHandler & operator=(const DoFHandler &)=delete
static const types::global_dof_index invalid_dof_index