From: Wolfgang Bangerth Date: Tue, 6 Sep 2016 22:28:03 +0000 (-0600) Subject: Remove exceptions without error messages. X-Git-Tag: v8.5.0-rc1~696^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3074%2Fhead;p=dealii.git 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. --- 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()); } }