17 #ifndef __deal2__dof_handler_h
18 #define __deal2__dof_handler_h
22 #include <deal.II/base/config.h>
24 #include <deal.II/base/smartpointer.h>
25 #include <deal.II/base/index_set.h>
26 #include <deal.II/base/std_cxx1x/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/function_map.h>
32 #include <boost/serialization/split_member.hpp>
44 template <
int dim>
class DoFLevel;
45 template <
int dim>
class DoFFaces;
47 struct Implementation;
52 struct Implementation;
58 struct Implementation;
63 struct Implementation;
182 template <
int dim,
int spacedim=dim>
185 typedef ::internal::DoFHandler::Iterators<DoFHandler<dim,spacedim>,
false> ActiveSelector;
186 typedef ::internal::DoFHandler::Iterators<DoFHandler<dim,spacedim>,
true> LevelSelector;
188 typedef typename ActiveSelector::CellAccessor cell_accessor;
189 typedef typename ActiveSelector::FaceAccessor face_accessor;
191 typedef typename ActiveSelector::line_iterator line_iterator;
192 typedef typename ActiveSelector::active_line_iterator active_line_iterator;
194 typedef typename ActiveSelector::quad_iterator quad_iterator;
195 typedef typename ActiveSelector::active_quad_iterator active_quad_iterator;
197 typedef typename ActiveSelector::hex_iterator hex_iterator;
198 typedef typename ActiveSelector::active_hex_iterator active_hex_iterator;
200 typedef typename ActiveSelector::active_cell_iterator active_cell_iterator;
202 typedef typename ActiveSelector::face_iterator face_iterator;
203 typedef typename ActiveSelector::active_face_iterator active_face_iterator;
205 typedef typename LevelSelector::CellAccessor level_cell_accessor;
206 typedef typename LevelSelector::FaceAccessor level_face_accessor;
208 typedef typename LevelSelector::cell_iterator level_cell_iterator;
209 typedef typename LevelSelector::face_iterator level_face_iterator;
211 typedef typename ActiveSelector::cell_iterator cell_iterator;
369 virtual void clear ();
439 void renumber_dofs (
const std::vector<types::global_dof_index> &new_numbers);
447 const std::vector<types::global_dof_index> &new_numbers);
522 cell_iterator
begin (
const unsigned int level = 0)
const;
536 active_cell_iterator
begin_active(
const unsigned int level = 0)
const;
545 cell_iterator
end ()
const;
553 cell_iterator
end (
const unsigned int level)
const;
560 active_cell_iterator
end_active (
const unsigned int level)
const;
568 level_cell_iterator
begin_mg (
const unsigned int level = 0)
const;
575 level_cell_iterator
end_mg (
const unsigned int level)
const;
584 level_cell_iterator
end_mg ()
const;
670 n_boundary_dofs (
const std::set<types::boundary_id> &boundary_indicators)
const;
767 const std::vector<IndexSet> &
770 const std::vector<IndexSet> &
771 locally_owned_mg_dofs_per_processor (
const unsigned int level)
const;
799 const std::vector<types::global_dof_index> &
835 template <
class Archive>
836 void save (Archive &ar,
const unsigned int version)
const;
843 template <
class Archive>
844 void load (Archive &ar,
const unsigned int version);
846 BOOST_SERIALIZATION_SPLIT_MEMBER()
872 types::global_dof_index,
873 << "The given list of new dof indices is not consecutive: "
874 << "the index " << arg1 << " does not exist.");
881 << "The given level " << arg1
882 << " is not in the
valid range!");
895 << "You tried to do something on level " << arg1
896 << ", but this level is empty.");
984 DoFHandler &operator = (const DoFHandler &);
1011 void init (
const unsigned int coarsest_level,
1012 const unsigned int finest_level,
1013 const unsigned int dofs_per_vertex);
1019 unsigned int get_coarsest_level ()
const;
1025 unsigned int get_finest_level ()
const;
1032 get_index (
const unsigned int level,
1033 const unsigned int dof_number)
const;
1040 void set_index (
const unsigned int level,
1041 const unsigned int dof_number,
1075 void clear_mg_space ();
1082 void reserve_space ();
1084 template <
int structdim>
1085 types::global_dof_index get_dof_index (
const unsigned int obj_level,
const unsigned int obj_index,
const unsigned int fe_index,
const unsigned int local_index)
const;
1087 template<
int structdim>
1088 void set_dof_index (
const unsigned int obj_level,
const unsigned int obj_index,
const unsigned int fe_index,
const unsigned int local_index,
const types::global_dof_index global_index)
const;
1097 std::vector<::internal::DoFHandler::DoFLevel<dim>*>
levels;
1099 std::vector<::internal::DoFHandler::DoFLevel<dim>*> mg_levels;
1113 std::vector<MGVertexDoFs> mg_vertex_dofs;
1120 friend struct ::internal::DoFAccessor::Implementation;
1121 friend struct ::internal::DoFCellAccessor::Implementation;
1123 friend struct ::internal::DoFHandler::Implementation;
1124 friend struct ::internal::DoFHandler::Policy::Implementation;
1146 template <
int dim,
int spacedim>
1151 return mg_number_cache.size()>0;
1154 template <
int dim,
int spacedim>
1159 return number_cache.n_global_dofs>0;
1162 template <
int dim,
int spacedim>
1167 return number_cache.n_global_dofs;
1170 template<
int dim,
int spacedim>
1174 Assert(has_level_dofs(),
ExcMessage(
"n_dofs(level) can only be called after distribute_mg_dofs()"));
1175 Assert (level < mg_number_cache.size (), ExcInvalidLevel (level));
1176 return mg_number_cache[
level].n_global_dofs;
1180 template <
int dim,
int spacedim>
1184 return number_cache.n_locally_owned_dofs;
1188 template <
int dim,
int spacedim>
1192 return number_cache.locally_owned_dofs;
1195 template <
int dim,
int spacedim>
1199 Assert(level < this->get_tria().n_global_levels(),
ExcMessage(
"invalid level in locally_owned_mg_dofs"));
1200 return mg_number_cache[
level].locally_owned_dofs;
1203 template <
int dim,
int spacedim>
1204 const std::vector<types::global_dof_index> &
1207 return number_cache.n_locally_owned_dofs_per_processor;
1211 template <
int dim,
int spacedim>
1212 const std::vector<IndexSet> &
1215 return number_cache.locally_owned_dofs_per_processor;
1218 template <
int dim,
int spacedim>
1219 const std::vector<IndexSet> &
1222 Assert(level < this->get_tria().n_global_levels(),
ExcMessage(
"invalid level in locally_owned_mg_dofs_per_processor"));
1223 return mg_number_cache[
level].locally_owned_dofs_per_processor;
1227 template <
int dim,
int spacedim>
1233 return *selected_fe;
1237 template <
int dim,
int spacedim>
1247 template <
int dim,
int spacedim>
1252 return block_info_object;
1265 template<
int dim,
int spacedim>
1266 std::string policy_to_string(const ::internal::DoFHandler::Policy::PolicyBase<dim,spacedim> &policy);
1271 template <
int dim,
int spacedim>
1272 template <
class Archive>
1274 const unsigned int)
const
1276 ar &block_info_object;
1285 unsigned int n_cells = tria->n_cells();
1286 std::string fe_name = selected_fe->get_name();
1287 std::string policy_name = internal::policy_to_string(*policy);
1289 ar &n_cells &fe_name &policy_name;
1293 template <
int dim,
int spacedim>
1294 template <
class Archive>
1298 ar &block_info_object;
1306 for (
unsigned int i=0; i<levels.size(); ++i)
1316 unsigned int n_cells;
1317 std::string fe_name;
1318 std::string policy_name;
1320 ar &n_cells &fe_name &policy_name;
1323 ExcMessage (
"The object being loaded into does not match the triangulation "
1324 "that has been stored previously."));
1326 ExcMessage (
"The finite element associated with this DoFHandler does not match "
1327 "the one that was associated with the DoFHandler previously stored."));
1328 AssertThrow (policy_name == internal::policy_to_string(*policy),
1329 ExcMessage (std::string (
"The policy currently associated with this DoFHandler (")
1330 + internal::policy_to_string(*policy)
1331 +std::string(
") does not match the one that was associated with the "
1332 "DoFHandler previously stored (")
1338 template<
int dim,
int spacedim>
1341 const unsigned int level,
1342 const unsigned int dof_number)
const
1349 template<
int dim,
int spacedim>
1352 const unsigned int level,
1353 const unsigned int dof_number,
1356 Assert ((level >= coarsest_level) && (level <= finest_level), ExcInvalidLevel (level));
1357 indices[indices_offset[level - coarsest_level] + dof_number] = index;
1362 DEAL_II_NAMESPACE_CLOSE
active_cell_iterator begin_active(const unsigned int level=0) const
DeclException1(ExcNewNumbersNotConsecutive, types::global_dof_index,<< "The given list of new dof indices is not consecutive: "<< "the index "<< arg1<< " does not exist.")
static const unsigned int space_dimension
Iterator points to a valid object.
bool has_active_dofs() const
::internal::DoFHandler::DoFFaces< dim > * faces
SmartPointer< const FiniteElement< dim, spacedim >, DoFHandler< dim, spacedim > > selected_fe
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)
active_cell_iterator end_active(const unsigned int level) const
static const unsigned int dimension
cell_iterator end() const
std::vector<::internal::DoFHandler::NumberCache > mg_number_cache
unsigned int max_couplings_between_boundary_dofs() const
const BlockInfo & block_info() const
#define AssertThrow(cond, exc)
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
level_cell_iterator begin_mg(const unsigned int level=0) const
const std::vector< types::global_dof_index > & n_locally_owned_dofs_per_processor() const
::FunctionMap< spacedim >::type FunctionMap
types::global_dof_index n_dofs() const
unsigned int max_couplings_between_dofs() const
unsigned int n_locally_owned_dofs() const
unsigned int finest_level
void initialize_local_block_info()
unsigned int global_dof_index
types::global_dof_index * indices_offset
#define Assert(cond, exc)
void initialize(const Triangulation< dim, spacedim > &tria, const FiniteElement< dim, spacedim > &fe)
const IndexSet & locally_owned_dofs() const
virtual void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
std::vector<::internal::DoFHandler::DoFLevel< dim > * > levels
bool has_level_dofs() const
const Triangulation< dim, spacedim > * tria
types::global_dof_index get_index(const unsigned int level, const unsigned int dof_number) const
const std::vector< IndexSet > & locally_owned_dofs_per_processor() const
std::vector< types::global_dof_index > vertex_dofs
BlockInfo block_info_object
const Triangulation< dim, spacedim > & get_tria() const
SmartPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
unsigned int coarsest_level
std_cxx1x::shared_ptr<::internal::DoFHandler::Policy::PolicyBase< dim, spacedim > > policy
void load(Archive &ar, const unsigned int version)
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
::ExceptionBase & ExcNotInitialized()
virtual void distribute_mg_dofs(const FiniteElement< dim, spacedim > &fe)
static const types::global_dof_index invalid_dof_index
level_cell_iterator end_mg() const
static const unsigned int default_fe_index
void save(Archive &ar, const unsigned int version) const
types::global_dof_index n_boundary_dofs() const
const FiniteElement< dim, spacedim > & get_fe() const
::internal::DoFHandler::NumberCache number_cache
virtual std::size_t memory_consumption() const
cell_iterator begin(const unsigned int level=0) const
const types::global_dof_index invalid_dof_index
void renumber_dofs(const std::vector< types::global_dof_index > &new_numbers)
DeclException0(ExcRenumberingIncomplete)