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/multigrid/mg_constrained_dofs.h> 32 #include <deal.II/base/mg_level_object.h> 33 #include <deal.II/dofs/dof_handler.h> 34 #include <deal.II/dofs/dof_tools.h> 35 #include <deal.II/fe/fe.h> 36 #include <deal.II/fe/component_mask.h> 37 #include <deal.II/numerics/matrix_tools.h> 43 DEAL_II_NAMESPACE_OPEN
56 std::vector<unsigned int> &,
69 std::vector<unsigned int> &,
83 std::vector<unsigned int> &,
95 std::vector<unsigned int> &,
105 template <
int dim,
int spacedim>
109 const unsigned int level,
110 std::vector<unsigned int> &row_lengths,
118 std::fill(row_lengths.begin(), row_lengths.end(), 0);
121 std::vector<bool> old_flags;
133 std::vector<types::global_dof_index> cell_indices;
134 std::vector<types::global_dof_index> neighbor_indices;
143 for (cell = dofs.
begin(level); cell != end; ++cell)
147 cell->get_mg_dof_indices(cell_indices);
173 row_lengths[cell_indices[i++]] += increment;
188 row_lengths[cell_indices[i++]] += increment;
195 row_lengths[cell_indices[i++]] += increment;
199 row_lengths[cell_indices[i++]] += increment;
212 for (
unsigned int iface=0; iface<GeometryInfo<dim>::faces_per_cell; ++iface)
214 bool level_boundary = cell->at_boundary(iface);
218 neighbor = cell->neighbor(iface);
219 if (static_cast<unsigned int>(neighbor->level()) != level)
220 level_boundary =
true;
225 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
244 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
245 row_lengths[cell_indices[local_dof]] += dof_increment;
250 if (face->user_flag_set())
252 face->set_user_flag();
266 neighbor->get_mg_dof_indices(neighbor_indices);
267 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
269 for (
unsigned int local_dof=0; local_dof<nfe.
dofs_per_cell; ++local_dof)
270 row_lengths[neighbor_indices[local_dof]] += fe.
dofs_per_face;
278 template <
int dim,
int spacedim>
282 const unsigned int level,
283 std::vector<unsigned int> &row_lengths,
292 std::fill(row_lengths.begin(), row_lengths.end(), 0);
295 std::vector<bool> old_flags;
307 std::vector<types::global_dof_index> cell_indices;
308 std::vector<types::global_dof_index> neighbor_indices;
314 std::vector<Table<2, DoFTools::Coupling> > couple_cell;
315 std::vector<Table<2, DoFTools::Coupling> > couple_face;
329 const unsigned int fe_index = cell->active_fe_index();
341 cell->get_mg_dof_indices(cell_indices);
364 unsigned int increment;
374 row_lengths[cell_indices[i]] += increment;
400 row_lengths[cell_indices[i]] += increment;
418 row_lengths[cell_indices[i]] += increment;
434 row_lengths[cell_indices[i]] += increment;
450 for (
unsigned int iface=0; iface<GeometryInfo<dim>::faces_per_cell; ++iface)
452 bool level_boundary = cell->at_boundary(iface);
456 neighbor = cell->neighbor(iface);
457 if (static_cast<unsigned int>(neighbor->level()) != level)
458 level_boundary =
true;
463 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
481 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
487 row_lengths[cell_indices[local_dof]] += dof_increment;
493 if (face->user_flag_set())
495 face->set_user_flag();
517 neighbor->get_mg_dof_indices(neighbor_indices);
520 for (
unsigned int local_dof=0; local_dof<fe.
dofs_per_cell; ++local_dof)
523 row_lengths[cell_indices[local_dof]]
527 for (
unsigned int local_dof=0; local_dof<nfe.
dofs_per_cell; ++local_dof)
530 row_lengths[neighbor_indices[local_dof]]
539 template <
typename DoFHandlerType,
typename SparsityPatternType>
541 SparsityPatternType &sparsity,
542 const unsigned int level)
547 Assert (sparsity.n_rows() == n_dofs,
549 Assert (sparsity.n_cols() == n_dofs,
552 const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
553 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
554 typename DoFHandlerType::cell_iterator cell = dof.begin(level),
555 endc = dof.end(level);
556 for (; cell!=endc; ++cell)
558 || cell->level_subdomain_id()==dof.get_triangulation().locally_owned_subdomain())
560 cell->get_mg_dof_indices (dofs_on_this_cell);
562 for (
unsigned int i=0; i<dofs_per_cell; ++i)
563 for (
unsigned int j=0; j<dofs_per_cell; ++j)
564 sparsity.add (dofs_on_this_cell[i],
565 dofs_on_this_cell[j]);
571 template <
int dim,
typename SparsityPatternType,
int spacedim>
574 SparsityPatternType &sparsity,
575 const unsigned int level)
580 Assert (sparsity.n_rows() == n_dofs,
582 Assert (sparsity.n_cols() == n_dofs,
585 const unsigned int dofs_per_cell = dof.
get_fe().dofs_per_cell;
586 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
587 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
589 endc = dof.
end(level);
590 for (; cell!=endc; ++cell)
592 if (!cell->is_locally_owned_on_level())
continue;
594 cell->get_mg_dof_indices (dofs_on_this_cell);
596 for (
unsigned int i=0; i<dofs_per_cell; ++i)
597 for (
unsigned int j=0; j<dofs_per_cell; ++j)
598 sparsity.add (dofs_on_this_cell[i],
599 dofs_on_this_cell[j]);
602 for (
unsigned int face = 0;
603 face < GeometryInfo<dim>::faces_per_cell;
606 bool use_face =
false;
607 if ((! cell->at_boundary(face)) &&
608 (static_cast<unsigned int>(cell->neighbor_level(face)) == level))
610 else if (cell->has_periodic_neighbor(face) &&
611 (
static_cast<unsigned int>(cell->periodic_neighbor_level(face)) == level))
617 neighbor = cell->neighbor_or_periodic_neighbor(face);
618 neighbor->get_mg_dof_indices (dofs_on_other_cell);
622 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_this_cell[i],
627 dofs_on_other_cell[j]);
630 if (neighbor->is_locally_owned_on_level() ==
false)
631 for (
unsigned int i=0; i<dofs_per_cell; ++i)
632 for (
unsigned int j=0; j<dofs_per_cell; ++j)
634 sparsity.add (dofs_on_other_cell[i],
635 dofs_on_other_cell[j]);
636 sparsity.add (dofs_on_other_cell[i],
637 dofs_on_this_cell[j]);
646 template <
int dim,
typename SparsityPatternType,
int spacedim>
649 SparsityPatternType &sparsity,
650 const unsigned int level)
662 Assert (sparsity.n_rows() == coarse_dofs,
664 Assert (sparsity.n_cols() == fine_dofs,
667 const unsigned int dofs_per_cell = dof.
get_fe().dofs_per_cell;
668 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
669 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
671 endc = dof.
end(level);
672 for (; cell!=endc; ++cell)
674 if (!cell->is_locally_owned_on_level())
continue;
676 cell->get_mg_dof_indices (dofs_on_this_cell);
678 for (
unsigned int face = 0;
679 face < GeometryInfo<dim>::faces_per_cell;
683 bool use_face =
false;
684 if ((! cell->at_boundary(face)) &&
685 (static_cast<unsigned int>(cell->neighbor_level(face)) != level))
687 else if (cell->has_periodic_neighbor(face) &&
688 (
static_cast<unsigned int>(cell->periodic_neighbor_level(face)) != level))
694 neighbor = cell->neighbor_or_periodic_neighbor(face);
695 neighbor->get_mg_dof_indices (dofs_on_other_cell);
697 for (
unsigned int i=0; i<dofs_per_cell; ++i)
699 for (
unsigned int j=0; j<dofs_per_cell; ++j)
701 sparsity.add (dofs_on_other_cell[i],
702 dofs_on_this_cell[j]);
703 sparsity.add (dofs_on_other_cell[j],
704 dofs_on_this_cell[i]);
714 template <
int dim,
typename SparsityPatternType,
int spacedim>
717 SparsityPatternType &sparsity,
718 const unsigned int level,
728 Assert (sparsity.n_rows() == n_dofs,
730 Assert (sparsity.n_cols() == n_dofs,
732 Assert (int_mask.n_rows() == n_comp,
734 Assert (int_mask.n_cols() == n_comp,
736 Assert (flux_mask.n_rows() == n_comp,
738 Assert (flux_mask.n_cols() == n_comp,
742 std::vector<types::global_dof_index> dofs_on_this_cell(total_dofs);
743 std::vector<types::global_dof_index> dofs_on_other_cell(total_dofs);
747 endc = dof.
end(level);
753 for (
unsigned int i=0; i<total_dofs; ++i)
754 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
765 std::vector<bool> user_flags;
769 for (; cell!=endc; ++cell)
771 if (!cell->is_locally_owned_on_level())
continue;
773 cell->get_mg_dof_indices (dofs_on_this_cell);
775 for (
unsigned int i=0; i<total_dofs; ++i)
776 for (
unsigned int j=0; j<total_dofs; ++j)
778 sparsity.add (dofs_on_this_cell[i],
779 dofs_on_this_cell[j]);
782 for (
unsigned int face = 0;
783 face < GeometryInfo<dim>::faces_per_cell;
787 if (cell_face->user_flag_set ())
790 if (cell->at_boundary (face) && !cell->has_periodic_neighbor(face))
792 for (
unsigned int i=0; i<total_dofs; ++i)
794 const bool i_non_zero_i = support_on_face (i, face);
795 for (
unsigned int j=0; j<total_dofs; ++j)
797 const bool j_non_zero_i = support_on_face (j, face);
800 sparsity.add (dofs_on_this_cell[i],
801 dofs_on_this_cell[j]);
803 && i_non_zero_i && j_non_zero_i)
804 sparsity.add (dofs_on_this_cell[i],
805 dofs_on_this_cell[j]);
812 neighbor = cell->neighbor_or_periodic_neighbor(face);
814 if (neighbor->level() < cell->level())
817 unsigned int neighbor_face = cell->has_periodic_neighbor(face)?
818 cell->periodic_neighbor_of_periodic_neighbor(face):
819 cell->neighbor_of_neighbor(face);
821 neighbor->get_mg_dof_indices (dofs_on_other_cell);
822 for (
unsigned int i=0; i<total_dofs; ++i)
824 const bool i_non_zero_i = support_on_face (i, face);
825 const bool i_non_zero_e = support_on_face (i, neighbor_face);
826 for (
unsigned int j=0; j<total_dofs; ++j)
828 const bool j_non_zero_i = support_on_face (j, face);
829 const bool j_non_zero_e = support_on_face (j, neighbor_face);
832 sparsity.add (dofs_on_this_cell[i],
833 dofs_on_other_cell[j]);
834 sparsity.add (dofs_on_other_cell[i],
835 dofs_on_this_cell[j]);
836 sparsity.add (dofs_on_this_cell[i],
837 dofs_on_this_cell[j]);
838 sparsity.add (dofs_on_other_cell[i],
839 dofs_on_other_cell[j]);
843 if (i_non_zero_i && j_non_zero_e)
844 sparsity.add (dofs_on_this_cell[i],
845 dofs_on_other_cell[j]);
846 if (i_non_zero_e && j_non_zero_i)
847 sparsity.add (dofs_on_other_cell[i],
848 dofs_on_this_cell[j]);
849 if (i_non_zero_i && j_non_zero_i)
850 sparsity.add (dofs_on_this_cell[i],
851 dofs_on_this_cell[j]);
852 if (i_non_zero_e && j_non_zero_e)
853 sparsity.add (dofs_on_other_cell[i],
854 dofs_on_other_cell[j]);
859 sparsity.add (dofs_on_this_cell[j],
860 dofs_on_other_cell[i]);
861 sparsity.add (dofs_on_other_cell[j],
862 dofs_on_this_cell[i]);
863 sparsity.add (dofs_on_this_cell[j],
864 dofs_on_this_cell[i]);
865 sparsity.add (dofs_on_other_cell[j],
866 dofs_on_other_cell[i]);
870 if (j_non_zero_i && i_non_zero_e)
871 sparsity.add (dofs_on_this_cell[j],
872 dofs_on_other_cell[i]);
873 if (j_non_zero_e && i_non_zero_i)
874 sparsity.add (dofs_on_other_cell[j],
875 dofs_on_this_cell[i]);
876 if (j_non_zero_i && i_non_zero_i)
877 sparsity.add (dofs_on_this_cell[j],
878 dofs_on_this_cell[i]);
879 if (j_non_zero_e && i_non_zero_e)
880 sparsity.add (dofs_on_other_cell[j],
881 dofs_on_other_cell[i]);
885 neighbor->face(neighbor_face)->set_user_flag ();
896 template <
int dim,
typename SparsityPatternType,
int spacedim>
899 SparsityPatternType &sparsity,
900 const unsigned int level,
917 Assert (sparsity.n_rows() == coarse_dofs,
919 Assert (sparsity.n_cols() == fine_dofs,
921 Assert (flux_mask.n_rows() == n_comp,
923 Assert (flux_mask.n_cols() == n_comp,
926 const unsigned int dofs_per_cell = dof.
get_fe().dofs_per_cell;
927 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
928 std::vector<types::global_dof_index> dofs_on_other_cell(dofs_per_cell);
932 endc = dof.
end(level);
937 for (
unsigned int i=0; i<dofs_per_cell; ++i)
938 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
941 for (; cell!=endc; ++cell)
943 if (!cell->is_locally_owned_on_level())
continue;
945 cell->get_mg_dof_indices (dofs_on_this_cell);
947 for (
unsigned int face = 0;
948 face < GeometryInfo<dim>::faces_per_cell;
952 bool use_face =
false;
953 if ((! cell->at_boundary(face)) &&
954 (static_cast<unsigned int>(cell->neighbor_level(face)) != level))
956 else if (cell->has_periodic_neighbor(face) &&
957 (
static_cast<unsigned int>(cell->periodic_neighbor_level(face)) != level))
963 neighbor = cell->neighbor_or_periodic_neighbor(face);
964 neighbor->get_mg_dof_indices (dofs_on_other_cell);
966 for (
unsigned int i=0; i<dofs_per_cell; ++i)
968 for (
unsigned int j=0; j<dofs_per_cell; ++j)
972 sparsity.add (dofs_on_other_cell[i],
973 dofs_on_this_cell[j]);
974 sparsity.add (dofs_on_other_cell[j],
975 dofs_on_this_cell[i]);
986 template <
typename DoFHandlerType,
typename SparsityPatternType>
990 SparsityPatternType &sparsity,
991 const unsigned int level)
996 Assert (sparsity.n_rows() == n_dofs,
998 Assert (sparsity.n_cols() == n_dofs,
1001 const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
1002 std::vector<types::global_dof_index> dofs_on_this_cell(dofs_per_cell);
1003 typename DoFHandlerType::cell_iterator cell = dof.begin(level),
1004 endc = dof.end(level);
1005 for (; cell!=endc; ++cell)
1006 if (cell->is_locally_owned_on_level())
1008 cell->get_mg_dof_indices (dofs_on_this_cell);
1009 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1010 for (
unsigned int j=0; j<dofs_per_cell; ++j)
1012 sparsity.add (dofs_on_this_cell[i],
1013 dofs_on_this_cell[j]);
1019 template <
int dim,
int spacedim>
1022 std::vector<std::vector<types::global_dof_index> > &result,
1024 std::vector<unsigned int> target_component)
1030 Assert (result.size() == nlevels,
1033 if (target_component.size() == 0)
1035 target_component.resize(n_components);
1036 for (
unsigned int i=0; i<n_components; ++i)
1037 target_component[i] = i;
1040 Assert(target_component.size() == n_components,
1043 for (
unsigned int l=0; l<nlevels; ++l)
1045 result[l].resize (n_components);
1046 std::fill (result[l].begin(),result[l].end(), 0U);
1052 if (n_components == 1)
1054 result[l][0] = dof_handler.
n_dofs(l);
1061 std::vector<std::vector<bool> >
1062 dofs_in_component (n_components,
1063 std::vector<bool>(dof_handler.
n_dofs(l),
1065 std::vector<ComponentMask> component_select (n_components);
1067 for (
unsigned int i=0; i<n_components; ++i)
1069 void (*fun_ptr) (
const unsigned int level,
1072 std::vector<bool> &)
1075 std::vector<bool> tmp(n_components,
false);
1081 component_select[i],
1082 dofs_in_component[i]);
1087 unsigned int component = 0;
1096 for (
unsigned int dd=0; dd<d; ++dd)
1099 result[l][target_component[component]]
1100 += std::count(dofs_in_component[component].begin(),
1101 dofs_in_component[component].end(),
1110 std::accumulate (result[l].begin(),
1122 template <
typename DoFHandlerType>
1125 (
const DoFHandlerType &dof_handler,
1126 std::vector<std::vector<types::global_dof_index> > &dofs_per_block,
1127 std::vector<unsigned int> target_block)
1130 const unsigned int n_blocks = fe.
n_blocks();
1131 const unsigned int n_levels = dof_handler.get_triangulation().n_global_levels();
1135 for (
unsigned int l=0; l<n_levels; ++l)
1136 std::fill (dofs_per_block[l].begin(), dofs_per_block[l].end(), 0U);
1140 if (target_block.size()==0)
1142 target_block.resize(n_blocks);
1143 for (
unsigned int i=0; i<n_blocks; ++i)
1144 target_block[i] = i;
1146 Assert(target_block.size()==n_blocks,
1149 const unsigned int max_block
1150 = *std::max_element (target_block.begin(),
1151 target_block.end());
1152 const unsigned int n_target_blocks = max_block + 1;
1153 (void)n_target_blocks;
1155 for (
unsigned int l=0; l<n_levels; ++l)
1164 for (
unsigned int l=0; l<n_levels; ++l)
1165 dofs_per_block[l][0] = dof_handler.n_dofs(l);
1171 for (
unsigned int l=0; l<n_levels; ++l)
1173 std::vector<std::vector<bool> >
1174 dofs_in_block (n_blocks, std::vector<bool>(dof_handler.n_dofs(l),
false));
1175 std::vector<BlockMask> block_select (n_blocks);
1177 for (
unsigned int i=0; i<n_blocks; ++i)
1179 void (*fun_ptr) (
const unsigned int level,
1180 const DoFHandlerType &,
1182 std::vector<bool> &)
1183 = &DoFTools::extract_level_dofs<DoFHandlerType>;
1185 std::vector<bool> tmp(n_blocks,
false);
1187 block_select[i] = tmp;
1190 l, dof_handler, block_select[i],
1196 for (
unsigned int block=0; block<fe.
n_blocks(); ++block)
1197 dofs_per_block[l][target_block[block]]
1198 += std::count(dofs_in_block[block].begin(),
1199 dofs_in_block[block].end(),
1206 template <
int dim,
int spacedim>
1211 std::vector<std::set<types::global_dof_index> > &boundary_indices,
1218 std::set<types::boundary_id> boundary_ids;
1219 typename std::map<types::boundary_id, const Function<dim>* >::const_iterator it
1220 = function_map.begin();
1221 for (; it!=function_map.end(); ++it)
1222 boundary_ids.insert(it->first);
1224 std::vector<IndexSet> boundary_indexset;
1227 boundary_indices[i].insert(boundary_indexset[i].begin(),
1228 boundary_indexset[i].end());
1232 template <
int dim,
int spacedim>
1236 std::vector<IndexSet> &boundary_indices,
1243 std::set<types::boundary_id> boundary_ids;
1244 typename std::map<types::boundary_id, const Function<dim>* >::const_iterator it = function_map.begin();
1245 for (; it!=function_map.end(); ++it)
1246 boundary_ids.insert(it->first);
1253 template <
int dim,
int spacedim>
1256 const std::set<types::boundary_id> &boundary_ids,
1257 std::vector<IndexSet> &boundary_indices,
1263 if (boundary_ids.size() == 0)
1267 if (boundary_indices[i].size() == 0)
1271 const bool fe_is_system = (n_components != 1);
1273 std::vector<types::global_dof_index> local_dofs;
1275 std::fill (local_dofs.begin (),
1285 for (; cell!=endc; ++cell)
1291 const unsigned int level = cell->level();
1294 for (
unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
1296 if (cell->at_boundary(face_no) ==
true)
1299 face = cell->face(face_no);
1302 if (boundary_ids.find(bi) != boundary_ids.end())
1304 face->get_mg_dof_indices(level, local_dofs);
1305 boundary_indices[level].add_indices(local_dofs.begin(), local_dofs.end());
1313 ExcMessage(
"It's probably worthwhile to select at least one component."));
1318 for (; cell!=endc; ++cell)
1321 for (
unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
1324 if (cell->at_boundary(face_no) ==
false)
1328 const unsigned int level = cell->level();
1332 if (boundary_ids.find(boundary_component) != boundary_ids.end())
1336 for (
unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
1339 = cell->get_fe().get_nonzero_components (i);
1343 bool selected =
false;
1344 for (
unsigned int c=0; c<n_components; ++c)
1345 if (nonzero_component_array[c] ==
true 1346 && component_mask[c]==
true)
1352 for (
unsigned int c=0; c<n_components; ++c)
1353 Assert (nonzero_component_array[c] ==
false || component_mask[c] ==
true,
1354 ExcMessage (
"You are using a non-primitive FiniteElement " 1355 "and try to constrain just some of its components!"));
1360 face->get_mg_dof_indices (level, local_dofs);
1363 for (
unsigned int i=0; i<local_dofs.size(); ++i)
1374 = cell->get_fe().get_nonzero_components (i);
1375 for (
unsigned int c=0; c<n_components; ++c)
1376 if (nonzero_component_array[c] ==
true)
1383 if (component_mask[component] ==
true)
1384 boundary_indices[level].add_index(local_dofs[i]);
1388 boundary_indices[level].add_indices(local_dofs.begin(), local_dofs.end());
1395 template <
int dim,
int spacedim>
1398 std::vector<std::set<types::global_dof_index> > &non_interface_dofs)
1409 std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
1410 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1411 std::vector<bool> cell_dofs_interface(dofs_per_cell,
false);
1414 endc = mg_dof_handler.
end();
1417 for (; cell!=endc; ++cell)
1420 && cell->level_subdomain_id()!=mg_dof_handler.
get_triangulation().locally_owned_subdomain())
1423 std::fill (cell_dofs.begin(), cell_dofs.end(),
false);
1424 std::fill (cell_dofs_interface.begin(), cell_dofs_interface.end(),
false);
1426 for (
unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
1429 if (!face->at_boundary())
1433 neighbor = cell->neighbor(face_nr);
1435 if ((neighbor->level() < cell->level()))
1437 for (
unsigned int j=0; j<dofs_per_face; ++j)
1442 for (
unsigned int j=0; j<dofs_per_face; ++j)
1449 for (
unsigned int j=0; j<dofs_per_face; ++j)
1454 const unsigned int level = cell->level();
1455 cell->get_mg_dof_indices (local_dof_indices);
1457 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1458 if (cell_dofs[i] && !cell_dofs_interface[i])
1459 non_interface_dofs[level].insert(local_dof_indices[i]);
1464 template <
int dim,
int spacedim>
1467 std::vector<IndexSet> &interface_dofs)
1473 std::vector<std::vector<types::global_dof_index> >
1474 tmp_interface_dofs(interface_dofs.size());
1478 const unsigned int dofs_per_cell = fe.dofs_per_cell;
1479 const unsigned int dofs_per_face = fe.dofs_per_face;
1481 std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
1483 std::vector<bool> cell_dofs(dofs_per_cell,
false);
1486 endc = mg_dof_handler.
end();
1488 for (; cell!=endc; ++cell)
1496 bool has_coarser_neighbor =
false;
1498 std::fill (cell_dofs.begin(), cell_dofs.end(),
false);
1500 for (
unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
1503 if (!face->at_boundary())
1507 neighbor = cell->neighbor(face_nr);
1516 if (neighbor->level() < cell->level())
1518 for (
unsigned int j=0; j<dofs_per_face; ++j)
1519 cell_dofs[fe.face_to_cell_index(j,face_nr)] =
true;
1521 has_coarser_neighbor =
true;
1526 if (has_coarser_neighbor ==
false)
1529 const unsigned int level = cell->level();
1530 cell->get_mg_dof_indices (local_dof_indices);
1532 for (
unsigned int i=0; i<dofs_per_cell; ++i)
1535 tmp_interface_dofs[level].push_back(local_dof_indices[i]);
1539 for (
unsigned int l=0; l<mg_dof_handler.
get_triangulation().n_global_levels(); ++l)
1541 interface_dofs[l].clear();
1542 std::sort(tmp_interface_dofs[l].begin(), tmp_interface_dofs[l].end());
1543 interface_dofs[l].add_indices(tmp_interface_dofs[l].begin(),
1544 std::unique(tmp_interface_dofs[l].begin(),
1545 tmp_interface_dofs[l].end()));
1546 interface_dofs[l].compress();
1553 template <
int dim,
int spacedim>
1565 for (; cell!=endc; ++cell)
1566 if (cell->is_locally_owned())
1568 min_level = cell->level();
1572 unsigned int global_min = min_level;
1588 #include "mg_tools.inst" 1590 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
Task< RT > new_task(const std::function< RT()> &function)
void load_user_flags(std::istream &in)
cell_iterator end() const
#define AssertIndexRange(index, range)
ActiveSelector::active_cell_iterator active_cell_iterator
active_cell_iterator begin_active(const unsigned int level=0) const
bool is_primitive() const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
unsigned int n_blocks() const
bool is_interface_matrix_entry(const unsigned int level, const types::global_dof_index i, const types::global_dof_index j) const
ActiveSelector::face_iterator face_iterator
cell_iterator end() const
active_cell_iterator begin_active(const unsigned int level=0) const
static ::ExceptionBase & ExcMessage(std::string arg1)
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
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
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
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
virtual unsigned int n_global_levels() const
T min(const T &t, const MPI_Comm &mpi_communicator)
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
static ::ExceptionBase & ExcNotImplemented()
const Triangulation< dim, spacedim > & get_triangulation() const
const types::global_dof_index invalid_dof_index
unsigned int n_base_elements() const
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const
static ::ExceptionBase & ExcInternalError()