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
71 template <
int dim,
typename Number=
double>
82 double downstream_size = 0;
84 for (
unsigned int d=0; d<dim; ++d)
86 downstream_size += (rhs[d] - lhs[d]) * weight;
89 if (downstream_size < 0)
91 else if (downstream_size > 0)
95 for (
unsigned int d=0; d<dim; ++d)
120 template <
int dim,
int spacedim>
121 std::vector<unsigned char>
125 std::vector<unsigned char> local_component_association (fe.
dofs_per_cell,
126 (
unsigned char)(-1));
134 local_component_association[i] =
145 const unsigned int first_comp =
150 component_mask).n_selected_components(fe.
n_components()) == 0)
151 local_component_association[i] = first_comp;
158 for (
unsigned int c=first_comp; c<fe.
n_components(); ++c)
159 if (component_mask[c] ==
true)
161 local_component_association[i] = c;
166 Assert (std::find (local_component_association.begin(),
167 local_component_association.end(),
170 local_component_association.end(),
173 return local_component_association;
193 template <
typename DoFHandlerType>
195 get_component_association (
const DoFHandlerType &dof,
197 std::vector<unsigned char> &dofs_by_component)
199 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension> &
200 fe_collection = dof.get_fe_collection();
202 Assert (dofs_by_component.size() == dof.n_locally_owned_dofs(),
204 dof.n_locally_owned_dofs()));
213 std::vector<std::vector<unsigned char> >
214 local_component_association (fe_collection.size());
215 for (
unsigned int f=0; f<fe_collection.size(); ++f)
219 local_component_association[f]
220 = get_local_component_association (fe, component_mask);
224 std::vector<types::global_dof_index> indices;
225 for (
typename DoFHandlerType::active_cell_iterator c=dof.begin_active();
227 if (c->is_locally_owned())
229 const unsigned int fe_index = c->active_fe_index();
230 const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell;
231 indices.resize(dofs_per_cell);
232 c->get_dof_indices(indices);
233 for (
unsigned int i=0; i<dofs_per_cell; ++i)
234 if (dof.locally_owned_dofs().is_element(indices[i]))
235 dofs_by_component[dof.locally_owned_dofs().index_within_set(indices[i])]
236 = local_component_association[fe_index][i];
248 template <
typename DoFHandlerType>
251 get_block_association (
const DoFHandlerType &dof,
252 std::vector<unsigned char> &dofs_by_block)
254 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension> &
255 fe_collection = dof.get_fe_collection();
257 Assert (dofs_by_block.size() == dof.n_locally_owned_dofs(),
259 dof.n_locally_owned_dofs()));
268 std::vector<std::vector<unsigned char> > local_block_association
269 (fe_collection.size());
270 for (
unsigned int f=0; f<fe_collection.size(); ++f)
275 (
unsigned char)(-1));
279 Assert (std::find (local_block_association[f].begin(),
280 local_block_association[f].end(),
283 local_block_association[f].end(),
288 std::vector<types::global_dof_index> indices;
289 for (
typename DoFHandlerType::active_cell_iterator c=dof.begin_active();
291 if (c->is_locally_owned())
293 const unsigned int fe_index = c->active_fe_index();
294 const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell;
295 indices.resize(dofs_per_cell);
296 c->get_dof_indices(indices);
297 for (
unsigned int i=0; i<dofs_per_cell; ++i)
298 if (dof.locally_owned_dofs().is_element(indices[i]))
299 dofs_by_block[dof.locally_owned_dofs().index_within_set(indices[i])]
300 = local_block_association[fe_index][i];
307 template <
typename DoFHandlerType,
typename Number>
309 const Vector<Number> &cell_data,
311 const unsigned int component)
313 const unsigned int dim = DoFHandlerType::dimension;
314 const unsigned int spacedim = DoFHandlerType::space_dimension;
327 const bool consider_components = (
n_components(dof_handler) != 1);
330 if (consider_components ==
false)
334 std::vector<unsigned char> component_dofs (dof_handler.n_locally_owned_dofs());
335 internal::get_component_association (dof_handler,
336 dof_handler.get_fe_collection().component_mask
340 for (
unsigned int i=0; i<dof_data.
size(); ++i)
341 if (component_dofs[i] == static_cast<unsigned char>(component))
346 std::vector<unsigned char> touch_count (dof_handler.n_dofs(), 0);
348 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
349 endc = dof_handler.
end();
350 std::vector<types::global_dof_index> dof_indices;
353 for (
unsigned int present_cell = 0; cell!=endc; ++cell, ++present_cell)
355 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
356 dof_indices.resize (dofs_per_cell);
357 cell->get_dof_indices (dof_indices);
359 for (
unsigned int i=0; i<dofs_per_cell; ++i)
362 if (!consider_components ||
363 (cell->get_fe().system_to_component_index(i).first == component))
366 dof_data(dof_indices[i]) += cell_data(present_cell);
369 ++touch_count[dof_indices[i]];
379 Assert (consider_components || (touch_count[i]!=0),
381 if (touch_count[i] != 0)
382 dof_data(i) /= touch_count[i];
388 template <
int dim,
int spacedim>
392 std::vector<bool> &selected_dofs)
398 ExcMessage (
"The given component mask is not sized correctly to represent the " 399 "components of the given finite element."));
423 internal::get_component_association (dof, component_mask,
427 if (component_mask[dofs_by_component[i]] ==
true)
428 selected_dofs[i] =
true;
434 template <
int dim,
int spacedim>
438 std::vector<bool> &selected_dofs)
444 ExcMessage (
"The given component mask is not sized correctly to represent the " 445 "components of the given finite element."));
453 std::fill_n (selected_dofs.begin(), dof.
n_dofs(),
false);
458 std::fill_n (selected_dofs.begin(), dof.
n_dofs(),
true);
464 std::fill_n (selected_dofs.begin(), dof.
n_dofs(),
false);
468 std::vector<unsigned char> dofs_by_component (dof.
n_dofs());
469 internal::get_component_association (dof, component_mask,
473 if (component_mask[dofs_by_component[i]] ==
true)
474 selected_dofs[i] =
true;
479 template <
int dim,
int spacedim>
483 std::vector<bool> &selected_dofs)
492 template <
int dim,
int spacedim>
496 std::vector<bool> &selected_dofs)
505 template <
typename DoFHandlerType>
508 const DoFHandlerType &dof,
510 std::vector<bool> &selected_dofs)
515 ExcMessage (
"The given component mask is not sized correctly to represent the " 516 "components of the given finite element."));
517 Assert(selected_dofs.size() == dof.n_dofs(level),
524 std::fill_n (selected_dofs.begin(), dof.n_dofs(level),
false);
529 std::fill_n (selected_dofs.begin(), dof.n_dofs(level),
true);
534 std::fill_n (selected_dofs.begin(), dof.n_dofs(level),
false);
538 std::vector<unsigned char> local_component_asssociation
539 = internal::get_local_component_association (fe, component_mask);
542 local_selected_dofs[i] = component_mask[local_component_asssociation[i]];
545 std::vector<types::global_dof_index> indices(fe.
dofs_per_cell);
546 typename DoFHandlerType::level_cell_iterator c;
547 for (c = dof.begin(level) ; c != dof.end(level) ; ++ c)
549 c->get_mg_dof_indices(indices);
551 selected_dofs[indices[i]] = local_selected_dofs[i];
557 template <
typename DoFHandlerType>
560 const DoFHandlerType &dof,
562 std::vector<bool> &selected_dofs)
571 template <
typename DoFHandlerType>
575 std::vector<bool> &selected_dofs,
576 const std::set<types::boundary_id> &boundary_ids)
579 (&dof_handler.get_triangulation())
581 ExcMessage (
"This function can not be used with distributed triangulations." 582 "See the documentation for more information."));
586 indices, boundary_ids);
589 selected_dofs.clear ();
590 selected_dofs.resize (dof_handler.n_dofs(),
false);
593 indices.fill_binary_vector(selected_dofs);
597 template <
typename DoFHandlerType>
602 const std::set<types::boundary_id> &boundary_ids)
605 ExcMessage (
"Component mask has invalid size."));
608 const unsigned int dim=DoFHandlerType::dimension;
611 selected_dofs.
clear ();
612 selected_dofs.
set_size(dof_handler.n_dofs());
616 const bool check_boundary_id = (boundary_ids.size() != 0);
620 const bool check_vector_component
626 std::vector<types::global_dof_index> face_dof_indices;
635 for (
typename DoFHandlerType::active_cell_iterator cell=dof_handler.begin_active();
636 cell!=dof_handler.end(); ++cell)
640 if (cell->is_artificial() ==
false)
641 for (
unsigned int face=0;
642 face<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
643 if (cell->at_boundary(face))
644 if (! check_boundary_id ||
645 (boundary_ids.find (cell->face(face)->boundary_id())
646 != boundary_ids.end()))
649 &fe = cell->get_fe();
652 face_dof_indices.resize (dofs_per_face);
653 cell->face(face)->get_dof_indices (face_dof_indices,
654 cell->active_fe_index());
657 if (!check_vector_component)
658 selected_dofs.
add_index (face_dof_indices[i]);
666 const unsigned int cell_index
687 selected_dofs.
add_index (face_dof_indices[i]);
691 const unsigned int first_nonzero_comp
696 if (component_mask[first_nonzero_comp] ==
true)
697 selected_dofs.
add_index (face_dof_indices[i]);
705 template <
typename DoFHandlerType>
709 std::vector<bool> &selected_dofs,
710 const std::set<types::boundary_id> &boundary_ids)
713 ExcMessage (
"This component mask has the wrong size."));
719 const bool check_boundary_id = (boundary_ids.size() != 0);
723 const bool check_vector_component
727 selected_dofs.clear ();
728 selected_dofs.resize (dof_handler.n_dofs(),
false);
729 std::vector<types::global_dof_index> cell_dof_indices;
738 for (
typename DoFHandlerType::active_cell_iterator cell=dof_handler.begin_active();
739 cell!=dof_handler.end(); ++cell)
740 for (
unsigned int face=0;
741 face<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
742 if (cell->at_boundary(face))
743 if (! check_boundary_id ||
744 (boundary_ids.find (cell->face(face)->boundary_id())
745 != boundary_ids.end()))
751 cell_dof_indices.resize (dofs_per_cell);
752 cell->get_dof_indices (cell_dof_indices);
757 if (!check_vector_component)
758 selected_dofs[cell_dof_indices[i]] =
true;
765 selected_dofs[cell_dof_indices[i]]
770 const unsigned int first_nonzero_comp
775 selected_dofs[cell_dof_indices[i]]
776 = (component_mask[first_nonzero_comp]
786 template <
typename DoFHandlerType>
789 const std::function<
bool(
const typename DoFHandlerType::active_cell_iterator &)> &predicate,
792 const std::function< bool(const typename DoFHandlerType::active_cell_iterator &)> predicate_local
793 = [=] (
const typename DoFHandlerType::active_cell_iterator & cell) ->
bool 795 return cell->is_locally_owned() && predicate(cell);
798 std::vector<types::global_dof_index> local_dof_indices;
802 std::set<types::global_dof_index> predicate_dofs;
804 typename DoFHandlerType::active_cell_iterator
805 cell = dof_handler.begin_active(),
806 endc = dof_handler.end();
807 for (; cell!=endc; ++cell)
808 if (!cell->is_artificial() && predicate(cell))
810 local_dof_indices.resize (cell->get_fe().dofs_per_cell);
811 cell->get_dof_indices (local_dof_indices);
812 predicate_dofs.insert(local_dof_indices.begin(),
813 local_dof_indices.end());
817 std::set<types::global_dof_index> dofs_with_support_on_halo_cells;
819 const std::vector<typename DoFHandlerType::active_cell_iterator> halo_cells =
821 for (
typename std::vector<typename DoFHandlerType::active_cell_iterator>::const_iterator it = halo_cells.begin();
822 it != halo_cells.end(); ++it)
829 Assert ((*it)->is_ghost(),
834 const unsigned int dofs_per_cell = (*it)->get_fe().dofs_per_cell;
835 local_dof_indices.resize (dofs_per_cell);
836 (*it)->get_dof_indices (local_dof_indices);
837 dofs_with_support_on_halo_cells.insert(local_dof_indices.begin(),
838 local_dof_indices.end());
850 std::set<types::global_dof_index> extra_halo;
851 for (std::set<types::global_dof_index>::iterator it = dofs_with_support_on_halo_cells.begin();
852 it != dofs_with_support_on_halo_cells.end(); ++it)
856 if (
const std::vector<std::pair<types::global_dof_index,double> > *line_ptr = cm.
get_constraint_entries(*it))
858 const unsigned int line_size = line_ptr->size();
859 for (
unsigned int j=0; j<line_size; ++j)
860 extra_halo.insert((*line_ptr)[j].first);
863 dofs_with_support_on_halo_cells.insert(extra_halo.begin(),
869 IndexSet support_set(dof_handler.n_dofs());
871 predicate_dofs.end());
872 support_set.compress();
874 IndexSet halo_set(dof_handler.n_dofs());
875 halo_set.
add_indices(dofs_with_support_on_halo_cells.begin(),
876 dofs_with_support_on_halo_cells.end());
879 support_set.subtract_set(halo_set);
891 template <
int spacedim>
895 return IndexSet(dof_handler.n_dofs());
899 template <
int spacedim>
902 const unsigned int dim = 2;
904 IndexSet selected_dofs(dof_handler.n_dofs());
910 for (
auto cell : dof_handler.active_cell_iterators())
911 if (!cell->is_artificial())
913 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
914 if (cell->face(face)->has_children())
916 const typename ::DoFHandler<dim,spacedim>::line_iterator
917 line = cell->face(face);
919 for (
unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
920 selected_dofs.add_index(line->child(0)->vertex_dof_index(1,dof));
922 for (
unsigned int child=0; child<2; ++child)
924 if (cell->neighbor_child_on_subface (face, child)->is_artificial())
926 for (
unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
927 selected_dofs.add_index(line->child(child)->dof_index(dof));
932 selected_dofs.compress();
933 return selected_dofs;
937 template <
int spacedim>
940 const unsigned int dim = 3;
942 IndexSet selected_dofs (dof_handler.n_dofs());
943 IndexSet unconstrained_dofs (dof_handler.n_dofs());
947 for (
auto cell : dof_handler.active_cell_iterators())
948 if (!cell->is_artificial())
949 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
951 const typename ::DoFHandler<dim,spacedim>::face_iterator
952 face = cell->face(f);
953 if (cell->face(f)->has_children())
955 for (
unsigned int child=0; child<4; ++child)
956 if (!cell->neighbor_child_on_subface (f, child)->is_artificial())
959 std::vector<types::global_dof_index> ldi(fe.dofs_per_face);
960 face->child(child)->get_dof_indices(ldi);
961 selected_dofs.add_indices(ldi.begin(), ldi.end());
966 for (
unsigned int vertex=0; vertex<4; ++vertex)
967 for (
unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
968 unconstrained_dofs.add_index(face->vertex_dof_index(vertex,dof));
971 selected_dofs.subtract_set(unconstrained_dofs);
972 return selected_dofs;
979 template <
int dim,
int spacedim>
982 std::vector<bool> &selected_dofs)
988 std::fill (selected_dofs.begin(), selected_dofs.end(),
false);
989 for (
const auto &index: selected_dofs_as_index_set)
990 selected_dofs[index] =
true;
995 template <
int dim,
int spacedim>
999 return internal::extract_hanging_node_dofs (dof_handler);
1004 template <
typename DoFHandlerType>
1008 std::vector<bool> &selected_dofs)
1010 Assert(selected_dofs.size() == dof_handler.n_dofs(),
1014 std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(),
false);
1016 std::vector<types::global_dof_index> local_dof_indices;
1021 typename DoFHandlerType::active_cell_iterator
1022 cell = dof_handler.begin_active(),
1023 endc = dof_handler.end();
1024 for (; cell!=endc; ++cell)
1025 if (cell->subdomain_id() == subdomain_id)
1027 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
1028 local_dof_indices.resize (dofs_per_cell);
1029 cell->get_dof_indices (local_dof_indices);
1030 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1031 selected_dofs[local_dof_indices[i]] =
true;
1037 template <
typename DoFHandlerType>
1043 dof_set = dof_handler.locally_owned_dofs();
1049 template <
typename DoFHandlerType>
1055 dof_set = dof_handler.locally_owned_dofs();
1060 std::vector<types::global_dof_index> dof_indices;
1061 std::set<types::global_dof_index> global_dof_indices;
1063 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1064 endc = dof_handler.
end();
1065 for (; cell!=endc; ++cell)
1066 if (cell->is_locally_owned())
1068 dof_indices.resize(cell->get_fe().dofs_per_cell);
1069 cell->get_dof_indices(dof_indices);
1071 for (std::vector<types::global_dof_index>::iterator it=dof_indices.begin();
1072 it!=dof_indices.end();
1075 global_dof_indices.insert(*it);
1078 dof_set.
add_indices(global_dof_indices.begin(), global_dof_indices.end());
1085 template <
typename DoFHandlerType>
1091 dof_set = dof_handler.locally_owned_dofs();
1101 std::vector<types::global_dof_index> dof_indices;
1102 std::vector<types::global_dof_index> dofs_on_ghosts;
1104 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1105 endc = dof_handler.
end();
1106 for (; cell!=endc; ++cell)
1107 if (cell->is_ghost())
1109 dof_indices.resize(cell->get_fe().dofs_per_cell);
1110 cell->get_dof_indices(dof_indices);
1111 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1113 dofs_on_ghosts.push_back(dof_indices[i]);
1117 std::sort(dofs_on_ghosts.begin(), dofs_on_ghosts.end());
1118 dof_set.
add_indices(dofs_on_ghosts.begin(), std::unique(dofs_on_ghosts.begin(),
1119 dofs_on_ghosts.end()));
1125 template <
typename DoFHandlerType>
1128 const unsigned int level,
1132 dof_set = dof_handler.locally_owned_mg_dofs(level);
1142 std::vector<types::global_dof_index> dof_indices;
1143 std::vector<types::global_dof_index> dofs_on_ghosts;
1145 typename DoFHandlerType::cell_iterator cell = dof_handler.
begin(level),
1146 endc = dof_handler.end(level);
1147 for (; cell!=endc; ++cell)
1152 if (
id == dof_handler.get_triangulation().locally_owned_subdomain()
1156 dof_indices.resize(cell->get_fe().dofs_per_cell);
1157 cell->get_mg_dof_indices(dof_indices);
1158 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1160 dofs_on_ghosts.push_back(dof_indices[i]);
1164 std::sort(dofs_on_ghosts.begin(), dofs_on_ghosts.end());
1165 dof_set.
add_indices(dofs_on_ghosts.begin(), std::unique(dofs_on_ghosts.begin(),
1166 dofs_on_ghosts.end()));
1173 template <
typename DoFHandlerType>
1177 std::vector<std::vector<bool> > &constant_modes)
1179 const unsigned int n_components = dof_handler.get_fe(0).n_components();
1182 component_mask.
size()));
1184 std::vector<unsigned char> dofs_by_component (dof_handler.n_locally_owned_dofs());
1185 internal::get_component_association (dof_handler, component_mask,
1187 unsigned int n_selected_dofs = 0;
1189 if (component_mask[i] ==
true)
1190 n_selected_dofs += std::count (dofs_by_component.begin(),
1191 dofs_by_component.end(), i);
1194 const IndexSet &locally_owned_dofs = dof_handler.locally_owned_dofs();
1195 std::vector<unsigned int> component_numbering(locally_owned_dofs.n_elements(),
1197 for (
unsigned int i=0, count=0; i<locally_owned_dofs.n_elements(); ++i)
1198 if (component_mask[dofs_by_component[i]])
1199 component_numbering[i] = count++;
1206 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension> &
1207 fe_collection = dof_handler.get_fe_collection();
1208 std::vector<Table<2,bool> > element_constant_modes;
1209 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
1211 unsigned int n_constant_modes = 0;
1212 for (
unsigned int f=0; f<fe_collection.size(); ++f)
1214 std::pair<Table<2,bool>, std::vector<unsigned int> > data
1215 = fe_collection[f].get_constant_modes();
1216 element_constant_modes.push_back(data.first);
1218 for (
unsigned int i=0; i<data.second.size(); ++i)
1219 if (component_mask[data.second[i]])
1220 constant_mode_to_component_translation[data.second[i]].
1221 emplace_back(n_constant_modes++, i);
1223 element_constant_modes[0].n_rows());
1227 constant_modes.clear ();
1228 constant_modes.resize (n_constant_modes, std::vector<bool>(n_selected_dofs,
1233 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1234 endc = dof_handler.end();
1235 std::vector<types::global_dof_index> dof_indices;
1236 for (; cell!=endc; ++cell)
1237 if (cell->is_locally_owned())
1239 dof_indices.resize(cell->get_fe().dofs_per_cell);
1240 cell->get_dof_indices(dof_indices);
1242 for (
unsigned int i=0; i<dof_indices.size(); ++i)
1243 if (locally_owned_dofs.is_element(dof_indices[i]))
1245 const unsigned int loc_index =
1246 locally_owned_dofs.index_within_set(dof_indices[i]);
1247 const unsigned int comp = dofs_by_component[loc_index];
1248 if (component_mask[comp])
1249 for (
unsigned int j=0; j<constant_mode_to_component_translation[comp].size(); ++j)
1250 constant_modes[constant_mode_to_component_translation[comp][j].first]
1251 [component_numbering[loc_index]] =
1252 element_constant_modes[cell->active_fe_index()]
1253 (constant_mode_to_component_translation[comp][j].second,i);
1260 template <
typename DoFHandlerType>
1263 std::vector<unsigned int> &active_fe_indices)
1265 AssertDimension (active_fe_indices.size(), dof_handler.get_triangulation().n_active_cells());
1267 typename DoFHandlerType::active_cell_iterator
1268 cell = dof_handler.begin_active(),
1269 endc = dof_handler.end();
1270 for (; cell!=endc; ++cell)
1271 active_fe_indices[cell->active_cell_index()] = cell->active_fe_index();
1274 template <
typename DoFHandlerType>
1275 std::vector<IndexSet>
1278 Assert(dof_handler.n_dofs() > 0,
1279 ExcMessage(
"The given DoFHandler has no DoFs."));
1283 Assert ((
dynamic_cast<const parallel::distributed::
1284 Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *
> 1285 (&dof_handler.get_triangulation()) ==
nullptr),
1286 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1287 "associated DoF handler objects, asking for any information " 1288 "related to a subdomain other than the locally owned one does " 1289 "not make sense."));
1292 std::vector< ::types::subdomain_id > subdomain_association (dof_handler.n_dofs ());
1293 ::DoFTools::get_subdomain_association (dof_handler, subdomain_association);
1306 const unsigned int n_subdomains
1308 (&dof_handler.get_triangulation()) ==
nullptr 1312 unsigned int max_subdomain_id = 0;
1313 for (
auto cell : dof_handler.active_cell_iterators())
1314 max_subdomain_id = std::max (max_subdomain_id, cell->subdomain_id());
1315 return max_subdomain_id + 1;
1320 (&dof_handler.get_triangulation())->get_communicator()));
1322 *std::max_element (subdomain_association.begin (),
1323 subdomain_association.end ()),
1326 std::vector<::IndexSet> index_sets (n_subdomains,
1335 index < subdomain_association.size (); ++index)
1338 if (subdomain_association[index] != this_subdomain)
1340 index_sets[this_subdomain].add_range (i_min, index);
1342 this_subdomain = subdomain_association[index];
1347 if (i_min == subdomain_association.size () - 1)
1349 index_sets[this_subdomain].add_index (i_min);
1355 index_sets[this_subdomain].add_range (
1356 i_min, subdomain_association.size ());
1359 for (
unsigned int i = 0; i < n_subdomains; i++)
1360 index_sets[i].compress ();
1365 template <
typename DoFHandlerType>
1366 std::vector<IndexSet>
1371 Assert ((
dynamic_cast<const parallel::distributed::
1372 Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *
> 1373 (&dof_handler.get_triangulation()) ==
nullptr),
1374 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1375 "associated DoF handler objects, asking for any information " 1376 "related to a subdomain other than the locally owned one does " 1377 "not make sense."));
1385 const ::types::subdomain_id n_subdomains = dof_set.size();
1391 subdomain_id < n_subdomains; ++subdomain_id)
1394 std::function<bool (const typename DoFHandlerType::active_cell_iterator &)> predicate
1396 const std::vector<typename DoFHandlerType::active_cell_iterator>
1401 std::vector<types::global_dof_index> local_dof_indices;
1402 std::set<types::global_dof_index> subdomain_halo_global_dof_indices;
1403 for (
typename std::vector<typename DoFHandlerType::active_cell_iterator>::const_iterator
1404 it_cell = active_halo_layer.begin(); it_cell!=active_halo_layer.end(); ++it_cell)
1406 const typename DoFHandlerType::active_cell_iterator &cell = *it_cell;
1407 Assert(cell->subdomain_id() != subdomain_id,
1408 ExcMessage(
"The subdomain ID of the halo cell should not match that of the vector entry."));
1410 local_dof_indices.resize(cell->get_fe().dofs_per_cell);
1411 cell->get_dof_indices(local_dof_indices);
1413 for (std::vector<types::global_dof_index>::iterator it=local_dof_indices.begin();
1414 it!=local_dof_indices.end();
1416 subdomain_halo_global_dof_indices.insert(*it);
1419 dof_set[subdomain_id].add_indices(subdomain_halo_global_dof_indices.begin(),
1420 subdomain_halo_global_dof_indices.end());
1422 dof_set[subdomain_id].compress();
1428 template <
typename DoFHandlerType>
1431 std::vector<types::subdomain_id> &subdomain_association)
1435 Assert ((
dynamic_cast<const parallel::distributed::
1436 Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *
> 1437 (&dof_handler.get_triangulation()) ==
nullptr),
1438 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1439 "associated DoF handler objects, asking for any subdomain other " 1440 "than the locally owned one does not make sense."));
1442 Assert(subdomain_association.size() == dof_handler.n_dofs(),
1444 dof_handler.n_dofs()));
1456 std::vector<types::subdomain_id> cell_owners (dof_handler.get_triangulation().n_active_cells());
1459 DoFHandlerType::space_dimension
>*> (&dof_handler.get_triangulation())))
1461 cell_owners = tr->get_true_subdomain_ids_of_cells();
1462 Assert (tr->get_true_subdomain_ids_of_cells().size() == tr->n_active_cells(),
1467 for (
typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active();
1468 cell!= dof_handler.end(); cell++)
1469 if (cell->is_locally_owned())
1470 cell_owners[cell->active_cell_index()] = cell->subdomain_id();
1474 std::fill_n (subdomain_association.begin(), dof_handler.n_dofs(),
1477 std::vector<types::global_dof_index> local_dof_indices;
1482 typename DoFHandlerType::active_cell_iterator
1483 cell = dof_handler.begin_active(),
1484 endc = dof_handler.end();
1485 for (; cell!=endc; ++cell)
1488 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
1489 local_dof_indices.resize (dofs_per_cell);
1490 cell->get_dof_indices (local_dof_indices);
1496 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1497 if (subdomain_association[local_dof_indices[i]] ==
1499 subdomain_association[local_dof_indices[i]] = subdomain_id;
1500 else if (subdomain_association[local_dof_indices[i]] > subdomain_id)
1502 subdomain_association[local_dof_indices[i]] = subdomain_id;
1506 Assert (std::find (subdomain_association.begin(),
1507 subdomain_association.end(),
1509 == subdomain_association.end(),
1515 template <
typename DoFHandlerType>
1520 std::vector<types::subdomain_id> subdomain_association (dof_handler.n_dofs());
1523 return std::count (subdomain_association.begin(),
1524 subdomain_association.end(),
1530 template <
typename DoFHandlerType>
1541 (subdomain == dof_handler.get_triangulation().locally_owned_subdomain()),
1542 ExcMessage (
"For parallel::distributed::Triangulation objects and " 1543 "associated DoF handler objects, asking for any subdomain other " 1544 "than the locally owned one does not make sense."));
1546 IndexSet index_set (dof_handler.n_dofs());
1548 std::vector<types::global_dof_index> local_dof_indices;
1556 std::vector<types::global_dof_index> subdomain_indices;
1558 typename DoFHandlerType::active_cell_iterator
1559 cell = dof_handler.begin_active(),
1560 endc = dof_handler.
end();
1561 for (; cell!=endc; ++cell)
1562 if ((cell->is_artificial() ==
false)
1564 (cell->subdomain_id() == subdomain))
1566 const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
1567 local_dof_indices.resize (dofs_per_cell);
1568 cell->get_dof_indices (local_dof_indices);
1569 subdomain_indices.insert(subdomain_indices.end(),
1570 local_dof_indices.begin(),
1571 local_dof_indices.end());
1574 std::sort (subdomain_indices.begin(), subdomain_indices.end());
1575 subdomain_indices.erase (std::unique(subdomain_indices.begin(),
1576 subdomain_indices.end()),
1577 subdomain_indices.end());
1580 index_set.add_indices (subdomain_indices.begin(), subdomain_indices.end());
1581 index_set.compress ();
1588 template <
typename DoFHandlerType>
1592 std::vector<unsigned int> &n_dofs_on_subdomain)
1594 Assert (n_dofs_on_subdomain.size() == dof_handler.get_fe(0).n_components(),
1596 dof_handler.get_fe(0).n_components()));
1597 std::fill (n_dofs_on_subdomain.begin(), n_dofs_on_subdomain.end(), 0);
1605 DoFHandlerType::space_dimension>::active_cell_iterator
1607 cell!=dof_handler.get_triangulation().end(); ++cell)
1608 if (cell->subdomain_id() == subdomain)
1614 ExcMessage (
"There are no cells for the given subdomain!"));
1618 std::vector<types::subdomain_id> subdomain_association (dof_handler.n_dofs());
1621 std::vector<unsigned char> component_association (dof_handler.n_dofs());
1622 internal::get_component_association (dof_handler, std::vector<bool>(),
1623 component_association);
1625 for (
unsigned int c=0; c<dof_handler.get_fe(0).n_components(); ++c)
1628 if ((subdomain_association[i] == subdomain) &&
1629 (component_association[i] ==
static_cast<unsigned char>(c)))
1630 ++n_dofs_on_subdomain[c];
1642 template <
int dim,
int spacedim>
1645 const std::vector<unsigned char> &dofs_by_component,
1646 const std::vector<unsigned int> &target_component,
1647 const bool only_once,
1648 std::vector<types::global_dof_index> &dofs_per_component,
1649 unsigned int &component)
1660 resolve_components(base, dofs_by_component, target_component,
1661 only_once, dofs_per_component, component);
1664 for (
unsigned int dd=0; dd<d; ++dd,++component)
1665 dofs_per_component[target_component[component]]
1666 += std::count(dofs_by_component.begin(),
1667 dofs_by_component.end(),
1674 for (
unsigned int dd=1; dd<d; ++dd)
1675 dofs_per_component[target_component[component-d+dd]] =
1676 dofs_per_component[target_component[component-d]];
1683 template <
int dim,
int spacedim>
1686 const std::vector<unsigned char> &dofs_by_component,
1687 const std::vector<unsigned int> &target_component,
1688 const bool only_once,
1689 std::vector<types::global_dof_index> &dofs_per_component,
1690 unsigned int &component)
1695 for (
unsigned int fe=1; fe<fe_collection.
size(); ++fe)
1699 Assert (fe_collection[fe].n_base_elements() == fe_collection[0].n_base_elements(),
1701 for (
unsigned int b=0;
b<fe_collection[0].n_base_elements(); ++
b)
1705 Assert (fe_collection[fe].base_element(b).n_base_elements() == fe_collection[0].base_element(b).n_base_elements(),
1710 resolve_components (fe_collection[0], dofs_by_component,
1711 target_component, only_once, dofs_per_component,
1725 template <
int dim,
int spacedim>
1735 template <
int dim,
int spacedim>
1736 bool all_elements_are_primitive (const ::hp::FECollection<dim,spacedim> &fe_collection)
1738 for (
unsigned int i=0; i<fe_collection.size(); ++i)
1739 if (fe_collection[i].is_primitive() ==
false)
1747 template <
typename DoFHandlerType>
1750 std::vector<types::global_dof_index> &dofs_per_component,
1752 std::vector<unsigned int> target_component)
1754 const unsigned int n_components = dof_handler.get_fe(0).n_components();
1756 std::fill (dofs_per_component.begin(), dofs_per_component.end(),
1761 if (target_component.size()==0)
1765 target_component[i] = i;
1773 const unsigned int max_component
1774 = *std::max_element (target_component.begin(),
1775 target_component.end());
1776 const unsigned int n_target_components = max_component + 1;
1777 (void)n_target_components;
1785 dofs_per_component[0] = dof_handler.n_locally_owned_dofs();
1792 std::vector<unsigned char> dofs_by_component (dof_handler.n_locally_owned_dofs());
1793 internal::get_component_association (dof_handler,
ComponentMask(),
1797 unsigned int component = 0;
1798 internal::resolve_components(dof_handler.get_fe_collection(),
1799 dofs_by_component, target_component,
1800 only_once, dofs_per_component, component);
1805 Assert ((internal::all_elements_are_primitive(dof_handler.get_fe_collection()) ==
false)
1807 (std::accumulate (dofs_per_component.begin(),
1808 dofs_per_component.end(),
1810 == dof_handler.n_locally_owned_dofs()),
1814 #ifdef DEAL_II_WITH_MPI 1815 const unsigned int dim = DoFHandlerType::dimension;
1816 const unsigned int spacedim = DoFHandlerType::space_dimension;
1820 (&dof_handler.get_triangulation())))
1822 std::vector<types::global_dof_index> local_dof_count = dofs_per_component;
1824 const int ierr = MPI_Allreduce (local_dof_count.data(), dofs_per_component.data(), n_target_components,
1825 DEAL_II_DOF_INDEX_MPI_TYPE,
1826 MPI_SUM, tria->get_communicator());
1834 template <
typename DoFHandlerType>
1837 std::vector<types::global_dof_index> &dofs_per_block,
1838 const std::vector<unsigned int> &target_block_)
1840 std::vector<unsigned int> target_block = target_block_;
1842 const ::hp::FECollection<DoFHandlerType::dimension,DoFHandlerType::space_dimension> &
1843 fe_collection = dof_handler.get_fe_collection();
1846 for (
unsigned int this_fe=0; this_fe<fe_collection.size(); ++this_fe)
1849 std::fill (dofs_per_block.begin(), dofs_per_block.end(),
1854 if (target_block.size()==0)
1856 target_block.resize(fe.
n_blocks());
1857 for (
unsigned int i=0; i<fe.
n_blocks(); ++i)
1858 target_block[i] = i;
1867 const unsigned int max_block
1868 = *std::max_element (target_block.begin(),
1869 target_block.end());
1870 const unsigned int n_target_blocks = max_block + 1;
1871 (void)n_target_blocks;
1873 const unsigned int n_blocks = fe.
n_blocks();
1881 dofs_per_block[0] = dof_handler.n_dofs();
1885 std::vector<unsigned char> dofs_by_block (dof_handler.n_locally_owned_dofs());
1886 internal::get_block_association (dof_handler, dofs_by_block);
1889 for (
unsigned int block=0; block<fe.
n_blocks(); ++block)
1890 dofs_per_block[target_block[block]]
1891 += std::count(dofs_by_block.begin(), dofs_by_block.end(),
1894 #ifdef DEAL_II_WITH_MPI 1899 (&dof_handler.get_triangulation())))
1901 std::vector<types::global_dof_index> local_dof_count = dofs_per_block;
1902 const int ierr = MPI_Allreduce (local_dof_count.data(), dofs_per_block.data(),
1904 DEAL_II_DOF_INDEX_MPI_TYPE,
1905 MPI_SUM, tria->get_communicator());
1914 template <
typename DoFHandlerType>
1917 std::vector<types::global_dof_index> &mapping)
1920 mapping.insert (mapping.end(), dof_handler.n_dofs(),
1923 std::vector<types::global_dof_index> dofs_on_face;
1933 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1934 endc = dof_handler.end();
1935 for (; cell!=endc; ++cell)
1936 for (
unsigned int f=0; f<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++f)
1937 if (cell->at_boundary(f))
1939 const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
1940 dofs_on_face.resize (dofs_per_face);
1941 cell->face(f)->get_dof_indices (dofs_on_face,
1942 cell->active_fe_index());
1943 for (
unsigned int i=0; i<dofs_per_face; ++i)
1945 mapping[dofs_on_face[i]] = next_boundary_index++;
1953 template <
typename DoFHandlerType>
1955 (
const DoFHandlerType &dof_handler,
1956 const std::set<types::boundary_id> &boundary_ids,
1957 std::vector<types::global_dof_index> &mapping)
1963 mapping.insert (mapping.end(), dof_handler.n_dofs(),
1967 if (boundary_ids.size() == 0)
1970 std::vector<types::global_dof_index> dofs_on_face;
1974 typename DoFHandlerType::active_cell_iterator cell = dof_handler.begin_active(),
1975 endc = dof_handler.end();
1976 for (; cell!=endc; ++cell)
1977 for (
unsigned int f=0; f<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++f)
1978 if (boundary_ids.find (cell->face(f)->boundary_id()) !=
1981 const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
1982 dofs_on_face.resize (dofs_per_face);
1983 cell->face(f)->get_dof_indices (dofs_on_face, cell->active_fe_index());
1984 for (
unsigned int i=0; i<dofs_per_face; ++i)
1986 mapping[dofs_on_face[i]] = next_boundary_index++;
1990 dof_handler.n_boundary_dofs (boundary_ids));
1997 template <
typename DoFHandlerType>
2001 const DoFHandlerType &dof_handler,
2004 const unsigned int dim = DoFHandlerType::dimension;
2005 const unsigned int spacedim = DoFHandlerType::space_dimension;
2010 for (
unsigned int fe_index = 0; fe_index < fe_collection.
size(); ++fe_index)
2013 Assert(fe_collection[fe_index].has_support_points(),
2017 fe_collection[fe_index].get_unit_support_points()));
2029 typename DoFHandlerType::active_cell_iterator cell =
2030 dof_handler.begin_active(), endc = dof_handler.end();
2032 std::vector<types::global_dof_index> local_dof_indices;
2033 for (; cell != endc; ++cell)
2035 if (cell->is_artificial() ==
false)
2037 hp_fe_values.reinit(cell);
2040 local_dof_indices.resize(cell->get_fe().dofs_per_cell);
2041 cell->get_dof_indices(local_dof_indices);
2043 const std::vector<Point<spacedim> > &points =
2045 for (
unsigned int i = 0; i < cell->get_fe().dofs_per_cell; ++i)
2047 support_points[local_dof_indices[i]] = points[i];
2052 template <
typename DoFHandlerType>
2056 const DoFHandlerType &dof_handler,
2060 std::map<types::global_dof_index,Point<DoFHandlerType::space_dimension> > x_support_points;
2067 Assert (x_support_points.find(i) != x_support_points.end(),
2069 support_points[i] = x_support_points[i];
2075 template <
int dim,
int spacedim>
2086 ExcMessage (
"This function can not be used with distributed triangulations." 2087 "See the documentation for more information."));
2093 internal::map_dofs_to_support_points (mapping_collection,
2099 template <
int dim,
int spacedim>
2110 ExcMessage (
"This function can not be used with distributed triangulations." 2111 "See the documentation for more information."));
2115 internal::map_dofs_to_support_points (mapping,
2121 template <
int dim,
int spacedim>
2127 support_points.clear();
2133 internal::map_dofs_to_support_points (mapping_collection,
2139 template <
int dim,
int spacedim>
2145 support_points.clear();
2149 internal::map_dofs_to_support_points (mapping,
2154 template <
int spacedim>
2161 typedef std::map< types::global_dof_index, Point<spacedim> >
2167 point_map_t point_map;
2170 for (
typename dof_map_t::const_iterator it = support_points.begin();
2171 it!=support_points.end();
2174 std::vector<types::global_dof_index> &v = point_map[it->second];
2175 v.push_back(it->first);
2179 for (
typename point_map_t::iterator it = point_map.begin();
2180 it!=point_map.end();
2183 out << it->first <<
" \"";
2184 const std::vector<types::global_dof_index> &v = it->second;
2185 for (
unsigned int i=0; i < v.size(); ++i)
2199 template <
int dim,
int spacedim>
2207 const unsigned int nb = fe.
n_blocks();
2209 tables_by_block.resize(1);
2210 tables_by_block[0].reinit(nb, nb);
2211 tables_by_block[0].fill(
none);
2219 tables_by_block[0](ib,jb) |= table(i,j);
2225 template <
int dim,
int spacedim>
2232 tables_by_block.resize(fe_collection.
size());
2234 for (
unsigned int f=0; f<fe_collection.
size(); ++f)
2238 const unsigned int nb = fe.
n_blocks();
2239 tables_by_block[f].reinit(nb, nb);
2240 tables_by_block[f].fill(
none);
2247 tables_by_block[f](ib,jb) |= table(i,j);
2255 template <
int dim,
int spacedim>
2258 const unsigned int level,
2259 const std::vector<bool> &selected_dofs,
2262 typename DoFHandler<dim,spacedim>::level_cell_iterator cell;
2263 typename DoFHandler<dim,spacedim>::level_cell_iterator endc = dof_handler.
end(level);
2264 std::vector<types::global_dof_index> indices;
2268 for (cell=dof_handler.
begin(level); cell != endc; ++cell)
2269 if (cell->is_locally_owned_on_level())
2273 for (cell=dof_handler.
begin(level); cell != endc; ++cell)
2274 if (cell->is_locally_owned_on_level())
2276 indices.resize(cell->
get_fe().dofs_per_cell);
2277 cell->get_mg_dof_indices(indices);
2279 if (selected_dofs.size()!=0)
2284 if (selected_dofs.size() == 0)
2285 block_list.
add(i,indices[j]-offset);
2288 if (selected_dofs[j])
2289 block_list.
add(i,indices[j]-offset);
2297 template <
typename DoFHandlerType>
2299 const DoFHandlerType &dof_handler,
2300 const unsigned int level,
2301 const bool interior_only)
2304 block_list.
reinit(1, dof_handler.n_dofs(level), dof_handler.n_dofs(level));
2305 typename DoFHandlerType::level_cell_iterator cell;
2306 typename DoFHandlerType::level_cell_iterator endc = dof_handler.end(level);
2308 std::vector<types::global_dof_index> indices;
2309 std::vector<bool> exclude;
2311 for (cell=dof_handler.begin(level); cell != endc; ++cell)
2313 indices.resize(cell->get_fe().dofs_per_cell);
2314 cell->get_mg_dof_indices(indices);
2320 std::fill(exclude.begin(), exclude.end(),
false);
2323 for (
unsigned int face=0; face<GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
2324 if (cell->at_boundary(face) || cell->neighbor(face)->level() != cell->level())
2325 for (
unsigned int i=0; i<dpf; ++i)
2329 block_list.
add(0, indices[j]);
2334 block_list.
add(0, indices[j]);
2340 template <
typename DoFHandlerType>
2342 const DoFHandlerType &dof_handler,
2343 const unsigned int level,
2344 const bool interior_dofs_only,
2345 const bool boundary_dofs)
2347 Assert(level > 0 && level < dof_handler.get_triangulation().n_levels(),
2348 ExcIndexRange(level, 1, dof_handler.get_triangulation().n_levels()));
2350 typename DoFHandlerType::level_cell_iterator pcell = dof_handler.begin(level-1);
2351 typename DoFHandlerType::level_cell_iterator endc = dof_handler.end(level-1);
2353 std::vector<types::global_dof_index> indices;
2354 std::vector<bool> exclude;
2356 for (
unsigned int block = 0; pcell != endc; ++pcell)
2358 if (!pcell->has_children())
2361 for (
unsigned int child=0; child<pcell->n_children(); ++child)
2363 const typename DoFHandlerType::level_cell_iterator cell = pcell->child(child);
2368 indices.resize(n_dofs);
2369 exclude.resize(n_dofs);
2370 std::fill(exclude.begin(), exclude.end(),
false);
2371 cell->get_mg_dof_indices(indices);
2373 if (interior_dofs_only)
2379 for (
unsigned int d=0; d<DoFHandlerType::dimension; ++d)
2382 for (
unsigned int i=0; i<dpf; ++i)
2389 for (
unsigned int face=0; face< GeometryInfo<DoFHandlerType::dimension>::faces_per_cell; ++face)
2390 if (cell->at_boundary(face))
2391 for (
unsigned int i=0; i<dpf; ++i)
2395 for (
unsigned int i=0; i<n_dofs; ++i)
2397 block_list.
add(block, indices[i]);
2403 template <
typename DoFHandlerType>
2404 std::vector<unsigned int>
2406 const DoFHandlerType &dof_handler,
2407 const unsigned int level,
2408 const bool interior_only,
2409 const bool boundary_patches,
2410 const bool level_boundary_patches,
2411 const bool single_cell_patches,
2412 const bool invert_vertex_mapping)
2414 const unsigned int n_blocks = dof_handler.get_fe().n_blocks();
2419 exclude_boundary_dofs,
2421 level_boundary_patches,
2422 single_cell_patches,
2423 invert_vertex_mapping);
2426 template <
typename DoFHandlerType>
2427 std::vector<unsigned int>
2429 const DoFHandlerType &dof_handler,
2430 const unsigned int level,
2432 const bool boundary_patches,
2433 const bool level_boundary_patches,
2434 const bool single_cell_patches,
2435 const bool invert_vertex_mapping)
2437 typename DoFHandlerType::level_cell_iterator cell;
2438 typename DoFHandlerType::level_cell_iterator endc = dof_handler.end(level);
2442 std::vector<unsigned int> vertex_cell_count(dof_handler.get_triangulation().n_vertices(), 0);
2445 std::vector<bool> vertex_boundary(dof_handler.get_triangulation().n_vertices(),
false);
2447 std::vector<unsigned int> vertex_mapping(dof_handler.get_triangulation().n_vertices(),
2451 std::vector<unsigned int> vertex_dof_count(dof_handler.get_triangulation().n_vertices(), 0);
2455 for (cell=dof_handler.begin(level); cell != endc; ++cell)
2456 for (
unsigned int v=0; v<GeometryInfo<DoFHandlerType::dimension>::vertices_per_cell; ++v)
2458 const unsigned int vg = cell->vertex_index(v);
2459 vertex_dof_count[vg] += cell->get_fe().dofs_per_cell;
2460 ++vertex_cell_count[vg];
2461 for (
unsigned int d=0; d<DoFHandlerType::dimension; ++d)
2464 if (cell->at_boundary(face))
2465 vertex_boundary[vg] =
true;
2466 else if ((!level_boundary_patches)
2467 && (cell->neighbor(face)->level() != (int) level))
2468 vertex_boundary[vg] =
true;
2474 for (
unsigned int vg=0; vg<vertex_dof_count.size(); ++vg)
2475 if ((!single_cell_patches && vertex_cell_count[vg] < 2)
2477 (!boundary_patches && vertex_boundary[vg]))
2478 vertex_dof_count[vg] = 0;
2481 unsigned int n_vertex_count=0;
2482 for (
unsigned int vg=0; vg<vertex_mapping.size(); ++vg)
2483 if (vertex_dof_count[vg] != 0)
2484 vertex_mapping[vg] = n_vertex_count++;
2487 for (
unsigned int vg=0; vg<vertex_mapping.size(); ++vg)
2488 if (vertex_dof_count[vg] != 0)
2489 vertex_dof_count[vertex_mapping[vg]] = vertex_dof_count[vg];
2493 vertex_dof_count.resize(n_vertex_count);
2497 block_list.
reinit(vertex_dof_count.size(), dof_handler.n_dofs(level), vertex_dof_count);
2499 std::vector<types::global_dof_index> indices;
2500 std::vector<bool> exclude;
2502 for (cell=dof_handler.begin(level); cell != endc; ++cell)
2506 cell->get_mg_dof_indices(indices);
2508 for (
unsigned int v=0; v<GeometryInfo<DoFHandlerType::dimension>::vertices_per_cell; ++v)
2510 const unsigned int vg = cell->vertex_index(v);
2511 const unsigned int block = vertex_mapping[vg];
2522 std::fill(exclude.begin(), exclude.end(),
false);
2525 for (
unsigned int d=0; d<DoFHandlerType::dimension; ++d)
2529 for (
unsigned int i=0; i<dpf; ++i)
2536 for (
unsigned int j=0; j<indices.size(); ++j)
2538 block_list.
add(block, indices[j]);
2542 for (
unsigned int j=0; j<indices.size(); ++j)
2543 block_list.
add(block, indices[j]);
2548 if (invert_vertex_mapping)
2551 unsigned int n_vertex_count = 0;
2552 for (
unsigned int vg = 0; vg < vertex_mapping.size(); ++vg)
2554 vertex_mapping[n_vertex_count++] = vg;
2557 vertex_mapping.resize(n_vertex_count);
2560 return vertex_mapping;
2564 template <
typename DoFHandlerType>
2568 std::set<types::global_dof_index> dofs_on_patch;
2569 std::vector<types::global_dof_index> local_dof_indices;
2574 for (
unsigned int i=0; i<patch.size(); ++i)
2576 const typename DoFHandlerType::active_cell_iterator cell = patch[i];
2577 Assert (cell->is_artificial() ==
false,
2578 ExcMessage(
"This function can not be called with cells that are " 2579 "not either locally owned or ghost cells."));
2580 local_dof_indices.resize (cell->get_fe().dofs_per_cell);
2581 cell->get_dof_indices (local_dof_indices);
2582 dofs_on_patch.insert (local_dof_indices.begin(),
2583 local_dof_indices.end());
2587 return dofs_on_patch.size();
2592 template <
typename DoFHandlerType>
2593 std::vector<types::global_dof_index>
2596 std::set<types::global_dof_index> dofs_on_patch;
2597 std::vector<types::global_dof_index> local_dof_indices;
2602 for (
unsigned int i=0; i<patch.size(); ++i)
2604 const typename DoFHandlerType::active_cell_iterator cell = patch[i];
2605 Assert (cell->is_artificial() ==
false,
2606 ExcMessage(
"This function can not be called with cells that are " 2607 "not either locally owned or ghost cells."));
2608 local_dof_indices.resize (cell->get_fe().dofs_per_cell);
2609 cell->get_dof_indices (local_dof_indices);
2610 dofs_on_patch.insert (local_dof_indices.begin(),
2611 local_dof_indices.end());
2614 Assert (dofs_on_patch.size() == count_dofs_on_patch<DoFHandlerType>(patch),
2621 return std::vector<types::global_dof_index> (dofs_on_patch.begin(),
2622 dofs_on_patch.end());
2632 #include "dof_tools.inst" 2636 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
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 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
size_type n_constraints() const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) 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
const hp::FECollection< dim, spacedim > & get_fe_collection() const
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
const std::vector< std::pair< size_type, double > > * get_constraint_entries(const size_type line) const
const types::global_dof_index invalid_dof_index
unsigned int size() const
unsigned int n_base_elements() const
ElementIterator begin() const
void push_back(const Quadrature< dim > &new_quadrature)
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()