From ec9bfa7e11576fa35b6cad484ed8954de86e8859 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Mon, 6 Apr 2020 11:35:51 +0200 Subject: [PATCH] use DEBUG_THROW_IF --- dune/gdt/local/dof-vector.hh | 12 +++--------- dune/gdt/local/operators/advection-fv.hh | 10 ++++------ dune/gdt/spaces/mapper/continuous.hh | 7 +++---- .../tools/timestepper/adaptive-rungekutta-kinetic.hh | 7 +++---- dune/gdt/tools/timestepper/adaptive-rungekutta.hh | 7 +++---- dune/gdt/tools/timestepper/explicit-rungekutta.hh | 7 +++---- 6 files changed, 19 insertions(+), 31 deletions(-) diff --git a/dune/gdt/local/dof-vector.hh b/dune/gdt/local/dof-vector.hh index 59658e842..e3ad2e292 100644 --- a/dune/gdt/local/dof-vector.hh +++ b/dune/gdt/local/dof-vector.hh @@ -214,27 +214,21 @@ public: void add_to_entry(const size_t ii, const ScalarType& value) { -#ifndef NDEBUG - DUNE_THROW_IF(!this->is_bound_, Exceptions::not_bound_to_an_element_yet, ""); -#endif + DEBUG_THROW_IF(!this->is_bound_, Exceptions::not_bound_to_an_element_yet, ""); assert(ii < size_); global_vector_.add_to_entry(global_DoF_indices_[ii], value); } void set_entry(const size_t ii, const ScalarType& value) { -#ifndef NDEBUG - DUNE_THROW_IF(!this->is_bound_, Exceptions::not_bound_to_an_element_yet, ""); -#endif + DEBUG_THROW_IF(!this->is_bound_, Exceptions::not_bound_to_an_element_yet, ""); assert(ii < size_); global_vector_.set_entry(global_DoF_indices_[ii], value); } ScalarType get_entry(const size_t ii) const { -#ifndef NDEBUG - DUNE_THROW_IF(!this->is_bound_, Exceptions::not_bound_to_an_element_yet, ""); -#endif + DEBUG_THROW_IF(!this->is_bound_, Exceptions::not_bound_to_an_element_yet, ""); assert(ii < size_); return global_vector_.get_entry(global_DoF_indices_[ii]); } diff --git a/dune/gdt/local/operators/advection-fv.hh b/dune/gdt/local/operators/advection-fv.hh index d8ef9798e..45448a63a 100644 --- a/dune/gdt/local/operators/advection-fv.hh +++ b/dune/gdt/local/operators/advection-fv.hh @@ -128,12 +128,10 @@ public: LocalOutsideRangeType& local_range_outside, const XT::Common::Parameter& param = {}) const override final { -#ifndef NDEBUG - DUNE_THROW_IF((local_range_inside.space().type() != SpaceType::finite_volume) - || (local_range_outside.space().type() != SpaceType::finite_volume), - Exceptions::operator_error, - "Use LocalAdvectionDgCouplingOperator instead!"); -#endif + DEBUG_THROW_IF((local_range_inside.space().type() != SpaceType::finite_volume) + || (local_range_outside.space().type() != SpaceType::finite_volume), + Exceptions::operator_error, + "Use LocalAdvectionDgCouplingOperator instead!"); local_sources_[0]->evaluate( source_is_elementwise_constant_ ? static_x : intersection().geometryInInside().center(), u_, param); local_sources_[1]->evaluate( diff --git a/dune/gdt/spaces/mapper/continuous.hh b/dune/gdt/spaces/mapper/continuous.hh index c265f4a80..28b750ef0 100644 --- a/dune/gdt/spaces/mapper/continuous.hh +++ b/dune/gdt/spaces/mapper/continuous.hh @@ -128,10 +128,9 @@ public: // one element and index 1 in the other element. Fixing this could be done by assigning an orientation to the edge // by looking at the (indices of the) vertices of the edge and reordering the local indices if the orientation is // not the same in all elements sharing the subentity. -#ifndef NDEBUG - if (d >= 2 && fe_order_ >= 3) - assert(element.type() == Dune::GeometryTypes::cube(d) && "Not implemented for this element, see comment above!"); -#endif + DEBUG_THROW_IF(d >= 2 && fe_order_ >= 3 && element.type() != Dune::GeometryTypes::cube(d), + Dune::NotImplemented, + "Not implemented for this element, see comment above!"); return mapper_.subIndex(element, local_key.subEntity(), local_key.codim()) + local_key.index(); } // ... mapToGlobal(...) diff --git a/dune/gdt/tools/timestepper/adaptive-rungekutta-kinetic.hh b/dune/gdt/tools/timestepper/adaptive-rungekutta-kinetic.hh index 2c2f33794..44214ceb1 100644 --- a/dune/gdt/tools/timestepper/adaptive-rungekutta-kinetic.hh +++ b/dune/gdt/tools/timestepper/adaptive-rungekutta-kinetic.hh @@ -150,14 +150,13 @@ public: assert(b_1_.size() == A_.rows()); assert(b_2_.size() == A_.rows()); assert(c_.size() == A_.rows()); -#ifndef NDEBUG for (size_t ii = 0; ii < A_.rows(); ++ii) { for (size_t jj = ii; jj < A_.cols(); ++jj) { - assert(Dune::XT::Common::FloatCmp::eq(A_[ii][jj], 0.0) - && "A has to be a lower triangular matrix with 0 on the main diagonal"); + DUNE_THROW_IF(XT::Common::FloatCmp::ne(A_[ii][jj], 0.0), + XT::Common::Exceptions::wrong_input_given, + "A has to be a lower triangular matrix with 0 on the main diagonal"); } } -#endif // NDEBUG // store as many discrete functions as needed for intermediate stages for (size_t ii = 0; ii < num_stages_; ++ii) { stages_k_.emplace_back(current_solution()); diff --git a/dune/gdt/tools/timestepper/adaptive-rungekutta.hh b/dune/gdt/tools/timestepper/adaptive-rungekutta.hh index d35b5cc14..34ee92498 100644 --- a/dune/gdt/tools/timestepper/adaptive-rungekutta.hh +++ b/dune/gdt/tools/timestepper/adaptive-rungekutta.hh @@ -275,14 +275,13 @@ public: assert(b_1_.size() == A_.rows()); assert(b_2_.size() == A_.rows()); assert(c_.size() == A_.rows()); -#ifndef NDEBUG for (size_t ii = 0; ii < A_.rows(); ++ii) { for (size_t jj = ii; jj < A_.cols(); ++jj) { - assert(Dune::XT::Common::FloatCmp::eq(A_[ii][jj], 0.0) - && "A has to be a lower triangular matrix with 0 on the main diagonal"); + DUNE_THROW_IF(XT::Common::FloatCmp::ne(A_[ii][jj], 0.0), + XT::Common::Exceptions::wrong_input_given, + "A has to be a lower triangular matrix with 0 on the main diagonal"); } } -#endif // NDEBUG // store as many discrete functions as needed for intermediate stages for (size_t ii = 0; ii < num_stages_; ++ii) { stages_k_.emplace_back(current_solution()); diff --git a/dune/gdt/tools/timestepper/explicit-rungekutta.hh b/dune/gdt/tools/timestepper/explicit-rungekutta.hh index 04199eeef..8b416257c 100644 --- a/dune/gdt/tools/timestepper/explicit-rungekutta.hh +++ b/dune/gdt/tools/timestepper/explicit-rungekutta.hh @@ -215,14 +215,13 @@ public: assert(A_.rows() == A_.cols() && "A has to be a square matrix"); assert(b_.size() == A_.rows()); assert(c_.size() == A_.rows()); -#ifndef NDEBUG for (size_t ii = 0; ii < A_.rows(); ++ii) { for (size_t jj = ii; jj < A_.cols(); ++jj) { - assert(Dune::XT::Common::FloatCmp::eq(A_[ii][jj], 0.0) - && "A has to be a lower triangular matrix with 0 on the main diagonal"); + DUNE_THROW_IF(XT::Common::FloatCmp::ne(A_[ii][jj], 0.0), + XT::Common::Exceptions::wrong_input_given, + "A has to be a lower triangular matrix with 0 on the main diagonal"); } } -#endif // NDEBUG // store as many discrete functions as needed for the stages k for (size_t ii = 0; ii < num_stages_; ++ii) { stages_k_.emplace_back(current_solution()); -- GitLab