40template <
int dim,
typename RtreeType>
53 return (
pow >=
sizeof(
unsigned int) * 8) ? 0 :
66 std::vector<types::global_cell_index>
nodes;
67 std::vector<std::vector<types::global_cell_index>>
adjacency;
72 std::cout <<
"Graph information" << std::endl;
73 for (
const auto &node :
nodes)
75 std::cout <<
"Neighbors for node " << node << std::endl;
76 for (
const auto &neigh_node :
adjacency[node])
77 std::cout << neigh_node << std::endl;
96 template <
int dim,
int spacedim,
typename MatrixType>
103 using NumberType =
typename MatrixType::value_type;
105 static constexpr bool is_trilinos_matrix =
106 std::is_same_v<TrilinosWrappers::SparseMatrix, MatrixType>;
107 static constexpr bool is_serial_matrix =
108 std::is_same_v<SparseMatrix<NumberType>, MatrixType>;
109 static constexpr bool is_supported_matrix =
110 is_trilinos_matrix || is_serial_matrix;
111 static_assert(is_supported_matrix);
112 if constexpr (is_trilinos_matrix)
113 Assert(matrix.m() == 0, ExcInternalError());
114 if constexpr (is_serial_matrix)
117 "The destination matrix and its sparsity pattern must the empty "
118 "upon calling this function."));
133 const IndexSet &locally_owned_dofs_fine =
135 const IndexSet locally_relevant_dofs_fine =
138 const IndexSet &locally_owned_dofs_coarse =
141 std::conditional_t<is_trilinos_matrix,
146 if constexpr (is_trilinos_matrix)
147 dsp.
reinit(locally_owned_dofs_fine,
148 locally_owned_dofs_coarse,
151 dsp.reinit(fine_agglo_dh.
n_dofs(),
153 locally_relevant_dofs_fine);
156 std::vector<types::global_dof_index> agglo_dof_indices(dofs_per_cell);
157 std::vector<types::global_dof_index> standard_dof_indices(dofs_per_cell);
158 std::vector<types::global_dof_index> output_dof_indices(dofs_per_cell);
160 const std::vector<Point<dim>> &unit_support_points =
168 std::vector<types::global_dof_index> local_dof_indices_coarse(
170 std::vector<types::global_dof_index> local_dof_indices_child(dofs_per_cell);
173 if (polytope->is_locally_owned())
175 polytope->get_dof_indices(local_dof_indices_coarse);
178 const auto &children_polytopes = polytope->children();
183 child_dh->get_dof_indices(local_dof_indices_child);
184 for (
const auto row : local_dof_indices_child)
186 local_dof_indices_coarse.begin(),
187 local_dof_indices_coarse.end());
191 const auto assemble_injection_matrix = [&]() {
193 std::vector<Point<dim>> reference_q_points(dofs_per_cell);
200 if (polytope->is_locally_owned())
202 polytope->get_dof_indices(local_dof_indices_coarse);
204 coarse_bboxes[polytope->index()];
207 const auto &children_polytopes = polytope->children();
213 child_dh->get_dof_indices(local_dof_indices_child);
218 std::vector<Point<dim>> real_qpoints;
219 real_qpoints.reserve(unit_support_points.size());
220 for (
const Point<dim> &p : unit_support_points)
223 for (
unsigned int i = 0; i < local_dof_indices_coarse.size();
226 const auto &p = coarse_bbox.
real_to_unit(real_qpoints[i]);
227 for (
unsigned int j = 0; j < local_dof_indices_child.size();
235 local_dof_indices_child,
236 local_dof_indices_coarse,
243 if constexpr (is_trilinos_matrix)
247 assemble_injection_matrix();
249 else if constexpr (is_serial_matrix)
253 assemble_injection_matrix();
264 "This injection does not support PETSc types."));
287 template <
typename VectorType,
typename MatrixType,
typename SolverType>
296 static constexpr bool is_serial_matrix =
297 std::is_same_v<SolverType, SparseDirectUMFPACK>;
298 static constexpr bool is_trilinos_matrix =
299 std::is_same_v<SolverType, TrilinosWrappers::SolverDirect>;
300 [[maybe_unused]]
static constexpr bool is_matrix_type_supported =
301 is_serial_matrix || is_trilinos_matrix;
302 Assert(is_matrix_type_supported, ExcNotImplemented());
306 if constexpr (is_serial_matrix)
309 std::is_same_v<VectorType,
310 dealii::Vector<typename MatrixType::value_type>>;
313 else if constexpr (is_trilinos_matrix)
315 [[maybe_unused]]
static constexpr bool is_supported_parallel_vector =
316 std::is_same_v<VectorType,
318 typename MatrixType::value_type>> ||
319 std::is_same_v<VectorType, TrilinosWrappers::MPI::Vector>;
320 Assert(is_supported_parallel_vector, ExcNotImplemented());
338 const VectorType &src)
const override
392 typename number =
double>
455 *
data.get_dof_info(0).vector_partitioner))
458 src_copy.
reinit(
data.get_dof_info().vector_partitioner);
464 *
data.get_dof_info(0).vector_partitioner))
467 dst_copy.
reinit(
data.get_dof_info().vector_partitioner);
483 return data.get_vector_partitioner()->size();
489 return data.get_vector_partitioner()->size();
493 el(
const unsigned int row,
const unsigned int col)
const
498 ExcMessage(
"Matrix-free does not allow for entry access"));
506 data.initialize_dof_vector(vector);
513 return data.get_dof_handler();
520 return data.get_dof_handler().get_triangulation();
543 const auto cell_operation = [&](
auto &phi) {
545 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
546 phi.submit_gradient(phi.get_gradient(q), q);
550 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
556 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
558 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
561 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
564 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
566 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
568 jump_value * 2. * sigmaF - average_valgrad * 0.5;
569 phi_m.submit_normal_derivative(-jump_value, q);
570 phi_p.submit_normal_derivative(-jump_value, q);
571 phi_m.submit_value(average_valgrad, q);
572 phi_p.submit_value(-average_valgrad, q);
578 const auto boundary_operation = [&](
auto &phi_m) {
582 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) *
585 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
589 -phi_m.get_normal_derivative(q);
590 average_valgrad += jump_value * sigmaF * 2.0;
591 phi_m.submit_normal_derivative(-jump_value, q);
592 phi_m.submit_value(average_valgrad, q);
606 const auto &dof_handler =
data.get_dof_handler();
610 dof_handler.locally_owned_mg_dofs(
data.get_mg_level()) :
611 dof_handler.locally_owned_dofs(),
612 data.get_task_info().communicator);
653 const auto cell_operation = [&](
auto &phi) {
655 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
656 phi.submit_gradient(phi.get_gradient(q), q);
660 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
666 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
668 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
671 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
674 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
676 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
678 jump_value * 2. * sigmaF - average_valgrad * 0.5;
679 phi_m.submit_normal_derivative(-jump_value, q);
680 phi_p.submit_normal_derivative(-jump_value, q);
681 phi_m.submit_value(average_valgrad, q);
682 phi_p.submit_value(-average_valgrad, q);
688 const auto boundary_operation = [&](
auto &phi_m) {
692 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) *
695 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
699 -phi_m.get_normal_derivative(q);
700 average_valgrad += jump_value * sigmaF * 2.0;
701 phi_m.submit_normal_derivative(-jump_value, q);
702 phi_m.submit_value(average_valgrad, q);
719 const IndexSet system_relevant_set =
725 system_relevant_set);
731 data.get_task_info().communicator,
732 system_relevant_set);
733 mg_matrix.
reinit(system_partitioning,
735 data.get_task_info().communicator);
761 .template cell_loop<LinearAlgebra::distributed::Vector<number>,
int>(
762 [](
const auto &matrix_free,
766 FEEvaluation<dim, -1, 0, n_components, number> phi(matrix_free,
768 for (
unsigned int cell = cells.first; cell < cells.second; ++cell)
771 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
773 if constexpr (n_components == 1)
775 phi.submit_value(1.0, q);
780 for (
unsigned int v = 0;
781 v < VectorizedArray<number>::size();
784 for (
unsigned int i = 0; i < n_components; i++)
787 phi.submit_value(temp, q);
805 unsigned int dummy = 0;
813 for (
unsigned int i = 0;
827 const std::pair<unsigned int, unsigned int> &cell_range)
const
831 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
835 phi.read_dof_values(src);
837 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
838 phi.submit_gradient(phi.get_gradient(q), q);
840 phi.distribute_local_to_global(dst);
849 const std::pair<unsigned int, unsigned int> &face_range)
const
854 for (
unsigned int face = face_range.first; face < face_range.second;
857 fe_eval.reinit(face);
858 fe_eval_neighbor.reinit(face);
860 fe_eval.read_dof_values(src);
863 fe_eval_neighbor.read_dof_values(src);
867 (
std::abs((fe_eval.normal_vector(0) *
868 fe_eval.inverse_jacobian(0))[dim - 1]) +
869 std::abs((fe_eval.normal_vector(0) *
870 fe_eval_neighbor.inverse_jacobian(0))[dim - 1])) *
873 for (
unsigned int q = 0; q < fe_eval.n_q_points; ++q)
876 (fe_eval.get_value(q) - fe_eval_neighbor.get_value(q)) * 0.5;
878 fe_eval.get_normal_derivative(q) +
879 fe_eval_neighbor.get_normal_derivative(q);
881 jump_value * 2. * sigmaF - average_valgrad * 0.5;
882 fe_eval.submit_normal_derivative(-jump_value, q);
883 fe_eval_neighbor.submit_normal_derivative(-jump_value, q);
884 fe_eval.submit_value(average_valgrad, q);
885 fe_eval_neighbor.submit_value(-average_valgrad, q);
889 fe_eval.distribute_local_to_global(dst);
892 fe_eval_neighbor.distribute_local_to_global(dst);
901 const std::pair<unsigned int, unsigned int> &face_range)
const
904 for (
unsigned int face = face_range.first; face < face_range.second;
907 fe_eval.reinit(face);
908 fe_eval.read_dof_values(src);
912 std::abs((fe_eval.normal_vector(0) *
913 fe_eval.inverse_jacobian(0))[dim - 1]) *
916 for (
unsigned int q = 0; q < fe_eval.n_q_points; ++q)
920 -fe_eval.get_normal_derivative(q);
921 average_valgrad += jump_value * sigmaF * 2.0;
922 fe_eval.submit_normal_derivative(-jump_value, q);
923 fe_eval.submit_value(average_valgrad, q);
928 fe_eval.distribute_local_to_global(dst);
937 const unsigned int &,
938 const std::pair<unsigned int, unsigned int> &cell_range)
const
944 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
949 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
951 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
953 phi.begin_dof_values()[i] = 1.;
955 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
956 phi.submit_gradient(phi.get_gradient(q), q);
958 local_diagonal_vector[i] = phi.begin_dof_values()[i];
960 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
961 phi.begin_dof_values()[i] = local_diagonal_vector[i];
962 phi.distribute_local_to_global(dst);
970 const unsigned int &,
971 const std::pair<unsigned int, unsigned int> &face_range)
const
978 for (
unsigned int face = face_range.first; face < face_range.second;
982 phi_outer.reinit(face);
986 (phi.normal_vector(0) * phi.inverse_jacobian(0))[dim - 1]) +
988 phi_outer.inverse_jacobian(0))[dim - 1])) *
992 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
996 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
998 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
1000 phi.begin_dof_values()[i] = 1.;
1004 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1007 (phi.get_value(q) - phi_outer.get_value(q)) * 0.5;
1009 phi.get_normal_derivative(q) +
1010 phi_outer.get_normal_derivative(q);
1012 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1013 phi.submit_normal_derivative(-jump_value, q);
1014 phi.submit_value(average_valgrad, q);
1018 local_diagonal_vector[i] = phi.begin_dof_values()[i];
1020 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1021 phi.begin_dof_values()[i] = local_diagonal_vector[i];
1022 phi.distribute_local_to_global(dst);
1025 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
1028 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1030 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
1032 phi_outer.begin_dof_values()[i] = 1.;
1036 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1039 (phi.get_value(q) - phi_outer.get_value(q)) * 0.5;
1041 phi.get_normal_derivative(q) +
1042 phi_outer.get_normal_derivative(q);
1044 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1045 phi_outer.submit_normal_derivative(-jump_value, q);
1046 phi_outer.submit_value(-average_valgrad, q);
1050 local_diagonal_vector[i] = phi_outer.begin_dof_values()[i];
1052 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1053 phi_outer.begin_dof_values()[i] = local_diagonal_vector[i];
1054 phi_outer.distribute_local_to_global(dst);
1062 const unsigned int &,
1063 const std::pair<unsigned int, unsigned int> &face_range)
const
1069 for (
unsigned int face = face_range.first; face < face_range.second;
1076 (phi.normal_vector(0) * phi.inverse_jacobian(0))[dim - 1]) *
1079 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1081 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
1083 phi.begin_dof_values()[i] = 1.;
1087 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1091 -phi.get_normal_derivative(q);
1092 average_valgrad += jump_value * sigmaF * 2.0;
1093 phi.submit_normal_derivative(-jump_value, q);
1094 phi.submit_value(average_valgrad, q);
1099 local_diagonal_vector[i] = phi.begin_dof_values()[i];
1101 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1102 phi.begin_dof_values()[i] = local_diagonal_vector[i];
1103 phi.distribute_local_to_global(dst);
1125 typename number =
double>
1153 "Degree of the operator must match the degree of the DoFHandler"));
1189 "Degree of the operator must match the degree of the DoFHandler"));
1207 fiber_constraints.
close();
1209 data.reinit(mapping,
1211 &fiber_dof_handler},
1212 std::vector<const AffineConstraints<number> *>{
1237 const unsigned int n_q = phi_fiber.
n_q_points;
1238 const unsigned int n_batches =
data.n_cell_batches();
1244 for (
unsigned int cell = 0; cell < n_batches; ++cell)
1247 const unsigned int base = cell * n_q;
1252 for (
unsigned int q = 0; q < n_q; ++q)
1257 for (
unsigned int q = 0; q < n_q; ++q)
1262 for (
unsigned int q = 0; q < n_q; ++q)
1266 for (
unsigned int q = 0; q < n_q; ++q)
1273 sq -= (fq * sq) * fq;
1275 nq -= (fq * nq) * fq;
1276 nq -= (sq * nq) * sq;
1288 const unsigned int n_fq = phi_face.
n_q_points;
1289 const unsigned int n_f_inner =
data.n_inner_face_batches();
1295 for (
unsigned int face = 0; face < n_f_inner; ++face)
1298 const unsigned int fbase = face * n_fq;
1303 for (
unsigned int q = 0; q < n_fq; ++q)
1308 for (
unsigned int q = 0; q < n_fq; ++q)
1313 for (
unsigned int q = 0; q < n_fq; ++q)
1317 for (
unsigned int q = 0; q < n_fq; ++q)
1324 sq -= (fq * sq) * fq;
1326 nq -= (fq * nq) * fq;
1327 nq -= (sq * nq) * sq;
1366 *
data.get_dof_info(0).vector_partitioner))
1369 src_copy.
reinit(
data.get_dof_info(0).vector_partitioner);
1376 *
data.get_dof_info(0).vector_partitioner))
1379 dst_copy.
reinit(
data.get_dof_info(0).vector_partitioner);
1398 return data.get_vector_partitioner()->size();
1404 return data.get_vector_partitioner()->size();
1408 el(
const unsigned int row,
const unsigned int col)
const
1413 ExcMessage(
"Matrix-free does not allow for entry access"));
1421 data.initialize_dof_vector(vector);
1428 return data.get_dof_handler();
1435 return data.get_dof_handler().get_triangulation();
1456 static_assert(dim != 3,
1457 "get_system_matrix() uses isotropic sigma and is only "
1458 "meant for the 2D example. Use the matrix-based "
1459 "assembly in monodomain_DG3D instead.");
1464 const auto cell_operation = [&](
auto &phi) {
1466 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1469 phi.submit_value(phi.get_value(q) *
factor, q);
1476 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
1482 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
1484 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
1487 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
1490 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
1492 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
1494 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1521 const auto &dof_handler =
data.get_dof_handler();
1525 dof_handler.locally_owned_mg_dofs(
data.get_mg_level()) :
1526 dof_handler.locally_owned_dofs(),
1527 data.get_task_info().communicator);
1532 data.get_mg_level(),
1566 static_assert(dim != 3,
1567 "get_system_matrix() uses isotropic sigma and is only "
1568 "meant for the 2D example. Use the matrix-based "
1569 "assembly in monodomain_DG3D instead.");
1574 const auto cell_operation = [&](
auto &phi) {
1576 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1578 phi.submit_value(phi.get_value(q) *
factor, q);
1584 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
1590 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
1592 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
1595 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
1598 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
1600 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
1602 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1617 ExcInternalError());
1623 const IndexSet system_relevant_set =
1629 system_relevant_set);
1634 system_partitioning,
1635 data.get_task_info().communicator,
1636 system_relevant_set);
1637 mg_matrix.
reinit(system_partitioning,
1639 data.get_task_info().communicator);
1661 unsigned int dummy = 0;
1669 for (
unsigned int i = 0;
1686 for (
unsigned int cell = 0; cell <
data.n_cell_batches(); ++cell)
1691 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1708 for (
unsigned int cell = 0; cell <
data.n_cell_batches(); ++cell)
1713 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1720 for (
unsigned int v = 0; v < VectorizedArray<number>::size();
1724 for (
unsigned int d = 0;
d < dim; ++
d)
1725 p[
d] = p_vect[
d][v];
1726 applied_current_value[v] = Iext.
value(p);
1732 applied_current_value,
1748 const std::pair<unsigned int, unsigned int> &cell_range)
const
1752 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
1758 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1774 const std::pair<unsigned int, unsigned int> &face_range)
const
1779 fe_eval_neighbor(
data,
false);
1781 for (
unsigned int face = face_range.first; face < face_range.second;
1785 fe_eval_neighbor.
reinit(face);
1801 for (
unsigned int q = 0; q < fe_eval.
n_q_points; ++q)
1803 const auto u_plus = fe_eval.
get_value(q);
1804 const auto u_minus = fe_eval_neighbor.
get_value(q);
1805 const auto jump_u = (u_plus - u_minus) * 0.5;
1810 const auto D_grad_plus =
1812 const auto D_grad_minus =
1816 const auto avg_D_grad_n =
1817 (D_grad_plus * normal + D_grad_minus * normal) * 0.5;
1825 const auto penalty_val = sigma_f * sigmaF * jump_u * 2.;
1827 fe_eval_neighbor.
submit_value(-penalty_val + avg_D_grad_n, q);
1847 const std::pair<unsigned int, unsigned int> &face_range)
const
1861 const unsigned int &,
1862 const std::pair<unsigned int, unsigned int> &cell_range)
const
1868 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
1880 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1900 const unsigned int &,
1901 const std::pair<unsigned int, unsigned int> &face_range)
const
1906 phi_outer(
data,
false);
1910 for (
unsigned int face = face_range.first; face < face_range.second;
1938 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1941 const auto u_minus = phi_outer.
get_value(q);
1942 const auto jump_u = (u_plus - u_minus) * 0.5;
1945 const auto D_grad_plus =
1947 const auto D_grad_minus =
1949 const auto avg_D_grad_n =
1950 (D_grad_plus * normal + D_grad_minus * normal) * 0.5;
1954 const auto penalty_val = sigma_f * sigmaF * jump_u * 2.;
1978 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1981 const auto u_minus = phi_outer.
get_value(q);
1982 const auto jump_u = (u_plus - u_minus) * 0.5;
1985 const auto D_grad_plus =
1987 const auto D_grad_minus =
1989 const auto avg_D_grad_n =
1990 (D_grad_plus * normal + D_grad_minus * normal) * 0.5;
1994 const auto penalty_val = sigma_f * sigmaF * jump_u * 2.;
1995 phi_outer.
submit_value(-penalty_val + avg_D_grad_n, q);
2012 const unsigned int &,
2013 const std::pair<unsigned int, unsigned int> &face_range)
const
2026 static_cast<unsigned int>(dim));
2031 static_cast<unsigned int>(dim - 1));
2041 const unsigned int cell,
2042 const unsigned int q)
const
2083 const unsigned int face,
2084 const unsigned int q)
const
2135 return std::distance(v.begin(), std::find(v.begin(), v.end(), index));
2146 Assert(cells.size() > 0, ExcMessage(
"No cells to be agglomerated."));
2147 const unsigned int n_faces = cells[0]->n_faces();
2149 std::vector<types::global_cell_index> vec_cells(cells.size());
2150 for (
size_t i = 0; i < cells.size(); i++)
2151 vec_cells[i] = cells[i]->active_cell_index();
2154 for (
const auto &cell : cells)
2160 g.
nodes.push_back(
get_index(vec_cells, cell->active_cell_index()));
2161 for (
unsigned int f = 0; f < n_faces; ++f)
2163 const auto &neigh = cell->neighbor(f);
2164 if (neigh.state() == IteratorState::IteratorStates::valid &&
2165 std::find(cells.begin(), cells.end(), neigh) != std::end(cells))
2167 .push_back(
get_index(vec_cells, neigh->active_cell_index()));
2175 dfs(std::vector<types::global_cell_index> &comp,
2176 std::vector<bool> &visited,
2185 dfs(comp, visited, g, u);
2194 std::vector<std::vector<types::global_cell_index>> &connected_components)
2196 Assert(g.
nodes.size() > 0, ExcMessage(
"No nodes in this graph."));
2198 connected_components.size() == 0,
2200 "Connected components have to be computed by the present function."));
2202 std::vector<bool> visited(g.
nodes.size());
2203 std::fill(visited.begin(), visited.end(), 0);
2210 connected_components.emplace_back();
2211 dfs(connected_components.back(), visited, g, v);
void distribute_local_to_global(const InVector &local_vector, const std::vector< size_type > &local_dof_indices, OutVector &global_vector) const
void resize(const size_type new_size)
Point< spacedim, Number > real_to_unit(const Point< spacedim, Number > &point) const
Point< spacedim, Number > unit_to_real(const Point< spacedim, Number > &point) const
const FiniteElement< dim, spacedim > & get_fe(const types::fe_index index=0) const
const IndexSet & locally_owned_dofs() const
types::global_dof_index n_dofs() const
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
gradient_type get_gradient(const unsigned int q_point) const
void submit_gradient(const gradient_type grad_in, const unsigned int q_point)
void submit_value(const value_type val_in, const unsigned int q_point)
void distribute_local_to_global(VectorType &dst, const unsigned int first_index=0, const std::bitset< n_lanes > &mask=std::bitset< n_lanes >().flip()) const
void read_dof_values_plain(const VectorType &src, const unsigned int first_index=0, const std::bitset< n_lanes > &mask=std::bitset< n_lanes >().flip())
value_type get_value(const unsigned int q_point) const
void read_dof_values(const VectorType &src, const unsigned int first_index=0, const std::bitset< n_lanes > &mask=std::bitset< n_lanes >().flip())
Tensor< 2, dim, VectorizedArrayType > inverse_jacobian(const unsigned int q_point) const
Tensor< 1, dim, VectorizedArrayType > normal_vector(const unsigned int q_point) const
Point< dim, VectorizedArrayType > quadrature_point(const unsigned int q) const
const VectorizedArrayType * begin_dof_values() const
const unsigned int n_q_points
void reinit(const unsigned int cell_batch_index)
void evaluate(const EvaluationFlags::EvaluationFlags evaluation_flag)
const unsigned int dofs_per_cell
void integrate(const EvaluationFlags::EvaluationFlags integration_flag)
void reinit(const unsigned int face_batch_number)
const unsigned int n_q_points
const unsigned int dofs_per_cell
void evaluate(const EvaluationFlags::EvaluationFlags evaluation_flag)
void integrate(const EvaluationFlags::EvaluationFlags integration_flag, const bool sum_into_values=false)
const unsigned int degree
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 RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
void zero_out_ghost_values() const
Number local_element(const size_type local_index) const
void update_ghost_values() const
size_type locally_owned_size() const
void swap(Vector< Number, MemorySpace > &v) noexcept
void compress(VectorOperation::values operation)
bool partitioners_are_globally_compatible(const Utilities::MPI::Partitioner &part) const
void copy_locally_owned_data_from(const Vector< Number2, MemorySpace > &src)
void reinit(const size_type size, const bool omit_zeroing_entries=false)
void copy_from(const size_type n_rows, const size_type n_cols, const ForwardIterator begin, const ForwardIterator end)
virtual MPI_Comm get_mpi_communicator() const
void reinit(const SparsityPatternType &sparsity_pattern)
const DoFHandler< dim, spacedim >::active_cell_iterator polytope_to_dh_iterator(const types::global_cell_index polytope_index) const
types::global_dof_index n_dofs() const noexcept
const Triangulation< dim, spacedim > & get_triangulation() const
const Mapping< dim > & get_mapping() const
const std::vector< BoundingBox< dim > > & get_local_bboxes() const
const FiniteElement< dim, spacedim > & get_fe() const
IteratorRange< agglomeration_iterator > polytope_iterators() const
DoFHandler< dim, spacedim > agglo_dh
~MGCoarseDirect()=default
const MatrixType & coarse_matrix
MGCoarseDirect(const MatrixType &matrix)
void operator()(const unsigned int, VectorType &dst, const VectorType &src) const override
void Tvmult(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
LinearAlgebra::distributed::Vector< number > inverse_diagonal_entries
AffineConstraints< number > constraints
void rhs(LinearAlgebra::distributed::Vector< number > &b) const
void vmult_add(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
void local_diagonal_face(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const unsigned int &, const std::pair< unsigned int, unsigned int > &face_range) const
void local_diagonal_boundary(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const unsigned int &, const std::pair< unsigned int, unsigned int > &face_range) const
TrilinosWrappers::SparseMatrix system_matrix
number el(const unsigned int row, const unsigned int col) const
void initialize_dof_vector(LinearAlgebra::distributed::Vector< number > &vector) const
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const unsigned int level=numbers::invalid_unsigned_int)
VectorizedArray< number > VectorizedArrayType
const Triangulation< dim > & get_triangulation() const
MatrixFree< dim, number > data
const LinearAlgebra::distributed::Vector< number > & get_matrix_diagonal_inverse() const
const DoFHandler< dim > & get_dof_handler() const
const MatrixFree< dim, number > * get_matrix_free() const
void local_diagonal_cell(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const unsigned int &, const std::pair< unsigned int, unsigned int > &cell_range) const
void vmult(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
void get_system_matrix(TrilinosWrappers::SparseMatrix &mg_matrix) const
void compute_inverse_diagonal()
void local_apply_boundary(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src, const std::pair< unsigned int, unsigned int > &face_range) const
types::global_dof_index n() const
const TrilinosWrappers::SparseMatrix & get_system_matrix() const
void Tvmult_add(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
LinearAlgebra::distributed::Vector< number > VectorType
types::global_dof_index m() const
void local_apply(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src, const std::pair< unsigned int, unsigned int > &cell_range) const
void local_apply_face(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src, const std::pair< unsigned int, unsigned int > &face_range) const
Tensor< 1, dim, VectorizedArrayType > apply_diffusion(const Tensor< 1, dim, VectorizedArrayType > &grad, const unsigned int cell, const unsigned int q) const
Physics::BilinearFormParameters parameters
void compute_inverse_diagonal()
AlignedVector< Tensor< 1, dim, VectorizedArrayType > > FiberArray
void rhs(LinearAlgebra::distributed::Vector< number > &rhs, const LinearAlgebra::distributed::Vector< number > &solution_minus_ion, const Function< dim > &Iext) const
MonodomainOperatorDG(const Physics::BilinearFormParameters ¶meters_)
const DoFHandler< dim > & get_dof_handler() const
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const DoFHandler< dim > &fiber_dof_handler, const unsigned int level=numbers::invalid_unsigned_int)
void local_apply_face(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src, const std::pair< unsigned int, unsigned int > &face_range) const
void local_apply(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src, const std::pair< unsigned int, unsigned int > &cell_range) const
Tensor< 1, dim, VectorizedArrayType > apply_diffusion_face(const Tensor< 1, dim, VectorizedArrayType > &vec, const unsigned int face, const unsigned int q) const
const LinearAlgebra::distributed::Vector< number > & get_matrix_diagonal_inverse() const
void local_diagonal_face(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const unsigned int &, const std::pair< unsigned int, unsigned int > &face_range) const
const MatrixFree< dim, number > * get_matrix_free() const
MatrixFree< dim, number > data
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const unsigned int level=numbers::invalid_unsigned_int)
FiberArray fiber_s_face_data
TrilinosWrappers::SparseMatrix system_matrix
LinearAlgebra::distributed::Vector< number > inverse_diagonal_entries
void local_diagonal_cell(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const unsigned int &, const std::pair< unsigned int, unsigned int > &cell_range) const
VectorizedArray< number > VectorizedArrayType
AffineConstraints< number > constraints
void Tvmult_add(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
static constexpr unsigned int n_face_q_points_total
void apply_mass_term(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
const TrilinosWrappers::SparseMatrix & get_system_matrix() const
number el(const unsigned int row, const unsigned int col) const
LinearAlgebra::distributed::Vector< number > VectorType
types::global_dof_index m() const
void local_apply_boundary(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src, const std::pair< unsigned int, unsigned int > &face_range) const
void precompute_fibers(const LinearAlgebra::distributed::Vector< number > &f0, const LinearAlgebra::distributed::Vector< number > &s0, const LinearAlgebra::distributed::Vector< number > &n0)
void get_system_matrix(TrilinosWrappers::SparseMatrix &mg_matrix) const
number face_sigma() const
FiberArray fiber_n_face_data
void local_diagonal_boundary(const MatrixFree< dim, number > &data, LinearAlgebra::distributed::Vector< number > &dst, const unsigned int &, const std::pair< unsigned int, unsigned int > &face_range) const
void vmult_add(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
void vmult(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
types::global_dof_index n() const
void initialize_dof_vector(LinearAlgebra::distributed::Vector< number > &vector) const
void Tvmult(LinearAlgebra::distributed::Vector< number > &dst, const LinearAlgebra::distributed::Vector< number > &src) const
FiberArray fiber_f_face_data
static constexpr unsigned int n_q_points_total
const Triangulation< dim > & get_triangulation() const
#define DEAL_II_NOT_IMPLEMENTED()
#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
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 > e(const Tensor< 2, dim, Number > &F)
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)
void create_graph_from_agglomerate(const std::vector< typename Triangulation< dim >::active_cell_iterator > &cells, Graph &g)
void dfs(std::vector< types::global_cell_index > &comp, std::vector< bool > &visited, const Graph &g, const types::global_cell_index v)
constexpr T constexpr_pow(T num, unsigned int pow)
void fill_injection_matrix(const AgglomerationHandler< dim, spacedim > &coarse_ah, const AgglomerationHandler< dim, spacedim > &fine_ah, SparsityPattern &sp, MatrixType &matrix)
void compute_connected_components(Graph &g, std::vector< std::vector< types::global_cell_index > > &connected_components)
types::global_cell_index get_index(const std::vector< types::global_cell_index > &v, const types::global_cell_index index)
constexpr unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
unsigned int global_dof_index
unsigned int global_cell_index
void swap(ObserverPointer< T, P > &t1, ObserverPointer< T, Q > &t2)
TasksParallelScheme tasks_parallel_scheme
UpdateFlags mapping_update_flags_inner_faces
UpdateFlags mapping_update_flags_boundary_faces
UpdateFlags mapping_update_flags
unsigned int tasks_block_size
std::vector< std::vector< types::global_cell_index > > adjacency
std::vector< types::global_cell_index > nodes