]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make 'mapping' variables 'const' in example files
authorLóránt Hadnagy <ae7tb99@protonmail.ch>
Thu, 25 Jul 2024 16:37:51 +0000 (19:37 +0300)
committerLóránt Hadnagy <ae7tb99@protonmail.ch>
Thu, 25 Jul 2024 16:37:51 +0000 (19:37 +0300)
18 files changed:
examples/step-11/step-11.cc
examples/step-16/step-16.cc
examples/step-34/step-34.cc
examples/step-37/step-37.cc
examples/step-38/step-38.cc
examples/step-44/step-44.cc
examples/step-45/step-45.cc
examples/step-47/step-47.cc
examples/step-48/step-48.cc
examples/step-59/step-59.cc
examples/step-6/step-6.cc
examples/step-64/step-64.cc
examples/step-65/step-65.cc
examples/step-67/step-67.cc
examples/step-68/step-68.cc
examples/step-76/step-76.cc
examples/step-79/step-79.cc
examples/step-87/step-87.cc

index ae1ff617d3598afbbc27805fc8764143f7f987b2..f1afbc1034a2f8683779a6425ec0a200d08397e3 100644 (file)
@@ -81,10 +81,10 @@ namespace Step11
     void solve();
     void write_high_order_mesh(const unsigned cycle);
 
-    Triangulation<dim> triangulation;
-    const FE_Q<dim>    fe;
-    DoFHandler<dim>    dof_handler;
-    MappingQ<dim>      mapping;
+    Triangulation<dim>  triangulation;
+    const FE_Q<dim>     fe;
+    DoFHandler<dim>     dof_handler;
+    const MappingQ<dim> mapping;
 
     SparsityPattern           sparsity_pattern;
     SparseMatrix<double>      system_matrix;
