]> https://gitweb.dealii.org/ - dealii.git/commitdiff
AssertDimension macro in examples
authorFabian Castelli <fabian.castelli@kit.edu>
Sat, 21 Aug 2021 15:23:26 +0000 (17:23 +0200)
committerFabian Castelli <fabian.castelli@kit.edu>
Mon, 23 Aug 2021 06:59:39 +0000 (08:59 +0200)
17 files changed:
doc/doxygen/headers/coding_conventions.h
examples/step-12/step-12.cc
examples/step-12b/step-12b.cc
examples/step-17/step-17.cc
examples/step-18/step-18.cc
examples/step-20/doc/results.dox
examples/step-20/step-20.cc
examples/step-21/step-21.cc
examples/step-29/step-29.cc
examples/step-30/step-30.cc
examples/step-35/step-35.cc
examples/step-43/step-43.cc
examples/step-58/step-58.cc
examples/step-61/step-61.cc
examples/step-63/step-63.cc
examples/step-8/step-8.cc
examples/step-9/step-9.cc

index c7a22bc8d09273c05c4197fbadb59fedcada6bed..128f14060b43f5e0085d09b8196ac764ead68bc4 100644 (file)
@@ -308,8 +308,7 @@ we list here:
     operator+=(Vector       &lhs,
                const Vector &rhs)
     {
-      Assert (lhs.size() == rhs.size(),
-              ExcDimensionMismatch(lhs.size(), rhs.size());
+      AssertDimension (lhs.size(), rhs.size());
       for (unsigned int i=0; i<lhs.size(); ++i)
         lhs(i) += rhs(i);
       return lhs;
index 06d43b86425e759a3120c312a076552cfa300d3a..a2ab5750bffff4ee418e78ce56a125732ee8dfda 100644 (file)
@@ -97,8 +97,7 @@ namespace Step12
   {
     (void)component;
     AssertIndexRange(component, 1);
-    Assert(values.size() == points.size(),
-           ExcDimensionMismatch(values.size(), points.size()));
+    AssertDimension(values.size(), points.size());
 
     for (unsigned int i = 0; i < values.size(); ++i)
       {
index 9c006081147d720982864432608439ad0c1821c4..aa717e06d9f4ce98add62c3c514ecfa190921622 100644 (file)
@@ -103,8 +103,7 @@ namespace Step12
   {
     (void)component;
     AssertIndexRange(component, 1);
-    Assert(values.size() == points.size(),
-           ExcDimensionMismatch(values.size(), points.size()));
+    AssertDimension(values.size(), points.size());
 
     for (unsigned int i = 0; i < values.size(); ++i)
       {
index 99d0a00baad13b5f65874e13a47762b284ff4a68..838013b7231b049c220108825dbaf6021dd6e378 100644 (file)
@@ -184,7 +184,7 @@ namespace Step17
     virtual void vector_value(const Point<dim> &p,
                               Vector<double> &  values) const override
     {
-      Assert(values.size() == dim, ExcDimensionMismatch(values.size(), dim));
+      AssertDimension(values.size(), dim);
       Assert(dim >= 2, ExcInternalError());
 
       Point<dim> point_1, point_2;
@@ -209,8 +209,7 @@ namespace Step17
     {
       const unsigned int n_points = points.size();
 
-      Assert(value_list.size() == n_points,
-             ExcDimensionMismatch(value_list.size(), n_points));
+      AssertDimension(value_list.size(), n_points);
 
       for (unsigned int p = 0; p < n_points; ++p)
         RightHandSide<dim>::vector_value(points[p], value_list[p]);
index b54569e9e2d8ff704c65b53d0a65f5d0e76c5cb7..f0906082ac0a43457b395b6ae1e0e618eaef2391 100644 (file)
@@ -559,7 +559,7 @@ namespace Step18
   inline void BodyForce<dim>::vector_value(const Point<dim> & /*p*/,
                                            Vector<double> &values) const
   {
-    Assert(values.size() == dim, ExcDimensionMismatch(values.size(), dim));
+    AssertDimension(values.size(), dim);
 
     const double g   = 9.81;
     const double rho = 7700;
@@ -577,8 +577,7 @@ namespace Step18
   {
     const unsigned int n_points = points.size();
 
-    Assert(value_list.size() == n_points,
-           ExcDimensionMismatch(value_list.size(), n_points));
+    AssertDimension(value_list.size(), n_points);
 
     for (unsigned int p = 0; p < n_points; ++p)
       BodyForce<dim>::vector_value(points[p], value_list[p]);
@@ -650,7 +649,7 @@ namespace Step18
   IncrementalBoundaryValues<dim>::vector_value(const Point<dim> & /*p*/,
                                                Vector<double> &values) const
   {
-    Assert(values.size() == dim, ExcDimensionMismatch(values.size(), dim));
+    AssertDimension(values.size(), dim);
 
     values    = 0;
     values(2) = -present_timestep * velocity;
@@ -665,8 +664,7 @@ namespace Step18
   {
     const unsigned int n_points = points.size();
 
-    Assert(value_list.size() == n_points,
-           ExcDimensionMismatch(value_list.size(), n_points));
+    AssertDimension(value_list.size(), n_points);
 
     for (unsigned int p = 0; p < n_points; ++p)
       IncrementalBoundaryValues<dim>::vector_value(points[p], value_list[p]);
index 9afeb6fdaa4a5fa3a782842469ddbcaf38bb774f..bccc6f073c8dcc974df76461590c315177632f8b 100644 (file)
@@ -179,8 +179,7 @@ void
 KInverse<dim>::value_list (const std::vector<Point<dim> > &points,
                            std::vector<Tensor<2,dim> >    &values) const
 {
-  Assert (points.size() == values.size(),
-         ExcDimensionMismatch (points.size(), values.size()));
+  AssertDimension (points.size(), values.size());
 
   for (unsigned int p=0; p<points.size(); ++p)
     {
@@ -256,8 +255,7 @@ void
 KInverse<dim>::value_list (const std::vector<Point<dim> > &points,
                            std::vector<Tensor<2,dim> >    &values) const
 {
-  Assert (points.size() == values.size(),
-         ExcDimensionMismatch (points.size(), values.size()));
+  AssertDimension (points.size(), values.size());
 
   for (unsigned int p=0; p<points.size(); ++p)
     {
index e8238891373b835f7c5ef36063b5def2ee2e72d2..833b04104226450136fdc97a3acda04c0720a437 100644 (file)
@@ -195,8 +195,7 @@ namespace Step20
     void ExactSolution<dim>::vector_value(const Point<dim> &p,
                                           Vector<double> &  values) const
     {
-      Assert(values.size() == dim + 1,
-             ExcDimensionMismatch(values.size(), dim + 1));
+      AssertDimension(values.size(), dim + 1);
 
       values(0) = alpha * p[1] * p[1] / 2 + beta - alpha * p[0] * p[0] / 2;
       values(1) = alpha * p[0] * p[1];
index cd96bfdec31251585faa2f524c9a2fc858055e4c..a3032ae782fac2c19801e98946e6c7483c418ca1 100644 (file)
@@ -267,8 +267,7 @@ namespace Step21
       value_list(const std::vector<Point<dim>> &points,
                  std::vector<Tensor<2, dim>> &  values) const override
       {
-        Assert(points.size() == values.size(),
-               ExcDimensionMismatch(points.size(), values.size()));
+        AssertDimension(points.size(), values.size());
 
         for (unsigned int p = 0; p < points.size(); ++p)
           {
@@ -336,8 +335,7 @@ namespace Step21
       value_list(const std::vector<Point<dim>> &points,
                  std::vector<Tensor<2, dim>> &  values) const override
       {
-        Assert(points.size() == values.size(),
-               ExcDimensionMismatch(points.size(), values.size()));
+        AssertDimension(points.size(), values.size());
 
         for (unsigned int p = 0; p < points.size(); ++p)
           {
index 03a3f0479f6e59e93b8e4b8ac05d06c7a818ddbe..fa7781939249a1126f3e2754666c15d46909009a 100644 (file)
@@ -102,7 +102,7 @@ namespace Step29
     virtual void vector_value(const Point<dim> & /*p*/,
                               Vector<double> &values) const override
     {
-      Assert(values.size() == 2, ExcDimensionMismatch(values.size(), 2));
+      AssertDimension(values.size(), 2);
 
       values(0) = 1;
       values(1) = 0;
@@ -112,8 +112,7 @@ namespace Step29
     vector_value_list(const std::vector<Point<dim>> &points,
                       std::vector<Vector<double>> &  value_list) const override
     {
-      Assert(value_list.size() == points.size(),
-             ExcDimensionMismatch(value_list.size(), points.size()));
+      AssertDimension(value_list.size(), points.size());
 
       for (unsigned int p = 0; p < points.size(); ++p)
         DirichletBoundaryValues<dim>::vector_value(points[p], value_list[p]);
@@ -326,9 +325,7 @@ namespace Step29
     const DataPostprocessorInputs::Vector<dim> &inputs,
     std::vector<Vector<double>> &               computed_quantities) const
   {
-    Assert(computed_quantities.size() == inputs.solution_values.size(),
-           ExcDimensionMismatch(computed_quantities.size(),
-                                inputs.solution_values.size()));
+    AssertDimension(computed_quantities.size(), inputs.solution_values.size());
 
     // The computation itself is straightforward: We iterate over each
     // entry in the output vector and compute $|u|$ from the
@@ -341,10 +338,8 @@ namespace Step29
     // something called a "norm".)
     for (unsigned int i = 0; i < computed_quantities.size(); ++i)
       {
-        Assert(computed_quantities[i].size() == 1,
-               ExcDimensionMismatch(computed_quantities[i].size(), 1));
-        Assert(inputs.solution_values[i].size() == 2,
-               ExcDimensionMismatch(inputs.solution_values[i].size(), 2));
+        AssertDimension(computed_quantities[i].size(), 1);
+        AssertDimension(inputs.solution_values[i].size(), 2);
 
         const std::complex<double> u(inputs.solution_values[i](0),
                                      inputs.solution_values[i](1));
index 87ac7be48aaa177d107cd036eb295a9aa09dd3fe..1f151aab4b30b11172bd46be2e96e1722df9c2f1 100644 (file)
@@ -63,8 +63,7 @@ namespace Step30
                             const unsigned int /*component*/ = 0) const override
     {
       (void)points;
-      Assert(values.size() == points.size(),
-             ExcDimensionMismatch(values.size(), points.size()));
+      AssertDimension(values.size(), points.size());
 
       std::fill(values.begin(), values.end(), 0.);
     }
@@ -79,8 +78,7 @@ namespace Step30
                             std::vector<double> &          values,
                             const unsigned int /*component*/ = 0) const override
     {
-      Assert(values.size() == points.size(),
-             ExcDimensionMismatch(values.size(), points.size()));
+      AssertDimension(values.size(), points.size());
 
       for (unsigned int i = 0; i < values.size(); ++i)
         {
@@ -110,8 +108,7 @@ namespace Step30
     void value_list(const std::vector<Point<dim>> &points,
                     std::vector<Point<dim>> &      values) const
     {
-      Assert(values.size() == points.size(),
-             ExcDimensionMismatch(values.size(), points.size()));
+      AssertDimension(values.size(), points.size());
 
       for (unsigned int i = 0; i < points.size(); ++i)
         {
index a0dc153f7995eeef0d08ca7d0116a9732374eb95..bee2871a986971c86ef91ca515ac86132d83bbd1 100644 (file)
@@ -352,8 +352,7 @@ namespace Step35
                                    const unsigned int) const
     {
       const unsigned int n_points = points.size();
-      Assert(values.size() == n_points,
-             ExcDimensionMismatch(values.size(), n_points));
+      AssertDimension(values.size(), n_points);
       for (unsigned int i = 0; i < n_points; ++i)
         values[i] = Velocity<dim>::value(points[i]);
     }
@@ -411,8 +410,7 @@ namespace Step35
       (void)component;
       AssertIndexRange(component, 1);
       const unsigned int n_points = points.size();
-      Assert(values.size() == n_points,
-             ExcDimensionMismatch(values.size(), n_points));
+      AssertDimension(values.size(), n_points);
       for (unsigned int i = 0; i < n_points; ++i)
         values[i] = Pressure<dim>::value(points[i]);
     }
index bd6fdf786929bfe6967cc43ba55d79aee7789eff..f44a9c8de5725dc71758c755682269844b5f2aee 100644 (file)
@@ -185,8 +185,7 @@ namespace Step43
     void KInverse<dim>::value_list(const std::vector<Point<dim>> &points,
                                    std::vector<Tensor<2, dim>> &  values) const
     {
-      Assert(points.size() == values.size(),
-             ExcDimensionMismatch(points.size(), values.size()));
+      AssertDimension(points.size(), values.size());
 
       for (unsigned int p = 0; p < points.size(); ++p)
         {
index bacc1c947bac5b57f134072ebec2a8763c31ae91..e21bc2a7758c4b559580dc1ad15577e860826844 100644 (file)
@@ -477,16 +477,12 @@ namespace Step58
       const DataPostprocessorInputs::Vector<dim> &inputs,
       std::vector<Vector<double>> &               computed_quantities) const
     {
-      Assert(computed_quantities.size() == inputs.solution_values.size(),
-             ExcDimensionMismatch(computed_quantities.size(),
-                                  inputs.solution_values.size()));
+      AssertDimension(computed_quantities.size(), inputs.solution_values.size());
 
       for (unsigned int q = 0; q < computed_quantities.size(); ++q)
         {
-          Assert(computed_quantities[q].size() == 1,
-                 ExcDimensionMismatch(computed_quantities[q].size(), 1));
-          Assert(inputs.solution_values[q].size() == 2,
-                 ExcDimensionMismatch(inputs.solution_values[q].size(), 2));
+          AssertDimension(computed_quantities[q].size(), 1);
+          AssertDimension(inputs.solution_values[q].size(), 2);
 
           const std::complex<double> psi(inputs.solution_values[q](0),
                                          inputs.solution_values[q](1));
@@ -536,17 +532,13 @@ namespace Step58
       const DataPostprocessorInputs::Vector<dim> &inputs,
       std::vector<Vector<double>> &               computed_quantities) const
     {
-      Assert(computed_quantities.size() == inputs.solution_values.size(),
-             ExcDimensionMismatch(computed_quantities.size(),
-                                  inputs.solution_values.size()));
+      AssertDimension(computed_quantities.size(), inputs.solution_values.size());
 
       double max_phase = -numbers::PI;
       for (unsigned int q = 0; q < computed_quantities.size(); ++q)
         {
-          Assert(computed_quantities[q].size() == 1,
-                 ExcDimensionMismatch(computed_quantities[q].size(), 1));
-          Assert(inputs.solution_values[q].size() == 2,
-                 ExcDimensionMismatch(inputs.solution_values[q].size(), 2));
+          AssertDimension(computed_quantities[q].size(), 1);
+          AssertDimension(inputs.solution_values[q].size(), 2);
 
           max_phase =
             std::max(max_phase,
index d3c35b6b2a86969564c3ff7ee39dc8fb3b96eae8..a13ae7f6f4ccfac65ba734e2a776657829a18258 100644 (file)
@@ -141,8 +141,7 @@ namespace Step61
   void Coefficient<dim>::value_list(const std::vector<Point<dim>> &points,
                                     std::vector<Tensor<2, dim>> &  values) const
   {
-    Assert(points.size() == values.size(),
-           ExcDimensionMismatch(points.size(), values.size()));
+    AssertDimension(points.size(), values.size());
     for (unsigned int p = 0; p < points.size(); ++p)
       values[p] = unit_symmetric_tensor<dim>();
   }
index eb4122d19b6babb6dd7e9b46f9b56649616c6bf4..01db361eafc6e13bc9cffd55000a6cf761427405 100644 (file)
@@ -388,8 +388,7 @@ namespace Step63
                                       std::vector<double> &          values,
                                       const unsigned int component) const
   {
-    Assert(values.size() == points.size(),
-           ExcDimensionMismatch(values.size(), points.size()));
+    AssertDimension(values.size(), points.size());
 
     for (unsigned int i = 0; i < points.size(); ++i)
       values[i] = RightHandSide<dim>::value(points[i], component);
@@ -439,8 +438,7 @@ namespace Step63
                                        std::vector<double> &          values,
                                        const unsigned int component) const
   {
-    Assert(values.size() == points.size(),
-           ExcDimensionMismatch(values.size(), points.size()));
+    AssertDimension(values.size(), points.size());
 
     for (unsigned int i = 0; i < points.size(); ++i)
       values[i] = BoundaryValues<dim>::value(points[i], component);
index 15f3734fcaa8a498b14df150c5d4c5297c836f72..8b5700c42cedb7a3a8aa5e9d1dde1b0e7a2733a9 100644 (file)
@@ -138,8 +138,7 @@ namespace Step8
   void right_hand_side(const std::vector<Point<dim>> &points,
                        std::vector<Tensor<1, dim>> &  values)
   {
-    Assert(values.size() == points.size(),
-           ExcDimensionMismatch(values.size(), points.size()));
+    AssertDimension(values.size(), points.size());
     Assert(dim >= 2, ExcNotImplemented());
 
     // The rest of the function implements computing force values. We will use
index d29c49fed8e9ff5c44eea9fbfef607696539a476..c00b03a26c717d9d61a838fc559f59394096ff5d 100644 (file)
@@ -117,6 +117,10 @@ namespace Step9
     // this macro call declares and defines a class
     // <code>ExcDimensionMismatch</code> inheriting from ExceptionBase which
     // implements all necessary error output functions.
+    //
+    // @note This exception is similarly used inside the
+    // <code>AssertDimension</code> macro, which is a handy wrapper to the
+    // check the dimensions of two given objects.
   };
 
   // The following two functions implement the interface described above. The

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.