]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Convert tutorials to use DEAL_II_ASSERT_UNREACHABLE(). 16600/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 6 Feb 2024 20:30:28 +0000 (13:30 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 6 Feb 2024 20:30:28 +0000 (13:30 -0700)
examples/step-17/step-17.cc
examples/step-34/step-34.cc
examples/step-35/step-35.cc
examples/step-50/step-50.cc
examples/step-6/doc/results.dox
examples/step-62/step-62.cc
examples/step-68/step-68.cc

index 8c549b6afe7be8081e442feb805a3b70bcff79dc..dbdb7db9d73e1c7838cacdbb84e0926bc92eab7b 100644 (file)
@@ -913,7 +913,7 @@ namespace Step17
               solution_names.emplace_back("z_displacement");
               break;
             default:
-              Assert(false, ExcInternalError());
+              DEAL_II_NOT_IMPLEMENTED();
           }
 
         data_out.add_data_vector(localized_solution, solution_names);
index de5290dc413971180f941eaa95afc7b3b0ea1205..1398bbb350a7a82dcbefdf954eeb6b3735fdeeae 100644 (file)
@@ -87,8 +87,7 @@ namespace Step34
             return (1. / (R.norm() * 4 * numbers::PI));
 
           default:
-            Assert(false, ExcInternalError());
-            return 0.;
+            DEAL_II_NOT_IMPLEMENTED();
         }
     }
 
@@ -105,8 +104,7 @@ namespace Step34
             return R / (-4 * numbers::PI * R.norm_square() * R.norm());
 
           default:
-            Assert(false, ExcInternalError());
-            return Tensor<1, dim>();
+            DEAL_II_NOT_IMPLEMENTED();
         }
     }
   } // namespace LaplaceKernel
index 7890177a8dc2e362ad0ff50b1059cc4ddc020aa0..fbafbb4327817023a54010e72c747c3f8a03cfb9 100644 (file)
@@ -1337,7 +1337,7 @@ namespace Step35
                   loc_vel_dof_indices[joint_fe.system_to_base_index(i).second]);
                 break;
               default:
-                Assert(false, ExcInternalError());
+                DEAL_II_ASSERT_UNREACHABLE();
             }
       }
     std::vector<std::string> joint_solution_names(dim, "v");
index 2239385f6c7b3fd277bee3b8bbb5549a471769cb..f82e09dd32b4e9bfa8a1114a952c4a29fc3b9485 100644 (file)
@@ -1191,7 +1191,7 @@ void LaplaceProblem<dim, degree>::solve()
         }
 
       default:
-        Assert(false, ExcInternalError());
+        DEAL_II_ASSERT_UNREACHABLE();
     }
 
   pcout << "   Number of CG iterations:      " << solver_control.last_step()
@@ -1569,7 +1569,7 @@ int main(int argc, char *argv[])
             }
 
           default:
-            Assert(false, ExcMessage("This program only works in 2d and 3d."));
+            DEAL_II_NOT_IMPLEMENTED();
         }
     }
   catch (std::exception &exc)
index ed135a8b439d6b3dc02a666d72d7dfc9d2e86d78..650280da5302b42d89a7c454ebea65c83adf8f0a 100644 (file)
@@ -593,25 +593,18 @@ double coefficient (const Point<dim> &p)
   else if ((p[0] >= 0) && (p[1] >= 0))    // upper right quadrant
     return 1000;
   else
-    {
-      Assert(false, ExcInternalError());
-      return 0;
-    }
+    DEAL_II_ASSERT_UNREACHABLE();
 }
 @endcode
-(Adding the <code>Assert</code> at the end ensures that either an exception
+(Adding the `DEAL_II_ASSERT_UNREACHABLE();` call at the end ensures that either an exception
 is thrown or that the program aborts if we ever get to that point
 -- which of course we shouldn't,
-but this is a good way to insure yourself: we all make mistakes by
+but this is a good way to insure yourself: We all make mistakes by
 sometimes not thinking of all cases, for example by checking
 for <code>p[0]</code> to be less than and greater than zero,
 rather than greater-or-equal to zero, and thereby forgetting
 some cases that would otherwise lead to bugs that are awkward
-to find. The <code>return 0;</code> at the end is only there to
-avoid compiler warnings that the function does not end in a
-<code>return</code> statement -- the compiler cannot see that the
-function would never actually get to that point because of the
-preceding <code>Assert</code> statement.)
+to find.
 
 By playing with such cases where four or more sectors come
 together and on which the coefficient has different values, one can
index 3a486edbd955519160a92c80d8116876441808c0..80856be1dd58f6a8269ea8b1493d042d9f98b68d 100644 (file)
@@ -546,9 +546,8 @@ namespace step62
         elastic_constant = mu * (3 * lambda + 2 * mu) / (lambda + mu);
       }
     else
-      {
-        Assert(false, ExcInternalError());
-      }
+      DEAL_II_NOT_IMPLEMENTED();
+
     const double material_a_speed_of_sound =
       std::sqrt(elastic_constant / material_a_rho);
     const double material_a_wavelength =
index cdb3d99f6f7b03cd62e04f5e68997e661263e7ad..149892bc5fe304c3330dab15dc0334cc95f2f930 100644 (file)
@@ -323,8 +323,7 @@ namespace Step68
           break;
 
         default:
-          Assert(false, ExcInternalError());
-          break;
+          DEAL_II_ASSERT_UNREACHABLE();
       }
 
     return base_weight + particle_weight * n_particles_in_cell;

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.