16 #include <deal.II/base/logstream.h> 17 #include <deal.II/base/thread_management.h> 18 #include <deal.II/lac/sparsity_pattern.h> 19 #include <deal.II/lac/block_sparsity_pattern.h> 20 #include <deal.II/lac/dynamic_sparsity_pattern.h> 21 #include <deal.II/lac/sparsity_pattern.h> 22 #include <deal.II/lac/block_vector.h> 23 #include <deal.II/lac/sparse_matrix.h> 24 #include <deal.II/lac/block_sparse_matrix.h> 25 #include <deal.II/lac/block_vector.h> 26 #include <deal.II/grid/tria.h> 27 #include <deal.II/grid/tria_iterator.h> 28 #include <deal.II/dofs/dof_accessor.h> 29 #include <deal.II/multigrid/mg_tools.h> 30 #include <deal.II/multigrid/mg_base.h> 31 #include <deal.II/base/mg_level_object.h> 32 #include <deal.II/dofs/dof_handler.h> 33 #include <deal.II/dofs/dof_tools.h> 34 #include <deal.II/fe/fe.h> 35 #include <deal.II/fe/component_mask.h> 36 #include <deal.II/numerics/matrix_tools.h> 42 DEAL_II_NAMESPACE_OPEN
55 std::vector<unsigned int> &,
58 Assert(
false, ExcNotImplemented());
68 std::vector<unsigned int> &,
72 Assert(
false, ExcNotImplemented());
82 std::vector<unsigned int> &,
85 Assert(
false, ExcNotImplemented());
94 std::vector<unsigned int> &,
98 Assert(
false, ExcNotImplemented());
104 template <
int dim,
int spacedim>
108 const unsigned int level,
109 std::vector<unsigned int> &row_lengths,
113 ExcDimensionMismatch(row_lengths.size(), dofs.
n_dofs()));
117 std::fill(row_lengths.begin(), row_lengths.end(), 0);
120 std::vector<bool> old_flags;
132 std::vector<types::global_dof_index> cell_indices;
133 std::vector<types::global_dof_index> neighbor_indices;
142 for (cell = dofs.
begin(level); cell != end; ++cell)
146 cell->get_mg_dof_indices(cell_indices);
172 row_lengths[cell_indices[i++]] += increment;
187 row_lengths[cell_indices[i++]] += increment;
194 row_lengths[cell_indices[i++]] += increment;
198 row_lengths[cell_indices[i++]] += increment;
211 for (
unsigned int iface=0; iface<GeometryInfo<dim>::faces_per_cell; ++iface)
213 bool level_boundary = cell->at_boundary(iface);
217 neighbor = cell->neighbor(iface);
218 if (static_cast<unsigned int>(neighbor->level()) != level)
219 level_boundary =
true;
224 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
230 typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(iface);
243 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
244 row_lengths[cell_indices[local_dof]] += dof_increment;
249 if (face->user_flag_set())
251 face->set_user_flag();
265 neighbor->get_mg_dof_indices(neighbor_indices);
266 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
268 for (
unsigned int local_dof=0; local_dof<nfe.
dofs_per_cell; ++local_dof)
269 row_lengths[neighbor_indices[local_dof]] += fe.
dofs_per_face;
277 template <
int dim,
int spacedim>
281 const unsigned int level,
282 std::vector<unsigned int> &row_lengths,
287 ExcDimensionMismatch(row_lengths.size(), dofs.
n_dofs()));
291 std::fill(row_lengths.begin(), row_lengths.end(), 0);
294 std::vector<bool> old_flags;
306 std::vector<types::global_dof_index> cell_indices;
307 std::vector<types::global_dof_index> neighbor_indices;
313 std::vector<Table<2, DoFTools::Coupling> > couple_cell;
314 std::vector<Table<2, DoFTools::Coupling> > couple_face;
328 const unsigned int fe_index = cell->active_fe_index();
331 ExcDimensionMismatch(couplings.n_rows(), fe.
n_components()));
333 ExcDimensionMismatch(couplings.n_cols(), fe.
n_components()));
335 ExcDimensionMismatch(flux_couplings.n_rows(), fe.
n_components()));
337 ExcDimensionMismatch(flux_couplings.n_cols(), fe.
n_components()));
340 cell->get_mg_dof_indices(cell_indices);
363 unsigned int increment;
373 row_lengths[cell_indices[i]] += increment;
399 row_lengths[cell_indices[i]] += increment;
417 row_lengths[cell_indices[i]] += increment;
433 row_lengths[cell_indices[i]] += increment;
449 for (
unsigned int iface=0; iface<GeometryInfo<dim>::faces_per_cell; ++iface)
451 bool level_boundary = cell->at_boundary(iface);
455 neighbor = cell->neighbor(iface);
456 if (static_cast<unsigned int>(neighbor->level()) != level)
457 level_boundary =
true;
462 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
468 typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(iface);
480 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
486 row_lengths[cell_indices[local_dof]] += dof_increment;
492 if (face->user_flag_set())
494 face->set_user_flag();
516 neighbor->get_mg_dof_indices(neighbor_indices);
519 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
522 row_lengths[cell_indices[local_dof]]
526 for (
unsigned int local_dof=0; local_dof<nfe.
dofs_per_cell; ++local_dof)
529 row_lengths[neighbor_indices[local_dof]]
538 template <
typename DoFHandlerType,
typename SparsityPatternType>
540 SparsityPatternType &sparsity,
541 const unsigned int level)
546 Assert (sparsity.n_rows() == n_dofs,
547 ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
548 Assert (sparsity.n_cols() == n_dofs,
549 ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
551 const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
552 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
553 typename DoFHandlerType::cell_iterator cell = dof.begin(level),
554 endc = dof.end(level);
555 for (; cell!=endc; ++cell)
557 || cell->level_subdomain_id()==dof.get_triangulation().locally_owned_subdomain())
559 cell->get_mg_dof_indices (dofs_on_this_cell);
561 for (
unsigned int i=0; i<dofs_per_cell; ++i)
562 for (
unsigned int j=0; j<dofs_per_cell; ++j)
563 sparsity.add (dofs_on_this_cell[i],
564 dofs_on_this_cell[j]);
570 template <
int dim,
typename SparsityPatternType,
int spacedim>
573 SparsityPatternType &sparsity,
574 const unsigned int level)
579 Assert (sparsity.n_rows() == n_dofs,
580 ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
581 Assert (sparsity.n_cols() == n_dofs,
582 ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
584 const unsigned int dofs_per_cell = dof.
get_fe().dofs_per_cell;
585 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
586 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
588 endc = dof.
end(level);
589 for (; cell!=endc; ++cell)
591 if (!cell->is_locally_owned_on_level())
continue;
593 cell->get_mg_dof_indices (dofs_on_this_cell);
595 for (
unsigned int i=0; i<dofs_per_cell; ++i)
596 for (
unsigned int j=0; j<dofs_per_cell; ++j)
597 sparsity.add (dofs_on_this_cell[i],
598 dofs_on_this_cell[j]);
601 for (
unsigned int face = 0;
602 face < GeometryInfo<dim>::faces_per_cell;
605 if ( (! cell->at_boundary(face)) &&
606 (static_cast<unsigned int>(cell->neighbor_level(face)) == level) )
609 neighbor = cell->neighbor(face);
610 neighbor->get_mg_dof_indices (dofs_on_other_cell);
614 for (
unsigned int i=0; i<dofs_per_cell; ++i)
616 for (
unsigned int j=0; j<dofs_per_cell; ++j)
618 sparsity.add (dofs_on_this_cell[i],
619 dofs_on_other_cell[j]);
622 if (neighbor->is_locally_owned_on_level() ==
false)
623 for (
unsigned int i=0; i<dofs_per_cell; ++i)
624 for (
unsigned int j=0; j<dofs_per_cell; ++j)
626 sparsity.add (dofs_on_other_cell[i],
627 dofs_on_other_cell[j]);
628 sparsity.add (dofs_on_other_cell[i],
629 dofs_on_this_cell[j]);
638 template <
int dim,
typename SparsityPatternType,
int spacedim>
641 SparsityPatternType &sparsity,
642 const unsigned int level)
654 Assert (sparsity.n_rows() == coarse_dofs,
655 ExcDimensionMismatch (sparsity.n_rows(), coarse_dofs));
656 Assert (sparsity.n_cols() == fine_dofs,
657 ExcDimensionMismatch (sparsity.n_cols(), fine_dofs));
659 const unsigned int dofs_per_cell = dof.
get_fe().dofs_per_cell;
660 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
661 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
663 endc = dof.
end(level);
664 for (; cell!=endc; ++cell)
666 if (!cell->is_locally_owned_on_level())
continue;
668 cell->get_mg_dof_indices (dofs_on_this_cell);
670 for (
unsigned int face = 0;
671 face < GeometryInfo<dim>::faces_per_cell;
676 if ( (! cell->at_boundary(face)) &&
677 (static_cast<unsigned int>(cell->neighbor_level(face)) != level) )
680 neighbor = cell->neighbor(face);
681 neighbor->get_mg_dof_indices (dofs_on_other_cell);
683 for (
unsigned int i=0; i<dofs_per_cell; ++i)
685 for (
unsigned int j=0; j<dofs_per_cell; ++j)
687 sparsity.add (dofs_on_other_cell[i],
688 dofs_on_this_cell[j]);
689 sparsity.add (dofs_on_other_cell[j],
690 dofs_on_this_cell[i]);
700 template <
int dim,
typename SparsityPatternType,
int spacedim>
703 SparsityPatternType &sparsity,
704 const unsigned int level,
714 Assert (sparsity.n_rows() == n_dofs,
715 ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
716 Assert (sparsity.n_cols() == n_dofs,
717 ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
718 Assert (int_mask.n_rows() == n_comp,
719 ExcDimensionMismatch (int_mask.n_rows(), n_comp));
720 Assert (int_mask.n_cols() == n_comp,
721 ExcDimensionMismatch (int_mask.n_cols(), n_comp));
722 Assert (flux_mask.n_rows() == n_comp,
723 ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
724 Assert (flux_mask.n_cols() == n_comp,
725 ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
728 std::vector<types::global_dof_index> dofs_on_this_cell(total_dofs);
729 std::vector<types::global_dof_index> dofs_on_other_cell(total_dofs);
733 endc = dof.
end(level);
739 for (
unsigned int i=0; i<total_dofs; ++i)
740 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
751 std::vector<bool> user_flags;
755 for (; cell!=endc; ++cell)
757 if (!cell->is_locally_owned_on_level())
continue;
759 cell->get_mg_dof_indices (dofs_on_this_cell);
761 for (
unsigned int i=0; i<total_dofs; ++i)
762 for (
unsigned int j=0; j<total_dofs; ++j)
764 sparsity.add (dofs_on_this_cell[i],
765 dofs_on_this_cell[j]);
768 for (
unsigned int face = 0;
769 face < GeometryInfo<dim>::faces_per_cell;
772 typename DoFHandler<dim,spacedim>::face_iterator cell_face = cell->face(face);
773 if (cell_face->user_flag_set ())
776 if (cell->at_boundary (face) )
778 for (
unsigned int i=0; i<total_dofs; ++i)
780 const bool i_non_zero_i = support_on_face (i, face);
781 for (
unsigned int j=0; j<total_dofs; ++j)
783 const bool j_non_zero_i = support_on_face (j, face);
786 sparsity.add (dofs_on_this_cell[i],
787 dofs_on_this_cell[j]);
789 && i_non_zero_i && j_non_zero_i)
790 sparsity.add (dofs_on_this_cell[i],
791 dofs_on_this_cell[j]);
798 neighbor = cell->neighbor(face);
800 if (neighbor->level() < cell->level())
803 unsigned int neighbor_face = cell->neighbor_of_neighbor(face);
805 neighbor->get_mg_dof_indices (dofs_on_other_cell);
806 for (
unsigned int i=0; i<total_dofs; ++i)
808 const bool i_non_zero_i = support_on_face (i, face);
809 const bool i_non_zero_e = support_on_face (i, neighbor_face);
810 for (
unsigned int j=0; j<total_dofs; ++j)
812 const bool j_non_zero_i = support_on_face (j, face);
813 const bool j_non_zero_e = support_on_face (j, neighbor_face);
816 sparsity.add (dofs_on_this_cell[i],
817 dofs_on_other_cell[j]);
818 sparsity.add (dofs_on_other_cell[i],
819 dofs_on_this_cell[j]);
820 sparsity.add (dofs_on_this_cell[i],
821 dofs_on_this_cell[j]);
822 sparsity.add (dofs_on_other_cell[i],
823 dofs_on_other_cell[j]);
827 if (i_non_zero_i && j_non_zero_e)
828 sparsity.add (dofs_on_this_cell[i],
829 dofs_on_other_cell[j]);
830 if (i_non_zero_e && j_non_zero_i)
831 sparsity.add (dofs_on_other_cell[i],
832 dofs_on_this_cell[j]);
833 if (i_non_zero_i && j_non_zero_i)
834 sparsity.add (dofs_on_this_cell[i],
835 dofs_on_this_cell[j]);
836 if (i_non_zero_e && j_non_zero_e)
837 sparsity.add (dofs_on_other_cell[i],
838 dofs_on_other_cell[j]);
843 sparsity.add (dofs_on_this_cell[j],
844 dofs_on_other_cell[i]);
845 sparsity.add (dofs_on_other_cell[j],
846 dofs_on_this_cell[i]);
847 sparsity.add (dofs_on_this_cell[j],
848 dofs_on_this_cell[i]);
849 sparsity.add (dofs_on_other_cell[j],
850 dofs_on_other_cell[i]);
854 if (j_non_zero_i && i_non_zero_e)
855 sparsity.add (dofs_on_this_cell[j],
856 dofs_on_other_cell[i]);
857 if (j_non_zero_e && i_non_zero_i)
858 sparsity.add (dofs_on_other_cell[j],
859 dofs_on_this_cell[i]);
860 if (j_non_zero_i && i_non_zero_i)
861 sparsity.add (dofs_on_this_cell[j],
862 dofs_on_this_cell[i]);
863 if (j_non_zero_e && i_non_zero_e)
864 sparsity.add (dofs_on_other_cell[j],
865 dofs_on_other_cell[i]);
869 neighbor->face(neighbor_face)->set_user_flag ();
880 template <
int dim,
typename SparsityPatternType,
int spacedim>
883 SparsityPatternType &sparsity,
884 const unsigned int level,
901 Assert (sparsity.n_rows() == coarse_dofs,
902 ExcDimensionMismatch (sparsity.n_rows(), coarse_dofs));
903 Assert (sparsity.n_cols() == fine_dofs,
904 ExcDimensionMismatch (sparsity.n_cols(), fine_dofs));
905 Assert (flux_mask.n_rows() == n_comp,
906 ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
907 Assert (flux_mask.n_cols() == n_comp,
908 ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
910 const unsigned int dofs_per_cell = dof.
get_fe().dofs_per_cell;
911 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
912 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
916 endc = dof.
end(level);
921 for (
unsigned int i=0; i<dofs_per_cell; ++i)
922 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
925 for (; cell!=endc; ++cell)
927 if (!cell->is_locally_owned_on_level())
continue;
929 cell->get_mg_dof_indices (dofs_on_this_cell);
931 for (
unsigned int face = 0;
932 face < GeometryInfo<dim>::faces_per_cell;
937 if ( (! cell->at_boundary(face)) &&
938 (static_cast<unsigned int>(cell->neighbor_level(face)) != level) )
941 neighbor = cell->neighbor(face);
942 neighbor->get_mg_dof_indices (dofs_on_other_cell);
944 for (
unsigned int i=0; i<dofs_per_cell; ++i)
946 for (
unsigned int j=0; j<dofs_per_cell; ++j)
950 sparsity.add (dofs_on_other_cell[i],
951 dofs_on_this_cell[j]);
952 sparsity.add (dofs_on_other_cell[j],
953 dofs_on_this_cell[i]);
964 template <
int dim,
int spacedim>
967 std::vector<std::vector<types::global_dof_index> > &result,
969 std::vector<unsigned int> target_component)
975 Assert (result.size() == nlevels,
976 ExcDimensionMismatch(result.size(), nlevels));
978 if (target_component.size() == 0)
980 target_component.resize(n_components);
981 for (
unsigned int i=0; i<n_components; ++i)
982 target_component[i] = i;
985 Assert(target_component.size() == n_components,
986 ExcDimensionMismatch(target_component.size(), n_components));
988 for (
unsigned int l=0; l<nlevels; ++l)
990 result[l].resize (n_components);
991 std::fill (result[l].begin(),result[l].end(), 0U);
997 if (n_components == 1)
999 result[l][0] = dof_handler.
n_dofs(l);
1006 std::vector<std::vector<bool> >
1007 dofs_in_component (n_components,
1008 std::vector<bool>(dof_handler.
n_dofs(l),
1010 std::vector<ComponentMask> component_select (n_components);
1012 for (
unsigned int i=0; i<n_components; ++i)
1014 void (*fun_ptr) (
const unsigned int level,
1017 std::vector<bool> &)
1020 std::vector<bool> tmp(n_components,
false);
1022 component_select[i] = ComponentMask(tmp);
1026 component_select[i],
1027 dofs_in_component[i]);
1032 unsigned int component = 0;
1041 for (
unsigned int dd=0; dd<d; ++dd)
1044 result[l][target_component[component]]
1045 += std::count(dofs_in_component[component].begin(),
1046 dofs_in_component[component].end(),
1055 std::accumulate (result[l].begin(),
1056 result[l].end(), 0U)
1059 ExcInternalError());
1066 template <
typename DoFHandlerType>
1069 (
const DoFHandlerType &dof_handler,
1070 std::vector<std::vector<types::global_dof_index> > &dofs_per_block,
1071 std::vector<unsigned int> target_block)
1074 const unsigned int n_blocks = fe.
n_blocks();
1075 const unsigned int n_levels = dof_handler.get_triangulation().n_global_levels();
1079 for (
unsigned int l=0; l<n_levels; ++l)
1080 std::fill (dofs_per_block[l].begin(), dofs_per_block[l].end(), 0U);
1084 if (target_block.size()==0)
1086 target_block.resize(n_blocks);
1087 for (
unsigned int i=0; i<n_blocks; ++i)
1088 target_block[i] = i;
1090 Assert(target_block.size()==n_blocks,
1091 ExcDimensionMismatch(target_block.size(),n_blocks));
1093 const unsigned int max_block
1094 = *std::max_element (target_block.begin(),
1095 target_block.end());
1096 const unsigned int n_target_blocks = max_block + 1;
1097 (void)n_target_blocks;
1099 for (
unsigned int l=0; l<n_levels; ++l)
1108 for (
unsigned int l=0; l<n_levels; ++l)
1109 dofs_per_block[l][0] = dof_handler.n_dofs(l);
1115 for (
unsigned int l=0; l<n_levels; ++l)
1117 std::vector<std::vector<bool> >
1118 dofs_in_block (n_blocks, std::vector<bool>(dof_handler.n_dofs(l),
false));
1119 std::vector<BlockMask> block_select (n_blocks);
1121 for (
unsigned int i=0; i<n_blocks; ++i)
1123 void (*fun_ptr) (
const unsigned int level,
1124 const DoFHandlerType &,
1126 std::vector<bool> &)
1127 = &DoFTools::extract_level_dofs<DoFHandlerType>;
1129 std::vector<bool> tmp(n_blocks,
false);
1131 block_select[i] = tmp;
1134 l, dof_handler, block_select[i],
1140 for (
unsigned int block=0; block<fe.
n_blocks(); ++block)
1141 dofs_per_block[l][target_block[block]]
1142 += std::count(dofs_in_block[block].begin(),
1143 dofs_in_block[block].end(),
1154 std::vector<std::set<types::global_dof_index> > &,
1157 Assert(
false, ExcNotImplemented());
1167 std::vector<std::set<types::global_dof_index> > &,
1170 Assert(
false, ExcNotImplemented());
1175 template <
int dim,
int spacedim>
1180 std::vector<std::set<types::global_dof_index> > &boundary_indices,
1186 if (function_map.size() == 0)
1194 const unsigned int n_components = DoFTools::n_components(dof);
1195 const bool fe_is_system = (n_components != 1);
1199 std::vector<types::global_dof_index> local_dofs;
1200 local_dofs.reserve (DoFTools::max_dofs_per_face(dof));
1201 std::fill (local_dofs.begin (),
1213 for (; cell!=endc; ++cell)
1219 const unsigned int level = cell->level();
1222 for (
unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
1224 if (cell->at_boundary(face_no) ==
true)
1226 const typename DoFHandler<dim,spacedim>::face_iterator
1227 face = cell->face(face_no);
1231 if (function_map.find(bi) != function_map.end())
1233 face->get_mg_dof_indices(level, local_dofs);
1235 boundary_indices[level].insert(local_dofs[i]);
1243 ExcMessage(
"It's probably worthwhile to select at least one component."));
1248 for (; cell!=endc; ++cell)
1251 for (
unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
1254 if (cell->at_boundary(face_no) ==
false)
1258 const unsigned int level = cell->level();
1270 for (
unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
1273 = cell->get_fe().get_nonzero_components (i);
1274 for (
unsigned int c=0; c<n_components; ++c)
1275 if ((nonzero_component_array[c] ==
true)
1277 (component_mask[c] ==
true))
1278 Assert (cell->get_fe().is_primitive (i),
1279 ExcMessage (
"This function can only deal with requested boundary " 1280 "values that correspond to primitive (scalar) base " 1284 typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
1286 if (function_map.find(boundary_component) != function_map.end())
1293 face->get_mg_dof_indices (level, local_dofs);
1307 for (
unsigned int i=0; i<local_dofs.size(); ++i)
1309 unsigned int component;
1333 const unsigned int cell_i
1378 if (component_mask[component] ==
true)
1379 boundary_indices[level].insert(local_dofs[i]);
1383 for (
unsigned int i=0; i<local_dofs.size(); ++i)
1384 boundary_indices[level].insert(local_dofs[i]);
1391 template <
int dim,
int spacedim>
1395 std::vector<IndexSet> &boundary_indices,
1399 ExcDimensionMismatch (boundary_indices.size(),
1402 std::vector<std::set<types::global_dof_index> >
1408 boundary_indices[i].add_indices (my_boundary_indices[i].begin(),
1409 my_boundary_indices[i].end());
1414 template <
int dim,
int spacedim>
1417 std::vector<std::set<types::global_dof_index> > &non_interface_dofs)
1420 ExcDimensionMismatch (non_interface_dofs.size(),
1428 std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
1429 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1430 std::vector<bool> cell_dofs_interface(dofs_per_cell,
false);
1433 endc = mg_dof_handler.
end();
1436 for (; cell!=endc; ++cell)
1439 && cell->level_subdomain_id()!=mg_dof_handler.
get_triangulation().locally_owned_subdomain())
1442 std::fill (cell_dofs.begin(), cell_dofs.end(),
false);
1443 std::fill (cell_dofs_interface.begin(), cell_dofs_interface.end(),
false);
1445 for (
unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
1447 const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
1448 if (!face->at_boundary())
1452 neighbor = cell->neighbor(face_nr);
1454 if ((neighbor->level() < cell->level()))
1456 for (
unsigned int j=0; j<dofs_per_face; ++j)
1461 for (
unsigned int j=0; j<dofs_per_face; ++j)
1468 for (
unsigned int j=0; j<dofs_per_face; ++j)
1473 const unsigned int level = cell->level();
1474 cell->get_mg_dof_indices (local_dof_indices);
1476 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1477 if (cell_dofs[i] && !cell_dofs_interface[i])
1478 non_interface_dofs[level].insert(local_dof_indices[i]);
1483 template <
int dim,
int spacedim>
1486 std::vector<IndexSet> &interface_dofs)
1489 ExcDimensionMismatch (interface_dofs.size(),
1492 std::vector<std::vector<types::global_dof_index> >
1493 tmp_interface_dofs(interface_dofs.size());
1497 const unsigned int dofs_per_cell = fe.dofs_per_cell;
1498 const unsigned int dofs_per_face = fe.dofs_per_face;
1500 std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
1502 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1505 endc = mg_dof_handler.
end();
1507 for (; cell!=endc; ++cell)
1515 bool has_coarser_neighbor =
false;
1517 std::fill (cell_dofs.begin(), cell_dofs.end(),
false);
1519 for (
unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
1521 const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
1522 if (!face->at_boundary())
1526 neighbor = cell->neighbor(face_nr);
1535 if (neighbor->level() < cell->level())
1537 for (
unsigned int j=0; j<dofs_per_face; ++j)
1538 cell_dofs[fe.face_to_cell_index(j,face_nr)] =
true;
1540 has_coarser_neighbor =
true;
1545 if (has_coarser_neighbor ==
false)
1548 const unsigned int level = cell->level();
1549 cell->get_mg_dof_indices (local_dof_indices);
1551 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1554 tmp_interface_dofs[level].push_back(local_dof_indices[i]);
1558 for (
unsigned int l=0; l<mg_dof_handler.
get_triangulation().n_global_levels(); ++l)
1560 interface_dofs[l].clear();
1561 std::sort(tmp_interface_dofs[l].begin(), tmp_interface_dofs[l].end());
1562 interface_dofs[l].add_indices(tmp_interface_dofs[l].begin(),
1563 std::unique(tmp_interface_dofs[l].begin(),
1564 tmp_interface_dofs[l].end()));
1565 interface_dofs[l].compress();
1573 #include "mg_tools.inst" 1575 DEAL_II_NAMESPACE_CLOSE
const unsigned int first_hex_index
static const unsigned int invalid_unsigned_int
#define AssertDimension(dim1, dim2)
const types::subdomain_id invalid_subdomain_id
cell_iterator begin(const unsigned int level=0) const
void load_user_flags(std::istream &in)
::ExceptionBase & ExcMessage(std::string arg1)
cell_iterator end() const
ActiveSelector::active_cell_iterator active_cell_iterator
const FiniteElement< dim, spacedim > & get_fe() const
const unsigned int dofs_per_line
unsigned int n_blocks() const
active_cell_iterator begin_active(const unsigned int level=0) const
ActiveSelector::cell_iterator cell_iterator
const unsigned int first_quad_index
unsigned int global_dof_index
#define Assert(cond, exc)
unsigned int element_multiplicity(const unsigned int index) const
bool is_primitive(const unsigned int i) const
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
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
std::map< types::boundary_id, const Function< dim, Number > * > type
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
const unsigned int dofs_per_cell
types::global_dof_index first_block_of_base(const unsigned int b) const
const types::subdomain_id artificial_subdomain_id
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) 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 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
const unsigned int first_line_index
void save_user_flags(std::ostream &out) const
const Triangulation< dim, spacedim > & get_triangulation() const
const unsigned int dofs_per_vertex
unsigned char boundary_id
unsigned int n_base_elements() const
Task< RT > new_task(const std_cxx11::function< RT()> &function)
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const