From 49c96e644ebae389f9bae6a4f9cac860b470b74c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 6 Sep 2016 16:28:03 -0600 Subject: [PATCH] Remove exceptions without error messages. 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. --- .../deal.II/base/auto_derivative_function.h | 4 ---- include/deal.II/base/function_derivative.h | 10 --------- source/base/auto_derivative_function.cc | 21 +++++++++++++++---- source/base/function_derivative.cc | 19 ++++++++++++++--- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/include/deal.II/base/auto_derivative_function.h b/include/deal.II/base/auto_derivative_function.h index 60487fbb74..0f1a51c154 100644 --- a/include/deal.II/base/auto_derivative_function.h +++ b/include/deal.II/base/auto_derivative_function.h @@ -204,10 +204,6 @@ public: DifferenceFormula get_formula_of_order (const unsigned int ord); - /** - * Exception. - */ - DeclException0(ExcInvalidFormula); private: diff --git a/include/deal.II/base/function_derivative.h b/include/deal.II/base/function_derivative.h index 731101823b..92c70edbf6 100644 --- a/include/deal.II/base/function_derivative.h +++ b/include/deal.II/base/function_derivative.h @@ -101,16 +101,6 @@ public: */ std::size_t memory_consumption () const; - /** - * @addtogroup Exceptions - * @{ - */ - - /** - * Exception. - */ - DeclException0(ExcInvalidFormula); - //@} private: /** * Function for differentiation. diff --git a/source/base/auto_derivative_function.cc b/source/base/auto_derivative_function.cc index 5b26745596..8f07803d2f 100644 --- a/source/base/auto_derivative_function.cc +++ b/source/base/auto_derivative_function.cc @@ -47,6 +47,19 @@ template void AutoDerivativeFunction::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::gradient (const Point &p, break; } default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcNotImplemented()); } return grad; } @@ -185,7 +198,7 @@ vector_gradient (const Point &p, } default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcNotImplemented()); } } @@ -246,7 +259,7 @@ gradient_list (const std::vector > &points, } default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcNotImplemented()); } } @@ -314,7 +327,7 @@ vector_gradient_list (const std::vector > &points, } default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcNotImplemented()); } } diff --git a/source/base/function_derivative.cc b/source/base/function_derivative.cc index 8395d70f56..c75d76c9e8 100644 --- a/source/base/function_derivative.cc +++ b/source/base/function_derivative.cc @@ -57,6 +57,19 @@ template void FunctionDerivative::set_formula (typename AutoDerivativeFunction::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::Euler: + case AutoDerivativeFunction::UpwindEuler: + case AutoDerivativeFunction::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::value (const Point &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::vector_value ( result/=(12.*h); return; default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcNotImplemented()); } } @@ -200,7 +213,7 @@ FunctionDerivative::value_list (const std::vector > &points, values[i] = (values[i] - 8.*aux[i])/(12*h); return; default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcNotImplemented()); } } -- 2.39.5