16 #include <deal.II/base/thread_management.h> 17 #include <deal.II/base/quadrature_lib.h> 18 #include <deal.II/base/table.h> 19 #include <deal.II/base/template_constraints.h> 20 #include <deal.II/base/utilities.h> 21 #include <deal.II/lac/sparsity_pattern.h> 22 #include <deal.II/lac/dynamic_sparsity_pattern.h> 23 #include <deal.II/lac/trilinos_sparsity_pattern.h> 24 #include <deal.II/lac/block_sparsity_pattern.h> 25 #include <deal.II/lac/vector.h> 26 #include <deal.II/lac/constraint_matrix.h> 27 #include <deal.II/grid/tria.h> 28 #include <deal.II/grid/tria_iterator.h> 29 #include <deal.II/grid/intergrid_map.h> 30 #include <deal.II/grid/filtered_iterator.h> 31 #include <deal.II/grid/grid_tools.h> 32 #include <deal.II/dofs/dof_handler.h> 33 #include <deal.II/dofs/dof_accessor.h> 34 #include <deal.II/fe/fe.h> 35 #include <deal.II/fe/fe_values.h> 36 #include <deal.II/fe/fe_tools.h> 37 #include <deal.II/hp/dof_handler.h> 38 #include <deal.II/hp/fe_collection.h> 39 #include <deal.II/hp/fe_values.h> 40 #include <deal.II/hp/mapping_collection.h> 41 #include <deal.II/hp/q_collection.h> 42 #include <deal.II/dofs/dof_tools.h> 43 #include <deal.II/distributed/tria.h> 44 #include <deal.II/distributed/shared_tria.h> 49 DEAL_II_NAMESPACE_OPEN
67 template <
int dim,
typename Number=
double>
78 for (
unsigned int d=0; d<dim; ++d)
102 template <
int dim,
int spacedim>
103 std::vector<unsigned char>
107 std::vector<unsigned char> local_component_association (fe.
dofs_per_cell,
108 (
unsigned char)(-1));
116 local_component_association[i] =
127 const unsigned int first_comp =
132 component_mask).n_selected_components(fe.
n_components()) == 0)
133 local_component_association[i] = first_comp;
140 for (
unsigned int c=first_comp; c<fe.
n_components(); ++c)
141 if (component_mask[c] ==
true)
143 local_component_association[i] = c;
148 Assert (std::find (local_component_association.begin(),
149 local_component_association.end(),
152 local_component_association.end(),
155 return local_component_association;
175 template <
typename DoFHandlerType>
177 get_component_association (
const DoFHandlerType &dof,
179 std::vector<unsigned char> &dofs_by_component)
181 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension>
182 fe_collection (dof.get_fe());
184 Assert (dofs_by_component.size() == dof.n_locally_owned_dofs(),
186 dof.n_locally_owned_dofs()));
195 std::vector<std::vector<unsigned char> >
196 local_component_association (fe_collection.size());
197 for (
unsigned int f=0; f<fe_collection.size(); ++f)
201 local_component_association[f]
202 = get_local_component_association (fe, component_mask);
206 std::vector<types::global_dof_index> indices;
207 for (
typename DoFHandlerType::active_cell_iterator c=dof.begin_active();
209 if (c->is_locally_owned())
211 const unsigned int fe_index = c->active_fe_index();
212 const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell;
213 indices.resize(dofs_per_cell);
214 c->get_dof_indices(indices);
215 for (
unsigned int i=0; i<dofs_per_cell; ++i)
216 if (dof.locally_owned_dofs().is_element(indices[i]))
217 dofs_by_component[dof.locally_owned_dofs().index_within_set(indices[i])]
218 = local_component_association[fe_index][i];
230 template <
typename DoFHandlerType>
233 get_block_association (
const DoFHandlerType &dof,
234 std::vector<unsigned char> &dofs_by_block)
236 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension>
237 fe_collection (dof.get_fe());
239 Assert (dofs_by_block.size() == dof.n_locally_owned_dofs(),
241 dof.n_locally_owned_dofs()));
250 std::vector<std::vector<unsigned char> > local_block_association
251 (fe_collection.size());
252 for (
unsigned int f=0; f<fe_collection.size(); ++f)
257 (
unsigned char)(-1));
261 Assert (std::find (local_block_association[f].begin(),
262 local_block_association[f].end(),
265 local_block_association[f].end(),
270 std::vector<types::global_dof_index> indices;
271 for (
typename DoFHandlerType::active_cell_iterator c=dof.begin_active();
273 if (c->is_locally_owned())
275 const unsigned int fe_index = c->active_fe_index();
276 const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell;
277 indices.resize(dofs_per_cell);
278 c->get_dof_indices(indices);
279 for (
unsigned int i=0; i<dofs_per_cell; ++i)
280 if (dof.locally_owned_dofs().is_element(indices[i]))
281 dofs_by_block[dof.locally_owned_dofs().index_within_set(indices[i])]
282 = local_block_association[fe_index][i];
289 template <
typename DoFHandlerType,
typename Number>
293 const unsigned int component)
295 const unsigned int dim = DoFHandlerType::dimension;
296 const unsigned int spacedim = DoFHandlerType::space_dimension;
303 Assert (fe_is_primitive(dof_handler) ==
true,
309 const bool consider_components = (n_components(dof_handler) != 1);
312 if (consider_components ==
false)
316 std::vector<unsigned char> component_dofs (dof_handler.n_locally_owned_dofs());
317 internal::get_component_association (dof_handler,
318 dof_handler.get_fe().component_mask
322 for (
unsigned int i=0; i<dof_data.
size(); ++i)
323 if (component_dofs[i] == static_cast<unsigned char>(component))
328 std::vector<unsigned char> touch_count (dof_handler.n_dofs(), 0);
330 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
331 endc = dof_handler.
end();
332 std::vector<types::global_dof_index> dof_indices;
333 dof_indices.reserve (max_dofs_per_cell(dof_handler));
335 for (
unsigned int present_cell = 0; cell!=endc; ++cell, ++present_cell)
337 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
338 dof_indices.resize (dofs_per_cell);
339 cell->get_dof_indices (dof_indices);
341 for (
unsigned int i=0; i<dofs_per_cell; ++i)
344 if (!consider_components ||
345 (cell->get_fe().system_to_component_index(i).first == component))
348 dof_data(dof_indices[i]) += cell_data(present_cell);
351 ++touch_count[dof_indices[i]];
361 Assert (consider_components || (touch_count[i]!=0),
363 if (touch_count[i] != 0)
364 dof_data(i) /= touch_count[i];
370 template <
int dim,
int spacedim>
374 std::vector<bool> &selected_dofs)
380 ExcMessage (
"The given component mask is not sized correctly to represent the " 381 "components of the given finite element."));
405 internal::get_component_association (dof, component_mask,
409 if (component_mask[dofs_by_component[i]] ==
true)
410 selected_dofs[i] =
true;
416 template <
int dim,
int spacedim>
420 std::vector<bool> &selected_dofs)
426 ExcMessage (
"The given component mask is not sized correctly to represent the " 427 "components of the given finite element."));
435 std::fill_n (selected_dofs.begin(), dof.
n_dofs(),
false);
440 std::fill_n (selected_dofs.begin(), dof.
n_dofs(),
true);
446 std::fill_n (selected_dofs.begin(), dof.
n_dofs(),
false);
450 std::vector<unsigned char> dofs_by_component (dof.
n_dofs());
451 internal::get_component_association (dof, component_mask,
455 if (component_mask[dofs_by_component[i]] ==
true)
456 selected_dofs[i] =
true;
461 template <
int dim,
int spacedim>
465 std::vector<bool> &selected_dofs)
474 template <
int dim,
int spacedim>
478 std::vector<bool> &selected_dofs)
487 template<
typename DoFHandlerType>
490 const DoFHandlerType &dof,
492 std::vector<bool> &selected_dofs)
497 ExcMessage (
"The given component mask is not sized correctly to represent the " 498 "components of the given finite element."));
499 Assert(selected_dofs.size() == dof.n_dofs(level),
506 std::fill_n (selected_dofs.begin(), dof.n_dofs(level),
false);
511 std::fill_n (selected_dofs.begin(), dof.n_dofs(level),
true);
516 std::fill_n (selected_dofs.begin(), dof.n_dofs(level),
false);
520 std::vector<unsigned char> local_component_asssociation
521 = internal::get_local_component_association (fe, component_mask);
524 local_selected_dofs[i] = component_mask[local_component_asssociation[i]];
527 std::vector<types::global_dof_index> indices(fe.
dofs_per_cell);
528 typename DoFHandlerType::level_cell_iterator c;
529 for (c = dof.begin(level) ; c != dof.end(level) ; ++ c)
531 c->get_mg_dof_indices(indices);
533 selected_dofs[indices[i]] = local_selected_dofs[i];
539 template<
typename DoFHandlerType>
542 const DoFHandlerType &dof,
544 std::vector<bool> &selected_dofs)
553 template <
typename DoFHandlerType>
557 std::vector<bool> &selected_dofs,
558 const std::set<types::boundary_id> &boundary_ids)
561 (&dof_handler.get_triangulation())
563 ExcMessage (
"This function can not be used with distributed triangulations." 564 "See the documentation for more information."));
568 indices, boundary_ids);
571 selected_dofs.clear ();
572 selected_dofs.resize (dof_handler.n_dofs(),
false);
575 indices.fill_binary_vector(selected_dofs);
579 template <
typename DoFHandlerType>
584 const std::set<types::boundary_id> &boundary_ids)
587 ExcMessage (
"Component mask has invalid size."));
590 const unsigned int dim=DoFHandlerType::dimension;
593 selected_dofs.
clear ();
594 selected_dofs.
set_size(dof_handler.n_dofs());
598 const bool check_boundary_id = (boundary_ids.size() != 0);
602 const bool check_vector_component
606 n_components(dof_handler)));
608 std::vector<types::global_dof_index> face_dof_indices;
609 face_dof_indices.reserve (max_dofs_per_face(dof_handler));
617 for (
typename DoFHandlerType::active_cell_iterator cell=dof_handler.begin_active();
618 cell!=dof_handler.end(); ++cell)
622 if (cell->is_artificial() ==
false)
623 for (
unsigned int face=0;
624 face<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
625 if (cell->at_boundary(face))
626 if (! check_boundary_id ||
627 (boundary_ids.find (cell->face(face)->boundary_id())
628 != boundary_ids.end()))
631 &fe = cell->get_fe();
634 face_dof_indices.resize (dofs_per_face);
635 cell->face(face)->get_dof_indices (face_dof_indices,
636 cell->active_fe_index());
639 if (!check_vector_component)
640 selected_dofs.
add_index (face_dof_indices[i]);
648 const unsigned int cell_index
669 selected_dofs.
add_index (face_dof_indices[i]);
673 const unsigned int first_nonzero_comp
678 if (component_mask[first_nonzero_comp] ==
true)
679 selected_dofs.
add_index (face_dof_indices[i]);
687 template <
typename DoFHandlerType>
691 std::vector<bool> &selected_dofs,
692 const std::set<types::boundary_id> &boundary_ids)
695 ExcMessage (
"This component mask has the wrong size."));
701 const bool check_boundary_id = (boundary_ids.size() != 0);
705 const bool check_vector_component
709 selected_dofs.clear ();
710 selected_dofs.resize (dof_handler.n_dofs(),
false);
711 std::vector<types::global_dof_index> cell_dof_indices;
712 cell_dof_indices.reserve (max_dofs_per_cell(dof_handler));
720 for (
typename DoFHandlerType::active_cell_iterator cell=dof_handler.begin_active();
721 cell!=dof_handler.end(); ++cell)
722 for (
unsigned int face=0;
723 face<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
724 if (cell->at_boundary(face))
725 if (! check_boundary_id ||
726 (boundary_ids.find (cell->face(face)->boundary_id())
727 != boundary_ids.end()))
733 cell_dof_indices.resize (dofs_per_cell);
734 cell->get_dof_indices (cell_dof_indices);
739 if (!check_vector_component)
740 selected_dofs[cell_dof_indices[i]] =
true;
747 selected_dofs[cell_dof_indices[i]]
752 const unsigned int first_nonzero_comp
757 selected_dofs[cell_dof_indices[i]]
758 = (component_mask[first_nonzero_comp]
773 template <
int spacedim>
775 std::vector<bool> &selected_dofs)
777 Assert(selected_dofs.size() == dof_handler.n_dofs(),
780 std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(),
false);
786 template <
int spacedim>
788 std::vector<bool> &selected_dofs)
790 const unsigned int dim = 2;
792 Assert(selected_dofs.size() == dof_handler.n_dofs(),
795 std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(),
false);
801 typename ::DoFHandler<dim,spacedim>::active_cell_iterator
802 cell = dof_handler.begin_active(),
803 endc = dof_handler.end();
804 for (; cell!=endc; ++cell)
805 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
806 if (cell->face(face)->has_children())
808 const typename ::DoFHandler<dim,spacedim>::line_iterator
809 line = cell->face(face);
811 for (
unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
812 selected_dofs[line->child(0)->vertex_dof_index(1,dof)] =
true;
814 for (
unsigned int child=0; child<2; ++child)
815 for (
unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
816 selected_dofs[line->child(child)->dof_index(dof)] =
true;
821 template <
int spacedim>
823 std::vector<bool> &selected_dofs)
825 const unsigned int dim = 3;
827 Assert(selected_dofs.size() == dof_handler.n_dofs(),
830 std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(),
false);
837 typename ::DoFHandler<dim,spacedim>::active_cell_iterator
838 cell = dof_handler.begin_active(),
839 endc = dof_handler.end();
840 for (; cell!=endc; ++cell)
841 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
842 if (cell->face(f)->has_children())
844 const typename ::DoFHandler<dim,spacedim>::face_iterator
845 face = cell->face(f);
847 for (
unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
848 selected_dofs[face->child(0)->vertex_dof_index(2,dof)] =
true;
852 for (
unsigned int line=0; line<4; ++line)
853 for (
unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
854 selected_dofs[face->line(line)->child(0)->vertex_dof_index(1,dof)] =
true;
859 for (
unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
860 selected_dofs[face->child(0)->line(1)->dof_index(dof)] =
true;
861 for (
unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
862 selected_dofs[face->child(1)->line(2)->dof_index(dof)] =
true;
863 for (
unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
864 selected_dofs[face->child(2)->line(3)->dof_index(dof)] =
true;
865 for (
unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
866 selected_dofs[face->child(3)->line(0)->dof_index(dof)] =
true;
869 for (
unsigned int line=0; line<4; ++line)
870 for (
unsigned int child=0; child<2; ++child)
871 for (
unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
872 selected_dofs[face->line(line)->child(child)->dof_index(dof)] =
true;
875 for (
unsigned int child=0; child<4; ++child)
876 for (
unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
877 selected_dofs[face->child(child)->dof_index(dof)] =
true;
885 template <
int dim,
int spacedim>
889 std::vector<bool> &selected_dofs)
891 internal::extract_hanging_node_dofs (dof_handler,
897 template <
typename DoFHandlerType>
901 std::vector<bool> &selected_dofs)
903 Assert(selected_dofs.size() == dof_handler.n_dofs(),
907 std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(),
false);
909 std::vector<types::global_dof_index> local_dof_indices;
910 local_dof_indices.reserve (max_dofs_per_cell(dof_handler));
914 typename DoFHandlerType::active_cell_iterator
915 cell = dof_handler.begin_active(),
916 endc = dof_handler.end();
917 for (; cell!=endc; ++cell)
918 if (cell->subdomain_id() == subdomain_id)
920 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
921 local_dof_indices.resize (dofs_per_cell);
922 cell->get_dof_indices (local_dof_indices);
923 for (
unsigned int i=0; i<dofs_per_cell; ++i)
924 selected_dofs[local_dof_indices[i]] =
true;
930 template <
typename DoFHandlerType>
936 dof_set = dof_handler.locally_owned_dofs();
942 template <
typename DoFHandlerType>
948 dof_set = dof_handler.locally_owned_dofs();
953 std::vector<types::global_dof_index> dof_indices;
954 std::set<types::global_dof_index> global_dof_indices;
956 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
957 endc = dof_handler.
end();
958 for (; cell!=endc; ++cell)
959 if (cell->is_locally_owned())
961 dof_indices.resize(cell->get_fe().dofs_per_cell);
962 cell->get_dof_indices(dof_indices);
964 for (std::vector<types::global_dof_index>::iterator it=dof_indices.begin();
965 it!=dof_indices.end();
968 global_dof_indices.insert(*it);
971 dof_set.
add_indices(global_dof_indices.begin(), global_dof_indices.end());
978 template <
typename DoFHandlerType>
984 dof_set = dof_handler.locally_owned_dofs();
994 std::vector<types::global_dof_index> dof_indices;
995 std::vector<types::global_dof_index> dofs_on_ghosts;
997 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
998 endc = dof_handler.
end();
999 for (; cell!=endc; ++cell)
1000 if (cell->is_ghost())
1002 dof_indices.resize(cell->get_fe().dofs_per_cell);
1003 cell->get_dof_indices(dof_indices);
1004 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1006 dofs_on_ghosts.push_back(dof_indices[i]);
1010 std::sort(dofs_on_ghosts.begin(), dofs_on_ghosts.end());
1011 dof_set.
add_indices(dofs_on_ghosts.begin(), std::unique(dofs_on_ghosts.begin(),
1012 dofs_on_ghosts.end()));
1017 template <
typename DoFHandlerType>
1020 const unsigned int level,
1024 dof_set = dof_handler.locally_owned_mg_dofs(level);
1034 std::vector<types::global_dof_index> dof_indices;
1035 std::vector<types::global_dof_index> dofs_on_ghosts;
1037 typename DoFHandlerType::cell_iterator cell = dof_handler.
begin(level),
1038 endc = dof_handler.end(level);
1039 for (; cell!=endc; ++cell)
1044 if (
id == dof_handler.get_triangulation().locally_owned_subdomain()
1048 dof_indices.resize(cell->get_fe().dofs_per_cell);
1049 cell->get_mg_dof_indices(dof_indices);
1050 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1052 dofs_on_ghosts.push_back(dof_indices[i]);
1056 std::sort(dofs_on_ghosts.begin(), dofs_on_ghosts.end());
1057 dof_set.
add_indices(dofs_on_ghosts.begin(), std::unique(dofs_on_ghosts.begin(),
1058 dofs_on_ghosts.end()));
1063 template <
typename DoFHandlerType>
1067 std::vector<std::vector<bool> > &constant_modes)
1069 const unsigned int n_components = dof_handler.get_fe().n_components();
1072 component_mask.
size()));
1074 std::vector<unsigned char> dofs_by_component (dof_handler.n_locally_owned_dofs());
1075 internal::get_component_association (dof_handler, component_mask,
1077 unsigned int n_selected_dofs = 0;
1078 for (
unsigned int i=0; i<n_components; ++i)
1079 if (component_mask[i] ==
true)
1080 n_selected_dofs += std::count (dofs_by_component.begin(),
1081 dofs_by_component.end(), i);
1084 const IndexSet &locally_owned_dofs = dof_handler.locally_owned_dofs();
1085 std::vector<unsigned int> component_numbering(locally_owned_dofs.n_elements(),
1087 for (
unsigned int i=0, count=0; i<locally_owned_dofs.n_elements(); ++i)
1088 if (component_mask[dofs_by_component[i]])
1089 component_numbering[i] = count++;
1096 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension>
1097 fe_collection (dof_handler.get_fe());
1098 std::vector<Table<2,bool> > element_constant_modes;
1099 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
1100 constant_mode_to_component_translation(n_components);
1101 unsigned int n_constant_modes = 0;
1102 for (
unsigned int f=0; f<fe_collection.size(); ++f)
1104 std::pair<Table<2,bool>, std::vector<unsigned int> > data
1105 = fe_collection[f].get_constant_modes();
1106 element_constant_modes.push_back(data.first);
1108 for (
unsigned int i=0; i<data.second.size(); ++i)
1109 if (component_mask[data.second[i]])
1110 constant_mode_to_component_translation[data.second[i]].
1111 push_back(std::make_pair(n_constant_modes++,i));
1113 element_constant_modes[0].n_rows());
1117 constant_modes.clear ();
1118 constant_modes.resize (n_constant_modes, std::vector<bool>(n_selected_dofs,
1123 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1124 endc = dof_handler.end();
1125 std::vector<types::global_dof_index> dof_indices;
1126 for (; cell!=endc; ++cell)
1127 if (cell->is_locally_owned())
1129 dof_indices.resize(cell->get_fe().dofs_per_cell);
1130 cell->get_dof_indices(dof_indices);
1132 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1133 if (locally_owned_dofs.is_element(dof_indices[i]))
1135 const unsigned int loc_index =
1136 locally_owned_dofs.index_within_set(dof_indices[i]);
1137 const unsigned int comp = dofs_by_component[loc_index];
1138 if (component_mask[comp])
1139 for (
unsigned int j=0; j<constant_mode_to_component_translation[comp].size(); ++j)
1140 constant_modes[constant_mode_to_component_translation[comp][j].first]
1141 [component_numbering[loc_index]] =
1142 element_constant_modes[cell->active_fe_index()]
1143 (constant_mode_to_component_translation[comp][j].second,i);
1150 template <
typename DoFHandlerType>
1153 std::vector<unsigned int> &active_fe_indices)
1155 AssertDimension (active_fe_indices.size(), dof_handler.get_triangulation().n_active_cells());
1157 typename DoFHandlerType::active_cell_iterator
1158 cell = dof_handler.begin_active(),
1159 endc = dof_handler.end();
1160 for (; cell!=endc; ++cell)
1161 active_fe_indices[cell->active_cell_index()] = cell->active_fe_index();
1164 template <
typename DoFHandlerType>
1165 std::vector<IndexSet>
1168 Assert(dof_handler.n_dofs() > 0,
1169 ExcMessage(
"The given DoFHandler has no DoFs."));
1173 Assert ((
dynamic_cast<const parallel::distributed::
1174 Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *
> 1175 (&dof_handler.get_triangulation()) == 0),
1176 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1177 "associated DoF handler objects, asking for any information " 1178 "related to a subdomain other than the locally owned one does " 1179 "not make sense."));
1182 std::vector< ::types::subdomain_id > subdomain_association (dof_handler.n_dofs ());
1183 ::DoFTools::get_subdomain_association (dof_handler, subdomain_association);
1190 const unsigned int n_subdomains
1192 (&dof_handler.get_triangulation()) == 0
1194 (1+*std::max_element (subdomain_association.begin (),
1195 subdomain_association.end ()))
1199 (&dof_handler.get_triangulation())->get_communicator()));
1201 *std::max_element (subdomain_association.begin (),
1202 subdomain_association.end ()),
1205 std::vector<::IndexSet> index_sets (n_subdomains,
1214 index < subdomain_association.size (); ++index)
1217 if (subdomain_association[index] != this_subdomain)
1219 index_sets[this_subdomain].add_range (i_min, index);
1221 this_subdomain = subdomain_association[index];
1226 if (i_min == subdomain_association.size () - 1)
1228 index_sets[this_subdomain].add_index (i_min);
1234 index_sets[this_subdomain].add_range (
1235 i_min, subdomain_association.size ());
1238 for (
unsigned int i = 0; i < n_subdomains; i++)
1239 index_sets[i].compress ();
1244 template <
typename DoFHandlerType>
1245 std::vector<IndexSet>
1250 Assert ((
dynamic_cast<const parallel::distributed::
1251 Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *
> 1252 (&dof_handler.get_triangulation()) == 0),
1253 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1254 "associated DoF handler objects, asking for any information " 1255 "related to a subdomain other than the locally owned one does " 1256 "not make sense."));
1264 const ::types::subdomain_id n_subdomains = dof_set.size();
1270 subdomain_id < n_subdomains; ++subdomain_id)
1273 std_cxx11::function<bool (const typename DoFHandlerType::active_cell_iterator &)> predicate
1275 const std::vector<typename DoFHandlerType::active_cell_iterator>
1280 std::vector<types::global_dof_index> local_dof_indices;
1281 std::set<types::global_dof_index> subdomain_halo_global_dof_indices;
1282 for (
typename std::vector<typename DoFHandlerType::active_cell_iterator>::const_iterator
1283 it_cell = active_halo_layer.begin(); it_cell!=active_halo_layer.end(); ++it_cell)
1285 const typename DoFHandlerType::active_cell_iterator &cell = *it_cell;
1286 Assert(cell->subdomain_id() != subdomain_id,
1287 ExcMessage(
"The subdomain ID of the halo cell should not match that of the vector entry."));
1289 local_dof_indices.resize(cell->get_fe().dofs_per_cell);
1290 cell->get_dof_indices(local_dof_indices);
1292 for (std::vector<types::global_dof_index>::iterator it=local_dof_indices.begin();
1293 it!=local_dof_indices.end();
1295 subdomain_halo_global_dof_indices.insert(*it);
1298 dof_set[subdomain_id].add_indices(subdomain_halo_global_dof_indices.begin(),
1299 subdomain_halo_global_dof_indices.end());
1301 dof_set[subdomain_id].compress();
1307 template <
typename DoFHandlerType>
1310 std::vector<types::subdomain_id> &subdomain_association)
1314 Assert ((
dynamic_cast<const parallel::distributed::
1315 Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *
> 1316 (&dof_handler.get_triangulation()) == 0),
1317 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1318 "associated DoF handler objects, asking for any subdomain other " 1319 "than the locally owned one does not make sense."));
1321 Assert(subdomain_association.size() == dof_handler.n_dofs(),
1323 dof_handler.n_dofs()));
1325 Assert(dof_handler.n_dofs() > 0,
1327 "This could happen when the function is called before NumberCache is written."));
1333 std::vector<types::subdomain_id> cell_owners (dof_handler.get_triangulation().n_active_cells());
1336 DoFHandlerType::space_dimension
>*> (&dof_handler.get_triangulation())))
1338 cell_owners = tr->get_true_subdomain_ids_of_cells();
1339 Assert (tr->get_true_subdomain_ids_of_cells().size() == tr->n_active_cells(),
1344 for (
typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active();
1345 cell!= dof_handler.end(); cell++)
1346 if (cell->is_locally_owned())
1347 cell_owners[cell->active_cell_index()] = cell->subdomain_id();
1351 std::fill_n (subdomain_association.begin(), dof_handler.n_dofs(),
1354 std::vector<types::global_dof_index> local_dof_indices;
1355 local_dof_indices.reserve (max_dofs_per_cell(dof_handler));
1359 bool coin_flip =
true;
1363 typename DoFHandlerType::active_cell_iterator
1364 cell = dof_handler.begin_active(),
1365 endc = dof_handler.end();
1366 for (; cell!=endc; ++cell)
1369 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
1370 local_dof_indices.resize (dofs_per_cell);
1371 cell->get_dof_indices (local_dof_indices);
1377 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1378 if (subdomain_association[local_dof_indices[i]] ==
1380 subdomain_association[local_dof_indices[i]] = subdomain_id;
1383 if (coin_flip ==
true)
1384 subdomain_association[local_dof_indices[i]] = subdomain_id;
1385 coin_flip = !coin_flip;
1389 Assert (std::find (subdomain_association.begin(),
1390 subdomain_association.end(),
1392 == subdomain_association.end(),
1398 template <
typename DoFHandlerType>
1403 std::vector<types::subdomain_id> subdomain_association (dof_handler.n_dofs());
1406 return std::count (subdomain_association.begin(),
1407 subdomain_association.end(),
1413 template <
typename DoFHandlerType>
1424 (subdomain == dof_handler.get_triangulation().locally_owned_subdomain()),
1425 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1426 "associated DoF handler objects, asking for any subdomain other " 1427 "than the locally owned one does not make sense."));
1429 IndexSet index_set (dof_handler.n_dofs());
1431 std::vector<types::global_dof_index> local_dof_indices;
1432 local_dof_indices.reserve (max_dofs_per_cell(dof_handler));
1439 std::vector<types::global_dof_index> subdomain_indices;
1441 typename DoFHandlerType::active_cell_iterator
1442 cell = dof_handler.begin_active(),
1443 endc = dof_handler.
end();
1444 for (; cell!=endc; ++cell)
1445 if ((cell->is_artificial() ==
false)
1447 (cell->subdomain_id() == subdomain))
1449 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
1450 local_dof_indices.resize (dofs_per_cell);
1451 cell->get_dof_indices (local_dof_indices);
1452 subdomain_indices.insert(subdomain_indices.end(),
1453 local_dof_indices.begin(),
1454 local_dof_indices.end());
1457 std::sort (subdomain_indices.begin(), subdomain_indices.end());
1458 subdomain_indices.erase (std::unique(subdomain_indices.begin(),
1459 subdomain_indices.end()),
1460 subdomain_indices.end());
1463 index_set.add_indices (subdomain_indices.begin(), subdomain_indices.end());
1464 index_set.compress ();
1471 template <
typename DoFHandlerType>
1475 std::vector<unsigned int> &n_dofs_on_subdomain)
1477 Assert (n_dofs_on_subdomain.size() == dof_handler.get_fe().n_components(),
1479 dof_handler.get_fe().n_components()));
1480 std::fill (n_dofs_on_subdomain.begin(), n_dofs_on_subdomain.end(), 0);
1488 DoFHandlerType::space_dimension>::active_cell_iterator
1490 cell!=dof_handler.get_triangulation().end(); ++cell)
1491 if (cell->subdomain_id() == subdomain)
1497 ExcMessage (
"There are no cells for the given subdomain!"));
1501 std::vector<types::subdomain_id> subdomain_association (dof_handler.n_dofs());
1504 std::vector<unsigned char> component_association (dof_handler.n_dofs());
1505 internal::get_component_association (dof_handler, std::vector<bool>(),
1506 component_association);
1508 for (
unsigned int c=0; c<dof_handler.get_fe().n_components(); ++c)
1511 if ((subdomain_association[i] == subdomain) &&
1512 (component_association[i] ==
static_cast<unsigned char>(c)))
1513 ++n_dofs_on_subdomain[c];
1525 template <
int dim,
int spacedim>
1528 const std::vector<unsigned char> &dofs_by_component,
1529 const std::vector<unsigned int> &target_component,
1530 const bool only_once,
1531 std::vector<types::global_dof_index> &dofs_per_component,
1532 unsigned int &component)
1543 resolve_components(base, dofs_by_component, target_component,
1544 only_once, dofs_per_component, component);
1547 for (
unsigned int dd=0; dd<d; ++dd,++component)
1548 dofs_per_component[target_component[component]]
1549 += std::count(dofs_by_component.begin(),
1550 dofs_by_component.end(),
1557 for (
unsigned int dd=1; dd<d; ++dd)
1558 dofs_per_component[target_component[component-d+dd]] =
1559 dofs_per_component[target_component[component-d]];
1566 template <
int dim,
int spacedim>
1569 const std::vector<unsigned char> &dofs_by_component,
1570 const std::vector<unsigned int> &target_component,
1571 const bool only_once,
1572 std::vector<types::global_dof_index> &dofs_per_component,
1573 unsigned int &component)
1578 for (
unsigned int fe=1; fe<fe_collection.
size(); ++fe)
1580 Assert (fe_collection[fe].n_components() == fe_collection[0].n_components(),
1582 Assert (fe_collection[fe].n_base_elements() == fe_collection[0].n_base_elements(),
1584 for (
unsigned int b=0;
b<fe_collection[0].n_base_elements(); ++
b)
1586 Assert (fe_collection[fe].base_element(b).n_components() == fe_collection[0].base_element(b).n_components(),
1588 Assert (fe_collection[fe].base_element(b).n_base_elements() == fe_collection[0].base_element(b).n_base_elements(),
1593 resolve_components (fe_collection[0], dofs_by_component,
1594 target_component, only_once, dofs_per_component,
1608 template <
int dim,
int spacedim>
1618 template <
int dim,
int spacedim>
1619 bool all_elements_are_primitive (const ::hp::FECollection<dim,spacedim> &fe_collection)
1621 for (
unsigned int i=0; i<fe_collection.size(); ++i)
1622 if (fe_collection[i].is_primitive() ==
false)
1630 template <
typename DoFHandlerType>
1633 std::vector<types::global_dof_index> &dofs_per_component,
1635 std::vector<unsigned int> target_component)
1637 const unsigned int n_components = dof_handler.get_fe().n_components();
1639 std::fill (dofs_per_component.begin(), dofs_per_component.end(),
1644 if (target_component.size()==0)
1646 target_component.resize(n_components);
1647 for (
unsigned int i=0; i<n_components; ++i)
1648 target_component[i] = i;
1651 Assert (target_component.size()==n_components,
1656 const unsigned int max_component
1657 = *std::max_element (target_component.begin(),
1658 target_component.end());
1659 const unsigned int n_target_components = max_component + 1;
1660 (void)n_target_components;
1666 if (n_components == 1)
1668 dofs_per_component[0] = dof_handler.n_locally_owned_dofs();
1675 std::vector<unsigned char> dofs_by_component (dof_handler.n_locally_owned_dofs());
1676 internal::get_component_association (dof_handler,
ComponentMask(),
1680 unsigned int component = 0;
1681 internal::resolve_components(dof_handler.get_fe(),
1682 dofs_by_component, target_component,
1683 only_once, dofs_per_component, component);
1688 Assert ((internal::all_elements_are_primitive(dof_handler.get_fe()) ==
false)
1690 (std::accumulate (dofs_per_component.begin(),
1691 dofs_per_component.end(),
1693 == dof_handler.n_locally_owned_dofs()),
1697 #ifdef DEAL_II_WITH_MPI 1698 const unsigned int dim = DoFHandlerType::dimension;
1699 const unsigned int spacedim = DoFHandlerType::space_dimension;
1703 (&dof_handler.get_triangulation())))
1705 std::vector<types::global_dof_index> local_dof_count = dofs_per_component;
1707 const int ierr = MPI_Allreduce (&local_dof_count[0], &dofs_per_component[0], n_target_components,
1708 DEAL_II_DOF_INDEX_MPI_TYPE,
1709 MPI_SUM, tria->get_communicator());
1717 template <
typename DoFHandlerType>
1720 std::vector<types::global_dof_index> &dofs_per_block,
1721 const std::vector<unsigned int> &target_block_)
1723 std::vector<unsigned int> target_block = target_block_;
1725 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension>
1726 fe_collection (dof_handler.get_fe());
1729 for (
unsigned int this_fe=0; this_fe<fe_collection.size(); ++this_fe)
1732 std::fill (dofs_per_block.begin(), dofs_per_block.end(),
1737 if (target_block.size()==0)
1739 target_block.resize(fe.
n_blocks());
1740 for (
unsigned int i=0; i<fe.
n_blocks(); ++i)
1741 target_block[i] = i;
1750 const unsigned int max_block
1751 = *std::max_element (target_block.begin(),
1752 target_block.end());
1753 const unsigned int n_target_blocks = max_block + 1;
1754 (void)n_target_blocks;
1756 const unsigned int n_blocks = fe.
n_blocks();
1764 dofs_per_block[0] = dof_handler.n_dofs();
1768 std::vector<unsigned char> dofs_by_block (dof_handler.n_locally_owned_dofs());
1769 internal::get_block_association (dof_handler, dofs_by_block);
1772 for (
unsigned int block=0; block<fe.
n_blocks(); ++block)
1773 dofs_per_block[target_block[block]]
1774 += std::count(dofs_by_block.begin(), dofs_by_block.end(),
1777 #ifdef DEAL_II_WITH_MPI 1782 (&dof_handler.get_triangulation())))
1784 std::vector<types::global_dof_index> local_dof_count = dofs_per_block;
1785 const int ierr = MPI_Allreduce (&local_dof_count[0], &dofs_per_block[0],
1787 DEAL_II_DOF_INDEX_MPI_TYPE,
1788 MPI_SUM, tria->get_communicator());
1797 template <
typename DoFHandlerType>
1800 std::vector<types::global_dof_index> &mapping)
1803 mapping.insert (mapping.end(), dof_handler.n_dofs(),
1804 DoFHandlerType::invalid_dof_index);
1806 std::vector<types::global_dof_index> dofs_on_face;
1807 dofs_on_face.reserve (max_dofs_per_face(dof_handler));
1816 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1817 endc = dof_handler.end();
1818 for (; cell!=endc; ++cell)
1819 for (
unsigned int f=0; f<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++f)
1820 if (cell->at_boundary(f))
1822 const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
1823 dofs_on_face.resize (dofs_per_face);
1824 cell->face(f)->get_dof_indices (dofs_on_face,
1825 cell->active_fe_index());
1826 for (
unsigned int i=0; i<dofs_per_face; ++i)
1827 if (mapping[dofs_on_face[i]] == DoFHandlerType::invalid_dof_index)
1828 mapping[dofs_on_face[i]] = next_boundary_index++;
1836 template <
typename DoFHandlerType>
1838 (
const DoFHandlerType &dof_handler,
1839 const std::set<types::boundary_id> &boundary_ids,
1840 std::vector<types::global_dof_index> &mapping)
1846 mapping.insert (mapping.end(), dof_handler.n_dofs(),
1847 DoFHandlerType::invalid_dof_index);
1850 if (boundary_ids.size() == 0)
1853 std::vector<types::global_dof_index> dofs_on_face;
1854 dofs_on_face.reserve (max_dofs_per_face(dof_handler));
1857 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1858 endc = dof_handler.end();
1859 for (; cell!=endc; ++cell)
1860 for (
unsigned int f=0; f<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++f)
1861 if (boundary_ids.find (cell->face(f)->boundary_id()) !=
1864 const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
1865 dofs_on_face.resize (dofs_per_face);
1866 cell->face(f)->get_dof_indices (dofs_on_face, cell->active_fe_index());
1867 for (
unsigned int i=0; i<dofs_per_face; ++i)
1868 if (mapping[dofs_on_face[i]] == DoFHandlerType::invalid_dof_index)
1869 mapping[dofs_on_face[i]] = next_boundary_index++;
1873 dof_handler.n_boundary_dofs (boundary_ids));
1880 template <
typename DoFHandlerType>
1884 const DoFHandlerType &dof_handler,
1887 const unsigned int dim = DoFHandlerType::dimension;
1888 const unsigned int spacedim = DoFHandlerType::space_dimension;
1893 for (
unsigned int fe_index = 0; fe_index < fe_collection.size(); ++fe_index)
1896 Assert(fe_collection[fe_index].has_support_points(),
1900 fe_collection[fe_index].get_unit_support_points()));
1912 typename DoFHandlerType::active_cell_iterator cell =
1913 dof_handler.begin_active(), endc = dof_handler.end();
1915 std::vector<types::global_dof_index> local_dof_indices;
1916 for (; cell != endc; ++cell)
1918 if (cell->is_artificial() ==
false)
1920 hp_fe_values.reinit(cell);
1923 local_dof_indices.resize(cell->get_fe().dofs_per_cell);
1924 cell->get_dof_indices(local_dof_indices);
1926 const std::vector<Point<spacedim> > &points =
1928 for (
unsigned int i = 0; i < cell->get_fe().dofs_per_cell; ++i)
1930 support_points[local_dof_indices[i]] = points[i];
1935 template <
typename DoFHandlerType>
1939 const DoFHandlerType &dof_handler,
1943 std::map<types::global_dof_index,Point<DoFHandlerType::space_dimension> > x_support_points;
1950 Assert (x_support_points.find(i) != x_support_points.end(),
1952 support_points[i] = x_support_points[i];
1958 template <
int dim,
int spacedim>
1969 ExcMessage (
"This function can not be used with distributed triangulations." 1970 "See the documentation for more information."));
1976 internal::map_dofs_to_support_points (mapping_collection,
1982 template<
int dim,
int spacedim>
1993 ExcMessage (
"This function can not be used with distributed triangulations." 1994 "See the documentation for more information."));
1998 internal::map_dofs_to_support_points (mapping,
2004 template <
int dim,
int spacedim>
2010 support_points.clear();
2016 internal::map_dofs_to_support_points (mapping_collection,
2022 template<
int dim,
int spacedim>
2028 support_points.clear();
2032 internal::map_dofs_to_support_points (mapping,
2037 template <
int spacedim>
2044 typedef std::map< types::global_dof_index, Point<spacedim> >
2050 point_map_t point_map;
2053 for (
typename dof_map_t::const_iterator it = support_points.begin();
2054 it!=support_points.end();
2057 std::vector<types::global_dof_index> &v = point_map[it->second];
2058 v.push_back(it->first);
2062 for (
typename point_map_t::iterator it = point_map.begin();
2063 it!=point_map.end();
2066 out << it->first <<
" \"";
2067 const std::vector<types::global_dof_index> &v = it->second;
2068 for (
unsigned int i=0; i < v.size(); ++i)
2082 template<
int dim,
int spacedim>
2090 const unsigned int nb = fe.
n_blocks();
2092 tables_by_block.resize(1);
2093 tables_by_block[0].reinit(nb, nb);
2094 tables_by_block[0].fill(
none);
2102 tables_by_block[0](ib,jb) |= table(i,j);
2108 template<
int dim,
int spacedim>
2115 tables_by_block.resize(fe_collection.
size());
2117 for (
unsigned int f=0; f<fe_collection.
size(); ++f)
2121 const unsigned int nb = fe.
n_blocks();
2122 tables_by_block[f].reinit(nb, nb);
2123 tables_by_block[f].fill(
none);
2130 tables_by_block[f](ib,jb) |= table(i,j);
2138 template <
int dim,
int spacedim>
2141 const unsigned int level,
2142 const std::vector<bool> &selected_dofs,
2145 typename DoFHandler<dim,spacedim>::level_cell_iterator cell;
2146 typename DoFHandler<dim,spacedim>::level_cell_iterator endc = dof_handler.
end(level);
2147 std::vector<types::global_dof_index> indices;
2151 for (cell=dof_handler.
begin(level); cell != endc; ++cell)
2152 if (cell->is_locally_owned_on_level())
2156 for (cell=dof_handler.
begin(level); cell != endc; ++cell)
2157 if (cell->is_locally_owned_on_level())
2159 indices.resize(cell->
get_fe().dofs_per_cell);
2160 cell->get_mg_dof_indices(indices);
2162 if (selected_dofs.size()!=0)
2167 if (selected_dofs.size() == 0)
2168 block_list.
add(i,indices[j]-offset);
2171 if (selected_dofs[j])
2172 block_list.
add(i,indices[j]-offset);
2180 template <
typename DoFHandlerType>
2182 const DoFHandlerType &dof_handler,
2183 const unsigned int level,
2184 const bool interior_only)
2187 block_list.
reinit(1, dof_handler.n_dofs(level), dof_handler.n_dofs(level));
2188 typename DoFHandlerType::level_cell_iterator cell;
2189 typename DoFHandlerType::level_cell_iterator endc = dof_handler.end(level);
2191 std::vector<types::global_dof_index> indices;
2192 std::vector<bool> exclude;
2194 for (cell=dof_handler.begin(level); cell != endc; ++cell)
2196 indices.resize(cell->get_fe().dofs_per_cell);
2197 cell->get_mg_dof_indices(indices);
2203 std::fill(exclude.begin(), exclude.end(),
false);
2206 for (
unsigned int face=0; face<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
2207 if (cell->at_boundary(face) || cell->neighbor(face)->level() != cell->level())
2208 for (
unsigned int i=0; i<dpf; ++i)
2212 block_list.
add(0, indices[j]);
2217 block_list.
add(0, indices[j]);
2223 template <
typename DoFHandlerType>
2225 const DoFHandlerType &dof_handler,
2226 const unsigned int level,
2227 const bool interior_dofs_only,
2228 const bool boundary_dofs)
2230 Assert(level > 0 && level < dof_handler.get_triangulation().n_levels(),
2231 ExcIndexRange(level, 1, dof_handler.get_triangulation().n_levels()));
2233 typename DoFHandlerType::level_cell_iterator pcell = dof_handler.begin(level-1);
2234 typename DoFHandlerType::level_cell_iterator endc = dof_handler.end(level-1);
2236 std::vector<types::global_dof_index> indices;
2237 std::vector<bool> exclude;
2239 for (
unsigned int block = 0; pcell != endc; ++pcell)
2241 if (!pcell->has_children())
2244 for (
unsigned int child=0; child<pcell->n_children(); ++child)
2246 const typename DoFHandlerType::level_cell_iterator cell = pcell->child(child);
2251 indices.resize(n_dofs);
2252 exclude.resize(n_dofs);
2253 std::fill(exclude.begin(), exclude.end(),
false);
2254 cell->get_mg_dof_indices(indices);
2256 if (interior_dofs_only)
2262 for (
unsigned int d=0; d<DoFHandlerType::dimension; ++d)
2265 for (
unsigned int i=0; i<dpf; ++i)
2272 for (
unsigned int face=0; face< GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
2273 if (cell->at_boundary(face))
2274 for (
unsigned int i=0; i<dpf; ++i)
2278 for (
unsigned int i=0; i<n_dofs; ++i)
2280 block_list.
add(block, indices[i]);
2286 template <
typename DoFHandlerType>
2287 std::vector<unsigned int>
2289 const DoFHandlerType &dof_handler,
2290 const unsigned int level,
2291 const bool interior_only,
2292 const bool boundary_patches,
2293 const bool level_boundary_patches,
2294 const bool single_cell_patches,
2295 const bool invert_vertex_mapping)
2297 const unsigned int n_blocks = dof_handler.get_fe().n_blocks();
2302 exclude_boundary_dofs,
2304 level_boundary_patches,
2305 single_cell_patches,
2306 invert_vertex_mapping);
2309 template <
typename DoFHandlerType>
2310 std::vector<unsigned int>
2312 const DoFHandlerType &dof_handler,
2313 const unsigned int level,
2315 const bool boundary_patches,
2316 const bool level_boundary_patches,
2317 const bool single_cell_patches,
2318 const bool invert_vertex_mapping)
2320 typename DoFHandlerType::level_cell_iterator cell;
2321 typename DoFHandlerType::level_cell_iterator endc = dof_handler.end(level);
2325 std::vector<unsigned int> vertex_cell_count(dof_handler.get_triangulation().n_vertices(), 0);
2328 std::vector<bool> vertex_boundary(dof_handler.get_triangulation().n_vertices(),
false);
2330 std::vector<unsigned int> vertex_mapping(dof_handler.get_triangulation().n_vertices(),
2334 std::vector<unsigned int> vertex_dof_count(dof_handler.get_triangulation().n_vertices(), 0);
2338 for (cell=dof_handler.begin(level); cell != endc; ++cell)
2339 for (
unsigned int v=0; v<GeometryInfo<DoFHandlerType::dimension>::vertices_per_cell; ++v)
2341 const unsigned int vg = cell->vertex_index(v);
2342 vertex_dof_count[vg] += cell->get_fe().dofs_per_cell;
2343 ++vertex_cell_count[vg];
2344 for (
unsigned int d=0; d<DoFHandlerType::dimension; ++d)
2347 if (cell->at_boundary(face))
2348 vertex_boundary[vg] =
true;
2349 else if ((!level_boundary_patches)
2350 && (cell->neighbor(face)->level() != (int) level))
2351 vertex_boundary[vg] =
true;
2357 for (
unsigned int vg=0; vg<vertex_dof_count.size(); ++vg)
2358 if ((!single_cell_patches && vertex_cell_count[vg] < 2)
2360 (!boundary_patches && vertex_boundary[vg]))
2361 vertex_dof_count[vg] = 0;
2364 unsigned int n_vertex_count=0;
2365 for (
unsigned int vg=0; vg<vertex_mapping.size(); ++vg)
2366 if (vertex_dof_count[vg] != 0)
2367 vertex_mapping[vg] = n_vertex_count++;
2370 for (
unsigned int vg=0; vg<vertex_mapping.size(); ++vg)
2371 if (vertex_dof_count[vg] != 0)
2372 vertex_dof_count[vertex_mapping[vg]] = vertex_dof_count[vg];
2376 vertex_dof_count.resize(n_vertex_count);
2380 block_list.
reinit(vertex_dof_count.size(), dof_handler.n_dofs(level), vertex_dof_count);
2382 std::vector<types::global_dof_index> indices;
2383 std::vector<bool> exclude;
2385 for (cell=dof_handler.begin(level); cell != endc; ++cell)
2389 cell->get_mg_dof_indices(indices);
2391 for (
unsigned int v=0; v<GeometryInfo<DoFHandlerType::dimension>::vertices_per_cell; ++v)
2393 const unsigned int vg = cell->vertex_index(v);
2394 const unsigned int block = vertex_mapping[vg];
2405 std::fill(exclude.begin(), exclude.end(),
false);
2408 for (
unsigned int d=0; d<DoFHandlerType::dimension; ++d)
2412 for (
unsigned int i=0; i<dpf; ++i)
2419 for (
unsigned int j=0; j<indices.size(); ++j)
2421 block_list.
add(block, indices[j]);
2425 for (
unsigned int j=0; j<indices.size(); ++j)
2426 block_list.
add(block, indices[j]);
2431 if (invert_vertex_mapping)
2434 unsigned int n_vertex_count = 0;
2435 for (
unsigned int vg = 0; vg < vertex_mapping.size(); ++vg)
2437 vertex_mapping[n_vertex_count++] = vg;
2440 vertex_mapping.resize(n_vertex_count);
2443 return vertex_mapping;
2447 template <
typename DoFHandlerType>
2451 std::set<types::global_dof_index> dofs_on_patch;
2452 std::vector<types::global_dof_index> local_dof_indices;
2457 for (
unsigned int i=0; i<patch.size(); ++i)
2459 const typename DoFHandlerType::active_cell_iterator cell = patch[i];
2460 Assert (cell->is_artificial() ==
false,
2461 ExcMessage(
"This function can not be called with cells that are " 2462 "not either locally owned or ghost cells."));
2463 local_dof_indices.resize (cell->get_fe().dofs_per_cell);
2464 cell->get_dof_indices (local_dof_indices);
2465 dofs_on_patch.insert (local_dof_indices.begin(),
2466 local_dof_indices.end());
2470 return dofs_on_patch.size();
2475 template <
typename DoFHandlerType>
2476 std::vector<types::global_dof_index>
2479 std::set<types::global_dof_index> dofs_on_patch;
2480 std::vector<types::global_dof_index> local_dof_indices;
2485 for (
unsigned int i=0; i<patch.size(); ++i)
2487 const typename DoFHandlerType::active_cell_iterator cell = patch[i];
2488 Assert (cell->is_artificial() ==
false,
2489 ExcMessage(
"This function can not be called with cells that are " 2490 "not either locally owned or ghost cells."));
2491 local_dof_indices.resize (cell->get_fe().dofs_per_cell);
2492 cell->get_dof_indices (local_dof_indices);
2493 dofs_on_patch.insert (local_dof_indices.begin(),
2494 local_dof_indices.end());
2497 Assert (dofs_on_patch.size() == count_dofs_on_patch<DoFHandlerType>(patch),
2504 return std::vector<types::global_dof_index> (dofs_on_patch.begin(),
2505 dofs_on_patch.end());
2515 #include "dof_tools.inst" 2519 DEAL_II_NAMESPACE_CLOSE
unsigned int n_active_cells() const
static const unsigned int invalid_unsigned_int
#define AssertDimension(dim1, dim2)
ElementIterator end() const
const types::subdomain_id invalid_subdomain_id
void add_index(const size_type index)
cell_iterator begin(const unsigned int level=0) const
const FEValues< dim, spacedim > & get_present_fe_values() const
static ::ExceptionBase & ExcIO()
cell_iterator end() const
#define AssertIndexRange(index, range)
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
active_cell_iterator begin_active(const unsigned int level=0) const
bool represents_n_components(const unsigned int n) const
bool represents_the_all_selected_mask() const
unsigned int size() const
Transformed quadrature points.
#define AssertThrow(cond, exc)
bool is_primitive() const
const FiniteElement< dim, spacedim > & get_fe() const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
const unsigned int dofs_per_line
unsigned int n_blocks() const
const std::vector< Point< spacedim > > & get_quadrature_points() const
const hp::FECollection< dim, spacedim > & get_fe() const
unsigned int component_to_block_index(const unsigned int component) const
unsigned int n_locally_owned_dofs() const
static ::ExceptionBase & ExcMessage(std::string arg1)
void push_back(const FiniteElement< dim, spacedim > &new_fe)
void add(const size_type i, const size_type j)
unsigned int global_dof_index
#define Assert(cond, exc)
unsigned int element_multiplicity(const unsigned int index) const
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
Abstract base class for mapping classes.
const ComponentMask & get_nonzero_components(const unsigned int i) const
std::pair< unsigned int, unsigned int > face_system_to_component_index(const unsigned int index) const
types::global_dof_index n_dofs() const
unsigned int size() const
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
virtual unsigned int face_to_cell_index(const unsigned int face_dof_index, const unsigned int face, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false) const
unsigned int subdomain_id
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
const unsigned int dofs_per_cell
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
void reinit(const size_type m, const size_type n, const unsigned int max_per_row)
void set_size(const size_type size)
const types::subdomain_id artificial_subdomain_id
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
#define AssertThrowMPI(error_code)
const Triangulation< dim, spacedim > & get_triangulation() const
unsigned int n_components() const
std::pair< unsigned int, types::global_dof_index > system_to_block_index(const unsigned int component) const
unsigned int n_selected_blocks(const unsigned int overall_number_of_blocks=numbers::invalid_unsigned_int) const
unsigned int first_selected_component(const unsigned int overall_number_of_components=numbers::invalid_unsigned_int) const
unsigned int n_selected_components(const unsigned int overall_number_of_components=numbers::invalid_unsigned_int) const
const unsigned int dofs_per_face
types::global_dof_index n_dofs() const
static ::ExceptionBase & ExcInvalidBoundaryIndicator()
static ::ExceptionBase & ExcNotImplemented()
const Triangulation< dim, spacedim > & get_triangulation() const
const unsigned int dofs_per_vertex
bool is_element(const size_type index) const
const types::boundary_id internal_face_boundary_id
unsigned int size() const
unsigned int n_base_elements() const
ElementIterator begin() const
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const
static ::ExceptionBase & ExcInternalError()
Triangulation< dim, spacedim > & get_triangulation()