From: Lóránt Hadnagy Date: Thu, 25 Jul 2024 16:37:51 +0000 (+0300) Subject: Make 'mapping' variables 'const' in example files X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb71bf757a34306c9199bdf190ff013c92f4e694;p=dealii.git Make 'mapping' variables 'const' in example files --- diff --git a/examples/step-11/step-11.cc b/examples/step-11/step-11.cc index ae1ff617d3..f1afbc1034 100644 --- a/examples/step-11/step-11.cc +++ b/examples/step-11/step-11.cc @@ -81,10 +81,10 @@ namespace Step11 void solve(); void write_high_order_mesh(const unsigned cycle); - Triangulation triangulation; - const FE_Q fe; - DoFHandler dof_handler; - MappingQ mapping; + Triangulation triangulation; + const FE_Q fe; + DoFHandler dof_handler; + const MappingQ mapping; SparsityPattern sparsity_pattern; SparseMatrix system_matrix; diff --git a/examples/step-16/step-16.cc b/examples/step-16/step-16.cc index b3580afcab..3efdcb9ef4 100644 --- a/examples/step-16/step-16.cc +++ b/examples/step-16/step-16.cc @@ -373,7 +373,7 @@ namespace Step16 template void LaplaceProblem::assemble_system() { - MappingQ1 mapping; + const MappingQ1 mapping; auto cell_worker = [&](const typename DoFHandler::active_cell_iterator &cell, @@ -425,8 +425,8 @@ namespace Step16 template void LaplaceProblem::assemble_multigrid() { - MappingQ1 mapping; - const unsigned int n_levels = triangulation.n_levels(); + const MappingQ1 mapping; + const unsigned int n_levels = triangulation.n_levels(); std::vector> boundary_constraints(n_levels); for (unsigned int level = 0; level < n_levels; ++level) diff --git a/examples/step-34/step-34.cc b/examples/step-34/step-34.cc index df9dbebcba..54c978e640 100644 --- a/examples/step-34/step-34.cc +++ b/examples/step-34/step-34.cc @@ -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 tria; - const FE_Q fe; - DoFHandler dof_handler; - MappingQ mapping; + Triangulation tria; + const FE_Q fe; + DoFHandler dof_handler; + const MappingQ 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 diff --git a/examples/step-37/step-37.cc b/examples/step-37/step-37.cc index 14d0a5ebcd..40a36faf86 100644 --- a/examples/step-37/step-37.cc +++ b/examples/step-37/step-37.cc @@ -688,7 +688,7 @@ namespace Step37 const FE_Q fe; DoFHandler dof_handler; - MappingQ1 mapping; + const MappingQ1 mapping; AffineConstraints constraints; using SystemMatrixType = diff --git a/examples/step-38/step-38.cc b/examples/step-38/step-38.cc index 401ad8d9c4..6ea8f11218 100644 --- a/examples/step-38/step-38.cc +++ b/examples/step-38/step-38.cc @@ -111,10 +111,10 @@ namespace Step38 void compute_error() const; - Triangulation triangulation; - const FE_Q fe; - DoFHandler dof_handler; - MappingQ mapping; + Triangulation triangulation; + const FE_Q fe; + DoFHandler dof_handler; + const MappingQ mapping; SparsityPattern sparsity_pattern; SparseMatrix system_matrix; diff --git a/examples/step-44/step-44.cc b/examples/step-44/step-44.cc index 53f8ff8403..cc93aacb20 100644 --- a/examples/step-44/step-44.cc +++ b/examples/step-44/step-44.cc @@ -3219,7 +3219,7 @@ namespace Step44 Vector soln(solution_n.size()); for (unsigned int i = 0; i < soln.size(); ++i) soln(i) = solution_n(i); - MappingQEulerian q_mapping(degree, dof_handler, soln); + const MappingQEulerian q_mapping(degree, dof_handler, soln); data_out.build_patches(q_mapping, degree); std::ofstream output("solution-" + std::to_string(dim) + "d-" + diff --git a/examples/step-45/step-45.cc b/examples/step-45/step-45.cc index 249bbeb15d..52b599eaa5 100644 --- a/examples/step-45/step-45.cc +++ b/examples/step-45/step-45.cc @@ -103,7 +103,7 @@ namespace Step45 ConditionalOStream pcout; - MappingQ mapping; + const MappingQ mapping; }; diff --git a/examples/step-47/step-47.cc b/examples/step-47/step-47.cc index 0326a65336..dded3499ac 100644 --- a/examples/step-47/step-47.cc +++ b/examples/step-47/step-47.cc @@ -161,7 +161,7 @@ namespace Step47 Triangulation triangulation; - MappingQ mapping; + const MappingQ mapping; const FE_Q fe; DoFHandler dof_handler; diff --git a/examples/step-48/step-48.cc b/examples/step-48/step-48.cc index fda1da3409..6f8393a38b 100644 --- a/examples/step-48/step-48.cc +++ b/examples/step-48/step-48.cc @@ -309,7 +309,7 @@ namespace Step48 const FE_Q fe; DoFHandler dof_handler; - MappingQ1 mapping; + const MappingQ1 mapping; AffineConstraints constraints; IndexSet locally_relevant_dofs; diff --git a/examples/step-59/step-59.cc b/examples/step-59/step-59.cc index ee53c1c8d3..570b76642b 100644 --- a/examples/step-59/step-59.cc +++ b/examples/step-59/step-59.cc @@ -926,7 +926,7 @@ namespace Step59 const FE_DGQHermite fe; DoFHandler dof_handler; - MappingQ1 mapping; + const MappingQ1 mapping; using SystemMatrixType = LaplaceOperator; SystemMatrixType system_matrix; diff --git a/examples/step-6/step-6.cc b/examples/step-6/step-6.cc index bab8c3936b..0dfaa2ae4e 100644 --- a/examples/step-6/step-6.cc +++ b/examples/step-6/step-6.cc @@ -474,7 +474,7 @@ void Step6::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 mapping(3); + const MappingQ mapping(3); grid_out.write_gnuplot(triangulation, output, &mapping); } diff --git a/examples/step-64/step-64.cc b/examples/step-64/step-64.cc index 441c98ac3d..4ab2559049 100644 --- a/examples/step-64/step-64.cc +++ b/examples/step-64/step-64.cc @@ -273,7 +273,7 @@ namespace Step64 const DoFHandler &dof_handler, const AffineConstraints &constraints) { - MappingQ mapping(fe_degree); + const MappingQ mapping(fe_degree); typename Portable::MatrixFree::AdditionalData additional_data; additional_data.mapping_update_flags = update_values | update_gradients | update_JxW_values | diff --git a/examples/step-65/step-65.cc b/examples/step-65/step-65.cc index fe3efad86e..718e386a07 100644 --- a/examples/step-65/step-65.cc +++ b/examples/step-65/step-65.cc @@ -610,7 +610,7 @@ namespace Step65 << std::endl << std::endl; - MappingQ mapping(fe.degree + 1); + const MappingQ mapping(fe.degree + 1); setup_system(mapping); assemble_system(mapping); solve(); diff --git a/examples/step-67/step-67.cc b/examples/step-67/step-67.cc index c19b3f0537..31fc80b9cf 100644 --- a/examples/step-67/step-67.cc +++ b/examples/step-67/step-67.cc @@ -1773,7 +1773,7 @@ namespace Euler_DG #endif const FESystem fe; - MappingQ mapping; + const MappingQ mapping; DoFHandler dof_handler; TimerOutput timer; diff --git a/examples/step-68/step-68.cc b/examples/step-68/step-68.cc index 1e5b4373bc..ef9737773d 100644 --- a/examples/step-68/step-68.cc +++ b/examples/step-68/step-68.cc @@ -231,7 +231,7 @@ namespace Step68 DoFHandler fluid_dh; const FESystem fluid_fe; - MappingQ1 mapping; + const MappingQ1 mapping; LinearAlgebra::distributed::Vector velocity_field; Functions::RayleighKotheVortex velocity; diff --git a/examples/step-76/step-76.cc b/examples/step-76/step-76.cc index b3ee87a59e..d64a57eff2 100644 --- a/examples/step-76/step-76.cc +++ b/examples/step-76/step-76.cc @@ -1203,7 +1203,7 @@ namespace Euler_DG #endif const FESystem fe; - MappingQ mapping; + const MappingQ mapping; DoFHandler dof_handler; TimerOutput timer; diff --git a/examples/step-79/step-79.cc b/examples/step-79/step-79.cc index 6da22e070d..59969e61a0 100644 --- a/examples/step-79/step-79.cc +++ b/examples/step-79/step-79.cc @@ -752,7 +752,7 @@ namespace SAND system_rhs = 0; - MappingQ mapping(1); + const MappingQ mapping(1); const QGauss quadrature_formula(fe.degree + 1); const QGauss face_quadrature_formula(fe.degree + 1); FEValues fe_values(mapping, @@ -1300,7 +1300,7 @@ namespace SAND BlockVector test_rhs; test_rhs.reinit(system_rhs); - MappingQ mapping(1); + const MappingQ mapping(1); const QGauss quadrature_formula(fe.degree + 1); const QGauss face_quadrature_formula(fe.degree + 1); FEValues fe_values(mapping, @@ -1626,7 +1626,7 @@ namespace SAND // Start with computing the objective function: double objective_function_merit = 0; { - MappingQ mapping(1); + const MappingQ mapping(1); const QGauss quadrature_formula(fe.degree + 1); const QGauss face_quadrature_formula(fe.degree + 1); FEValues fe_values(mapping, diff --git a/examples/step-87/step-87.cc b/examples/step-87/step-87.cc index 5d51f55fc9..5c8718632c 100644 --- a/examples/step-87/step-87.cc +++ b/examples/step-87/step-87.cc @@ -161,8 +161,8 @@ namespace Step87 constexpr unsigned int dim = 2; constexpr unsigned int fe_degree = 3; - MappingQ1 mapping; - Triangulation tria; + const MappingQ1 mapping; + Triangulation tria; GridGenerator::subdivided_hyper_cube(tria, 7); const FE_Q fe(fe_degree); @@ -299,7 +299,7 @@ namespace Step87 pcout << "Running: example 1" << std::endl; - MappingQ1 mapping; + const MappingQ1 mapping; DistributedTriangulation tria(MPI_COMM_WORLD); GridGenerator::subdivided_hyper_cube(tria, 7); @@ -466,7 +466,7 @@ namespace Step87 pcout << " - create system" << std::endl; const FE_Q fe(fe_degree); - MappingQ1 mapping; + const MappingQ1 mapping; DistributedTriangulation 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 mapping_background; - const FESystem fe_background(FE_Q(degree), dim); - DoFHandler dof_handler_background(tria_background); + const MappingQ1 mapping_background; + const FESystem fe_background(FE_Q(degree), dim); + DoFHandler 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 mapping_immersed_base(3); - MappingQCache mapping_immersed(3); + const MappingQ mapping_immersed_base(3); + MappingQCache mapping_immersed(3); mapping_immersed.initialize(mapping_immersed_base, tria_immersed); const QGauss quadrature_immersed(degree + 1);