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
49 struct Implementation;
54 struct Implementation;
65 struct Implementation;
190 template <
int dim,
int spacedim=dim>
193 typedef ::internal::DoFHandler::Iterators<DoFHandler<dim,spacedim>,
false> ActiveSelector;
194 typedef ::internal::DoFHandler::Iterators<DoFHandler<dim,spacedim>,
true> LevelSelector;
196 typedef typename ActiveSelector::CellAccessor cell_accessor;
197 typedef typename ActiveSelector::FaceAccessor face_accessor;
199 typedef typename ActiveSelector::line_iterator line_iterator;
200 typedef typename ActiveSelector::active_line_iterator active_line_iterator;
202 typedef typename ActiveSelector::quad_iterator quad_iterator;
203 typedef typename ActiveSelector::active_quad_iterator active_quad_iterator;
205 typedef typename ActiveSelector::hex_iterator hex_iterator;
206 typedef typename ActiveSelector::active_hex_iterator active_hex_iterator;
258 typedef typename ActiveSelector::face_iterator face_iterator;
259 typedef typename ActiveSelector::active_face_iterator active_face_iterator;
261 typedef typename LevelSelector::CellAccessor level_cell_accessor;
262 typedef typename LevelSelector::FaceAccessor level_face_accessor;
264 typedef typename LevelSelector::cell_iterator level_cell_iterator;
265 typedef typename LevelSelector::face_iterator level_face_iterator;
390 virtual void clear ();
421 void renumber_dofs (
const std::vector<types::global_dof_index> &new_numbers);
428 const std::vector<types::global_dof_index> &new_numbers);
527 level_cell_iterator
begin_mg (
const unsigned int level = 0)
const;
533 level_cell_iterator
end_mg (
const unsigned int level)
const;
539 level_cell_iterator
end_mg ()
const;
714 template<
typename number>
723 n_boundary_dofs (
const std::set<types::boundary_id> &boundary_ids)
const;
780 const std::vector<IndexSet> &
783 const std::vector<IndexSet> &
784 locally_owned_mg_dofs_per_processor (
const unsigned int level)
const;
798 const std::vector<types::global_dof_index> &
832 template <class Archive>
833 void save (Archive &ar, const
unsigned int version) const;
839 template <class Archive>
840 void load (Archive &ar, const
unsigned int version);
842 BOOST_SERIALIZATION_SPLIT_MEMBER()
866 types::global_dof_index,
867 << "The given list of new dof indices is not consecutive: "
868 << "the index " << arg1 << " does not exist.");
875 << "The given level " << arg1
876 << " is not in the valid range!");
888 << "You tried to do something on level " << arg1
889 << ", but this level is empty.");
976 void init (
const unsigned int coarsest_level,
977 const unsigned int finest_level,
978 const unsigned int dofs_per_vertex);
983 unsigned int get_coarsest_level ()
const;
988 unsigned int get_finest_level ()
const;
995 get_index (
const unsigned int level,
996 const unsigned int dof_number)
const;
1002 void set_index (
const unsigned int level,
1003 const unsigned int dof_number,
1036 void clear_mg_space ();
1043 void reserve_space ();
1045 template <
int structdim>
1047 const unsigned int obj_index,
1048 const unsigned int fe_index,
1049 const unsigned int local_index)
const;
1051 template<
int structdim>
1052 void set_dof_index (
const unsigned int obj_level,
1053 const unsigned int obj_index,
1054 const unsigned int fe_index,
1055 const unsigned int local_index,
1073 std::vector<::internal::DoFHandler::DoFLevel<dim>*>
levels;
1075 std::vector<::internal::DoFHandler::DoFLevel<dim>*> mg_levels;
1091 friend struct ::internal::DoFAccessor::Implementation;
1092 friend struct ::internal::DoFCellAccessor::Implementation;
1094 friend struct ::internal::DoFHandler::Implementation;
1095 friend struct ::internal::DoFHandler::Policy::Implementation;
1099 #ifdef DEAL_II_WITH_CXX11 1100 #ifndef DEAL_II_MSVC 1102 "The dimension <dim> of a DoFHandler must be less than or " 1103 "equal to the space dimension <spacedim> in which it lives.");
1126 template <
int dim,
int spacedim>
1131 return mg_number_cache.size()>0;
1134 template <
int dim,
int spacedim>
1139 return number_cache.n_global_dofs>0;
1142 template <
int dim,
int spacedim>
1147 return number_cache.n_global_dofs;
1150 template<
int dim,
int spacedim>
1154 Assert(has_level_dofs(),
ExcMessage(
"n_dofs(level) can only be called after distribute_mg_dofs()"));
1156 return mg_number_cache[
level].n_global_dofs;
1160 template <
int dim,
int spacedim>
1164 return number_cache.n_locally_owned_dofs;
1168 template <
int dim,
int spacedim>
1172 return number_cache.locally_owned_dofs;
1175 template <
int dim,
int spacedim>
1180 return mg_number_cache[
level].locally_owned_dofs;
1183 template <
int dim,
int spacedim>
1184 const std::vector<types::global_dof_index> &
1187 return number_cache.n_locally_owned_dofs_per_processor;
1191 template <
int dim,
int spacedim>
1192 const std::vector<IndexSet> &
1195 return number_cache.locally_owned_dofs_per_processor;
1198 template <
int dim,
int spacedim>
1199 const std::vector<IndexSet> &
1203 return mg_number_cache[
level].locally_owned_dofs_per_processor;
1207 template <
int dim,
int spacedim>
1212 Assert(selected_fe!=0,
ExcMessage(
"You are trying to access the DoFHandler's FiniteElement object before it has been initialized."));
1213 return *selected_fe;
1218 template <
int dim,
int spacedim>
1229 template <
int dim,
int spacedim>
1240 template <
int dim,
int spacedim>
1245 return block_info_object;
1249 template <
int dim,
int spacedim>
1250 template <
typename number>
1255 std::set<types::boundary_id> boundary_ids_only;
1257 p = boundary_ids.begin();
1258 p != boundary_ids.end(); ++p)
1259 boundary_ids_only.insert (p->first);
1262 return n_boundary_dofs(boundary_ids_only);
1276 template<
int dim,
int spacedim>
1277 std::string policy_to_string(const ::internal::DoFHandler::Policy::PolicyBase<dim,spacedim> &policy);
1281 template <
int dim,
int spacedim>
1282 template <
class Archive>
1284 const unsigned int)
const 1286 ar &block_info_object;
1295 unsigned int n_cells = tria->n_cells();
1296 std::string fe_name = selected_fe->get_name();
1297 std::string policy_name = internal::policy_to_string(*policy);
1299 ar &n_cells &fe_name &policy_name;
1303 template <
int dim,
int spacedim>
1304 template <
class Archive>
1308 ar &block_info_object;
1316 for (
unsigned int i=0; i<levels.size(); ++i)
1327 unsigned int n_cells;
1328 std::string fe_name;
1329 std::string policy_name;
1331 ar &n_cells &fe_name &policy_name;
1334 ExcMessage (
"The object being loaded into does not match the triangulation " 1335 "that has been stored previously."));
1337 ExcMessage (
"The finite element associated with this DoFHandler does not match " 1338 "the one that was associated with the DoFHandler previously stored."));
1339 AssertThrow (policy_name == internal::policy_to_string(*policy),
1340 ExcMessage (std::string (
"The policy currently associated with this DoFHandler (")
1341 + internal::policy_to_string(*policy)
1342 +std::string(
") does not match the one that was associated with the " 1343 "DoFHandler previously stored (")
1349 template<
int dim,
int spacedim>
1352 const unsigned int level,
1353 const unsigned int dof_number)
const 1360 template<
int dim,
int spacedim>
1363 const unsigned int level,
1364 const unsigned int dof_number,
1368 indices[indices_offset[level - coarsest_level] + dof_number] = index;
1373 DEAL_II_NAMESPACE_CLOSE
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
level_cell_iterator end_mg() const
cell_iterator begin(const unsigned int level=0) const
std::vector<::internal::DoFHandler::NumberCache > mg_number_cache
std_cxx11::shared_ptr<::internal::DoFHandler::Policy::PolicyBase< dim, spacedim > > policy
types::global_dof_index * indices
static const unsigned int dimension
void set_index(const unsigned int level, const unsigned int dof_number, const types::global_dof_index index)
static const unsigned int spacedim
static ::ExceptionBase & ExcRenumberingIncomplete()
static ::ExceptionBase & ExcInvalidLevel(int arg1)
const BlockInfo & block_info() const
const Triangulation< dim, spacedim > & get_tria() const 1
cell_iterator end() const
SmartPointer< const FiniteElement< dim, spacedim >, DoFHandler< dim, spacedim > > selected_fe
IteratorRange< level_cell_iterator > mg_cell_iterators_on_level(const unsigned int level) const
std::vector<::internal::DoFHandler::DoFLevel< dim > * > levels
ActiveSelector::active_cell_iterator active_cell_iterator
SmartPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
static ::ExceptionBase & ExcNotInitialized()
#define AssertThrow(cond, exc)
virtual std::size_t memory_consumption() const
::internal::DoFHandler::NumberCache number_cache
void initialize(const Triangulation< dim, spacedim > &tria, const FiniteElement< dim, spacedim > &fe)
const FiniteElement< dim, spacedim > & get_fe() const
virtual void distribute_mg_dofs(const FiniteElement< dim, spacedim > &fe)
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
active_cell_iterator begin_active(const unsigned int level=0) const
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
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)
IteratorRange< active_cell_iterator > active_cell_iterators() const
static const unsigned int default_fe_index
types::global_dof_index get_index(const unsigned int level, const unsigned int dof_number) const
const Triangulation< dim, spacedim > * tria
active_cell_iterator end_active(const unsigned int level) const
static ::ExceptionBase & ExcGridsDoNotMatch()
#define DeclException0(Exception0)
types::global_dof_index n_boundary_dofs() const
types::global_dof_index n_dofs() const
level_cell_iterator begin_mg(const unsigned int level=0) 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)
void initialize_local_block_info()
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
unsigned int coarsest_level
virtual void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
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
const Triangulation< dim, spacedim > & get_triangulation() const
const Triangulation< dim, spacedim > & get_triangulation() const
static ::ExceptionBase & ExcNewNumbersNotConsecutive(types::global_dof_index arg1)
unsigned char boundary_id
static const unsigned int space_dimension
unsigned int max_couplings_between_boundary_dofs() const
const types::global_dof_index invalid_dof_index
const IndexSet & locally_owned_dofs() const
bool has_level_dofs() const
IteratorRange< cell_iterator > cell_iterators() const
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