]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid deprecated AffineConstraints functions in the tutorials. 16032/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 22 Sep 2023 14:23:22 +0000 (08:23 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 22 Sep 2023 14:23:22 +0000 (08:23 -0600)
14 files changed:
examples/step-16/step-16.cc
examples/step-32/step-32.cc
examples/step-37/step-37.cc
examples/step-40/step-40.cc
examples/step-42/step-42.cc
examples/step-45/step-45.cc
examples/step-48/step-48.cc
examples/step-50/step-50.cc
examples/step-55/step-55.cc
examples/step-63/step-63.cc
examples/step-64/step-64.cc
examples/step-66/step-66.cc
examples/step-70/step-70.cc
examples/step-75/step-75.cc

index 2002e66b56175e3d076c5d85c557918795f0b4ec..09c4302d7de23816bef67673c67dd9731f73b07f 100644 (file)
@@ -433,9 +433,9 @@ namespace Step16
     std::vector<AffineConstraints<double>> boundary_constraints(n_levels);
     for (unsigned int level = 0; level < n_levels; ++level)
       {
-        const IndexSet dofset =
-          DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
-        boundary_constraints[level].reinit(dofset);
+        boundary_constraints[level].reinit(
+          dof_handler.locally_owned_mg_dofs(level),
+          DoFTools::extract_locally_relevant_level_dofs(dof_handler, level));
         boundary_constraints[level].add_lines(
           mg_constrained_dofs.get_refinement_edge_indices(level));
         boundary_constraints[level].add_lines(
index f193a5a56cca8c036a3be67ce745cf7011d63c03..4ff165b3c1a8a2a97c4b6b03b430417eb9f0397b 100644 (file)
@@ -1852,26 +1852,28 @@ namespace Step32
     // of each matrix or vector will be stored where, then call the functions
     // that actually set up the matrices, and at the end also resize the
     // various vectors we keep around in this program.
-    std::vector<IndexSet> stokes_partitioning, stokes_relevant_partitioning;
-    IndexSet              temperature_partitioning(n_T),
-      temperature_relevant_partitioning(n_T);
-    IndexSet stokes_relevant_set;
-    {
-      IndexSet stokes_index_set = stokes_dof_handler.locally_owned_dofs();
-      stokes_partitioning.push_back(stokes_index_set.get_view(0, n_u));
-      stokes_partitioning.push_back(stokes_index_set.get_view(n_u, n_u + n_p));
-
-      stokes_relevant_set =
-        DoFTools::extract_locally_relevant_dofs(stokes_dof_handler);
-      stokes_relevant_partitioning.push_back(
-        stokes_relevant_set.get_view(0, n_u));
-      stokes_relevant_partitioning.push_back(
-        stokes_relevant_set.get_view(n_u, n_u + n_p));
-
-      temperature_partitioning = temperature_dof_handler.locally_owned_dofs();
-      temperature_relevant_partitioning =
-        DoFTools::extract_locally_relevant_dofs(temperature_dof_handler);
-    }
+
+    const IndexSet &stokes_locally_owned_index_set =
+      stokes_dof_handler.locally_owned_dofs();
+    const IndexSet stokes_locally_relevant_set =
+      DoFTools::extract_locally_relevant_dofs(stokes_dof_handler);
+
+    std::vector<IndexSet> stokes_partitioning;
+    stokes_partitioning.push_back(
+      stokes_locally_owned_index_set.get_view(0, n_u));
+    stokes_partitioning.push_back(
+      stokes_locally_owned_index_set.get_view(n_u, n_u + n_p));
+
+    std::vector<IndexSet> stokes_relevant_partitioning;
+    stokes_relevant_partitioning.push_back(
+      stokes_locally_relevant_set.get_view(0, n_u));
+    stokes_relevant_partitioning.push_back(
+      stokes_locally_relevant_set.get_view(n_u, n_u + n_p));
+
+    const IndexSet temperature_partitioning =
+      temperature_dof_handler.locally_owned_dofs();
+    const IndexSet temperature_relevant_partitioning =
+      DoFTools::extract_locally_relevant_dofs(temperature_dof_handler);
 
     // Following this, we can compute constraints for the solution vectors,
     // including hanging node constraints and homogeneous and inhomogeneous
@@ -1886,7 +1888,8 @@ namespace Step32
     // objects.
     {
       stokes_constraints.clear();
-      stokes_constraints.reinit(stokes_relevant_set);
+      stokes_constraints.reinit(stokes_locally_owned_index_set,
+                                stokes_locally_relevant_set);
 
       DoFTools::make_hanging_node_constraints(stokes_dof_handler,
                                               stokes_constraints);
@@ -1910,7 +1913,8 @@ namespace Step32
     }
     {
       temperature_constraints.clear();
-      temperature_constraints.reinit(temperature_relevant_partitioning);
+      temperature_constraints.reinit(temperature_partitioning,
+                                     temperature_relevant_partitioning);
 
       DoFTools::make_hanging_node_constraints(temperature_dof_handler,
                                               temperature_constraints);
index 2c5a38a832275fd67a5036beae3f7d525df7ad2f..2b2c089b690826fb2af334cd6fa3fe01c0146892 100644 (file)
@@ -780,51 +780,50 @@ namespace Step37
   {
     Timer time;
     setup_time = 0;
+    {
+      system_matrix.clear();
+      mg_matrices.clear_elements();
 
-    system_matrix.clear();
-    mg_matrices.clear_elements();
-
-    dof_handler.distribute_dofs(fe);
-    dof_handler.distribute_mg_dofs();
-
-    pcout << "Number of degrees of freedom: " << dof_handler.n_dofs()
-          << std::endl;
+      dof_handler.distribute_dofs(fe);
+      dof_handler.distribute_mg_dofs();
 
-    const IndexSet locally_relevant_dofs =
-      DoFTools::extract_locally_relevant_dofs(dof_handler);
+      pcout << "Number of degrees of freedom: " << dof_handler.n_dofs()
+            << std::endl;
 
-    constraints.clear();
-    constraints.reinit(locally_relevant_dofs);
-    DoFTools::make_hanging_node_constraints(dof_handler, constraints);
-    VectorTools::interpolate_boundary_values(
-      mapping, dof_handler, 0, Functions::ZeroFunction<dim>(), constraints);
-    constraints.close();
+      constraints.clear();
+      constraints.reinit(dof_handler.locally_owned_dofs(),
+                         DoFTools::extract_locally_relevant_dofs(dof_handler));
+      DoFTools::make_hanging_node_constraints(dof_handler, constraints);
+      VectorTools::interpolate_boundary_values(
+        mapping, dof_handler, 0, Functions::ZeroFunction<dim>(), constraints);
+      constraints.close();
+    }
     setup_time += time.wall_time();
     time_details << "Distribute DoFs & B.C.     (CPU/wall) " << time.cpu_time()
                  << "s/" << time.wall_time() << 's' << std::endl;
     time.restart();
-
     {
-      typename MatrixFree<dim, double>::AdditionalData additional_data;
-      additional_data.tasks_parallel_scheme =
-        MatrixFree<dim, double>::AdditionalData::none;
-      additional_data.mapping_update_flags =
-        (update_gradients | update_JxW_values | update_quadrature_points);
-      std::shared_ptr<MatrixFree<dim, double>> system_mf_storage(
-        new MatrixFree<dim, double>());
-      system_mf_storage->reinit(mapping,
-                                dof_handler,
-                                constraints,
-                                QGauss<1>(fe.degree + 1),
-                                additional_data);
-      system_matrix.initialize(system_mf_storage);
-    }
-
-    system_matrix.evaluate_coefficient(Coefficient<dim>());
+      {
+        typename MatrixFree<dim, double>::AdditionalData additional_data;
+        additional_data.tasks_parallel_scheme =
+          MatrixFree<dim, double>::AdditionalData::none;
+        additional_data.mapping_update_flags =
+          (update_gradients | update_JxW_values | update_quadrature_points);
+        std::shared_ptr<MatrixFree<dim, double>> system_mf_storage(
+          new MatrixFree<dim, double>());
+        system_mf_storage->reinit(mapping,
+                                  dof_handler,
+                                  constraints,
+                                  QGauss<1>(fe.degree + 1),
+                                  additional_data);
+        system_matrix.initialize(system_mf_storage);
+      }
 
-    system_matrix.initialize_dof_vector(solution);
-    system_matrix.initialize_dof_vector(system_rhs);
+      system_matrix.evaluate_coefficient(Coefficient<dim>());
 
+      system_matrix.initialize_dof_vector(solution);
+      system_matrix.initialize_dof_vector(system_rhs);
+    }
     setup_time += time.wall_time();
     time_details << "Setup matrix-free system   (CPU/wall) " << time.cpu_time()
                  << "s/" << time.wall_time() << 's' << std::endl;
@@ -839,43 +838,44 @@ namespace Step37
     // closely the construction of the system matrix on the original mesh,
     // except the slight difference in naming when accessing information on
     // the levels rather than the active cells.
-    const unsigned int nlevels = triangulation.n_global_levels();
-    mg_matrices.resize(0, nlevels - 1);
-
-    const std::set<types::boundary_id> dirichlet_boundary_ids = {0};
-    mg_constrained_dofs.initialize(dof_handler);
-    mg_constrained_dofs.make_zero_boundary_constraints(dof_handler,
-                                                       dirichlet_boundary_ids);
-
-    for (unsigned int level = 0; level < nlevels; ++level)
-      {
-        const IndexSet relevant_dofs =
-          DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
-        AffineConstraints<double> level_constraints;
-        level_constraints.reinit(relevant_dofs);
-        level_constraints.add_lines(
-          mg_constrained_dofs.get_boundary_indices(level));
-        level_constraints.close();
-
-        typename MatrixFree<dim, float>::AdditionalData additional_data;
-        additional_data.tasks_parallel_scheme =
-          MatrixFree<dim, float>::AdditionalData::none;
-        additional_data.mapping_update_flags =
-          (update_gradients | update_JxW_values | update_quadrature_points);
-        additional_data.mg_level = level;
-        std::shared_ptr<MatrixFree<dim, float>> mg_mf_storage_level(
-          new MatrixFree<dim, float>());
-        mg_mf_storage_level->reinit(mapping,
-                                    dof_handler,
-                                    level_constraints,
-                                    QGauss<1>(fe.degree + 1),
-                                    additional_data);
-
-        mg_matrices[level].initialize(mg_mf_storage_level,
-                                      mg_constrained_dofs,
-                                      level);
-        mg_matrices[level].evaluate_coefficient(Coefficient<dim>());
-      }
+    {
+      const unsigned int nlevels = triangulation.n_global_levels();
+      mg_matrices.resize(0, nlevels - 1);
+
+      const std::set<types::boundary_id> dirichlet_boundary_ids = {0};
+      mg_constrained_dofs.initialize(dof_handler);
+      mg_constrained_dofs.make_zero_boundary_constraints(
+        dof_handler, dirichlet_boundary_ids);
+
+      for (unsigned int level = 0; level < nlevels; ++level)
+        {
+          AffineConstraints<double> level_constraints(
+            dof_handler.locally_owned_mg_dofs(level),
+            DoFTools::extract_locally_relevant_level_dofs(dof_handler, level));
+          level_constraints.add_lines(
+            mg_constrained_dofs.get_boundary_indices(level));
+          level_constraints.close();
+
+          typename MatrixFree<dim, float>::AdditionalData additional_data;
+          additional_data.tasks_parallel_scheme =
+            MatrixFree<dim, float>::AdditionalData::none;
+          additional_data.mapping_update_flags =
+            (update_gradients | update_JxW_values | update_quadrature_points);
+          additional_data.mg_level = level;
+          std::shared_ptr<MatrixFree<dim, float>> mg_mf_storage_level(
+            new MatrixFree<dim, float>());
+          mg_mf_storage_level->reinit(mapping,
+                                      dof_handler,
+                                      level_constraints,
+                                      QGauss<1>(fe.degree + 1),
+                                      additional_data);
+
+          mg_matrices[level].initialize(mg_mf_storage_level,
+                                        mg_constrained_dofs,
+                                        level);
+          mg_matrices[level].evaluate_coefficient(Coefficient<dim>());
+        }
+    }
     setup_time += time.wall_time();
     time_details << "Setup matrix-free levels   (CPU/wall) " << time.cpu_time()
                  << "s/" << time.wall_time() << 's' << std::endl;
index b30e3ced21774107d9f638e1801a86fc0fc33070..dfce3d21a022ee04040c801c52903bbe8d112596 100644 (file)
@@ -282,15 +282,23 @@ namespace Step40
     // expect any information to store. In our case, as explained in the
     // @ref distributed module, the degrees of freedom we need to care about on
     // each processor are the locally relevant ones, so we pass this to the
-    // AffineConstraints::reinit function. As a side note, if you forget to
-    // pass this argument, the AffineConstraints class will allocate an array
+    // AffineConstraints::reinit() function as a second argument. A further
+    // optimization, AffineConstraint can avoid certain operations if you also
+    // provide it with the set of locally owned degrees of freedom -- the
+    // first argument to AffineConstraints::reinit().
+    //
+    // (What would happen if we didn't pass this information to
+    // AffineConstraints, for example if we called the argument-less version of
+    // AffineConstraints::reinit() typically used in non-parallel codes? In that
+    // case, the AffineConstraints class will allocate an array
     // with length equal to the largest DoF index it has seen so far. For
-    // processors with high MPI process number, this may be very large --
+    // processors with large numbers of MPI processes, this may be very large --
     // maybe on the order of billions. The program would then allocate more
     // memory than for likely all other operations combined for this single
-    // array.
+    // array. Fortunately, recent versions of deal.II would trigger an assertion
+    // that tells you that this is considered a bug.)
     constraints.clear();
-    constraints.reinit(locally_relevant_dofs);
+    constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
     DoFTools::make_hanging_node_constraints(dof_handler, constraints);
     VectorTools::interpolate_boundary_values(dof_handler,
                                              0,
index 8246694fdcd0c1c934ad589165e127b657a8b0ff..3fcd08064db4b9277761b0e9ae48928877e815a6 100644 (file)
@@ -979,7 +979,8 @@ namespace Step42
     /* setup hanging nodes and Dirichlet constraints */
     {
       TimerOutput::Scope t(computing_timer, "Setup: constraints");
-      constraints_hanging_nodes.reinit(locally_relevant_dofs);
+      constraints_hanging_nodes.reinit(locally_owned_dofs,
+                                       locally_relevant_dofs);
       DoFTools::make_hanging_node_constraints(dof_handler,
                                               constraints_hanging_nodes);
       constraints_hanging_nodes.close();
@@ -1059,7 +1060,8 @@ namespace Step42
   template <int dim>
   void PlasticityContactProblem<dim>::compute_dirichlet_constraints()
   {
-    constraints_dirichlet_and_hanging_nodes.reinit(locally_relevant_dofs);
+    constraints_dirichlet_and_hanging_nodes.reinit(locally_owned_dofs,
+                                                   locally_relevant_dofs);
     constraints_dirichlet_and_hanging_nodes.merge(constraints_hanging_nodes);
 
     if (base_mesh == "box")
@@ -1197,7 +1199,7 @@ namespace Step42
     diag_mass_matrix_vector_relevant = diag_mass_matrix_vector;
 
 
-    all_constraints.reinit(locally_relevant_dofs);
+    all_constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
     active_set.clear();
 
     // The second part is a loop over all cells in which we look at each
index 69120c2149dc4230f768cfa6a512845aed263913..7acdfa3f9fcac6252d8b482ad7945b1553922cdd 100644 (file)
@@ -366,7 +366,7 @@ namespace Step45
 
     {
       owned_partitioning.clear();
-      IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs();
+      const IndexSet &locally_owned_dofs = dof_handler.locally_owned_dofs();
       owned_partitioning.push_back(locally_owned_dofs.get_view(0, n_u));
       owned_partitioning.push_back(locally_owned_dofs.get_view(n_u, n_u + n_p));
 
@@ -378,7 +378,7 @@ namespace Step45
         locally_relevant_dofs.get_view(n_u, n_u + n_p));
 
       constraints.clear();
-      constraints.reinit(locally_relevant_dofs);
+      constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
 
       const FEValuesExtractors::Vector velocities(0);
 
index ea993a580005ea9d8ee6d040b6333a8bae1b87e4..7d6a7e8609b9479857317056306f711d965a6fdf 100644 (file)
@@ -409,9 +409,9 @@ namespace Step48
 
     // We generate hanging node constraints for ensuring continuity of the
     // solution. As in step-40, we need to equip the constraint matrix with
-    // the IndexSet of locally relevant degrees of freedom to avoid it to
-    // consume too much memory for big problems. Next, the <code> MatrixFree
-    // </code> object for the problem is set up. Note that we specify a
+    // the IndexSet of locally active and locally relevant degrees of freedom
+    // to avoid it consuming too much memory for big problems. Next, the
+    // MatrixFree object for the problem is set up. Note that we specify a
     // particular scheme for shared-memory parallelization (hence one would
     // use multithreading for intra-node parallelism and not MPI; we here
     // choose the standard option &mdash; if we wanted to disable shared
@@ -428,7 +428,7 @@ namespace Step48
     locally_relevant_dofs =
       DoFTools::extract_locally_relevant_dofs(dof_handler);
     constraints.clear();
-    constraints.reinit(locally_relevant_dofs);
+    constraints.reinit(dof_handler.locally_owned_dofs(), locally_relevant_dofs);
     DoFTools::make_hanging_node_constraints(dof_handler, constraints);
     constraints.close();
 
index 032663879b6e7286487a44f6bb5a5f6cbd2a38da..6492d805cffc44ada43e5e95c7f2f16e4f871341 100644 (file)
@@ -490,7 +490,7 @@ void LaplaceProblem<dim, degree>::setup_system()
 
   solution.reinit(locally_owned_dofs, mpi_communicator);
   right_hand_side.reinit(locally_owned_dofs, mpi_communicator);
-  constraints.reinit(locally_relevant_dofs);
+  constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
   DoFTools::make_hanging_node_constraints(dof_handler, constraints);
 
   VectorTools::interpolate_boundary_values(
@@ -592,11 +592,10 @@ void LaplaceProblem<dim, degree>::setup_multigrid()
 
           for (unsigned int level = 0; level < n_levels; ++level)
             {
-              const IndexSet relevant_dofs =
+              AffineConstraints<double> level_constraints(
+                dof_handler.locally_owned_mg_dofs(level),
                 DoFTools::extract_locally_relevant_level_dofs(dof_handler,
-                                                              level);
-              AffineConstraints<double> level_constraints;
-              level_constraints.reinit(relevant_dofs);
+                                                              level));
               level_constraints.add_lines(
                 mg_constrained_dofs.get_boundary_indices(level));
               level_constraints.close();
@@ -824,9 +823,9 @@ void LaplaceProblem<dim, degree>::assemble_multigrid()
     triangulation.n_global_levels());
   for (unsigned int level = 0; level < triangulation.n_global_levels(); ++level)
     {
-      const IndexSet dof_set =
-        DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
-      boundary_constraints[level].reinit(dof_set);
+      boundary_constraints[level].reinit(
+        dof_handler.locally_owned_mg_dofs(level),
+        DoFTools::extract_locally_relevant_level_dofs(dof_handler, level));
       boundary_constraints[level].add_lines(
         mg_constrained_dofs.get_refinement_edge_indices(level));
       boundary_constraints[level].add_lines(
index 583cabf5f1ac65741e273c8a0a744141579ace9e..89d64d1839b21e98e12815558ead4467feaaabe9 100644 (file)
@@ -382,10 +382,10 @@ namespace Step55
     // We split up the IndexSet for locally owned and locally relevant DoFs
     // into two IndexSets based on how we want to create the block matrices
     // and vectors.
+    const IndexSet &locally_owned_dofs = dof_handler.locally_owned_dofs();
     owned_partitioning.resize(2);
-    owned_partitioning[0] = dof_handler.locally_owned_dofs().get_view(0, n_u);
-    owned_partitioning[1] =
-      dof_handler.locally_owned_dofs().get_view(n_u, n_u + n_p);
+    owned_partitioning[0] = locally_owned_dofs.get_view(0, n_u);
+    owned_partitioning[1] = locally_owned_dofs.get_view(n_u, n_u + n_p);
 
     const IndexSet locally_relevant_dofs =
       DoFTools::extract_locally_relevant_dofs(dof_handler);
@@ -399,7 +399,7 @@ namespace Step55
     // to put this function call in, in case adaptive refinement gets
     // introduced later.
     {
-      constraints.reinit(locally_relevant_dofs);
+      constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
 
       const FEValuesExtractors::Vector velocities(0);
       DoFTools::make_hanging_node_constraints(dof_handler, constraints);
index 16bbfb689f318975ab79f71344ca89740693c108..bfead4ce5f8e6ad73283856fb8d389a3884f5e4d 100644 (file)
@@ -814,9 +814,9 @@ namespace Step63
     for (unsigned int level = 0; level < triangulation.n_global_levels();
          ++level)
       {
-        const IndexSet locally_owned_level_dof_indices =
-          DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
-        boundary_constraints[level].reinit(locally_owned_level_dof_indices);
+        boundary_constraints[level].reinit(
+          dof_handler.locally_owned_mg_dofs(level),
+          DoFTools::extract_locally_relevant_level_dofs(dof_handler, level));
         boundary_constraints[level].add_lines(
           mg_constrained_dofs.get_refinement_edge_indices(level));
         boundary_constraints[level].add_lines(
index 8466cdca2889cc13c93c337bf43dd389b3d85c6a..5b14e2b24c9de1c9ca64cbe05554db69fa5201ac 100644 (file)
@@ -415,7 +415,7 @@ namespace Step64
     system_rhs_dev.reinit(locally_owned_dofs, mpi_communicator);
 
     constraints.clear();
-    constraints.reinit(locally_relevant_dofs);
+    constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
     DoFTools::make_hanging_node_constraints(dof_handler, constraints);
     VectorTools::interpolate_boundary_values(dof_handler,
                                              0,
index e407742ed4a17071dd4c03b47a9f14bde3fd8e39..d5c258506329c470daaec0f239442e3a217156e9 100644 (file)
@@ -544,11 +544,9 @@ namespace Step66
     dof_handler.distribute_dofs(fe);
     dof_handler.distribute_mg_dofs();
 
-    const IndexSet locally_relevant_dofs =
-      DoFTools::extract_locally_relevant_dofs(dof_handler);
-
     constraints.clear();
-    constraints.reinit(locally_relevant_dofs);
+    constraints.reinit(dof_handler.locally_owned_dofs(),
+                       DoFTools::extract_locally_relevant_dofs(dof_handler));
     DoFTools::make_hanging_node_constraints(dof_handler, constraints);
     VectorTools::interpolate_boundary_values(dof_handler,
                                              0,
@@ -592,11 +590,9 @@ namespace Step66
 
     for (unsigned int level = 0; level < nlevels; ++level)
       {
-        const IndexSet relevant_dofs =
-          DoFTools::extract_locally_relevant_level_dofs(dof_handler, level);
-
-        AffineConstraints<double> level_constraints;
-        level_constraints.reinit(relevant_dofs);
+        AffineConstraints<double> level_constraints(
+          dof_handler.locally_owned_mg_dofs(level),
+          DoFTools::extract_locally_relevant_level_dofs(dof_handler, level));
         level_constraints.add_lines(
           mg_constrained_dofs.get_boundary_indices(level));
         level_constraints.close();
index 5e494ea190cc9170563eb31b8833680539310ce5..82904e58feb606fbe7331429922da465275bb9e0 100644 (file)
@@ -1250,7 +1250,7 @@ namespace Step70
     fluid_relevant_dofs[1] = locally_relevant_dofs.get_view(n_u, n_u + n_p);
 
     {
-      constraints.reinit(locally_relevant_dofs);
+      constraints.reinit(fluid_dh.locally_owned_dofs(), locally_relevant_dofs);
 
       const FEValuesExtractors::Vector velocities(0);
       DoFTools::make_hanging_node_constraints(fluid_dh, constraints);
@@ -1263,7 +1263,7 @@ namespace Step70
       constraints.close();
     }
 
-    auto locally_owned_dofs_per_processor =
+    const auto locally_owned_dofs_per_processor =
       Utilities::MPI::all_gather(mpi_communicator,
                                  fluid_dh.locally_owned_dofs());
     {
index 7ff8fda19ffb39ad1cf55238680731a2541cd5da..417819f0e90bfec2861597da80d16fe6d028af23 100644 (file)
@@ -325,11 +325,9 @@ namespace Step75
     // operator is applied to a vector with only the Dirichlet values set. The
     // result is the negative right-hand-side vector.
     {
-      AffineConstraints<number> constraints_without_dbc;
-
-      const IndexSet locally_relevant_dofs =
-        DoFTools::extract_locally_relevant_dofs(dof_handler);
-      constraints_without_dbc.reinit(locally_relevant_dofs);
+      AffineConstraints<number> constraints_without_dbc(
+        dof_handler.locally_owned_dofs(),
+        DoFTools::extract_locally_relevant_dofs(dof_handler));
 
       DoFTools::make_hanging_node_constraints(dof_handler,
                                               constraints_without_dbc);
@@ -779,9 +777,8 @@ namespace Step75
         const auto &dof_handler = dof_handlers[level];
         auto       &constraint  = constraints[level];
 
-        const IndexSet locally_relevant_dofs =
-          DoFTools::extract_locally_relevant_dofs(dof_handler);
-        constraint.reinit(locally_relevant_dofs);
+        constraint.reinit(dof_handler.locally_owned_dofs(),
+                          DoFTools::extract_locally_relevant_dofs(dof_handler));
 
         DoFTools::make_hanging_node_constraints(dof_handler, constraint);
         VectorTools::interpolate_boundary_values(mapping_collection,
@@ -1117,7 +1114,7 @@ namespace Step75
     system_rhs.reinit(locally_owned_dofs, mpi_communicator);
 
     constraints.clear();
-    constraints.reinit(locally_relevant_dofs);
+    constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
     DoFTools::make_hanging_node_constraints(dof_handler, constraints);
     VectorTools::interpolate_boundary_values(
       mapping_collection, dof_handler, 0, Solution<dim>(), constraints);

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.