47#include <boost/geometry/algorithms/distance.hpp>
48#include <boost/geometry/index/detail/rtree/utilities/print.hpp>
49#include <boost/geometry/index/rtree.hpp>
50#include <boost/geometry/strategies/strategies.hpp>
54#ifdef DEAL_II_WITH_TRILINOS
55# include <EpetraExt_RowMatrixOut.h>
58#ifdef DEAL_II_WITH_CGAL
60# include <CGAL/Constrained_Delaunay_triangulation_2.h>
61# include <CGAL/Constrained_triangulation_plus_2.h>
62# include <CGAL/Exact_predicates_exact_constructions_kernel.h>
63# include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
64# include <CGAL/Polygon_2.h>
65# include <CGAL/Polygon_with_holes_2.h>
66# include <CGAL/Segment_Delaunay_graph_2.h>
67# include <CGAL/Segment_Delaunay_graph_traits_2.h>
68# include <CGAL/intersections.h>
69# include <CGAL/squared_distance_2.h>
70# include <CGAL/squared_distance_3.h>
84 get_index(
const std::vector<types::global_cell_index> &v,
87 return std::distance(v.begin(), std::find(v.begin(), v.end(), index));
96 template <
int dim,
int spacedim>
102 const std::vector<types::global_cell_index> locally_owned_cells)
117 if (cell->is_locally_owned())
119 const unsigned int index = cell->active_cell_index();
120 cell_connectivity.
add(
get_index(locally_owned_cells, index),
122 for (
auto f : cell->face_indices())
123 if ((cell->at_boundary(f) ==
false) &&
124 (cell->neighbor(f)->has_children() ==
false) &&
125 cell->neighbor(f)->is_locally_owned())
127 const unsigned int other_index =
128 cell->neighbor(f)->active_cell_index();
130 cell_connectivity.
add(
get_index(locally_owned_cells, index),
145 template <
typename Value,
150 struct Rtree_visitor :
public boost::geometry::index::detail::rtree::visitor<
152 typename Options::parameters_type,
155 typename Options::node_tag,
162 boost::geometry::dimension<Box>::value>::active_cell_iterator>> &boxes,
163 std::vector<std::vector<unsigned int>> &csr);
170 typename boost::geometry::index::detail::rtree::internal_node<
172 typename Options::parameters_type,
175 typename Options::node_tag>::type;
180 using Leaf =
typename boost::geometry::index::detail::rtree::leaf<
182 typename Options::parameters_type,
185 typename Options::node_tag>::type;
229 boost::geometry::dimension<Box>::value>::active_cell_iterator>>
232 std::vector<std::vector<unsigned int>> &
row_ptr;
237 template <
typename Value,
246 boost::geometry::dimension<Box>::value>::active_cell_iterator>>
248 std::vector<std::vector<unsigned int>> &csr)
260 template <
typename Value,
269 using elements_type =
270 typename boost::geometry::index::detail::rtree::elements_type<
272 const elements_type &elements =
273 boost::geometry::index::detail::rtree::elements(node);
277 size_t level_backup =
level;
280 for (
typename elements_type::const_iterator it = elements.begin();
281 it != elements.end();
284 boost::geometry::index::detail::rtree::apply_visitor(*
this,
288 level = level_backup;
299 size_t level_backup =
level;
302 for (
const auto &child : elements)
304 boost::geometry::index::detail::rtree::apply_visitor(*
this,
311 level = level_backup;
316 size_t level_backup =
level;
320 for (
const auto &child : elements)
322 boost::geometry::index::detail::rtree::apply_visitor(*
this,
325 level = level_backup;
332 template <
typename Value,
341 using elements_type =
342 typename boost::geometry::index::detail::rtree::elements_type<
344 const elements_type &elements =
345 boost::geometry::index::detail::rtree::elements(leaf);
348 for (
const auto &it : elements)
355 template <
typename Rtree>
357 std::vector<std::vector<unsigned int>>,
358 std::vector<std::vector<
typename Triangulation<boost::geometry::dimension<
359 typename Rtree::indexable_type>::value>::active_cell_iterator>>>
363 boost::geometry::index::detail::rtree::utilities::view<Rtree>;
366 std::vector<std::vector<unsigned int>> csrs;
367 std::vector<std::vector<
typename Triangulation<boost::geometry::dimension<
368 typename Rtree::indexable_type>::value>::active_cell_iterator>>
371 if (rtv.depth() == 0)
376 agglomerates.resize(1);
377 agglomerates[0].resize(1);
383 const unsigned int target_level =
387 typename RtreeView::options_type,
388 typename RtreeView::translator_type,
389 typename RtreeView::box_type,
390 typename RtreeView::allocators_type>
391 node_visitor(rtv.translator(), target_level, agglomerates, csrs);
392 rtv.apply_visitor(node_visitor);
396 return {csrs, agglomerates};
400 template <
int dim,
typename Number =
double>
403 const unsigned int face_index,
408#ifdef DEAL_II_WITH_CGAL
410 using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
411 std::vector<typename Kernel::FT> candidates;
412 candidates.reserve(polygon_boundary.size() - 1);
416 std::vector<unsigned int> face_indices(polygon_boundary.size());
417 std::iota(face_indices.begin(), face_indices.end(), 0);
418 face_indices.erase(face_indices.cbegin() +
421 if constexpr (dim == 2)
423 typename Kernel::Segment_2 face_segm(
424 {polygon_boundary[face_index]->vertex(0)[0],
425 polygon_boundary[face_index]->vertex(0)[1]},
426 {polygon_boundary[face_index]->vertex(1)[0],
427 polygon_boundary[face_index]->vertex(1)[1]});
431 const auto &midpoint = CGAL::midpoint(face_segm);
433 const typename Kernel::Vector_2 orthogonal_direction{-deal_normal[0],
435 const typename Kernel::Ray_2 ray(midpoint, orthogonal_direction);
436 for (
const auto f : face_indices)
438 typename Kernel::Segment_2 segm({polygon_boundary[f]->vertex(0)[0],
439 polygon_boundary[f]->vertex(0)[1]},
440 {polygon_boundary[f]->vertex(1)[0],
441 polygon_boundary[f]->vertex(
444 if (CGAL::do_intersect(ray, segm))
445 candidates.push_back(CGAL::squared_distance(midpoint, segm));
448 *std::min_element(candidates.cbegin(), candidates.cend())));
450 else if constexpr (dim == 3)
452 const typename Kernel::Point_3 ¢er{
453 polygon_boundary[face_index]->center()[0],
454 polygon_boundary[face_index]->center()[1],
455 polygon_boundary[face_index]->center()[2]};
457 const typename Kernel::Vector_3 orthogonal_direction{-deal_normal[0],
460 const typename Kernel::Ray_3 ray(center, orthogonal_direction);
462 for (
const auto f : face_indices)
465 typename Kernel::Triangle_3 first_triangle(
466 {polygon_boundary[f]->vertex(0)[0],
467 polygon_boundary[f]->vertex(0)[1],
468 polygon_boundary[f]->vertex(0)[2]},
469 {polygon_boundary[f]->vertex(1)[0],
470 polygon_boundary[f]->vertex(1)[1],
471 polygon_boundary[f]->vertex(1)[2]},
472 {polygon_boundary[f]->vertex(3)[0],
473 polygon_boundary[f]->vertex(3)[1],
474 polygon_boundary[f]->vertex(3)[2]});
475 typename Kernel::Triangle_3 second_triangle(
476 {polygon_boundary[f]->vertex(0)[0],
477 polygon_boundary[f]->vertex(0)[1],
478 polygon_boundary[f]->vertex(0)[2]},
479 {polygon_boundary[f]->vertex(3)[0],
480 polygon_boundary[f]->vertex(3)[1],
481 polygon_boundary[f]->vertex(3)[2]},
482 {polygon_boundary[f]->vertex(2)[0],
483 polygon_boundary[f]->vertex(2)[1],
484 polygon_boundary[f]->vertex(2)[2]});
488 if (CGAL::do_intersect(ray, first_triangle))
489 candidates.push_back(
490 CGAL::squared_distance(center, first_triangle));
491 if (CGAL::do_intersect(ray, second_triangle))
492 candidates.push_back(
493 CGAL::squared_distance(center, second_triangle));
497 *std::min_element(candidates.cbegin(), candidates.cend())));
501 Assert(
false, ExcImpossibleInDim(dim));
503 (void)polygon_boundary;
509 Assert(
false, ExcNeedsCGAL());
511 (void)polygon_boundary;
522 template <
int dim,
int spacedim = dim>
526 const std::vector<types::global_cell_index> &cell_idxs,
528 &cells_to_be_agglomerated)
530 Assert(cells_to_be_agglomerated.size() == 0,
532 "The vector of cells is supposed to be filled by this function."));
534 if (std::find(cell_idxs.begin(),
536 cell->active_cell_index()) != cell_idxs.end())
538 cells_to_be_agglomerated.push_back(cell);
554 template <
int dim,
int spacedim>
562 ExcMessage(
"Invalid number of partitions, you provided " +
563 std::to_string(n_partitions)));
565 auto parallel_triangulation =
569 (parallel_triangulation !=
nullptr),
571 "Only fully distributed triangulations are supported. If you are using"
572 "a parallel::distributed::triangulation, you must convert it to a fully"
573 "distributed as explained in the documentation."));
576 if (n_partitions == 1)
578 for (
const auto &cell : parallel_triangulation->active_cell_iterators())
579 if (cell->is_locally_owned())
580 cell->set_material_id(0);
585 std::vector<types::global_cell_index> locally_owned_cells;
587 if (cell->is_locally_owned())
588 locally_owned_cells.push_back(cell->active_cell_index());
593 locally_owned_cells);
596 sp_cell_connectivity.
copy_from(cell_connectivity);
602 std::vector<unsigned int> partition_indices(
603 parallel_triangulation->n_locally_owned_active_cells());
611 for (
const auto &cell : parallel_triangulation->active_cell_iterators())
612 if (cell->is_locally_owned())
613 cell->set_material_id(
615 cell->active_cell_index())]);
630 template <
int dim,
int spacedim>
634 const unsigned int n_partitions,
642 "The agglomerated grid must be empty upon calling this function."));
644 ExcMessage(
"Invalid number of partitions, you provided " +
645 std::to_string(n_partitions)));
647 auto parallel_triangulation =
651 (parallel_triangulation !=
nullptr),
653 "Only fully distributed triangulations are supported. If you are using"
654 "a parallel::distributed::triangulation, you must convert it to a"
655 "fully distributed as explained in the documentation."));
658 if (n_partitions == 1)
660 for (
const auto &cell : parallel_triangulation->active_cell_iterators())
661 if (cell->is_locally_owned())
667 std::vector<types::global_cell_index> locally_owned_cells;
669 if (cell->is_locally_owned())
670 locally_owned_cells.push_back(cell->active_cell_index());
675 locally_owned_cells);
678 sp_cell_connectivity.
copy_from(cell_connectivity);
684 std::vector<unsigned int> partition_indices(
685 parallel_triangulation->n_locally_owned_active_cells());
691 std::vector<std::vector<typename Triangulation<dim>::active_cell_iterator>>
692 cells_per_partion_id;
693 cells_per_partion_id.resize(n_partitions);
696 for (
const auto &cell : parallel_triangulation->active_cell_iterators())
697 if (cell->is_locally_owned())
699 locally_owned_cells, cell->active_cell_index())]]
703 for (
unsigned int i = 0; i < n_partitions; ++i)
711 tuple<std::vector<double>, std::vector<double>, std::vector<double>,
double>
714 static_assert(dim == 2);
715#ifdef DEAL_II_WITH_CGAL
716 using Kernel = CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt;
717 using Polygon_with_holes =
typename CGAL::Polygon_with_holes_2<Kernel>;
718 using Gt =
typename CGAL::Segment_Delaunay_graph_traits_2<Kernel>;
719 using SDG2 =
typename CGAL::Segment_Delaunay_graph_2<Gt>;
720 using CDT =
typename CGAL::Constrained_Delaunay_triangulation_2<Kernel>;
721 using CDTP =
typename CGAL::Constrained_triangulation_plus_2<CDT>;
722 using Point =
typename CDTP::Point;
723 using Cid =
typename CDTP::Constraint_id;
724 using Vertex_handle =
typename CDTP::Vertex_handle;
727 const auto compute_radius_inscribed_circle =
728 [](
const CGAL::Polygon_2<Kernel> &polygon) ->
double {
731 sdg.insert_segments(polygon.edges_begin(), polygon.edges_end());
733 double sd = 0, sqdist = 0;
734 typename SDG2::Finite_faces_iterator fit = sdg.finite_faces_begin();
735 for (; fit != sdg.finite_faces_end(); ++fit)
737 typename Kernel::Point_2 pp = sdg.primal(fit);
738 for (
int i = 0; i < 3; ++i)
740 assert(!sdg.is_infinite(fit->vertex(i)));
741 if (fit->vertex(i)->site().is_segment())
743 typename Kernel::Segment_2 s =
744 fit->vertex(i)->site().segment();
745 sqdist = CGAL::to_double(CGAL::squared_distance(pp, s));
749 typename Kernel::Point_2 p = fit->vertex(i)->site().point();
750 sqdist = CGAL::to_double(CGAL::squared_distance(pp, p));
754 if (polygon.bounded_side(pp) == CGAL::ON_BOUNDED_SIDE)
761 const auto mesh_size = [&ah]() ->
double {
764 if (polytope->is_locally_owned())
766 const double diameter = polytope->diameter();
777 std::vector<double> circle_ratios;
778 std::vector<double> unformity_factors;
786 if (polytope->is_locally_owned())
788 const std::vector<typename Triangulation<dim>::active_face_iterator>
789 &boundary = polytope->polytope_boundary();
791 const double diameter = polytope->diameter();
792 const double radius_circumscribed_circle = .5 *
diameter;
795 for (
unsigned int f = 0; f < boundary.size(); f += 1)
798 cdtp.insert_constraint(
799 {boundary[f]->vertex(0)[0], boundary[f]->vertex(0)[1]},
800 {boundary[f]->vertex(1)[0], boundary[f]->vertex(1)[1]});
802 cdtp.split_subconstraint_graph_into_constraints();
804 CGAL::Polygon_2<Kernel> outer_polygon;
805 auto it = outer_polygon.vertices_begin();
806 for (
typename CDTP::Constraint_id cid : cdtp.constraints())
808 for (
typename CDTP::Vertex_handle vh :
809 cdtp.vertices_in_constraint(cid))
811 it = outer_polygon.insert(outer_polygon.vertices_end(),
815 outer_polygon.erase(it);
817 const double radius_inscribed_circle =
818 compute_radius_inscribed_circle(outer_polygon);
820 circle_ratios.push_back(radius_inscribed_circle /
821 radius_circumscribed_circle);
822 unformity_factors.push_back(
diameter / mesh_size);
826 const auto &agglo_values = ah.
reinit(polytope);
827 const double measure_element =
828 std::accumulate(agglo_values.get_JxW_values().cbegin(),
829 agglo_values.get_JxW_values().cend(),
831 box_ratio.push_back(measure_element /
832 bboxes[polytope->index()].volume());
839 double covering_bboxes = 0.;
840 for (
unsigned int i = 0; i < bboxes.size(); ++i)
841 covering_bboxes += bboxes[i].
volume();
843 const double overlap_factor =
850 return {unformity_factors, circle_ratios, box_ratio, overlap_factor};
866 const std::string &filename)
868 static_assert(dim == 2);
869 std::ofstream myfile;
870 myfile.open(filename +
".csv");
873 if (polytope->is_locally_owned())
875 const std::vector<typename Triangulation<dim>::active_face_iterator>
876 &boundary = polytope->polytope_boundary();
877 for (
unsigned int f = 0; f < boundary.size(); ++f)
879 myfile << boundary[f]->vertex(0)[0];
881 myfile << boundary[f]->vertex(0)[1];
883 myfile << boundary[f]->vertex(1)[0];
885 myfile << boundary[f]->vertex(1)[1];
895 template <
typename T>
899 return (
pow >=
sizeof(
unsigned int) * 8) ? 0 :
908 const std::string &matrix_name,
911#ifdef DEAL_II_WITH_TRILINOS
912 const Epetra_CrsMatrix &trilinos_matrix = matrix.trilinos_matrix();
915 EpetraExt::RowMatrixToMatrixMarketFile(filename.c_str(),
937 template <
int dim,
int spacedim,
typename VectorType>
942 const VectorType &src)
944 Assert((dim == spacedim), ExcNotImplemented());
948 "The destination vector must the empt upon calling this function."));
950 using NumberType =
typename VectorType::value_type;
951 constexpr bool is_trilinos_vector =
952 std::is_same_v<VectorType, TrilinosWrappers::MPI::Vector>;
953 using MatrixType = std::conditional_t<is_trilinos_vector,
957 MatrixType interpolation_matrix;
960 typename std::conditional_t<!is_trilinos_vector, SparsityPattern, void *>
976 std::unique_ptr<FiniteElement<dim>> output_fe;
978 output_fe = std::make_unique<FE_DGQ<dim>>(fe.degree);
980 output_fe = std::make_unique<FE_SimplexDGP<dim>>(fe.degree);
989 const IndexSet locally_relevant_dofs =
997 locally_relevant_dofs);
999 std::vector<types::global_dof_index> agglo_dof_indices(fe.dofs_per_cell);
1000 std::vector<types::global_dof_index> standard_dof_indices(
1002 std::vector<types::global_dof_index> output_dof_indices(
1003 output_fe->dofs_per_cell);
1012 if (cell->is_locally_owned())
1017 cell->active_cell_index());
1018 slaves.emplace_back(cell);
1020 cell->get_dof_indices(agglo_dof_indices);
1022 for (
const auto &slave : slaves)
1025 const auto slave_output =
1026 slave->as_dof_handler_iterator(*output_dh);
1027 slave_output->get_dof_indices(output_dof_indices);
1028 for (
const auto row : output_dof_indices)
1030 agglo_dof_indices.begin(),
1031 agglo_dof_indices.end());
1037 const auto assemble_interpolation_matrix = [&]() {
1039 std::vector<Point<dim>> reference_q_points(fe.dofs_per_cell);
1046 if (cell->is_locally_owned())
1051 cell->active_cell_index());
1052 slaves.emplace_back(cell);
1054 cell->get_dof_indices(agglo_dof_indices);
1062 for (
const auto &slave : slaves)
1065 const auto slave_output =
1066 slave->as_dof_handler_iterator(*output_dh);
1068 slave_output->get_dof_indices(output_dof_indices);
1069 output_fe_values.
reinit(slave_output);
1073 const auto &q_points =
1075 for (
const auto i : output_fe_values.
dof_indices())
1078 for (
const auto j : output_fe_values.
dof_indices())
1080 local_matrix(i, j) = fe.shape_value(j, p);
1086 interpolation_matrix);
1093 if constexpr (std::is_same_v<MatrixType, TrilinosWrappers::SparseMatrix>)
1099 locally_relevant_dofs);
1101 interpolation_matrix.reinit(locally_owned_dofs,
1102 locally_owned_dofs_agglo,
1105 dst.reinit(locally_owned_dofs);
1106 assemble_interpolation_matrix();
1108 else if constexpr (std::is_same_v<MatrixType, SparseMatrix<NumberType>>)
1111 interpolation_matrix.reinit(sp);
1112 dst.reinit(output_dh->
n_dofs());
1113 assemble_interpolation_matrix();
1118 (void)agglomeration_handler;
1130 interpolation_matrix.vmult(dst, src);
1146 template <
int dim,
int spacedim,
typename VectorType>
1151 const VectorType &src,
1152 const bool on_the_fly =
true)
1154 Assert((dim == spacedim), ExcNotImplemented());
1158 "The destination vector must the empt upon calling this function."));
1160 using NumberType =
typename VectorType::value_type;
1161 static constexpr bool is_trilinos_vector =
1162 std::is_same_v<VectorType, TrilinosWrappers::MPI::Vector>;
1164 static constexpr bool is_supported_vector =
1165 std::is_same_v<VectorType, Vector<NumberType>> || is_trilinos_vector;
1166 static_assert(is_supported_vector);
1169 if (on_the_fly ==
false)
1185 agglomeration_handler.
get_fe();
1191 std::unique_ptr<FiniteElement<dim>> output_fe;
1193 output_fe = std::make_unique<FE_DGQ<dim>>(original_fe.
degree);
1196 std::make_unique<FE_SimplexDGP<dim>>(original_fe.
degree);
1205 if constexpr (std::is_same_v<VectorType,
1208 const IndexSet &locally_owned_dofs =
1210 dst.reinit(locally_owned_dofs);
1212 else if constexpr (std::is_same_v<VectorType, Vector<NumberType>>)
1214 dst.reinit(output_dh.
n_dofs());
1219 (void)agglomeration_handler;
1227 const unsigned int dofs_per_cell =
1229 const unsigned int output_dofs_per_cell =
1230 output_fe->n_dofs_per_cell();
1237 std::vector<types::global_dof_index> local_dof_indices(
1239 std::vector<types::global_dof_index> local_dof_indices_output(
1240 output_dofs_per_cell);
1243 for (
const auto &polytope :
1246 if (polytope->is_locally_owned())
1248 polytope->get_dof_indices(local_dof_indices);
1251 const auto &deal_cells =
1252 polytope->get_agglomerate();
1253 for (
const auto &cell : deal_cells)
1255 const auto slave_output = cell->as_dof_handler_iterator(
1257 slave_output->get_dof_indices(local_dof_indices_output);
1258 output_fe_values.
reinit(slave_output);
1260 const auto &qpoints =
1263 for (
unsigned int j = 0; j < output_dofs_per_cell; ++j)
1265 const auto &ref_qpoint =
1267 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1268 dst(local_dof_indices_output[j]) +=
1269 src(local_dof_indices[i]) *
1291 Assert(original_fe_collection[0].n_components() >= 1,
1292 ExcMessage(
"Invalid FE: must have at least one component."));
1293 if (original_fe_collection[0].n_components() == 1)
1296 for (
unsigned int i = 0; i < original_fe_collection.
size(); ++i)
1298 std::unique_ptr<FiniteElement<dim>> output_fe;
1300 output_fe = std::make_unique<FE_DGQ<dim>>(
1301 original_fe_collection[i].degree);
1303 output_fe = std::make_unique<FE_SimplexDGP<dim>>(
1304 original_fe_collection[i].degree);
1307 output_fe_collection.
push_back(*output_fe);
1310 else if (original_fe_collection[0].n_components() > 1)
1313 for (
unsigned int i = 0; i < original_fe_collection.
size(); ++i)
1315 std::vector<const FiniteElement<dim, spacedim> *>
1317 std::vector<unsigned int> multiplicities;
1318 for (
unsigned int b = 0;
1319 b < original_fe_collection[i].n_base_elements();
1323 &original_fe_collection[i].base_element(
b)))
1324 base_elements.push_back(
1330 original_fe_collection[i]
1334 base_elements.push_back(
1336 original_fe_collection[i]
1342 multiplicities.push_back(
1343 original_fe_collection[i].element_multiplicity(
b));
1348 for (
const auto *ptr : base_elements)
1350 output_fe_collection.
push_back(output_fe_system);
1358 for (
const auto &polytope :
1361 if (polytope->is_locally_owned())
1363 const auto &deal_cells =
1364 polytope->get_agglomerate();
1365 const unsigned int active_fe_idx =
1366 polytope->active_fe_index();
1368 for (
const auto &cell : deal_cells)
1371 slave_cell_dh_iterator =
1372 cell->as_dof_handler_iterator(output_dh);
1373 slave_cell_dh_iterator->set_active_fe_index(
1380 if constexpr (std::is_same_v<VectorType,
1383 const IndexSet &locally_owned_dofs =
1385 dst.reinit(locally_owned_dofs);
1387 else if constexpr (std::is_same_v<VectorType, Vector<NumberType>>)
1389 dst.reinit(output_dh.
n_dofs());
1394 (void)agglomeration_handler;
1401 for (
const auto &polytope :
1404 if (polytope->is_locally_owned())
1406 const unsigned int active_fe_idx =
1407 polytope->active_fe_index();
1408 const unsigned int dofs_per_cell =
1409 polytope->get_fe().dofs_per_cell;
1410 const unsigned int output_dofs_per_cell =
1411 output_fe_collection[active_fe_idx].n_dofs_per_cell();
1413 .get_unit_support_points());
1416 output_fe_collection[active_fe_idx],
1419 std::vector<types::global_dof_index> local_dof_indices(
1421 std::vector<types::global_dof_index>
1422 local_dof_indices_output(output_dofs_per_cell);
1424 polytope->get_dof_indices(local_dof_indices);
1427 const auto &deal_cells =
1428 polytope->get_agglomerate();
1429 for (
const auto &cell : deal_cells)
1431 const auto slave_output = cell->as_dof_handler_iterator(
1433 slave_output->get_dof_indices(local_dof_indices_output);
1434 output_fe_values.
reinit(slave_output);
1436 const auto &qpoints =
1439 for (
unsigned int j = 0; j < output_dofs_per_cell; ++j)
1441 const unsigned int component_idx_of_this_dof =
1442 slave_output->get_fe()
1443 .system_to_component_index(j)
1445 const auto &ref_qpoint =
1447 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1448 dst(local_dof_indices_output[j]) +=
1449 src(local_dof_indices[i]) *
1450 original_fe_collection[active_fe_idx]
1451 .shape_value_component(
1452 i, ref_qpoint, component_idx_of_this_dof);
1470 template <
int dim,
int spacedim,
typename MatrixType>
1474 MatrixType &interpolation_matrix)
1476 Assert((dim == spacedim), ExcNotImplemented());
1478 using NumberType =
typename MatrixType::value_type;
1479 constexpr bool is_trilinos_matrix =
1480 std::is_same_v<MatrixType, TrilinosWrappers::MPI::Vector>;
1483 typename std::conditional_t<!is_trilinos_matrix, SparsityPattern, void *>
1502 const IndexSet locally_relevant_dofs =
1510 locally_relevant_dofs);
1512 std::vector<types::global_dof_index> agglo_dof_indices(fe.
dofs_per_cell);
1513 std::vector<types::global_dof_index> standard_dof_indices(fe.
dofs_per_cell);
1514 std::vector<types::global_dof_index> output_dof_indices(fe.
dofs_per_cell);
1523 if (cell->is_locally_owned())
1528 cell->active_cell_index());
1529 slaves.emplace_back(cell);
1531 cell->get_dof_indices(agglo_dof_indices);
1533 for (
const auto &slave : slaves)
1536 const auto slave_output =
1537 slave->as_dof_handler_iterator(*output_dh);
1538 slave_output->get_dof_indices(output_dof_indices);
1539 for (
const auto row : output_dof_indices)
1541 agglo_dof_indices.begin(),
1542 agglo_dof_indices.end());
1548 const auto assemble_interpolation_matrix = [&]() {
1550 std::vector<Point<dim>> reference_q_points(fe.
dofs_per_cell);
1557 if (cell->is_locally_owned())
1562 cell->active_cell_index());
1563 slaves.emplace_back(cell);
1565 cell->get_dof_indices(agglo_dof_indices);
1573 for (
const auto &slave : slaves)
1576 const auto slave_output =
1577 slave->as_dof_handler_iterator(*output_dh);
1579 slave_output->get_dof_indices(output_dof_indices);
1580 output_fe_values.
reinit(slave_output);
1584 const auto &q_points =
1586 for (
const auto i : output_fe_values.
dof_indices())
1589 for (
const auto j : output_fe_values.
dof_indices())
1597 interpolation_matrix);
1604 if constexpr (std::is_same_v<MatrixType, TrilinosWrappers::SparseMatrix>)
1610 locally_relevant_dofs);
1612 interpolation_matrix.reinit(locally_owned_dofs,
1613 locally_owned_dofs_agglo,
1616 assemble_interpolation_matrix();
1618 else if constexpr (std::is_same_v<MatrixType, SparseMatrix<NumberType>>)
1621 interpolation_matrix.reinit(sp);
1622 assemble_interpolation_matrix();
1627 (void)agglomeration_handler;
1648 template <
int dim,
typename Number,
typename VectorType>
1651 const VectorType &solution,
1653 const std::vector<VectorTools::NormType> &norms,
1654 std::vector<double> &global_errors)
1656 Assert(solution.size() > 0,
1658 "Solution vector must be non-empty upon calling this function."));
1659 Assert(std::any_of(norms.cbegin(),
1662 return (norm_type ==
1663 VectorTools::NormType::H1_seminorm ||
1664 norm_type == VectorTools::NormType::L2_norm);
1666 ExcMessage(
"Norm type not supported"));
1667 global_errors.resize(norms.size());
1668 std::fill(global_errors.begin(), global_errors.end(), 0.);
1671 std::vector<double> local_errors(norms.size());
1672 std::fill(local_errors.begin(), local_errors.end(), 0.);
1675 const unsigned int dofs_per_cell = agglomeration_handler.
n_dofs_per_cell();
1677 const bool compute_semi_H1 =
1678 std::any_of(norms.cbegin(),
1681 return norm_type == VectorTools::NormType::H1_seminorm;
1684 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1687 if (polytope->is_locally_owned())
1689 const auto &agglo_values = agglomeration_handler.
reinit(polytope);
1690 polytope->get_dof_indices(local_dof_indices);
1693 const unsigned int n_qpoints = q_points.size();
1694 std::vector<double> analyical_sol_at_qpoints(n_qpoints);
1695 exact_solution.
value_list(q_points, analyical_sol_at_qpoints);
1696 std::vector<Tensor<1, dim>> grad_analyical_sol_at_qpoints(
1699 if (compute_semi_H1)
1701 grad_analyical_sol_at_qpoints);
1703 for (
unsigned int q_index : agglo_values.quadrature_point_indices())
1705 double solution_at_qpoint = 0.;
1707 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1709 solution_at_qpoint += solution(local_dof_indices[i]) *
1710 agglo_values.shape_value(i, q_index);
1712 if (compute_semi_H1)
1713 grad_solution_at_qpoint +=
1714 solution(local_dof_indices[i]) *
1715 agglo_values.shape_grad(i, q_index);
1718 local_errors[0] +=
std::pow((analyical_sol_at_qpoints[q_index] -
1719 solution_at_qpoint),
1721 agglo_values.JxW(q_index);
1724 if (compute_semi_H1)
1725 for (
unsigned int d = 0;
d < dim; ++
d)
1727 std::pow((grad_analyical_sol_at_qpoints[q_index][
d] -
1728 grad_solution_at_qpoint[
d]),
1730 agglo_values.JxW(q_index);
1739 [](
const double a,
const double b) { return a + b; });
1741 global_errors[0] =
std::sqrt(global_errors[0]);
1743 if (compute_semi_H1)
1748 [](
const double a,
const double b) { return a + b; });
1749 global_errors[1] =
std::sqrt(global_errors[1]);
1767 &agglomeration_handlers,
1770 const unsigned int starting_tree_level)
1772 const auto parallel_tria =
1776 Assert(parallel_tria->n_active_cells() > 0, ExcInternalError());
1778 const MPI_Comm
comm = parallel_tria->get_mpi_communicator();
1784 static constexpr unsigned int max_elem_per_node =
1786 std::vector<std::pair<BoundingBox<dim>,
1788 boxes(parallel_tria->n_locally_owned_active_cells());
1790 for (
const auto &cell : parallel_tria->active_cell_iterators())
1791 if (cell->is_locally_owned())
1795 Assert(n_levels(tree) >= 2, ExcMessage(
"At least two levels are needed."));
1796 pcout <<
"Total number of available levels: " << n_levels(tree)
1799 pcout <<
"Starting level: " << starting_tree_level << std::endl;
1800 const unsigned int total_tree_levels =
1801 n_levels(tree) - starting_tree_level + 1;
1806 agglomeration_handlers.resize(total_tree_levels);
1808 for (
unsigned int extraction_level = starting_tree_level;
1809 extraction_level <= n_levels(tree);
1812 agglomeration_handlers[extraction_level - starting_tree_level] =
1813 std::make_unique<AgglomerationHandler<dim>>(cached_tria);
1817 agglomeration_handlers[extraction_level - starting_tree_level]
1818 ->connect_hierarchy(agglomerator);
1821 unsigned int agglo_index = 0;
1822 for (
unsigned int i = 0; i < agglomerates.size(); ++i)
1824 const auto &agglo = agglomerates[i];
1825 for (
const auto &el : agglo)
1827 el->set_material_id(agglo_index);
1832 const unsigned int n_local_agglomerates = agglo_index;
1833 unsigned int total_agglomerates =
1835 pcout <<
"Total agglomerates per (tree) level: " << extraction_level
1836 <<
": " << total_agglomerates << std::endl;
1841 std::vector<typename Triangulation<dim>::active_cell_iterator>>
1842 cells_per_subdomain(n_local_agglomerates);
1843 for (
const auto &cell : parallel_tria->active_cell_iterators())
1844 if (cell->is_locally_owned())
1845 cells_per_subdomain[cell->material_id()].push_back(cell);
1848 for (std::size_t i = 0; i < cells_per_subdomain.size(); ++i)
1849 agglomeration_handlers[extraction_level - starting_tree_level]
1850 ->define_agglomerate(cells_per_subdomain[i]);
1852 agglomeration_handlers[extraction_level - starting_tree_level]
1858 agglomeration_handlers[extraction_level - starting_tree_level]
1859 ->distribute_agglomerated_dofs(fe_dg);
1862 return total_tree_levels;
1879 const double penalty_constant,
1883 const unsigned int dofs_per_cell =
1888 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1890 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1892 M11(i, j) += (-0.5 * fe_faces0.
shape_grad(i, q_index) * normal *
1894 0.5 * fe_faces0.
shape_grad(j, q_index) * normal *
1896 (penalty_constant / h_f) *
1899 fe_faces0.
JxW(q_index);
1900 M12(i, j) += (0.5 * fe_faces0.
shape_grad(i, q_index) * normal *
1902 0.5 * fe_faces1.
shape_grad(j, q_index) * normal *
1904 (penalty_constant / h_f) *
1907 fe_faces1.
JxW(q_index);
1908 M21(i, j) += (-0.5 * fe_faces1.
shape_grad(i, q_index) * normal *
1910 0.5 * fe_faces0.
shape_grad(j, q_index) * normal *
1912 (penalty_constant / h_f) *
1915 fe_faces1.
JxW(q_index);
1916 M22(i, j) += (0.5 * fe_faces1.
shape_grad(i, q_index) * normal *
1918 0.5 * fe_faces1.
shape_grad(j, q_index) * normal *
1920 (penalty_constant / h_f) *
1923 fe_faces1.
JxW(q_index);
1939 const std::vector<std::vector<double>> &recv_values,
1941 const std::vector<double> &recv_jxws,
1942 const double penalty_constant,
1946 (recv_values.size() > 0 && recv_gradients.size() && recv_jxws.size()),
1948 "Not possible to assemble jumps and averages at a ghosted interface."));
1949 const unsigned int dofs_per_cell = M11.
m();
1954 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1956 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1958 M11(i, j) += (-0.5 * fe_faces0.
shape_grad(i, q_index) * normal *
1960 0.5 * fe_faces0.
shape_grad(j, q_index) * normal *
1962 (penalty_constant / h_f) *
1965 fe_faces0.
JxW(q_index);
1966 M12(i, j) += (0.5 * fe_faces0.
shape_grad(i, q_index) * normal *
1967 recv_values[j][q_index] -
1968 0.5 * recv_gradients[j][q_index] * normal *
1970 (penalty_constant / h_f) *
1972 recv_values[j][q_index]) *
1975 (-0.5 * recv_gradients[i][q_index] * normal *
1977 0.5 * fe_faces0.
shape_grad(j, q_index) * normal *
1978 recv_values[i][q_index] -
1979 (penalty_constant / h_f) * recv_values[i][q_index] *
1983 (0.5 * recv_gradients[i][q_index] * normal *
1984 recv_values[j][q_index] +
1985 0.5 * recv_gradients[j][q_index] * normal *
1986 recv_values[i][q_index] +
1987 (penalty_constant / h_f) * recv_values[i][q_index] *
1988 recv_values[j][q_index]) *
2001 template <
int dim,
typename MatrixType>
2008 (std::is_same_v<MatrixType, TrilinosWrappers::SparseMatrix> ||
2009 std::is_same_v<MatrixType,
2015 ExcMessage(
"FE type not supported."));
2018 constraints.
close();
2019 const double penalty_constant =
2023 .create_agglomeration_sparsity_pattern(dsp);
2024 system_matrix.reinit(dsp);
2031 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
2032 std::vector<types::global_dof_index> local_dof_indices_neighbor(
2037 if (polytope->is_locally_owned())
2040 const auto &agglo_values = ah.
reinit(polytope);
2041 for (
unsigned int q_index : agglo_values.quadrature_point_indices())
2043 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
2045 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
2047 cell_matrix(i, j) +=
2048 agglo_values.shape_grad(i, q_index) *
2049 agglo_values.shape_grad(j, q_index) *
2050 agglo_values.JxW(q_index);
2055 polytope->get_dof_indices(local_dof_indices);
2057 unsigned int n_faces = polytope->n_faces();
2058 const double h_f = polytope->diameter();
2059 for (
unsigned int f = 0; f < n_faces; ++f)
2061 if (polytope->at_boundary(f))
2064 const auto &fe_face = ah.
reinit(polytope, f);
2066 for (
unsigned int q_index :
2067 fe_face.quadrature_point_indices())
2070 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
2072 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
2074 cell_matrix(i, j) +=
2075 (-fe_face.shape_value(i, q_index) *
2076 fe_face.shape_grad(j, q_index) * normal -
2077 fe_face.shape_grad(i, q_index) * normal *
2078 fe_face.shape_value(j, q_index) +
2079 (penalty_constant / h_f) *
2080 fe_face.shape_value(i, q_index) *
2081 fe_face.shape_value(j, q_index)) *
2082 fe_face.JxW(q_index);
2089 const auto &neigh_polytope = polytope->neighbor(f);
2090 if (polytope->id() < neigh_polytope->id())
2093 polytope->neighbor_of_agglomerated_neighbor(f);
2094 Assert(neigh_polytope->neighbor(nofn)->id() ==
2096 ExcMessage(
"Mismatch."));
2098 polytope, neigh_polytope, f, nofn);
2099 const auto &fe_faces0 = fe_faces.first;
2100 if (neigh_polytope->is_locally_owned())
2103 const auto &fe_faces1 = fe_faces.second;
2118 neigh_polytope->get_dof_indices(
2119 local_dof_indices_neighbor);
2121 M11, local_dof_indices, system_matrix);
2125 local_dof_indices_neighbor,
2129 local_dof_indices_neighbor,
2133 M22, local_dof_indices_neighbor, system_matrix);
2140 neigh_polytope->subdomain_id();
2141 const auto &recv_jxws =
2143 .at({neigh_polytope->id(), nofn});
2144 const auto &recv_values =
2146 .at({neigh_polytope->id(), nofn});
2147 const auto &recv_gradients =
2149 .at({neigh_polytope->id(), nofn});
2170 neigh_polytope->get_dof_indices(
2171 local_dof_indices_neighbor);
2173 M11, local_dof_indices, system_matrix);
2177 local_dof_indices_neighbor,
2181 local_dof_indices_neighbor,
2185 M22, local_dof_indices_neighbor, system_matrix);
2205 template <
int dim,
typename MatrixType,
typename VectorType>
2208 VectorType &system_rhs,
2214 (std::is_same_v<MatrixType, TrilinosWrappers::SparseMatrix> ||
2215 std::is_same_v<MatrixType,
2220 "Implemented only for simplex meshes for the time being."));
2223 ExcNotImplemented());
2225 const double penalty_constant = .5 * fe_dg.
degree * (fe_dg.
degree + 1);
2227 constraints.
close();
2230 const IndexSet locally_relevant_dofs =
2239 locally_relevant_dofs);
2241 system_matrix.reinit(locally_owned_dofs,
2248 const unsigned int quadrature_degree = fe_dg.
degree + 1;
2279 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
2284 if (cell->is_locally_owned())
2296 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
2298 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
2300 cell_matrix(i, j) += fe_values.
shape_grad(i, q_index) *
2302 fe_values.
JxW(q_index);
2306 fe_values.
JxW(q_index);
2311 cell->get_dof_indices(local_dof_indices);
2313 for (
const auto f : cell->face_indices())
2315 const double extent1 =
2316 cell->measure() / cell->face(f)->measure();
2318 if (cell->face(f)->at_boundary())
2320 hf = (1. / extent1 + 1. / extent1);
2321 fe_faces0.
reinit(cell, f);
2324 for (
unsigned int q_index :
2327 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
2329 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
2331 cell_matrix(i, j) +=
2338 (penalty_constant * hf) *
2341 fe_faces0.
JxW(q_index);
2350 const auto &neigh_cell = cell->neighbor(f);
2351 if (cell->global_active_cell_index() <
2352 neigh_cell->global_active_cell_index())
2354 const double extent2 =
2355 neigh_cell->measure() /
2356 neigh_cell->face(cell->neighbor_of_neighbor(f))
2358 hf = (1. / extent1 + 1. / extent2);
2359 fe_faces0.
reinit(cell, f);
2360 fe_faces1.
reinit(neigh_cell,
2361 cell->neighbor_of_neighbor(f));
2363 std::vector<types::global_dof_index>
2364 local_dof_indices_neighbor(dofs_per_cell);
2373 for (
unsigned int q_index :
2376 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
2378 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
2387 (penalty_constant * hf) *
2390 fe_faces0.
JxW(q_index);
2399 (penalty_constant * hf) *
2402 fe_faces1.
JxW(q_index);
2412 (penalty_constant * hf) *
2415 fe_faces1.
JxW(q_index);
2425 (penalty_constant * hf) *
2428 fe_faces1.
JxW(q_index);
2435 neigh_cell->get_dof_indices(local_dof_indices_neighbor);
2438 M11, local_dof_indices, system_matrix);
2442 local_dof_indices_neighbor,
2446 local_dof_indices_neighbor,
2450 M22, local_dof_indices_neighbor, system_matrix);
void distribute_local_to_global(const InVector &local_vector, const std::vector< size_type > &local_dof_indices, OutVector &global_vector) const
Point< spacedim, Number > real_to_unit(const Point< spacedim, Number > &point) const
void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
const Triangulation< dim, spacedim > & get_triangulation() const
const IndexSet & locally_owned_dofs() const
void reinit(const Triangulation< dim, spacedim > &tria)
types::global_dof_index n_dofs() const
MPI_Comm get_mpi_communicator() const
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_unique_and_sorted=false)
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
void add(const size_type i, const size_type j)
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell, const unsigned int face_no)
const std::vector< Point< spacedim > > & get_quadrature_points() const
const std::vector< Tensor< 1, spacedim > > & get_normal_vectors() const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > dof_indices() const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > quadrature_point_indices() const
const Tensor< 1, spacedim > & shape_grad(const unsigned int i, const unsigned int q_point) const
double JxW(const unsigned int q_point) const
const double & shape_value(const unsigned int i, const unsigned int q_point) const
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell)
const unsigned int degree
unsigned int n_dofs_per_cell() const
const unsigned int dofs_per_cell
const std::vector< Point< dim > > & get_unit_support_points() const
virtual double shape_value(const unsigned int i, const Point< dim > &p) const
virtual void gradient_list(const std::vector< Point< dim > > &points, std::vector< Tensor< 1, dim, RangeNumberType > > &gradients, const unsigned int component=0) const
virtual void value_list(const std::vector< Point< dim > > &points, std::vector< RangeNumberType > &values, const unsigned int component=0) const
virtual BoundingBox< spacedim > get_bounding_box(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end)
bool all_reference_cells_are_hyper_cube() const
virtual MPI_Comm get_mpi_communicator() const
bool all_reference_cells_are_simplex() const
unsigned int n_dofs_per_cell() const noexcept
types::global_cell_index cell_to_polytope_index(const typename Triangulation< dim, spacedim >::active_cell_iterator &cell) const
const DoFHandler< dim, spacedim > & get_dof_handler() const
const std::vector< typename Triangulation< dim, spacedim >::active_cell_iterator > & get_slaves_of_idx(types::global_cell_index idx) const
const FEValues< dim, spacedim > & reinit(const AgglomerationIterator< dim, spacedim > &polytope) const
std::map< types::subdomain_id, std::map< std::pair< CellId, unsigned int >, std::vector< double > > > recv_jxws
DoFHandler< dim, spacedim > output_dh
std::pair< const FEValuesBase< dim, spacedim > &, const FEValuesBase< dim, spacedim > & > reinit_interface(const AgglomerationIterator< dim, spacedim > &polytope_in, const AgglomerationIterator< dim, spacedim > &neigh_polytope, const unsigned int local_in, const unsigned int local_outside) const
std::map< types::subdomain_id, std::map< std::pair< CellId, unsigned int >, std::vector< std::vector< Tensor< 1, spacedim > > > > > recv_gradients
const Triangulation< dim, spacedim > & get_triangulation() const
const Mapping< dim > & get_mapping() const
unsigned int n_agglomerates() const
const std::vector< BoundingBox< dim > > & get_local_bboxes() const
const FiniteElement< dim, spacedim > & get_fe() const
std::map< types::subdomain_id, std::map< std::pair< CellId, unsigned int >, std::vector< std::vector< double > > > > recv_values
bool is_master_cell(const CellIterator &cell) const
IteratorRange< agglomeration_iterator > polytope_iterators() const
agglomeration_iterator define_agglomerate(const AgglomerationContainer &cells)
DoFHandler< dim, spacedim > agglo_dh
bool used_fe_collection() const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const std::vector< std::vector< typename Triangulation< dim >::active_cell_iterator > > & extract_agglomerates()
unsigned int size() const
void push_back(const FiniteElement< dim, spacedim > &new_fe)
unsigned int n_locally_owned_active_cells() const
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators() const
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertThrow(cond, exc)
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
typename ActiveSelector::active_cell_iterator active_cell_iterator
TriaActiveIterator< TriaAccessor< dim - 1, dim, spacedim > > active_face_iterator
void make_flux_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern)
Expression pow(const Expression &base, const Expression &exponent)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
T reduce(const T &local_value, const MPI_Comm comm, const std::function< T(const T &, const T &)> &combiner, const unsigned int root_process=0)
void get_face_connectivity_of_cells(const parallel::fullydistributed::Triangulation< dim, spacedim > &triangulation, DynamicSparsityPattern &cell_connectivity, const std::vector< types::global_cell_index > locally_owned_cells)
void interpolate_to_fine_grid(const AgglomerationHandler< dim, spacedim > &agglomeration_handler, VectorType &dst, const VectorType &src)
types::global_cell_index get_index(const std::vector< types::global_cell_index > &v, const types::global_cell_index index)
void partition_locally_owned_regions(const unsigned int n_partitions, Triangulation< dim, spacedim > &triangulation, const SparsityTools::Partitioner partitioner)
void fill_interpolation_matrix(const AgglomerationHandler< dim, spacedim > &agglomeration_handler, MatrixType &interpolation_matrix)
void assemble_local_jumps_and_averages(FullMatrix< double > &M11, FullMatrix< double > &M12, FullMatrix< double > &M21, FullMatrix< double > &M22, const FEValuesBase< dim > &fe_faces0, const FEValuesBase< dim > &fe_faces1, const double penalty_constant, const double h_f)
std::pair< std::vector< std::vector< unsigned int > >, std::vector< std::vector< typename Triangulation< boost::geometry::dimension< typename Rtree::indexable_type >::value >::active_cell_iterator > > > extract_children_of_level(const Rtree &tree, const unsigned int level)
void interpolate_to_fine_grid(const AgglomerationHandler< dim, spacedim > &agglomeration_handler, VectorType &dst, const VectorType &src, const bool on_the_fly=true)
void compute_global_error(const AgglomerationHandler< dim > &agglomeration_handler, const VectorType &solution, const Function< dim, Number > &exact_solution, const std::vector< VectorTools::NormType > &norms, std::vector< double > &global_errors)
Number compute_h_orthogonal(const unsigned int face_index, const std::vector< typename Triangulation< dim >::active_face_iterator > &polygon_boundary, const Tensor< 1, dim > &deal_normal)
unsigned int construct_agglomerated_levels(const Triangulation< dim > &tria, std::vector< std::unique_ptr< AgglomerationHandler< dim > > > &agglomeration_handlers, const FE_DGQ< dim > &fe_dg, const Mapping< dim > &mapping, const unsigned int starting_tree_level)
constexpr T constexpr_pow(T num, unsigned int pow)
void assemble_dg_matrix(MatrixType &system_matrix, const FiniteElement< dim > &fe_dg, const AgglomerationHandler< dim > &ah)
void collect_cells_for_agglomeration(const Triangulation< dim, spacedim > &tria, const std::vector< types::global_cell_index > &cell_idxs, std::vector< typename Triangulation< dim, spacedim >::active_cell_iterator > &cells_to_be_agglomerated)
void assemble_local_jumps_and_averages_ghost(FullMatrix< double > &M11, FullMatrix< double > &M12, FullMatrix< double > &M21, FullMatrix< double > &M22, const FEValuesBase< dim > &fe_faces0, const std::vector< std::vector< double > > &recv_values, const std::vector< std::vector< Tensor< 1, dim > > > &recv_gradients, const std::vector< double > &recv_jxws, const double penalty_constant, const double h_f)
void assemble_dg_matrix_on_standard_mesh(MatrixType &system_matrix, VectorType &system_rhs, const Mapping< dim > &mapping, const FiniteElement< dim > &fe_dg, const DoFHandler< dim > &dof_handler)
void write_to_matrix_market_format(const std::string &filename, const std::string &matrix_name, const TrilinosWrappers::SparseMatrix &matrix)
void export_polygon_to_csv_file(const AgglomerationHandler< dim > &agglomeration_handler, const std::string &filename)
std::tuple< std::vector< double >, std::vector< double >, std::vector< double >, double > compute_quality_metrics(const AgglomerationHandler< dim > &ah)
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
unsigned int subdomain_id
unsigned int global_cell_index
*braid_SplitCommworld & comm
RTree< typename LeafTypeIterator::value_type, IndexType, IndexableGetter > pack_rtree(const LeafTypeIterator &begin, const LeafTypeIterator &end)
const Translator & translator
void operator()(const InternalNode &node)
std::vector< std::vector< typename Triangulation< boost::geometry::dimension< Box >::value >::active_cell_iterator > > & agglomerates
Rtree_visitor(const Translator &translator, unsigned int target_level, std::vector< std::vector< typename Triangulation< boost::geometry::dimension< Box >::value >::active_cell_iterator > > &boxes, std::vector< std::vector< unsigned int > > &csr)
typename boost::geometry::index::detail::rtree::leaf< Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag >::type Leaf
const size_t target_level
std::vector< std::vector< unsigned int > > & row_ptr
typename boost::geometry::index::detail::rtree::internal_node< Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag >::type InternalNode
size_t next_level_leafs_processed