54 template <
int dim,
int spacedim,
typename number>
75 &dof.get_triangulation()))
80 "For distributed Triangulation objects and associated "
81 "DoFHandler objects, asking for any subdomain other than the "
82 "locally owned one does not make sense."));
91 for (
const auto &cell : dof.active_cell_iterators())
93 (subdomain_id == cell->subdomain_id())) &&
94 cell->is_locally_owned())
96 const unsigned int dofs_per_cell = cell->get_fe().n_dofs_per_cell();
111 template <
int dim,
int spacedim,
typename number>
129 dof.get_fe(0).n_components()));
132 dof.get_fe(0).n_components()));
139 &dof.get_triangulation()))
144 "For distributed Triangulation objects and associated "
145 "DoFHandler objects, asking for any subdomain other than the "
146 "locally owned one does not make sense."));
150 dof.get_fe_collection();
152 const std::vector<Table<2, Coupling>>
dof_mask
158 for (
unsigned int f = 0; f < fe_collection.
size(); ++f)
162 fe_collection[f].n_dofs_per_cell()));
164 for (
unsigned int i = 0; i < fe_collection[f].n_dofs_per_cell(); ++i)
165 for (
unsigned int j = 0;
j < fe_collection[f].n_dofs_per_cell(); ++
j)
176 for (
const auto &cell : dof.active_cell_iterators())
178 (subdomain_id == cell->subdomain_id())) &&
179 cell->is_locally_owned())
182 const unsigned int dofs_per_cell =
183 fe_collection[fe_index].n_dofs_per_cell();
201 template <
int dim,
int spacedim>
223 &
dof_row.get_triangulation()) !=
nullptr ||
225 &
dof_col.get_triangulation()) !=
nullptr)
228 ExcMessage(
"This function can only be used with with parallel "
229 "Triangulations when the Triangulations are equal."));
235 std::list<std::pair<cell_iterator, cell_iterator>> cell_list =
238#ifdef DEAL_II_WITH_MPI
243 &
dof_row.get_triangulation()) !=
nullptr ||
245 &
dof_col.get_triangulation()) !=
nullptr)
248 dof_row.get_triangulation().locally_owned_subdomain();
250 dof_col.get_triangulation().locally_owned_subdomain(),
256 [=](
const std::pair<cell_iterator, cell_iterator> &
pair) {
257 return pair.first->subdomain_id() != this_subdomain_id ||
258 pair.second->subdomain_id() != this_subdomain_id;
272 cell_row->get_fe().n_dofs_per_cell();
274 cell_col->get_fe().n_dofs_per_cell();
290 GridTools::get_active_child_cells<DoFHandler<dim, spacedim>>(
299 cell_col->get_fe().n_dofs_per_cell();
316 GridTools::get_active_child_cells<DoFHandler<dim, spacedim>>(
323 cell_row->get_fe().n_dofs_per_cell();
342 template <
int dim,
int spacedim>
353 std::map<types::boundary_id, const Function<spacedim, double> *>
355 boundary_ids[0] =
nullptr;
356 boundary_ids[1] =
nullptr;
371 if (sparsity.
n_rows() != 0)
383 std::vector<types::global_dof_index> cols;
390 for (
const auto &cell : dof.active_cell_iterators())
391 for (
const unsigned int f : cell->face_indices())
392 if (cell->at_boundary(f))
394 const unsigned int dofs_per_face =
395 cell->get_fe().n_dofs_per_face(f);
398 cell->active_fe_index());
407 std::sort(cols.begin(), cols.end());
417 template <
int dim,
int spacedim,
typename number>
429 for (
unsigned int direction = 0; direction < 2; ++direction)
432 if (boundary_ids.find(direction) == boundary_ids.end())
439 while (!cell->at_boundary(direction))
440 cell = cell->neighbor(direction);
441 while (!cell->is_active())
442 cell = cell->child(direction);
444 const unsigned int dofs_per_vertex =
445 cell->
get_fe().n_dofs_per_vertex();
450 for (
unsigned int i = 0; i < dofs_per_vertex; ++i)
470 Assert(sparsity.
n_rows() == dof.n_boundary_dofs(boundary_ids),
472 dof.n_boundary_dofs(boundary_ids)));
473 Assert(sparsity.
n_cols() == dof.n_boundary_dofs(boundary_ids),
475 dof.n_boundary_dofs(boundary_ids)));
477 if (sparsity.
n_rows() != 0)
489 std::vector<types::global_dof_index> cols;
491 for (
const auto &cell : dof.active_cell_iterators())
492 for (
const unsigned int f : cell->face_indices())
493 if (boundary_ids.find(cell->face(f)->boundary_id()) !=
496 const unsigned int dofs_per_face =
497 cell->get_fe().n_dofs_per_face(f);
500 cell->active_fe_index());
508 std::sort(cols.begin(), cols.end());
518 template <
int dim,
int spacedim,
typename number>
540 &dof.get_triangulation()))
545 "For distributed Triangulation objects and associated "
546 "DoFHandler objects, asking for any subdomain other than the "
547 "locally owned one does not make sense."));
563 for (
const auto &cell : dof.active_cell_iterators())
565 (subdomain_id == cell->subdomain_id())) &&
566 cell->is_locally_owned())
569 cell->get_fe().n_dofs_per_cell();
580 for (
const unsigned int face : cell->face_indices())
584 const bool periodic_neighbor = cell->has_periodic_neighbor(face);
585 if (!cell->at_boundary(face) || periodic_neighbor)
588 neighbor = cell->neighbor_or_periodic_neighbor(face);
595 while (neighbor->has_children())
596 neighbor = neighbor->child(face == 0 ? 1 : 0);
598 if (neighbor->has_children())
600 for (
unsigned int sub_nr = 0;
607 cell->periodic_neighbor_child_on_subface(
609 cell->neighbor_child_on_subface(face,
sub_nr);
616 constraints.add_entries_local_to_global(
621 constraints.add_entries_local_to_global(
630 cell->subdomain_id())
631 constraints.add_entries_local_to_global(
641 if ((!periodic_neighbor &&
642 cell->neighbor_is_coarser(face)) ||
643 (periodic_neighbor &&
644 cell->periodic_neighbor_is_coarser(face)))
645 if (neighbor->subdomain_id() == cell->subdomain_id())
649 neighbor->
get_fe().n_dofs_per_cell();
654 constraints.add_entries_local_to_global(
664 if (!cell->neighbor_or_periodic_neighbor(face)
666 (neighbor->subdomain_id() != cell->subdomain_id()))
668 constraints.add_entries_local_to_global(
673 if (neighbor->subdomain_id() != cell->subdomain_id())
674 constraints.add_entries_local_to_global(
687 template <
int dim,
int spacedim>
696 template <
int dim,
int spacedim>
709 const unsigned int n_dofs = fe.n_dofs_per_cell();
713 for (
unsigned int i = 0; i < n_dofs; ++i)
715 const unsigned int ii =
716 (fe.is_primitive(i) ?
717 fe.system_to_component_index(i).first :
718 fe.get_nonzero_components(i).first_selected_component());
721 for (
unsigned int j = 0;
j < n_dofs; ++
j)
723 const unsigned int jj =
724 (fe.is_primitive(
j) ?
725 fe.system_to_component_index(
j).first :
726 fe.get_nonzero_components(
j).first_selected_component());
737 template <
int dim,
int spacedim>
738 std::vector<Table<2, Coupling>>
743 std::vector<Table<2, Coupling>> return_value(fe.
size());
744 for (
unsigned int i = 0; i < fe.
size(); ++i)
759 template <
int dim,
int spacedim,
typename number>
773 std::vector<types::global_dof_index> rows;
778 if (dof.has_hp_capabilities() ==
false)
783 fe.n_dofs_per_cell());
785 fe.n_dofs_per_cell());
795 for (
unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
796 for (
const unsigned int f :
GeometryInfo<dim>::face_indices())
802 fe.n_dofs_per_cell());
804 for (
unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
805 for (
unsigned int j = 0;
j < fe.n_dofs_per_cell(); ++
j)
809 for (
const auto &cell : dof.active_cell_iterators())
810 if (((subdomain_id ==
numbers::invalid_subdomain_id) ||
811 (subdomain_id == cell->subdomain_id())) &&
812 cell->is_locally_owned())
821 for (
const unsigned int face_n : cell->face_indices())
826 const bool periodic_neighbor =
827 cell->has_periodic_neighbor(
face_n);
829 if (cell->at_boundary(
face_n) && (!periodic_neighbor))
831 for (
unsigned int i = 0; i < fe.n_dofs_per_cell();
836 for (
unsigned int j = 0;
j < fe.n_dofs_per_cell();
856 spacedim>::level_cell_iterator
858 cell->neighbor_or_periodic_neighbor(
face_n);
863 if (neighbor->level() == cell->level() &&
864 neighbor->index() > cell->index() &&
865 neighbor->is_active() &&
866 neighbor->is_locally_owned())
880 if (neighbor->level() != cell->level() &&
881 ((!periodic_neighbor &&
882 !cell->neighbor_is_coarser(
face_n)) ||
883 (periodic_neighbor &&
884 !cell->periodic_neighbor_is_coarser(
face_n))) &&
885 neighbor->is_locally_owned())
894 cell->periodic_neighbor_face_no(
face_n) :
895 cell->neighbor_face_no(
face_n);
905 while (neighbor->has_children())
906 neighbor = neighbor->child(
face_n == 0 ? 1 : 0);
908 if (neighbor->has_children())
910 for (
unsigned int sub_nr = 0;
918 ->periodic_neighbor_child_on_subface(
920 cell->neighbor_child_on_subface(
face_n,
925 for (
unsigned int i = 0;
926 i < fe.n_dofs_per_cell();
933 for (
unsigned int j = 0;
934 j < fe.n_dofs_per_cell();
1023 for (
unsigned int i = 0; i < fe.n_dofs_per_cell();
1030 for (
unsigned int j = 0;
1031 j < fe.n_dofs_per_cell();
1126 const ::hp::FECollection<dim, spacedim> &fe =
1127 dof.get_fe_collection();
1130 dof.get_fe_collection().max_dofs_per_cell());
1132 dof.get_fe_collection().max_dofs_per_cell());
1134 const unsigned int n_components = fe.n_components();
1144 for (
unsigned int c1 = 0;
c1 < n_components; ++
c1)
1145 for (
unsigned int c2 = 0;
c2 < n_components; ++
c2)
1155 for (
unsigned int f = 0; f < fe.size(); ++f)
1159 fe[f].n_dofs_per_cell()));
1161 for (
unsigned int i = 0; i < fe[f].n_dofs_per_cell(); ++i)
1162 for (
unsigned int j = 0;
j < fe[f].n_dofs_per_cell(); ++
j)
1168 for (
const auto &cell : dof.active_cell_iterators())
1171 cell->is_locally_owned())
1179 constraints.add_entries_local_to_global(
1186 for (
const unsigned int face : cell->face_indices())
1191 const bool periodic_neighbor =
1192 cell->has_periodic_neighbor(face);
1194 if ((!cell->at_boundary(face)) || periodic_neighbor)
1197 spacedim>::level_cell_iterator
1199 cell->neighbor_or_periodic_neighbor(face);
1205 if (neighbor->level() == cell->level() &&
1206 neighbor->index() > cell->index() &&
1207 neighbor->is_active() &&
1208 neighbor->is_locally_owned())
1222 if (neighbor->level() != cell->level() &&
1223 ((!periodic_neighbor &&
1224 !cell->neighbor_is_coarser(face)) ||
1225 (periodic_neighbor &&
1226 !cell->periodic_neighbor_is_coarser(face))) &&
1227 neighbor->is_locally_owned())
1241 while (neighbor->has_children())
1242 neighbor = neighbor->child(face == 0 ? 1 : 0);
1244 if (neighbor->has_children())
1246 for (
unsigned int sub_nr = 0;
1254 ->periodic_neighbor_child_on_subface(
1256 cell->neighbor_child_on_subface(face,
1263 for (
unsigned int i = 0;
1264 i < cell->get_fe().n_dofs_per_cell();
1267 const unsigned int ii =
1268 (cell->get_fe().is_primitive(i) ?
1270 .system_to_component_index(i)
1273 .get_nonzero_components(i)
1274 .first_selected_component());
1279 for (
unsigned int j = 0;
1284 const unsigned int jj =
1288 .system_to_component_index(
j)
1291 .get_nonzero_components(
j)
1292 .first_selected_component());
1320 neighbor->get_fe().n_dofs_per_cell());
1322 for (
unsigned int i = 0;
1323 i < cell->get_fe().n_dofs_per_cell();
1326 const unsigned int ii =
1327 (cell->get_fe().is_primitive(i) ?
1329 .system_to_component_index(i)
1332 .get_nonzero_components(i)
1333 .first_selected_component());
1338 for (
unsigned int j = 0;
1339 j < neighbor->get_fe().n_dofs_per_cell();
1342 const unsigned int jj =
1343 (neighbor->get_fe().is_primitive(
j) ?
1345 .system_to_component_index(
j)
1348 .get_nonzero_components(
j)
1349 .first_selected_component());
1386 template <
int dim,
int spacedim>
1405 internal::always_couple_on_faces<dim, spacedim>);
1410 template <
int dim,
int spacedim,
typename number>
1420 const std::function<
1428 const unsigned int n_comp = dof.get_fe(0).n_components();
1449 &dof.get_triangulation()))
1454 "For distributed Triangulation objects and associated "
1455 "DoFHandler objects, asking for any subdomain other than the "
1456 "locally owned one does not make sense."));
1462 "The function which specifies if a flux coupling occurs over a given "
1465 internal::make_flux_sparsity_pattern(dof,
1480#include "dof_tools_sparsity.inst"
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
void reinit(value_type *starting_element, const std::size_t n_elements)
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
typename LevelSelector::cell_iterator level_cell_iterator
types::global_dof_index size_type
virtual void add_entries(const ArrayView< const std::pair< size_type, size_type > > &entries)
virtual void add_row_entries(const size_type &row, const ArrayView< const size_type > &columns, const bool indices_are_sorted=false)=0
unsigned int size() const
unsigned int max_dofs_per_cell() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::cell_iterator cell_iterator
typename ActiveSelector::face_iterator face_iterator
typename ActiveSelector::active_cell_iterator active_cell_iterator
void make_flux_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern)
void make_boundary_sparsity_pattern(const DoFHandler< dim, spacedim > &dof, const std::vector< types::global_dof_index > &dof_to_boundary_mapping, SparsityPatternBase &sparsity_pattern)
void make_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern, const AffineConstraints< number > &constraints=AffineConstraints< number >(), const bool keep_constrained_dofs=true, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id)
const types::boundary_id internal_face_boundary_id
const types::subdomain_id invalid_subdomain_id
const types::global_dof_index invalid_dof_index
unsigned int subdomain_id
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation