]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove exceptions without error messages. 3074/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 6 Sep 2016 22:28:03 +0000 (16:28 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 7 Sep 2016 18:37:08 +0000 (12:37 -0600)
Here, just check that a valid value is set for the finite difference formula. Later on,
we should then not ever get an invalid value any more, but if we do, we can just say
that whatever we got is not implemented.

include/deal.II/base/auto_derivative_function.h
include/deal.II/base/function_derivative.h
source/base/auto_derivative_function.cc
source/base/function_derivative.cc

index 60487fbb74f36b7554faeb2b137b0442cef72eb5..0f1a51c15460ff4d08298c3f081dbf2a21d8ee05 100644 (file)
@@ -204,10 +204,6 @@ public:
   DifferenceFormula
   get_formula_of_order (const unsigned int ord);
 
-  /**
-   * Exception.
-   */
-  DeclException0(ExcInvalidFormula);
 
 private:
 
index 731101823b302958dff357a477d18e83ca858138..92c70edbf67d6aa96d6d3bf481f30635f698100e 100644 (file)
@@ -101,16 +101,6 @@ public:
    */
   std::size_t memory_consumption () const;
 
-  /**
-   * @addtogroup Exceptions
-   * @{
-   */
-
-  /**
-   * Exception.
-   */
-  DeclException0(ExcInvalidFormula);
-  //@}
 private:
   /**
    * Function for differentiation.
index 5b267455963fd997924826b964dc9cd7aa03ac26..8f07803d2fd75d0fd40c522c76e14438d9593bab 100644 (file)
@@ -47,6 +47,19 @@ template <int dim>
 void
 AutoDerivativeFunction<dim>::set_formula (const DifferenceFormula form)
 {
+  // go through all known formulas, reject ones we don't know about
+  // and don't handle in the member functions of this class
+  switch (form)
+    {
+    case Euler:
+    case UpwindEuler:
+    case FourthOrder:
+      break;
+    default:
+      Assert(false, ExcMessage("The argument passed to this function does not "
+                               "match any known difference formula."));
+    }
+
   formula = form;
 }
 
@@ -108,7 +121,7 @@ AutoDerivativeFunction<dim>::gradient (const Point<dim>   &p,
       break;
     }
     default:
-      Assert(false, ExcInvalidFormula());
+      Assert(false, ExcNotImplemented());
     }
   return grad;
 }
@@ -185,7 +198,7 @@ vector_gradient (const Point<dim>            &p,
     }
 
     default:
-      Assert(false, ExcInvalidFormula());
+      Assert(false, ExcNotImplemented());
     }
 }
 
@@ -246,7 +259,7 @@ gradient_list (const std::vector<Point<dim> > &points,
     }
 
     default:
-      Assert(false, ExcInvalidFormula());
+      Assert(false, ExcNotImplemented());
     }
 }
 
@@ -314,7 +327,7 @@ vector_gradient_list (const std::vector<Point<dim> >            &points,
     }
 
     default:
-      Assert(false, ExcInvalidFormula());
+      Assert(false, ExcNotImplemented());
     }
 }
 
index 8395d70f56b6969b4b7a5d697abac15e37939c17..c75d76c9e83a7c5f288a30471169deca932446d3 100644 (file)
@@ -57,6 +57,19 @@ template <int dim>
 void
 FunctionDerivative<dim>::set_formula (typename AutoDerivativeFunction<dim>::DifferenceFormula form)
 {
+  // go through all known formulas, reject ones we don't know about
+  // and don't handle in the member functions of this class
+  switch (form)
+    {
+    case AutoDerivativeFunction<dim>::Euler:
+    case AutoDerivativeFunction<dim>::UpwindEuler:
+    case AutoDerivativeFunction<dim>::FourthOrder:
+      break;
+    default:
+      Assert(false, ExcMessage("The argument passed to this function does not "
+                               "match any known difference formula."));
+    }
+
   formula = form;
 }
 
@@ -91,7 +104,7 @@ FunctionDerivative<dim>::value (const Point<dim>   &p,
       return (-f.value(p+2*incr[0], component) + 8*f.value(p+incr[0], component)
               -8*f.value(p-incr[0], component) + f.value(p-2*incr[0], component))/(12*h);
     default:
-      Assert(false, ExcInvalidFormula());
+      Assert(false, ExcNotImplemented());
     }
   return 0.;
 }
@@ -134,7 +147,7 @@ FunctionDerivative<dim>::vector_value (
       result/=(12.*h);
       return;
     default:
-      Assert(false, ExcInvalidFormula());
+      Assert(false, ExcNotImplemented());
     }
 }
 
@@ -200,7 +213,7 @@ FunctionDerivative<dim>::value_list (const std::vector<Point<dim> > &points,
         values[i] = (values[i] - 8.*aux[i])/(12*h);
       return;
     default:
-      Assert(false, ExcInvalidFormula());
+      Assert(false, ExcNotImplemented());
     }
 }
 

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.