]> https://gitweb.dealii.org/ - dealii.git/commitdiff
cell_weight: make assertion blocks smaller. 13561/head
authorMarc Fehling <mafehling.git@gmail.com>
Tue, 22 Mar 2022 20:03:42 +0000 (14:03 -0600)
committerMarc Fehling <mafehling.git@gmail.com>
Tue, 22 Mar 2022 21:01:11 +0000 (15:01 -0600)
source/distributed/tria.cc
source/grid/grid_tools.cc

index 773d56fe1aea5258c26955ef3826db32967708bf..64fef1ee4cdb30b19d2336e4ef78288c7934a2d6 100644 (file)
@@ -3361,19 +3361,14 @@ namespace parallel
               // get cell weights for a weighted repartitioning.
               const std::vector<unsigned int> cell_weights = get_cell_weights();
 
-#  ifdef DEBUG
               // verify that the global sum of weights is larger than 0
-              const auto local_weights_sum =
-                std::accumulate(cell_weights.begin(),
-                                cell_weights.end(),
-                                std::uint64_t(0));
-              const auto global_weights_sum =
-                Utilities::MPI::sum(local_weights_sum, this->mpi_communicator);
-              Assert(global_weights_sum > 0,
+              Assert(Utilities::MPI::sum(std::accumulate(cell_weights.begin(),
+                                                         cell_weights.end(),
+                                                         std::uint64_t(0)),
+                                         this->mpi_communicator) > 0,
                      ExcMessage(
                        "The global sum of weights over all active cells "
                        "is zero. Please verify how you generate weights."));
-#  endif
 
               PartitionWeights<dim, spacedim> partition_weights(cell_weights);
 
@@ -3543,18 +3538,14 @@ namespace parallel
           // get cell weights for a weighted repartitioning.
           const std::vector<unsigned int> cell_weights = get_cell_weights();
 
-#  ifdef DEBUG
           // verify that the global sum of weights is larger than 0
-          const auto local_weights_sum = std::accumulate(cell_weights.begin(),
-                                                         cell_weights.end(),
-                                                         std::uint64_t(0));
-          const auto global_weights_sum =
-            Utilities::MPI::sum(local_weights_sum, this->mpi_communicator);
-          Assert(global_weights_sum > 0,
+          Assert(Utilities::MPI::sum(std::accumulate(cell_weights.begin(),
+                                                     cell_weights.end(),
+                                                     std::uint64_t(0)),
+                                     this->mpi_communicator) > 0,
                  ExcMessage(
                    "The global sum of weights over all active cells "
                    "is zero. Please verify how you generate weights."));
-#  endif
 
           PartitionWeights<dim, spacedim> partition_weights(cell_weights);
 
index 4e77809375f3cdb131644dc44c95cb2fc023acc0..c0961adac3d474a9a61d1fe0dc6133ad6526d35c 100644 (file)
@@ -3842,15 +3842,12 @@ namespace GridTools
                               shared_tria->get_communicator(),
                               cell_weights);
 
-#ifdef DEBUG
         // verify that the global sum of weights is larger than 0
-        const auto global_cell_sum = std::accumulate(cell_weights.begin(),
-                                                     cell_weights.end(),
-                                                     std::uint64_t(0));
-        Assert(global_cell_sum > 0,
+        Assert(std::accumulate(cell_weights.begin(),
+                               cell_weights.end(),
+                               std::uint64_t(0)) > 0,
                ExcMessage("The global sum of weights over all active cells "
                           "is zero. Please verify how you generate weights."));
-#endif
       }
 
     // Call the other more general function
@@ -3946,15 +3943,12 @@ namespace GridTools
                               shared_tria->get_communicator(),
                               cell_weights);
 
-#ifdef DEBUG
         // verify that the global sum of weights is larger than 0
-        const auto global_cell_sum = std::accumulate(cell_weights.begin(),
-                                                     cell_weights.end(),
-                                                     std::uint64_t(0));
-        Assert(global_cell_sum > 0,
+        Assert(std::accumulate(cell_weights.begin(),
+                               cell_weights.end(),
+                               std::uint64_t(0)) > 0,
                ExcMessage("The global sum of weights over all active cells "
                           "is zero. Please verify how you generate weights."));
-#endif
       }
 
     // Call the other more general function

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.