528 *
double return_value = 0.0;
532 * return_value = 24.0 *
std::pow(p(1) * (1.0 - p(1)), 2) +
533 * +24.0 *
std::pow(p(0) * (1.0 - p(0)), 2) +
534 * 2.0 * (2.0 - 12.0 * p(0) + 12.0 * p(0) * p(0)) *
535 * (2.0 - 12.0 * p(1) + 12.0 * p(1) * p(1));
540 * 24.0 *
std::pow(p(1) * (1.0 - p(1)) * p(2) * (1.0 - p(2)), 2) +
541 * 24.0 *
std::pow(p(0) * (1.0 - p(0)) * p(2) * (1.0 - p(2)), 2) +
542 * 24.0 *
std::pow(p(0) * (1.0 - p(0)) * p(1) * (1.0 - p(1)), 2) +
543 * 2.0 * (2.0 - 12.0 * p(0) + 12.0 * p(0) * p(0)) *
544 * (2.0 - 12.0 * p(1) + 12.0 * p(1) * p(1)) *
545 *
std::pow(p(2) * (1.0 - p(2)), 2) +
546 * 2.0 * (2.0 - 12.0 * p(0) + 12.0 * p(0) * p(0)) *
547 * (2.0 - 12.0 * p(2) + 12.0 * p(2) * p(2)) *
548 *
std::pow(p(1) * (1.0 - p(1)), 2) +
549 * 2.0 * (2.0 - 12.0 * p(1) + 12.0 * p(1) * p(1)) *
550 * (2.0 - 12.0 * p(2) + 12.0 * p(2) * p(2)) *
554 *
Assert(
false, ExcNotImplemented());
556 *
return return_value;
563 * This
class implement the manufactured (exact) solution @f$u@f$. To compute the
564 * errors, we need the
value of @f$u@f$ as well as its
gradient and its Hessian.
568 *
class ExactSolution :
public Function<dim>
576 *
const unsigned int component = 0)
const override;
580 *
const unsigned int component = 0)
const override;
584 *
const unsigned int component = 0)
const override;
590 *
double ExactSolution<dim>::value(
const Point<dim> &p,
591 *
const unsigned int )
const
593 *
double return_value = 0.0;
597 * return_value =
std::pow(p(0) * (1.0 - p(0)) * p(1) * (1.0 - p(1)), 2);
601 * return_value =
std::pow(p(0) * (1.0 - p(0)) * p(1) * (1.0 - p(1)) *
602 * p(2) * (1.0 - p(2)),
606 *
Assert(
false, ExcNotImplemented());
608 *
return return_value;
615 * ExactSolution<dim>::gradient(
const Point<dim> &p,
616 *
const unsigned int )
const
622 * return_gradient[0] =
625 * return_gradient[1] =
631 * return_gradient[0] =
633 *
std::pow(p(1) * (1.0 - p(1)) * p(2) * (1.0 - p(2)), 2);
634 * return_gradient[1] =
636 *
std::pow(p(0) * (1.0 - p(0)) * p(2) * (1.0 - p(2)), 2);
637 * return_gradient[2] =
639 *
std::pow(p(0) * (1.0 - p(0)) * p(1) * (1.0 - p(1)), 2);
642 *
Assert(
false, ExcNotImplemented());
644 *
return return_gradient;
651 * ExactSolution<dim>::hessian(
const Point<dim> &p,
652 *
const unsigned int )
const
658 * return_hessian[0][0] = (2.0 - 12.0 * p(0) + 12.0 * p(0) * p(0)) *
660 * return_hessian[0][1] =
663 * return_hessian[1][1] = (2.0 - 12.0 * p(1) + 12.0 * p(1) * p(1)) *
668 * return_hessian[0][0] =
669 * (2.0 - 12.0 * p(0) + 12.0 * p(0) * p(0)) *
670 *
std::pow(p(1) * (1.0 - p(1)) * p(2) * (1.0 - p(2)), 2);
671 * return_hessian[0][1] =
675 * return_hessian[0][2] =
679 * return_hessian[1][1] =
680 * (2.0 - 12.0 * p(1) + 12.0 * p(1) * p(1)) *
681 *
std::pow(p(0) * (1.0 - p(0)) * p(2) * (1.0 - p(2)), 2);
682 * return_hessian[1][2] =
686 * return_hessian[2][2] =
687 * (2.0 - 12.0 * p(2) + 12.0 * p(2) * p(2)) *
688 *
std::pow(p(0) * (1.0 - p(0)) * p(1) * (1.0 - p(1)), 2);
691 *
Assert(
false, ExcNotImplemented());
693 *
return return_hessian;
701 * <a name=
"ImplementationofthecodeBiLaplacianLDGLiftcodeclass"></a>
702 * <h3>Implementation of the <code>BiLaplacianLDGLift</code>
class</h3>
707 * <a name=
"BiLaplacianLDGLiftBiLaplacianLDGLift"></a>
708 * <h4>BiLaplacianLDGLift::BiLaplacianLDGLift</h4>
712 * In the constructor, we
set the polynomial degree of the two finite element
713 * spaces, we associate the corresponding DoF handlers to the
triangulation,
714 * and we
set the two penalty coefficients.
718 * BiLaplacianLDGLift<dim>::BiLaplacianLDGLift(
const unsigned int n_refinements,
719 *
const unsigned int fe_degree,
720 *
const double penalty_jump_grad,
721 *
const double penalty_jump_val)
722 * : n_refinements(n_refinements)
726 * , penalty_jump_grad(penalty_jump_grad)
727 * , penalty_jump_val(penalty_jump_val)
735 * <a name=
"BiLaplacianLDGLiftmake_grid"></a>
736 * <h4>BiLaplacianLDGLift::make_grid</h4>
740 * To build a mesh
for @f$\Omega=(0,1)^d@f$, we simply call the function
741 * <code>GridGenerator::hyper_cube</code> and then refine it
using
742 * <code>refine_global</code>. The number of refinements is hard-coded
747 *
void BiLaplacianLDGLift<dim>::make_grid()
749 * std::cout <<
"Building the mesh............." << std::endl;
755 * std::cout <<
"Number of active cells: " <<
triangulation.n_active_cells()
764 * <a name=
"BiLaplacianLDGLiftsetup_system"></a>
765 * <h4>BiLaplacianLDGLift::setup_system</h4>
769 * In the following function, we
set up the degrees of freedom, the sparsity
770 * pattern, the size of the
matrix @f$A@f$, and the size of the solution and
771 * right-hand side vectors
772 * @f$\boldsymbol{U}@f$ and @f$\boldsymbol{
F}@f$. For the sparsity pattern, we cannot
774 * (as we would
do for instance
for the SIPG method) because we need to take
775 * into account the interactions of a neighboring cell with another
776 * neighboring cell as described in the introduction. The extended sparsity
777 * pattern is built by iterating over all the active cells. For the current
778 * cell, we collect all its degrees of freedom as well as the degrees of
779 * freedom of all its neighboring cells, and then couple everything with
784 *
void BiLaplacianLDGLift<dim>::setup_system()
786 * dof_handler.distribute_dofs(fe);
788 * std::cout <<
"Number of degrees of freedom: " << dof_handler.n_dofs()
793 *
const auto dofs_per_cell = fe.dofs_per_cell;
795 *
for (
const auto &cell : dof_handler.active_cell_iterators())
798 * cell->get_dof_indices(dofs);
800 *
for (
unsigned int f = 0; f < cell->n_faces(); ++f)
801 *
if (!cell->face(f)->at_boundary())
803 *
const auto neighbor_cell = cell->neighbor(f);
805 * std::vector<types::global_dof_index> tmp(dofs_per_cell);
806 * neighbor_cell->get_dof_indices(tmp);
808 * dofs.insert(std::end(dofs), std::begin(tmp), std::end(tmp));
811 *
for (
const auto i : dofs)
812 * for (const auto j : dofs)
819 * sparsity_pattern.copy_from(dsp);
822 *
matrix.reinit(sparsity_pattern);
823 * rhs.reinit(dof_handler.n_dofs());
825 * solution.reinit(dof_handler.n_dofs());
829 * At the
end of the function, we output
this sparsity pattern as
830 * a scalable vector graphic. You can visualize it by loading
this
831 * file in most web browsers:
834 * std::ofstream out(
"sparsity-pattern.svg");
835 * sparsity_pattern.print_svg(out);
843 * <a name=
"BiLaplacianLDGLiftassemble_system"></a>
844 * <h4>BiLaplacianLDGLift::assemble_system</h4>
848 * This function simply calls the two
functions responsible
849 *
for the assembly of the
matrix and the right-hand side.
853 *
void BiLaplacianLDGLift<dim>::assemble_system()
855 * std::cout <<
"Assembling the system............." << std::endl;
860 * std::cout <<
"Done. " << std::endl;
868 * <a name=
"BiLaplacianLDGLiftassemble_matrix"></a>
869 * <h4>BiLaplacianLDGLift::assemble_matrix</h4>
873 * This function assembles the
matrix @f$A@f$ whose entries are defined
874 * by @f$A_{ij}=A_h(\varphi_j,\varphi_i)@f$ which involves the product of
875 * discrete Hessians and the penalty terms.
879 *
void BiLaplacianLDGLift<dim>::assemble_matrix()
884 *
QGauss<dim - 1> quad_face(fe.degree + 1);
886 *
const unsigned int n_q_points = quad.size();
887 *
const unsigned int n_q_points_face = quad_face.size();
897 *
const unsigned int n_dofs = fe_values.dofs_per_cell;
899 * std::vector<types::global_dof_index> local_dof_indices(n_dofs);
900 * std::vector<types::global_dof_index> local_dof_indices_neighbor(n_dofs);
901 * std::vector<types::global_dof_index> local_dof_indices_neighbor_2(n_dofs);
905 * As indicated in the introduction, the following matrices are used
for
906 * the contributions of the products of the discrete Hessians.
924 * The following matrices are used
for the contributions of the two
936 * std::vector<std::vector<Tensor<2, dim>>> discrete_hessians(
938 * std::vector<std::vector<std::vector<Tensor<2, dim>>>>
940 * discrete_hessians);
942 *
for (
const auto &cell : dof_handler.active_cell_iterators())
945 * cell->get_dof_indices(local_dof_indices);
949 * We now compute all the discrete Hessians that are not vanishing
950 * on the current cell, i.e., the discrete Hessian of all the basis
951 *
functions with support on the current cell or on one of its
955 * compute_discrete_hessians(cell,
957 * discrete_hessians_neigh);
961 * First, we compute and add the interactions of the degrees of freedom
962 * of the current cell.
965 * stiffness_matrix_cc = 0;
966 *
for (
unsigned int q = 0; q < n_q_points; ++q)
968 *
const double dx = fe_values.JxW(q);
970 *
for (
unsigned int i = 0; i < n_dofs; ++i)
971 *
for (
unsigned int j = 0; j < n_dofs; ++j)
976 * stiffness_matrix_cc(i, j) += scalar_product(H_j, H_i) *
dx;
980 *
for (
unsigned int i = 0; i < n_dofs; ++i)
981 *
for (
unsigned int j = 0; j < n_dofs; ++j)
983 *
matrix(local_dof_indices[i], local_dof_indices[j]) +=
984 * stiffness_matrix_cc(i, j);
989 * Next, we compute and add the interactions of the degrees of freedom
990 * of the current cell with those of its neighbors. Note that the
991 * interactions of the degrees of freedom of a neighbor with those of
992 * the same neighbor are included here.
995 *
for (
unsigned int face_no = 0; face_no < cell->n_faces(); ++face_no)
998 * cell->face(face_no);
1000 *
const bool at_boundary = face->at_boundary();
1005 * There is
nothing to be done
if boundary face (the liftings of
1006 * the Dirichlet BCs are accounted
for in the assembly of the
1007 * RHS; in fact,
nothing to be done in
this program since we
1008 * prescribe homogeneous BCs).
1015 * neighbor_cell = cell->neighbor(face_no);
1016 * neighbor_cell->get_dof_indices(local_dof_indices_neighbor);
1018 * stiffness_matrix_cn = 0;
1019 * stiffness_matrix_nc = 0;
1020 * stiffness_matrix_nn = 0;
1021 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1023 *
const double dx = fe_values.JxW(q);
1025 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1027 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1033 * discrete_hessians_neigh[face_no][i][q];
1035 * discrete_hessians_neigh[face_no][j][q];
1037 * stiffness_matrix_cn(i, j) +=
1038 * scalar_product(H_j_neigh, H_i) *
dx;
1039 * stiffness_matrix_nc(i, j) +=
1040 * scalar_product(H_j, H_i_neigh) *
dx;
1041 * stiffness_matrix_nn(i, j) +=
1042 * scalar_product(H_j_neigh, H_i_neigh) *
dx;
1047 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1049 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1051 *
matrix(local_dof_indices[i],
1052 * local_dof_indices_neighbor[j]) +=
1053 * stiffness_matrix_cn(i, j);
1054 *
matrix(local_dof_indices_neighbor[i],
1055 * local_dof_indices[j]) +=
1056 * stiffness_matrix_nc(i, j);
1057 *
matrix(local_dof_indices_neighbor[i],
1058 * local_dof_indices_neighbor[j]) +=
1059 * stiffness_matrix_nn(i, j);
1068 * We now compute and add the interactions of the degrees of freedom of
1069 * a neighboring cells with those of another neighboring cell (
this is
1070 * where we need the extended sparsity pattern).
1073 *
for (
unsigned int face_no = 0; face_no < cell->n_faces() - 1; ++face_no)
1076 * cell->face(face_no);
1078 *
const bool at_boundary = face->at_boundary();
1083 * Dirichlet BCs are accounted
for in the assembly of the RHS;
1084 * in fact,
nothing to be done in
this program since we
1085 * prescribe homogeneous BCs)
1094 *
for (
unsigned int face_no_2 = face_no + 1;
1095 * face_no_2 < cell->n_faces();
1099 * cell->face(face_no_2);
1101 *
const bool at_boundary_2 = face_2->at_boundary();
1102 *
if (!at_boundary_2)
1105 * neighbor_cell = cell->neighbor(face_no);
1106 * neighbor_cell->get_dof_indices(
1107 * local_dof_indices_neighbor);
1109 * neighbor_cell_2 = cell->neighbor(face_no_2);
1110 * neighbor_cell_2->get_dof_indices(
1111 * local_dof_indices_neighbor_2);
1113 * stiffness_matrix_n1n2 = 0;
1114 * stiffness_matrix_n2n1 = 0;
1116 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1118 *
const double dx = fe_values.JxW(q);
1120 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1121 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1124 * discrete_hessians_neigh[face_no][i][q];
1126 * discrete_hessians_neigh[face_no][j][q];
1129 * discrete_hessians_neigh[face_no_2][i][q];
1131 * discrete_hessians_neigh[face_no_2][j][q];
1133 * stiffness_matrix_n1n2(i, j) +=
1134 * scalar_product(H_j_neigh2, H_i_neigh) *
dx;
1135 * stiffness_matrix_n2n1(i, j) +=
1136 * scalar_product(H_j_neigh, H_i_neigh2) *
dx;
1140 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1141 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1143 *
matrix(local_dof_indices_neighbor[i],
1144 * local_dof_indices_neighbor_2[j]) +=
1145 * stiffness_matrix_n1n2(i, j);
1146 *
matrix(local_dof_indices_neighbor_2[i],
1147 * local_dof_indices_neighbor[j]) +=
1148 * stiffness_matrix_n2n1(i, j);
1158 * Finally, we compute and add the two penalty terms.
1161 *
for (
unsigned int face_no = 0; face_no < cell->n_faces(); ++face_no)
1164 * cell->face(face_no);
1166 *
const double mesh_inv = 1.0 / face->diameter();
1167 *
const double mesh3_inv =
1168 * 1.0 /
std::pow(face->diameter(), 3);
1170 * fe_face.reinit(cell, face_no);
1174 *
const bool at_boundary = face->at_boundary();
1177 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1179 *
const double dx = fe_face.JxW(q);
1181 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1182 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1184 * ip_matrix_cc(i, j) += penalty_jump_grad * mesh_inv *
1185 * fe_face.shape_grad(j, q) *
1186 * fe_face.shape_grad(i, q) *
dx;
1187 * ip_matrix_cc(i, j) += penalty_jump_val * mesh3_inv *
1188 * fe_face.shape_value(j, q) *
1189 * fe_face.shape_value(i, q) *
dx;
1197 * neighbor_cell = cell->neighbor(face_no);
1198 *
const unsigned int face_no_neighbor =
1199 * cell->neighbor_of_neighbor(face_no);
1203 * In the next step, we need to have a global way to compare the
1204 * cells in order to not calculate the same jump term twice:
1207 *
if (neighbor_cell->id() < cell->id())
1211 * fe_face_neighbor.reinit(neighbor_cell, face_no_neighbor);
1212 * neighbor_cell->get_dof_indices(local_dof_indices_neighbor);
1218 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1220 *
const double dx = fe_face.JxW(q);
1222 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1224 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1226 * ip_matrix_cc(i, j) +=
1227 * penalty_jump_grad * mesh_inv *
1228 * fe_face.shape_grad(j, q) *
1229 * fe_face.shape_grad(i, q) *
dx;
1230 * ip_matrix_cc(i, j) +=
1231 * penalty_jump_val * mesh3_inv *
1232 * fe_face.shape_value(j, q) *
1233 * fe_face.shape_value(i, q) *
dx;
1235 * ip_matrix_cn(i, j) -=
1236 * penalty_jump_grad * mesh_inv *
1237 * fe_face_neighbor.shape_grad(j, q) *
1238 * fe_face.shape_grad(i, q) *
dx;
1239 * ip_matrix_cn(i, j) -=
1240 * penalty_jump_val * mesh3_inv *
1241 * fe_face_neighbor.shape_value(j, q) *
1242 * fe_face.shape_value(i, q) *
dx;
1244 * ip_matrix_nc(i, j) -=
1245 * penalty_jump_grad * mesh_inv *
1246 * fe_face.shape_grad(j, q) *
1247 * fe_face_neighbor.shape_grad(i, q) *
dx;
1248 * ip_matrix_nc(i, j) -=
1249 * penalty_jump_val * mesh3_inv *
1250 * fe_face.shape_value(j, q) *
1251 * fe_face_neighbor.shape_value(i, q) *
dx;
1253 * ip_matrix_nn(i, j) +=
1254 * penalty_jump_grad * mesh_inv *
1255 * fe_face_neighbor.shape_grad(j, q) *
1256 * fe_face_neighbor.shape_grad(i, q) *
dx;
1257 * ip_matrix_nn(i, j) +=
1258 * penalty_jump_val * mesh3_inv *
1259 * fe_face_neighbor.shape_value(j, q) *
1260 * fe_face_neighbor.shape_value(i, q) *
dx;
1268 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1270 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1272 *
matrix(local_dof_indices[i], local_dof_indices[j]) +=
1273 * ip_matrix_cc(i, j);
1279 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1281 *
for (
unsigned int j = 0; j < n_dofs; ++j)
1283 *
matrix(local_dof_indices[i],
1284 * local_dof_indices_neighbor[j]) +=
1285 * ip_matrix_cn(i, j);
1286 *
matrix(local_dof_indices_neighbor[i],
1287 * local_dof_indices[j]) += ip_matrix_nc(i, j);
1288 *
matrix(local_dof_indices_neighbor[i],
1289 * local_dof_indices_neighbor[j]) +=
1290 * ip_matrix_nn(i, j);
1304 * <a name=
"BiLaplacianLDGLiftassemble_rhs"></a>
1305 * <h4>BiLaplacianLDGLift::assemble_rhs</h4>
1309 * This function
assemble the right-hand side of the system. Since we consider
1310 * homogeneous Dirichlet boundary conditions, imposed weakly in the bilinear
1311 * form
using the Nitsche approach, it only involves the contribution of the
1312 * forcing term @f$\int_{\Omega}fv_h@f$.
1315 *
template <
int dim>
1316 *
void BiLaplacianLDGLift<dim>::assemble_rhs()
1324 *
const unsigned int n_dofs = fe_values.dofs_per_cell;
1325 *
const unsigned int n_quad_pts = quad.size();
1327 *
const RightHandSide<dim> right_hand_side;
1330 * std::vector<types::global_dof_index> local_dof_indices(n_dofs);
1332 *
for (
const auto &cell : dof_handler.active_cell_iterators())
1334 * fe_values.
reinit(cell);
1335 * cell->get_dof_indices(local_dof_indices);
1338 *
for (
unsigned int q = 0; q < n_quad_pts; ++q)
1340 *
const double dx = fe_values.JxW(q);
1342 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1345 * right_hand_side.value(fe_values.quadrature_point(q)) *
1346 * fe_values.shape_value(i, q) *
dx;
1350 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1351 * rhs(local_dof_indices[i]) += local_rhs(i);
1360 * <a name=
"BiLaplacianLDGLiftsolve"></a>
1361 * <h4>BiLaplacianLDGLift::solve</h4>
1365 * To solve the linear system @f$A\boldsymbol{U}=\boldsymbol{
F}@f$,
1366 * we proceed as in @ref step_74
"step-74" and use a direct method. We could
1367 * as well use an iterative method,
for instance the conjugate
1368 *
gradient method as in @ref step_3
"step-3".
1371 *
template <
int dim>
1372 *
void BiLaplacianLDGLift<dim>::solve()
1376 * A_direct.vmult(solution, rhs);
1384 * <a name=
"BiLaplacianLDGLiftcompute_errors"></a>
1385 * <h4>BiLaplacianLDGLift::compute_errors</h4>
1389 * This function computes the discrete @f$H^2@f$, @f$H^1@f$ and @f$L^2@f$ norms of
1390 * the error @f$u-u_h@f$, where @f$u@f$ is the exact solution and @f$u_h@f$ is
1391 * the
approximate solution. See the introduction
for the definition
1395 *
template <
int dim>
1396 *
void BiLaplacianLDGLift<dim>::compute_errors()
1398 *
double error_H2 = 0;
1399 *
double error_H1 = 0;
1400 *
double error_L2 = 0;
1403 *
QGauss<dim - 1> quad_face(fe.degree + 1);
1419 *
const unsigned int n_q_points = quad.size();
1420 *
const unsigned int n_q_points_face = quad_face.size();
1424 * We introduce some variables
for the exact solution...
1427 *
const ExactSolution<dim> u_exact;
1434 * std::vector<double> solution_values_cell(n_q_points);
1435 * std::vector<Tensor<1, dim>> solution_gradients_cell(n_q_points);
1436 * std::vector<Tensor<2, dim>> solution_hessians_cell(n_q_points);
1438 * std::vector<double> solution_values(n_q_points_face);
1439 * std::vector<double> solution_values_neigh(n_q_points_face);
1440 * std::vector<Tensor<1, dim>> solution_gradients(n_q_points_face);
1441 * std::vector<Tensor<1, dim>> solution_gradients_neigh(n_q_points_face);
1443 *
for (
const auto &cell : dof_handler.active_cell_iterators())
1445 * fe_values.
reinit(cell);
1447 * fe_values.get_function_values(solution, solution_values_cell);
1448 * fe_values.get_function_gradients(solution, solution_gradients_cell);
1449 * fe_values.get_function_hessians(solution, solution_hessians_cell);
1453 * We
first add the <i>bulk</i> terms.
1456 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1458 *
const double dx = fe_values.JxW(q);
1460 * error_H2 += (u_exact.hessian(fe_values.quadrature_point(q)) -
1461 * solution_hessians_cell[q])
1464 * error_H1 += (u_exact.gradient(fe_values.quadrature_point(q)) -
1465 * solution_gradients_cell[q])
1468 * error_L2 +=
std::pow(u_exact.value(fe_values.quadrature_point(q)) -
1469 * solution_values_cell[q],
1476 * We then add the face contributions.
1479 *
for (
unsigned int face_no = 0; face_no < cell->n_faces(); ++face_no)
1482 * cell->face(face_no);
1484 *
const double mesh_inv = 1.0 / face->diameter();
1485 *
const double mesh3_inv =
1486 * 1.0 /
std::pow(face->diameter(), 3);
1488 * fe_face.reinit(cell, face_no);
1490 * fe_face.get_function_values(solution, solution_values);
1491 * fe_face.get_function_gradients(solution, solution_gradients);
1493 *
const bool at_boundary = face->at_boundary();
1496 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1498 *
const double dx = fe_face.JxW(q);
1499 *
const double u_exact_q =
1500 * u_exact.value(fe_face.quadrature_point(q));
1502 * u_exact.gradient(fe_face.quadrature_point(q));
1506 * (u_exact_grad_q - solution_gradients[q]).
norm_square() *
1508 * error_H2 += mesh3_inv *
1509 *
std::pow(u_exact_q - solution_values[q], 2) *
1511 * error_H1 += mesh_inv *
1512 *
std::pow(u_exact_q - solution_values[q], 2) *
1520 * neighbor_cell = cell->neighbor(face_no);
1521 *
const unsigned int face_no_neighbor =
1522 * cell->neighbor_of_neighbor(face_no);
1526 * In the next step, we need to have a global way to compare the
1527 * cells in order to not calculate the same jump term twice:
1530 *
if (neighbor_cell->id() < cell->id())
1534 * fe_face_neighbor.reinit(neighbor_cell, face_no_neighbor);
1536 * fe_face.get_function_values(solution, solution_values);
1537 * fe_face_neighbor.get_function_values(solution,
1538 * solution_values_neigh);
1539 * fe_face.get_function_gradients(solution,
1540 * solution_gradients);
1541 * fe_face_neighbor.get_function_gradients(
1542 * solution, solution_gradients_neigh);
1544 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1546 *
const double dx = fe_face.JxW(q);
1550 * To compute the jump term, we use the fact that
1551 * @f$\jump{u}=0@f$ and
1552 * @f$\jump{\nabla u}=\mathbf{0}@f$ since @f$u\in
1558 * (solution_gradients_neigh[q] - solution_gradients[q])
1561 * error_H2 += mesh3_inv *
1562 *
std::pow(solution_values_neigh[q] -
1563 * solution_values[q],
1566 * error_H1 += mesh_inv *
1567 *
std::pow(solution_values_neigh[q] -
1568 * solution_values[q],
1584 * std::cout <<
"DG H2 norm of the error: " << error_H2 << std::endl;
1585 * std::cout <<
"DG H1 norm of the error: " << error_H1 << std::endl;
1586 * std::cout <<
" L2 norm of the error: " << error_L2 << std::endl;
1594 * <a name=
"BiLaplacianLDGLiftoutput_results"></a>
1595 * <h4>BiLaplacianLDGLift::output_results</h4>
1599 * This function, which writes the solution to a
vtk file,
1600 * is copied from @ref step_3
"step-3".
1603 *
template <
int dim>
1604 *
void BiLaplacianLDGLift<dim>::output_results() const
1608 * data_out.add_data_vector(solution,
"solution");
1609 * data_out.build_patches();
1611 * std::ofstream output(
"solution.vtk");
1612 * data_out.write_vtk(output);
1620 * <a name=
"BiLaplacianLDGLiftassemble_local_matrix"></a>
1621 * <h4>BiLaplacianLDGLift::assemble_local_matrix</h4>
1625 * As already mentioned above,
this function is used to
assemble
1626 * the (local) mass matrices needed
for the computations of the
1627 * lifting terms. We reiterate that only the basis
functions with
1628 * support on the current cell are considered.
1631 *
template <
int dim>
1632 *
void BiLaplacianLDGLift<dim>::assemble_local_matrix(
1634 *
const unsigned int n_q_points,
1639 *
const unsigned int n_dofs = fe_values_lift.dofs_per_cell;
1642 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1644 *
const double dx = fe_values_lift.JxW(q);
1646 *
for (
unsigned int m = 0; m < n_dofs; ++m)
1647 *
for (
unsigned int n = 0; n < n_dofs; ++n)
1649 * local_matrix(m, n) +=
1650 * scalar_product(fe_values_lift[tau_ext].
value(n, q),
1651 * fe_values_lift[tau_ext].
value(m, q)) *
1662 * <a name=
"BiLaplacianLDGLiftcompute_discrete_hessians"></a>
1663 * <h4>BiLaplacianLDGLift::compute_discrete_hessians</h4>
1667 * This function is the main novelty of
this program. It computes
1668 * the discrete Hessian @f$H_h(\varphi)@f$
for all the basis
functions
1669 * @f$\varphi@f$ of @f$\mathbb{V}_h@f$ supported on the current cell and
1670 * those supported on a neighboring cell. The
first argument
1671 * indicates the current cell (referring to the global
DoFHandler
1672 *
object),
while the other two arguments are output variables that
1673 * are filled by
this function.
1677 * In the following, we need to evaluate finite element shape
1678 *
functions for the `fe_lift` finite element on the current
1679 * cell. Like
for example in @ref step_61
"step-61",
this "lift" space is defined
1680 * on every cell individually; as a consequence, there is no global
1681 *
DoFHandler associated with
this because we simply have no need
1682 *
for such a
DoFHandler. That leaves the question of what we should
1684 * them to evaluate shape
functions of `fe_lift` on a concrete
1685 * cell. If we simply provide the
first argument to
this function,
1687 * that the given `cell` belongs to a
DoFHandler that has a
1688 * different finite element associated with it than the `fe_lift`
1689 *
object we want to evaluate. Fortunately, there is a relatively
1691 * points into a
triangulation -- the same cell, but not associated
1692 * with a
DoFHandler, and consequently no finite element space. In
1693 * that case,
FEValues::reinit() will skip the check that would
1694 * otherwise lead to an error message. All we have to do is to convert
1696 * see the
first couple of lines of the function below to see how
1700 * template <
int dim>
1701 *
void BiLaplacianLDGLift<dim>::compute_discrete_hessians(
1702 * const typename
DoFHandler<dim>::active_cell_iterator &cell,
1703 *
std::vector<
std::vector<
Tensor<2, dim>>> & discrete_hessians,
1705 * &discrete_hessians_neigh)
1711 *
QGauss<dim - 1> quad_face(
fe.degree + 1);
1713 *
const unsigned int n_q_points = quad.size();
1714 *
const unsigned int n_q_points_face = quad_face.size();
1718 * The information we need from the basis
functions of
1719 * @f$\mathbb{V}_h@f$: <code>fe_values</code> is needed to add
1720 * the broken Hessian part of the discrete Hessian,
while
1721 * <code>fe_face</code> and <code>fe_face_neighbor</code>
1722 * are used to compute the right-hand sides
for the local
1734 *
const unsigned int n_dofs = fe_values.dofs_per_cell;
1738 * The information needed from the basis
functions
1739 * of the finite element space
for the lifting terms:
1740 * <code>fe_values_lift</code> is used
for the (local)
1741 * mass
matrix (see @f$\boldsymbol{M}_c@f$ in the introduction),
1742 * while <code>fe_face_lift</code> is used to compute the
1743 * right-hand sides (see @f$\boldsymbol{G}_c@f$
for @f$b_e@f$).
1755 *
const unsigned int n_dofs_lift = fe_values_lift.dofs_per_cell;
1758 *
Vector<double> local_rhs_re(n_dofs_lift), local_rhs_be(n_dofs_lift),
1759 * coeffs_re(n_dofs_lift), coeffs_be(n_dofs_lift), coeffs_tmp(n_dofs_lift);
1764 *
double factor_avg;
1766 * fe_values.reinit(cell);
1767 * fe_values_lift.reinit(cell_lift);
1771 * We start by assembling the (local) mass
matrix used
for the computation
1772 * of the lifting terms @f$r_e@f$ and @f$b_e@f$.
1775 * assemble_local_matrix(fe_values_lift, n_q_points, local_matrix_lift);
1777 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1778 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1780 * discrete_hessians[i][q] = 0;
1782 *
for (
unsigned int face_no = 0;
1783 * face_no < discrete_hessians_neigh.size();
1786 * discrete_hessians_neigh[face_no][i][q] = 0;
1793 * @f$x_q@f$ of <code>cell</code>
for each basis function supported on
1794 * <code>cell</code>, namely we fill-in the variable
1795 * <code>discrete_hessians[i][q]</code>. For the lifting terms, we need to
1796 * add the contribution of all the faces of <code>cell</code>.
1799 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1804 *
for (
unsigned int face_no = 0; face_no < cell->n_faces(); ++face_no)
1807 * cell->face(face_no);
1809 *
const bool at_boundary = face->at_boundary();
1813 * Recall that by convention, the average of a function across a
1814 * boundary face @f$e@f$ reduces to the
trace of the function on the
1815 * only element adjacent to @f$e@f$, namely there is no factor
1816 * @f$\frac{1}{2}@f$. We distinguish between the two cases (the current
1817 * face lies in the interior or on the boundary of the domain)
using
1818 * the variable <code>factor_avg</code>.
1827 * fe_face.reinit(cell, face_no);
1828 * fe_face_lift.reinit(cell_lift, face_no);
1831 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1833 *
const double dx = fe_face_lift.JxW(q);
1837 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
1839 * local_rhs_re(m) +=
1841 * (fe_face_lift[tau_ext].
value(m, q) * normal) *
1842 * fe_face.shape_grad(i, q) *
dx;
1848 * Here, <code>local_rhs_be(m)</code> corresponds to @f$G_m@f$
1849 * introduced in the comments about the implementation of the
1850 * lifting @f$b_e@f$ in the
case
1851 * @f$\varphi=\varphi^c@f$.
1855 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1857 *
const double dx = fe_face_lift.JxW(q);
1861 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
1863 * local_rhs_be(m) += factor_avg *
1864 * fe_face_lift[tau_ext].divergence(m, q) *
1865 * normal * fe_face.shape_value(i, q) *
dx;
1870 * solver.solve(local_matrix_lift,
1874 * coeffs_re += coeffs_tmp;
1877 * solver.solve(local_matrix_lift,
1881 * coeffs_be += coeffs_tmp;
1885 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1887 * discrete_hessians[i][q] += fe_values.shape_hessian(i, q);
1889 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
1891 * discrete_hessians[i][q] -=
1892 * coeffs_re[m] * fe_values_lift[tau_ext].value(m, q);
1895 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
1897 * discrete_hessians[i][q] +=
1898 * coeffs_be[m] * fe_values_lift[tau_ext].value(m, q);
1908 * @f$x_q@f$ of <code>cell</code>
for each basis function supported on a
1909 * neighboring <code>neighbor_cell</code> of <code>cell</code>, namely we
1910 * fill-in the variable <code>discrete_hessians_neigh[face_no][i][q]</code>.
1911 * For the lifting terms, we only need to add the contribution of the
1912 * face adjacent to <code>cell</code> and <code>neighbor_cell</code>.
1915 *
for (
unsigned int face_no = 0; face_no < cell->n_faces(); ++face_no)
1918 * cell->face(face_no);
1920 *
const bool at_boundary = face->at_boundary();
1926 * For non-homogeneous Dirichlet BCs, we would need to
1927 * compute the lifting of the prescribed BC (see the
1928 *
"Possible Extensions" section
for more details).
1935 * neighbor_cell = cell->neighbor(face_no);
1936 *
const unsigned int face_no_neighbor =
1937 * cell->neighbor_of_neighbor(face_no);
1938 * fe_face_neighbor.reinit(neighbor_cell, face_no_neighbor);
1940 *
for (
unsigned int i = 0; i < n_dofs; ++i)
1945 * fe_face_lift.reinit(cell_lift, face_no);
1948 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1950 *
const double dx = fe_face_lift.JxW(q);
1952 * fe_face_neighbor.normal_vector(q);
1954 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
1956 * local_rhs_re(m) +=
1957 * 0.5 * (fe_face_lift[tau_ext].value(m, q) * normal) *
1958 * fe_face_neighbor.shape_grad(i, q) *
dx;
1964 * Here, <code>local_rhs_be(m)</code> corresponds to @f$G_m@f$
1965 * introduced in the comments about the implementation of the
1966 * lifting @f$b_e@f$ in the
case
1967 * @f$\varphi=\varphi^n@f$.
1971 *
for (
unsigned int q = 0; q < n_q_points_face; ++q)
1973 *
const double dx = fe_face_lift.JxW(q);
1975 * fe_face_neighbor.normal_vector(q);
1977 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
1979 * local_rhs_be(m) +=
1980 * 0.5 * fe_face_lift[tau_ext].divergence(m, q) *
1981 * normal * fe_face_neighbor.shape_value(i, q) *
dx;
1985 * solver.solve(local_matrix_lift,
1989 * solver.solve(local_matrix_lift,
1994 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1996 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
1998 * discrete_hessians_neigh[face_no][i][q] -=
1999 * coeffs_re[m] * fe_values_lift[tau_ext].value(m, q);
2002 *
for (
unsigned int m = 0; m < n_dofs_lift; ++m)
2004 * discrete_hessians_neigh[face_no][i][q] +=
2005 * coeffs_be[m] * fe_values_lift[tau_ext].value(m, q);
2019 * <a name=
"BiLaplacianLDGLiftrun"></a>
2020 * <h4>BiLaplacianLDGLift::run</h4>
2023 *
template <
int dim>
2024 *
void BiLaplacianLDGLift<dim>::run()
2029 * assemble_system();
2044 * <a name=
"Thecodemaincodefunction"></a>
2045 * <h3>The <code>main</code> function</h3>
2049 * This is the <code>main</code> function. We define here the number of mesh
2050 * refinements, the polynomial degree
for the two finite element spaces
2051 * (
for the solution and the two liftings) and the two penalty coefficients.
2052 * We can also change the dimension to run the code in 3
d.
2059 *
const unsigned int n_ref = 3;
2061 *
const unsigned int degree =
2064 *
const double penalty_grad =
2066 *
const double penalty_val =
2069 * Step82::BiLaplacianLDGLift<2> problem(n_ref,
2076 *
catch (std::exception &exc)
2078 * std::cerr << std::endl
2080 * <<
"----------------------------------------------------"
2082 * std::cerr <<
"Exception on processing: " << std::endl
2083 * << exc.what() << std::endl
2084 * <<
"Aborting!" << std::endl
2085 * <<
"----------------------------------------------------"
2091 * std::cerr << std::endl
2093 * <<
"----------------------------------------------------"
2095 * std::cerr <<
"Unknown exception!" << std::endl
2096 * <<
"Aborting!" << std::endl
2097 * <<
"----------------------------------------------------"
2105<a name=
"Results"></a><h1>Results</h1>
2109When running the program, the sparsity pattern is written to an
svg file, the solution is written to a
vtk file, and some results are printed to the console. With the current setup, the output should read
2113Number of active cells: 64
2114Number of degrees of freedom: 576
2115Assembling the system.............
2117DG H2
norm of the error: 0.0151063
2118DG H1
norm of the error: 0.000399747
2119 L2 norm of the error: 5.33856e-05
2123This corresponds to the bi-Laplacian problem with the manufactured solution mentioned above
for @f$d=2@f$, 3 refinements of the mesh, degree @f$k=2@f$, and @f$\gamma_0=\gamma_1=1@f$
for the penalty coefficients. By changing the number of refinements, we get the following results:
2125<table align=
"center" class=
"doxtable">
2138 <td align=
"center">1</td>
2139 <td align=
"right">4</td>
2140 <td align=
"right">36</td>
2141 <td align=
"center">5.651e-02</td>
2142 <td align=
"center">--</td>
2143 <td align=
"center">3.366e-03</td>
2144 <td align=
"center">--</td>
2145 <td align=
"center">3.473e-04</td>
2146 <td align=
"center">--</td>
2149 <td align=
"center">2</td>
2150 <td align=
"right">16</td>
2151 <td align=
"right">144</td>
2152 <td align=
"center">3.095e-02</td>
2153 <td align=
"center">0.87</td>
2154 <td align=
"center">1.284e-03</td>
2155 <td align=
"center">1.39</td>
2156 <td align=
"center">1.369e-04</td>
2157 <td align=
"center">1.34</td>
2160 <td align=
"center">3</td>
2161 <td align=
"right">64</td>
2162 <td align=
"right">576</td>
2163 <td align=
"center">1.511e-02</td>
2164 <td align=
"center">1.03</td>
2165 <td align=
"center">3.997e-04</td>
2166 <td align=
"center">1.68</td>
2167 <td align=
"center">5.339e-05</td>
2168 <td align=
"center">1.36</td>
2171 <td align=
"center">4</td>
2172 <td align=
"right">256</td>
2173 <td align=
"right">2304</td>
2174 <td align=
"center">7.353e-03</td>
2175 <td align=
"center">1.04</td>
2176 <td align=
"center">1.129e-04</td>
2177 <td align=
"center">1.82</td>
2178 <td align=
"center">1.691e-05</td>
2179 <td align=
"center">1.66</td>
2182 <td align=
"center">5</td>
2183 <td align=
"right">1024</td>
2184 <td align=
"right">9216</td>
2185 <td align=
"center">3.609e-03</td>
2186 <td align=
"center">1.03</td>
2187 <td align=
"center">3.024e-05</td>
2188 <td align=
"center">1.90</td>
2189 <td align=
"center">4.789e-06</td>
2190 <td align=
"center">1.82</td>
2193 <td align=
"center">6</td>
2194 <td align=
"right">4096</td>
2195 <td align=
"right">36864</td>
2196 <td align=
"center">1.785e-03</td>
2197 <td align=
"center">1.02</td>
2198 <td align=
"center">7.850e-06</td>
2199 <td align=
"center">1.95</td>
2200 <td align=
"center">1.277e-06</td>
2201 <td align=
"center">1.91</td>
2205This matches the expected optimal convergence rates
for the @f$H^2@f$ and
2206@f$H^1@f$ norms, but is sub-optimal
for the @f$L_2@f$
norm. Incidentally,
this
2207also matches the results seen in @ref step_47
"step-47" when
using polynomial degree
2210Indeed, just like in @ref step_47
"step-47", we can regain the optimal convergence
2211order
if we
set the polynomial degree of the finite elements to @f$k=3@f$
2212or higher. Here are the
numbers for @f$k=3@f$:
2214<table align=
"center" class=
"doxtable">
2215 <tr> <th> n_ref </th> <th>
n_cells </th> <th> n_dofs </th> <th> error H2 </th> <th> rate </th> <th> error H1 </th> <th> rate </th> <th> error
L2 </th> <th> rate</th> </tr>
2216 <tr> <td> 1 </td> <td> 4 </td> <td> 36 </td> <td> 1.451e-02 </td> <td> -- </td> <td> 5.494e-04 </td> <td> -- </td> <td> 3.035e-05 </td> <td> --</td> </tr>
2217 <tr> <td> 2 </td> <td> 16 </td> <td> 144 </td> <td> 3.565e-03 </td> <td> 2.02 </td> <td> 6.870e-05 </td> <td> 3.00 </td> <td> 2.091e-06 </td> <td> 3.86</td> </tr>
2218 <tr> <td> 3 </td> <td> 64 </td> <td> 576 </td> <td> 8.891e-04 </td> <td> 2.00 </td> <td> 8.584e-06 </td> <td> 3.00 </td> <td> 1.352e-07 </td> <td> 3.95</td> </tr>
2219 <tr> <td> 4 </td> <td> 256 </td> <td> 2304 </td> <td> 2.223e-04 </td> <td> 2.00 </td> <td> 1.073e-06 </td> <td> 3.00 </td> <td> 8.594e-09 </td> <td> 3.98</td> </tr>
2220 <tr> <td> 5 </td> <td> 1024 </td> <td> 9216 </td> <td> 5.560e-05 </td> <td> 2.00 </td> <td> 1.341e-07 </td> <td> 3.00 </td> <td> 5.418e-10 </td> <td> 3.99</td> </tr>
2221 <tr> <td> 6 </td> <td> 4096 </td> <td> 36864 </td> <td> 1.390e-05 </td> <td> 2.00 </td> <td> 1.676e-08 </td> <td> 3.00 </td> <td> 3.245e-11 </td> <td> 4.06</td> </tr>
2225<a name=
"Possibleextensions"></a><h3>Possible extensions</h3>
2228The code can be easily adapted to deal with the following cases:
2231 <li>Non-homogeneous Dirichlet boundary conditions on (part of) the boundary @f$\partial \Omega@f$ of @f$\Omega@f$.</li>
2232 <li>Hanging-nodes (proceed as in @ref step_14
"step-14" to not visit a sub-face twice when computing the lifting terms in <code>compute_discrete_hessians</code> and the penalty terms in <code>assemble_matrix</code>).</li>
2233 <li>LDG method
for the Poisson problem (use the discrete gradient consisting of the broken gradient and the lifting of the jump of @f$u_h@f$).</li>
2236We give below additional details
for the
first of these points.
2239<a name=
"NonhomogeneousDirichletboundaryconditions"></a><h4>Non-homogeneous Dirichlet boundary conditions</h4>
2241If we prescribe non-homogeneous Dirichlet conditions, say
2243\nabla u=\mathbf{g} \quad \mbox{and} \quad u=g \qquad \mbox{on } \partial \Omega,
2245then the right-hand side @f$\boldsymbol{
F}@f$ of the linear system needs to be modified as follows
2247F_i:=\int_{\Omega}f\varphi_i-\sum_{e\in\mathcal{
E}_h^
b}\int_{\Omega}r_e(\mathbf{g}):H_h(\varphi_i)+\sum_{
e\in\mathcal{
E}_h^
b}\int_{\Omega}b_e(g):H_h(\varphi_i)+\gamma_1\sum_{
e\in\mathcal{
E}_h^
b}h_e^{-1}\int_e\mathbf{g}\cdot\nabla\varphi_i+\gamma_0\sum_{e\in\mathcal{
E}_h^
b}h_e^{-3}\int_e g\varphi_i, \qquad 1\leq i \leq N_h.
2249Note that
for any given
index @f$i@f$, many of the terms are zero. Indeed,
for @f$e\in \mathcal{
E}_h^
b@f$ we have @f${\rm supp}\,(r_e(\mathbf{g}))={\rm supp}\,(b_e(g))=K@f$, where @f$K@f$ is the element
for which @f$e\subset\partial K@f$. Therefore, the liftings @f$r_e(\mathbf{g})@f$ and @f$b_e(g)@f$ contribute to @f$F_i@f$ only
if @f$\varphi_i@f$ has support on @f$K@f$ or a neighbor of @f$K@f$. In other words, when integrating on a cell @f$K@f$, we need to add
2251\int_{
K}f\varphi_i+\sum_{e\in\mathcal{
E}_h^
b, e\subset\partial
K}\left[-\int_{
K}r_e(\mathbf{g}):H_h(\varphi_i)+\int_{
K}b_e(g):H_h(\varphi_i)+\gamma_1h_e^{-1}\int_e\mathbf{g}\cdot\nabla\varphi_i+\gamma_0h_e^{-3}\int_e g\varphi_i\right]
2253to @f$F_i@f$
for the indices @f$i@f$ such that @f$\varphi_i@f$ has support on @f$K@f$ and
2255\sum_{e\in\mathcal{
E}_h^
b, e\subset\partial
K}\left[-\int_{
K}r_e(\mathbf{g}):H_h(\varphi_i)+\int_{
K}b_e(g):H_h(\varphi_i)\right]
2257to @f$F_i@f$ for the indices @f$i@f$ such that @f$\varphi_i@f$ has support on a neighbor of @f$K@f$.
2260Note that we can easily consider the case where Dirichlet boundary conditions are imposed only on a subset @f$\emptyset\neq\Gamma_D\subset\partial \Omega@f$. In this case, we simply need to replace @f$\mathcal{
E}_h^
b@f$ by @f$\mathcal{
E}_h^D\subset\mathcal{
E}_h^
b@f$ consisting of the faces belonging to @f$\Gamma_D@f$. This also affects the
matrix @f$A@f$ (simply replace @f$\mathcal{
E}_h=\mathcal{
E}_h^0\cup\mathcal{
E}_h^
b@f$ by @f$\mathcal{
E}_h=\mathcal{
E}_h^0\cup\mathcal{
E}_h^D@f$).
2263<a name=
"PlainProg"></a>
2264<h1> The plain program</h1>
2265@include
"step-82.cc"
void attach_dof_handler(const DoFHandler< dim, spacedim > &)
const SmartPointer< const FiniteElement< dim, spacedim >, FEValuesBase< dim, spacedim > > fe
const Quadrature< dim > quadrature
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell)
virtual SymmetricTensor< 2, dim, RangeNumberType > hessian(const Point< dim > &p, const unsigned int component=0) const
virtual Tensor< 1, dim, RangeNumberType > gradient(const Point< dim > &p, const unsigned int component=0) const
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
void initialize(const SparsityPattern &sparsity_pattern)
constexpr numbers::NumberTraits< Number >::real_type norm_square() const
__global__ void set(Number *val, const Number s, const size_type N)
#define Assert(cond, exc)
typename ActiveSelector::face_iterator face_iterator
typename ActiveSelector::active_cell_iterator active_cell_iterator
void loop(ITERATOR begin, std_cxx20::type_identity_t< ITERATOR > end, DOFINFO &dinfo, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
void make_flux_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern)
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_normal_vectors
Normal vectors.
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt K
void approximate(SynchronousIterators< std::tuple< typename DoFHandler< dim, spacedim >::active_cell_iterator, Vector< float >::iterator > > const &cell, const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof_handler, const InputVector &solution, const unsigned int component)
void hyper_cube(Triangulation< dim, spacedim > &tria, const double left=0., const double right=1., const bool colorize=false)
@ matrix
Contents is actually a matrix.
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
void L2(Vector< number > &result, const FEValuesBase< dim > &fe, const std::vector< double > &input, const double factor=1.)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > E(const Tensor< 2, dim, Number > &F)
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)
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
void call(const std::function< RT()> &function, internal::return_value< RT > &ret_val)
VectorType::value_type * end(VectorType &V)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
int(&) functions(const void *v1, const void *v2)
void assemble(const MeshWorker::DoFInfoBox< dim, DOFINFO > &dinfo, A *assembler)
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
unsigned int global_dof_index
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
DEAL_II_HOST constexpr Number trace(const SymmetricTensor< 2, dim2, Number > &)