index b3580afcab7123a31272c654f7c14e9b2ba9f500..3efdcb9ef4d129e46a02d4175adff8280cb78115 100644 (file)
@@ -373,7 +373,7 @@ namespace Step16
   template <int dim>
   void LaplaceProblem<dim>::assemble_system()
   {
-    MappingQ1<dim> mapping;
+    const MappingQ1<dim> mapping;
 
     auto cell_worker =
       [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
@@ -425,8 +425,8 @@ namespace Step16
   template <int dim>
   void LaplaceProblem<dim>::assemble_multigrid()
   {
-    MappingQ1<dim>     mapping;
-    const unsigned int n_levels = triangulation.n_levels();
+    const MappingQ1<dim> mapping;
+    const unsigned int   n_levels = triangulation.n_levels();
 
     std::vector<AffineConstraints<double>> boundary_constraints(n_levels);
     for (unsigned int level = 0; level < n_levels; ++level)
index df9dbebcba05b7923e802cc0c8f0b2e02e792bc6..54c978e640ce54c792f3d40e362a71c837aa8f3b 100644 (file)
@@ -230,10 +230,10 @@ namespace Step34
     // finite element space. The order of the finite element space and of the
     // mapping can be selected in the constructor of the class.
 
-    Triangulation<dim - 1, dim> tria;
-    const FE_Q<dim - 1, dim>    fe;
-    DoFHandler<dim - 1, dim>    dof_handler;
-    MappingQ<dim - 1, dim>      mapping;
+    Triangulation<dim - 1, dim>  tria;
+    const FE_Q<dim - 1, dim>     fe;
+    DoFHandler<dim - 1, dim>     dof_handler;
+    const MappingQ<dim - 1, dim> mapping;
 
     // In BEM methods, the matrix that is generated is dense. Depending on the
     // size of the problem, the final system might be solved by direct LU
index 14d0a5ebcde2636ab44d441a58fd259e9827d742..40a36faf867a0b3f711a5c9de497f3fc98394e94 100644 (file)
@@ -688,7 +688,7 @@ namespace Step37
     const FE_Q<dim> fe;
     DoFHandler<dim> dof_handler;
 
-    MappingQ1<dim> mapping;
+    const MappingQ1<dim> mapping;
 
     AffineConstraints<double> constraints;
     using SystemMatrixType =
index 401ad8d9c49e3f9ac027158891b4c7f3f3df7f90..6ea8f11218709243fe8f6944a354fd5096afdadd 100644 (file)
@@ -111,10 +111,10 @@ namespace Step38
     void compute_error() const;
 
 
-    Triangulation<dim, spacedim> triangulation;
-    const FE_Q<dim, spacedim>    fe;
-    DoFHandler<dim, spacedim>    dof_handler;
-    MappingQ<dim, spacedim>      mapping;
+    Triangulation<dim, spacedim>  triangulation;
+    const FE_Q<dim, spacedim>     fe;
+    DoFHandler<dim, spacedim>     dof_handler;
+    const MappingQ<dim, spacedim> mapping;
 
     SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
index 53f8ff84033a7e538e9c56a7854e2adf05d443a2..cc93aacb20214d68e5d69ed742a58f5cfc37ea7a 100644 (file)
@@ -3219,7 +3219,7 @@ namespace Step44
     Vector<double> soln(solution_n.size());
     for (unsigned int i = 0; i < soln.size(); ++i)
       soln(i) = solution_n(i);
-    MappingQEulerian<dim> q_mapping(degree, dof_handler, soln);
+    const MappingQEulerian<dim> q_mapping(degree, dof_handler, soln);
     data_out.build_patches(q_mapping, degree);
 
     std::ofstream output("solution-" + std::to_string(dim) + "d-" +
index 249bbeb15dc9b0aff03dc7fe972c8757430b1c15..52b599eaa5ca369aa65733634085f9c673a2404b 100644 (file)
@@ -103,7 +103,7 @@ namespace Step45
 
     ConditionalOStream pcout;
 
-    MappingQ<dim> mapping;
+    const MappingQ<dim> mapping;
   };
 
 
index 0326a653361e0aa5d33216878061ba5169866e0d..dded3499aca0c2e3d616cd0682a86be49772cec8 100644 (file)
@@ -161,7 +161,7 @@ namespace Step47
 
     Triangulation<dim> triangulation;
 
-    MappingQ<dim> mapping;
+    const MappingQ<dim> mapping;
 
     const FE_Q<dim>           fe;
     DoFHandler<dim>           dof_handler;
index fda1da340962a6d3ab760fabeb5a6ee64da8b80f..6f8393a38bfd075db86609a4d3e54b6ee4f2deaf 100644 (file)
@@ -309,7 +309,7 @@ namespace Step48
     const FE_Q<dim> fe;
     DoFHandler<dim> dof_handler;
 
-    MappingQ1<dim> mapping;
+    const MappingQ1<dim> mapping;
 
     AffineConstraints<double> constraints;
     IndexSet                  locally_relevant_dofs;
index ee53c1c8d37f0844b5085c31fce7ea5a110a1299..570b76642ba8cccd2aff78d1dcb64e721fc74794 100644 (file)
@@ -926,7 +926,7 @@ namespace Step59
     const FE_DGQHermite<dim> fe;
     DoFHandler<dim>          dof_handler;
 
-    MappingQ1<dim> mapping;
+    const MappingQ1<dim> mapping;
 
     using SystemMatrixType = LaplaceOperator<dim, fe_degree, double>;
     SystemMatrixType system_matrix;
index bab8c3936ba6484d474b220ded587eeb14be0590..0dfaa2ae4e73706a1ee831c32dc5b74e66d22919 100644 (file)
@@ -474,7 +474,7 @@ void Step6<dim>::output_results(const unsigned int cycle) const
     std::ofstream         output("grid-" + std::to_string(cycle) + ".gnuplot");
     GridOutFlags::Gnuplot gnuplot_flags(false, 5);
     grid_out.set_flags(gnuplot_flags);
-    MappingQ<dim> mapping(3);
+    const MappingQ<dim> mapping(3);
     grid_out.write_gnuplot(triangulation, output, &mapping);
   }
 
index 441c98ac3db3d8041d09e6053228c5f937a0c841..4ab25590499d17d9df36b29fd74927ab0c1c57eb 100644 (file)
@@ -273,7 +273,7 @@ namespace Step64
     const DoFHandler<dim>           &dof_handler,
     const AffineConstraints<double> &constraints)
   {
-    MappingQ<dim> mapping(fe_degree);
+    const MappingQ<dim> mapping(fe_degree);
     typename Portable::MatrixFree<dim, double>::AdditionalData additional_data;
     additional_data.mapping_update_flags = update_values | update_gradients |
                                            update_JxW_values |
index fe3efad86e2e2315e2b1167215904707f08161ac..718e386a07543a023639eb498bfc3b2b4bbb590c 100644 (file)
@@ -610,7 +610,7 @@ namespace Step65
                 << std::endl
                 << std::endl;
 
-      MappingQ<dim> mapping(fe.degree + 1);
+      const MappingQ<dim> mapping(fe.degree + 1);
       setup_system(mapping);
       assemble_system(mapping);
       solve();
index c19b3f05370e8114f1acab2620e6a16c911b61d1..31fc80b9cf4b16a8d904e57985f9f9a34fda6a3b 100644 (file)
@@ -1773,7 +1773,7 @@ namespace Euler_DG
 #endif
 
     const FESystem<dim> fe;
-    MappingQ<dim>       mapping;
+    const MappingQ<dim> mapping;
     DoFHandler<dim>     dof_handler;
 
     TimerOutput timer;
index 1e5b4373bc4aaecc6017aa1af41cff948cd4c68e..ef9737773dc9fa9f83a74e610b495188a310d690 100644 (file)
@@ -231,7 +231,7 @@ namespace Step68
 
     DoFHandler<dim>                            fluid_dh;
     const FESystem<dim>                        fluid_fe;
-    MappingQ1<dim>                             mapping;
+    const MappingQ1<dim>                       mapping;
     LinearAlgebra::distributed::Vector<double> velocity_field;
 
     Functions::RayleighKotheVortex<dim> velocity;
index b3ee87a59ecc2374d584d31817f8d4a815513752..d64a57eff2fde8cd0ed4467dd4a89e9ff999e56d 100644 (file)
@@ -1203,7 +1203,7 @@ namespace Euler_DG
 #endif
 
     const FESystem<dim> fe;
-    MappingQ<dim>       mapping;
+    const MappingQ<dim> mapping;
     DoFHandler<dim>     dof_handler;
 
     TimerOutput timer;
index 6da22e070d4fb9b3ca69245a5510296630807c29..59969e61a003052ca9ca815f086a5470da36d6b9 100644 (file)
@@ -752,7 +752,7 @@ namespace SAND
     system_rhs    = 0;
 
 
-    MappingQ<dim>         mapping(1);
+    const MappingQ<dim>   mapping(1);
     const QGauss<dim>     quadrature_formula(fe.degree + 1);
     const QGauss<dim - 1> face_quadrature_formula(fe.degree + 1);
     FEValues<dim>         fe_values(mapping,
@@ -1300,7 +1300,7 @@ namespace SAND
     BlockVector<double> test_rhs;
     test_rhs.reinit(system_rhs);
 
-    MappingQ<dim>         mapping(1);
+    const MappingQ<dim>   mapping(1);
     const QGauss<dim>     quadrature_formula(fe.degree + 1);
     const QGauss<dim - 1> face_quadrature_formula(fe.degree + 1);
     FEValues<dim>         fe_values(mapping,
@@ -1626,7 +1626,7 @@ namespace SAND
     // Start with computing the objective function:
     double objective_function_merit = 0;
     {
-      MappingQ<dim>         mapping(1);
+      const MappingQ<dim>   mapping(1);
       const QGauss<dim>     quadrature_formula(fe.degree + 1);
       const QGauss<dim - 1> face_quadrature_formula(fe.degree + 1);
       FEValues<dim>         fe_values(mapping,
index 5d51f55fc93baa51c6e3df76018d5e7521588d1d..5c8718632c7f83c1be9cc62ae3425c27201a0905 100644 (file)
@@ -161,8 +161,8 @@ namespace Step87
     constexpr unsigned int dim       = 2;
     constexpr unsigned int fe_degree = 3;
 
-    MappingQ1<dim>     mapping;
-    Triangulation<dim> tria;
+    const MappingQ1<dim> mapping;
+    Triangulation<dim>   tria;
     GridGenerator::subdivided_hyper_cube(tria, 7);
 
     const FE_Q<dim> fe(fe_degree);
@@ -299,7 +299,7 @@ namespace Step87
 
     pcout << "Running: example 1" << std::endl;
 
-    MappingQ1<dim>                mapping;
+    const MappingQ1<dim>          mapping;
     DistributedTriangulation<dim> tria(MPI_COMM_WORLD);
     GridGenerator::subdivided_hyper_cube(tria, 7);
 
@@ -466,7 +466,7 @@ namespace Step87
     pcout << "  - create system" << std::endl;
 
     const FE_Q<dim>               fe(fe_degree);
-    MappingQ1<dim>                mapping;
+    const MappingQ1<dim>          mapping;
     DistributedTriangulation<dim> tria(MPI_COMM_WORLD);
     GridGenerator::subdivided_hyper_cube(tria, 50);
 
@@ -736,9 +736,9 @@ namespace Step87
     GridGenerator::hyper_cube(tria_background);
     tria_background.refine_global(5);
 
-    MappingQ1<dim>      mapping_background;
-    const FESystem<dim> fe_background(FE_Q<dim>(degree), dim);
-    DoFHandler<dim>     dof_handler_background(tria_background);
+    const MappingQ1<dim> mapping_background;
+    const FESystem<dim>  fe_background(FE_Q<dim>(degree), dim);
+    DoFHandler<dim>      dof_handler_background(tria_background);
     dof_handler_background.distribute_dofs(fe_background);
 
     // and, similarly, for the immersed surface mesh.
@@ -758,8 +758,8 @@ namespace Step87
     // that is updated in every time step according to the nodal
     // displacements. Two types of finite elements are used to
     // represent scalar and vector-valued DoF values.
-    MappingQ<dim - 1, dim>      mapping_immersed_base(3);
-    MappingQCache<dim - 1, dim> mapping_immersed(3);
+    const MappingQ<dim - 1, dim> mapping_immersed_base(3);
+    MappingQCache<dim - 1, dim>  mapping_immersed(3);
     mapping_immersed.initialize(mapping_immersed_base, tria_immersed);
     const QGauss<dim - 1> quadrature_immersed(degree + 1);
 

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.