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/dofs/block_info.h> 27 #include <deal.II/dofs/dof_iterator_selector.h> 28 #include <deal.II/dofs/number_cache.h> 29 #include <deal.II/dofs/dof_faces.h> 30 #include <deal.II/dofs/dof_levels.h> 31 #include <deal.II/dofs/function_map.h> 32 #include <deal.II/hp/fe_collection.h> 34 #include <boost/serialization/split_member.hpp> 41 DEAL_II_NAMESPACE_OPEN
48 namespace DoFHandlerImplementation
50 struct Implementation;
55 struct Implementation;
59 namespace DoFAccessorImplementation
64 namespace DoFCellAccessorImplementation
66 struct Implementation;
191 template <
int dim,
int spacedim=dim>
194 typedef ::internal::DoFHandlerImplementation::Iterators<DoFHandler<dim,spacedim>,
false> ActiveSelector;
195 typedef ::internal::DoFHandlerImplementation::Iterators<DoFHandler<dim,spacedim>,
true> LevelSelector;
197 typedef typename ActiveSelector::CellAccessor cell_accessor;
198 typedef typename ActiveSelector::FaceAccessor face_accessor;
200 typedef typename ActiveSelector::line_iterator line_iterator;
201 typedef typename ActiveSelector::active_line_iterator active_line_iterator;
203 typedef typename ActiveSelector::quad_iterator quad_iterator;
204 typedef typename ActiveSelector::active_quad_iterator active_quad_iterator;
206 typedef typename ActiveSelector::hex_iterator hex_iterator;
207 typedef typename ActiveSelector::active_hex_iterator active_hex_iterator;
290 typedef typename LevelSelector::CellAccessor level_cell_accessor;
291 typedef typename LevelSelector::FaceAccessor level_face_accessor;
293 typedef typename LevelSelector::cell_iterator level_cell_iterator;
294 typedef typename LevelSelector::face_iterator level_face_iterator;
464 virtual void clear ();
518 void renumber_dofs (
const std::vector<types::global_dof_index> &new_numbers);
525 const std::vector<types::global_dof_index> &new_numbers);
624 level_cell_iterator
begin_mg (
const unsigned int level = 0)
const;
630 level_cell_iterator
end_mg (
const unsigned int level)
const;
636 level_cell_iterator
end_mg ()
const;
820 template <
typename number>
829 n_boundary_dofs (
const std::set<types::boundary_id> &boundary_ids)
const;
896 const std::vector<IndexSet> &
915 const std::vector<types::global_dof_index> &
930 const std::vector<IndexSet> &
939 get_fe (
const unsigned int index=0)
const;
968 template <
class Archive>
969 void save (Archive &ar,
const unsigned int version)
const;
975 template <
class Archive>
976 void load (Archive &ar,
const unsigned int version);
978 BOOST_SERIALIZATION_SPLIT_MEMBER()
995 types::global_dof_index,
996 << "The given list of new dof indices is not consecutive: "
997 << "the index " << arg1 << " does not exist.");
1004 << "The given level " << arg1
1005 << " is not in the valid range!");
1017 << "You tried to do something on level " << arg1
1018 << ", but this level is empty.");
1080 void init (
const unsigned int coarsest_level,
1081 const unsigned int finest_level,
1082 const unsigned int dofs_per_vertex);
1087 unsigned int get_coarsest_level ()
const;
1092 unsigned int get_finest_level ()
const;
1099 get_index (
const unsigned int level,
1100 const unsigned int dof_number,
1101 const unsigned int dofs_per_vertex)
const;
1107 void set_index (
const unsigned int level,
1108 const unsigned int dof_number,
1109 const unsigned int dofs_per_vertex,
1132 std::unique_ptr<types::global_dof_index[]>
indices;
1145 template <
int structdim>
1147 const unsigned int obj_index,
1148 const unsigned int fe_index,
1149 const unsigned int local_index)
const;
1151 template <
int structdim>
1152 void set_dof_index (
const unsigned int obj_level,
1153 const unsigned int obj_index,
1154 const unsigned int fe_index,
1155 const unsigned int local_index,
1173 std::vector<std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim> > >
levels;
1175 std::vector<std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel<dim> > > mg_levels;
1182 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim> >
faces;
1184 std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces<dim> > mg_faces;
1191 friend struct ::internal::DoFAccessorImplementation::Implementation;
1192 friend struct ::internal::DoFCellAccessorImplementation::Implementation;
1194 friend struct ::internal::DoFHandlerImplementation::Implementation;
1195 friend struct ::internal::DoFHandlerImplementation::Policy::Implementation;
1199 #ifndef DEAL_II_MSVC 1201 "The dimension <dim> of a DoFHandler must be less than or " 1202 "equal to the space dimension <spacedim> in which it lives.");
1214 template <
int dim,
int spacedim>
1219 return mg_number_cache.size()>0;
1224 template <
int dim,
int spacedim>
1229 return number_cache.n_global_dofs>0;
1234 template <
int dim,
int spacedim>
1239 return number_cache.n_global_dofs;
1244 template <
int dim,
int spacedim>
1248 Assert(has_level_dofs(),
ExcMessage(
"n_dofs(level) can only be called after distribute_mg_dofs()"));
1250 return mg_number_cache[
level].n_global_dofs;
1255 template <
int dim,
int spacedim>
1259 return number_cache.n_locally_owned_dofs;
1264 template <
int dim,
int spacedim>
1268 return number_cache.locally_owned_dofs;
1273 template <
int dim,
int spacedim>
1278 ExcMessage(
"invalid level in locally_owned_mg_dofs"));
1279 return mg_number_cache[
level].locally_owned_dofs;
1284 template <
int dim,
int spacedim>
1285 const std::vector<types::global_dof_index> &
1288 return number_cache.n_locally_owned_dofs_per_processor;
1293 template <
int dim,
int spacedim>
1294 const std::vector<IndexSet> &
1297 return number_cache.locally_owned_dofs_per_processor;
1302 template <
int dim,
int spacedim>
1303 const std::vector<IndexSet> &
1307 return mg_number_cache[
level].locally_owned_dofs_per_processor;
1312 template <
int dim,
int spacedim>
1316 (
const unsigned int index)
const 1320 return get_fe_collection()[0];
1325 template <
int dim,
int spacedim>
1330 Assert(fe_collection.size() > 0,
1331 ExcMessage(
"You are trying to access the DoFHandler's FECollection object before it has been initialized."));
1332 return fe_collection;
1337 template <
int dim,
int spacedim>
1343 ExcMessage(
"This DoFHandler object has not been associated " 1344 "with a triangulation."));
1350 template <
int dim,
int spacedim>
1355 return block_info_object;
1360 template <
int dim,
int spacedim>
1361 template <
typename number>
1366 std::set<types::boundary_id> boundary_ids_only;
1368 p = boundary_ids.begin();
1369 p != boundary_ids.end(); ++p)
1370 boundary_ids_only.insert (p->first);
1373 return n_boundary_dofs(boundary_ids_only);
1387 template <
int dim,
int spacedim>
1388 std::string policy_to_string(const ::internal::DoFHandlerImplementation::Policy::PolicyBase<dim,spacedim> &policy);
1393 template <
int dim,
int spacedim>
1394 template <
class Archive>
1396 const unsigned int)
const 1398 ar &block_info_object;
1405 unsigned int n_levels = levels.size();
1407 for (
unsigned int i = 0; i < levels.size(); ++i)
1413 bool faces_is_nullptr = (faces.get()==
nullptr);
1414 ar &faces_is_nullptr;
1415 if (!faces_is_nullptr)
1421 unsigned int n_cells = tria->n_cells();
1422 std::string fe_name = this->get_fe(0).get_name();
1423 std::string policy_name = internal::policy_to_string(*policy);
1425 ar &n_cells &fe_name &policy_name;
1430 template <
int dim,
int spacedim>
1431 template <
class Archive>
1435 ar &block_info_object;
1451 levels.resize(size);
1452 for (
unsigned int i = 0; i < levels.size(); ++i)
1454 std::unique_ptr<internal::DoFHandlerImplementation::DoFLevel<dim>> level;
1456 levels[i] = std::move(level);
1460 bool faces_is_nullptr =
true;
1461 ar &faces_is_nullptr;
1462 if (!faces_is_nullptr)
1467 unsigned int n_cells;
1468 std::string fe_name;
1469 std::string policy_name;
1471 ar &n_cells &fe_name &policy_name;
1474 ExcMessage (
"The object being loaded into does not match the triangulation " 1475 "that has been stored previously."));
1476 AssertThrow (fe_name == this->get_fe(0).get_name(),
1477 ExcMessage (
"The finite element associated with this DoFHandler does not match " 1478 "the one that was associated with the DoFHandler previously stored."));
1479 AssertThrow (policy_name == internal::policy_to_string(*policy),
1480 ExcMessage (
"The policy currently associated with this DoFHandler (" 1481 + internal::policy_to_string(*policy)
1482 +
") does not match the one that was associated with the " 1483 "DoFHandler previously stored (" 1491 template <
int dim,
int spacedim>
1495 const unsigned int dof_number,
1496 const unsigned int dofs_per_vertex)
const 1504 template <
int dim,
int spacedim>
1508 const unsigned int dof_number,
1509 const unsigned int dofs_per_vertex,
1513 indices[dofs_per_vertex * (level - coarsest_level) + dof_number] = index;
1519 DEAL_II_NAMESPACE_CLOSE
DoFHandler & operator=(const DoFHandler &)=delete
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
static const unsigned int dimension
static const unsigned int spacedim
static ::ExceptionBase & ExcInvalidLevel(int arg1)
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const BlockInfo & block_info() const
cell_iterator end() const
::internal::DoFHandlerImplementation::NumberCache number_cache
std::vector< std::unique_ptr<::internal::DoFHandlerImplementation::DoFLevel< dim > > > levels
const std::vector< IndexSet > & locally_owned_mg_dofs_per_processor(const unsigned int level) const
IteratorRange< level_cell_iterator > mg_cell_iterators_on_level(const unsigned int level) const
ActiveSelector::active_cell_iterator active_cell_iterator
SmartPointer< const Triangulation< dim, spacedim >, DoFHandler< dim, spacedim > > tria
#define AssertThrow(cond, exc)
virtual std::size_t memory_consumption() const
void initialize(const Triangulation< dim, spacedim > &tria, const FiniteElement< dim, spacedim > &fe)
std::unique_ptr<::internal::DoFHandlerImplementation::Policy::PolicyBase< dim, spacedim > > policy
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
ActiveSelector::face_iterator face_iterator
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
std::vector<::internal::DoFHandlerImplementation::NumberCache > mg_number_cache
bool has_active_dofs() const
virtual void distribute_mg_dofs()
#define Assert(cond, exc)
IteratorRange< active_cell_iterator > active_cell_iterators() const
static const unsigned int default_fe_index
const Triangulation< dim, spacedim > * tria
active_cell_iterator end_active(const unsigned int level) const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) 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
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
void set_index(const unsigned int level, const unsigned int dof_number, const unsigned int dofs_per_vertex, const types::global_dof_index index)
std::unique_ptr<::internal::DoFHandlerImplementation::DoFFaces< dim > > faces
void renumber_dofs(const std::vector< types::global_dof_index > &new_numbers)
std::unique_ptr< types::global_dof_index[]> indices
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)
types::global_dof_index get_index(const unsigned int level, const unsigned int dof_number, const unsigned int dofs_per_vertex) const
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
ActiveSelector::active_face_iterator active_face_iterator
static ::ExceptionBase & ExcNewNumbersNotConsecutive(types::global_dof_index arg1)
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
hp::FECollection< dim, spacedim > fe_collection