deal.II version GIT relicensing-1721-g8100761196 2024-08-31 12:30:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
step-47.h
Go to the documentation of this file.
1 = 0) const override
675 *   {
676 *   return std::sin(PI * p[0]) * std::sin(PI * p[1]);
677 *   }
678 *  
679 *   virtual Tensor<1, dim>
680 *   gradient(const Point<dim> &p,
681 *   const unsigned int /*component*/ = 0) const override
682 *   {
683 *   Tensor<1, dim> r;
684 *   r[0] = PI * std::cos(PI * p[0]) * std::sin(PI * p[1]);
685 *   r[1] = PI * std::cos(PI * p[1]) * std::sin(PI * p[0]);
686 *   return r;
687 *   }
688 *  
689 *   virtual void
690 *   hessian_list(const std::vector<Point<dim>> &points,
691 *   std::vector<SymmetricTensor<2, dim>> &hessians,
692 *   const unsigned int /*component*/ = 0) const override
693 *   {
694 *   for (unsigned i = 0; i < points.size(); ++i)
695 *   {
696 *   const double x = points[i][0];
697 *   const double y = points[i][1];
698 *  
699 *   hessians[i][0][0] = -PI * PI * std::sin(PI * x) * std::sin(PI * y);
700 *   hessians[i][0][1] = PI * PI * std::cos(PI * x) * std::cos(PI * y);
701 *   hessians[i][1][1] = -PI * PI * std::sin(PI * x) * std::sin(PI * y);
702 *   }
703 *   }
704 *   };
705 *  
706 *  
707 *   template <int dim>
708 *   class RightHandSide : public Function<dim>
709 *   {
710 *   public:
711 *   static_assert(dim == 2, "Only dim==2 is implemented");
712 *  
713 *   virtual double value(const Point<dim> &p,
714 *   const unsigned int /*component*/ = 0) const override
715 *  
716 *   {
717 *   return 4 * Utilities::fixed_power<4>(PI) * std::sin(PI * p[0]) *
718 *   std::sin(PI * p[1]);
719 *   }
720 *   };
721 *   } // namespace ExactSolution
722 *  
723 *  
724 *  
725 * @endcode
726 *
727 *
728 * <a name="step_47-Themainclass"></a>
729 * <h3>The main class</h3>
730 *
731
732 *
733 * The following is the principal class of this tutorial program. It has
734 * the structure of many of the other tutorial programs and there should
735 * really be nothing particularly surprising about its contents or
736 * the constructor that follows it.
737 *
738 * @code
739 *   template <int dim>
740 *   class BiharmonicProblem
741 *   {
742 *   public:
743 *   BiharmonicProblem(const unsigned int fe_degree);
744 *  
745 *   void run();
746 *  
747 *   private:
748 *   void make_grid();
749 *   void setup_system();
750 *   void assemble_system();
751 *   void solve();
752 *   void compute_errors();
753 *   void output_results(const unsigned int iteration) const;
754 *  
756 *  
757 *   const MappingQ<dim> mapping;
758 *  
759 *   const FE_Q<dim> fe;
760 *   DoFHandler<dim> dof_handler;
761 *   AffineConstraints<double> constraints;
762 *  
763 *   SparsityPattern sparsity_pattern;
764 *   SparseMatrix<double> system_matrix;
765 *  
766 *   Vector<double> solution;
767 *   Vector<double> system_rhs;
768 *   };
769 *  
770 *  
771 *  
772 *   template <int dim>
773 *   BiharmonicProblem<dim>::BiharmonicProblem(const unsigned int fe_degree)
774 *   : mapping(1)
775 *   , fe(fe_degree)
776 *   , dof_handler(triangulation)
777 *   {}
778 *  
779 *  
780 *  
781 * @endcode
782 *
783 * Next up are the functions that create the initial mesh (a once refined
784 * unit square) and set up the constraints, vectors, and matrices on
785 * each mesh. Again, both of these are essentially unchanged from many
786 * previous tutorial programs.
787 *
788 * @code
789 *   template <int dim>
790 *   void BiharmonicProblem<dim>::make_grid()
791 *   {
793 *   triangulation.refine_global(1);
794 *  
795 *   std::cout << "Number of active cells: " << triangulation.n_active_cells()
796 *   << std::endl
797 *   << "Total number of cells: " << triangulation.n_cells()
798 *   << std::endl;
799 *   }
800 *  
801 *  
802 *  
803 *   template <int dim>
804 *   void BiharmonicProblem<dim>::setup_system()
805 *   {
806 *   dof_handler.distribute_dofs(fe);
807 *  
808 *   std::cout << " Number of degrees of freedom: " << dof_handler.n_dofs()
809 *   << std::endl;
810 *  
811 *   constraints.clear();
812 *   DoFTools::make_hanging_node_constraints(dof_handler, constraints);
813 *  
815 *   0,
816 *   ExactSolution::Solution<dim>(),
817 *   constraints);
818 *   constraints.close();
819 *  
820 *  
821 *   DynamicSparsityPattern dsp(dof_handler.n_dofs());
822 *   DoFTools::make_flux_sparsity_pattern(dof_handler, dsp, constraints, true);
823 *   sparsity_pattern.copy_from(dsp);
824 *   system_matrix.reinit(sparsity_pattern);
825 *  
826 *   solution.reinit(dof_handler.n_dofs());
827 *   system_rhs.reinit(dof_handler.n_dofs());
828 *   }
829 *  
830 *  
831 *  
832 * @endcode
833 *
834 *
835 * <a name="step_47-Assemblingthelinearsystem"></a>
836 * <h4>Assembling the linear system</h4>
837 *
838
839 *
840 * The following pieces of code are more interesting. They all relate to the
841 * assembly of the linear system. While assembling the cell-interior terms
842 * is not of great difficulty -- that works in essence like the assembly
843 * of the corresponding terms of the Laplace equation, and you have seen
844 * how this works in @ref step_4 "step-4" or @ref step_6 "step-6", for example -- the difficulty
845 * is with the penalty terms in the formulation. These require the evaluation
846 * of gradients of shape functions at interfaces of cells. At the least,
847 * one would therefore need to use two FEFaceValues objects, but if one of the
848 * two sides is adaptively refined, then one actually needs an FEFaceValues
849 * and one FESubfaceValues objects; one also needs to keep track which
850 * shape functions live where, and finally we need to ensure that every
851 * face is visited only once. All of this is a substantial overhead to the
852 * logic we really want to implement (namely the penalty terms in the
853 * bilinear form). As a consequence, we will make use of the
854 * FEInterfaceValues class -- a helper class in deal.II that allows us
855 * to abstract away the two FEFaceValues or FESubfaceValues objects and
856 * directly access what we really care about: jumps, averages, etc.
857 *
858
859 *
860 * But this doesn't yet solve our problem of having to keep track of
861 * which faces we have already visited when we loop over all cells and
862 * all of their faces. To make this process simpler, we use the
863 * MeshWorker::mesh_loop() function that provides a simple interface
864 * for this task: Based on the ideas outlined in the WorkStream
865 * namespace documentation, MeshWorker::mesh_loop() requires three
866 * functions that do work on cells, interior faces, and boundary
867 * faces. These functions work on scratch objects for intermediate
868 * results, and then copy the result of their computations into
869 * copy data objects from where a copier function copies them into
870 * the global matrix and right hand side objects.
871 *
872
873 *
874 * The following structures then provide the scratch and copy objects
875 * that are necessary for this approach. You may look up the WorkStream
876 * namespace as well as the
877 * @ref threads "Parallel computing with multiple processors"
878 * topic for more information on how they typically work.
879 *
880 * @code
881 *   template <int dim>
882 *   struct ScratchData
883 *   {
884 *   ScratchData(const Mapping<dim> &mapping,
885 *   const FiniteElement<dim> &fe,
886 *   const unsigned int quadrature_degree,
887 *   const UpdateFlags update_flags,
888 *   const UpdateFlags interface_update_flags)
889 *   : fe_values(mapping, fe, QGauss<dim>(quadrature_degree), update_flags)
890 *   , fe_interface_values(mapping,
891 *   fe,
892 *   QGauss<dim - 1>(quadrature_degree),
893 *   interface_update_flags)
894 *   {}
895 *  
896 *  
897 *   ScratchData(const ScratchData<dim> &scratch_data)
898 *   : fe_values(scratch_data.fe_values.get_mapping(),
899 *   scratch_data.fe_values.get_fe(),
900 *   scratch_data.fe_values.get_quadrature(),
901 *   scratch_data.fe_values.get_update_flags())
902 *   , fe_interface_values(scratch_data.fe_values.get_mapping(),
903 *   scratch_data.fe_values.get_fe(),
904 *   scratch_data.fe_interface_values.get_quadrature(),
905 *   scratch_data.fe_interface_values.get_update_flags())
906 *   {}
907 *  
908 *   FEValues<dim> fe_values;
909 *   FEInterfaceValues<dim> fe_interface_values;
910 *   };
911 *  
912 *  
913 *  
914 *   struct CopyData
915 *   {
916 *   CopyData(const unsigned int dofs_per_cell)
917 *   : cell_matrix(dofs_per_cell, dofs_per_cell)
918 *   , cell_rhs(dofs_per_cell)
919 *   , local_dof_indices(dofs_per_cell)
920 *   {}
921 *  
922 *  
923 *   CopyData(const CopyData &) = default;
924 *  
925 *  
926 *   CopyData(CopyData &&) = default;
927 *  
928 *  
929 *   ~CopyData() = default;
930 *  
931 *  
932 *   CopyData &operator=(const CopyData &) = default;
933 *  
934 *  
935 *   CopyData &operator=(CopyData &&) = default;
936 *  
937 *  
938 *   struct FaceData
939 *   {
940 *   FullMatrix<double> cell_matrix;
941 *   std::vector<types::global_dof_index> joint_dof_indices;
942 *   };
943 *  
944 *   FullMatrix<double> cell_matrix;
945 *   Vector<double> cell_rhs;
946 *   std::vector<types::global_dof_index> local_dof_indices;
947 *   std::vector<FaceData> face_data;
948 *   };
949 *  
950 *  
951 *  
952 * @endcode
953 *
954 * The more interesting part is where we actually assemble the linear system.
955 * Fundamentally, this function has five parts:
956 * - The definition of the `cell_worker` lambda function, a small
957 * function that is defined within the `assemble_system()`
958 * function and that will be responsible for computing the local
959 * integrals on an individual cell. It will work on a copy of the
960 * `ScratchData` class and put its results into the corresponding
961 * `CopyData` object.
962 * - The definition of the `face_worker` lambda function that does
963 * the integration of all terms that live on the interfaces between
964 * cells.
965 * - The definition of the `boundary_worker` function that does the
966 * same but for cell faces located on the boundary of the domain.
967 * - The definition of the `copier` function that is responsible
968 * for copying all of the data the previous three functions have
969 * put into copy objects for a single cell, into the global matrix
970 * and right hand side.
971 *
972
973 *
974 * The fifth part is the one where we bring all of this together.
975 *
976
977 *
978 * Let us go through each of these pieces necessary for the assembly
979 * in turns.
980 *
981 * @code
982 *   template <int dim>
983 *   void BiharmonicProblem<dim>::assemble_system()
984 *   {
985 *   using Iterator = typename DoFHandler<dim>::active_cell_iterator;
986 *  
987 * @endcode
988 *
989 * The first piece is the `cell_worker` that does the assembly
990 * on the cell interiors. It is a (lambda) function that takes
991 * a cell (input), a scratch object, and a copy object (output)
992 * as arguments. It looks like the assembly functions of many
993 * other of the tutorial programs, or at least the body of the
994 * loop over all cells.
995 *
996
997 *
998 * The terms we integrate here are the cell contribution
999 * @f{align*}{
1000 * A^K_{ij} = \int_K \nabla^2\varphi_i(x) : \nabla^2\varphi_j(x) dx
1001 * @f}
1002 * to the global matrix, and
1003 * @f{align*}{
1004 * f^K_i = \int_K \varphi_i(x) f(x) dx
1005 * @f}
1006 * to the right hand side vector.
1007 *
1008
1009 *
1010 * We use the same technique as used in the assembly of @ref step_22 "step-22"
1011 * to accelerate the function: Instead of calling
1012 * `fe_values.shape_hessian(i, qpoint)` in the innermost loop,
1013 * we create a variable `hessian_i` that evaluates this
1014 * value once in the loop over `i` and re-use the so-evaluated
1015 * value in the loop over `j`. For symmetry, we do the same with a
1016 * variable `hessian_j`, although it is indeed only used once and
1017 * we could have left the call to `fe_values.shape_hessian(j,qpoint)`
1018 * in the instruction that computes the scalar product between
1019 * the two terms.
1020 *
1021 * @code
1022 *   auto cell_worker = [&](const Iterator &cell,
1023 *   ScratchData<dim> &scratch_data,
1024 *   CopyData &copy_data) {
1025 *   copy_data.cell_matrix = 0;
1026 *   copy_data.cell_rhs = 0;
1027 *  
1028 *   FEValues<dim> &fe_values = scratch_data.fe_values;
1029 *   fe_values.reinit(cell);
1030 *  
1031 *   cell->get_dof_indices(copy_data.local_dof_indices);
1032 *  
1033 *   ExactSolution::RightHandSide<dim> right_hand_side;
1034 *  
1035 *   const unsigned int dofs_per_cell =
1036 *   scratch_data.fe_values.get_fe().n_dofs_per_cell();
1037 *  
1038 *   for (unsigned int qpoint = 0; qpoint < fe_values.n_quadrature_points;
1039 *   ++qpoint)
1040 *   {
1041 *   for (unsigned int i = 0; i < dofs_per_cell; ++i)
1042 *   {
1043 *   const Tensor<2, dim> &hessian_i =
1044 *   fe_values.shape_hessian(i, qpoint);
1045 *  
1046 *   for (unsigned int j = 0; j < dofs_per_cell; ++j)
1047 *   {
1048 *   const Tensor<2, dim> &hessian_j =
1049 *   fe_values.shape_hessian(j, qpoint);
1050 *  
1051 *   copy_data.cell_matrix(i, j) +=
1052 *   scalar_product(hessian_i, // nabla^2 phi_i(x)
1053 *   hessian_j) * // nabla^2 phi_j(x)
1054 *   fe_values.JxW(qpoint); // dx
1055 *   }
1056 *  
1057 *   copy_data.cell_rhs(i) +=
1058 *   fe_values.shape_value(i, qpoint) * // phi_i(x)
1059 *   right_hand_side.value(
1060 *   fe_values.quadrature_point(qpoint)) * // f(x)
1061 *   fe_values.JxW(qpoint); // dx
1062 *   }
1063 *   }
1064 *   };
1065 *  
1066 *  
1067 * @endcode
1068 *
1069 * The next building block is the one that assembles penalty terms on each
1070 * of the interior faces of the mesh. As described in the documentation of
1071 * MeshWorker::mesh_loop(), this function receives arguments that denote
1072 * a cell and its neighboring cell, as well as (for each of the two
1073 * cells) the face (and potentially sub-face) we have to integrate
1074 * over. Again, we also get a scratch object, and a copy object
1075 * for putting the results in.
1076 *
1077
1078 *
1079 * The function has three parts itself. At the top, we initialize
1080 * the FEInterfaceValues object and create a new `CopyData::FaceData`
1081 * object to store our input in. This gets pushed to the end of the
1082 * `copy_data.face_data` variable. We need to do this because
1083 * the number of faces (or subfaces) over which we integrate for a
1084 * given cell differs from cell to cell, and the sizes of these
1085 * matrices also differ, depending on what degrees of freedom
1086 * are adjacent to the face or subface. As discussed in the documentation
1087 * of MeshWorker::mesh_loop(), the copy object is reset every time a new
1088 * cell is visited, so that what we push to the end of
1089 * `copy_data.face_data()` is really all that the later `copier` function
1090 * gets to see when it copies the contributions of each cell to the global
1091 * matrix and right hand side objects.
1092 *
1093 * @code
1094 *   auto face_worker = [&](const Iterator &cell,
1095 *   const unsigned int &f,
1096 *   const unsigned int &sf,
1097 *   const Iterator &ncell,
1098 *   const unsigned int &nf,
1099 *   const unsigned int &nsf,
1100 *   ScratchData<dim> &scratch_data,
1101 *   CopyData &copy_data) {
1102 *   FEInterfaceValues<dim> &fe_interface_values =
1103 *   scratch_data.fe_interface_values;
1104 *   fe_interface_values.reinit(cell, f, sf, ncell, nf, nsf);
1105 *  
1106 *   copy_data.face_data.emplace_back();
1107 *   CopyData::FaceData &copy_data_face = copy_data.face_data.back();
1108 *  
1109 *   copy_data_face.joint_dof_indices =
1110 *   fe_interface_values.get_interface_dof_indices();
1111 *  
1112 *   const unsigned int n_interface_dofs =
1113 *   fe_interface_values.n_current_interface_dofs();
1114 *   copy_data_face.cell_matrix.reinit(n_interface_dofs, n_interface_dofs);
1115 *  
1116 * @endcode
1117 *
1118 * The second part deals with determining what the penalty
1119 * parameter should be. By looking at the units of the various
1120 * terms in the bilinear form, it is clear that the penalty has
1121 * to have the form @f$\frac{\gamma}{h_K}@f$ (i.e., one over length
1122 * scale), but it is not a priori obvious how one should choose
1123 * the dimension-less number @f$\gamma@f$. From the discontinuous
1124 * Galerkin theory for the Laplace equation, one might
1125 * conjecture that the right choice is @f$\gamma=p(p+1)@f$ is the
1126 * right choice, where @f$p@f$ is the polynomial degree of the
1127 * finite element used. We will discuss this choice in a bit
1128 * more detail in the results section of this program.
1129 *
1130
1131 *
1132 * In the formula above, @f$h_K@f$ is the size of cell @f$K@f$. But this
1133 * is not quite so straightforward either: If one uses highly
1134 * stretched cells, then a more involved theory says that @f$h@f$
1135 * should be replaced by the diameter of cell @f$K@f$ normal to the
1136 * direction of the edge in question. It turns out that there
1137 * is a function in deal.II for that. Secondly, @f$h_K@f$ may be
1138 * different when viewed from the two different sides of a face.
1139 *
1140
1141 *
1142 * To stay on the safe side, we take the maximum of the two values.
1143 * We will note that it is possible that this computation has to be
1144 * further adjusted if one were to use hanging nodes resulting from
1145 * adaptive mesh refinement.
1146 *
1147 * @code
1148 *   const unsigned int p = fe.degree;
1149 *   const double gamma_over_h =
1150 *   std::max((1.0 * p * (p + 1) /
1151 *   cell->extent_in_direction(
1152 *   GeometryInfo<dim>::unit_normal_direction[f])),
1153 *   (1.0 * p * (p + 1) /
1154 *   ncell->extent_in_direction(
1155 *   GeometryInfo<dim>::unit_normal_direction[nf])));
1156 *  
1157 * @endcode
1158 *
1159 * Finally, and as usual, we loop over the quadrature points and
1160 * indices `i` and `j` to add up the contributions of this face
1161 * or sub-face. These are then stored in the
1162 * `copy_data.face_data` object created above. As for the cell
1163 * worker, we pull the evaluation of averages and jumps out of
1164 * the loops if possible, introducing local variables that store
1165 * these results. The assembly then only needs to use these
1166 * local variables in the innermost loop. Regarding the concrete
1167 * formula this code implements, recall that the interface terms
1168 * of the bilinear form were as follows:
1169 * @f{align*}{
1170 * -\sum_{e \in \mathbb{F}} \int_{e}
1171 * \jump{ \frac{\partial v_h}{\partial \mathbf n}}
1172 * \average{\frac{\partial^2 u_h}{\partial \mathbf n^2}} \ ds
1173 * -\sum_{e \in \mathbb{F}} \int_{e}
1174 * \average{\frac{\partial^2 v_h}{\partial \mathbf n^2}}
1175 * \jump{\frac{\partial u_h}{\partial \mathbf n}} \ ds
1176 * + \sum_{e \in \mathbb{F}}
1177 * \frac{\gamma}{h_e}
1178 * \int_e
1179 * \jump{\frac{\partial v_h}{\partial \mathbf n}}
1180 * \jump{\frac{\partial u_h}{\partial \mathbf n}} \ ds.
1181 * @f}
1182 *
1183 * @code
1184 *   for (unsigned int qpoint = 0;
1185 *   qpoint < fe_interface_values.n_quadrature_points;
1186 *   ++qpoint)
1187 *   {
1188 *   const auto &n = fe_interface_values.normal(qpoint);
1189 *  
1190 *   for (unsigned int i = 0; i < n_interface_dofs; ++i)
1191 *   {
1192 *   const double av_hessian_i_dot_n_dot_n =
1193 *   (fe_interface_values.average_of_shape_hessians(i, qpoint) * n *
1194 *   n);
1195 *   const double jump_grad_i_dot_n =
1196 *   (fe_interface_values.jump_in_shape_gradients(i, qpoint) * n);
1197 *  
1198 *   for (unsigned int j = 0; j < n_interface_dofs; ++j)
1199 *   {
1200 *   const double av_hessian_j_dot_n_dot_n =
1201 *   (fe_interface_values.average_of_shape_hessians(j, qpoint) *
1202 *   n * n);
1203 *   const double jump_grad_j_dot_n =
1204 *   (fe_interface_values.jump_in_shape_gradients(j, qpoint) *
1205 *   n);
1206 *  
1207 *   copy_data_face.cell_matrix(i, j) +=
1208 *   (-av_hessian_i_dot_n_dot_n // - {grad^2 v n n }
1209 *   * jump_grad_j_dot_n // [grad u n]
1210 *   - av_hessian_j_dot_n_dot_n // - {grad^2 u n n }
1211 *   * jump_grad_i_dot_n // [grad v n]
1212 *   + // +
1213 *   gamma_over_h * // gamma/h
1214 *   jump_grad_i_dot_n * // [grad v n]
1215 *   jump_grad_j_dot_n) * // [grad u n]
1216 *   fe_interface_values.JxW(qpoint); // dx
1217 *   }
1218 *   }
1219 *   }
1220 *   };
1221 *  
1222 *  
1223 * @endcode
1224 *
1225 * The third piece is to do the same kind of assembly for faces that
1226 * are at the boundary. The idea is the same as above, of course,
1227 * with only the difference that there are now penalty terms that
1228 * also go into the right hand side.
1229 *
1230
1231 *
1232 * As before, the first part of the function simply sets up some
1233 * helper objects:
1234 *
1235 * @code
1236 *   auto boundary_worker = [&](const Iterator &cell,
1237 *   const unsigned int &face_no,
1238 *   ScratchData<dim> &scratch_data,
1239 *   CopyData &copy_data) {
1240 *   FEInterfaceValues<dim> &fe_interface_values =
1241 *   scratch_data.fe_interface_values;
1242 *   fe_interface_values.reinit(cell, face_no);
1243 *   const auto &q_points = fe_interface_values.get_quadrature_points();
1244 *  
1245 *   copy_data.face_data.emplace_back();
1246 *   CopyData::FaceData &copy_data_face = copy_data.face_data.back();
1247 *  
1248 *   const unsigned int n_dofs =
1249 *   fe_interface_values.n_current_interface_dofs();
1250 *   copy_data_face.joint_dof_indices =
1251 *   fe_interface_values.get_interface_dof_indices();
1252 *  
1253 *   copy_data_face.cell_matrix.reinit(n_dofs, n_dofs);
1254 *  
1255 *   const std::vector<double> &JxW = fe_interface_values.get_JxW_values();
1256 *   const std::vector<Tensor<1, dim>> &normals =
1257 *   fe_interface_values.get_normal_vectors();
1258 *  
1259 *  
1260 *   ExactSolution::Solution<dim> exact_solution;
1261 *   std::vector<Tensor<1, dim>> exact_gradients(q_points.size());
1262 *   exact_solution.gradient_list(q_points, exact_gradients);
1263 *  
1264 *  
1265 * @endcode
1266 *
1267 * Positively, because we now only deal with one cell adjacent to the
1268 * face (as we are on the boundary), the computation of the penalty
1269 * factor @f$\gamma@f$ is substantially simpler:
1270 *
1271 * @code
1272 *   const unsigned int p = fe.degree;
1273 *   const double gamma_over_h =
1274 *   (1.0 * p * (p + 1) /
1275 *   cell->extent_in_direction(
1276 *   GeometryInfo<dim>::unit_normal_direction[face_no]));
1277 *  
1278 * @endcode
1279 *
1280 * The third piece is the assembly of terms. This is now
1281 * slightly more involved since these contains both terms for
1282 * the matrix and for the right hand side. The former is exactly
1283 * the same as for the interior faces stated above if one just
1284 * defines the jump and average appropriately (which is what the
1285 * FEInterfaceValues class does). The latter requires us to
1286 * evaluate the boundary conditions @f$j(\mathbf x)@f$, which in the
1287 * current case (where we know the exact solution) we compute
1288 * from @f$j(\mathbf x) = \frac{\partial u(\mathbf x)}{\partial
1289 * {\mathbf n}}@f$. The term to be added to the right hand side
1290 * vector is then
1291 * @f$\frac{\gamma}{h_e}\int_e
1292 * \jump{\frac{\partial v_h}{\partial \mathbf n}} j \ ds@f$.
1293 *
1294 * @code
1295 *   for (unsigned int qpoint = 0; qpoint < q_points.size(); ++qpoint)
1296 *   {
1297 *   const auto &n = normals[qpoint];
1298 *  
1299 *   for (unsigned int i = 0; i < n_dofs; ++i)
1300 *   {
1301 *   const double av_hessian_i_dot_n_dot_n =
1302 *   (fe_interface_values.average_of_shape_hessians(i, qpoint) * n *
1303 *   n);
1304 *   const double jump_grad_i_dot_n =
1305 *   (fe_interface_values.jump_in_shape_gradients(i, qpoint) * n);
1306 *  
1307 *   for (unsigned int j = 0; j < n_dofs; ++j)
1308 *   {
1309 *   const double av_hessian_j_dot_n_dot_n =
1310 *   (fe_interface_values.average_of_shape_hessians(j, qpoint) *
1311 *   n * n);
1312 *   const double jump_grad_j_dot_n =
1313 *   (fe_interface_values.jump_in_shape_gradients(j, qpoint) *
1314 *   n);
1315 *  
1316 *   copy_data_face.cell_matrix(i, j) +=
1317 *   (-av_hessian_i_dot_n_dot_n // - {grad^2 v n n}
1318 *   * jump_grad_j_dot_n // [grad u n]
1319 *  
1320 *   - av_hessian_j_dot_n_dot_n // - {grad^2 u n n}
1321 *   * jump_grad_i_dot_n // [grad v n]
1322 *  
1323 *   + gamma_over_h // gamma/h
1324 *   * jump_grad_i_dot_n // [grad v n]
1325 *   * jump_grad_j_dot_n // [grad u n]
1326 *   ) *
1327 *   JxW[qpoint]; // dx
1328 *   }
1329 *  
1330 *   copy_data.cell_rhs(i) +=
1331 *   (-av_hessian_i_dot_n_dot_n * // - {grad^2 v n n }
1332 *   (exact_gradients[qpoint] * n) // (grad u_exact . n)
1333 *   + // +
1334 *   gamma_over_h // gamma/h
1335 *   * jump_grad_i_dot_n // [grad v n]
1336 *   * (exact_gradients[qpoint] * n) // (grad u_exact . n)
1337 *   ) *
1338 *   JxW[qpoint]; // dx
1339 *   }
1340 *   }
1341 *   };
1342 *  
1343 * @endcode
1344 *
1345 * Part 4 is a small function that copies the data produced by the
1346 * cell, interior, and boundary face assemblers above into the
1347 * global matrix and right hand side vector. There really is not
1348 * very much to do here: We distribute the cell matrix and right
1349 * hand side contributions as we have done in almost all of the
1350 * other tutorial programs using the constraints objects. We then
1351 * also have to do the same for the face matrix contributions
1352 * that have gained content for the faces (interior and boundary)
1353 * and that the `face_worker` and `boundary_worker` have added
1354 * to the `copy_data.face_data` array.
1355 *
1356 * @code
1357 *   auto copier = [&](const CopyData &copy_data) {
1358 *   constraints.distribute_local_to_global(copy_data.cell_matrix,
1359 *   copy_data.cell_rhs,
1360 *   copy_data.local_dof_indices,
1361 *   system_matrix,
1362 *   system_rhs);
1363 *  
1364 *   for (const auto &cdf : copy_data.face_data)
1365 *   {
1366 *   constraints.distribute_local_to_global(cdf.cell_matrix,
1367 *   cdf.joint_dof_indices,
1368 *   system_matrix);
1369 *   }
1370 *   };
1371 *  
1372 *  
1373 * @endcode
1374 *
1375 * Having set all of this up, what remains is to just create a scratch
1376 * and copy data object and call the MeshWorker::mesh_loop() function
1377 * that then goes over all cells and faces, calls the respective workers
1378 * on them, and then the copier function that puts things into the
1379 * global matrix and right hand side. As an additional benefit,
1380 * MeshWorker::mesh_loop() does all of this in parallel, using
1381 * as many processor cores as your machine happens to have.
1382 *
1383 * @code
1384 *   const unsigned int n_gauss_points = dof_handler.get_fe().degree + 1;
1385 *   ScratchData<dim> scratch_data(mapping,
1386 *   fe,
1387 *   n_gauss_points,
1388 *   update_values | update_gradients |
1389 *   update_hessians | update_quadrature_points |
1390 *   update_JxW_values,
1391 *   update_values | update_gradients |
1392 *   update_hessians | update_quadrature_points |
1393 *   update_JxW_values | update_normal_vectors);
1394 *   CopyData copy_data(dof_handler.get_fe().n_dofs_per_cell());
1395 *   MeshWorker::mesh_loop(dof_handler.begin_active(),
1396 *   dof_handler.end(),
1397 *   cell_worker,
1398 *   copier,
1399 *   scratch_data,
1400 *   copy_data,
1401 *   MeshWorker::assemble_own_cells |
1402 *   MeshWorker::assemble_boundary_faces |
1403 *   MeshWorker::assemble_own_interior_faces_once,
1404 *   boundary_worker,
1405 *   face_worker);
1406 *   }
1407 *  
1408 *  
1409 *  
1410 * @endcode
1411 *
1412 *
1413 * <a name="step_47-Solvingthelinearsystemandpostprocessing"></a>
1414 * <h4>Solving the linear system and postprocessing</h4>
1415 *
1416
1417 *
1418 * The show is essentially over at this point: The remaining functions are
1419 * not overly interesting or novel. The first one simply uses a direct
1420 * solver to solve the linear system (see also @ref step_29 "step-29"):
1421 *
1422 * @code
1423 *   template <int dim>
1424 *   void BiharmonicProblem<dim>::solve()
1425 *   {
1426 *   std::cout << " Solving system..." << std::endl;
1427 *  
1428 *   SparseDirectUMFPACK A_direct;
1429 *   A_direct.initialize(system_matrix);
1430 *   A_direct.vmult(solution, system_rhs);
1431 *  
1432 *   constraints.distribute(solution);
1433 *   }
1434 *  
1435 *  
1436 *  
1437 * @endcode
1438 *
1439 * The next function evaluates the error between the computed solution
1440 * and the exact solution (which is known here because we have chosen
1441 * the right hand side and boundary values in a way so that we know
1442 * the corresponding solution). In the first two code blocks below,
1443 * we compute the error in the @f$L_2@f$ norm and the @f$H^1@f$ semi-norm.
1444 *
1445 * @code
1446 *   template <int dim>
1447 *   void BiharmonicProblem<dim>::compute_errors()
1448 *   {
1449 *   {
1450 *   Vector<float> norm_per_cell(triangulation.n_active_cells());
1451 *   VectorTools::integrate_difference(mapping,
1452 *   dof_handler,
1453 *   solution,
1454 *   ExactSolution::Solution<dim>(),
1455 *   norm_per_cell,
1456 *   QGauss<dim>(fe.degree + 2),
1457 *   VectorTools::L2_norm);
1458 *   const double error_norm =
1459 *   VectorTools::compute_global_error(triangulation,
1460 *   norm_per_cell,
1461 *   VectorTools::L2_norm);
1462 *   std::cout << " Error in the L2 norm : " << error_norm
1463 *   << std::endl;
1464 *   }
1465 *  
1466 *   {
1467 *   Vector<float> norm_per_cell(triangulation.n_active_cells());
1468 *   VectorTools::integrate_difference(mapping,
1469 *   dof_handler,
1470 *   solution,
1471 *   ExactSolution::Solution<dim>(),
1472 *   norm_per_cell,
1473 *   QGauss<dim>(fe.degree + 2),
1474 *   VectorTools::H1_seminorm);
1475 *   const double error_norm =
1476 *   VectorTools::compute_global_error(triangulation,
1477 *   norm_per_cell,
1478 *   VectorTools::H1_seminorm);
1479 *   std::cout << " Error in the H1 seminorm : " << error_norm
1480 *   << std::endl;
1481 *   }
1482 *  
1483 * @endcode
1484 *
1485 * Now also compute an approximation to the @f$H^2@f$ seminorm error. The actual
1486 * @f$H^2@f$ seminorm would require us to integrate second derivatives of the
1487 * solution @f$u_h@f$, but given the Lagrange shape functions we use, @f$u_h@f$ of
1488 * course has kinks at the interfaces between cells, and consequently second
1489 * derivatives are singular at interfaces. As a consequence, we really only
1490 * integrate over the interior of cells and ignore the interface
1491 * contributions. This is *not* an equivalent norm to the energy norm for
1492 * the problem, but still gives us an idea of how fast the error converges.
1493 *
1494
1495 *
1496 * We note that one could address this issue by defining a norm that
1497 * is equivalent to the energy norm. This would involve adding up not
1498 * only the integrals over cell interiors as we do below, but also adding
1499 * penalty terms for the jump of the derivative of @f$u_h@f$ across interfaces,
1500 * with an appropriate scaling of the two kinds of terms. We will leave
1501 * this for later work.
1502 *
1503 * @code
1504 *   {
1505 *   const QGauss<dim> quadrature_formula(fe.degree + 2);
1506 *   ExactSolution::Solution<dim> exact_solution;
1507 *   Vector<double> error_per_cell(triangulation.n_active_cells());
1508 *  
1509 *   FEValues<dim> fe_values(mapping,
1510 *   fe,
1511 *   quadrature_formula,
1512 *   update_values | update_hessians |
1513 *   update_quadrature_points | update_JxW_values);
1514 *  
1515 *   const FEValuesExtractors::Scalar scalar(0);
1516 *   const unsigned int n_q_points = quadrature_formula.size();
1517 *  
1518 *   std::vector<SymmetricTensor<2, dim>> exact_hessians(n_q_points);
1519 *   std::vector<Tensor<2, dim>> hessians(n_q_points);
1520 *   for (auto &cell : dof_handler.active_cell_iterators())
1521 *   {
1522 *   fe_values.reinit(cell);
1523 *   fe_values[scalar].get_function_hessians(solution, hessians);
1524 *   exact_solution.hessian_list(fe_values.get_quadrature_points(),
1525 *   exact_hessians);
1526 *  
1527 *   double local_error = 0;
1528 *   for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
1529 *   {
1530 *   local_error +=
1531 *   ((exact_hessians[q_point] - hessians[q_point]).norm_square() *
1532 *   fe_values.JxW(q_point));
1533 *   }
1534 *   error_per_cell[cell->active_cell_index()] = std::sqrt(local_error);
1535 *   }
1536 *  
1537 *   const double error_norm =
1538 *   VectorTools::compute_global_error(triangulation,
1539 *   error_per_cell,
1540 *   VectorTools::L2_norm);
1541 *   std::cout << " Error in the broken H2 seminorm: " << error_norm
1542 *   << std::endl;
1543 *   }
1544 *   }
1545 *  
1546 *  
1547 *  
1548 * @endcode
1549 *
1550 * Equally uninteresting is the function that generates graphical output.
1551 * It looks exactly like the one in @ref step_6 "step-6", for example.
1552 *
1553 * @code
1554 *   template <int dim>
1555 *   void
1556 *   BiharmonicProblem<dim>::output_results(const unsigned int iteration) const
1557 *   {
1558 *   std::cout << " Writing graphical output..." << std::endl;
1559 *  
1560 *   DataOut<dim> data_out;
1561 *  
1562 *   data_out.attach_dof_handler(dof_handler);
1563 *   data_out.add_data_vector(solution, "solution");
1564 *   data_out.build_patches();
1565 *  
1566 *   const std::string filename =
1567 *   ("output_" + Utilities::int_to_string(iteration, 6) + ".vtu");
1568 *   std::ofstream output_vtu(filename);
1569 *   data_out.write_vtu(output_vtu);
1570 *   }
1571 *  
1572 *  
1573 *  
1574 * @endcode
1575 *
1576 * The same is true for the `run()` function: Just like in previous
1577 * programs.
1578 *
1579 * @code
1580 *   template <int dim>
1581 *   void BiharmonicProblem<dim>::run()
1582 *   {
1583 *   make_grid();
1584 *  
1585 *   const unsigned int n_cycles = 4;
1586 *   for (unsigned int cycle = 0; cycle < n_cycles; ++cycle)
1587 *   {
1588 *   std::cout << "Cycle " << cycle << " of " << n_cycles << std::endl;
1589 *  
1590 *   triangulation.refine_global(1);
1591 *   setup_system();
1592 *  
1593 *   assemble_system();
1594 *   solve();
1595 *  
1596 *   output_results(cycle);
1597 *  
1598 *   compute_errors();
1599 *   std::cout << std::endl;
1600 *   }
1601 *   }
1602 *   } // namespace Step47
1603 *  
1604 *  
1605 *  
1606 * @endcode
1607 *
1608 *
1609 * <a name="step_47-Themainfunction"></a>
1610 * <h3>The main() function</h3>
1611 *
1612
1613 *
1614 * Finally for the `main()` function. There is, again, not very much to see
1615 * here: It looks like the ones in previous tutorial programs. There
1616 * is a variable that allows selecting the polynomial degree of the element
1617 * we want to use for solving the equation. Because the C0IP formulation
1618 * we use requires the element degree to be at least two, we check with
1619 * an assertion that whatever one sets for the polynomial degree actually
1620 * makes sense.
1621 *
1622 * @code
1623 *   int main()
1624 *   {
1625 *   try
1626 *   {
1627 *   using namespace dealii;
1628 *   using namespace Step47;
1629 *  
1630 *   const unsigned int fe_degree = 2;
1631 *   Assert(fe_degree >= 2,
1632 *   ExcMessage("The C0IP formulation for the biharmonic problem "
1633 *   "only works if one uses elements of polynomial "
1634 *   "degree at least 2."));
1635 *  
1636 *   BiharmonicProblem<2> biharmonic_problem(fe_degree);
1637 *   biharmonic_problem.run();
1638 *   }
1639 *   catch (std::exception &exc)
1640 *   {
1641 *   std::cerr << std::endl
1642 *   << std::endl
1643 *   << "----------------------------------------------------"
1644 *   << std::endl;
1645 *   std::cerr << "Exception on processing: " << std::endl
1646 *   << exc.what() << std::endl
1647 *   << "Aborting!" << std::endl
1648 *   << "----------------------------------------------------"
1649 *   << std::endl;
1650 *  
1651 *   return 1;
1652 *   }
1653 *   catch (...)
1654 *   {
1655 *   std::cerr << std::endl
1656 *   << std::endl
1657 *   << "----------------------------------------------------"
1658 *   << std::endl;
1659 *   std::cerr << "Unknown exception!" << std::endl
1660 *   << "Aborting!" << std::endl
1661 *   << "----------------------------------------------------"
1662 *   << std::endl;
1663 *   return 1;
1664 *   }
1665 *  
1666 *   return 0;
1667 *   }
1668 * @endcode
1669<a name="step_47-Results"></a><h1>Results</h1>
1670
1671
1672We run the program with right hand side and boundary values as
1673discussed in the introduction. These will produce the
1674solution @f$u = \sin(\pi x) \sin(\pi y)@f$ on the domain @f$\Omega = (0,1)^2@f$.
1675We test this setup using @f$Q_2@f$, @f$Q_3@f$, and @f$Q_4@f$ elements, which one can
1676change via the `fe_degree` variable in the `main()` function. With mesh
1677refinement, the @f$L_2@f$ convergence rates, @f$H^1@f$-seminorm rate,
1678and @f$H^2@f$-seminorm convergence of @f$u@f$
1679should then be around 2, 2, 1 for @f$Q_2@f$ (with the @f$L_2@f$ norm
1680sub-optimal as discussed in the introduction); 4, 3, 2 for
1681@f$Q_3@f$; and 5, 4, 3 for @f$Q_4@f$, respectively.
1682
1683From the literature, it is not immediately clear what
1684the penalty parameter @f$\gamma@f$ should be. For example,
1685@cite Brenner2010 state that it needs to be larger than one, and
1686choose @f$\gamma=5@f$. The FEniCS/Dolphin tutorial chooses it as
1687@f$\gamma=8@f$, see
1688https://fenicsproject.org/docs/dolfin/1.6.0/python/demo/documented/biharmonic/python/documentation.html
1689. @cite Wells2007 uses a value for @f$\gamma@f$ larger than the
1690number of edges belonging to an element for Kirchhoff plates (see
1691their Section 4.2). This suggests that maybe
1692@f$\gamma = 1@f$, @f$2@f$, are too small; on the other hand, a value
1693@f$p(p+1)@f$ would be reasonable,
1694where @f$p@f$ is the degree of polynomials. The last of these choices is
1695the one one would expect to work by comparing
1696to the discontinuous Galerkin formulations for the Laplace equation
1697(see, for example, the discussions in @ref step_39 "step-39" and @ref step_74 "step-74"),
1698and it will turn out to also work here.
1699But we should check what value of @f$\gamma@f$ is right, and we will do so
1700below; changing @f$\gamma@f$ is easy in the two `face_worker` and
1701`boundary_worker` functions defined in `assemble_system()`.
1702
1703
1704<a name="step_47-TestresultsoniQsub2subiwithigammapp1i"></a><h3>Test results on <i>Q<sub>2</sub></i> with <i>&gamma; = p(p+1)</i> </h3>
1705
1706
1707We run the code with differently refined meshes
1708and get the following convergence rates.
1709
1710<table align="center" class="doxtable">
1711 <tr>
1712 <th>Number of refinements </th><th> @f$\|u-u_h\|_{L_2}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|_{H^1}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|^\circ_{H^2}@f$ </th><th> Conv. rates </th>
1713 </tr>
1714 <tr>
1715 <td> 2 </td><td> 8.780e-03 </td><td> </td><td> 7.095e-02 </td><td> </td><td> 1.645 </td><td> </td>
1716 </tr>
1717 <tr>
1718 <td> 3 </td><td> 3.515e-03 </td><td> 1.32 </td><td> 2.174e-02 </td><td> 1.70 </td><td> 8.121e-01 </td><td> 1.018 </td>
1719 </tr>
1720 <tr>
1721 <td> 4 </td><td> 1.103e-03 </td><td> 1.67 </td><td> 6.106e-03 </td><td> 1.83 </td><td> 4.015e-01 </td><td> 1.016 </td>
1722 </tr>
1723 <tr>
1724 <td> 5 </td><td> 3.084e-04 </td><td> 1.83 </td><td> 1.622e-03 </td><td> 1.91 </td><td> 1.993e-01 </td><td> 1.010 </td>
1725 </tr>
1726</table>
1727We can see that the @f$L_2@f$ convergence rates are around 2,
1728@f$H^1@f$-seminorm convergence rates are around 2,
1729and @f$H^2@f$-seminorm convergence rates are around 1. The latter two
1730match the theoretically expected rates; for the former, we have no
1731theorem but are not surprised that it is sub-optimal given the remark
1732in the introduction.
1733
1734
1735<a name="step_47-TestresultsoniQsub3subiwithigammapp1i"></a><h3>Test results on <i>Q<sub>3</sub></i> with <i>&gamma; = p(p+1)</i> </h3>
1736
1737
1738
1739<table align="center" class="doxtable">
1740 <tr>
1741 <th>Number of refinements </th><th> @f$\|u-u_h\|_{L_2}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|_{H^1}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|^\circ_{H^2}@f$ </th><th> Conv. rates </th>
1742 </tr>
1743 <tr>
1744 <td> 2 </td><td> 2.045e-04 </td><td> </td><td> 4.402e-03 </td><td> </td><td> 1.641e-01 </td><td> </td>
1745 </tr>
1746 <tr>
1747 <td> 3 </td><td> 1.312e-05 </td><td> 3.96 </td><td> 5.537e-04 </td><td> 2.99 </td><td> 4.096e-02 </td><td> 2.00 </td>
1748 </tr>
1749 <tr>
1750 <td> 4 </td><td> 8.239e-07 </td><td> 3.99 </td><td> 6.904e-05 </td><td> 3.00 </td><td> 1.023e-02 </td><td> 2.00 </td>
1751 </tr>
1752 <tr>
1753 <td> 5 </td><td> 5.158e-08 </td><td> 3.99 </td><td> 8.621e-06 </td><td> 3.00 </td><td> 2.558e-03 </td><td> 2.00 </td>
1754 </tr>
1755</table>
1756We can see that the @f$L_2@f$ convergence rates are around 4,
1757@f$H^1@f$-seminorm convergence rates are around 3,
1758and @f$H^2@f$-seminorm convergence rates are around 2.
1759This, of course, matches our theoretical expectations.
1760
1761
1762<a name="step_47-TestresultsoniQsub4subiwithigammapp1i"></a><h3>Test results on <i>Q<sub>4</sub></i> with <i>&gamma; = p(p+1)</i> </h3>
1763
1764
1765<table align="center" class="doxtable">
1766 <tr>
1767 <th>Number of refinements </th><th> @f$\|u-u_h\|_{L_2}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|_{H^1}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|^\circ_{H^2}@f$ </th><th> Conv. rates </th>
1768 </tr>
1769 <tr>
1770 <td> 2 </td><td> 6.510e-06 </td><td> </td><td> 2.215e-04 </td><td> </td><td> 1.275e-02 </td><td> </td>
1771 </tr>
1772 <tr>
1773 <td> 3 </td><td> 2.679e-07 </td><td> 4.60 </td><td> 1.569e-05 </td><td> 3.81 </td><td> 1.496e-03 </td><td> 3.09 </td>
1774 </tr>
1775 <tr>
1776 <td> 4 </td><td> 9.404e-09 </td><td> 4.83 </td><td> 1.040e-06 </td><td> 3.91 </td><td> 1.774e-04 </td><td> 3.07 </td>
1777 </tr>
1778 <tr>
1779 <td> 5 </td><td> 7.943e-10 </td><td> 3.56 </td><td> 6.693e-08 </td><td> 3.95 </td><td> 2.150e-05 </td><td> 3.04 </td>
1780 </tr>
1781</table>
1782We can see that the @f$L_2@f$ norm convergence rates are around 5,
1783@f$H^1@f$-seminorm convergence rates are around 4,
1784and @f$H^2@f$-seminorm convergence rates are around 3.
1785On the finest mesh, the @f$L_2@f$ norm convergence rate
1786is much smaller than our theoretical expectations
1787because the linear solver becomes the limiting factor due
1788to round-off. Of course the @f$L_2@f$ error is also very small already in
1789that case.
1790
1791
1792<a name="step_47-TestresultsoniQsub2subiwithigamma1i"></a><h3>Test results on <i>Q<sub>2</sub></i> with <i>&gamma; = 1</i> </h3>
1793
1794
1795For comparison with the results above, let us now also consider the
1796case where we simply choose @f$\gamma=1@f$:
1797
1798<table align="center" class="doxtable">
1799 <tr>
1800 <th>Number of refinements </th><th> @f$\|u-u_h\|_{L_2}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|_{H^1}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|^\circ_{H^2}@f$ </th><th> Conv. rates </th>
1801 </tr>
1802 <tr>
1803 <td> 2 </td><td> 7.350e-02 </td><td> </td><td> 7.323e-01 </td><td> </td><td> 10.343 </td><td> </td>
1804 </tr>
1805 <tr>
1806 <td> 3 </td><td> 6.798e-03 </td><td> 3.43 </td><td> 1.716e-01 </td><td> 2.09 </td><td>4.836 </td><td> 1.09 </td>
1807 </tr>
1808 <tr>
1809 <td> 4 </td><td> 9.669e-04 </td><td> 2.81 </td><td> 6.436e-02 </td><td> 1.41 </td><td> 3.590 </td><td> 0.430 </td>
1810 </tr>
1811 <tr>
1812 <td> 5 </td><td> 1.755e-04 </td><td> 2.46 </td><td> 2.831e-02 </td><td> 1.18 </td><td>3.144 </td><td> 0.19 </td>
1813 </tr>
1814</table>
1815Although @f$L_2@f$ norm convergence rates of @f$u@f$ more or less
1816follows the theoretical expectations,
1817the @f$H^1@f$-seminorm and @f$H^2@f$-seminorm do not seem to converge as expected.
1818Comparing results from @f$\gamma = 1@f$ and @f$\gamma = p(p+1)@f$, it is clear that
1819@f$\gamma = p(p+1)@f$ is a better penalty.
1820Given that @f$\gamma=1@f$ is already too small for @f$Q_2@f$ elements, it may not be surprising that if one repeated the
1821experiment with a @f$Q_3@f$ element, the results are even more disappointing: One again only obtains convergence
1822rates of 2, 1, zero -- i.e., no better than for the @f$Q_2@f$ element (although the errors are smaller in magnitude).
1823Maybe surprisingly, however, one obtains more or less the expected convergence orders when using @f$Q_4@f$
1824elements. Regardless, this uncertainty suggests that @f$\gamma=1@f$ is at best a risky choice, and at worst an
1825unreliable one and that we should choose @f$\gamma@f$ larger.
1826
1827
1828<a name="step_47-TestresultsoniQsub2subiwithigamma2i"></a><h3>Test results on <i>Q<sub>2</sub></i> with <i>&gamma; = 2</i> </h3>
1829
1830
1831Since @f$\gamma=1@f$ is clearly too small, one might conjecture that
1832@f$\gamma=2@f$ might actually work better. Here is what one obtains in
1833that case:
1834
1835<table align="center" class="doxtable">
1836 <tr>
1837 <th>Number of refinements </th><th> @f$\|u-u_h\|_{L_2}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|_{H^1}@f$ </th><th> Conv. rates </th><th> @f$|u-u_h|^\circ_{H^2}@f$ </th><th> Conv. rates </th>
1838 </tr>
1839 <tr>
1840 <td> 2 </td><td> 4.133e-02 </td><td> </td><td> 2.517e-01 </td><td> </td><td> 3.056 </td><td> </td>
1841 </tr>
1842 <tr>
1843 <td> 3 </td><td> 6.500e-03 </td><td>2.66 </td><td> 5.916e-02 </td><td> 2.08 </td><td>1.444 </td><td> 1.08 </td>
1844 </tr>
1845 <tr>
1846 <td> 4 </td><td> 6.780e-04 </td><td> 3.26 </td><td> 1.203e-02 </td><td> 2.296 </td><td> 6.151e-01 </td><td> 1.231 </td>
1847 </tr>
1848 <tr>
1849 <td> 5 </td><td> 1.622e-04 </td><td> 2.06 </td><td> 2.448e-03 </td><td> 2.297 </td><td> 2.618e-01 </td><td> 1.232 </td>
1850 </tr>
1851</table>
1852In this case, the convergence rates more or less follow the
1853theoretical expectations, but, compared to the results from @f$\gamma =
1854p(p+1)@f$, are more variable.
1855Again, we could repeat this kind of experiment for @f$Q_3@f$ and @f$Q_4@f$ elements. In both cases, we will find that we
1856obtain roughly the expected convergence rates. Of more interest may then be to compare the absolute
1857size of the errors. While in the table above, for the @f$Q_2@f$ case, the errors on the finest grid are comparable between
1858the @f$\gamma=p(p+1)@f$ and @f$\gamma=2@f$ case, for @f$Q_3@f$ the errors are substantially larger for @f$\gamma=2@f$ than for
1859@f$\gamma=p(p+1)@f$. The same is true for the @f$Q_4@f$ case.
1860
1861
1862<a name="step_47-Conclusionsforthechoiceofthepenaltyparameter"></a><h3> Conclusions for the choice of the penalty parameter </h3>
1863
1864
1865The conclusions for which of the "reasonable" choices one should use for the penalty parameter
1866is that @f$\gamma=p(p+1)@f$ yields the expected results. It is, consequently, what the code
1867uses as currently written.
1868
1869
1870<a name="step_47-Possibilitiesforextensions"></a><h3> Possibilities for extensions </h3>
1871
1872
1873There are a number of obvious extensions to this program that would
1874make sense:
1875
1876- The program uses a square domain and a uniform mesh. Real problems
1877 don't come this way, and one should verify convergence also on
1878 domains with other shapes and, in particular, curved boundaries. One
1879 may also be interested in resolving areas of less regularity by
1880 using adaptive mesh refinement.
1881
1882- From a more theoretical perspective, the convergence results above
1883 only used the "broken" @f$H^2@f$ seminorm @f$|\cdot|^\circ_{H^2}@f$ instead
1884 of the "equivalent" norm @f$|\cdot|_h@f$. This is good enough to
1885 convince ourselves that the program isn't fundamentally
1886 broken. However, it might be interesting to measure the error in the
1887 actual norm for which we have theoretical results. Implementing this
1888 addition should not be overly difficult using, for example, the
1889 FEInterfaceValues class combined with MeshWorker::mesh_loop() in the
1890 same spirit as we used for the assembly of the linear system.
1891
1892
1893<a name="step_47-Derivationforthesimplysupportedplates"></a> <h4> Derivation for the simply supported plates </h4>
1894
1895
1896 Similar to the "clamped" boundary condition addressed in the implementation,
1897 we will derive the @f$C^0@f$ IP finite element scheme for simply supported plates:
1898 @f{align*}{
1899 \Delta^2 u(\mathbf x) &= f(\mathbf x)
1900 \qquad \qquad &&\forall \mathbf x \in \Omega,
1901 u(\mathbf x) &= g(\mathbf x) \qquad \qquad
1902 &&\forall \mathbf x \in \partial\Omega, \\
1903 \Delta u(\mathbf x) &= h(\mathbf x) \qquad \qquad
1904 &&\forall \mathbf x \in \partial\Omega.
1905 @f}
1906 We multiply the biharmonic equation by the test function @f$v_h@f$ and integrate over @f$ K @f$ and get:
1907 @f{align*}{
1908 \int_K v_h (\Delta^2 u_h)
1909 &= \int_K (D^2 v_h) : (D^2 u_h)
1910 + \int_{\partial K} v_h \frac{\partial (\Delta u_h)}{\partial \mathbf{n}}
1911 -\int_{\partial K} (\nabla v_h) \cdot (\frac{\partial \nabla u_h}{\partial \mathbf{n}}).
1912 @f}
1913
1914 Summing up over all cells @f$K \in \mathbb{T}@f$,since normal directions of @f$\Delta u_h@f$ are pointing at
1915 opposite directions on each interior edge shared by two cells and @f$v_h = 0@f$ on @f$\partial \Omega@f$,
1916 @f{align*}{
1917 \sum_{K \in \mathbb{T}} \int_{\partial K} v_h \frac{\partial (\Delta u_h)}{\partial \mathbf{n}} = 0,
1918 @f}
1919 and by the definition of jump over cell interfaces,
1920 @f{align*}{
1921 -\sum_{K \in \mathbb{T}} \int_{\partial K} (\nabla v_h) \cdot (\frac{\partial \nabla u_h}{\partial \mathbf{n}}) = -\sum_{e \in \mathbb{F}} \int_{e} \jump{\frac{\partial v_h}{\partial \mathbf{n}}} (\frac{\partial^2 u_h}{\partial \mathbf{n^2}}).
1922 @f}
1923 We separate interior faces and boundary faces of the domain,
1924 @f{align*}{
1925 -\sum_{K \in \mathbb{T}} \int_{\partial K} (\nabla v_h) \cdot (\frac{\partial \nabla u_h}{\partial \mathbf{n}}) = -\sum_{e \in \mathbb{F}^i} \int_{e} \jump{\frac{\partial v_h}{\partial \mathbf{n}}} (\frac{\partial^2 u_h}{\partial \mathbf{n^2}})
1926 - \sum_{e \in \partial \Omega} \int_{e} \jump{\frac{\partial v_h}{\partial \mathbf{n}}} h,
1927 @f}
1928 where @f$\mathbb{F}^i@f$ is the set of interior faces.
1929 This leads us to
1930 @f{align*}{
1931 \sum_{K \in \mathbb{T}} \int_K (D^2 v_h) : (D^2 u_h) \ dx - \sum_{e \in \mathbb{F}^i} \int_{e} \jump{\frac{\partial v_h}{\partial \mathbf{n}}} (\frac{\partial^2 u_h}{\partial \mathbf{n^2}}) \ ds
1932 = \sum_{K \in \mathbb{T}}\int_{K} v_h f \ dx + \sum_{e\subset\partial\Omega} \int_{e} \jump{\frac{\partial v_h}{\partial \mathbf{n}}} h \ ds.
1933 @f}
1934
1935 In order to symmetrize and stabilize the discrete problem,
1936 we add symmetrization and stabilization term.
1937 We finally get the @f$C^0@f$ IP finite element scheme for the biharmonic equation:
1938 find @f$u_h@f$ such that @f$u_h =g@f$ on @f$\partial \Omega@f$ and
1939 @f{align*}{
1940 \mathcal{A}(v_h,u_h)&=\mathcal{F}(v_h) \quad \text{holds for all test functions } v_h,
1941 @f}
1942 where
1943 @f{align*}{
1944 \mathcal{A}(v_h,u_h):=&\sum_{K \in \mathbb{T}}\int_K D^2v_h:D^2u_h \ dx
1945 \\
1946 &
1947 -\sum_{e \in \mathbb{F}^i} \int_{e}
1948 \jump{\frac{\partial v_h}{\partial \mathbf n}}
1949 \average{\frac{\partial^2 u_h}{\partial \mathbf n^2}} \ ds
1950 -\sum_{e \in \mathbb{F}^i} \int_{e}
1951 \average{\frac{\partial^2 v_h}{\partial \mathbf n^2}}
1952 \jump{\frac{\partial u_h}{\partial \mathbf n}} \ ds
1953 \\
1954 &+ \sum_{e \in \mathbb{F}^i}
1955 \frac{\gamma}{h_e}
1956 \int_e
1957 \jump{\frac{\partial v_h}{\partial \mathbf n}}
1958 \jump{\frac{\partial u_h}{\partial \mathbf n}} \ ds,
1959 @f}
1960 and
1961 @f{align*}{
1962 \mathcal{F}(v_h)&:=\sum_{K \in \mathbb{T}}\int_{K} v_h f \ dx
1963 +
1964 \sum_{e\subset\partial\Omega}
1965 \int_e \jump{\frac{\partial v_h}{\partial \mathbf n}} h \ ds.
1966 @f}
1967 The implementation of this boundary case is similar to the "clamped" version
1968 except that `boundary_worker` is no longer needed for system assembling
1969 and the right hand side is changed according to the formulation.
1970 *
1971 *
1972<a name="step_47-PlainProg"></a>
1973<h1> The plain program</h1>
1974@include "step-47.cc"
1975*/
Definition fe_q.h:554
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
Definition point.h:111
void make_hanging_node_constraints(const DoFHandler< dim, spacedim > &dof_handler, AffineConstraints< number > &constraints)
void make_flux_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern)
const Event initial
Definition event.cc:64
void hyper_cube(Triangulation< dim, spacedim > &tria, const double left=0., const double right=1., const bool colorize=false)
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
Definition divergence.h:471
void interpolate_boundary_values(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const std::map< types::boundary_id, const Function< spacedim, number > * > &function_map, std::map< types::global_dof_index, number > &boundary_values, const ComponentMask &component_mask={})
void run(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length, const unsigned int chunk_size)
int(&) functions(const void *v1, const void *v2)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation