39template <
int dim,
typename RtreeType>
52 return (
pow >=
sizeof(
unsigned int) * 8) ? 0 :
65 std::vector<types::global_cell_index>
nodes;
66 std::vector<std::vector<types::global_cell_index>>
adjacency;
71 std::cout <<
"Graph information" << std::endl;
72 for (
const auto &node :
nodes)
74 std::cout <<
"Neighbors for node " << node << std::endl;
75 for (
const auto &neigh_node :
adjacency[node])
76 std::cout << neigh_node << std::endl;
95 template <
int dim,
int spacedim,
typename MatrixType>
102 using NumberType =
typename MatrixType::value_type;
104 static constexpr bool is_trilinos_matrix =
105 std::is_same_v<TrilinosWrappers::SparseMatrix, MatrixType>;
106 static constexpr bool is_serial_matrix =
107 std::is_same_v<SparseMatrix<NumberType>, MatrixType>;
108 static constexpr bool is_supported_matrix =
109 is_trilinos_matrix || is_serial_matrix;
110 static_assert(is_supported_matrix);
111 if constexpr (is_trilinos_matrix)
112 Assert(matrix.m() == 0, ExcInternalError());
113 if constexpr (is_serial_matrix)
116 "The destination matrix and its sparsity pattern must the empty "
117 "upon calling this function."));
132 const IndexSet &locally_owned_dofs_fine =
134 const IndexSet locally_relevant_dofs_fine =
137 const IndexSet &locally_owned_dofs_coarse =
140 std::conditional_t<is_trilinos_matrix,
145 if constexpr (is_trilinos_matrix)
146 dsp.
reinit(locally_owned_dofs_fine,
147 locally_owned_dofs_coarse,
150 dsp.reinit(fine_agglo_dh.
n_dofs(),
152 locally_relevant_dofs_fine);
155 std::vector<types::global_dof_index> agglo_dof_indices(dofs_per_cell);
156 std::vector<types::global_dof_index> standard_dof_indices(dofs_per_cell);
157 std::vector<types::global_dof_index> output_dof_indices(dofs_per_cell);
159 const std::vector<Point<dim>> &unit_support_points =
167 std::vector<types::global_dof_index> local_dof_indices_coarse(
169 std::vector<types::global_dof_index> local_dof_indices_child(dofs_per_cell);
172 if (polytope->is_locally_owned())
174 polytope->get_dof_indices(local_dof_indices_coarse);
177 const auto &children_polytopes = polytope->children();
182 child_dh->get_dof_indices(local_dof_indices_child);
183 for (
const auto row : local_dof_indices_child)
185 local_dof_indices_coarse.begin(),
186 local_dof_indices_coarse.end());
190 const auto assemble_injection_matrix = [&]() {
192 std::vector<Point<dim>> reference_q_points(dofs_per_cell);
199 if (polytope->is_locally_owned())
201 polytope->get_dof_indices(local_dof_indices_coarse);
203 coarse_bboxes[polytope->index()];
206 const auto &children_polytopes = polytope->children();
212 child_dh->get_dof_indices(local_dof_indices_child);
217 std::vector<Point<dim>> real_qpoints;
218 real_qpoints.reserve(unit_support_points.size());
219 for (
const Point<dim> &p : unit_support_points)
222 for (
unsigned int i = 0; i < local_dof_indices_coarse.size();
225 const auto &p = coarse_bbox.
real_to_unit(real_qpoints[i]);
226 for (
unsigned int j = 0; j < local_dof_indices_child.size();
234 local_dof_indices_child,
235 local_dof_indices_coarse,
242 if constexpr (is_trilinos_matrix)
246 assemble_injection_matrix();
248 else if constexpr (is_serial_matrix)
252 assemble_injection_matrix();
263 "This injection does not support PETSc types."));
286 template <
typename VectorType,
typename MatrixType,
typename SolverType>
295 static constexpr bool is_serial_matrix =
296 std::is_same_v<SolverType, SparseDirectUMFPACK>;
297 static constexpr bool is_trilinos_matrix =
298 std::is_same_v<SolverType, TrilinosWrappers::SolverDirect>;
299 [[maybe_unused]]
static constexpr bool is_matrix_type_supported =
300 is_serial_matrix || is_trilinos_matrix;
301 Assert(is_matrix_type_supported, ExcNotImplemented());
305 if constexpr (is_serial_matrix)
308 std::is_same_v<VectorType,
309 dealii::Vector<typename MatrixType::value_type>>;
312 else if constexpr (is_trilinos_matrix)
314 [[maybe_unused]]
static constexpr bool is_supported_parallel_vector =
315 std::is_same_v<VectorType,
317 typename MatrixType::value_type>> ||
318 std::is_same_v<VectorType, TrilinosWrappers::MPI::Vector>;
319 Assert(is_supported_parallel_vector, ExcNotImplemented());
337 const VectorType &src)
const override
391 typename number =
double>
454 *
data.get_dof_info(0).vector_partitioner))
457 src_copy.
reinit(
data.get_dof_info().vector_partitioner);
463 *
data.get_dof_info(0).vector_partitioner))
466 dst_copy.
reinit(
data.get_dof_info().vector_partitioner);
482 return data.get_vector_partitioner()->size();
488 return data.get_vector_partitioner()->size();
492 el(
const unsigned int row,
const unsigned int col)
const
497 ExcMessage(
"Matrix-free does not allow for entry access"));
505 data.initialize_dof_vector(vector);
512 return data.get_dof_handler();
519 return data.get_dof_handler().get_triangulation();
542 const auto cell_operation = [&](
auto &phi) {
544 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
545 phi.submit_gradient(phi.get_gradient(q), q);
549 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
555 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
557 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
560 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
563 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
565 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
567 jump_value * 2. * sigmaF - average_valgrad * 0.5;
568 phi_m.submit_normal_derivative(-jump_value, q);
569 phi_p.submit_normal_derivative(-jump_value, q);
570 phi_m.submit_value(average_valgrad, q);
571 phi_p.submit_value(-average_valgrad, q);
577 const auto boundary_operation = [&](
auto &phi_m) {
581 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) *
584 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
588 -phi_m.get_normal_derivative(q);
589 average_valgrad += jump_value * sigmaF * 2.0;
590 phi_m.submit_normal_derivative(-jump_value, q);
591 phi_m.submit_value(average_valgrad, q);
605 const auto &dof_handler =
data.get_dof_handler();
609 dof_handler.locally_owned_mg_dofs(
data.get_mg_level()) :
610 dof_handler.locally_owned_dofs(),
611 data.get_task_info().communicator);
652 const auto cell_operation = [&](
auto &phi) {
654 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
655 phi.submit_gradient(phi.get_gradient(q), q);
659 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
665 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
667 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
670 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
673 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
675 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
677 jump_value * 2. * sigmaF - average_valgrad * 0.5;
678 phi_m.submit_normal_derivative(-jump_value, q);
679 phi_p.submit_normal_derivative(-jump_value, q);
680 phi_m.submit_value(average_valgrad, q);
681 phi_p.submit_value(-average_valgrad, q);
687 const auto boundary_operation = [&](
auto &phi_m) {
691 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) *
694 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
698 -phi_m.get_normal_derivative(q);
699 average_valgrad += jump_value * sigmaF * 2.0;
700 phi_m.submit_normal_derivative(-jump_value, q);
701 phi_m.submit_value(average_valgrad, q);
718 const IndexSet system_relevant_set =
724 system_relevant_set);
730 data.get_task_info().communicator,
731 system_relevant_set);
732 mg_matrix.
reinit(system_partitioning,
734 data.get_task_info().communicator);
760 .template cell_loop<LinearAlgebra::distributed::Vector<number>,
int>(
761 [](
const auto &matrix_free,
765 FEEvaluation<dim, -1, 0, n_components, number> phi(matrix_free,
767 for (
unsigned int cell = cells.first; cell < cells.second; ++cell)
770 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
772 if constexpr (n_components == 1)
774 phi.submit_value(1.0, q);
779 for (
unsigned int v = 0;
780 v < VectorizedArray<number>::size();
783 for (
unsigned int i = 0; i < n_components; i++)
786 phi.submit_value(temp, q);
804 unsigned int dummy = 0;
812 for (
unsigned int i = 0;
826 const std::pair<unsigned int, unsigned int> &cell_range)
const
830 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
834 phi.read_dof_values(src);
836 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
837 phi.submit_gradient(phi.get_gradient(q), q);
839 phi.distribute_local_to_global(dst);
848 const std::pair<unsigned int, unsigned int> &face_range)
const
853 for (
unsigned int face = face_range.first; face < face_range.second;
856 fe_eval.reinit(face);
857 fe_eval_neighbor.reinit(face);
859 fe_eval.read_dof_values(src);
862 fe_eval_neighbor.read_dof_values(src);
866 (
std::abs((fe_eval.normal_vector(0) *
867 fe_eval.inverse_jacobian(0))[dim - 1]) +
868 std::abs((fe_eval.normal_vector(0) *
869 fe_eval_neighbor.inverse_jacobian(0))[dim - 1])) *
872 for (
unsigned int q = 0; q < fe_eval.n_q_points; ++q)
875 (fe_eval.get_value(q) - fe_eval_neighbor.get_value(q)) * 0.5;
877 fe_eval.get_normal_derivative(q) +
878 fe_eval_neighbor.get_normal_derivative(q);
880 jump_value * 2. * sigmaF - average_valgrad * 0.5;
881 fe_eval.submit_normal_derivative(-jump_value, q);
882 fe_eval_neighbor.submit_normal_derivative(-jump_value, q);
883 fe_eval.submit_value(average_valgrad, q);
884 fe_eval_neighbor.submit_value(-average_valgrad, q);
888 fe_eval.distribute_local_to_global(dst);
891 fe_eval_neighbor.distribute_local_to_global(dst);
900 const std::pair<unsigned int, unsigned int> &face_range)
const
903 for (
unsigned int face = face_range.first; face < face_range.second;
906 fe_eval.reinit(face);
907 fe_eval.read_dof_values(src);
911 std::abs((fe_eval.normal_vector(0) *
912 fe_eval.inverse_jacobian(0))[dim - 1]) *
915 for (
unsigned int q = 0; q < fe_eval.n_q_points; ++q)
919 -fe_eval.get_normal_derivative(q);
920 average_valgrad += jump_value * sigmaF * 2.0;
921 fe_eval.submit_normal_derivative(-jump_value, q);
922 fe_eval.submit_value(average_valgrad, q);
927 fe_eval.distribute_local_to_global(dst);
936 const unsigned int &,
937 const std::pair<unsigned int, unsigned int> &cell_range)
const
943 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
948 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
950 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
952 phi.begin_dof_values()[i] = 1.;
954 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
955 phi.submit_gradient(phi.get_gradient(q), q);
957 local_diagonal_vector[i] = phi.begin_dof_values()[i];
959 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
960 phi.begin_dof_values()[i] = local_diagonal_vector[i];
961 phi.distribute_local_to_global(dst);
969 const unsigned int &,
970 const std::pair<unsigned int, unsigned int> &face_range)
const
977 for (
unsigned int face = face_range.first; face < face_range.second;
981 phi_outer.reinit(face);
985 (phi.normal_vector(0) * phi.inverse_jacobian(0))[dim - 1]) +
987 phi_outer.inverse_jacobian(0))[dim - 1])) *
991 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
995 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
997 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
999 phi.begin_dof_values()[i] = 1.;
1003 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1006 (phi.get_value(q) - phi_outer.get_value(q)) * 0.5;
1008 phi.get_normal_derivative(q) +
1009 phi_outer.get_normal_derivative(q);
1011 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1012 phi.submit_normal_derivative(-jump_value, q);
1013 phi.submit_value(average_valgrad, q);
1017 local_diagonal_vector[i] = phi.begin_dof_values()[i];
1019 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1020 phi.begin_dof_values()[i] = local_diagonal_vector[i];
1021 phi.distribute_local_to_global(dst);
1024 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
1027 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1029 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
1031 phi_outer.begin_dof_values()[i] = 1.;
1035 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1038 (phi.get_value(q) - phi_outer.get_value(q)) * 0.5;
1040 phi.get_normal_derivative(q) +
1041 phi_outer.get_normal_derivative(q);
1043 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1044 phi_outer.submit_normal_derivative(-jump_value, q);
1045 phi_outer.submit_value(-average_valgrad, q);
1049 local_diagonal_vector[i] = phi_outer.begin_dof_values()[i];
1051 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1052 phi_outer.begin_dof_values()[i] = local_diagonal_vector[i];
1053 phi_outer.distribute_local_to_global(dst);
1061 const unsigned int &,
1062 const std::pair<unsigned int, unsigned int> &face_range)
const
1068 for (
unsigned int face = face_range.first; face < face_range.second;
1075 (phi.normal_vector(0) * phi.inverse_jacobian(0))[dim - 1]) *
1078 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1080 for (
unsigned int j = 0; j < phi.dofs_per_cell; ++j)
1082 phi.begin_dof_values()[i] = 1.;
1086 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1090 -phi.get_normal_derivative(q);
1091 average_valgrad += jump_value * sigmaF * 2.0;
1092 phi.submit_normal_derivative(-jump_value, q);
1093 phi.submit_value(average_valgrad, q);
1098 local_diagonal_vector[i] = phi.begin_dof_values()[i];
1100 for (
unsigned int i = 0; i < phi.dofs_per_cell; ++i)
1101 phi.begin_dof_values()[i] = local_diagonal_vector[i];
1102 phi.distribute_local_to_global(dst);
1124 typename number =
double>
1152 "Degree of the operator must match the degree of the DoFHandler"));
1188 "Degree of the operator must match the degree of the DoFHandler"));
1206 fiber_constraints.
close();
1208 data.reinit(mapping,
1210 &fiber_dof_handler},
1211 std::vector<const AffineConstraints<number> *>{
1236 const unsigned int n_q = phi_fiber.
n_q_points;
1237 const unsigned int n_batches =
data.n_cell_batches();
1243 for (
unsigned int cell = 0; cell < n_batches; ++cell)
1246 const unsigned int base = cell * n_q;
1251 for (
unsigned int q = 0; q < n_q; ++q)
1256 for (
unsigned int q = 0; q < n_q; ++q)
1261 for (
unsigned int q = 0; q < n_q; ++q)
1265 for (
unsigned int q = 0; q < n_q; ++q)
1272 sq -= (fq * sq) * fq;
1274 nq -= (fq * nq) * fq;
1275 nq -= (sq * nq) * sq;
1287 const unsigned int n_fq = phi_face.
n_q_points;
1288 const unsigned int n_f_inner =
data.n_inner_face_batches();
1294 for (
unsigned int face = 0; face < n_f_inner; ++face)
1297 const unsigned int fbase = face * n_fq;
1302 for (
unsigned int q = 0; q < n_fq; ++q)
1307 for (
unsigned int q = 0; q < n_fq; ++q)
1312 for (
unsigned int q = 0; q < n_fq; ++q)
1316 for (
unsigned int q = 0; q < n_fq; ++q)
1323 sq -= (fq * sq) * fq;
1325 nq -= (fq * nq) * fq;
1326 nq -= (sq * nq) * sq;
1365 *
data.get_dof_info(0).vector_partitioner))
1368 src_copy.
reinit(
data.get_dof_info(0).vector_partitioner);
1375 *
data.get_dof_info(0).vector_partitioner))
1378 dst_copy.
reinit(
data.get_dof_info(0).vector_partitioner);
1397 return data.get_vector_partitioner()->size();
1403 return data.get_vector_partitioner()->size();
1407 el(
const unsigned int row,
const unsigned int col)
const
1412 ExcMessage(
"Matrix-free does not allow for entry access"));
1420 data.initialize_dof_vector(vector);
1427 return data.get_dof_handler();
1434 return data.get_dof_handler().get_triangulation();
1455 static_assert(dim != 3,
1456 "get_system_matrix() uses isotropic sigma and is only "
1457 "meant for the 2D example. Use the matrix-based "
1458 "assembly in monodomain_DG3D instead.");
1463 const auto cell_operation = [&](
auto &phi) {
1465 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1468 phi.submit_value(phi.get_value(q) *
factor, q);
1470 phi.submit_gradient(phi.get_gradient(q) *
parameters.sigma, q);
1475 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
1481 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
1483 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
1486 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
1489 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
1491 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
1493 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1494 phi_m.submit_normal_derivative(-
parameters.sigma * jump_value, q);
1495 phi_p.submit_normal_derivative(-
parameters.sigma * jump_value, q);
1496 phi_m.submit_value(
parameters.sigma * average_valgrad, q);
1497 phi_p.submit_value(-
parameters.sigma * average_valgrad, q);
1520 const auto &dof_handler =
data.get_dof_handler();
1524 dof_handler.locally_owned_mg_dofs(
data.get_mg_level()) :
1525 dof_handler.locally_owned_dofs(),
1526 data.get_task_info().communicator);
1531 data.get_mg_level(),
1565 static_assert(dim != 3,
1566 "get_system_matrix() uses isotropic sigma and is only "
1567 "meant for the 2D example. Use the matrix-based "
1568 "assembly in monodomain_DG3D instead.");
1573 const auto cell_operation = [&](
auto &phi) {
1575 for (
unsigned int q = 0; q < phi.n_q_points; ++q)
1577 phi.submit_value(phi.get_value(q) *
factor, q);
1578 phi.submit_gradient(phi.get_gradient(q) *
parameters.sigma, q);
1583 const auto face_operation = [&](
auto &phi_m,
auto &phi_p) {
1589 (phi_m.normal_vector(0) * phi_m.inverse_jacobian(0))[dim - 1]) +
1591 (phi_m.normal_vector(0) * phi_p.inverse_jacobian(0))[dim - 1])) *
1594 for (
unsigned int q = 0; q < phi_m.n_q_points; ++q)
1597 (phi_m.get_value(q) - phi_p.get_value(q)) * 0.5;
1599 phi_m.get_normal_derivative(q) + phi_p.get_normal_derivative(q);
1601 jump_value * 2. * sigmaF - average_valgrad * 0.5;
1602 phi_m.submit_normal_derivative(-
parameters.sigma * jump_value, q);
1603 phi_p.submit_normal_derivative(-
parameters.sigma * jump_value, q);
1604 phi_m.submit_value(
parameters.sigma * average_valgrad, q);
1605 phi_p.submit_value(-
parameters.sigma * average_valgrad, q);
1616 ExcInternalError());
1622 const IndexSet system_relevant_set =
1628 system_relevant_set);
1633 system_partitioning,
1634 data.get_task_info().communicator,
1635 system_relevant_set);
1636 mg_matrix.
reinit(system_partitioning,
1638 data.get_task_info().communicator);
1660 unsigned int dummy = 0;
1668 for (
unsigned int i = 0;
1685 for (
unsigned int cell = 0; cell <
data.n_cell_batches(); ++cell)
1690 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1707 for (
unsigned int cell = 0; cell <
data.n_cell_batches(); ++cell)
1712 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1719 for (
unsigned int v = 0; v < VectorizedArray<number>::size();
1723 for (
unsigned int d = 0;
d < dim; ++
d)
1724 p[
d] = p_vect[
d][v];
1725 applied_current_value[v] = Iext.
value(p);
1731 applied_current_value,
1747 const std::pair<unsigned int, unsigned int> &cell_range)
const
1751 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
1757 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1773 const std::pair<unsigned int, unsigned int> &face_range)
const
1778 fe_eval_neighbor(
data,
false);
1780 for (
unsigned int face = face_range.first; face < face_range.second;
1784 fe_eval_neighbor.
reinit(face);
1800 for (
unsigned int q = 0; q < fe_eval.
n_q_points; ++q)
1802 const auto u_plus = fe_eval.
get_value(q);
1803 const auto u_minus = fe_eval_neighbor.
get_value(q);
1804 const auto jump_u = (u_plus - u_minus) * 0.5;
1809 const auto D_grad_plus =
1811 const auto D_grad_minus =
1815 const auto avg_D_grad_n =
1816 (D_grad_plus * normal + D_grad_minus * normal) * 0.5;
1824 const auto penalty_val = sigma_f * sigmaF * jump_u * 2.;
1826 fe_eval_neighbor.
submit_value(-penalty_val + avg_D_grad_n, q);
1846 const std::pair<unsigned int, unsigned int> &face_range)
const
1860 const unsigned int &,
1861 const std::pair<unsigned int, unsigned int> &cell_range)
const
1867 for (
unsigned int cell = cell_range.first; cell < cell_range.second;
1879 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1899 const unsigned int &,
1900 const std::pair<unsigned int, unsigned int> &face_range)
const
1905 phi_outer(
data,
false);
1909 for (
unsigned int face = face_range.first; face < face_range.second;
1937 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1940 const auto u_minus = phi_outer.
get_value(q);
1941 const auto jump_u = (u_plus - u_minus) * 0.5;
1944 const auto D_grad_plus =
1946 const auto D_grad_minus =
1948 const auto avg_D_grad_n =
1949 (D_grad_plus * normal + D_grad_minus * normal) * 0.5;
1953 const auto penalty_val = sigma_f * sigmaF * jump_u * 2.;
1977 for (
unsigned int q = 0; q < phi.
n_q_points; ++q)
1980 const auto u_minus = phi_outer.
get_value(q);
1981 const auto jump_u = (u_plus - u_minus) * 0.5;
1984 const auto D_grad_plus =
1986 const auto D_grad_minus =
1988 const auto avg_D_grad_n =
1989 (D_grad_plus * normal + D_grad_minus * normal) * 0.5;
1993 const auto penalty_val = sigma_f * sigmaF * jump_u * 2.;
1994 phi_outer.
submit_value(-penalty_val + avg_D_grad_n, q);
2011 const unsigned int &,
2012 const std::pair<unsigned int, unsigned int> &face_range)
const
2025 static_cast<unsigned int>(dim));
2030 static_cast<unsigned int>(dim - 1));
2040 const unsigned int cell,
2041 const unsigned int q)
const
2082 const unsigned int face,
2083 const unsigned int q)
const
2134 return std::distance(v.begin(), std::find(v.begin(), v.end(), index));
2145 Assert(cells.size() > 0, ExcMessage(
"No cells to be agglomerated."));
2146 const unsigned int n_faces = cells[0]->n_faces();
2148 std::vector<types::global_cell_index> vec_cells(cells.size());
2149 for (
size_t i = 0; i < cells.size(); i++)
2150 vec_cells[i] = cells[i]->active_cell_index();
2153 for (
const auto &cell : cells)
2159 g.
nodes.push_back(
get_index(vec_cells, cell->active_cell_index()));
2160 for (
unsigned int f = 0; f < n_faces; ++f)
2162 const auto &neigh = cell->neighbor(f);
2163 if (neigh.state() == IteratorState::IteratorStates::valid &&
2164 std::find(cells.begin(), cells.end(), neigh) != std::end(cells))
2166 .push_back(
get_index(vec_cells, neigh->active_cell_index()));
2174 dfs(std::vector<types::global_cell_index> &comp,
2175 std::vector<bool> &visited,
2184 dfs(comp, visited, g, u);
2193 std::vector<std::vector<types::global_cell_index>> &connected_components)
2195 Assert(g.
nodes.size() > 0, ExcMessage(
"No nodes in this graph."));
2197 connected_components.size() == 0,
2199 "Connected components have to be computed by the present function."));
2201 std::vector<bool> visited(g.
nodes.size());
2202 std::fill(visited.begin(), visited.end(), 0);
2209 connected_components.emplace_back();
2210 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
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
void update_ghost_values() 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
EnableObserverPointer Subscriptor
#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