]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Step-12: select quadrature at a central place 11455/head
authorPeter Munch <peterrmuench@gmail.com>
Sat, 2 Jan 2021 10:55:40 +0000 (11:55 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Sat, 2 Jan 2021 22:42:33 +0000 (23:42 +0100)
examples/step-12/step-12.cc

index ac096ba25601555166c18e94942846f3e497c585..c23bca2e08001edeae27627710e97eef0bd77422 100644 (file)
@@ -145,20 +145,21 @@ namespace Step12
   template <int dim>
   struct ScratchData
   {
-    ScratchData(const Mapping<dim> &      mapping,
-                const FiniteElement<dim> &fe,
-                const unsigned int        quadrature_degree,
-                const UpdateFlags         update_flags = update_values |
+    ScratchData(const Mapping<dim> &       mapping,
+                const FiniteElement<dim> & fe,
+                const Quadrature<dim> &    quadrature,
+                const Quadrature<dim - 1> &quadrature_face,
+                const UpdateFlags          update_flags = update_values |
                                                  update_gradients |
                                                  update_quadrature_points |
                                                  update_JxW_values,
                 const UpdateFlags interface_update_flags =
                   update_values | update_gradients | update_quadrature_points |
                   update_JxW_values | update_normal_vectors)
-      : fe_values(mapping, fe, QGauss<dim>(quadrature_degree), update_flags)
+      : fe_values(mapping, fe, quadrature, update_flags)
       , fe_interface_values(mapping,
                             fe,
-                            QGauss<dim - 1>(quadrature_degree),
+                            quadrature_face,
                             interface_update_flags)
     {}
 
@@ -232,8 +233,11 @@ namespace Step12
     const MappingQ1<dim> mapping;
 
     // Furthermore we want to use DG elements.
-    FE_DGQ<dim>     fe;
-    DoFHandler<dim> dof_handler;
+    const FE_DGQ<dim> fe;
+    DoFHandler<dim>   dof_handler;
+
+    const QGauss<dim>     quadrature;
+    const QGauss<dim - 1> quadrature_face;
 
     // The next four members represent the linear system to be solved.
     // <code>system_matrix</code> and <code>right_hand_side</code> are generated
@@ -255,6 +259,8 @@ namespace Step12
     : mapping()
     , fe(1)
     , dof_handler(triangulation)
+    , quadrature(fe.tensor_degree() + 1)
+    , quadrature_face(fe.tensor_degree() + 1)
   {}
 
 
@@ -435,9 +441,7 @@ namespace Step12
         }
     };
 
-    const unsigned int n_gauss_points = dof_handler.get_fe().degree + 1;
-
-    ScratchData<dim> scratch_data(mapping, fe, n_gauss_points);
+    ScratchData<dim> scratch_data(mapping, fe, quadrature, quadrature_face);
     CopyData         copy_data;
 
     // Here, we finally handle the assembly. We pass in ScratchData and
@@ -550,7 +554,7 @@ namespace Step12
     data_out.attach_dof_handler(dof_handler);
     data_out.add_data_vector(solution, "u", DataOut<dim>::type_dof_data);
 
-    data_out.build_patches();
+    data_out.build_patches(mapping);
 
     data_out.write_vtk(output);
 
@@ -561,7 +565,7 @@ namespace Step12
                                         solution,
                                         Functions::ZeroFunction<dim>(),
                                         values,
-                                        QGauss<dim>(fe.degree + 1),
+                                        quadrature,
                                         VectorTools::Linfty_norm);
       const double l_infty =
         VectorTools::compute_global_error(triangulation,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.