16 #ifndef dealii__dof_handler_h 17 #define dealii__dof_handler_h 21 #include <deal.II/base/config.h> 22 #include <deal.II/base/exceptions.h> 23 #include <deal.II/base/smartpointer.h> 24 #include <deal.II/base/index_set.h> 25 #include <deal.II/base/iterator_range.h> 26 #include <deal.II/base/std_cxx11/shared_ptr.h> 27 #include <deal.II/dofs/block_info.h> 28 #include <deal.II/dofs/dof_iterator_selector.h> 29 #include <deal.II/dofs/number_cache.h> 30 #include <deal.II/dofs/dof_faces.h> 31 #include <deal.II/dofs/dof_levels.h> 32 #include <deal.II/dofs/function_map.h> 34 #include <boost/serialization/split_member.hpp> 40 DEAL_II_NAMESPACE_OPEN
46 struct Implementation;
51 struct Implementation;
57 struct Implementation;
62 struct Implementation;
183 template <
int dim,
int spacedim=dim>
186 typedef ::internal::DoFHandler::Iterators<DoFHandler<dim,spacedim>,
false> ActiveSelector;
187 typedef ::internal::DoFHandler::Iterators<DoFHandler<dim,spacedim>,
true> LevelSelector;
189 typedef typename ActiveSelector::CellAccessor cell_accessor;
190 typedef typename ActiveSelector::FaceAccessor face_accessor;
192 typedef typename ActiveSelector::line_iterator line_iterator;
193 typedef typename ActiveSelector::active_line_iterator active_line_iterator;
195 typedef typename ActiveSelector::quad_iterator quad_iterator;
196 typedef typename ActiveSelector::active_quad_iterator active_quad_iterator;
198 typedef typename ActiveSelector::hex_iterator hex_iterator;
199 typedef typename ActiveSelector::active_hex_iterator active_hex_iterator;
251 typedef typename ActiveSelector::face_iterator face_iterator;
252 typedef typename ActiveSelector::active_face_iterator active_face_iterator;
254 typedef typename LevelSelector::CellAccessor level_cell_accessor;
255 typedef typename LevelSelector::FaceAccessor level_face_accessor;
257 typedef typename LevelSelector::cell_iterator level_cell_iterator;
258 typedef typename LevelSelector::face_iterator level_face_iterator;
269 static const unsigned int dimension = dim;
274 static const unsigned int space_dimension = spacedim;
296 static const unsigned int default_fe_index = 0;
357 bool has_level_dofs()
const;
373 bool has_active_dofs()
const;
381 void initialize_local_block_info();
388 virtual void clear ();
419 void renumber_dofs (
const std::vector<types::global_dof_index> &new_numbers);
425 void renumber_dofs (
const unsigned int level,
426 const std::vector<types::global_dof_index> &new_numbers);
456 unsigned int max_couplings_between_dofs ()
const;
470 unsigned int max_couplings_between_boundary_dofs ()
const;
485 cell_iterator begin (
const unsigned int level = 0)
const;
499 active_cell_iterator begin_active(
const unsigned int level = 0)
const;
505 cell_iterator end ()
const;
511 cell_iterator end (
const unsigned int level)
const;
518 active_cell_iterator end_active (
const unsigned int level)
const;
525 level_cell_iterator begin_mg (
const unsigned int level = 0)
const;
531 level_cell_iterator end_mg (
const unsigned int level)
const;
537 level_cell_iterator end_mg ()
const;
711 n_boundary_dofs (
const FunctionMap &boundary_ids)
const;
718 n_boundary_dofs (
const std::set<types::boundary_id> &boundary_ids)
const;
751 unsigned int n_locally_owned_dofs()
const;
758 const IndexSet &locally_owned_dofs()
const;
764 const IndexSet &locally_owned_mg_dofs(
const unsigned int level)
const;
775 const std::vector<IndexSet> &
776 locally_owned_dofs_per_processor ()
const;
778 const std::vector<IndexSet> &
779 locally_owned_mg_dofs_per_processor (
const unsigned int level)
const;
793 const std::vector<types::global_dof_index> &
794 n_locally_owned_dofs_per_processor ()
const;
811 const
Triangulation<dim,spacedim> &get_triangulation () const;
821 virtual
std::
size_t memory_consumption () const;
827 template <class Archive>
828 void save (Archive &ar, const
unsigned int version) const;
834 template <class Archive>
835 void load (Archive &ar, const
unsigned int version);
837 BOOST_SERIALIZATION_SPLIT_MEMBER()
845 DeclException0 (ExcRenumberingIncomplete);
850 DeclException0 (ExcGridsDoNotMatch);
855 DeclException0 (ExcInvalidBoundaryIndicator);
861 types::global_dof_index,
862 << "The given list of new dof indices is not consecutive: "
863 << "the index " << arg1 << " does not exist.");
870 << "The given level " << arg1
871 << " is not in the valid range!");
876 DeclException0 (ExcFacesHaveNoLevel);
883 << "You tried to do something on level " << arg1
884 << ", but this level is empty.");
902 DoFHandler &operator = (const DoFHandler &);
971 void init (
const unsigned int coarsest_level,
972 const unsigned int finest_level,
973 const unsigned int dofs_per_vertex);
978 unsigned int get_coarsest_level ()
const;
983 unsigned int get_finest_level ()
const;
990 get_index (
const unsigned int level,
991 const unsigned int dof_number)
const;
997 void set_index (
const unsigned int level,
998 const unsigned int dof_number,
1031 void clear_mg_space ();
1036 void clear_space ();
1038 void reserve_space ();
1040 template <
int structdim>
1042 const unsigned int obj_index,
1043 const unsigned int fe_index,
1044 const unsigned int local_index)
const;
1046 template<
int structdim>
1047 void set_dof_index (
const unsigned int obj_level,
1048 const unsigned int obj_index,
1049 const unsigned int fe_index,
1050 const unsigned int local_index,
1068 std::vector<::internal::DoFHandler::DoFLevel<dim>*>
levels;
1070 std::vector<::internal::DoFHandler::DoFLevel<dim>*> mg_levels;
1086 friend struct ::internal::DoFAccessor::Implementation;
1087 friend struct ::internal::DoFCellAccessor::Implementation;
1089 friend struct ::internal::DoFHandler::Implementation;
1090 friend struct ::internal::DoFHandler::Policy::Implementation;
1112 template <
int dim,
int spacedim>
1117 return mg_number_cache.size()>0;
1120 template <
int dim,
int spacedim>
1125 return number_cache.n_global_dofs>0;
1128 template <
int dim,
int spacedim>
1133 return number_cache.n_global_dofs;
1136 template<
int dim,
int spacedim>
1140 Assert(has_level_dofs(),
ExcMessage(
"n_dofs(level) can only be called after distribute_mg_dofs()"));
1141 Assert (level < mg_number_cache.size (), ExcInvalidLevel (level));
1142 return mg_number_cache[
level].n_global_dofs;
1146 template <
int dim,
int spacedim>
1150 return number_cache.n_locally_owned_dofs;
1154 template <
int dim,
int spacedim>
1158 return number_cache.locally_owned_dofs;
1161 template <
int dim,
int spacedim>
1166 return mg_number_cache[
level].locally_owned_dofs;
1169 template <
int dim,
int spacedim>
1170 const std::vector<types::global_dof_index> &
1173 return number_cache.n_locally_owned_dofs_per_processor;
1177 template <
int dim,
int spacedim>
1178 const std::vector<IndexSet> &
1181 return number_cache.locally_owned_dofs_per_processor;
1184 template <
int dim,
int spacedim>
1185 const std::vector<IndexSet> &
1189 return mg_number_cache[
level].locally_owned_dofs_per_processor;
1193 template <
int dim,
int spacedim>
1198 Assert(selected_fe!=0,
ExcMessage(
"You are trying to access the DoFHandler's FiniteElement object before it has been initialized."));
1199 return *selected_fe;
1204 template <
int dim,
int spacedim>
1215 template <
int dim,
int spacedim>
1226 template <
int dim,
int spacedim>
1231 return block_info_object;
1244 template<
int dim,
int spacedim>
1245 std::string policy_to_string(const ::internal::DoFHandler::Policy::PolicyBase<dim,spacedim> &policy);
1250 template <
int dim,
int spacedim>
1251 template <
class Archive>
1253 const unsigned int)
const 1255 ar &block_info_object;
1264 unsigned int n_cells = tria->n_cells();
1265 std::string fe_name = selected_fe->get_name();
1266 std::string policy_name = internal::policy_to_string(*policy);
1268 ar &n_cells &fe_name &policy_name;
1272 template <
int dim,
int spacedim>
1273 template <
class Archive>
1277 ar &block_info_object;
1285 for (
unsigned int i=0; i<levels.size(); ++i)
1296 unsigned int n_cells;
1297 std::string fe_name;
1298 std::string policy_name;
1300 ar &n_cells &fe_name &policy_name;
1303 ExcMessage (
"The object being loaded into does not match the triangulation " 1304 "that has been stored previously."));
1306 ExcMessage (
"The finite element associated with this DoFHandler does not match " 1307 "the one that was associated with the DoFHandler previously stored."));
1308 AssertThrow (policy_name == internal::policy_to_string(*policy),
1309 ExcMessage (std::string (
"The policy currently associated with this DoFHandler (")
1310 + internal::policy_to_string(*policy)
1311 +std::string(
") does not match the one that was associated with the " 1312 "DoFHandler previously stored (")
1318 template<
int dim,
int spacedim>
1321 const unsigned int level,
1322 const unsigned int dof_number)
const 1324 Assert ((level >= coarsest_level) && (level <= finest_level), ExcInvalidLevel (level));
1325 return indices[indices_offset[level - coarsest_level] + dof_number];
1329 template<
int dim,
int spacedim>
1332 const unsigned int level,
1333 const unsigned int dof_number,
1336 Assert ((level >= coarsest_level) && (level <= finest_level), ExcInvalidLevel (level));
1337 indices[indices_offset[level - coarsest_level] + dof_number] = index;
1342 DEAL_II_NAMESPACE_CLOSE
std::vector< MGVertexDoFs > mg_vertex_dofs
::FunctionMap< spacedim >::type FunctionMap
types::global_dof_index * indices
void set_index(const unsigned int level, const unsigned int dof_number, const types::global_dof_index index)
::ExceptionBase & ExcMessage(std::string arg1)
const BlockInfo & block_info() const
std::vector<::internal::DoFHandler::DoFLevel< dim > * > levels
ActiveSelector::active_cell_iterator active_cell_iterator
#define AssertThrow(cond, exc)
const FiniteElement< dim, spacedim > & get_fe() const
BlockDynamicSparsityPattern BlockCompressedSparsityPattern DEAL_II_DEPRECATED
unsigned int n_locally_owned_dofs() const
const std::vector< types::global_dof_index > & n_locally_owned_dofs_per_processor() const
unsigned int finest_level
ActiveSelector::cell_iterator cell_iterator
#define DeclException1(Exception1, type1, outsequence)
unsigned int global_dof_index
types::global_dof_index * indices_offset
bool has_active_dofs() const
#define Assert(cond, exc)
types::global_dof_index get_index(const unsigned int level, const unsigned int dof_number) const
const Triangulation< dim, spacedim > * tria
#define DeclException0(Exception0)
types::global_dof_index n_boundary_dofs() const
types::global_dof_index n_dofs() const
::internal::DoFHandler::DoFFaces< dim > * faces
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
void renumber_dofs(const std::vector< types::global_dof_index > &new_numbers)
const Triangulation< dim, spacedim > & get_tria() const DEAL_II_DEPRECATED
const std::vector< IndexSet > & locally_owned_dofs_per_processor() 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...
const Triangulation< dim, spacedim > & get_triangulation() const
const Triangulation< dim, spacedim > & get_triangulation() const
const types::global_dof_index invalid_dof_index
const IndexSet & locally_owned_dofs() const
bool has_level_dofs() const
void save(Archive &ar, const unsigned int version) const
std::vector< types::global_dof_index > vertex_dofs