From: David Wells Date: Sun, 8 Jul 2018 02:16:47 +0000 (-0400) Subject: step-9: Remove some unneeded code. X-Git-Tag: v9.1.0-rc1~853^2~9 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4700f3cae6e69111bf1b1d607b1774e979660ff;p=dealii.git step-9: Remove some unneeded code. 1. The default constructor destroys the DoFHandler correctly already, so we can get rid of the explicit declaration. 2. Remove explicit value_list overrides: Modern compilers are good enough at devirtualizing that this optimization is no longer necessary. 3. Remove some empty constructors. --- diff --git a/examples/step-9/step-9.cc b/examples/step-9/step-9.cc index 1be2bdc17b..ac32ace6ef 100644 --- a/examples/step-9/step-9.cc +++ b/examples/step-9/step-9.cc @@ -82,7 +82,6 @@ namespace Step9 { public: AdvectionProblem(); - ~AdvectionProblem(); void run(); private: @@ -196,15 +195,8 @@ namespace Step9 class AdvectionField : public TensorFunction<1, dim> { public: - AdvectionField() - : TensorFunction<1, dim>() - {} - virtual Tensor<1, dim> value(const Point &p) const override; - virtual void value_list(const std::vector> &points, - std::vector> &values) const override; - // In previous examples, we have used assertions that throw exceptions in // several places. However, we have never seen how such exceptions are // declared. This can be done as follows: @@ -259,22 +251,6 @@ namespace Step9 return value; } - - - template - void - AdvectionField::value_list(const std::vector> &points, - std::vector> & values) const - { - Assert(values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i = 0; i < points.size(); ++i) - values[i] = AdvectionField::value(points[i]); - } - - - // Besides the advection field, we need two functions describing the source // terms (right hand side) and the boundary values. First for // the right hand side, which follows the same pattern as in previous @@ -282,24 +258,14 @@ namespace Step9 // function in the vicinity of a source point, which we denote by the // constant static variable center_point. We set the values of // this center using the same template tricks as we have shown in the step-7 - // example program. The rest is simple and has been shown previously, - // including the way to avoid virtual function calls in the - // value_list function. + // example program. The rest is simple and has been shown previously. template class RightHandSide : public Function { public: - RightHandSide() - : Function() - {} - virtual double value(const Point & p, const unsigned int component = 0) const override; - virtual void value_list(const std::vector> &points, - std::vector & values, - const unsigned int component = 0) const override; - private: static const Point center_point; }; @@ -340,36 +306,14 @@ namespace Step9 - template - void RightHandSide::value_list(const std::vector> &points, - std::vector & values, - const unsigned int component) const - { - Assert(values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i = 0; i < points.size(); ++i) - values[i] = RightHandSide::value(points[i], component); - } - - - // Finally for the boundary values, which is just another class derived from // the Function base class: template class BoundaryValues : public Function { public: - BoundaryValues() - : Function() - {} - virtual double value(const Point & p, const unsigned int component = 0) const override; - - virtual void value_list(const std::vector> &points, - std::vector & values, - const unsigned int component = 0) const override; }; @@ -387,22 +331,6 @@ namespace Step9 return sine_term * weight; } - - - template - void BoundaryValues::value_list(const std::vector> &points, - std::vector & values, - const unsigned int component) const - { - Assert(values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - - for (unsigned int i = 0; i < points.size(); ++i) - values[i] = BoundaryValues::value(points[i], component); - } - - - // @sect3{GradientEstimation class declaration} // Now, finally, here comes the class that will compute the difference @@ -526,14 +454,6 @@ namespace Step9 - template - AdvectionProblem::~AdvectionProblem() - { - dof_handler.clear(); - } - - - template void AdvectionProblem::setup_system() {