From db841d863d051c3455265b027155825591d3223b Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Thu, 2 Dec 2021 09:53:55 +0100 Subject: [PATCH 01/19] Add script to apply clang-tidy to all targets --- apply_clang_tidy.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 apply_clang_tidy.sh diff --git a/apply_clang_tidy.sh b/apply_clang_tidy.sh new file mode 100755 index 000000000..288a4857e --- /dev/null +++ b/apply_clang_tidy.sh @@ -0,0 +1,27 @@ +# This script assumes that clang-tidy is installed and in the PATH. +# In addition, clang-tidy needs a compilation database, so you have to run +# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . +# in your build directory and then copy or symlink the resulting +# compile_commands.json to the source directory. + +# It is possible to run clang-tidy on the whole directory at once, using parallelism and all. +# However, even with the run-clang-tidy.py script and -j1, the fixes are applied several +# times to each header (once for each compilation unit in which the header is included), +# resulting in messed up files. We thus simply run clang-tidy sequentially for each +# compilation unit. This takes a long time, but since we only have to do this every +# now and then and can do other stuff while waiting for the script, this should be fine. + +# Headerchecks +BUILD_DIR=../build/clang-debug/dune-xt +CLANG_TIDY_BINARY=clang-tidy +for file in `find ${BUILD_DIR}/headercheck -name *.hh.cc`; do + ${CLANG_TIDY_BINARY} --config-file=.clang-tidy -fix ${file} +done +# Regular C++ files +for file in `find dune/xt/ -name *.cc`; do + ${CLANG_TIDY_BINARY} --config-file=.clang-tidy -fix ${file} +done +# Python bindings +for file in `find python/ -name *.cc`; do + ${CLANG_TIDY_BINARY} --config-file=.clang-tidy -fix ${file} +done -- GitLab From af96cc40895b6cd23f7ddb5fd16ced807a7e5d43 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Thu, 2 Dec 2021 10:29:31 +0100 Subject: [PATCH 02/19] Silence clang-tidy warning --- dune/xt/common/string.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dune/xt/common/string.hh b/dune/xt/common/string.hh index 5453a8029..526f1f72b 100644 --- a/dune/xt/common/string.hh +++ b/dune/xt/common/string.hh @@ -196,7 +196,10 @@ static inline char** vector_to_main_args(const std::vector<std::string>& args) char** argv = new char*[args.size()]; for (auto ii : value_range(args.size())) { argv[ii] = new char[args[ii].length() + 1]; - strcpy(argv[ii], args[ii].c_str()); + // clang-tidy complains that strcpy is insecure because it does not provide bounding of the memory buffer. + // However, the usage here seems fine and I did not find a more secure standard replacement, so we just + // silence the warning here. + strcpy(argv[ii], args[ii].c_str()); // NOLINT(clang-analyzer-security.insecureAPI.strcpy) } return argv; } // ... vector_to_main_args(...) -- GitLab From 40b3c34e047cda20c743cd119cf68fe215d0b8a1 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Thu, 2 Dec 2021 10:48:53 +0100 Subject: [PATCH 03/19] [clang-tidy] apply modernize-use-override --- dune/xt/common/logstreams.hh | 20 +++--- dune/xt/common/memory.hh | 30 ++++----- dune/xt/functions/ESV2007.hh | 29 ++++----- .../base/combined-element-functions.hh | 8 +-- dune/xt/functions/base/combined-functions.hh | 8 +-- .../functions/base/combined-grid-functions.hh | 4 +- dune/xt/functions/base/composition.hh | 17 +++-- .../base/derivatives-of-element-functions.hh | 8 +-- .../base/derivatives-of-grid-functions.hh | 4 +- .../base/function-as-flux-function.hh | 12 ++-- .../base/function-as-grid-function.hh | 14 ++-- dune/xt/functions/base/reinterpret.hh | 4 +- dune/xt/functions/base/sliced.hh | 12 ++-- dune/xt/functions/base/transformed.hh | 12 ++-- dune/xt/functions/base/visualization.hh | 28 ++++---- dune/xt/functions/checkerboard.hh | 10 +-- dune/xt/functions/constant.hh | 14 ++-- dune/xt/functions/elementwise-diameter.hh | 12 ++-- dune/xt/functions/elementwise-minimum.hh | 10 +-- dune/xt/functions/expression/default.hh | 16 ++--- dune/xt/functions/expression/parametric.hh | 8 +-- dune/xt/functions/flattop.hh | 4 +- dune/xt/functions/generic/flux-function.hh | 20 +++--- dune/xt/functions/generic/function.hh | 12 ++-- dune/xt/functions/generic/grid-function.hh | 14 ++-- dune/xt/functions/grid-function.hh | 12 ++-- dune/xt/functions/indicator.hh | 20 +++--- .../interfaces/element-flux-functions.hh | 2 +- .../functions/interfaces/element-functions.hh | 2 +- dune/xt/functions/interfaces/flux-function.hh | 2 +- dune/xt/functions/interfaces/function.hh | 2 +- dune/xt/functions/interfaces/grid-function.hh | 2 +- dune/xt/functions/inverse.hh | 14 ++-- dune/xt/grid/boundaryinfo/alldirichlet.hh | 4 +- dune/xt/grid/boundaryinfo/allneumann.hh | 2 +- dune/xt/grid/boundaryinfo/allreflecting.hh | 2 +- dune/xt/grid/boundaryinfo/boundarysegment.hh | 2 +- dune/xt/grid/boundaryinfo/functionbased.hh | 4 +- dune/xt/grid/boundaryinfo/normalbased.hh | 4 +- dune/xt/grid/boundaryinfo/types.hh | 44 ++++++------- dune/xt/grid/filters/base.hh | 16 ++--- dune/xt/grid/filters/element.hh | 20 +++--- dune/xt/grid/filters/intersection.hh | 64 +++++++++---------- dune/xt/grid/functors/boundary-detector.hh | 8 +-- dune/xt/grid/functors/bounding-box.hh | 8 +-- dune/xt/grid/functors/generic.hh | 24 +++---- dune/xt/grid/functors/refinement.hh | 2 +- dune/xt/grid/output/entity_visualization.hh | 6 +- dune/xt/grid/print.hh | 8 +-- dune/xt/grid/walker.hh | 6 +- dune/xt/la/container/common/matrix/sparse.hh | 6 +- dune/xt/la/container/common/vector/dense.hh | 12 ++-- dune/xt/la/container/common/vector/sparse.hh | 20 +++--- dune/xt/la/container/eigen/base.hh | 14 ++-- dune/xt/la/container/eigen/dense.hh | 6 +- dune/xt/la/container/eigen/sparse.hh | 4 +- dune/xt/la/container/istl.hh | 18 +++--- dune/xt/la/container/matrix-interface.hh | 2 +- dune/xt/la/container/matrix-view.hh | 8 +-- dune/xt/la/container/vector-interface.hh | 4 +- dune/xt/la/container/vector-view.hh | 8 +-- dune/xt/la/eigen-solver/default.hh | 2 +- dune/xt/la/eigen-solver/eigen.hh | 2 +- dune/xt/la/eigen-solver/fmatrix.hh | 2 +- .../xt/la/generalized-eigen-solver/default.hh | 2 +- dune/xt/la/matrix-inverter/default.hh | 2 +- dune/xt/la/matrix-inverter/eigen.hh | 2 +- dune/xt/la/matrix-inverter/fmatrix.hh | 2 +- dune/xt/la/solver/istl/preconditioners.hh | 8 +-- dune/xt/la/solver/istl/schurcomplement.hh | 6 +- dune/xt/test/common/configuration.cc | 2 +- 71 files changed, 370 insertions(+), 372 deletions(-) diff --git a/dune/xt/common/logstreams.hh b/dune/xt/common/logstreams.hh index 6417debf0..eaa42bf12 100644 --- a/dune/xt/common/logstreams.hh +++ b/dune/xt/common/logstreams.hh @@ -68,8 +68,8 @@ public: protected: friend class CombinedBuffer; - virtual std::streamsize xsputn(const char_type* s, std::streamsize count); - virtual int_type overflow(int_type ch = traits_type::eof()); + std::streamsize xsputn(const char_type* s, std::streamsize count) override; + int_type overflow(int_type ch = traits_type::eof()) override; private: inline bool enabled() const @@ -101,7 +101,7 @@ private: std::mutex sync_mutex_; protected: - virtual int sync(); + int sync() override; }; // class FileBuffer class CombinedBuffer : public SuspendableStrBuffer @@ -118,9 +118,9 @@ public: int pubsync(); protected: - virtual std::streamsize xsputn(const char_type* s, std::streamsize count); - virtual int_type overflow(int_type ch = traits_type::eof()); - virtual int sync(); + std::streamsize xsputn(const char_type* s, std::streamsize count) override; + int_type overflow(int_type ch = traits_type::eof()) override; + int sync() override; private: std::list<std::unique_ptr<SuspendableStrBuffer>> buffer_; @@ -136,7 +136,7 @@ public: {} protected: - virtual int sync(); + int sync() override; }; // class EmptyBuffer /** @@ -151,7 +151,7 @@ class TimedPrefixedStreamBuffer : public std::basic_stringbuf<char, std::char_tr public: TimedPrefixedStreamBuffer(const Timer& timer, const std::string& prefix, std::ostream& out = std::cout); - virtual int sync(); + int sync() override; private: TimedPrefixedStreamBuffer(const TimedPrefixedStreamBuffer&) = delete; @@ -181,7 +181,7 @@ public: , BaseType(&this->access()) {} - virtual ~LogStream() + ~LogStream() override { flush(); } @@ -240,7 +240,7 @@ class TimedPrefixedLogStream public: TimedPrefixedLogStream(const Timer& timer, const std::string& prefix, std::ostream& outstream); - virtual ~TimedPrefixedLogStream(); + ~TimedPrefixedLogStream() override; }; // TimedPrefixedLogStream //! ostream compatible class wrapping file and console output diff --git a/dune/xt/common/memory.hh b/dune/xt/common/memory.hh index 957a8c17c..e15ba8e43 100644 --- a/dune/xt/common/memory.hh +++ b/dune/xt/common/memory.hh @@ -56,12 +56,12 @@ public: : tt_(tt) {} - const T& access() const override final + const T& access() const final { return tt_; } - ConstAccessInterface<T>* copy() const override final + ConstAccessInterface<T>* copy() const final { return new ConstAccessByReference<T>(tt_); } @@ -90,12 +90,12 @@ public: : tt_(tt) {} - const T& access() const override final + const T& access() const final { return *tt_; } - ConstAccessInterface<T>* copy() const override final + ConstAccessInterface<T>* copy() const final { return new ConstAccessByPointer<T>(tt_); } @@ -112,12 +112,12 @@ public: : tt_(tt) {} - const T& access() const override final + const T& access() const final { return tt_; } - ConstAccessInterface<T>* copy() const override final + ConstAccessInterface<T>* copy() const final { return new ConstAccessByValue<T>(T(tt_)); } @@ -151,17 +151,17 @@ public: : tt_(tt) {} - T& access() override final + T& access() final { return tt_; } - const T& access() const override final + const T& access() const final { return tt_; } - AccessInterface<T>* copy() override final + AccessInterface<T>* copy() final { return new AccessByReference<T>(tt_); } @@ -190,17 +190,17 @@ public: : tt_(tt) {} - T& access() override final + T& access() final { return *tt_; } - const T& access() const override final + const T& access() const final { return *tt_; } - AccessInterface<T>* copy() override final + AccessInterface<T>* copy() final { return new AccessByPointer<T>(tt_); } @@ -217,17 +217,17 @@ public: : tt_(tt) {} - const T& access() const override final + const T& access() const final { return tt_; } - T& access() override final + T& access() final { return tt_; } - AccessInterface<T>* copy() const override final + AccessInterface<T>* copy() const final { return new AccessByValue<T>(T(tt_)); } diff --git a/dune/xt/functions/ESV2007.hh b/dune/xt/functions/ESV2007.hh index a8d828de4..62ef2c6b9 100644 --- a/dune/xt/functions/ESV2007.hh +++ b/dune/xt/functions/ESV2007.hh @@ -93,12 +93,12 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return order_; } @@ -106,7 +106,7 @@ public: /** * \brief "0.5 * pi * pi * cos(0.5 * pi * x[0]) * cos(0.5 * pi * x[1])" */ - RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const final { return (M_PI_2 * M_PI * cos(M_PI_2 * xx[0]) * cos(M_PI_2 * xx[1])); } @@ -115,7 +115,7 @@ public: * \brief ["-0.25 * pi * pi * pi * sin(0.5 * pi * x[0]) * cos(0.5 * pi * x[1])" * "-0.25 * pi * pi * pi * cos(0.5 * pi * x[0]) * sin(0.5 * pi * x[1])"] */ - DerivativeRangeReturnType jacobian(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const override final + DerivativeRangeReturnType jacobian(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const final { DerivativeRangeReturnType ret(0.); const DomainFieldType pre = -0.25 * M_PI * M_PI * M_PI; @@ -191,12 +191,12 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return order_; } @@ -204,7 +204,7 @@ public: /** * \brief "cos(0.5 * pi * x[0]) * cos(0.5 * pi * x[1])" */ - RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const final { return (cos(M_PI_2 * xx[0]) * cos(M_PI_2 * xx[1])); } @@ -213,7 +213,7 @@ public: * \brief ["-0.5 * pi * sin(0.5 * pi * x[0]) * cos(0.5 * pi * x[1])" * "-0.5 * pi * cos(0.5 * pi * x[0]) * sin(0.5 * pi * x[1])"] */ - DerivativeRangeReturnType jacobian(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const override final + DerivativeRangeReturnType jacobian(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const final { DerivativeRangeReturnType ret(0.); const DomainFieldType pre = -0.5 * M_PI; @@ -264,25 +264,24 @@ private: {} protected: - void post_bind(const ElementType& ele) override final + void post_bind(const ElementType& ele) final { post_bind_helper<ElementType, d>::post_bind(ele, value_, local_diffusion_, poincare_constant_); } public: - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return 0; } - RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const final { this->assert_inside_reference_element(xx); return value_; } - DerivativeRangeReturnType jacobian(const DomainType& xx, - const Common::Parameter& /*param*/ = {}) const override final + DerivativeRangeReturnType jacobian(const DomainType& xx, const Common::Parameter& /*param*/ = {}) const final { this->assert_inside_reference_element(xx); return DerivativeRangeReturnType(); @@ -382,12 +381,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalCutoffFunction>(*diffusion_, poincare_constant_); } diff --git a/dune/xt/functions/base/combined-element-functions.hh b/dune/xt/functions/base/combined-element-functions.hh index 876844541..f641a9b02 100644 --- a/dune/xt/functions/base/combined-element-functions.hh +++ b/dune/xt/functions/base/combined-element-functions.hh @@ -96,19 +96,19 @@ protected: } public: - int order(const XT::Common::Parameter& param = {}) const override final + int order(const XT::Common::Parameter& param = {}) const final { return Helper::order(left_.access(), right_.access(), param); } RangeReturnType evaluate(const DomainType& point_in_reference_element, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return Helper::evaluate(left_.access(), right_.access(), point_in_reference_element, param); } DerivativeRangeReturnType jacobian(const DomainType& point_in_reference_element, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return Helper::jacobian(left_.access(), right_.access(), point_in_reference_element, param); } @@ -181,7 +181,7 @@ public: CombinedElementFunction(ThisType&&) = default; protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { Storage::left.access().bind(element); Storage::right.access().bind(element); diff --git a/dune/xt/functions/base/combined-functions.hh b/dune/xt/functions/base/combined-functions.hh index d1b35c29f..468622d2c 100644 --- a/dune/xt/functions/base/combined-functions.hh +++ b/dune/xt/functions/base/combined-functions.hh @@ -125,24 +125,24 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - int order(const XT::Common::Parameter& param = {}) const override final + int order(const XT::Common::Parameter& param = {}) const final { return Helper::order(*left_, *right_, param); } RangeReturnType evaluate(const DomainType& point_in_global_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return Helper::evaluate(*left_, *right_, point_in_global_coordinates, param); } DerivativeRangeReturnType jacobian(const DomainType& point_in_global_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return Helper::jacobian(*left_, *right_, point_in_global_coordinates, param); } diff --git a/dune/xt/functions/base/combined-grid-functions.hh b/dune/xt/functions/base/combined-grid-functions.hh index f7cbef17f..e7f417fb9 100644 --- a/dune/xt/functions/base/combined-grid-functions.hh +++ b/dune/xt/functions/base/combined-grid-functions.hh @@ -126,7 +126,7 @@ public: CombinedGridFunction(ThisType&& source) = default; - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { LOG_(debug) << "local_function()" << std::endl; using LeftLF = typename LeftType::LocalFunctionType; @@ -148,7 +148,7 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } diff --git a/dune/xt/functions/base/composition.hh b/dune/xt/functions/base/composition.hh index c72086b95..b1977c142 100644 --- a/dune/xt/functions/base/composition.hh +++ b/dune/xt/functions/base/composition.hh @@ -69,12 +69,12 @@ struct GeneralElementFunctionChooser } public: - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return 2; } - RangeType evaluate(const DomainType& xx) const override final + RangeType evaluate(const DomainType& xx) const final { // evaluate inner function const auto inner_value = local_inner_function_->evaluate(xx); @@ -90,7 +90,7 @@ struct GeneralElementFunctionChooser return local_outer_function_->evaluate(outer_element.geometry().local(inner_value)); } - DerivativeRangeType jacobian(const DomainType& /*xx*/) const override final + DerivativeRangeType jacobian(const DomainType& /*xx*/) const final { DUNE_THROW(Dune::NotImplemented, ""); } @@ -140,18 +140,17 @@ struct ElementFunctionForGlobalChooser ElementFunction& operator=(const ElementFunction& /*other*/) = delete; - int order(const XT::Common::Parameter& param = {}) const override final + int order(const XT::Common::Parameter& param = {}) const final { return global_function_.order(param) * localizable_function_.local_function(element_)->order(param); } - RangeType evaluate(const DomainType& xx, const XT::Common::Parameter& param = {}) const override final + RangeType evaluate(const DomainType& xx, const XT::Common::Parameter& param = {}) const final { return global_function_.evaluate(localizable_function_.local_function(element_)->evaluate(xx, param), param); } - DerivativeRangeType jacobian(const DomainType& /*xx*/, - const XT::Common::Parameter& /*param*/ = {}) const override final + DerivativeRangeType jacobian(const DomainType& /*xx*/, const XT::Common::Parameter& /*param*/ = {}) const final { DUNE_THROW(Dune::NotImplemented, ""); } @@ -254,12 +253,12 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<ElementFunction>(inner_function_, outer_function_, element_search_); } diff --git a/dune/xt/functions/base/derivatives-of-element-functions.hh b/dune/xt/functions/base/derivatives-of-element-functions.hh index 6f3490fa5..32d2989ef 100644 --- a/dune/xt/functions/base/derivatives-of-element-functions.hh +++ b/dune/xt/functions/base/derivatives-of-element-functions.hh @@ -199,24 +199,24 @@ public: {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { if (do_post_bind_) func_.access().bind(element); } public: - int order(const XT::Common::Parameter& param = {}) const override final + int order(const XT::Common::Parameter& param = {}) const final { return Select::order(func_.access().order(param)); } - RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& param = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& param = {}) const final { return Select::evaluate(func_.access(), xx, param); } - DerivativeRangeReturnType jacobian(const DomainType& xx, const Common::Parameter& param = {}) const override final + DerivativeRangeReturnType jacobian(const DomainType& xx, const Common::Parameter& param = {}) const final { return Select::jacobian(func_.access(), xx, param); } diff --git a/dune/xt/functions/base/derivatives-of-grid-functions.hh b/dune/xt/functions/base/derivatives-of-grid-functions.hh index a43770435..7f79ec391 100644 --- a/dune/xt/functions/base/derivatives-of-grid-functions.hh +++ b/dune/xt/functions/base/derivatives-of-grid-functions.hh @@ -63,7 +63,7 @@ public: , name_(other.name_) {} - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<DerivativeElementFunction<typename GridFunctionType::LocalFunctionType, derivative>>( grid_function_->local_function()); @@ -82,7 +82,7 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } diff --git a/dune/xt/functions/base/function-as-flux-function.hh b/dune/xt/functions/base/function-as-flux-function.hh index ddbbe4c09..f964e74a8 100644 --- a/dune/xt/functions/base/function-as-flux-function.hh +++ b/dune/xt/functions/base/function-as-flux-function.hh @@ -42,7 +42,7 @@ public: : function_storage_(std::move(function_ptr)) {} - bool x_dependent() const override final + bool x_dependent() const final { return false; } @@ -52,7 +52,7 @@ public: * \{ **/ - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalFunction>(function_storage_.access()); } @@ -63,7 +63,7 @@ public: * \{ **/ - std::string name() const override final + std::string name() const final { return function_storage_.access().name(); } @@ -89,7 +89,7 @@ private: {} - int order(const Common::Parameter& param = {}) const override final + int order(const Common::Parameter& param = {}) const final { return function_.order(param); } @@ -98,7 +98,7 @@ private: RangeReturnType evaluate(const DomainType& /*point_in_reference_element*/, const StateType& u, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return function_.evaluate(u, param); } @@ -107,7 +107,7 @@ private: JacobianRangeReturnType jacobian(const DomainType& /*point_in_reference_element*/, const StateType& u, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return function_.jacobian(u, param); } diff --git a/dune/xt/functions/base/function-as-grid-function.hh b/dune/xt/functions/base/function-as-grid-function.hh index e66521325..ef058f1bb 100644 --- a/dune/xt/functions/base/function-as-grid-function.hh +++ b/dune/xt/functions/base/function-as-grid-function.hh @@ -70,12 +70,12 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalFunction>(*function_); } - std::string name() const override final + std::string name() const final { return function_->name(); } @@ -98,13 +98,13 @@ private: {} protected: - void post_bind(const ElementType& el) override final + void post_bind(const ElementType& el) final { geometry_ = std::make_unique<GeometryType>(el.geometry()); } public: - int order(const Common::Parameter& param = {}) const override final + int order(const Common::Parameter& param = {}) const final { DUNE_THROW_IF(!(geometry_), Exceptions::not_bound_to_an_element_yet, function_->name()); return function_->order(param); @@ -113,7 +113,7 @@ private: using BaseType::evaluate; RangeReturnType evaluate(const DomainType& point_in_reference_element, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { DUNE_THROW_IF(!(geometry_), Exceptions::not_bound_to_an_element_yet, function_->name()); this->assert_inside_reference_element(point_in_reference_element); @@ -123,7 +123,7 @@ private: using BaseType::jacobian; DerivativeRangeReturnType jacobian(const DomainType& point_in_reference_element, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { DUNE_THROW_IF(!(geometry_), Exceptions::not_bound_to_an_element_yet, function_->name()); this->assert_inside_reference_element(point_in_reference_element); @@ -134,7 +134,7 @@ private: DerivativeRangeReturnType derivative(const std::array<size_t, d>& alpha, const DomainType& point_in_reference_element, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { DUNE_THROW_IF(!(geometry_), Exceptions::not_bound_to_an_element_yet, function_->name()); this->assert_inside_reference_element(point_in_reference_element); diff --git a/dune/xt/functions/base/reinterpret.hh b/dune/xt/functions/base/reinterpret.hh index 813891964..b5e4778c3 100644 --- a/dune/xt/functions/base/reinterpret.hh +++ b/dune/xt/functions/base/reinterpret.hh @@ -79,7 +79,7 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<ReinterpretLocalfunction>(*source_, source_grid_view_); } @@ -159,7 +159,7 @@ private: * \note In some special situations (e.g., if the target element is not completely contained in one source * element), this may give inaccurate results. **/ - int order(const Common::Parameter& param = {}) const override final + int order(const Common::Parameter& param = {}) const final { if (source_element_which_contains_complete_target_element_ == nullptr && source_element_which_contains_some_point_of_target_element_ == nullptr) diff --git a/dune/xt/functions/base/sliced.hh b/dune/xt/functions/base/sliced.hh index 275f3f551..4980ff09e 100644 --- a/dune/xt/functions/base/sliced.hh +++ b/dune/xt/functions/base/sliced.hh @@ -71,18 +71,18 @@ class SlicedGridFunction<GF, r, 1> : public XT::Functions::GridFunctionInterface {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { local_function_->bind(element); } public: - int order(const XT::Common::Parameter& = {}) const override final + int order(const XT::Common::Parameter& = {}) const final { return local_function_->order(); } - RangeReturnType evaluate(const DomainType& xx, const XT::Common::Parameter& param = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const XT::Common::Parameter& param = {}) const final { RangeReturnType ret; const auto value = local_function_->evaluate(xx, param); @@ -92,7 +92,7 @@ class SlicedGridFunction<GF, r, 1> : public XT::Functions::GridFunctionInterface } DerivativeRangeReturnType jacobian(const DomainType& /*xx*/, - const XT::Common::Parameter& /*param*/ = {}) const override final + const XT::Common::Parameter& /*param*/ = {}) const final { DUNE_THROW(NotImplemented, "Yet!"); } @@ -142,12 +142,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_.empty() ? "sliced " + function_->name() : name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<SlicedLocalFunction>(*function_, dims_); } diff --git a/dune/xt/functions/base/transformed.hh b/dune/xt/functions/base/transformed.hh index 609caa302..b7c515d3b 100644 --- a/dune/xt/functions/base/transformed.hh +++ b/dune/xt/functions/base/transformed.hh @@ -78,24 +78,24 @@ class TransformedGridFunction : public XT::Functions::GridFunctionInterface<type {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { local_function_->bind(element); } public: - int order(const XT::Common::Parameter& param = {}) const override final + int order(const XT::Common::Parameter& param = {}) const final { return local_function_->order(param); } - RangeReturnType evaluate(const DomainType& xx, const XT::Common::Parameter& param = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const XT::Common::Parameter& param = {}) const final { return transformation_(local_function_->evaluate(xx, param)); } DerivativeRangeReturnType jacobian(const DomainType& /*xx*/, - const XT::Common::Parameter& /*param*/ = {}) const override final + const XT::Common::Parameter& /*param*/ = {}) const final { DUNE_THROW(NotImplemented, "TransformedLocalFunction does not provide jacobian evaluations (yet)!"); } @@ -142,12 +142,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<TransformedLocalFunction>(*function_, transformation_); } diff --git a/dune/xt/functions/base/visualization.hh b/dune/xt/functions/base/visualization.hh index 23c71d65f..8fff3459e 100644 --- a/dune/xt/functions/base/visualization.hh +++ b/dune/xt/functions/base/visualization.hh @@ -57,12 +57,12 @@ class DefaultVisualizer : public VisualizerInterface<r, rC, R> public: using typename BaseType::RangeType; - int ncomps() const override final + int ncomps() const final { return helper<>::ncomps(); } - double evaluate(const int& comp, const RangeType& val) const override final + double evaluate(const int& comp, const RangeType& val) const final { return helper<>::evaluate(comp, val); } @@ -115,12 +115,12 @@ class SumVisualizer : public VisualizerInterface<r, rC, R> public: using typename BaseType::RangeType; - int ncomps() const override final + int ncomps() const final { return 1; } - double evaluate(DXTC_DEBUG_ONLY const int& comp, const RangeType& val) const override final + double evaluate(DXTC_DEBUG_ONLY const int& comp, const RangeType& val) const final { assert(comp == 0); return Common::reduce(val.begin(), val.end(), 0.); @@ -141,12 +141,12 @@ public: : comp_(comp) {} - int ncomps() const override final + int ncomps() const final { return 1; } - double evaluate(const int& comp, const RangeType& val) const override final + double evaluate(const int& comp, const RangeType& val) const final { DUNE_THROW_IF(comp != 0, Dune::InvalidStateException, "This visualizer plots only a single component!"); return val[comp_]; @@ -171,12 +171,12 @@ public: , eval_(eval) {} - int ncomps() const override final + int ncomps() const final { return ncomps_; } - double evaluate(const int& comp, const RangeType& val) const override final + double evaluate(const int& comp, const RangeType& val) const final { return eval_(comp, val); } @@ -222,17 +222,17 @@ public: , param_(param) {} - int ncomps() const override final + int ncomps() const final { return visualizer_.access().ncomps(); } - std::string name() const override final + std::string name() const final { return name_; } - double evaluate(int comp, const EntityType& en, const DomainType& xx) const override final + double evaluate(int comp, const EntityType& en, const DomainType& xx) const final { local_function_->bind(en); const auto value = local_function_->evaluate(xx, param_); @@ -291,17 +291,17 @@ public: DUNE_THROW(Dune::NotImplemented, "Only implemented for scalar functions by now!"); } - int ncomps() const override final + int ncomps() const final { return visualizer_.access().ncomps(); } - std::string name() const override final + std::string name() const final { return name_; } - double evaluate(int comp, const EntityType& en, const DomainType& xx) const override final + double evaluate(int comp, const EntityType& en, const DomainType& xx) const final { local_function_->bind(en); const auto value = local_function_->jacobian(xx, param_); diff --git a/dune/xt/functions/checkerboard.hh b/dune/xt/functions/checkerboard.hh index 0cea7be36..56b5e53a3 100644 --- a/dune/xt/functions/checkerboard.hh +++ b/dune/xt/functions/checkerboard.hh @@ -56,7 +56,7 @@ class CheckerboardFunction : public GridFunctionInterface<E, r, rC, R> {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { current_value_ = 0; if (is_in_checkerboard(element)) { @@ -66,20 +66,20 @@ class CheckerboardFunction : public GridFunctionInterface<E, r, rC, R> } public: - int order(const Common::Parameter& /*param*/ = {}) const override final + int order(const Common::Parameter& /*param*/ = {}) const final { return 0; } RangeReturnType evaluate(const DomainType& point_in_reference_element, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { this->assert_inside_reference_element(point_in_reference_element); return current_value_; } DerivativeRangeReturnType jacobian(const DomainType& point_in_reference_element, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { this->assert_inside_reference_element(point_in_reference_element); return DerivativeRangeReturnType(); @@ -209,7 +209,7 @@ public: return name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalCheckerboardFunction>(lower_left_, upper_right_, num_elements_, values_); } diff --git a/dune/xt/functions/constant.hh b/dune/xt/functions/constant.hh index 044d731e8..f2367631b 100644 --- a/dune/xt/functions/constant.hh +++ b/dune/xt/functions/constant.hh @@ -76,24 +76,24 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return 0; } RangeReturnType evaluate(const DomainType& /*point_in_global_coordinates*/, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { return value_; } DerivativeRangeReturnType jacobian(const DomainType& /*point_in_global_coordinates*/, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { return DerivativeRangeReturnType(); // defaults to 0 } - std::string name() const override final + std::string name() const final { return name_; } @@ -152,17 +152,17 @@ public: return "dune.xt.functions.constantfluxfunction"; } - bool x_dependent() const override final + bool x_dependent() const final { return false; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return constant_flux_function_.local_function(); } - std::string name() const override final + std::string name() const final { return constant_function_.name(); } diff --git a/dune/xt/functions/elementwise-diameter.hh b/dune/xt/functions/elementwise-diameter.hh index e9ab1b7d6..f2d92b34e 100644 --- a/dune/xt/functions/elementwise-diameter.hh +++ b/dune/xt/functions/elementwise-diameter.hh @@ -38,24 +38,24 @@ class ElementwiseDiameterFunction : public GridFunctionInterface<E> {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { diameter_ = Grid::diameter(element); } public: - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return 0; } - RangeReturnType evaluate(const DomainType& /*xx*/, const XT::Common::Parameter& /*param*/ = {}) const override final + RangeReturnType evaluate(const DomainType& /*xx*/, const XT::Common::Parameter& /*param*/ = {}) const final { return diameter_; } DerivativeRangeReturnType jacobian(const DomainType& /*xx*/, - const XT::Common::Parameter& /*param*/ = {}) const override final + const XT::Common::Parameter& /*param*/ = {}) const final { return DerivativeRangeReturnType(); } @@ -91,12 +91,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalFunction>(); } - std::string name() const override final + std::string name() const final { return name_; } diff --git a/dune/xt/functions/elementwise-minimum.hh b/dune/xt/functions/elementwise-minimum.hh index 8ea386789..6e1af215a 100644 --- a/dune/xt/functions/elementwise-minimum.hh +++ b/dune/xt/functions/elementwise-minimum.hh @@ -123,7 +123,7 @@ private: {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { some_lf_->bind(element); min_ = internal::ElementwiseMinimumFunctionHelper<typename SomeFunction::LocalFunctionType>::compute( @@ -131,12 +131,12 @@ private: } public: - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return 0; } - RangeReturnType evaluate(const DomainType& /*xx*/, const XT::Common::Parameter& /*param*/ = {}) const override final + RangeReturnType evaluate(const DomainType& /*xx*/, const XT::Common::Parameter& /*param*/ = {}) const final { return min_; } @@ -183,12 +183,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalFunction>(*some_func_, search_quadrature_order_); } - std::string name() const override final + std::string name() const final { return name_; } diff --git a/dune/xt/functions/expression/default.hh b/dune/xt/functions/expression/default.hh index 9db75c7c0..379f35553 100644 --- a/dune/xt/functions/expression/default.hh +++ b/dune/xt/functions/expression/default.hh @@ -162,12 +162,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - int order(const Common::Parameter& /*param*/ = {}) const override final + int order(const Common::Parameter& /*param*/ = {}) const final { return static_cast<int>(order_); } @@ -175,7 +175,7 @@ public: using BaseType::evaluate; RangeReturnType evaluate(const DomainType& point_in_global_coordinates, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { RangeReturnType ret(0.); Common::FieldVector<RangeFieldType, r * rC> tmp_vector_; @@ -193,7 +193,7 @@ public: using BaseType::jacobian; DerivativeRangeReturnType jacobian(const DomainType& point_in_global_coordinates, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { if (gradients_.size() != r) DUNE_THROW(NotImplemented, "Do not call jacobian() if no gradients are given on construction!"); @@ -354,12 +354,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - int order(const Common::Parameter& /*param*/ = {}) const override final + int order(const Common::Parameter& /*param*/ = {}) const final { return static_cast<int>(order_); } @@ -367,7 +367,7 @@ public: using BaseType::evaluate; RangeReturnType evaluate(const DomainType& point_in_global_coordinates, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { RangeReturnType ret(0.); function_.evaluate(point_in_global_coordinates, ret); @@ -378,7 +378,7 @@ public: using BaseType::jacobian; DerivativeRangeReturnType jacobian(const DomainType& point_in_global_coordinates, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { if (gradients_.size() != r) DUNE_THROW(NotImplemented, "Do not call jacobian() if no gradients are given on construction!"); diff --git a/dune/xt/functions/expression/parametric.hh b/dune/xt/functions/expression/parametric.hh index 9d94b6852..4a7679066 100644 --- a/dune/xt/functions/expression/parametric.hh +++ b/dune/xt/functions/expression/parametric.hh @@ -112,18 +112,18 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - int order(const Common::Parameter& /*param*/ = {}) const override final + int order(const Common::Parameter& /*param*/ = {}) const final { return static_cast<int>(order_); } RangeReturnType evaluate(const DomainType& point_in_global_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { RangeReturnType ret(0.); Common::Parameter parsed_param; @@ -181,7 +181,7 @@ public: } // ... evaluate(...) DerivativeRangeReturnType jacobian(const DomainType& /*point_in_global_coordinates*/, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { DUNE_THROW(NotImplemented, "Not yet, at least..."); } diff --git a/dune/xt/functions/flattop.hh b/dune/xt/functions/flattop.hh index a60766d91..b1f873c75 100644 --- a/dune/xt/functions/flattop.hh +++ b/dune/xt/functions/flattop.hh @@ -98,7 +98,7 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } @@ -109,7 +109,7 @@ public: } RangeReturnType evaluate(const DomainType& point_in_reference_element, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { RangeReturnType ret = value_; for (size_t dd = 0; dd < domain_dim; ++dd) { diff --git a/dune/xt/functions/generic/flux-function.hh b/dune/xt/functions/generic/flux-function.hh index 9209269aa..9203a293b 100644 --- a/dune/xt/functions/generic/flux-function.hh +++ b/dune/xt/functions/generic/flux-function.hh @@ -100,13 +100,13 @@ private: {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { post_bind_(element); } public: - int order(const XT::Common::Parameter& param = {}) const override final + int order(const XT::Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); return order_(parsed_param); @@ -114,7 +114,7 @@ private: RangeReturnType evaluate(const DomainType& point_in_local_coordinates, const StateType& u, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); return evaluate_(point_in_local_coordinates, u, parsed_param); @@ -122,7 +122,7 @@ private: JacobianRangeReturnType jacobian(const DomainType& point_in_local_coordinates, const StateType& u, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); return jacobian_(point_in_local_coordinates, u, parsed_param); @@ -131,7 +131,7 @@ private: void evaluate(const DomainType& point_in_local_coordinates, const StateType& u, DynamicRangeType& ret, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); dynamic_evaluate_(point_in_local_coordinates, u, ret, parsed_param); @@ -140,14 +140,14 @@ private: void jacobian(const DomainType& point_in_local_coordinates, const StateType& u, DynamicJacobianRangeType& ret, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); return dynamic_jacobian_(point_in_local_coordinates, u, ret, parsed_param); } - const Common::ParameterType& parameter_type() const override final + const Common::ParameterType& parameter_type() const final { return param_type_; } @@ -249,17 +249,17 @@ public: , dynamic_jacobian_(jacobian_func) {} - const Common::ParameterType& parameter_type() const override final + const Common::ParameterType& parameter_type() const final { return param_type_; } - std::string name() const override final + std::string name() const final { return name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalGenericFluxFunction>( order_, post_bind_, evaluate_, dynamic_evaluate_, param_type_, jacobian_, dynamic_jacobian_); diff --git a/dune/xt/functions/generic/function.hh b/dune/xt/functions/generic/function.hh index 20537f9b8..95f28fc25 100644 --- a/dune/xt/functions/generic/function.hh +++ b/dune/xt/functions/generic/function.hh @@ -127,38 +127,38 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - int order(const Common::Parameter& param = {}) const override final + int order(const Common::Parameter& param = {}) const final { return order_(this->parse_parameter(param)); } RangeReturnType evaluate(const DomainType& point_in_global_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return evaluate_(point_in_global_coordinates, this->parse_parameter(param)); } void evaluate(const DomainType& point_in_global_coordinates, DynamicRangeType& ret, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { dynamic_evaluate_(point_in_global_coordinates, ret, this->parse_parameter(param)); } DerivativeRangeReturnType jacobian(const DomainType& point_in_global_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return jacobian_(point_in_global_coordinates, this->parse_parameter(param)); } DerivativeRangeReturnType derivative(const std::array<size_t, d>& alpha, const DomainType& point_in_global_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { return derivative_(alpha, point_in_global_coordinates, this->parse_parameter(param)); } - std::string name() const override final + std::string name() const final { return name_; } diff --git a/dune/xt/functions/generic/grid-function.hh b/dune/xt/functions/generic/grid-function.hh index d7b6c6797..d12f4abb6 100644 --- a/dune/xt/functions/generic/grid-function.hh +++ b/dune/xt/functions/generic/grid-function.hh @@ -98,27 +98,27 @@ private: {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { post_bind_(element); } public: - int order(const XT::Common::Parameter& param = {}) const override final + int order(const XT::Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); return order_(parsed_param); } RangeReturnType evaluate(const DomainType& point_in_local_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); return evaluate_(point_in_local_coordinates, parsed_param); } DerivativeRangeReturnType jacobian(const DomainType& point_in_local_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { auto parsed_param = this->parse_parameter(param); auto local_jacobian = jacobian_(point_in_local_coordinates, parsed_param); @@ -137,7 +137,7 @@ private: DerivativeRangeReturnType derivative(const std::array<size_t, d>& alpha, const DomainType& point_in_local_coordinates, - const Common::Parameter& param = {}) const override final + const Common::Parameter& param = {}) const final { DUNE_THROW(Dune::NotImplemented, "This function should also transform the derivatives (like the jacobian method), go ahead and " @@ -219,12 +219,12 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalGenericGridFunction>( order_, post_bind_, evaluate_, this->parameter_type(), jacobian_, derivative_); diff --git a/dune/xt/functions/grid-function.hh b/dune/xt/functions/grid-function.hh index 8e50196e2..34f09f6ac 100644 --- a/dune/xt/functions/grid-function.hh +++ b/dune/xt/functions/grid-function.hh @@ -248,12 +248,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return function_->local_function(); } - std::string name() const override final + std::string name() const final { return name_; } @@ -480,12 +480,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return function_->local_function(); } - std::string name() const override final + std::string name() const final { return name_; } @@ -681,13 +681,13 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { LOG_(info) << "GridFunction<1,1>::local_function()" << std::endl; return function_->local_function(); } - std::string name() const override final + std::string name() const final { return name_; } diff --git a/dune/xt/functions/indicator.hh b/dune/xt/functions/indicator.hh index 5b054d097..825d82246 100644 --- a/dune/xt/functions/indicator.hh +++ b/dune/xt/functions/indicator.hh @@ -49,7 +49,7 @@ class IndicatorGridFunction : public GridFunctionInterface<E, r, rC, R> {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { current_value_ = 0.; const auto center = element.geometry().center(); @@ -62,20 +62,20 @@ class IndicatorGridFunction : public GridFunctionInterface<E, r, rC, R> } // ... post_bind(...) public: - int order(const Common::Parameter& /*param*/ = {}) const override final + int order(const Common::Parameter& /*param*/ = {}) const final { return 0; } RangeReturnType evaluate(const DomainType& point_in_reference_element, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { this->assert_inside_reference_element(point_in_reference_element); return current_value_; } DerivativeRangeReturnType jacobian(const DomainType& point_in_reference_element, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { this->assert_inside_reference_element(point_in_reference_element); return DerivativeRangeReturnType(); @@ -163,12 +163,12 @@ public: return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::string name() const override final + std::string name() const final { return name_; } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { return std::make_unique<LocalIndicatorGridFunction>(subdomain_and_value_tuples_); } @@ -239,7 +239,7 @@ public: return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return 0; } @@ -261,7 +261,7 @@ public: return config; } // ... defaults(...) - std::string name() const override final + std::string name() const final { return name_; } @@ -269,7 +269,7 @@ public: using BaseType::evaluate; RangeReturnType evaluate(const DomainType& point_in_global_coordinates, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { RangeReturnType value(0.); for (const auto& subdomain_and_value_tuple : *subdomain_and_value_tuples_) { @@ -285,7 +285,7 @@ public: using BaseType::jacobian; DerivativeRangeReturnType jacobian(const DomainType& /*point_in_global_coordinates*/, - const Common::Parameter& /*param*/ = {}) const override final + const Common::Parameter& /*param*/ = {}) const final { return DerivativeRangeReturnType(); // <- defaults to 0 } diff --git a/dune/xt/functions/interfaces/element-flux-functions.hh b/dune/xt/functions/interfaces/element-flux-functions.hh index c75412bb1..c866981bd 100644 --- a/dune/xt/functions/interfaces/element-flux-functions.hh +++ b/dune/xt/functions/interfaces/element-flux-functions.hh @@ -108,7 +108,7 @@ public: ElementFluxFunctionSetInterface(ThisType&& source) = default; - virtual ~ElementFluxFunctionSetInterface() = default; + ~ElementFluxFunctionSetInterface() override = default; /** * \name ´´These methods have to be implemented.'' diff --git a/dune/xt/functions/interfaces/element-functions.hh b/dune/xt/functions/interfaces/element-functions.hh index cffd9651b..1be5dc9fa 100644 --- a/dune/xt/functions/interfaces/element-functions.hh +++ b/dune/xt/functions/interfaces/element-functions.hh @@ -495,7 +495,7 @@ public: ElementFunctionInterface(const ThisType& other) = default; ElementFunctionInterface(ThisType&& source) = default; - virtual ~ElementFunctionInterface() = default; + ~ElementFunctionInterface() override = default; ThisType& operator=(const ThisType& other) = default; ThisType& operator=(ThisType&& source) = default; diff --git a/dune/xt/functions/interfaces/flux-function.hh b/dune/xt/functions/interfaces/flux-function.hh index 5e44f3aa2..258782248 100644 --- a/dune/xt/functions/interfaces/flux-function.hh +++ b/dune/xt/functions/interfaces/flux-function.hh @@ -76,7 +76,7 @@ public: : Common::ParametricInterface(param_type) {} - virtual ~FluxFunctionInterface() = default; + ~FluxFunctionInterface() override = default; virtual bool x_dependent() const { diff --git a/dune/xt/functions/interfaces/function.hh b/dune/xt/functions/interfaces/function.hh index 00a9b5b90..ade23db2d 100644 --- a/dune/xt/functions/interfaces/function.hh +++ b/dune/xt/functions/interfaces/function.hh @@ -140,7 +140,7 @@ public: FunctionInterface(ThisType&) = default; - virtual ~FunctionInterface() = default; + ~FunctionInterface() override = default; ThisType& operator=(const ThisType&) = delete; diff --git a/dune/xt/functions/interfaces/grid-function.hh b/dune/xt/functions/interfaces/grid-function.hh index 154958e4e..f9296c762 100644 --- a/dune/xt/functions/interfaces/grid-function.hh +++ b/dune/xt/functions/interfaces/grid-function.hh @@ -119,7 +119,7 @@ public: GridFunctionInterface(ThisType&) = default; - virtual ~GridFunctionInterface() = default; + ~GridFunctionInterface() override = default; ThisType& operator=(const ThisType&) = delete; diff --git a/dune/xt/functions/inverse.hh b/dune/xt/functions/inverse.hh index f1920f387..2d7747066 100644 --- a/dune/xt/functions/inverse.hh +++ b/dune/xt/functions/inverse.hh @@ -109,18 +109,18 @@ public: {} protected: - void post_bind(const ElementType& element) override final + void post_bind(const ElementType& element) final { func_.access().bind(element); } public: - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return order_; } - RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& param = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& param = {}) const final { return Helper::compute(func_.access().evaluate(xx, param)); } @@ -183,12 +183,12 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_function_impl()); } - int order(const XT::Common::Parameter& /*param*/ = {}) const override final + int order(const XT::Common::Parameter& /*param*/ = {}) const final { return order_; } - RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& param = {}) const override final + RangeReturnType evaluate(const DomainType& xx, const Common::Parameter& param = {}) const final { return Helper::compute(func_.evaluate(xx, param)); } @@ -257,13 +257,13 @@ public: { return std::unique_ptr<ThisType>(this->copy_as_grid_function_impl()); } - std::unique_ptr<LocalFunctionType> local_function() const override final + std::unique_ptr<LocalFunctionType> local_function() const final { using LocalFunction = InverseElementFunction<typename GridFunctionType::LocalFunctionType>; return std::make_unique<LocalFunction>(func_->local_function(), order_); } - std::string name() const override final + std::string name() const final { return name_; } diff --git a/dune/xt/grid/boundaryinfo/alldirichlet.hh b/dune/xt/grid/boundaryinfo/alldirichlet.hh index 7dc0c7778..3313cfc57 100644 --- a/dune/xt/grid/boundaryinfo/alldirichlet.hh +++ b/dune/xt/grid/boundaryinfo/alldirichlet.hh @@ -46,7 +46,7 @@ public: return alldirichlet_boundaryinfo_default_config().template get<std::string>("type"); } - const BoundaryType& type(const IntersectionType& intersection) const override final + const BoundaryType& type(const IntersectionType& intersection) const final { if (intersection.boundary() && !intersection.neighbor()) return dirichlet_boundary; @@ -84,7 +84,7 @@ public: return "xt.grid.boundaryinfo.process"; } - const BoundaryType& type(const IntersectionType& intersection) const override final + const BoundaryType& type(const IntersectionType& intersection) const final { if (!intersection.neighbor() && !intersection.boundary()) return dirichlet_boundary; diff --git a/dune/xt/grid/boundaryinfo/allneumann.hh b/dune/xt/grid/boundaryinfo/allneumann.hh index 390315765..4c1a58619 100644 --- a/dune/xt/grid/boundaryinfo/allneumann.hh +++ b/dune/xt/grid/boundaryinfo/allneumann.hh @@ -46,7 +46,7 @@ public: return allneumann_boundaryinfo_default_config().template get<std::string>("type"); } - const BoundaryType& type(const IntersectionType& intersection) const override final + const BoundaryType& type(const IntersectionType& intersection) const final { if (intersection.boundary()) return neumann_boundary; diff --git a/dune/xt/grid/boundaryinfo/allreflecting.hh b/dune/xt/grid/boundaryinfo/allreflecting.hh index 0828689ea..9acaaab8e 100644 --- a/dune/xt/grid/boundaryinfo/allreflecting.hh +++ b/dune/xt/grid/boundaryinfo/allreflecting.hh @@ -46,7 +46,7 @@ public: return allreflecting_boundaryinfo_default_config().template get<std::string>("type"); } - const BoundaryType& type(const IntersectionType& intersection) const override final + const BoundaryType& type(const IntersectionType& intersection) const final { if (intersection.boundary()) return reflecting_boundary; diff --git a/dune/xt/grid/boundaryinfo/boundarysegment.hh b/dune/xt/grid/boundaryinfo/boundarysegment.hh index 62b30bb19..6df3401fa 100644 --- a/dune/xt/grid/boundaryinfo/boundarysegment.hh +++ b/dune/xt/grid/boundaryinfo/boundarysegment.hh @@ -86,7 +86,7 @@ public: , id_map_(id_map) {} - const BoundaryType& type(const IntersectionType& intersection) const override final + const BoundaryType& type(const IntersectionType& intersection) const final { if (!intersection.boundary() || intersection.neighbor()) return no_boundary; diff --git a/dune/xt/grid/boundaryinfo/functionbased.hh b/dune/xt/grid/boundaryinfo/functionbased.hh index de872ddfc..30f73d55f 100644 --- a/dune/xt/grid/boundaryinfo/functionbased.hh +++ b/dune/xt/grid/boundaryinfo/functionbased.hh @@ -65,7 +65,7 @@ public: FunctionBasedBoundaryInfo(ThisType&& source) = default; - void repr(std::ostream& out) const override final + void repr(std::ostream& out) const final { out << "FunctionBasedBoundaryInfo(tol=" << tol_ << ", default_boundary_type=" << *default_boundary_type_ << ")"; } @@ -79,7 +79,7 @@ public: {std::move(fct_ptr), std::move(bt_ptr), std::move(local_fct_ptr)}); } // ... register_new_function(...) - const BoundaryType& type(const IntersectionType& intersection) const override final + const BoundaryType& type(const IntersectionType& intersection) const final { LOG_(debug) << "type(intersection=" << print(intersection) << "):" << std::endl; if (!intersection.boundary()) { diff --git a/dune/xt/grid/boundaryinfo/normalbased.hh b/dune/xt/grid/boundaryinfo/normalbased.hh index 573a1577d..cca2deae5 100644 --- a/dune/xt/grid/boundaryinfo/normalbased.hh +++ b/dune/xt/grid/boundaryinfo/normalbased.hh @@ -173,7 +173,7 @@ public: NormalBasedBoundaryInfo(ThisType&& source) = default; - void repr(std::ostream& out) const override final + void repr(std::ostream& out) const final { out << "NormalBasedBoundaryInfo(tol=" << tol_ << ", default_boundary_type=" << *default_boundary_type_; if (normal_to_type_map_.size() > 0) @@ -205,7 +205,7 @@ public: normal_to_type_map_.emplace(normal, std::shared_ptr<BoundaryType>(boundary_type)); } // ... void register_new_normal(...) - const BoundaryType& type(const IntersectionType& intersection) const override final + const BoundaryType& type(const IntersectionType& intersection) const final { LOG_(debug) << "type(intersection=" << print(intersection) << "):" << std::endl; if (!intersection.boundary()) { diff --git a/dune/xt/grid/boundaryinfo/types.hh b/dune/xt/grid/boundaryinfo/types.hh index 1c78bca37..7fec3951d 100644 --- a/dune/xt/grid/boundaryinfo/types.hh +++ b/dune/xt/grid/boundaryinfo/types.hh @@ -28,12 +28,12 @@ namespace Dune::XT::Grid { class NoBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "no_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new NoBoundary(); } @@ -43,12 +43,12 @@ public: class UnknownBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "unknown_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new UnknownBoundary(); } @@ -58,12 +58,12 @@ public: class DirichletBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "dirichlet_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new DirichletBoundary(); } @@ -73,12 +73,12 @@ public: class NeumannBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "neumann_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new NeumannBoundary(); } @@ -88,12 +88,12 @@ public: class RobinBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "robin_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new RobinBoundary(); } @@ -103,12 +103,12 @@ public: class ReflectingBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "reflecting_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new ReflectingBoundary(); } @@ -118,12 +118,12 @@ public: class AbsorbingBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "absorbing_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new AbsorbingBoundary(); } @@ -133,12 +133,12 @@ public: class InflowBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "inflow_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new InflowBoundary(); } @@ -148,12 +148,12 @@ public: class OutflowBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "outflow_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new OutflowBoundary(); } @@ -163,12 +163,12 @@ public: class InflowOutflowBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "inflow_outflow_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new InflowOutflowBoundary(); } @@ -178,12 +178,12 @@ public: class ImpermeableBoundary : public BoundaryType { public: - std::string id() const override final + std::string id() const final { return "impermeable_boundary"; } - BoundaryType* copy() const override final + BoundaryType* copy() const final { return new ImpermeableBoundary(); } diff --git a/dune/xt/grid/filters/base.hh b/dune/xt/grid/filters/base.hh index c2a73a890..786004095 100644 --- a/dune/xt/grid/filters/base.hh +++ b/dune/xt/grid/filters/base.hh @@ -224,12 +224,12 @@ public: , combine_lambda_(std::move(combine_lambda)) {} - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new CombinedIntersectionFilter<GridViewType>(*left_, *right_, combine_lambda_); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { return combine_lambda_(left_->contains(grid_layer, intersection), right_->contains(grid_layer, intersection)); } @@ -274,12 +274,12 @@ public: , combine_lambda_(std::move(combine_lambda)) {} - ElementFilter<GridViewType>* copy() const override final + ElementFilter<GridViewType>* copy() const final { return new CombinedElementFilter<GridViewType>(*left_, *right_, combine_lambda_); } - bool contains(const GridViewType& grid_layer, const ElementType& element) const override final + bool contains(const GridViewType& grid_layer, const ElementType& element) const final { return combine_lambda_(left_->contains(grid_layer, element), right_->contains(grid_layer, element)); } @@ -308,12 +308,12 @@ public: : filter_(std::move(filter)) {} - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new NegatedIntersectionFilter<GridViewType>(*filter_); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { return !filter_->contains(grid_layer, intersection); } @@ -340,12 +340,12 @@ public: : filter_(std::move(filter)) {} - ElementFilter<GridViewType>* copy() const override final + ElementFilter<GridViewType>* copy() const final { return new NegatedElementFilter<GridViewType>(*filter_); } - bool contains(const GridViewType& grid_layer, const ElementType& element) const override final + bool contains(const GridViewType& grid_layer, const ElementType& element) const final { return !filter_->contains(grid_layer, element); } diff --git a/dune/xt/grid/filters/element.hh b/dune/xt/grid/filters/element.hh index 63b9c95ba..b19a13eb4 100644 --- a/dune/xt/grid/filters/element.hh +++ b/dune/xt/grid/filters/element.hh @@ -42,12 +42,12 @@ public: explicit AllElements() = default; - ElementFilter<GridViewType>* copy() const override final + ElementFilter<GridViewType>* copy() const final { return new AllElements<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const ElementType& /*element*/) const override final + bool contains(const GridViewType& /*grid_layer*/, const ElementType& /*element*/) const final { return true; } @@ -71,12 +71,12 @@ public: explicit NoElements() = default; - ElementFilter<GridViewType>* copy() const override final + ElementFilter<GridViewType>* copy() const final { return new NoElements<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const ElementType& /*element*/) const override final + bool contains(const GridViewType& /*grid_layer*/, const ElementType& /*element*/) const final { return false; } @@ -100,12 +100,12 @@ public: explicit BoundaryElements() = default; - ElementFilter<GridViewType>* copy() const override final + ElementFilter<GridViewType>* copy() const final { return new BoundaryElements<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const ElementType& element) const override final + bool contains(const GridViewType& /*grid_layer*/, const ElementType& element) const final { return element.hasBoundaryIntersections(); } @@ -132,12 +132,12 @@ public: : filter_(lambda) {} - ElementFilter<GridViewType>* copy() const override final + ElementFilter<GridViewType>* copy() const final { return new GenericFilteredElements<GridViewType>(filter_); } - bool contains(const GridViewType& grid_layer, const ElementType& element) const override final + bool contains(const GridViewType& grid_layer, const ElementType& element) const final { return filter_(grid_layer, element); } @@ -164,12 +164,12 @@ public: explicit PartitionSetElements() = default; - ElementFilter<GridViewType>* copy() const override final + ElementFilter<GridViewType>* copy() const final { return new PartitionSetElements<GridViewType, PartitionSetType>(); } - bool contains(const GridViewType& /*grid_layer*/, const ElementType& element) const override final + bool contains(const GridViewType& /*grid_layer*/, const ElementType& element) const final { return PartitionSetType::contains(element.partitionType()); } diff --git a/dune/xt/grid/filters/intersection.hh b/dune/xt/grid/filters/intersection.hh index 312ac4e15..817bd15e6 100644 --- a/dune/xt/grid/filters/intersection.hh +++ b/dune/xt/grid/filters/intersection.hh @@ -46,12 +46,12 @@ public: explicit AllIntersections() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new AllIntersections<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& /*intersection*/) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& /*intersection*/) const final { return true; } @@ -77,12 +77,12 @@ public: explicit AllIntersectionsOnce() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new AllIntersectionsOnce<GridViewType>(); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { if (!intersection.neighbor()) return true; @@ -112,12 +112,12 @@ public: explicit NoIntersections() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new NoIntersections<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& /*intersection*/) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& /*intersection*/) const final { return false; } @@ -147,12 +147,12 @@ public: explicit InnerIntersections() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new InnerIntersections<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const final { return intersection.neighbor() && !intersection.boundary(); } @@ -185,12 +185,12 @@ public: explicit InnerIntersectionsOnce() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new InnerIntersectionsOnce<GridViewType>(); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { if (intersection.neighbor() && !intersection.boundary()) { const auto inside_element = intersection.inside(); @@ -249,12 +249,12 @@ public: : outside_indices_to_ignore_(outside_indices_to_ignore) {} - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new InnerIntersectionsOnceMap<GridViewType>(outside_indices_to_ignore_); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { if (intersection.neighbor() && !intersection.boundary()) { const auto inside_element = intersection.inside(); @@ -293,12 +293,12 @@ public: explicit PartitionSetInnerIntersectionsOnce() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new PartitionSetInnerIntersectionsOnce<GridViewType, PartitionSetType>(); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { if (intersection.neighbor() && !intersection.boundary() && PartitionSetType::contains(intersection.inside().partitionType())) { @@ -330,12 +330,12 @@ public: explicit BoundaryIntersections() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new BoundaryIntersections<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const final { return intersection.boundary(); } @@ -359,12 +359,12 @@ public: explicit NonPeriodicBoundaryIntersections() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new NonPeriodicBoundaryIntersections<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const final { return intersection.boundary() && !intersection.neighbor(); } @@ -394,12 +394,12 @@ public: explicit PeriodicBoundaryIntersections() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new PeriodicBoundaryIntersections<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const final { return intersection.neighbor() && intersection.boundary(); } @@ -432,12 +432,12 @@ public: explicit PeriodicBoundaryIntersectionsOnce() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new PeriodicBoundaryIntersectionsOnce<GridViewType>(); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { if (intersection.neighbor() && intersection.boundary()) { const auto inside_element = intersection.inside(); @@ -476,12 +476,12 @@ public: : outside_indices_to_ignore_(outside_indices_to_ignore) {} - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new PeriodicBoundaryIntersectionsOnceMap<GridViewType>(outside_indices_to_ignore_); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { if (intersection.neighbor() && intersection.boundary()) { const auto inside_element = intersection.inside(); @@ -520,12 +520,12 @@ public: : filter_(func) {} - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new GenericFilteredIntersections<GridViewType>(filter_); } - bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const override final + bool contains(const GridViewType& grid_layer, const IntersectionType& intersection) const final { return filter_(grid_layer, intersection); } @@ -579,12 +579,12 @@ public: , boundary_type_(other.boundary_type_) {} - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new CustomBoundaryIntersections<GridViewType>(*this); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const final { LOG_(debug) << "contains(intersection=" << print(intersection) << "):\n boundary_info_.type(intersection) = " << boundary_info_.type(intersection) @@ -629,12 +629,12 @@ public: , boundary_type_(boundary_type) {} - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new CustomBoundaryAndProcessIntersections<GridViewType>(boundary_info_, boundary_type_); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const final { const bool process_boundary = !intersection.neighbor() && !intersection.boundary(); const bool physical_boundary = boundary_info_.type(intersection) == *boundary_type_; @@ -664,12 +664,12 @@ public: explicit ProcessIntersections() = default; - IntersectionFilter<GridViewType>* copy() const override final + IntersectionFilter<GridViewType>* copy() const final { return new ProcessIntersections<GridViewType>(); } - bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const override final + bool contains(const GridViewType& /*grid_layer*/, const IntersectionType& intersection) const final { return (!intersection.neighbor() && !intersection.boundary()); } diff --git a/dune/xt/grid/functors/boundary-detector.hh b/dune/xt/grid/functors/boundary-detector.hh index 38487ac04..0befc04eb 100644 --- a/dune/xt/grid/functors/boundary-detector.hh +++ b/dune/xt/grid/functors/boundary-detector.hh @@ -69,7 +69,7 @@ public: BoundaryDetectorFunctor(const BoundaryDetectorFunctor& other) = default; - void prepare() override final + void prepare() final { found_ = 0; } @@ -86,7 +86,7 @@ public: void apply_local(const IntersectionType& intersection, const ElementType& inside_element, - const ElementType& outside_element) override final + const ElementType& outside_element) final { LOG_(debug) << "apply_local(intersection=" << print(intersection) << "): calling compute_locally()" << std::endl; found_ += compute_locally(intersection, inside_element, outside_element); @@ -97,12 +97,12 @@ public: return found_; } - void finalize() override final + void finalize() final { Propagator::finalize_imp(); } - BaseType* copy() override final + BaseType* copy() final { return Propagator::copy_imp(); } diff --git a/dune/xt/grid/functors/bounding-box.hh b/dune/xt/grid/functors/bounding-box.hh index e1cea17fb..49c8a24ac 100644 --- a/dune/xt/grid/functors/bounding-box.hh +++ b/dune/xt/grid/functors/bounding-box.hh @@ -72,13 +72,13 @@ public: MinMaxCoordinateFunctor(const MinMaxCoordinateFunctor& other) = default; - void prepare() override final + void prepare() final { bounding_box_ = std::make_pair(VectorType(std::numeric_limits<D>::max()), VectorType(std::numeric_limits<D>::min())); } - void apply_local(const typename BaseType::ElementType& element) override final + void apply_local(const typename BaseType::ElementType& element) final { const auto& geo = element.geometry(); for (auto i : Common::value_range(geo.corners())) { @@ -95,12 +95,12 @@ public: return bounding_box_; } - void finalize() override final + void finalize() final { Propagator::finalize_imp(); } - BaseType* copy() override final + BaseType* copy() final { return Propagator::copy_imp(); } diff --git a/dune/xt/grid/functors/generic.hh b/dune/xt/grid/functors/generic.hh index 5e9684e89..e4ce0adb1 100644 --- a/dune/xt/grid/functors/generic.hh +++ b/dune/xt/grid/functors/generic.hh @@ -41,22 +41,22 @@ public: , finalize_func_(std::move(finalize_func)) {} - BaseType* copy() override final + BaseType* copy() final { return new GenericElementFunctor<GL>(*this); } - void prepare() override final + void prepare() final { prepare_func_(); } - void apply_local(const ElementType& element) override final + void apply_local(const ElementType& element) final { apply_func_(element); } - void finalize() override final + void finalize() final { finalize_func_(); } @@ -91,24 +91,24 @@ public: , finalize_func_(std::move(finalize_func)) {} - BaseType* copy() override final + BaseType* copy() final { return new GenericIntersectionFunctor(*this); } - void prepare() override final + void prepare() final { prepare_func_(); } void apply_local(const IntersectionType& intersection, const ElementType& inside_element, - const ElementType& outside_element) override final + const ElementType& outside_element) final { apply_func_(intersection, inside_element, outside_element); } - void finalize() override final + void finalize() final { finalize_func_(); } @@ -146,24 +146,24 @@ public: , finalize_func_(std::move(finalize_func)) {} - void prepare() override final + void prepare() final { prepare_func_(); } - void apply_local(const ElementType& element) override final + void apply_local(const ElementType& element) final { element_apply_func_(element); } void apply_local(const IntersectionType& intersection, const ElementType& inside_element, - const ElementType& outside_element) override final + const ElementType& outside_element) final { intersection_apply_func_(intersection, inside_element, outside_element); } - void finalize() override final + void finalize() final { finalize_func_(); } diff --git a/dune/xt/grid/functors/refinement.hh b/dune/xt/grid/functors/refinement.hh index e7863a015..fe8dcaaad 100644 --- a/dune/xt/grid/functors/refinement.hh +++ b/dune/xt/grid/functors/refinement.hh @@ -34,7 +34,7 @@ struct MaximumEntityVolumeRefineFunctor : public ElementFunctor<GridViewType> , grid_(grid) {} - void apply_local(const typename BaseType::ElementType& element) override final + void apply_local(const typename BaseType::ElementType& element) final { const double volume = element.geometry().volume(); if (volume > threshold_volume_) diff --git a/dune/xt/grid/output/entity_visualization.hh b/dune/xt/grid/output/entity_visualization.hh index 7db0ac68b..8a5365e3d 100644 --- a/dune/xt/grid/output/entity_visualization.hh +++ b/dune/xt/grid/output/entity_visualization.hh @@ -170,7 +170,7 @@ struct ElementVisualization << std::endl; } - double operator()(const Element&) const + double operator()(const Element&) const override { return -1; } @@ -196,7 +196,7 @@ struct ElementVisualization , boundaryInfo_(boundaryInfo) {} - double operator()(const Element& entity) const + double operator()(const Element& entity) const override { static constexpr DirichletBoundary dirichlet_type{}; static constexpr NeumannBoundary neumann_type{}; @@ -303,7 +303,7 @@ struct ElementVisualization , gridview_(view) {} - double operator()(const Element& entity) const + double operator()(const Element& entity) const override { return gridview_.indexSet().index(entity); } diff --git a/dune/xt/grid/print.hh b/dune/xt/grid/print.hh index f22eaf73a..e5d519586 100644 --- a/dune/xt/grid/print.hh +++ b/dune/xt/grid/print.hh @@ -33,7 +33,7 @@ public: : internal::DefaultPrinter<T, use_repr>(val, cfg) {} - void repr(std::ostream& out) const override final + void repr(std::ostream& out) const final { const auto& geometry = this->value.geometry(); const auto num_corners = geometry.corners(); @@ -43,7 +43,7 @@ public: out << ", normal=" << this->value.centerUnitOuterNormal() << "}"; } - void str(std::ostream& out) const override final + void str(std::ostream& out) const final { const auto& geometry = this->value.geometry(); const auto num_corners = geometry.corners(); @@ -69,7 +69,7 @@ public: : internal::DefaultPrinter<T, use_repr>(val, cfg) {} - void repr(std::ostream& out) const override final + void repr(std::ostream& out) const final { const auto& geometry = this->value.geometry(); const auto num_corners = geometry.corners(); @@ -82,7 +82,7 @@ public: out << "}"; } - void str(std::ostream& out) const override final + void str(std::ostream& out) const final { const auto& geometry = this->value.geometry(); const auto num_corners = geometry.corners(); diff --git a/dune/xt/grid/walker.hh b/dune/xt/grid/walker.hh index f56a8ec8d..3956300bc 100644 --- a/dune/xt/grid/walker.hh +++ b/dune/xt/grid/walker.hh @@ -250,7 +250,7 @@ public: Walker(ThisType&& source) = default; - virtual ~Walker() = default; + ~Walker() override = default; const GridViewType& grid_view() const { @@ -487,7 +487,7 @@ public: * \{ */ - virtual void prepare() override + void prepare() override { auto prep = [](auto& wrapper_list) { for (auto&& wrapper : wrapper_list) @@ -561,7 +561,7 @@ public: } // ... apply_local(...) // finalize all threads - virtual void finalize() override + void finalize() override { auto fin = [](auto& per_thread_value) { for (auto&& list : per_thread_value) { diff --git a/dune/xt/la/container/common/matrix/sparse.hh b/dune/xt/la/container/common/matrix/sparse.hh index 2dbdd85a3..23880e213 100644 --- a/dune/xt/la/container/common/matrix/sparse.hh +++ b/dune/xt/la/container/common/matrix/sparse.hh @@ -414,7 +414,7 @@ public: return true; } - size_t non_zeros() const override final + size_t non_zeros() const final { return entries_->size(); } @@ -933,7 +933,7 @@ public: return true; } - size_t non_zeros() const override final + size_t non_zeros() const final { return entries_->size(); } @@ -1342,7 +1342,7 @@ public: return sparse_ ? sparse_matrix_.valid() : dense_matrix_.valid(); } - size_t non_zeros() const override final + size_t non_zeros() const final { return sparse_ ? sparse_matrix_.non_zeros() : dense_matrix_.non_zeros(); } diff --git a/dune/xt/la/container/common/vector/dense.hh b/dune/xt/la/container/common/vector/dense.hh index a6b257d55..2fc05b8e9 100644 --- a/dune/xt/la/container/common/vector/dense.hh +++ b/dune/xt/la/container/common/vector/dense.hh @@ -480,7 +480,7 @@ public: /// \name These methods override default implementations from VectorInterface. /// \{ - ScalarType dot(const ThisType& other) const override final + ScalarType dot(const ThisType& other) const final { if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, @@ -488,22 +488,22 @@ public: return backend() * other.backend(); } // ... dot(...) - RealType l1_norm() const override final + RealType l1_norm() const final { return backend().l1_norm(); } - RealType l2_norm() const override final + RealType l2_norm() const final { return backend().l2_norm(); } - RealType sup_norm() const override final + RealType sup_norm() const final { return backend().sup_norm(); } - void iadd(const ThisType& other) override final + void iadd(const ThisType& other) final { if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, @@ -512,7 +512,7 @@ public: backend() += other.backend(); } // ... iadd(...) - void isub(const ThisType& other) override final + void isub(const ThisType& other) final { if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, diff --git a/dune/xt/la/container/common/vector/sparse.hh b/dune/xt/la/container/common/vector/sparse.hh index a8eb0e1e7..1d58c17fd 100644 --- a/dune/xt/la/container/common/vector/sparse.hh +++ b/dune/xt/la/container/common/vector/sparse.hh @@ -383,7 +383,7 @@ public: /// \name These methods override default implementations from VectorInterface. /// \{ - ScalarType dot(const ThisType& other) const override final + ScalarType dot(const ThisType& other) const final { assert(other.size() == size()); const auto& indices = *indices_; @@ -404,7 +404,7 @@ public: return ret; } // ... dot(...) - RealType l1_norm() const override final + RealType l1_norm() const final { using Dune::XT::Common::abs; return std::accumulate(entries_->begin(), @@ -413,7 +413,7 @@ public: [](const RealType& a, const ScalarType& b) { return a + abs(b); }); } - RealType l2_norm() const override final + RealType l2_norm() const final { using Dune::XT::Common::abs; return std::sqrt( @@ -422,7 +422,7 @@ public: })); } - RealType sup_norm() const override final + RealType sup_norm() const final { using Dune::XT::Common::abs; auto it = std::max_element( @@ -430,7 +430,7 @@ public: return entries_->size() > 0 ? abs(*it) : 0.; } - ThisType add(const ThisType& other) const override final + ThisType add(const ThisType& other) const final { ThisType ret = this->copy(); ret.entries_->reserve(ret.entries_->size() + other.entries_->size()); @@ -439,12 +439,12 @@ public: return ret; } // ... add(...) - void add(const ThisType& other, ThisType& result) const override final + void add(const ThisType& other, ThisType& result) const final { result.deep_copy(add(other)); } // ... add(...) - ThisType sub(const ThisType& other) const override final + ThisType sub(const ThisType& other) const final { ThisType ret = this->copy(); ret.entries_->reserve(ret.entries_->size() + other.entries_->size()); @@ -453,17 +453,17 @@ public: return ret; } // ... sub(...) - void sub(const ThisType& other, ThisType& result) const override final + void sub(const ThisType& other, ThisType& result) const final { result.deep_copy(sub(other)); } // ... add(...) - void iadd(const ThisType& other) override final + void iadd(const ThisType& other) final { axpy(ScalarType(1), other); } // ... iadd(...) - void isub(const ThisType& other) override final + void isub(const ThisType& other) final { axpy(ScalarType(-1), other); } // ... isub(...) diff --git a/dune/xt/la/container/eigen/base.hh b/dune/xt/la/container/eigen/base.hh index 20f4962f7..8964b3e8e 100644 --- a/dune/xt/la/container/eigen/base.hh +++ b/dune/xt/la/container/eigen/base.hh @@ -206,7 +206,7 @@ public: /// \name These methods override default implementations from VectorInterface. /// \{ - std::pair<size_t, RealType> amax() const override final + std::pair<size_t, RealType> amax() const final { auto result = std::make_pair(size_t(0), RealType(0)); size_t min_index = 0; @@ -232,22 +232,22 @@ public: return backend().transpose() * other.backend(); } // ... dot(...) - ScalarType dot(const VectorImpType& other) const override final + ScalarType dot(const VectorImpType& other) const final { return this->template dot<Traits>(other); } - RealType l1_norm() const override final + RealType l1_norm() const final { return backend().template lpNorm<1>(); } - RealType l2_norm() const override final + RealType l2_norm() const final { return backend().template lpNorm<2>(); } - RealType sup_norm() const override final + RealType sup_norm() const final { return backend().template lpNorm<::Eigen::Infinity>(); } @@ -262,7 +262,7 @@ public: backend() += other.backend(); } // ... iadd(...) - void iadd(const VectorImpType& other) override final + void iadd(const VectorImpType& other) final { return this->template iadd<Traits>(other); } @@ -277,7 +277,7 @@ public: backend() -= other.backend(); } // ... isub(...) - void isub(const VectorImpType& other) override final + void isub(const VectorImpType& other) final { this->template isub<Traits>(other); } diff --git a/dune/xt/la/container/eigen/dense.hh b/dune/xt/la/container/eigen/dense.hh index a3c9f76f2..4d93a45c3 100644 --- a/dune/xt/la/container/eigen/dense.hh +++ b/dune/xt/la/container/eigen/dense.hh @@ -690,21 +690,21 @@ public: using InterfaceType::operator-; - ThisType operator-(const ThisType& other) const override final + ThisType operator-(const ThisType& other) const final { return ThisType(this->backend() - other.backend()); } using InterfaceType::operator+; - ThisType operator+(const ThisType& other) const override final + ThisType operator+(const ThisType& other) const final { return ThisType(this->backend() + other.backend()); } using InterfaceType::operator*; - ThisType operator*(const ThisType& other) const override final + ThisType operator*(const ThisType& other) const final { return ThisType(this->backend() * other.backend()); } diff --git a/dune/xt/la/container/eigen/sparse.hh b/dune/xt/la/container/eigen/sparse.hh index bf1481186..d7d8ab0c2 100644 --- a/dune/xt/la/container/eigen/sparse.hh +++ b/dune/xt/la/container/eigen/sparse.hh @@ -421,7 +421,7 @@ public: return true; } - size_t non_zeros() const override final + size_t non_zeros() const final { return backend_->nonZeros(); } @@ -451,7 +451,7 @@ public: return ret; } // ... pattern(...) - ThisType pruned(const ScalarType eps = Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const override final + ThisType pruned(const ScalarType eps = Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const final { return ThisType(*backend_, true, eps); } diff --git a/dune/xt/la/container/istl.hh b/dune/xt/la/container/istl.hh index 89c6737a2..95d9411a1 100644 --- a/dune/xt/la/container/istl.hh +++ b/dune/xt/la/container/istl.hh @@ -302,7 +302,7 @@ public: /// \name These methods override default implementations from VectorInterface.. /// \{ - ScalarType dot(const ThisType& other) const override final + ScalarType dot(const ThisType& other) const final { if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, @@ -310,22 +310,22 @@ public: return backend().dot(other.backend()); } // ... dot(...) - RealType l1_norm() const override final + RealType l1_norm() const final { return backend().one_norm(); } - RealType l2_norm() const override final + RealType l2_norm() const final { return backend().two_norm(); } - RealType sup_norm() const override final + RealType sup_norm() const final { return backend().infinity_norm(); } - void iadd(const ThisType& other) override final + void iadd(const ThisType& other) final { if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, @@ -334,7 +334,7 @@ public: backend() += other.backend(); } // ... iadd(...) - void isub(const ThisType& other) override final + void isub(const ThisType& other) final { if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, @@ -673,14 +673,14 @@ public: * \attention Use and interprete with care, since the Dune::BCRSMatrix is known to report strange things here, * depending on its state! */ - size_t non_zeros() const override final + size_t non_zeros() const final { return backend_->nonzeroes(); } SparsityPatternDefault pattern(const bool prune = false, const typename Common::FloatCmp::DefaultEpsilon<ScalarType>::Type eps = - Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const override final + Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const final { SparsityPatternDefault ret(rows()); if (prune) { @@ -700,7 +700,7 @@ public: } // ... pattern(...) ThisType pruned(const typename Common::FloatCmp::DefaultEpsilon<ScalarType>::Type eps = - Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const override final + Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const final { return ThisType(*backend_, true, eps); } diff --git a/dune/xt/la/container/matrix-interface.hh b/dune/xt/la/container/matrix-interface.hh index 5bfc00c7b..89ee71bf4 100644 --- a/dune/xt/la/container/matrix-interface.hh +++ b/dune/xt/la/container/matrix-interface.hh @@ -80,7 +80,7 @@ public: static constexpr bool sparse = Traits::sparse; static_assert(std::is_same<ScalarImp, typename Traits::ScalarType>::value); - virtual ~MatrixInterface() = default; + ~MatrixInterface() override = default; /// \name Have to be implemented by a derived class in addition to the ones required by ContainerInterface! /// \{ diff --git a/dune/xt/la/container/matrix-view.hh b/dune/xt/la/container/matrix-view.hh index d8d564f16..619f84a9c 100644 --- a/dune/xt/la/container/matrix-view.hh +++ b/dune/xt/la/container/matrix-view.hh @@ -251,7 +251,7 @@ public: return true; } - RealType sup_norm() const override final + RealType sup_norm() const final { RealType ret = 0; for (size_t ii = 0; ii < rows(); ++ii) @@ -262,7 +262,7 @@ public: SparsityPatternDefault pattern(const bool prune = false, const typename Common::FloatCmp::DefaultEpsilon<ScalarType>::Type eps = - Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const override final + Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const final { SparsityPatternDefault ret(rows()); auto matrix_patt = matrix_.pattern(prune, eps); @@ -463,14 +463,14 @@ public: return const_matrix_view_.valid(); } - RealType sup_norm() const override final + RealType sup_norm() const final { return const_matrix_view_.sup_norm(); } // ... sup_norm(...) SparsityPatternDefault pattern(const bool prune = false, const typename Common::FloatCmp::DefaultEpsilon<ScalarType>::Type eps = - Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const override final + Common::FloatCmp::DefaultEpsilon<ScalarType>::value()) const final { return const_matrix_view_.pattern(prune, eps); } // ... pattern(...) diff --git a/dune/xt/la/container/vector-interface.hh b/dune/xt/la/container/vector-interface.hh index 3b0692350..3ba3f1531 100644 --- a/dune/xt/la/container/vector-interface.hh +++ b/dune/xt/la/container/vector-interface.hh @@ -82,7 +82,7 @@ public: friend iterator; static_assert(std::is_same<ScalarType, typename Traits::ScalarType>::value); - virtual ~VectorInterface() {} + ~VectorInterface() override {} template <class Vector> std::enable_if_t<Common::is_vector<Vector>::value, derived_type&> assign_from(const Vector& other) @@ -548,7 +548,7 @@ public: return this->as_imp(); } - virtual derived_type& operator/=(const ScalarType& scalar) + derived_type& operator/=(const ScalarType& scalar) override { for (auto& element : *this) element /= scalar; diff --git a/dune/xt/la/container/vector-view.hh b/dune/xt/la/container/vector-view.hh index 197e7047c..4908b44a9 100644 --- a/dune/xt/la/container/vector-view.hh +++ b/dune/xt/la/container/vector-view.hh @@ -175,28 +175,28 @@ public: return vector_[index(ii)]; } - ThisType add(const ThisType& other) const override final + ThisType add(const ThisType& other) const final { DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, "Methods returning a new VectorView are not implemented!"); return other; } // ... add(...) - ThisType sub(const ThisType& other) const override final + ThisType sub(const ThisType& other) const final { DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, "Methods returning a new VectorView are not implemented!"); return other; } // ... sub(...) - ThisType operator+(const ThisType& other) const override final + ThisType operator+(const ThisType& other) const final { DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, "Methods returning a new VectorView are not implemented!"); return other; } - ThisType operator-(const ThisType& other) const override final + ThisType operator-(const ThisType& other) const final { DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, "Methods returning a new VectorView are not implemented!"); diff --git a/dune/xt/la/eigen-solver/default.hh b/dune/xt/la/eigen-solver/default.hh index 016f608d2..9294b4379 100644 --- a/dune/xt/la/eigen-solver/default.hh +++ b/dune/xt/la/eigen-solver/default.hh @@ -87,7 +87,7 @@ public: {} protected: - void compute() const override final + void compute() const final { const auto type = options_->template get<std::string>("type"); const auto rows = M::rows(matrix_); diff --git a/dune/xt/la/eigen-solver/eigen.hh b/dune/xt/la/eigen-solver/eigen.hh index 093f21be5..be7b3cdb2 100644 --- a/dune/xt/la/eigen-solver/eigen.hh +++ b/dune/xt/la/eigen-solver/eigen.hh @@ -77,7 +77,7 @@ public: {} protected: - void compute() const override final + void compute() const final { const auto type = options_->template get<std::string>("type", EigenSolverOptions<EigenDenseMatrix<S>>::types()[0]); const size_t N = matrix_.rows(); diff --git a/dune/xt/la/eigen-solver/fmatrix.hh b/dune/xt/la/eigen-solver/fmatrix.hh index 2cf161f63..3c2d66c79 100644 --- a/dune/xt/la/eigen-solver/fmatrix.hh +++ b/dune/xt/la/eigen-solver/fmatrix.hh @@ -106,7 +106,7 @@ public: {} protected: - void compute() const override final + void compute() const final { const auto type = options_->template get<std::string>("type"); #if HAVE_LAPACKE || HAVE_MKL diff --git a/dune/xt/la/generalized-eigen-solver/default.hh b/dune/xt/la/generalized-eigen-solver/default.hh index 4a885a5c5..aeeb4c532 100644 --- a/dune/xt/la/generalized-eigen-solver/default.hh +++ b/dune/xt/la/generalized-eigen-solver/default.hh @@ -89,7 +89,7 @@ public: {} protected: - void compute() const override final + void compute() const final { const auto type = options_->template get<std::string>("type"); if (type == "lapack") { diff --git a/dune/xt/la/matrix-inverter/default.hh b/dune/xt/la/matrix-inverter/default.hh index 5fb5b8b4e..06b72de83 100644 --- a/dune/xt/la/matrix-inverter/default.hh +++ b/dune/xt/la/matrix-inverter/default.hh @@ -61,7 +61,7 @@ public: compute(); } - void compute() override final + void compute() final { using M = Common::MatrixAbstraction<MatrixType>; const auto type = options_.template get<std::string>("type"); diff --git a/dune/xt/la/matrix-inverter/eigen.hh b/dune/xt/la/matrix-inverter/eigen.hh index a4b37de5a..f10909931 100644 --- a/dune/xt/la/matrix-inverter/eigen.hh +++ b/dune/xt/la/matrix-inverter/eigen.hh @@ -68,7 +68,7 @@ public: compute(); } - void compute() override final + void compute() final { const auto type = options_.template get<std::string>("type"); const XT::Common::Configuration default_opts = MatrixInverterOptions<MatrixType>::options(type); diff --git a/dune/xt/la/matrix-inverter/fmatrix.hh b/dune/xt/la/matrix-inverter/fmatrix.hh index c9f3b101b..f102ce833 100644 --- a/dune/xt/la/matrix-inverter/fmatrix.hh +++ b/dune/xt/la/matrix-inverter/fmatrix.hh @@ -78,7 +78,7 @@ public: compute(); } - void compute() override final + void compute() final { const auto type = options_.template get<std::string>("type"); if (type == "direct") { diff --git a/dune/xt/la/solver/istl/preconditioners.hh b/dune/xt/la/solver/istl/preconditioners.hh index 19e985210..f73e96e86 100644 --- a/dune/xt/la/solver/istl/preconditioners.hh +++ b/dune/xt/la/solver/istl/preconditioners.hh @@ -39,19 +39,19 @@ public: {} //! Category of the preconditioner (see SolverCategory::Category) - SolverCategory::Category category() const override final + SolverCategory::Category category() const final { return category_; } - void pre(domain_type&, range_type&) override final {} + void pre(domain_type&, range_type&) final {} - void apply(domain_type& v, const range_type& d) override final + void apply(domain_type& v, const range_type& d) final { v = d; } - void post(domain_type&) override final {} + void post(domain_type&) final {} private: SolverCategory::Category category_; diff --git a/dune/xt/la/solver/istl/schurcomplement.hh b/dune/xt/la/solver/istl/schurcomplement.hh index 8a0f60d37..4746885f7 100644 --- a/dune/xt/la/solver/istl/schurcomplement.hh +++ b/dune/xt/la/solver/istl/schurcomplement.hh @@ -77,7 +77,7 @@ public: The input vector is consistent and the output must also be consistent on the interior+border partition. */ - void apply(const Vector& x, Vector& y) const override final + void apply(const Vector& x, Vector& y) const final { // we want to calculate y = (B2^T A^{-1} B1 - C) x // calculate B1 x @@ -101,7 +101,7 @@ public: y -= Cx; } - void applyscaleadd(Field alpha, const Vector& x, Vector& y) const override final + void applyscaleadd(Field alpha, const Vector& x, Vector& y) const final { auto Sx = n_vec_2_; apply(x, Sx); @@ -110,7 +110,7 @@ public: } //! Category of the linear operator (see SolverCategory::Category) - SolverCategory::Category category() const override final + SolverCategory::Category category() const final { return SolverCategory::Category::sequential; } diff --git a/dune/xt/test/common/configuration.cc b/dune/xt/test/common/configuration.cc index 009176723..2ccb80e82 100644 --- a/dune/xt/test/common/configuration.cc +++ b/dune/xt/test/common/configuration.cc @@ -206,7 +206,7 @@ struct ConfigTest : public testing::Test , keys(boost::assign::list_of<std::string>().repeat_fun(values.size() - 1, key_gen)) {} - virtual ~ConfigTest() {} + ~ConfigTest() override {} void get() { -- GitLab From 7118ecadec5449f8e823615820392749a709e744 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Thu, 2 Dec 2021 13:41:00 +0100 Subject: [PATCH 04/19] [python/coupling_grid_view] fix compilation error and warnings --- dune/xt/grid/boundaryinfo/functionbased.hh | 2 +- dune/xt/grid/view/coupling.hh | 7 ++++--- .../interfaces/element-function_for_all_grids.hh | 4 ++-- python/dune/xt/grid/dd_glued_gridprovider/cube.cc | 2 -- .../dune/xt/grid/dd_glued_gridprovider/provider.cc | 12 +++++++----- python/dune/xt/grid/element.cc | 8 ++++---- python/dune/xt/grid/functors/bounding-box.cc | 2 +- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/dune/xt/grid/boundaryinfo/functionbased.hh b/dune/xt/grid/boundaryinfo/functionbased.hh index 30f73d55f..cb61b45d1 100644 --- a/dune/xt/grid/boundaryinfo/functionbased.hh +++ b/dune/xt/grid/boundaryinfo/functionbased.hh @@ -110,8 +110,8 @@ public: } // ... type(...) private: - const std::unique_ptr<BoundaryType> default_boundary_type_; const double tol_; + const std::unique_ptr<BoundaryType> default_boundary_type_; std::list<std::tuple<std::unique_ptr<FunctionType>, std::unique_ptr<BoundaryType>, std::unique_ptr<typename FunctionType::LocalFunctionType>>> diff --git a/dune/xt/grid/view/coupling.hh b/dune/xt/grid/view/coupling.hh index b82af6e70..83960d13c 100644 --- a/dune/xt/grid/view/coupling.hh +++ b/dune/xt/grid/view/coupling.hh @@ -321,14 +321,15 @@ public: return index_pair.second; } } + DUNE_THROW(XT::Common::Exceptions::index_out_of_range, "Could not find matching inside index!"); } int size(int codim) const { if (codim == 0) - return inside_elements_->size(); + return XT::Common::numeric_cast<int>(inside_elements_->size()); if (codim == 1) - return coupling_size_; + return XT::Common::numeric_cast<int>(coupling_size_); DUNE_THROW(NotImplemented, ""); } @@ -383,7 +384,7 @@ private: const MacroIntersectionType macro_intersection_; const MacroGridViewType& macro_grid_view_; const LocalGridProviderType& local_inside_grid_; - int coupling_size_; + size_t coupling_size_; std::shared_ptr<std::vector<LocalElementType>> inside_elements_; std::shared_ptr<std::vector<int>> inside_elements_ids_; std::shared_ptr< diff --git a/python/dune/xt/functions/interfaces/element-function_for_all_grids.hh b/python/dune/xt/functions/interfaces/element-function_for_all_grids.hh index 3d7404eab..96ade27aa 100644 --- a/python/dune/xt/functions/interfaces/element-function_for_all_grids.hh +++ b/python/dune/xt/functions/interfaces/element-function_for_all_grids.hh @@ -135,7 +135,7 @@ struct ElementFunctionSetInterface_for_all_grids for_all_r_and_rC<Dune::XT::Common::tuple_tail_t<Dims>>::bind_interface(m); } - static void bind_combined(pybind11::module& m) + static void bind_combined(pybind11::module& /*m*/) { #if 0 for_all_rC<r>::bind_combined(m); @@ -160,7 +160,7 @@ struct ElementFunctionSetInterface_for_all_grids ElementFunctionSetInterface_for_all_grids<Dune::XT::Common::tuple_tail_t<GridTypes>>::bind_interface(m); } - static void bind_combined(pybind11::module& m) + static void bind_combined(pybind11::module& /*m*/) { #if 0 for_all_r_and_rC<>::bind_combined(m); diff --git a/python/dune/xt/grid/dd_glued_gridprovider/cube.cc b/python/dune/xt/grid/dd_glued_gridprovider/cube.cc index e5fb87281..e83e26611 100644 --- a/python/dune/xt/grid/dd_glued_gridprovider/cube.cc +++ b/python/dune/xt/grid/dd_glued_gridprovider/cube.cc @@ -30,8 +30,6 @@ struct make_cube_dd_grid { namespace py = pybind11; using namespace pybind11::literals; - using D = typename G::ctype; - static const size_t d = G::dimension; m.def( "make_cube_dd_grid", diff --git a/python/dune/xt/grid/dd_glued_gridprovider/provider.cc b/python/dune/xt/grid/dd_glued_gridprovider/provider.cc index c6df9910c..8d6e8213f 100644 --- a/python/dune/xt/grid/dd_glued_gridprovider/provider.cc +++ b/python/dune/xt/grid/dd_glued_gridprovider/provider.cc @@ -61,14 +61,14 @@ public: , macro_boundary_info_(macro_boundary_info) {} - const Dune::XT::Grid::BoundaryType& type(const IntersectionType& intersection) const override final + const Dune::XT::Grid::BoundaryType& type(const IntersectionType& intersection) const final { // find out if this micro intersection lies within the macro element or on a macro intersection for (auto&& macro_intersection : intersections(macro_grid_view_, macro_element_)) { - const size_t num_corners = intersection.geometry().corners(); - size_t num_corners_inside = 0; - size_t num_corners_outside = 0; - for (size_t cc = 0; cc < num_corners; ++cc) { + const int num_corners = intersection.geometry().corners(); + int num_corners_inside = 0; + int num_corners_outside = 0; + for (int cc = 0; cc < num_corners; ++cc) { const auto micro_corner = intersection.geometry().corner(cc); if (XT::Grid::contains(macro_intersection, micro_corner)) ++num_corners_inside; @@ -177,6 +177,7 @@ public: "ss = " << ss << "\n nn = " << nn); } } + DUNE_THROW(XT::Common::Exceptions::index_out_of_range, "Did not find correct inside macro element!"); }, "ss"_a, "nn"_a); @@ -193,6 +194,7 @@ public: self.macro_grid_view(), macro_element, macro_boundary_info); } } + DUNE_THROW(XT::Common::Exceptions::index_out_of_range, "Did not find correct macro element!"); }, "ss"_a, "macro_boundary_info"_a); diff --git a/python/dune/xt/grid/element.cc b/python/dune/xt/grid/element.cc index a2da0c18c..fc7c0307b 100644 --- a/python/dune/xt/grid/element.cc +++ b/python/dune/xt/grid/element.cc @@ -70,7 +70,7 @@ public: c.def_property_readonly("affine", [](type& self) { return self.geometry().affine(); }); c.def_property_readonly("volume", [](type& self) { return self.geometry().volume(); }); c.def_property_readonly("center", [](type& self) { - py::array_t<double> result(/*shape=*/{d}); + py::array_t<double> result(/*shape=*/d); auto access_to_result = result.mutable_unchecked<1>(); const auto center = self.geometry().center(); for (size_t ii = 0; ii < d; ++ii) @@ -123,7 +123,7 @@ public: for (size_t dd = 0; dd < d; ++dd) x_local_dune[dd] = access_to_x_local(dd); const auto x_global = self.geometry().global(x_local_dune); - result = py::array_t<double>(/*shape=*/{d}); + result = py::array_t<double>(/*shape=*/d); auto access_to_result = result.mutable_unchecked<1>(); for (size_t dd = 0; dd < d; ++dd) access_to_result(dd) = x_global[dd]; @@ -165,7 +165,7 @@ public: for (size_t dd = 0; dd < d; ++dd) x_global_dune[dd] = access_to_x_global(dd); const auto x_local = self.geometry().local(x_global_dune); - result = py::array_t<double>(/*shape=*/{d}); + result = py::array_t<double>(/*shape=*/d); auto access_to_result = result.mutable_unchecked<1>(); for (size_t dd = 0; dd < d; ++dd) access_to_result(dd) = x_local[dd]; @@ -206,7 +206,7 @@ public: XT::Common::FieldVector<double, d> x_local_dune; for (size_t dd = 0; dd < d; ++dd) x_local_dune[dd] = access_to_x_local(dd); - result = py::array_t<double>(/*shape=*/{1}); + result = py::array_t<double>(/*shape=*/1); auto access_to_result = result.mutable_unchecked<1>(); access_to_result(0) = self.geometry().integrationElement(x_local_dune); } else if (x_local.ndim() == 2) { diff --git a/python/dune/xt/grid/functors/bounding-box.cc b/python/dune/xt/grid/functors/bounding-box.cc index 69422b859..2c4356805 100644 --- a/python/dune/xt/grid/functors/bounding-box.cc +++ b/python/dune/xt/grid/functors/bounding-box.cc @@ -39,7 +39,7 @@ public: static bound_type bind(pybind11::module& m, const std::string& grid_id = grid_name<G>::value(), const std::string& layer_id = "", - const std::string& class_id = "bounding_box_functor", ) + const std::string& class_id = "bounding_box_functor") { namespace py = pybind11; using namespace pybind11::literals; -- GitLab From 1466b47b5089c85557b3c908398cde86e9b61ccf Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Thu, 2 Dec 2021 16:05:14 +0100 Subject: [PATCH 05/19] [clang-tidy] apply readability-else-after-return --- dune/xt/common/configuration.cc | 5 +- dune/xt/common/convergence-study.cc | 3 +- dune/xt/common/logstreams.cc | 2 +- dune/xt/common/parameter.cc | 4 +- dune/xt/common/string_internal.hh | 3 +- dune/xt/functions/checkerboard.hh | 3 +- dune/xt/functions/expression/mathexpr.cc | 6 +- dune/xt/functions/flattop.hh | 6 +- dune/xt/grid/boundaryinfo/boundarysegment.hh | 7 +- dune/xt/grid/boundaryinfo/factory.hh | 22 +- dune/xt/grid/boundaryinfo/normalbased.hh | 4 +- dune/xt/grid/boundaryinfo/types.hh | 27 +- dune/xt/grid/dd/glued.hh | 6 +- dune/xt/grid/element.hh | 4 +- dune/xt/grid/filters/intersection.hh | 32 +- dune/xt/grid/gridprovider/factory.hh | 15 +- dune/xt/grid/mapper.hh | 4 +- dune/xt/grid/output/entity_visualization.hh | 6 +- dune/xt/grid/search.hh | 16 +- dune/xt/la/container/common/vector/sparse.hh | 15 +- dune/xt/la/container/conversion.hh | 24 +- dune/xt/la/container/eigen/sparse.hh | 8 +- dune/xt/la/container/istl.hh | 19 +- dune/xt/la/container/matrix-market.hh | 307 ++++++++++-------- dune/xt/la/eigen-solver/internal/base.hh | 4 +- .../generalized-eigen-solver/internal/base.hh | 4 +- dune/xt/la/solver/istl.hh | 6 +- dune/xt/la/solver/istl/amg.hh | 7 +- dune/xt/la/solver/istl/saddlepoint.hh | 5 +- dune/xt/test/common/float_cmp.cc | 6 +- 30 files changed, 294 insertions(+), 286 deletions(-) diff --git a/dune/xt/common/configuration.cc b/dune/xt/common/configuration.cc index 093e519e1..7cf99ad65 100644 --- a/dune/xt/common/configuration.cc +++ b/dune/xt/common/configuration.cc @@ -338,10 +338,9 @@ std::string Configuration::find_common_prefix(const BaseType& subtree, const std if (previous_prefix.empty()) return find_common_prefix(subtree.sub(subkeys[0]), subkeys[0]); return find_common_prefix(subtree.sub(subkeys[0]), previous_prefix + "." + subkeys[0]); - } else { - // end of the recursion, return the previous prefix - return previous_prefix; } + // end of the recursion, return the previous prefix + return previous_prefix; } // ... find_common_prefix(...) void Configuration::report_flatly(const BaseType& subtree, const std::string& prefix, std::ostream& out) const diff --git a/dune/xt/common/convergence-study.cc b/dune/xt/common/convergence-study.cc index ed2d5d53b..a90766f29 100644 --- a/dune/xt/common/convergence-study.cc +++ b/dune/xt/common/convergence-study.cc @@ -65,8 +65,7 @@ std::string ConvergenceStudy::lfill(const std::string& id, const size_t len) con return id; if (id.size() > len) return id.substr(0, len - 1) + "."; - else /*if (id.size() < len_)*/ - return std::string(len - id.size(), ' ') + id; + return std::string(len - id.size(), ' ') + id; } std::string ConvergenceStudy::cfill(const std::string& id, const size_t len) const diff --git a/dune/xt/common/logstreams.cc b/dune/xt/common/logstreams.cc index cb50c3774..d8b9ccf49 100644 --- a/dune/xt/common/logstreams.cc +++ b/dune/xt/common/logstreams.cc @@ -126,7 +126,7 @@ std::string TimedPrefixedStreamBuffer::elapsed_time_str() const return (boost::format("%02dw %02dd %02d:%02d:%02d|") % weeks % days % hours % minutes % seconds).str(); if (elapsed > secs_per_day) // less than a week, more than a day return (boost::format("%02dd %02d:%02d:%02d|") % days % hours % minutes % seconds).str(); - else if (elapsed > secs_per_hour) // less than a day, more than one hour + if (elapsed > secs_per_hour) // less than a day, more than one hour return (boost::format("%02d:%02d:%02d|") % hours % minutes % seconds).str(); else // less than one hour return (boost::format("%02d:%02d|") % minutes % seconds).str(); diff --git a/dune/xt/common/parameter.cc b/dune/xt/common/parameter.cc index eaf08dec8..2d83596c6 100644 --- a/dune/xt/common/parameter.cc +++ b/dune/xt/common/parameter.cc @@ -88,10 +88,8 @@ bool ParameterType::operator==(const ParameterType& other) const return this_single_element.second == other_single_element.second; } return false; - - } else { - return this->dict_ == other.dict_; } + return this->dict_ == other.dict_; } // ... operator==(...) bool ParameterType::operator!=(const ParameterType& other) const diff --git a/dune/xt/common/string_internal.hh b/dune/xt/common/string_internal.hh index 6aff25a95..f944c3d1c 100644 --- a/dune/xt/common/string_internal.hh +++ b/dune/xt/common/string_internal.hh @@ -101,8 +101,7 @@ struct Helper<bool> return true; if (ss_lower_case == "false") return false; - else - return convert_safely<bool>(ss); + return convert_safely<bool>(ss); } }; // struct Helper< bool, ... > diff --git a/dune/xt/functions/checkerboard.hh b/dune/xt/functions/checkerboard.hh index 56b5e53a3..6a17428bb 100644 --- a/dune/xt/functions/checkerboard.hh +++ b/dune/xt/functions/checkerboard.hh @@ -91,8 +91,7 @@ class CheckerboardFunction : public GridFunctionInterface<E, r, rC, R> const auto center = element.geometry().center(); if (Common::FloatCmp::le(lower_left_, center) && Common::FloatCmp::lt(center, upper_right_)) return 1; - else - return 0; + return 0; } size_t find_subdomain(const ElementType& element) const diff --git a/dune/xt/functions/expression/mathexpr.cc b/dune/xt/functions/expression/mathexpr.cc index 15506eec6..d824d3366 100644 --- a/dune/xt/functions/expression/mathexpr.cc +++ b/dune/xt/functions/expression/mathexpr.cc @@ -1424,8 +1424,7 @@ int ROperation::NMembers() const // Number of members for an operation like a,b, return 1; if (mmb2 == NULL) return 0; - else - return 1 + mmb2->NMembers(); + return 1 + mmb2->NMembers(); } ROperation ROperation::NthMember(int n) const @@ -1444,8 +1443,7 @@ ROperation ROperation::NthMember(int n) const return *this; if (mmb1 != NULL) return *mmb1; - else - return ErrVal; + return ErrVal; }; if (op != Juxt) return ErrVal; diff --git a/dune/xt/functions/flattop.hh b/dune/xt/functions/flattop.hh index b1f873c75..1481f7fbd 100644 --- a/dune/xt/functions/flattop.hh +++ b/dune/xt/functions/flattop.hh @@ -166,8 +166,7 @@ private: return 0.0; if (point > 0.0) return 1.0; - else - return std::pow(1.0 + point, 2) * (1.0 - 2.0 * point); + return std::pow(1.0 + point, 2) * (1.0 - 2.0 * point); } // ... phi_left(...) RangeFieldType phi_right(const RangeFieldType& point) const @@ -176,8 +175,7 @@ private: return 1.0; if (point > 1.0) return 0.0; - else - return std::pow(1.0 - point, 2) * (1.0 + 2.0 * point); + return std::pow(1.0 - point, 2) * (1.0 + 2.0 * point); } // ... phi_right(...) const DomainType lower_left_; diff --git a/dune/xt/grid/boundaryinfo/boundarysegment.hh b/dune/xt/grid/boundaryinfo/boundarysegment.hh index 6df3401fa..df0d13ee4 100644 --- a/dune/xt/grid/boundaryinfo/boundarysegment.hh +++ b/dune/xt/grid/boundaryinfo/boundarysegment.hh @@ -97,12 +97,11 @@ public: id = element.first; if (id == "dirichlet") return dirichlet_boundary; - else if (id == "neumann") + if (id == "neumann") return neumann_boundary; - else if (id == "robin") + if (id == "robin") return robin_boundary; - else - return unknown_boundary; + return unknown_boundary; } // ... type(...) private: diff --git a/dune/xt/grid/boundaryinfo/factory.hh b/dune/xt/grid/boundaryinfo/factory.hh index f58cfc709..ded943df5 100644 --- a/dune/xt/grid/boundaryinfo/factory.hh +++ b/dune/xt/grid/boundaryinfo/factory.hh @@ -37,15 +37,14 @@ public: { if (type == AllDirichletBoundaryInfo<I>::static_id()) return alldirichlet_boundaryinfo_default_config(); - else if (type == AllNeumannBoundaryInfo<I>::static_id()) + if (type == AllNeumannBoundaryInfo<I>::static_id()) return allneumann_boundaryinfo_default_config(); - else if (type == BoundarySegmentIndexBasedBoundaryInfo<I>::static_id()) + if (type == BoundarySegmentIndexBasedBoundaryInfo<I>::static_id()) return boundarysegment_boundaryinfo_default_config(); - else if (type == NormalBasedBoundaryInfo<I>::static_id()) + if (type == NormalBasedBoundaryInfo<I>::static_id()) return normalbased_boundaryinfo_default_config<I::Entity::dimension>(); - else - DUNE_THROW(Common::Exceptions::wrong_input_given, - "'" << type << "' is not a valid " << BoundaryInfo<I>::static_id() << "!"); + DUNE_THROW(Common::Exceptions::wrong_input_given, + "'" << type << "' is not a valid " << BoundaryInfo<I>::static_id() << "!"); } // ... default_config(...) static std::unique_ptr<BoundaryInfo<I>> create(const Common::Configuration& config) @@ -53,15 +52,14 @@ public: const auto type = config.get<std::string>("type"); if (type == AllDirichletBoundaryInfo<I>::static_id()) return make_alldirichlet_boundaryinfo<I>(config); - else if (type == AllNeumannBoundaryInfo<I>::static_id()) + if (type == AllNeumannBoundaryInfo<I>::static_id()) return make_allneumann_boundaryinfo<I>(config); - else if (type == BoundarySegmentIndexBasedBoundaryInfo<I>::static_id()) + if (type == BoundarySegmentIndexBasedBoundaryInfo<I>::static_id()) return make_boundarysegment_boundaryinfo<I>(config); - else if (type == NormalBasedBoundaryInfo<I>::static_id()) + if (type == NormalBasedBoundaryInfo<I>::static_id()) return make_normalbased_boundaryinfo<I>(config); - else - DUNE_THROW(Common::Exceptions::wrong_input_given, - "'" << type << "' is not a valid " << BoundaryInfo<I>::static_id() << "!"); + DUNE_THROW(Common::Exceptions::wrong_input_given, + "'" << type << "' is not a valid " << BoundaryInfo<I>::static_id() << "!"); } // ... create(...) static std::unique_ptr<BoundaryInfo<I>> create(const std::string& type = available().at(0)) diff --git a/dune/xt/grid/boundaryinfo/normalbased.hh b/dune/xt/grid/boundaryinfo/normalbased.hh index cca2deae5..c5c6de17b 100644 --- a/dune/xt/grid/boundaryinfo/normalbased.hh +++ b/dune/xt/grid/boundaryinfo/normalbased.hh @@ -222,8 +222,8 @@ public: if (XT::Common::FloatCmp::eq(outer_normal, normal, tol_)) { LOG_(debug) << " registered normal " << normal << " matches, returning " << *type_ptr << std::endl; return *type_ptr; - } else - LOG_(debug) << " registered normal " << normal << " does not match" << std::endl; + } + LOG_(debug) << " registered normal " << normal << " does not match" << std::endl; } LOG_(debug) << " no registered normal matched, returning " << *default_boundary_type_ << std::endl; return *default_boundary_type_; diff --git a/dune/xt/grid/boundaryinfo/types.hh b/dune/xt/grid/boundaryinfo/types.hh index 7fec3951d..90a9cc532 100644 --- a/dune/xt/grid/boundaryinfo/types.hh +++ b/dune/xt/grid/boundaryinfo/types.hh @@ -199,30 +199,29 @@ static inline BoundaryType* make_boundary_type(const std::string& id) { if (id == NoBoundary().id()) return new NoBoundary(); - else if (id == UnknownBoundary().id()) + if (id == UnknownBoundary().id()) return new UnknownBoundary(); - else if (id == DirichletBoundary().id()) + if (id == DirichletBoundary().id()) return new DirichletBoundary(); - else if (id == NeumannBoundary().id()) + if (id == NeumannBoundary().id()) return new NeumannBoundary(); - else if (id == RobinBoundary().id()) + if (id == RobinBoundary().id()) return new RobinBoundary(); - else if (id == ReflectingBoundary().id()) + if (id == ReflectingBoundary().id()) return new ReflectingBoundary(); - else if (id == InflowBoundary().id()) + if (id == InflowBoundary().id()) return new InflowBoundary(); - else if (id == OutflowBoundary().id()) + if (id == OutflowBoundary().id()) return new OutflowBoundary(); - else if (id == InflowBoundary().id()) + if (id == InflowBoundary().id()) return new InflowBoundary(); - else if (id == InflowOutflowBoundary().id()) + if (id == InflowOutflowBoundary().id()) return new InflowOutflowBoundary(); - else if (id == ImpermeableBoundary().id()) + if (id == ImpermeableBoundary().id()) return new ImpermeableBoundary(); - else { - DUNE_THROW(Exceptions::boundary_type_error, "id: " << id); - return new UnknownBoundary(); - } + DUNE_THROW(Exceptions::boundary_type_error, "id: " << id); + return new UnknownBoundary(); + } // ... make_boundary_type(...) diff --git a/dune/xt/grid/dd/glued.hh b/dune/xt/grid/dd/glued.hh index 3a98dd7d5..1a428cda4 100644 --- a/dune/xt/grid/dd/glued.hh +++ b/dune/xt/grid/dd/glued.hh @@ -512,8 +512,7 @@ public: assert_macro_grid_state(); if (layer == Layers::leaf) return -1; - else - return local_grid(macro_entity).grid().maxLevel(); + return local_grid(macro_entity).grid().maxLevel(); } int max_local_level(const size_t macro_entity_index) const @@ -521,8 +520,7 @@ public: assert_macro_grid_state(); if (layer == Layers::leaf) return -1; - else - return local_grid(macro_entity_index).grid().maxLevel(); + return local_grid(macro_entity_index).grid().maxLevel(); } const std::vector<std::pair<MicroEntityType, std::vector<int>>>& diff --git a/dune/xt/grid/element.hh b/dune/xt/grid/element.hh index af41dff35..0bdb4c4ab 100644 --- a/dune/xt/grid/element.hh +++ b/dune/xt/grid/element.hh @@ -33,8 +33,8 @@ sub_entity_center(const Dune::Entity<0, dim, GridImp, EntityImp> element, const Common::Exceptions::index_out_of_range, "element.subEntities(" << codim << ") = " << element.subEntities(codim) << "\n i = " << i); return element.template subEntity<cd>(Common::numeric_cast<int>(i)).geometry().center(); - } else - return sub_entity_center<dim, GridImp, EntityImp, cd - 1>(element, codim, i); + } + return sub_entity_center<dim, GridImp, EntityImp, cd - 1>(element, codim, i); } } diff --git a/dune/xt/grid/filters/intersection.hh b/dune/xt/grid/filters/intersection.hh index 817bd15e6..9036f6d56 100644 --- a/dune/xt/grid/filters/intersection.hh +++ b/dune/xt/grid/filters/intersection.hh @@ -86,11 +86,9 @@ public: { if (!intersection.neighbor()) return true; - else { - const auto inside_element = intersection.inside(); - const auto outside_element = intersection.outside(); - return grid_layer.indexSet().index(inside_element) < grid_layer.indexSet().index(outside_element); - } + const auto inside_element = intersection.inside(); + const auto outside_element = intersection.outside(); + return grid_layer.indexSet().index(inside_element) < grid_layer.indexSet().index(outside_element); } }; // class AllIntersectionsOnce @@ -198,8 +196,8 @@ public: const auto inside_index = grid_layer.indexSet().index(inside_element); const auto outside_index = grid_layer.indexSet().index(outside_element); return inside_index < outside_index; - } else - return false; + } + return false; } }; // class InnerIntersectionsOnce @@ -263,10 +261,9 @@ public: const auto outside_index = grid_layer.indexSet().index(outside_element); if (outside_indices_to_ignore_.at(inside_index).count(outside_index)) return false; - else - return true; - } else - return false; + return true; + } + return false; } const std::map<size_t, std::set<size_t>>& outside_indices_to_ignore_; @@ -307,8 +304,8 @@ public: if (!PartitionSetType::contains(intersection.outside().partitionType())) return true; return grid_layer.indexSet().index(inside_element) < grid_layer.indexSet().index(outside_element); - } else - return false; + } + return false; } }; // class PartitionSetInnerIntersectionsOnce @@ -443,9 +440,8 @@ public: const auto inside_element = intersection.inside(); const auto outside_element = intersection.outside(); return grid_layer.indexSet().index(inside_element) < grid_layer.indexSet().index(outside_element); - } else { - return false; } + return false; } }; // class PeriodicBoundaryIntersectionsOnce @@ -490,11 +486,9 @@ public: const auto outside_index = grid_layer.indexSet().index(outside_element); if (outside_indices_to_ignore_.at(inside_index).count(outside_index)) return false; - else - return true; - } else { - return false; + return true; } + return false; } const std::map<size_t, std::set<size_t>>& outside_indices_to_ignore_; diff --git a/dune/xt/grid/gridprovider/factory.hh b/dune/xt/grid/gridprovider/factory.hh index 086c0e263..01f64f640 100644 --- a/dune/xt/grid/gridprovider/factory.hh +++ b/dune/xt/grid/gridprovider/factory.hh @@ -37,8 +37,7 @@ class GridProviderFactory { if (cfg.empty()) return G::create(G::default_config(), mpi_comm); - else - return G::create(cfg, mpi_comm); + return G::create(cfg, mpi_comm); } static std::string available_as_str() @@ -65,11 +64,11 @@ public: { if (CubeType::static_id() == type) return CubeType::default_config(); - else if (DgfType::static_id() == type) + if (DgfType::static_id() == type) return DgfType::default_config(); - else if (GmshType::static_id() == type) + if (GmshType::static_id() == type) return GmshType::default_config(); - else if (available().empty()) + if (available().empty()) DUNE_THROW(Common::Exceptions::wrong_input_given, "There is no grid provider available for " << Common::Typename<GridType>::value() << "!"); else @@ -95,11 +94,11 @@ public: } if (CubeType::static_id() == type) return call_create<CubeType>(config, mpi_comm); - else if (DgfType::static_id() == type) + if (DgfType::static_id() == type) return call_create<DgfType>(config, mpi_comm); - else if (GmshType::static_id() == type) + if (GmshType::static_id() == type) return call_create<GmshType>(config, mpi_comm); - else if (available().empty()) + if (available().empty()) DUNE_THROW(Common::Exceptions::wrong_input_given, "There is no grid provider available for " << Common::Typename<GridType>::value() << "!"); else diff --git a/dune/xt/grid/mapper.hh b/dune/xt/grid/mapper.hh index 0d2003466..7af62923e 100644 --- a/dune/xt/grid/mapper.hh +++ b/dune/xt/grid/mapper.hh @@ -45,8 +45,8 @@ size_t sub_entity_index(const Dune::Mapper<G, MapperImp, IndexType>& mapper, Common::Exceptions::index_out_of_range, "element.subEntities(" << codim << ") = " << element.subEntities(codim) << "\n i = " << i); return Common::numeric_cast<size_t>(mapper.index(element.template subEntity<cd>(Common::numeric_cast<int>(i)))); - } else - return sub_entity_index<G, MapperImp, IndexType, dim, GridImp, EntityImp, cd - 1>(mapper, element, codim, i); + } + return sub_entity_index<G, MapperImp, IndexType, dim, GridImp, EntityImp, cd - 1>(mapper, element, codim, i); } } diff --git a/dune/xt/grid/output/entity_visualization.hh b/dune/xt/grid/output/entity_visualization.hh index 8a5365e3d..449d81d47 100644 --- a/dune/xt/grid/output/entity_visualization.hh +++ b/dune/xt/grid/output/entity_visualization.hh @@ -203,11 +203,11 @@ struct ElementVisualization for (auto intersectionIt = gridview_.ibegin(entity); intersectionIt != gridview_.iend(entity); ++intersectionIt) { if (type_ == "dirichlet") { return (boundaryInfo_.type(*intersectionIt) == dirichlet_type); - } else if (type_ == "neumann") { + } + if (type_ == "neumann") { return (boundaryInfo_.type(*intersectionIt) == neumann_type); - } else { - DUNE_THROW(Common::Exceptions::internal_error, "Unknown type '" << type_ << "'!"); } + DUNE_THROW(Common::Exceptions::internal_error, "Unknown type '" << type_ << "'!"); } return 0; } diff --git a/dune/xt/grid/search.hh b/dune/xt/grid/search.hh index ceb5dca7f..3996bd964 100644 --- a/dune/xt/grid/search.hh +++ b/dune/xt/grid/search.hh @@ -51,16 +51,14 @@ struct CheckInside { if (codim == point.size()) { return Common::FloatCmp::eq(geometry.center(), point); - } else { - if (Common::FloatCmp::ne( - geometry.global(geometry.local(point)), - point, - 2. * Common::FloatCmp::DefaultEpsilon<typename GlobalCoordinateType::value_type>::value(), - 2. * Common::FloatCmp::DefaultEpsilon<typename GlobalCoordinateType::value_type>::value())) - return false; - const auto& refElement = reference_element(geometry); - return refElement.checkInside(geometry.local(point)); } + if (Common::FloatCmp::ne(geometry.global(geometry.local(point)), + point, + 2. * Common::FloatCmp::DefaultEpsilon<typename GlobalCoordinateType::value_type>::value(), + 2. * Common::FloatCmp::DefaultEpsilon<typename GlobalCoordinateType::value_type>::value())) + return false; + const auto& refElement = reference_element(geometry); + return refElement.checkInside(geometry.local(point)); } }; diff --git a/dune/xt/la/container/common/vector/sparse.hh b/dune/xt/la/container/common/vector/sparse.hh index 1d58c17fd..6a33a39f6 100644 --- a/dune/xt/la/container/common/vector/sparse.hh +++ b/dune/xt/la/container/common/vector/sparse.hh @@ -302,8 +302,7 @@ public: auto it = std::lower_bound(indices_->begin(), indices_->end(), ii); if (it == indices_->end() || *it != ii) return ScalarType(0.); - else - return (*entries_)[std::distance(indices_->begin(), it)]; + return (*entries_)[std::distance(indices_->begin(), it)]; } protected: @@ -315,13 +314,13 @@ protected: indices_->push_back(ii); entries_->push_back(0.); return entries_->back(); - } else if (*it != ii) { + } + if (*it != ii) { indices_->insert(it, ii); entries_->insert(entries_->begin() + index, 0.); return (*entries_)[index]; - } else { - return (*entries_)[index]; } + return (*entries_)[index]; } inline const ScalarType& get_unchecked_ref(const size_t ii) const @@ -332,13 +331,13 @@ protected: indices_->push_back(ii); entries_->push_back(0.); return entries_->back(); - } else if (*it != ii) { + } + if (*it != ii) { indices_->insert(it, ii); entries_->insert(entries_->begin() + index, 0.); return (*entries_)[index]; - } else { - return (*entries_)[index]; } + return (*entries_)[index]; } public: diff --git a/dune/xt/la/container/conversion.hh b/dune/xt/la/container/conversion.hh index 97c355b3a..2e287dc2e 100644 --- a/dune/xt/la/container/conversion.hh +++ b/dune/xt/la/container/conversion.hh @@ -120,22 +120,22 @@ typename std::enable_if<is_matrix<RangeType>::value, RangeType>::type convert_to #endif ); return ret; - } else { - RangeType ret(rows, cols); - for (size_t ii = 0; ii < rows; ++ii) - for (size_t jj = 0; jj < cols; ++jj) - ret.set_entry(ii, - jj, + } + RangeType ret(rows, cols); + for (size_t ii = 0; ii < rows; ++ii) + for (size_t jj = 0; jj < cols; ++jj) + ret.set_entry(ii, + jj, #ifndef DXT_DISABLE_CHECKS - Common::numeric_cast<typename Common::MatrixAbstraction<RangeType>::S>( + Common::numeric_cast<typename Common::MatrixAbstraction<RangeType>::S>( #endif - source.get_entry(ii, jj) + source.get_entry(ii, jj) #ifndef DXT_DISABLE_CHECKS - ) + ) #endif - ); - return ret; - } + ); + return ret; + } // ... convert_to(...) diff --git a/dune/xt/la/container/eigen/sparse.hh b/dune/xt/la/container/eigen/sparse.hh index d7d8ab0c2..2762ff51a 100644 --- a/dune/xt/la/container/eigen/sparse.hh +++ b/dune/xt/la/container/eigen/sparse.hh @@ -364,7 +364,8 @@ public: if (col == jj) { backend().coeffRef(static_cast<EIGEN_size_t>(row), static_cast<EIGEN_size_t>(jj)) = ScalarType(0); break; - } else if (col > jj) + } + if (col > jj) break; } } @@ -402,7 +403,8 @@ public: else backend().coeffRef(static_cast<EIGEN_size_t>(row), static_cast<EIGEN_size_t>(jj)) = ScalarType(0); break; - } else if (col > jj) + } + if (col > jj) break; } } @@ -516,7 +518,7 @@ private: const size_t col = row_it.col(); if ((ii == row) && (jj == col)) return true; - else if ((row > ii) && (col > jj)) + if ((row > ii) && (col > jj)) return false; } } diff --git a/dune/xt/la/container/istl.hh b/dune/xt/la/container/istl.hh index 95d9411a1..db7210074 100644 --- a/dune/xt/la/container/istl.hh +++ b/dune/xt/la/container/istl.hh @@ -603,8 +603,7 @@ public: assert(jj < cols()); if (these_are_valid_indices(ii, jj)) return backend_->operator[](ii)[jj][0][0]; - else - return ScalarType(0); + return ScalarType(0); } // ... get_entry(...) void clear_row(const size_t ii) @@ -685,16 +684,16 @@ public: SparsityPatternDefault ret(rows()); if (prune) { return pruned_pattern_from_backend(*backend_, eps); - } else { - for (size_t ii = 0; ii < rows(); ++ii) { - if (backend_->getrowsize(ii) > 0) { - const auto& row = backend_->operator[](ii); - const auto it_end = row.end(); - for (auto it = row.begin(); it != it_end; ++it) - ret.insert(ii, it.index()); - } + } + for (size_t ii = 0; ii < rows(); ++ii) { + if (backend_->getrowsize(ii) > 0) { + const auto& row = backend_->operator[](ii); + const auto it_end = row.end(); + for (auto it = row.begin(); it != it_end; ++it) + ret.insert(ii, it.index()); } } + ret.sort(); return ret; } // ... pattern(...) diff --git a/dune/xt/la/container/matrix-market.hh b/dune/xt/la/container/matrix-market.hh index 25a9e328d..1e9efd7cb 100644 --- a/dune/xt/la/container/matrix-market.hh +++ b/dune/xt/la/container/matrix-market.hh @@ -27,19 +27,180 @@ namespace Dune { namespace XT { namespace LA { +namespace internal { template <class MatrixType> -MatrixType read_matrix_market(const std::string& filename) +MatrixType read_matrix_market_array_format(std::ifstream& matrix_file, + std::string& curr_line, + const bool field_qualifier_is_complex, + const bool is_general, + const bool is_symmetric, + const bool is_skew_symmetric) { using M = XT::Common::MatrixAbstraction<MatrixType>; using RealType = typename M::RealType; using ScalarType = typename M::ScalarType; + // dense matrix format, first line contains 'num_rows num_cols', each following line contains one matrix entry, + // entries are in column-major order + // parse first line + std::vector<std::string> matrix_dimensions; + boost::algorithm::split( + matrix_dimensions, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); + DUNE_THROW_IF(matrix_dimensions.size() != 2, Dune::IOError, "Could not read matrix dimensions!"); + const size_t rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); + const size_t cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); + MatrixType ret = M::create(rows, cols, 0., XT::LA::dense_pattern(rows, cols)); + DUNE_THROW_IF(!is_general && rows != cols, + Dune::InvalidStateException, + "You're trying to create a non-square symmetric/skew-symmetric/hermitian matrix!"); + // read entries + const size_t expected_entry_size = field_qualifier_is_complex ? 2 : 1; + std::vector<std::string> curr_entry(expected_entry_size); + const size_t expected_num_entries = + is_general ? rows * cols : (is_skew_symmetric ? (rows * (rows - 1)) / 2 : (rows * (rows - 1)) / 2 + rows); + for (size_t ii = 0; ii < expected_num_entries; ++ii) { + size_t curr_row, curr_col; + if (is_general) { + curr_row = ii % rows; + curr_col = ii / rows; + } else { + // (skew-)symmetric or hermitian + // only (strictly) lower triangular part is given + // In the symmetric/hermitian case, first column has rows entries, second one rows - 1 entries, ... + // In the skew-symmetric case, the diagonal is also ommited, so each column has one entry less + size_t col_size = is_skew_symmetric ? rows - 1 : rows; + curr_col = 0; + curr_row = ii; + while (curr_row >= col_size) { + curr_row -= col_size; + curr_col += 1; + col_size -= 1; + } + curr_row += is_skew_symmetric ? curr_col + 1 : curr_col; + } + // get next line, skip blank lines + do { + std::getline(matrix_file, curr_line); + XT::Common::trim(curr_line); + } while (curr_line.empty() && matrix_file.good()); + DUNE_THROW_IF(!matrix_file.good(), Dune::IOError, "There were not enough entries for this matrix!"); + boost::algorithm::split(curr_entry, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); + DUNE_THROW_IF( + !(curr_entry.size() == expected_entry_size), Dune::InvalidStateException, "Invalid entry encountered!"); + ScalarType entry = XT::Common::create_real_or_complex_number<ScalarType>( + XT::Common::from_string<RealType>(curr_entry[0]), + XT::Common::from_string<RealType>(field_qualifier_is_complex ? curr_entry[1] : "0.")); + M::set_entry(ret, curr_row, curr_col, entry); + } // ii + if (!is_general) { + // fill in upper triangular part + for (size_t ii = 0; ii < rows; ++ii) { + for (size_t jj = 0; jj < ii; ++jj) { + if (is_symmetric) + M::set_entry(ret, jj, ii, M::get_entry(ret, ii, jj)); + else if (is_skew_symmetric) + M::set_entry(ret, jj, ii, -1. * M::get_entry(ret, ii, jj)); + else // format is hermitian + M::set_entry(ret, jj, ii, XT::Common::conj(M::get_entry(ret, ii, jj))); + } // jj + } // ii + } + return ret; +} + +template <class MatrixType> +MatrixType read_matrix_market_coordinate_format(std::ifstream& matrix_file, + std::string& curr_line, + const bool field_qualifier_is_complex, + const bool is_general, + const bool is_symmetric, + const bool is_skew_symmetric) +{ + using M = XT::Common::MatrixAbstraction<MatrixType>; + using RealType = typename M::RealType; + using ScalarType = typename M::ScalarType; + // coordinate format, first line contains 'num_rows num_cols num_nonzeros', each following line contains one matrix + // entry in the format 'row_index col_index entry', indices are 1-based + std::vector<std::string> matrix_dimensions; + boost::algorithm::split( + matrix_dimensions, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); + DUNE_THROW_IF(matrix_dimensions.size() != 3, Dune::IOError, "Could not read matrix dimensions!"); + const size_t rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); + const size_t cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); + const size_t nnz = XT::Common::from_string<size_t>(matrix_dimensions[2]); + // read entries + std::vector<std::tuple<size_t, size_t, ScalarType>> entries(nnz); + const size_t expected_entry_size = field_qualifier_is_complex ? 4 : 3; + std::vector<std::string> curr_entry(expected_entry_size); + for (size_t ii = 0; ii < nnz; ++ii) { + // get next line, skip blank lines + do { + std::getline(matrix_file, curr_line); + XT::Common::trim(curr_line); + } while (curr_line.empty() && matrix_file.good()); + DUNE_THROW_IF(!matrix_file.good(), Dune::IOError, "There were not enough entries for this matrix!"); + boost::algorithm::split(curr_entry, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); + DUNE_THROW_IF( + !(curr_entry.size() == expected_entry_size), Dune::InvalidStateException, "Invalid entry encountered!"); + ScalarType entry = XT::Common::create_real_or_complex_number<ScalarType>( + XT::Common::from_string<RealType>(curr_entry[2]), + XT::Common::from_string<RealType>(field_qualifier_is_complex ? curr_entry[3] : "0.")); + entries[ii] = std::make_tuple( + XT::Common::from_string<size_t>(curr_entry[0]), XT::Common::from_string<size_t>(curr_entry[1]), entry); + } + SparsityPatternDefault pattern(rows); + for (size_t ii = 0; ii < nnz; ++ii) { + // entries in matrix market format are 1-based + const size_t row = std::get<0>(entries[ii]); + const size_t col = std::get<1>(entries[ii]); + DUNE_THROW_IF( + row == 0 || col == 0, Dune::InvalidStateException, "Indices in matrix market format have to be 1-based!"); + DUNE_THROW_IF( + (!is_general) && row < col, + Dune::InvalidStateException, + "Only provide (strictly) lower triangular portion of matrix for symmetric/hermitian/skew-symmetric format!"); + DUNE_THROW_IF( + is_skew_symmetric && row == col, + Dune::InvalidStateException, + "Only provide (strictly) lower triangular portion of matrix for symmetric/hermitian/skew-symmetric format!"); + pattern.insert(row - 1, col - 1); + if (!is_general) + pattern.insert(col - 1, row - 1); + } + pattern.sort(); + MatrixType ret = M::create(rows, cols, 0., pattern); + for (size_t ii = 0; ii < nnz; ++ii) { + const size_t row = std::get<0>(entries[ii]) - 1; + const size_t col = std::get<1>(entries[ii]) - 1; + const ScalarType entry = std::get<2>(entries[ii]); + M::set_entry(ret, row, col, entry); + if (!is_general) { + if (is_symmetric) + M::set_entry(ret, col, row, entry); + else if (is_skew_symmetric) + M::set_entry(ret, col, row, -entry); + else // format is hermitian + M::set_entry(ret, col, row, XT::Common::conj(entry)); + } + } // ii + return ret; +} + + +} // namespace internal + + +template <class MatrixType> +MatrixType read_matrix_market(const std::string& filename) +{ + using M = XT::Common::MatrixAbstraction<MatrixType>; + using ScalarType = typename M::ScalarType; constexpr bool scalartype_is_complex = XT::Common::is_complex<ScalarType>::value; std::ifstream matrix_file(filename); DUNE_THROW_IF(!matrix_file.is_open(), Dune::IOError, "Opening matrix file for reading failed!"); std::string curr_line; - std::string matrix_market_prefix = "%%MatrixMarket"; + static const std::string matrix_market_prefix = "%%MatrixMarket"; // Search for matrix market header // Find line that starts with %%MatrixMarket, compare returns 0 if match is found while (curr_line.compare(0, matrix_market_prefix.size(), matrix_market_prefix) && matrix_file.good()) { @@ -82,140 +243,12 @@ MatrixType read_matrix_market(const std::string& filename) XT::Common::trim(curr_line); } DUNE_THROW_IF(!matrix_file.good(), Dune::IOError, "File only contains header and comments, no data found!"); - if (format_str == "array") { - // dense matrix format, first line contains 'num_rows num_cols', each following line contains one matrix entry, - // entries are in column-major order parse first line - std::vector<std::string> matrix_dimensions; - boost::algorithm::split( - matrix_dimensions, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); - DUNE_THROW_IF(matrix_dimensions.size() != 2, Dune::IOError, "Could not read matrix dimensions!"); - const size_t rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); - const size_t cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); - MatrixType ret = M::create(rows, cols, 0., XT::LA::dense_pattern(rows, cols)); - DUNE_THROW_IF(!is_general && rows != cols, - Dune::InvalidStateException, - "You're trying to create a non-square symmetric/skew-symmetric/hermitian matrix!"); - // read entries - const size_t expected_entry_size = field_qualifier_is_complex ? 2 : 1; - std::vector<std::string> curr_entry(expected_entry_size); - const size_t expected_num_entries = - is_general ? rows * cols : (is_skew_symmetric ? (rows * (rows - 1)) / 2 : (rows * (rows - 1)) / 2 + rows); - for (size_t ii = 0; ii < expected_num_entries; ++ii) { - size_t curr_row, curr_col; - if (is_general) { - curr_row = ii % rows; - curr_col = ii / rows; - } else { - // (skew-)symmetric or hermitian - // only (strictly) lower triangular part is given - // In the symmetric/hermitian case, first column has rows entries, second one rows - 1 entries, ... - // In the skew-symmetric case, the diagonal is also ommited, so each column has one entry less - size_t col_size = is_skew_symmetric ? rows - 1 : rows; - curr_col = 0; - curr_row = ii; - while (curr_row >= col_size) { - curr_row -= col_size; - curr_col += 1; - col_size -= 1; - } - curr_row += is_skew_symmetric ? curr_col + 1 : curr_col; - } - // get next line, skip blank lines - do { - std::getline(matrix_file, curr_line); - XT::Common::trim(curr_line); - } while (curr_line.empty() && matrix_file.good()); - DUNE_THROW_IF(!matrix_file.good(), Dune::IOError, "There were not enough entries for this matrix!"); - boost::algorithm::split(curr_entry, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); - DUNE_THROW_IF( - !(curr_entry.size() == expected_entry_size), Dune::InvalidStateException, "Invalid entry encountered!"); - ScalarType entry = XT::Common::create_real_or_complex_number<ScalarType>( - XT::Common::from_string<RealType>(curr_entry[0]), - XT::Common::from_string<RealType>(field_qualifier_is_complex ? curr_entry[1] : "0.")); - M::set_entry(ret, curr_row, curr_col, entry); - } // ii - if (!is_general) { - // fill in upper triangular part - for (size_t ii = 0; ii < rows; ++ii) { - for (size_t jj = 0; jj < ii; ++jj) { - if (is_symmetric) - M::set_entry(ret, jj, ii, M::get_entry(ret, ii, jj)); - else if (is_skew_symmetric) - M::set_entry(ret, jj, ii, -1. * M::get_entry(ret, ii, jj)); - else // format is hermitian - M::set_entry(ret, jj, ii, XT::Common::conj(M::get_entry(ret, ii, jj))); - } // jj - } // ii - } - return ret; - } else { - // coordinate format, first line contains 'num_rows num_cols num_nonzeros', each following line contains one matrix - // entry in the format 'row_index col_index entry', indices are 1-based - std::vector<std::string> matrix_dimensions; - boost::algorithm::split( - matrix_dimensions, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); - DUNE_THROW_IF(matrix_dimensions.size() != 3, Dune::IOError, "Could not read matrix dimensions!"); - const size_t rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); - const size_t cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); - const size_t nnz = XT::Common::from_string<size_t>(matrix_dimensions[2]); - // read entries - std::vector<std::tuple<size_t, size_t, ScalarType>> entries(nnz); - const size_t expected_entry_size = field_qualifier_is_complex ? 4 : 3; - std::vector<std::string> curr_entry(expected_entry_size); - for (size_t ii = 0; ii < nnz; ++ii) { - // get next line, skip blank lines - do { - std::getline(matrix_file, curr_line); - XT::Common::trim(curr_line); - } while (curr_line.empty() && matrix_file.good()); - DUNE_THROW_IF(!matrix_file.good(), Dune::IOError, "There were not enough entries for this matrix!"); - boost::algorithm::split(curr_entry, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); - DUNE_THROW_IF( - !(curr_entry.size() == expected_entry_size), Dune::InvalidStateException, "Invalid entry encountered!"); - ScalarType entry = XT::Common::create_real_or_complex_number<ScalarType>( - XT::Common::from_string<RealType>(curr_entry[2]), - XT::Common::from_string<RealType>(field_qualifier_is_complex ? curr_entry[3] : "0.")); - entries[ii] = std::make_tuple( - XT::Common::from_string<size_t>(curr_entry[0]), XT::Common::from_string<size_t>(curr_entry[1]), entry); - } - SparsityPatternDefault pattern(rows); - for (size_t ii = 0; ii < nnz; ++ii) { - // entries in matrix market format are 1-based - const size_t row = std::get<0>(entries[ii]); - const size_t col = std::get<1>(entries[ii]); - DUNE_THROW_IF( - row == 0 || col == 0, Dune::InvalidStateException, "Indices in matrix market format have to be 1-based!"); - DUNE_THROW_IF( - (!is_general) && row < col, - Dune::InvalidStateException, - "Only provide (strictly) lower triangular portion of matrix for symmetric/hermitian/skew-symmetric format!"); - DUNE_THROW_IF( - is_skew_symmetric && row == col, - Dune::InvalidStateException, - "Only provide (strictly) lower triangular portion of matrix for symmetric/hermitian/skew-symmetric format!"); - pattern.insert(row - 1, col - 1); - if (!is_general) - pattern.insert(col - 1, row - 1); - } - pattern.sort(); - MatrixType ret = M::create(rows, cols, 0., pattern); - for (size_t ii = 0; ii < nnz; ++ii) { - const size_t row = std::get<0>(entries[ii]) - 1; - const size_t col = std::get<1>(entries[ii]) - 1; - const ScalarType entry = std::get<2>(entries[ii]); - M::set_entry(ret, row, col, entry); - if (!is_general) { - if (is_symmetric) - M::set_entry(ret, col, row, entry); - else if (is_skew_symmetric) - M::set_entry(ret, col, row, -entry); - else // format is hermitian - M::set_entry(ret, col, row, XT::Common::conj(entry)); - } - } // ii - return ret; - } // coordinate format -} // namespace LA + if (format_str == "array") + return internal::read_matrix_market_array_format<MatrixType>( + matrix_file, curr_line, field_qualifier_is_complex, is_general, is_symmetric, is_skew_symmetric); + return internal::read_matrix_market_coordinate_format<MatrixType>( + matrix_file, curr_line, field_qualifier_is_complex, is_general, is_symmetric, is_skew_symmetric); +} template <class MatrixType> @@ -270,4 +303,4 @@ void write_matrix_market(const MatrixType& mat, const std::string& filename, con } // namespace XT } // namespace Dune -#endif // DUNE_XT_LA_CONTAINER_MATRIX_MARKET_HH \ No newline at end of file +#endif // DUNE_XT_LA_CONTAINER_MATRIX_MARKET_HH diff --git a/dune/xt/la/eigen-solver/internal/base.hh b/dune/xt/la/eigen-solver/internal/base.hh index 77568f689..cc8218c5c 100644 --- a/dune/xt/la/eigen-solver/internal/base.hh +++ b/dune/xt/la/eigen-solver/internal/base.hh @@ -147,7 +147,7 @@ public: compute_and_check(); if (eigenvalues_) return *eigenvalues_; - else if (options_->get<bool>("compute_eigenvalues")) + if (options_->get<bool>("compute_eigenvalues")) DUNE_THROW(Common::Exceptions::internal_error, "The eigenvalues_ member is not filled after calling compute()!"); else DUNE_THROW(Common::Exceptions::you_are_using_this_wrong, @@ -215,7 +215,7 @@ public: compute_and_check(); if (eigenvectors_) return *eigenvectors_; - else if (options_->get<bool>("compute_eigenvectors")) + if (options_->get<bool>("compute_eigenvectors")) DUNE_THROW(Common::Exceptions::internal_error, "The eigenvectors_ member is not filled after calling compute()!"); else DUNE_THROW(Common::Exceptions::you_are_using_this_wrong, diff --git a/dune/xt/la/generalized-eigen-solver/internal/base.hh b/dune/xt/la/generalized-eigen-solver/internal/base.hh index 5ef4b1326..b5cd9088a 100644 --- a/dune/xt/la/generalized-eigen-solver/internal/base.hh +++ b/dune/xt/la/generalized-eigen-solver/internal/base.hh @@ -155,7 +155,7 @@ public: compute_and_check(); if (eigenvalues_) return *eigenvalues_; - else if (options_->get<bool>("compute_eigenvalues")) + if (options_->get<bool>("compute_eigenvalues")) DUNE_THROW(Common::Exceptions::internal_error, "The eigenvalues_ member is not filled after calling compute()!"); else DUNE_THROW(Common::Exceptions::you_are_using_this_wrong, @@ -223,7 +223,7 @@ public: compute_and_check(); if (eigenvectors_) return *eigenvectors_; - else if (options_->get<bool>("compute_eigenvectors")) + if (options_->get<bool>("compute_eigenvectors")) DUNE_THROW(Common::Exceptions::internal_error, "The eigenvectors_ member is not filled after calling compute()!"); else DUNE_THROW(Common::Exceptions::you_are_using_this_wrong, diff --git a/dune/xt/la/solver/istl.hh b/dune/xt/la/solver/istl.hh index d94af821f..801200ba7 100644 --- a/dune/xt/la/solver/istl.hh +++ b/dune/xt/la/solver/istl.hh @@ -145,12 +145,14 @@ public: iterative_options.set("preconditioner.isotropy_dim", "2"); // <- this as well iterative_options.set("preconditioner.verbose", "0"); return iterative_options; - } else if (tp == "bicgstab.ilut" || tp == "bicgstab.ssor") { + } + if (tp == "bicgstab.ilut" || tp == "bicgstab.ssor") { iterative_options.set("preconditioner.iterations", "2"); iterative_options.set("preconditioner.relaxation_factor", "1.0"); return iterative_options; #if HAVE_UMFPACK - } else if (tp == "umfpack") { + } + if (tp == "umfpack") { return general_opts; #endif #if HAVE_SUPERLU diff --git a/dune/xt/la/solver/istl/amg.hh b/dune/xt/la/solver/istl/amg.hh index 39b2bb8a4..2535f5c02 100644 --- a/dune/xt/la/solver/istl/amg.hh +++ b/dune/xt/la/solver/istl/amg.hh @@ -115,7 +115,8 @@ public: InverseOperatorResult stats; solver.apply(solution.backend(), rhs.backend(), stats); return stats; - } else if (smoother_type == "ssor") { + } + if (smoother_type == "ssor") { using PreconditionerType_SSOR = Amg::AMG<MatrixOperatorType, IstlVectorType, SmootherType_SSOR, CommunicatorType>; PreconditionerType_SSOR preconditioner(matrix_operator, amg_criterion, smoother_parameters_ILU, communicator_); @@ -136,8 +137,8 @@ public: InverseOperatorResult stats; solver.apply(solution.backend(), rhs.backend(), stats); return stats; - } else - DUNE_THROW(Common::Exceptions::wrong_input_given, "Unknown smoother requested: " << smoother_type); + } + DUNE_THROW(Common::Exceptions::wrong_input_given, "Unknown smoother requested: " << smoother_type); } // ... call(...) protected: const MatrixType& matrix_; diff --git a/dune/xt/la/solver/istl/saddlepoint.hh b/dune/xt/la/solver/istl/saddlepoint.hh index a3bc16f2c..5b6f2bc48 100644 --- a/dune/xt/la/solver/istl/saddlepoint.hh +++ b/dune/xt/la/solver/istl/saddlepoint.hh @@ -69,10 +69,9 @@ public: iterative_options += general_opts; if (tp == "direct") return general_opts; - else if (tp == "cg_direct_schurcomplement" || tp == "cg_cg_schurcomplement") + if (tp == "cg_direct_schurcomplement" || tp == "cg_cg_schurcomplement") return iterative_options; - else - return general_opts; + return general_opts; } // ... options(...) void apply(const Vector& f, const Vector& g, Vector& u, Vector& p) const diff --git a/dune/xt/test/common/float_cmp.cc b/dune/xt/test/common/float_cmp.cc index 2f8975f2f..2a39f0e40 100644 --- a/dune/xt/test/common/float_cmp.cc +++ b/dune/xt/test/common/float_cmp.cc @@ -84,8 +84,7 @@ typename std::enable_if<XT::Common::is_vector<T>::value, T>::type make_type(cons using Vec = XT::Common::VectorAbstraction<T>; if (Vec::has_static_size) return Vec::create(Vec::static_size, number); - else - return Vec::create(VECSIZE, number); + return Vec::create(VECSIZE, number); } template <class T, class S> @@ -94,8 +93,7 @@ typename std::enable_if<XT::Common::is_matrix<T>::value, T>::type make_type(cons using Mat = XT::Common::MatrixAbstraction<T>; if (Mat::has_static_size) return Mat::create(Mat::static_rows, Mat::static_cols, number); - else - return Mat::create(VECSIZE, NUMCOLS, number); + return Mat::create(VECSIZE, NUMCOLS, number); } template <class T, -- GitLab From 1ed0454e0600b202b955bd60ad26cc025159e45e Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 09:26:25 +0100 Subject: [PATCH 06/19] [clang-tidy] Apply remaining modernize fixes modernize-avoid-bind, modernize-avoid-c-arrays, modernize-concat-nested-namespaces, modernize-deprecated-headers, modernize-deprecated-ios-base-aliases, modernize-loop-convert, modernize-make-shared, modernize-make-unique, modernize-pass-by-value, modernize-raw-string-literal, modernize-redundant-void-arg, modernize-replace-auto-ptr, modernize-replace-disallow-copy-and-assign-macro, modernize-replace-random-shuffle, modernize-return-braced-init-list, modernize-shrink-to-fit, modernize-unary-static-assert, modernize-use-auto, modernize-use-bool-literals, modernize-use-default-member-init, modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, modernize-use-nullptr, modernize-use-transparent-functors, modernize-use-uncaught-exceptions Together with the already applied modernize-use-override we now applied all modernize checks except for modernize-use-nodiscard, modernize-use-noexcept and modernize-use-trailing-return-type --- dune/xt/common/configuration.cc | 7 +-- dune/xt/common/fixed_map.hh | 2 +- dune/xt/common/localization-study.cc | 7 +-- dune/xt/common/localization-study.hh | 2 +- dune/xt/common/logging.cc | 1 - dune/xt/common/logging.hh | 2 +- dune/xt/common/logstreams.cc | 5 ++- dune/xt/common/logstreams.hh | 2 +- dune/xt/common/memory.hh | 5 ++- dune/xt/common/misc.cc | 4 +- dune/xt/common/misc.hh | 4 +- dune/xt/common/parameter.cc | 5 ++- dune/xt/common/parameter.hh | 4 +- dune/xt/common/print.hh | 15 ++++--- dune/xt/common/signals.cc | 4 +- dune/xt/common/signals.hh | 4 +- dune/xt/common/string.hh | 2 +- dune/xt/common/timedlogging.cc | 7 ++- dune/xt/common/timedlogging.hh | 11 ++--- dune/xt/common/timings.cc | 4 +- dune/xt/common/timings.hh | 5 ++- dune/xt/common/tuple.hh | 6 +-- dune/xt/common/validation.hh | 7 +-- dune/xt/functions/ESV2007.hh | 13 +++--- dune/xt/functions/base/composition.hh | 9 ++-- dune/xt/functions/base/visualization.hh | 20 +++++---- dune/xt/functions/checkerboard.hh | 13 +++--- dune/xt/functions/elementwise-diameter.hh | 9 ++-- dune/xt/functions/elementwise-minimum.hh | 5 ++- dune/xt/functions/expression/base.hh | 5 ++- dune/xt/functions/expression/default.hh | 17 +++---- dune/xt/functions/expression/parametric.hh | 5 ++- dune/xt/functions/flattop.hh | 5 ++- dune/xt/functions/generic/flux-function.hh | 32 +++++++------- dune/xt/functions/generic/function.hh | 22 +++++----- dune/xt/functions/generic/grid-function.hh | 44 +++++++++---------- dune/xt/functions/grid-function.hh | 9 ++-- dune/xt/functions/indicator.hh | 12 ++--- dune/xt/grid/bound-object.hh | 12 ++--- dune/xt/grid/boundaryinfo/boundarysegment.hh | 8 ++-- dune/xt/grid/boundaryinfo/interfaces.hh | 2 +- dune/xt/grid/dd/glued.hh | 7 +-- dune/xt/grid/filters/element.hh | 3 +- dune/xt/grid/filters/intersection.hh | 11 ++--- dune/xt/grid/functors/generic.hh | 4 +- dune/xt/grid/gridprovider/provider.hh | 3 +- dune/xt/grid/output/entity_visualization.hh | 6 +-- dune/xt/grid/output/pgf.hh | 5 ++- .../parallel/partitioning/ranged-internal.hh | 4 +- dune/xt/la/container/common/vector/dense.hh | 3 +- dune/xt/la/container/container-interface.hh | 2 +- dune/xt/la/container/eigen/dense.hh | 3 +- dune/xt/la/container/eigen/sparse.hh | 3 +- dune/xt/la/container/istl.hh | 5 ++- dune/xt/la/container/matrix-market.hh | 10 ++--- dune/xt/la/container/matrix-view.hh | 20 ++------- dune/xt/la/container/vector-array/list.hh | 2 +- dune/xt/la/container/vector-interface.hh | 2 +- dune/xt/la/container/vector-view.hh | 7 ++- dune/xt/la/eigen-solver/default.hh | 4 +- dune/xt/la/eigen-solver/eigen.hh | 4 +- dune/xt/la/eigen-solver/fmatrix.hh | 8 ++-- .../xt/la/generalized-eigen-solver/default.hh | 2 +- dune/xt/la/solver/istl.hh | 2 +- dune/xt/test/common/configuration.cc | 2 +- dune/xt/test/common/tuple.cc | 10 ++--- dune/xt/test/grid/periodic_gridview.cc | 6 +-- dune/xt/test/la/eigensolver.hh | 5 +-- dune/xt/test/la/generalized-eigensolver.hh | 5 +-- dune/xt/test/la/matrixinverter.hh | 5 +-- python/dune/xt/common/empty.cc | 5 ++- python/dune/xt/functions/spe10.hh | 2 +- python/dune/xt/grid/element.cc | 2 +- 73 files changed, 264 insertions(+), 255 deletions(-) diff --git a/dune/xt/common/configuration.cc b/dune/xt/common/configuration.cc index 7cf99ad65..15ca4659a 100644 --- a/dune/xt/common/configuration.cc +++ b/dune/xt/common/configuration.cc @@ -62,11 +62,8 @@ Configuration::Configuration(const ParameterTree& tree_in, const std::string& su } Configuration::Configuration(const Configuration& other) - : BaseType(other) - , warn_on_default_access_(other.warn_on_default_access_) - , log_on_exit_(other.log_on_exit_) - , logfile_(other.logfile_) -{} + + = default; Configuration::Configuration(const std::initializer_list<std::pair<std::string, std::string>>& key_value_pairs) : warn_on_default_access_(ConfigurationDefaults().warn_on_default_access) diff --git a/dune/xt/common/fixed_map.hh b/dune/xt/common/fixed_map.hh index 81aed66af..21f50e066 100644 --- a/dune/xt/common/fixed_map.hh +++ b/dune/xt/common/fixed_map.hh @@ -143,7 +143,7 @@ public: using iterator = FixedMapIterator<ThisType>; using const_iterator = ConstFixedMapIterator<ThisType>; - FixedMap() {} + FixedMap() = default; /** inserts key-value value pairs from initializer list * if list.size() > N only the first N elements are considered * if list.size() < N the Map is padded with default constructed elements diff --git a/dune/xt/common/localization-study.cc b/dune/xt/common/localization-study.cc index 95db7fefc..7fda7c0ed 100644 --- a/dune/xt/common/localization-study.cc +++ b/dune/xt/common/localization-study.cc @@ -16,16 +16,17 @@ #include <boost/io/ios_state.hpp> #include <dune/xt/common/string.hh> +#include <utility> #include "localization-study.hh" namespace Dune::XT::Common { -LocalizationStudy::LocalizationStudy(const std::vector<std::string>& only_these_indicators) - : only_these_indicators_(only_these_indicators) +LocalizationStudy::LocalizationStudy(std::vector<std::string> only_these_indicators) + : only_these_indicators_(std::move(only_these_indicators)) {} -LocalizationStudy::~LocalizationStudy() {} +LocalizationStudy::~LocalizationStudy() = default; std::vector<std::string> LocalizationStudy::used_indicators() const { diff --git a/dune/xt/common/localization-study.hh b/dune/xt/common/localization-study.hh index 56f206424..aa8397474 100644 --- a/dune/xt/common/localization-study.hh +++ b/dune/xt/common/localization-study.hh @@ -26,7 +26,7 @@ namespace Dune::XT::Common { class LocalizationStudy { public: - LocalizationStudy(const std::vector<std::string>& only_these_indicators = {}); + LocalizationStudy(std::vector<std::string> only_these_indicators = {}); virtual ~LocalizationStudy(); diff --git a/dune/xt/common/logging.cc b/dune/xt/common/logging.cc index 843d11a9f..8d4c2eafd 100644 --- a/dune/xt/common/logging.cc +++ b/dune/xt/common/logging.cc @@ -24,7 +24,6 @@ namespace Dune::XT::Common { Logging::Logging() : streamIDs_({LOG_ERROR, LOG_DEBUG, LOG_INFO}) - , logflags_(LOG_NONE) , emptyLogStream_(logflags_) { for (const auto id : streamIDs_) diff --git a/dune/xt/common/logging.hh b/dune/xt/common/logging.hh index a8bfecf07..90638db2a 100644 --- a/dune/xt/common/logging.hh +++ b/dune/xt/common/logging.hh @@ -134,7 +134,7 @@ private: StreamMap streammap_; using IdVec = std::vector<int>; IdVec streamIDs_; - int logflags_; + int logflags_{LOG_NONE}; EmptyLogStream emptyLogStream_; friend Logging& Logger(); diff --git a/dune/xt/common/logstreams.cc b/dune/xt/common/logstreams.cc index d8b9ccf49..9cc617586 100644 --- a/dune/xt/common/logstreams.cc +++ b/dune/xt/common/logstreams.cc @@ -16,6 +16,7 @@ #include <boost/format.hpp> #include <dune/xt/common/string.hh> +#include <utility> #include "logstreams.hh" @@ -78,9 +79,9 @@ int SuspendableStrBuffer::pubsync() return 0; } -TimedPrefixedStreamBuffer::TimedPrefixedStreamBuffer(const Timer& timer, const std::string& prefix, std::ostream& out) +TimedPrefixedStreamBuffer::TimedPrefixedStreamBuffer(const Timer& timer, std::string prefix, std::ostream& out) : timer_(timer) - , prefix_(prefix) + , prefix_(std::move(prefix)) , out_(out) , prefix_needed_(true) {} diff --git a/dune/xt/common/logstreams.hh b/dune/xt/common/logstreams.hh index eaa42bf12..3f9c953df 100644 --- a/dune/xt/common/logstreams.hh +++ b/dune/xt/common/logstreams.hh @@ -149,7 +149,7 @@ class TimedPrefixedStreamBuffer : public std::basic_stringbuf<char, std::char_tr using BaseType = std::basic_stringbuf<char, std::char_traits<char>>; public: - TimedPrefixedStreamBuffer(const Timer& timer, const std::string& prefix, std::ostream& out = std::cout); + TimedPrefixedStreamBuffer(const Timer& timer, std::string prefix, std::ostream& out = std::cout); int sync() override; diff --git a/dune/xt/common/memory.hh b/dune/xt/common/memory.hh index e15ba8e43..5a3b71bc7 100644 --- a/dune/xt/common/memory.hh +++ b/dune/xt/common/memory.hh @@ -16,6 +16,7 @@ #include <memory> #include <dune/xt/common/debug.hh> +#include <utility> namespace Dune::XT::Common { @@ -87,7 +88,7 @@ public: {} explicit ConstAccessByPointer(std::shared_ptr<const T> tt) - : tt_(tt) + : tt_(std::move(tt)) {} const T& access() const final @@ -187,7 +188,7 @@ public: {} explicit AccessByPointer(std::shared_ptr<T> tt) - : tt_(tt) + : tt_(std::move(tt)) {} T& access() final diff --git a/dune/xt/common/misc.cc b/dune/xt/common/misc.cc index 23a26ed1f..3a46a1ba6 100644 --- a/dune/xt/common/misc.cc +++ b/dune/xt/common/misc.cc @@ -13,8 +13,8 @@ #include "misc.hh" -#include <stdlib.h> -#include <stdio.h> +#include <cstdlib> +#include <cstdio> #include <unordered_map> #include <algorithm> #include <dune/xt/common/string.hh> diff --git a/dune/xt/common/misc.hh b/dune/xt/common/misc.hh index 45952f039..395a33c72 100644 --- a/dune/xt/common/misc.hh +++ b/dune/xt/common/misc.hh @@ -16,7 +16,7 @@ #include <cstring> #include <map> -#include <assert.h> +#include <cassert> #include <algorithm> #include <dune/common/version.hh> #include <dune/common/exceptions.hh> @@ -31,7 +31,7 @@ #include <cmath> #include <cerrno> #include <limits> -#include <string.h> +#include <cstring> #include <stdexcept> #include <sys/stat.h> #include <sys/types.h> diff --git a/dune/xt/common/parameter.cc b/dune/xt/common/parameter.cc index 2d83596c6..82ab13f82 100644 --- a/dune/xt/common/parameter.cc +++ b/dune/xt/common/parameter.cc @@ -18,6 +18,7 @@ #include <dune/xt/common/exceptions.hh> #include <dune/xt/common/float_cmp.hh> #include <dune/xt/common/numeric_cast.hh> +#include <utility> #include "parameter.hh" @@ -212,8 +213,8 @@ std::ostream& operator<<(std::ostream& out, const Parameter& mu) // =============================== // ===== ParametricInterface ===== // =============================== -ParametricInterface::ParametricInterface(const ParameterType& param_type) - : parameter_type_(param_type) +ParametricInterface::ParametricInterface(ParameterType param_type) + : parameter_type_(std::move(param_type)) {} bool ParametricInterface::is_parametric() const diff --git a/dune/xt/common/parameter.hh b/dune/xt/common/parameter.hh index 40a4a8847..0ae22c2b4 100644 --- a/dune/xt/common/parameter.hh +++ b/dune/xt/common/parameter.hh @@ -243,7 +243,7 @@ private: public: /// \note this is somehow necessary to make clang 3.8 happy (and cannot be defaulted) - ~Parameter() {} + ~Parameter() = default; Parameter(const std::vector<std::pair<std::string, ValueType>>& key_value_pairs = {}); @@ -280,7 +280,7 @@ std::ostream& operator<<(std::ostream& out, const Parameter& mu); class ParametricInterface { public: - ParametricInterface(const ParameterType& param_type = {}); + ParametricInterface(ParameterType param_type = {}); ParametricInterface(const ParametricInterface& other) = default; diff --git a/dune/xt/common/print.hh b/dune/xt/common/print.hh index 7f8ff5d12..521aa5d94 100644 --- a/dune/xt/common/print.hh +++ b/dune/xt/common/print.hh @@ -13,8 +13,9 @@ #ifndef DUNE_XT_COMMON_PRINT_HH #define DUNE_XT_COMMON_PRINT_HH -#include <string> #include <iostream> +#include <string> +#include <utility> #include <dune/xt/common/configuration.hh> #include <dune/xt/common/filesystem.hh> @@ -100,9 +101,9 @@ class VectorPrinter : public internal::DefaultPrinter<T, use_repr> public: const std::string class_name; - VectorPrinter(const T& val, const Configuration& cfg = {}, const std::string& clss_nm = Typename<T>::value()) + VectorPrinter(const T& val, const Configuration& cfg = {}, std::string clss_nm = Typename<T>::value()) : internal::DefaultPrinter<T, use_repr>(val, cfg) - , class_name(clss_nm) + , class_name(std::move(clss_nm)) {} void repr(std::ostream& out) const override @@ -150,9 +151,9 @@ class MatrixPrinter : public internal::DefaultPrinter<T, use_repr> public: const std::string class_name; - MatrixPrinter(const T& val, const Configuration& cfg = {}, const std::string& clss_nm = Typename<T>::value()) + MatrixPrinter(const T& val, const Configuration& cfg = {}, std::string clss_nm = Typename<T>::value()) : internal::DefaultPrinter<T, use_repr>(val, cfg) - , class_name(clss_nm) + , class_name(std::move(clss_nm)) {} void repr(std::ostream& out) const override @@ -481,9 +482,9 @@ public: using reference = T; using iterator_category = std::output_iterator_tag; - PrefixOutputIterator(std::ostream& o, std::string const& p = "") + PrefixOutputIterator(std::ostream& o, std::string p = "") : ostream(o) - , prefix(p) + , prefix(std::move(p)) , first(true) {} diff --git a/dune/xt/common/signals.cc b/dune/xt/common/signals.cc index 275098c67..53d5dee30 100644 --- a/dune/xt/common/signals.cc +++ b/dune/xt/common/signals.cc @@ -26,7 +26,7 @@ void reset_signal(int signal) new_action.sa_handler = SIG_DFL; sigemptyset(&new_action.sa_mask); new_action.sa_flags = 0; - sigaction(signal, &new_action, NULL); + sigaction(signal, &new_action, nullptr); } // reset_signal //! example signal handler @@ -39,7 +39,7 @@ void handle_interrupt(int signal) } // handle_interrupt //! type of handler functions -typedef void handler_type(int); +using handler_type = void(int); //! calling this from your main() will install handler as callback when signal is received void install_signal_handler(int signal, handler_type handler) diff --git a/dune/xt/common/signals.hh b/dune/xt/common/signals.hh index 485473a75..94a33f90a 100644 --- a/dune/xt/common/signals.hh +++ b/dune/xt/common/signals.hh @@ -12,7 +12,7 @@ #ifndef DUNE_XT_COMMON_SIGNALS #define DUNE_XT_COMMON_SIGNALS -#include <signal.h> +#include <csignal> namespace Dune::XT::Common { @@ -25,7 +25,7 @@ void reset_signal(int signal); void handle_interrupt(int signal); //! type of handler functions -typedef void handler_type(int); +using handler_type = void(int); //! calling this from your main() will install handler as callback when signal is received void install_signal_handler(int signal = SIGINT, handler_type handler = handle_interrupt); diff --git a/dune/xt/common/string.hh b/dune/xt/common/string.hh index 526f1f72b..1d4c2faf6 100644 --- a/dune/xt/common/string.hh +++ b/dune/xt/common/string.hh @@ -166,7 +166,7 @@ void trim(std::string& s); void trim(std::vector<std::string>& v); //! returns string with local time in current locale's format -inline std::string stringFromTime(time_t cur_time = time(NULL)) +inline std::string stringFromTime(time_t cur_time = time(nullptr)) { return ctime(&cur_time); } diff --git a/dune/xt/common/timedlogging.cc b/dune/xt/common/timedlogging.cc index 97bc45101..17d1d2892 100644 --- a/dune/xt/common/timedlogging.cc +++ b/dune/xt/common/timedlogging.cc @@ -14,6 +14,7 @@ #include <ostream> #include <boost/format.hpp> +#include <utility> #include "memory.hh" #include "exceptions.hh" @@ -25,12 +26,11 @@ namespace Dune::XT::Common { DefaultLogger::DefaultLogger(const std::string& prfx, const std::array<bool, 3>& initial_state, - const std::array<std::string, 3>& colors, + std::array<std::string, 3> colors, bool global_timer) : prefix(prfx) , state(initial_state) - , copy_count(0) - , colors_(colors) + , colors_(std::move(colors)) , global_timer_(global_timer) , info_(std::make_shared<TimedPrefixedLogStream>(global_timer_ ? SecondsSinceStartup() : timer_, build_prefix(prfx.empty() ? "info" : prfx, copy_count, colors_[0]), @@ -223,7 +223,6 @@ TimedLogging::TimedLogging() , info_suffix_(enable_colors_ ? StreamModifiers::normal : "") , debug_suffix_(enable_colors_ ? StreamModifiers::normal : "") , warning_suffix_(enable_colors_ ? StreamModifiers::normal : "") - , created_(false) , current_level_(-1) { update_colors(); diff --git a/dune/xt/common/timedlogging.hh b/dune/xt/common/timedlogging.hh index fede850c1..5d2111385 100644 --- a/dune/xt/common/timedlogging.hh +++ b/dune/xt/common/timedlogging.hh @@ -28,6 +28,7 @@ #include <dune/xt/common/color.hh> #include <dune/xt/common/logstreams.hh> #include <dune/xt/common/string.hh> +#include <utility> #ifndef DUNE_XT_COMMON_TIMEDLOGGING_ENABLE_DEBUG # ifndef NDEBUG @@ -77,11 +78,11 @@ class DefaultLogger public: std::string prefix; std::array<bool, 3> state; - size_t copy_count; + size_t copy_count{0}; DefaultLogger(const std::string& prfx = "", const std::array<bool, 3>& initial_state = default_logger_state(), - const std::array<std::string, 3>& colors = {{"blue", "darkgray", "red"}}, + std::array<std::string, 3> colors = {{"blue", "darkgray", "red"}}, bool global_timer = true); DefaultLogger(const DefaultLogger&); @@ -302,7 +303,7 @@ private: std::string info_suffix_; std::string debug_suffix_; std::string warning_suffix_; - bool created_; + bool created_{false}; std::atomic<ssize_t> current_level_; Timer timer_; std::mutex mutex_; @@ -458,9 +459,9 @@ class ActiveEnableDebugLoggingForCtors using ThisType = ActiveEnableDebugLoggingForCtors<T>; public: - ActiveEnableDebugLoggingForCtors(const std::string& prefix, const std::string& class_id) + ActiveEnableDebugLoggingForCtors(const std::string& prefix, std::string class_id) : logger_(TimedLogger().get(prefix)) - , class_id_(class_id) + , class_id_(std::move(class_id)) { logger_.debug() << class_id_ << "(this=" << this << ")" << std::endl; } diff --git a/dune/xt/common/timings.cc b/dune/xt/common/timings.cc index 1e2cbb14f..1bc64a9d0 100644 --- a/dune/xt/common/timings.cc +++ b/dune/xt/common/timings.cc @@ -73,7 +73,7 @@ void Timings::start(const std::string& section_name) { std::lock_guard<std::mutex> lock(mutex_); - const KnownTimersMap::iterator section = known_timers_map_.find(section_name); + const auto section = known_timers_map_.find(section_name); if (section != known_timers_map_.end()) { if (section->second.first) // timer currently running return; @@ -112,7 +112,7 @@ TimingData::TimeType Timings::walltime(std::string section_name) const TimingData::DeltaType Timings::delta(const std::string& section_name) const { - DeltaMap::const_iterator section = commited_deltas_.find(section_name); + auto section = commited_deltas_.find(section_name); if (section == commited_deltas_.end()) { // timer might still be running const auto& timer_it = known_timers_map_.find(section_name); diff --git a/dune/xt/common/timings.hh b/dune/xt/common/timings.hh index 79c62e87c..4adf9676c 100644 --- a/dune/xt/common/timings.hh +++ b/dune/xt/common/timings.hh @@ -36,6 +36,7 @@ #include <dune/common/parallel/mpihelper.hh> #include <dune/xt/common/parallel/threadstorage.hh> +#include <utility> namespace Dune::XT::Common { @@ -148,8 +149,8 @@ protected: const std::string section_name_; public: - explicit inline ScopedTiming(const std::string& section_name) - : section_name_(section_name) + explicit inline ScopedTiming(std::string section_name) + : section_name_(std::move(section_name)) { timings().start(section_name_); } diff --git a/dune/xt/common/tuple.hh b/dune/xt/common/tuple.hh index e48567037..55f27e8e2 100644 --- a/dune/xt/common/tuple.hh +++ b/dune/xt/common/tuple.hh @@ -194,10 +194,10 @@ struct Combine using u_next = typename next<UIterator>::type; using v_next = typename next<VIterator>::type; - typedef + using type = typename if_<std::is_same<v_next, v_end>, typename if_<std::is_same<u_next, u_end>, end_of_recursion_tag, Generate<u_next, v_begin>>::type, - Generate<UIterator, v_next>>::type type; + Generate<UIterator, v_next>>::type; }; // this class run test on generated types in thos round and go to next*/ @@ -305,7 +305,7 @@ namespace internal { template <std::size_t> struct Any { - Any(...) {} + Any(...) = default; }; template <typename T> diff --git a/dune/xt/common/validation.hh b/dune/xt/common/validation.hh index 6c270a039..86fc1b053 100644 --- a/dune/xt/common/validation.hh +++ b/dune/xt/common/validation.hh @@ -20,6 +20,7 @@ #include <dune/xt/common/string.hh> #include <dune/xt/common/type_traits.hh> #include <dune/xt/common/float_cmp.hh> +#include <utility> namespace Dune::XT::Common { @@ -60,7 +61,7 @@ class ValidateAny : public ValidatorInterface<T, ValidateAny<T>> using BaseType = ValidatorInterface<T, ThisType>; public: - inline ValidateAny() {} + inline ValidateAny() = default; inline ValidateAny(const ThisType&) {} inline bool operator()(const T&) const @@ -84,8 +85,8 @@ class ValidateInList : public ValidatorInterface<T, ValidateInList<T, ListImp>> ListType valid_list_; public: - explicit ValidateInList(const ListType& valid_list) - : valid_list_(valid_list) + explicit ValidateInList(ListType valid_list) + : valid_list_(std::move(valid_list)) {} inline bool operator()(const T& rhs) const diff --git a/dune/xt/functions/ESV2007.hh b/dune/xt/functions/ESV2007.hh index 62ef2c6b9..55e573c5b 100644 --- a/dune/xt/functions/ESV2007.hh +++ b/dune/xt/functions/ESV2007.hh @@ -29,6 +29,7 @@ #include <dune/xt/functions/grid-function.hh> #include <dune/xt/functions/interfaces/grid-function.hh> #include <dune/xt/functions/interfaces/function.hh> +#include <utility> namespace Dune::XT::Functions::ESV2007 { @@ -72,9 +73,9 @@ public: } // ... defaults(...) Testcase1Force(const size_t ord = defaults().template get<int>("integration_order"), - const std::string& nm = "ESV2007Testcase1Force") + std::string nm = "ESV2007Testcase1Force") : order_(static_cast<int>(ord)) - , name_(nm) + , name_(std::move(nm)) {} Testcase1Force(const ThisType&) = default; @@ -170,9 +171,9 @@ public: } // ... defaults(...) Testcase1ExactSolution(const size_t ord = defaults().template get<int>("integration_order"), - const std::string& nm = "ESV2007Testcase1ExactSolution") + std::string nm = "ESV2007Testcase1ExactSolution") : order_(static_cast<int>(ord)) - , name_(nm) + , name_(std::move(nm)) {} Testcase1ExactSolution(const ThisType&) = default; @@ -353,11 +354,11 @@ public: CutoffFunction(GridFunction<E, d, d, R> diffusion, const RangeFieldType poincare_constant = 1.0 / (M_PI * M_PI), - const std::string& nm = "ESV2007CutoffFunction") + std::string nm = "ESV2007CutoffFunction") : BaseType(diffusion.parameter_type()) , diffusion_(diffusion.copy_as_grid_function()) , poincare_constant_(poincare_constant) - , name_(nm) + , name_(std::move(nm)) {} CutoffFunction(const ThisType& other) diff --git a/dune/xt/functions/base/composition.hh b/dune/xt/functions/base/composition.hh index b1977c142..1a19f1287 100644 --- a/dune/xt/functions/base/composition.hh +++ b/dune/xt/functions/base/composition.hh @@ -20,6 +20,7 @@ #include <dune/xt/functions/interfaces/grid-function.hh> #include <dune/xt/functions/interfaces/function.hh> #include <dune/xt/grid/search.hh> +#include <utility> namespace Dune::XT::Functions { namespace internal { @@ -217,18 +218,18 @@ public: CompositionFunction(const InnerType inner_function, const OuterType outer_function, const OuterGridViewType outer_grid_view, - const std::string& nm = static_id()) + std::string nm = static_id()) : inner_function_(inner_function) , outer_function_(outer_function) , element_search_(std::make_shared<typename Grid::EntityInlevelSearch<OuterGridViewType>>(outer_grid_view)) - , name_(nm) + , name_(std::move(nm)) {} // constructor without grid view, only makes sense if OuterType is derived from FunctionInterface - CompositionFunction(const InnerType local_func, const OuterType global_func, const std::string& nm = static_id()) + CompositionFunction(const InnerType local_func, const OuterType global_func, std::string nm = static_id()) : inner_function_(local_func) , outer_function_(global_func) - , name_(nm) + , name_(std::move(nm)) { static_assert(std::is_base_of<XT::Functions::FunctionInterface<OuterType::domain_dim, OuterType::range_dim, diff --git a/dune/xt/functions/base/visualization.hh b/dune/xt/functions/base/visualization.hh index 8fff3459e..8c2a08fbe 100644 --- a/dune/xt/functions/base/visualization.hh +++ b/dune/xt/functions/base/visualization.hh @@ -14,6 +14,7 @@ #define DUNE_XT_FUNCTIONS_BASE_VISUALIZATION_HH #include <algorithm> +#include <utility> #include <dune/grid/io/file/vtk/function.hh> @@ -40,7 +41,8 @@ class VisualizerInterface public: using RangeType = typename RangeTypeSelector<R, r, rC>::type; - virtual ~VisualizerInterface(){}; + virtual ~VisualizerInterface() = default; + ; virtual int ncomps() const = 0; @@ -204,22 +206,22 @@ public: VisualizationAdapter(const GridFunctionType& grid_function, const VisualizerInterface<range_dim, range_dim_cols, RangeField>& visualizer, const std::string& nm = "", - const XT::Common::Parameter& param = {}) + XT::Common::Parameter param = {}) : function_(grid_function.copy_as_grid_function()) , local_function_(function_->local_function()) , visualizer_(visualizer) , name_(nm.empty() ? function_->name() : nm) - , param_(param) + , param_(std::move(param)) {} VisualizationAdapter(const GridFunctionType& grid_function, const std::string& nm = "", - const XT::Common::Parameter& param = {}) + XT::Common::Parameter param = {}) : function_(grid_function.copy_as_grid_function()) , local_function_(function_->local_function()) , visualizer_(new DefaultVisualizer<range_dim, range_dim_cols, RangeField>()) , name_(nm.empty() ? function_->name() : nm) - , param_(param) + , param_(std::move(param)) {} int ncomps() const final @@ -267,12 +269,12 @@ public: GradientVisualizationAdapter(const GridFunctionType& grid_function, const VisualizerInterface<d, 1, RangeField>& visualizer, const std::string& nm = "", - const XT::Common::Parameter& param = {}) + XT::Common::Parameter param = {}) : function_(grid_function.copy_as_grid_function()) , local_function_(function_->local_function()) , visualizer_(visualizer) , name_(nm.empty() ? "grad_ " + function_->name() : nm) - , param_(param) + , param_(std::move(param)) { if (range_dim > 1) DUNE_THROW(Dune::NotImplemented, "Only implemented for scalar functions by now!"); @@ -280,12 +282,12 @@ public: GradientVisualizationAdapter(const GridFunctionType& grid_function, const std::string& nm = "", - const XT::Common::Parameter& param = {}) + XT::Common::Parameter param = {}) : function_(grid_function.copy_as_grid_function()) , local_function_(function_->local_function()) , visualizer_(new DefaultVisualizer<d, 1, RangeField>()) , name_(nm.empty() ? "grad_" + function_->name() : nm) - , param_(param) + , param_(std::move(param)) { if (range_dim > 1) DUNE_THROW(Dune::NotImplemented, "Only implemented for scalar functions by now!"); diff --git a/dune/xt/functions/checkerboard.hh b/dune/xt/functions/checkerboard.hh index 6a17428bb..3ae611ce3 100644 --- a/dune/xt/functions/checkerboard.hh +++ b/dune/xt/functions/checkerboard.hh @@ -16,6 +16,7 @@ #include <dune/xt/common/configuration.hh> #include <dune/xt/functions/interfaces/grid-function.hh> +#include <utility> namespace Dune::XT::Functions { @@ -52,7 +53,7 @@ class CheckerboardFunction : public GridFunctionInterface<E, r, rC, R> , lower_left_(lower_left) , upper_right_(upper_right) , num_elements_(num_elements) - , values_(values) + , values_(std::move(values)) {} protected: @@ -90,8 +91,8 @@ class CheckerboardFunction : public GridFunctionInterface<E, r, rC, R> { const auto center = element.geometry().center(); if (Common::FloatCmp::le(lower_left_, center) && Common::FloatCmp::lt(center, upper_right_)) - return 1; - return 0; + return true; + return false; } size_t find_subdomain(const ElementType& element) const @@ -155,12 +156,12 @@ public: const DomainType& upper_right, const FieldVector<size_t, domain_dim>& num_elements, std::shared_ptr<std::vector<RangeType>> values, - const std::string& nm = "CheckerboardFunction") + std::string nm = "CheckerboardFunction") : lower_left_(lower_left) , upper_right_(upper_right) , num_elements_(num_elements) - , values_(values) - , name_(nm) + , values_(std::move(values)) + , name_(std::move(nm)) { #ifndef NDEBUG // checks diff --git a/dune/xt/functions/elementwise-diameter.hh b/dune/xt/functions/elementwise-diameter.hh index f2d92b34e..cb4d66b1d 100644 --- a/dune/xt/functions/elementwise-diameter.hh +++ b/dune/xt/functions/elementwise-diameter.hh @@ -12,6 +12,7 @@ #define DUNE_XT_FUNCTIONS_ELEMENTWISE_DIAMETER_HH #include <dune/xt/functions/interfaces/grid-function.hh> +#include <utility> namespace Dune::XT::Functions { @@ -34,7 +35,7 @@ class ElementwiseDiameterFunction : public GridFunctionInterface<E> LocalFunction() : BaseType() - , diameter_(0) + {} protected: @@ -61,7 +62,7 @@ class ElementwiseDiameterFunction : public GridFunctionInterface<E> } private: - double diameter_; + double diameter_{0}; }; // class LocalFunction public: @@ -70,9 +71,9 @@ public: using BaseType::rC; using typename BaseType::LocalFunctionType; - ElementwiseDiameterFunction(const std::string& nm = "ElementwiseDiameterFunction") + ElementwiseDiameterFunction(std::string nm = "ElementwiseDiameterFunction") : BaseType() - , name_(nm) + , name_(std::move(nm)) {} ElementwiseDiameterFunction(const ThisType&) = default; diff --git a/dune/xt/functions/elementwise-minimum.hh b/dune/xt/functions/elementwise-minimum.hh index 6e1af215a..a4712cac7 100644 --- a/dune/xt/functions/elementwise-minimum.hh +++ b/dune/xt/functions/elementwise-minimum.hh @@ -17,6 +17,7 @@ #include <dune/xt/functions/interfaces/grid-function.hh> #include <dune/xt/functions/grid-function.hh> #include <dune/xt/functions/type_traits.hh> +#include <utility> namespace Dune::XT::Functions { namespace internal { @@ -151,11 +152,11 @@ private: public: ElementwiseMinimumFunction(GridFunction<E, r_, rC_> some_func, const int search_quadrature_order, - const std::string& nm = "ElementwiseMinimumFunction") + std::string nm = "ElementwiseMinimumFunction") : BaseType() , some_func_(some_func.copy_as_grid_function()) , search_quadrature_order_(search_quadrature_order) - , name_(nm) + , name_(std::move(nm)) { DUNE_THROW_IF(!some_func_->parameter_type().empty(), Exceptions::parameter_error, diff --git a/dune/xt/functions/expression/base.hh b/dune/xt/functions/expression/base.hh index 3b21e450c..29f7df6f7 100644 --- a/dune/xt/functions/expression/base.hh +++ b/dune/xt/functions/expression/base.hh @@ -16,6 +16,7 @@ #include <mutex> #include <sstream> +#include <utility> #include <vector> #include <dune/common/dynvector.hh> @@ -55,8 +56,8 @@ public: using RangeFieldType = RangeField; static constexpr size_t range_dim = rangeDim; - MathExpressionBase(const std::string& var, const Common::FieldVector<std::string, range_dim>& exprs) - : variable_(var) + MathExpressionBase(std::string var, const Common::FieldVector<std::string, range_dim>& exprs) + : variable_(std::move(var)) , expressions_(exprs) { setup(); diff --git a/dune/xt/functions/expression/default.hh b/dune/xt/functions/expression/default.hh index 379f35553..c137cc7e5 100644 --- a/dune/xt/functions/expression/default.hh +++ b/dune/xt/functions/expression/default.hh @@ -23,6 +23,7 @@ #include "base.hh" #include <dune/xt/functions/interfaces/function.hh> +#include <utility> namespace Dune::XT::Functions { @@ -106,11 +107,11 @@ public: const Common::FieldMatrix<std::string, r, rC>& expressions, const Common::FieldVector<Common::FieldMatrix<std::string, rC, d>, r>& gradient_expressions, const size_t ord, - const std::string& nm = static_id()) + std::string nm = static_id()) : BaseType() , function_(variable, matrix_to_vector(expressions)) , order_(ord) - , name_(nm) + , name_(std::move(nm)) { for (size_t cc = 0; cc < r; ++cc) { gradients_.emplace_back(std::vector<MathExpressionGradientType>()); @@ -129,11 +130,11 @@ public: ExpressionFunction(const std::string& variable, const Common::FieldMatrix<std::string, r, rC>& expressions, const size_t ord, - const std::string& nm = static_id()) + std::string nm = static_id()) : BaseType() , function_(variable, matrix_to_vector(expressions)) , order_(ord) - , name_(nm) + , name_(std::move(nm)) {} ExpressionFunction(const ThisType& other) @@ -307,11 +308,11 @@ public: const Common::FieldVector<std::string, r>& expressions, const Common::FieldMatrix<std::string, r, d>& gradient_expressions, const size_t ord, - const std::string& nm = static_id()) + std::string nm = static_id()) : BaseType() , function_(variable, expressions) , order_(ord) - , name_(nm) + , name_(std::move(nm)) { for (size_t rr = 0; rr < r; ++rr) gradients_.emplace_back(new MathExpressionGradientType(variable, gradient_expressions[rr])); @@ -324,11 +325,11 @@ public: ExpressionFunction(const std::string& variable, const Common::FieldVector<std::string, r>& expressions, const size_t ord, - const std::string& nm = static_id()) + std::string nm = static_id()) : BaseType() , function_(variable, expressions) , order_(ord) - , name_(nm) + , name_(std::move(nm)) {} ExpressionFunction(const ThisType& other) diff --git a/dune/xt/functions/expression/parametric.hh b/dune/xt/functions/expression/parametric.hh index 4a7679066..a8ff74676 100644 --- a/dune/xt/functions/expression/parametric.hh +++ b/dune/xt/functions/expression/parametric.hh @@ -16,6 +16,7 @@ #include <limits> #include <dune/xt/common/parameter.hh> +#include <utility> #include "dune/xt/functions/interfaces/function.hh" #include "base.hh" @@ -61,10 +62,10 @@ public: const Common::ParameterType& param_type, const Common::FieldVector<std::string, r>& expressions, const size_t ord = 0, - const std::string& nm = static_id()) + std::string nm = static_id()) : BaseType(param_type) , order_(ord) - , name_(nm) + , name_(std::move(nm)) , num_parameter_variables_(0) { DUNE_THROW_IF(variable.empty(), Common::Exceptions::wrong_input_given, "Given variable must not be empty!"); diff --git a/dune/xt/functions/flattop.hh b/dune/xt/functions/flattop.hh index 1481f7fbd..ab5e8806d 100644 --- a/dune/xt/functions/flattop.hh +++ b/dune/xt/functions/flattop.hh @@ -16,6 +16,7 @@ #include <dune/xt/common/configuration.hh> #include <dune/xt/functions/interfaces/function.hh> +#include <utility> namespace Dune::XT::Functions { @@ -72,12 +73,12 @@ public: const DomainType& upper_right, const DomainType& boundary_layer, const RangeReturnType& value = RangeReturnType(1), - const std::string& name_in = "FlatTopFunction") + std::string name_in = "FlatTopFunction") : lower_left_(lower_left) , upper_right_(upper_right) , boundary_layer_(boundary_layer) , value_(value) - , name_(name_in) + , name_(std::move(name_in)) { check_input(); } diff --git a/dune/xt/functions/generic/flux-function.hh b/dune/xt/functions/generic/flux-function.hh index 9203a293b..e9b9bc29f 100644 --- a/dune/xt/functions/generic/flux-function.hh +++ b/dune/xt/functions/generic/flux-function.hh @@ -188,15 +188,15 @@ public: GenericFluxFunction(const int ord, GenericPostBindFunctionType post_bind_func = default_post_bind_function(), GenericEvaluateFunctionType evaluate_func = default_evaluate_function(), - const Common::ParameterType& param_type = Common::ParameterType(), - const std::string& nm = "GenericFluxFunction", + Common::ParameterType param_type = Common::ParameterType(), + std::string nm = "GenericFluxFunction", GenericJacobianFunctionType jacobian_func = default_jacobian_function()) : order_(default_order_lambda(ord)) , post_bind_(post_bind_func) , evaluate_(evaluate_func) , dynamic_evaluate_(default_dynamic_evaluate_function()) - , param_type_(param_type) - , name_(nm) + , param_type_(std::move(param_type)) + , name_(std::move(nm)) , jacobian_(jacobian_func) , dynamic_jacobian_(default_dynamic_jacobian_function()) {} @@ -204,15 +204,15 @@ public: GenericFluxFunction(GenericOrderFunctionType order_func, GenericPostBindFunctionType post_bind_func = default_post_bind_function(), GenericEvaluateFunctionType evaluate_func = default_evaluate_function(), - const Common::ParameterType& param_type = Common::ParameterType(), - const std::string& nm = "GenericFluxFunction", + Common::ParameterType param_type = Common::ParameterType(), + std::string nm = "GenericFluxFunction", GenericJacobianFunctionType jacobian_func = default_jacobian_function()) : order_(std::move(order_func)) , post_bind_(post_bind_func) , evaluate_(evaluate_func) , dynamic_evaluate_(default_dynamic_evaluate_function()) - , param_type_(param_type) - , name_(nm) + , param_type_(std::move(param_type)) + , name_(std::move(nm)) , jacobian_(jacobian_func) , dynamic_jacobian_(default_dynamic_jacobian_function()) {} @@ -220,15 +220,15 @@ public: GenericFluxFunction(const int ord, GenericPostBindFunctionType post_bind_func, GenericDynamicEvaluateFunctionType evaluate_func, - const Common::ParameterType& param_type = Common::ParameterType(), - const std::string& nm = "GenericFluxFunction", + Common::ParameterType param_type = Common::ParameterType(), + std::string nm = "GenericFluxFunction", GenericDynamicJacobianFunctionType jacobian_func = default_dynamic_jacobian_function()) : order_(default_order_lambda(ord)) , post_bind_(post_bind_func) , evaluate_(evaluate_from_dynamic_evaluate(evaluate_func)) , dynamic_evaluate_(evaluate_func) - , param_type_(param_type) - , name_(nm) + , param_type_(std::move(param_type)) + , name_(std::move(nm)) , jacobian_(jacobian_from_dynamic_jacobian(jacobian_func)) , dynamic_jacobian_(jacobian_func) {} @@ -236,15 +236,15 @@ public: GenericFluxFunction(GenericOrderFunctionType order_func, GenericPostBindFunctionType post_bind_func, GenericDynamicEvaluateFunctionType evaluate_func, - const Common::ParameterType& param_type = Common::ParameterType(), - const std::string& nm = "GenericFluxFunction", + Common::ParameterType param_type = Common::ParameterType(), + std::string nm = "GenericFluxFunction", GenericDynamicJacobianFunctionType jacobian_func = default_dynamic_jacobian_function()) : order_(std::move(order_func)) , post_bind_(post_bind_func) , evaluate_(evaluate_from_dynamic_evaluate(evaluate_func)) , dynamic_evaluate_(evaluate_func) - , param_type_(param_type) - , name_(nm) + , param_type_(std::move(param_type)) + , name_(std::move(nm)) , jacobian_(jacobian_from_dynamic_jacobian(jacobian_func)) , dynamic_jacobian_(jacobian_func) {} diff --git a/dune/xt/functions/generic/function.hh b/dune/xt/functions/generic/function.hh index 95f28fc25..f59541458 100644 --- a/dune/xt/functions/generic/function.hh +++ b/dune/xt/functions/generic/function.hh @@ -53,7 +53,7 @@ public: GenericFunction(GenericOrderFunctionType order_func, GenericEvaluateFunctionType evaluate_func = default_evaluate_function(), - const std::string& nm = "smooth_lambda_function", + std::string nm = "smooth_lambda_function", const Common::ParameterType& param_type = {}, GenericJacobianFunctionType jacobian_func = default_jacobian_function(), GenericDerivativeFunctionType derivative_func = default_derivative_function()) @@ -63,27 +63,27 @@ public: , dynamic_evaluate_(static_to_dynamic_evaluate(evaluate_)) , jacobian_(jacobian_func) , derivative_(derivative_func) - , name_(nm) + , name_(std::move(nm)) {} GenericFunction(int ord, GenericEvaluateFunctionType evaluate_func = default_evaluate_function(), - const std::string& nm = "smooth_lambda_function", + std::string nm = "smooth_lambda_function", const Common::ParameterType& param_type = {}, GenericJacobianFunctionType jacobian_func = default_jacobian_function(), GenericDerivativeFunctionType derivative_func = default_derivative_function()) : BaseType(param_type) , order_([=](const auto& /*param*/) { return ord; }) - , evaluate_(evaluate_func) + , evaluate_(std::move(evaluate_func)) , dynamic_evaluate_(static_to_dynamic_evaluate(evaluate_)) - , jacobian_(jacobian_func) - , derivative_(derivative_func) - , name_(nm) + , jacobian_(std::move(jacobian_func)) + , derivative_(std::move(derivative_func)) + , name_(std::move(nm)) {} GenericFunction(GenericOrderFunctionType order_func, GenericDynamicEvaluateFunctionType dynamic_evaluate_func, - const std::string& nm = "smooth_lambda_function", + std::string nm = "smooth_lambda_function", const Common::ParameterType& param_type = {}, GenericJacobianFunctionType jacobian_func = default_jacobian_function(), GenericDerivativeFunctionType derivative_func = default_derivative_function()) @@ -93,12 +93,12 @@ public: , dynamic_evaluate_(dynamic_evaluate_func) , jacobian_(jacobian_func) , derivative_(derivative_func) - , name_(nm) + , name_(std::move(nm)) {} GenericFunction(int ord, GenericDynamicEvaluateFunctionType dynamic_evaluate_func, - const std::string& nm = "smooth_lambda_function", + std::string nm = "smooth_lambda_function", const Common::ParameterType& param_type = {}, GenericJacobianFunctionType jacobian_func = default_jacobian_function(), GenericDerivativeFunctionType derivative_func = default_derivative_function()) @@ -108,7 +108,7 @@ public: , dynamic_evaluate_(dynamic_evaluate_func) , jacobian_(jacobian_func) , derivative_(derivative_func) - , name_(nm) + , name_(std::move(nm)) {} GenericFunction(const ThisType&) = default; diff --git a/dune/xt/functions/generic/grid-function.hh b/dune/xt/functions/generic/grid-function.hh index d12f4abb6..882a09ba4 100644 --- a/dune/xt/functions/generic/grid-function.hh +++ b/dune/xt/functions/generic/grid-function.hh @@ -83,18 +83,18 @@ private: using GenericDerivativeFunctionType = std::function<DerivativeRangeReturnType( const std::array<size_t, d>&, const DomainType&, const XT::Common::Parameter&)>; - LocalGenericGridFunction(const GenericOrderFunctionType& order_func, - const GenericPostBindFunctionType& post_bind_func, - const GenericEvaluateFunctionType& evaluate_func, + LocalGenericGridFunction(GenericOrderFunctionType order_func, + GenericPostBindFunctionType post_bind_func, + GenericEvaluateFunctionType evaluate_func, const Common::ParameterType& param_type, - const GenericJacobianFunctionType& jacobian_func, - const GenericDerivativeFunctionType& derivative_func) + GenericJacobianFunctionType jacobian_func, + GenericDerivativeFunctionType derivative_func) : BaseType(param_type) - , order_(order_func) - , post_bind_(post_bind_func) - , evaluate_(evaluate_func) - , jacobian_(jacobian_func) - , derivative_(derivative_func) + , order_(std::move(order_func)) + , post_bind_(std::move(post_bind_func)) + , evaluate_(std::move(evaluate_func)) + , jacobian_(std::move(jacobian_func)) + , derivative_(std::move(derivative_func)) {} protected: @@ -175,32 +175,32 @@ public: GenericPostBindFunctionType post_bind_func = default_post_bind_function(), GenericEvaluateFunctionType evaluate_func = default_evaluate_function(), const Common::ParameterType& param_type = Common::ParameterType(), - const std::string& nm = "GenericGridFunction", + std::string nm = "GenericGridFunction", GenericJacobianFunctionType jacobian_func = default_jacobian_function(), GenericDerivativeFunctionType derivative_func = default_derivative_function()) : BaseType(param_type) , order_(default_order_lambda(ord)) - , post_bind_(post_bind_func) - , evaluate_(evaluate_func) - , name_(nm) - , jacobian_(jacobian_func) - , derivative_(derivative_func) + , post_bind_(std::move(post_bind_func)) + , evaluate_(std::move(evaluate_func)) + , name_(std::move(nm)) + , jacobian_(std::move(jacobian_func)) + , derivative_(std::move(derivative_func)) {} GenericGridFunction(GenericOrderFunctionType order_func, GenericPostBindFunctionType post_bind_func = default_post_bind_function(), GenericEvaluateFunctionType evaluate_func = default_evaluate_function(), const Common::ParameterType& param_type = Common::ParameterType(), - const std::string& nm = "GenericGridFunction", + std::string nm = "GenericGridFunction", GenericJacobianFunctionType jacobian_func = default_jacobian_function(), GenericDerivativeFunctionType derivative_func = default_derivative_function()) : BaseType(param_type) , order_(std::move(order_func)) - , post_bind_(post_bind_func) - , evaluate_(evaluate_func) - , name_(nm) - , jacobian_(jacobian_func) - , derivative_(derivative_func) + , post_bind_(std::move(post_bind_func)) + , evaluate_(std::move(evaluate_func)) + , name_(std::move(nm)) + , jacobian_(std::move(jacobian_func)) + , derivative_(std::move(derivative_func)) {} GenericGridFunction(const ThisType&) = default; diff --git a/dune/xt/functions/grid-function.hh b/dune/xt/functions/grid-function.hh index 34f09f6ac..600bc1369 100644 --- a/dune/xt/functions/grid-function.hh +++ b/dune/xt/functions/grid-function.hh @@ -26,6 +26,7 @@ #include <dune/xt/functions/interfaces/grid-function.hh> #include <dune/xt/functions/generic/function.hh> #include <dune/xt/functions/generic/grid-function.hh> +#include <utility> namespace Dune::XT::Functions { @@ -132,13 +133,13 @@ public: using GenericFunctionType = GenericFunction<d, r, rC>; GridFunction(const typename RangeTypeSelector<R, r, rC>::type& value, - const std::string& nm = "GridFunction", + std::string nm = "GridFunction", const std::string& logging_prefix = "") : BaseType({}, logging_prefix.empty() ? "GridFunction" : logging_prefix, {{!logging_prefix.empty(), !logging_prefix.empty(), true}}) , function_(new FunctionAsGridFunctionWrapper<E, r, rC, R>(new ConstantFunction<d, r, rC, R>(value))) - , name_(nm) + , name_(std::move(nm)) {} GridFunction(const FunctionInterface<d, r, rC, R>& func, const std::string& logging_prefix = "") @@ -174,14 +175,14 @@ public: {} GridFunction(std::tuple<int, typename GenericFunctionType::GenericEvaluateFunctionType> order_evaluate, - const std::string& nm = "GridFunction", + std::string nm = "GridFunction", const std::string& logging_prefix = "") : BaseType({}, logging_prefix.empty() ? "GridFunction" : logging_prefix, {{!logging_prefix.empty(), !logging_prefix.empty(), true}}) , function_(new FunctionAsGridFunctionWrapper<E, r, rC, R>( new GenericFunctionType(std::get<0>(order_evaluate), std::get<1>(order_evaluate)))) - , name_(nm) + , name_(std::move(nm)) {} GridFunction(std::tuple<int, typename GenericFunctionType::GenericEvaluateFunctionType, const std::string&> diff --git a/dune/xt/functions/indicator.hh b/dune/xt/functions/indicator.hh index 825d82246..66d0cf6c9 100644 --- a/dune/xt/functions/indicator.hh +++ b/dune/xt/functions/indicator.hh @@ -116,9 +116,9 @@ public: } // ... defaults(...) IndicatorGridFunction(std::shared_ptr<std::vector<std::tuple<DomainType, DomainType, RangeType>>> values, - const std::string& name_in = "IndicatorGridFunction") - : subdomain_and_value_tuples_(values) - , name_(name_in) + std::string name_in = "IndicatorGridFunction") + : subdomain_and_value_tuples_(std::move(values)) + , name_(std::move(name_in)) {} /** @@ -208,9 +208,9 @@ public: using typename BaseType::RangeReturnType; IndicatorFunction(std::shared_ptr<std::vector<std::tuple<DomainType, DomainType, RangeReturnType>>> values, - const std::string& nm = "IndicatorFunction") - : subdomain_and_value_tuples_(values) - , name_(nm) + std::string nm = "IndicatorFunction") + : subdomain_and_value_tuples_(std::move(values)) + , name_(std::move(nm)) {} IndicatorFunction(const std::vector<std::tuple<DomainType, DomainType, RangeReturnType>>& values, diff --git a/dune/xt/grid/bound-object.hh b/dune/xt/grid/bound-object.hh index c1f002655..9acb494c9 100644 --- a/dune/xt/grid/bound-object.hh +++ b/dune/xt/grid/bound-object.hh @@ -36,14 +36,14 @@ public: : /*DebugLogging("dune.xt.grid", "ElementBoundObject") ,*/ element_(nullptr) - , is_bound_(false) + {} ElementBoundObject(const ThisType& other) : /*DebugLogging(other) ,*/ element_(nullptr) - , is_bound_(false) + { if (other.element_) { element_ = std::make_unique<ElementType>(*other.element_); @@ -108,7 +108,7 @@ private: std::unique_ptr<ElementType> element_; protected: - bool is_bound_; + bool is_bound_{false}; }; // class ElementBoundObject @@ -124,12 +124,12 @@ public: IntersectionBoundObject() : intersection_(nullptr) - , is_bound_(false) + {} IntersectionBoundObject(const ThisType& other) : intersection_(nullptr) - , is_bound_(false) + { if (other.intersection_) { intersection_ = std::make_unique<IntersectionType>(*other.intersection_); @@ -187,7 +187,7 @@ private: std::unique_ptr<IntersectionType> intersection_; protected: - bool is_bound_; + bool is_bound_{false}; }; // class IntersectionBoundObject diff --git a/dune/xt/grid/boundaryinfo/boundarysegment.hh b/dune/xt/grid/boundaryinfo/boundarysegment.hh index df0d13ee4..c0bc15781 100644 --- a/dune/xt/grid/boundaryinfo/boundarysegment.hh +++ b/dune/xt/grid/boundaryinfo/boundarysegment.hh @@ -16,6 +16,7 @@ #include "interfaces.hh" #include <dune/xt/grid/boundaryinfo/types.hh> +#include <utility> namespace Dune::XT::Grid { @@ -80,10 +81,9 @@ public: return std::make_unique<ThisType>(default_type, id_map); } // ... create(...) - BoundarySegmentIndexBasedBoundaryInfo(const std::string& def, - const std::map<std::string, std::pair<size_t, size_t>>& id_map) - : default_(def) - , id_map_(id_map) + BoundarySegmentIndexBasedBoundaryInfo(std::string def, std::map<std::string, std::pair<size_t, size_t>> id_map) + : default_(std::move(def)) + , id_map_(std::move(id_map)) {} const BoundaryType& type(const IntersectionType& intersection) const final diff --git a/dune/xt/grid/boundaryinfo/interfaces.hh b/dune/xt/grid/boundaryinfo/interfaces.hh index 96be2050f..7267830ed 100644 --- a/dune/xt/grid/boundaryinfo/interfaces.hh +++ b/dune/xt/grid/boundaryinfo/interfaces.hh @@ -89,7 +89,7 @@ public: virtual void repr(std::ostream& out) const { - out << "BoundaryInfo(\?\?\?)"; + out << R"(BoundaryInfo(???))"; } virtual std::string str() const diff --git a/dune/xt/grid/dd/glued.hh b/dune/xt/grid/dd/glued.hh index 1a428cda4..0be3204af 100644 --- a/dune/xt/grid/dd/glued.hh +++ b/dune/xt/grid/dd/glued.hh @@ -40,6 +40,7 @@ #include <dune/xt/grid/gridprovider/cube.hh> #include <dune/xt/grid/search.hh> #include <dune/xt/grid/type_traits.hh> +#include <utility> namespace Dune::XT::Grid::DD { namespace Exceptions { @@ -556,7 +557,7 @@ public: // logger.debug() << "local_intersection: " << local_intersection.indexInInside() << ":" << // std::endl; const auto local_intersection_geometry = local_intersection.geometry(); - const size_t num_corners = boost::numeric_cast<size_t>(local_intersection_geometry.corners()); + const auto num_corners = boost::numeric_cast<size_t>(local_intersection_geometry.corners()); // ** Check if all corners of the intersection lie on the domain boundary (aka the boundary intersection // of // the macro entity this local grid belongs to. Therefore @@ -1073,9 +1074,9 @@ public: prepare_local_vtk_writers(); } // GluedVTKWriter(...) - GluedVTKWriter(const GluedGridType& glued_grid, const std::vector<int>& local_levels) + GluedVTKWriter(const GluedGridType& glued_grid, std::vector<int> local_levels) : glued_grid_(glued_grid) - , local_levels_(local_levels) + , local_levels_(std::move(local_levels)) { for (size_t ss = 0; ss < glued_grid_.num_subdomains(); ++ss) if (local_levels_[ss] < 0) diff --git a/dune/xt/grid/filters/element.hh b/dune/xt/grid/filters/element.hh index b19a13eb4..c3ac44404 100644 --- a/dune/xt/grid/filters/element.hh +++ b/dune/xt/grid/filters/element.hh @@ -19,6 +19,7 @@ #include <dune/xt/grid/boundaryinfo.hh> #include <dune/xt/grid/type_traits.hh> #include <dune/grid/common/partitionset.hh> +#include <utility> #include "base.hh" @@ -129,7 +130,7 @@ public: using GenericFunctionType = std::function<bool(const GridViewType&, const ElementType&)>; explicit GenericFilteredElements(GenericFunctionType lambda) - : filter_(lambda) + : filter_(std::move(lambda)) {} ElementFilter<GridViewType>* copy() const final diff --git a/dune/xt/grid/filters/intersection.hh b/dune/xt/grid/filters/intersection.hh index 9036f6d56..2fc1d8f34 100644 --- a/dune/xt/grid/filters/intersection.hh +++ b/dune/xt/grid/filters/intersection.hh @@ -22,6 +22,7 @@ #include <dune/xt/grid/boundaryinfo.hh> #include <dune/xt/grid/print.hh> #include <dune/xt/grid/type_traits.hh> +#include <utility> #include <dune/xt/grid/print.hh> #include "base.hh" @@ -511,7 +512,7 @@ public: using GenericFunctionType = std::function<bool(const GridViewType&, const IntersectionType&)>; explicit GenericFilteredIntersections(GenericFunctionType func) - : filter_(func) + : filter_(std::move(func)) {} IntersectionFilter<GridViewType>* copy() const final @@ -559,12 +560,12 @@ public: {} explicit CustomBoundaryIntersections(const BoundaryInfo<IntersectionType>& boundary_info, - const std::shared_ptr<BoundaryType>& boundary_type, + std::shared_ptr<BoundaryType> boundary_type, const std::string& logging_prefix = "", const std::array<bool, 3>& logging_state = Common::default_logger_state()) : BaseType(logging_prefix.empty() ? "xt.grid.customboundaryintersections" : logging_prefix, logging_state) , boundary_info_(boundary_info) - , boundary_type_(boundary_type) + , boundary_type_(std::move(boundary_type)) {} CustomBoundaryIntersections(const ThisType& other) @@ -618,9 +619,9 @@ public: {} explicit CustomBoundaryAndProcessIntersections(const BoundaryInfo<IntersectionType>& boundary_info, - const std::shared_ptr<BoundaryType>& boundary_type) + std::shared_ptr<BoundaryType> boundary_type) : boundary_info_(boundary_info) - , boundary_type_(boundary_type) + , boundary_type_(std::move(boundary_type)) {} IntersectionFilter<GridViewType>* copy() const final diff --git a/dune/xt/grid/functors/generic.hh b/dune/xt/grid/functors/generic.hh index e4ce0adb1..40462320f 100644 --- a/dune/xt/grid/functors/generic.hh +++ b/dune/xt/grid/functors/generic.hh @@ -37,7 +37,7 @@ public: GenericApplyFunctionType apply_func, GenericFinalizeFunctionType finalize_func) : prepare_func_(std::move(prepare_func)) - , apply_func_(apply_func) + , apply_func_(std::move(apply_func)) , finalize_func_(std::move(finalize_func)) {} @@ -87,7 +87,7 @@ public: GenericApplyFunctionType apply_func, GenericFinalizeFunctionType finalize_func) : prepare_func_(std::move(prepare_func)) - , apply_func_(apply_func) + , apply_func_(std::move(apply_func)) , finalize_func_(std::move(finalize_func)) {} diff --git a/dune/xt/grid/gridprovider/provider.hh b/dune/xt/grid/gridprovider/provider.hh index 32c6c8694..0ca410710 100644 --- a/dune/xt/grid/gridprovider/provider.hh +++ b/dune/xt/grid/gridprovider/provider.hh @@ -35,6 +35,7 @@ #include <dune/xt/grid/layers.hh> #include <dune/xt/grid/type_traits.hh> #include <dune/xt/grid/output/entity_visualization.hh> +#include <utility> namespace Dune::XT::Grid { @@ -69,7 +70,7 @@ public: {} GridProvider(std::shared_ptr<GridType> grd_ptr) - : grid_ptr_(grd_ptr) + : grid_ptr_(std::move(grd_ptr)) {} #if DUNE_VERSION_EQUAL(DUNE_COMMON, 2, 7) diff --git a/dune/xt/grid/output/entity_visualization.hh b/dune/xt/grid/output/entity_visualization.hh index 449d81d47..0b1d8e8b7 100644 --- a/dune/xt/grid/output/entity_visualization.hh +++ b/dune/xt/grid/output/entity_visualization.hh @@ -60,12 +60,12 @@ struct ElementVisualization { public: using Element = extract_entity_t<GridViewType>; - FunctorBase(std::string filename = "Functor", const std::string& dirname = ".") + FunctorBase(std::string filename = "Functor", std::string dirname = ".") : filename_(std::move(filename)) - , dir_(dirname) + , dir_(std::move(dirname)) {} - virtual ~FunctorBase() {} + virtual ~FunctorBase() = default; const std::string filename() const { diff --git a/dune/xt/grid/output/pgf.hh b/dune/xt/grid/output/pgf.hh index be79c2ab1..95a609efa 100644 --- a/dune/xt/grid/output/pgf.hh +++ b/dune/xt/grid/output/pgf.hh @@ -23,6 +23,7 @@ #include <dune/xt/grid/functors/interfaces.hh> #include <dune/xt/grid/functors/bounding-box.hh> #include <dune/xt/grid/walker.hh> +#include <utility> namespace Dune::XT::Grid { @@ -101,10 +102,10 @@ class PgfEntityFunctorIntersections : public ElementAndIntersectionFunctor<GridV public: PgfEntityFunctorIntersections(const GridViewType& grid_view, std::ostream& file, - const std::string& color = "black", + std::string color = "black", const bool print_entityIndex = false) : file_(file) - , color_(color) + , color_(std::move(color)) , print_entityIndex_(print_entityIndex) , grid_view_(grid_view) {} diff --git a/dune/xt/grid/parallel/partitioning/ranged-internal.hh b/dune/xt/grid/parallel/partitioning/ranged-internal.hh index ca932faef..515b2870c 100644 --- a/dune/xt/grid/parallel/partitioning/ranged-internal.hh +++ b/dune/xt/grid/parallel/partitioning/ranged-internal.hh @@ -48,10 +48,10 @@ namespace Dune::XT::Grid { //! construct RangedPartitioning(const GridView &gv, Size partitions) { - const Iterator end = gv.template end<0, pit>(); + const auto end = gv.template end<0, pit>(); // GridView's size() would return the wrong count for non AllPartition Views/Iterators const auto totalsize = std::distance(gv.template begin<0, pit>(), end); - Iterator it = gv.template begin<0, pit>(); + auto it = gv.template begin<0, pit>(); entry_points_.reserve(partitions + 1); stride_ = totalsize / partitions; overflow_ = totalsize % partitions; diff --git a/dune/xt/la/container/common/vector/dense.hh b/dune/xt/la/container/common/vector/dense.hh index 2fc05b8e9..6c384eed7 100644 --- a/dune/xt/la/container/common/vector/dense.hh +++ b/dune/xt/la/container/common/vector/dense.hh @@ -20,6 +20,7 @@ #include <mutex> #include <numeric> #include <type_traits> +#include <utility> #include <vector> #include <dune/common/dynvector.hh> @@ -323,7 +324,7 @@ public: {} explicit CommonDenseVector(std::shared_ptr<BackendType> backend_ptr, const size_t num_mutexes = 1) - : backend_(backend_ptr) + : backend_(std::move(backend_ptr)) , mutexes_(std::make_unique<MutexesType>(num_mutexes)) {} diff --git a/dune/xt/la/container/container-interface.hh b/dune/xt/la/container/container-interface.hh index 167949ebe..1ab8f0723 100644 --- a/dune/xt/la/container/container-interface.hh +++ b/dune/xt/la/container/container-interface.hh @@ -110,7 +110,7 @@ public: static_assert(std::is_same<ScalarType, typename Traits::ScalarType>::value); ContainerInterface() = default; - virtual ~ContainerInterface() {} + virtual ~ContainerInterface() = default; ThisType& operator=(const ThisType& other) { diff --git a/dune/xt/la/container/eigen/dense.hh b/dune/xt/la/container/eigen/dense.hh index 4d93a45c3..fb73b6f17 100644 --- a/dune/xt/la/container/eigen/dense.hh +++ b/dune/xt/la/container/eigen/dense.hh @@ -15,6 +15,7 @@ #include <memory> #include <type_traits> +#include <utility> #include <vector> #include <initializer_list> #include <complex> @@ -475,7 +476,7 @@ public: {} explicit EigenDenseMatrix(std::shared_ptr<BackendType> backend_ptr, const size_t num_mutexes = 1) - : backend_(backend_ptr) + : backend_(std::move(backend_ptr)) , mutexes_(std::make_unique<MutexesType>(num_mutexes)) {} diff --git a/dune/xt/la/container/eigen/sparse.hh b/dune/xt/la/container/eigen/sparse.hh index 2762ff51a..f9e8953f9 100644 --- a/dune/xt/la/container/eigen/sparse.hh +++ b/dune/xt/la/container/eigen/sparse.hh @@ -15,6 +15,7 @@ #include <memory> #include <type_traits> +#include <utility> #include <vector> #include <complex> #include <mutex> @@ -201,7 +202,7 @@ public: {} explicit EigenRowMajorSparseMatrix(std::shared_ptr<BackendType> backend_ptr, const size_t num_mutexes = 1) - : backend_(backend_ptr) + : backend_(std::move(backend_ptr)) , mutexes_(std::make_unique<MutexesType>(num_mutexes)) {} diff --git a/dune/xt/la/container/istl.hh b/dune/xt/la/container/istl.hh index db7210074..60f910274 100644 --- a/dune/xt/la/container/istl.hh +++ b/dune/xt/la/container/istl.hh @@ -14,6 +14,7 @@ #ifndef DUNE_XT_LA_CONTAINER_ISTL_HH #define DUNE_XT_LA_CONTAINER_ISTL_HH +#include <utility> #include <vector> #include <initializer_list> #include <complex> @@ -155,7 +156,7 @@ public: {} explicit IstlDenseVector(std::shared_ptr<BackendType> backend_ptr, const size_t num_mutexes = 1) - : backend_(backend_ptr) + : backend_(std::move(backend_ptr)) , mutexes_(std::make_unique<MutexesType>(num_mutexes)) {} @@ -466,7 +467,7 @@ public: {} explicit IstlRowMajorSparseMatrix(std::shared_ptr<BackendType> backend_ptr, const size_t num_mutexes = 1) - : backend_(backend_ptr) + : backend_(std::move(backend_ptr)) , mutexes_(std::make_unique<MutexesType>(num_mutexes)) {} diff --git a/dune/xt/la/container/matrix-market.hh b/dune/xt/la/container/matrix-market.hh index 1e9efd7cb..ff3c5263f 100644 --- a/dune/xt/la/container/matrix-market.hh +++ b/dune/xt/la/container/matrix-market.hh @@ -48,8 +48,8 @@ MatrixType read_matrix_market_array_format(std::ifstream& matrix_file, boost::algorithm::split( matrix_dimensions, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); DUNE_THROW_IF(matrix_dimensions.size() != 2, Dune::IOError, "Could not read matrix dimensions!"); - const size_t rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); - const size_t cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); + const auto rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); + const auto cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); MatrixType ret = M::create(rows, cols, 0., XT::LA::dense_pattern(rows, cols)); DUNE_THROW_IF(!is_general && rows != cols, Dune::InvalidStateException, @@ -126,9 +126,9 @@ MatrixType read_matrix_market_coordinate_format(std::ifstream& matrix_file, boost::algorithm::split( matrix_dimensions, curr_line, boost::algorithm::is_space(), boost::algorithm::token_compress_on); DUNE_THROW_IF(matrix_dimensions.size() != 3, Dune::IOError, "Could not read matrix dimensions!"); - const size_t rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); - const size_t cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); - const size_t nnz = XT::Common::from_string<size_t>(matrix_dimensions[2]); + const auto rows = XT::Common::from_string<size_t>(matrix_dimensions[0]); + const auto cols = XT::Common::from_string<size_t>(matrix_dimensions[1]); + const auto nnz = XT::Common::from_string<size_t>(matrix_dimensions[2]); // read entries std::vector<std::tuple<size_t, size_t, ScalarType>> entries(nnz); const size_t expected_entry_size = field_qualifier_is_complex ? 4 : 3; diff --git a/dune/xt/la/container/matrix-view.hh b/dune/xt/la/container/matrix-view.hh index 619f84a9c..084f280af 100644 --- a/dune/xt/la/container/matrix-view.hh +++ b/dune/xt/la/container/matrix-view.hh @@ -82,10 +82,6 @@ public: const ScalarType /*value*/ = ScalarType(0), const size_t /*num_mutexes*/ = 1) : matrix_(internal::empty_matrix_ref<MatrixImp>()) - , first_row_(0) - , past_last_row_(0) - , first_col_(0) - , past_last_col_(0) , pattern_(nullptr) { DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, "This constructor does not make sense for MatrixView"); @@ -97,10 +93,6 @@ public: const SparsityPatternDefault& /*pattern*/, const size_t /*num_mutexes*/ = 1) : matrix_(internal::empty_matrix_ref<MatrixImp>()) - , first_row_(0) - , past_last_row_(0) - , first_col_(0) - , past_last_col_(0) , pattern_(nullptr) { DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, "This constructor does not make sense for MatrixView"); @@ -126,10 +118,6 @@ public: // However, the MatrixInterface does not compile for non-copyable types, so we fail at runtime here. ConstMatrixView(const ThisType& other) : matrix_(other.matrix_) - , first_row_(0) - , past_last_row_(0) - , first_col_(0) - , past_last_col_(0) , pattern_(nullptr) { DUNE_THROW(Dune::NotImplemented, "Copying is disabled, simply create a new view!"); @@ -292,10 +280,10 @@ public: private: const Matrix& matrix_; - const size_t first_row_; - const size_t past_last_row_; - const size_t first_col_; - const size_t past_last_col_; + const size_t first_row_{0}; + const size_t past_last_row_{0}; + const size_t first_col_{0}; + const size_t past_last_col_{0}; std::shared_ptr<std::once_flag> pattern_init_flag_; mutable std::shared_ptr<SparsityPatternDefault> pattern_; }; // class ConstMatrixView diff --git a/dune/xt/la/container/vector-array/list.hh b/dune/xt/la/container/vector-array/list.hh index 9ba86ee0e..f7422334c 100644 --- a/dune/xt/la/container/vector-array/list.hh +++ b/dune/xt/la/container/vector-array/list.hh @@ -27,7 +27,7 @@ namespace LA { template <class Vector> class ListVectorArray { - static_assert(is_vector<Vector>::value, ""); + static_assert(is_vector<Vector>::value); public: using ThisType = ListVectorArray; diff --git a/dune/xt/la/container/vector-interface.hh b/dune/xt/la/container/vector-interface.hh index 3ba3f1531..9c02c2950 100644 --- a/dune/xt/la/container/vector-interface.hh +++ b/dune/xt/la/container/vector-interface.hh @@ -82,7 +82,7 @@ public: friend iterator; static_assert(std::is_same<ScalarType, typename Traits::ScalarType>::value); - ~VectorInterface() override {} + ~VectorInterface() override = default; template <class Vector> std::enable_if_t<Common::is_vector<Vector>::value, derived_type&> assign_from(const Vector& other) diff --git a/dune/xt/la/container/vector-view.hh b/dune/xt/la/container/vector-view.hh index 4908b44a9..f518566a7 100644 --- a/dune/xt/la/container/vector-view.hh +++ b/dune/xt/la/container/vector-view.hh @@ -100,8 +100,7 @@ public: const ScalarType /*value*/ = ScalarType(0), const size_t /*num_mutexes*/ = 1) : vector_(internal::empty_vector_ref<VectorImp>()) - , first_entry_(0) - , past_last_entry_(0) + { DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, "This constructor does not make sense for VectorView"); } @@ -254,8 +253,8 @@ private: friend class VectorInterface<internal::ConstVectorViewTraits<VectorImp>, ScalarType>; const Vector& vector_; - const size_t first_entry_; - const size_t past_last_entry_; + const size_t first_entry_{0}; + const size_t past_last_entry_{0}; }; // class ConstVectorView diff --git a/dune/xt/la/eigen-solver/default.hh b/dune/xt/la/eigen-solver/default.hh index 9294b4379..06076cff7 100644 --- a/dune/xt/la/eigen-solver/default.hh +++ b/dune/xt/la/eigen-solver/default.hh @@ -36,8 +36,8 @@ public: { std::vector<std::string> tps; if (Common::Lapacke::available()) - tps.push_back("lapack"); - tps.push_back("shifted_qr"); + tps.emplace_back("lapack"); + tps.emplace_back("shifted_qr"); return tps; } diff --git a/dune/xt/la/eigen-solver/eigen.hh b/dune/xt/la/eigen-solver/eigen.hh index be7b3cdb2..72cfa7f2c 100644 --- a/dune/xt/la/eigen-solver/eigen.hh +++ b/dune/xt/la/eigen-solver/eigen.hh @@ -40,8 +40,8 @@ public: { std::vector<std::string> tps = {"eigen"}; if (Common::Lapacke::available()) - tps.push_back("lapack"); - tps.push_back("shifted_qr"); + tps.emplace_back("lapack"); + tps.emplace_back("shifted_qr"); return tps; } diff --git a/dune/xt/la/eigen-solver/fmatrix.hh b/dune/xt/la/eigen-solver/fmatrix.hh index 3c2d66c79..03d405d1e 100644 --- a/dune/xt/la/eigen-solver/fmatrix.hh +++ b/dune/xt/la/eigen-solver/fmatrix.hh @@ -47,13 +47,13 @@ public: { std::vector<std::string> tps; if (Common::Lapacke::available()) - tps.push_back("lapack"); + tps.emplace_back("lapack"); #if HAVE_EIGEN - tps.push_back("eigen"); + tps.emplace_back("eigen"); #endif if (internal::numpy_eigensolver_available()) - tps.push_back("numpy"); - tps.push_back("shifted_qr"); + tps.emplace_back("numpy"); + tps.emplace_back("shifted_qr"); return tps; } diff --git a/dune/xt/la/generalized-eigen-solver/default.hh b/dune/xt/la/generalized-eigen-solver/default.hh index aeeb4c532..9c8bdba6c 100644 --- a/dune/xt/la/generalized-eigen-solver/default.hh +++ b/dune/xt/la/generalized-eigen-solver/default.hh @@ -35,7 +35,7 @@ public: { std::vector<std::string> tps; if (Common::Lapacke::available()) - tps.push_back("lapack"); + tps.emplace_back("lapack"); DUNE_THROW_IF(tps.empty(), Exceptions::generalized_eigen_solver_failed, "No backend available for generalized eigenvalue problems!"); diff --git a/dune/xt/la/solver/istl.hh b/dune/xt/la/solver/istl.hh index 801200ba7..a5eb9b2e8 100644 --- a/dune/xt/la/solver/istl.hh +++ b/dune/xt/la/solver/istl.hh @@ -120,7 +120,7 @@ public: ret.insert(ret.begin(), "superlu"); #endif #if HAVE_UMFPACK - ret.push_back("umfpack"); + ret.emplace_back("umfpack"); #endif } return ret; diff --git a/dune/xt/test/common/configuration.cc b/dune/xt/test/common/configuration.cc index 2ccb80e82..d4d5eb80c 100644 --- a/dune/xt/test/common/configuration.cc +++ b/dune/xt/test/common/configuration.cc @@ -206,7 +206,7 @@ struct ConfigTest : public testing::Test , keys(boost::assign::list_of<std::string>().repeat_fun(values.size() - 1, key_gen)) {} - ~ConfigTest() override {} + ~ConfigTest() override = default; void get() { diff --git a/dune/xt/test/common/tuple.cc b/dune/xt/test/common/tuple.cc index 64dd6c7b2..f192af16d 100644 --- a/dune/xt/test/common/tuple.cc +++ b/dune/xt/test/common/tuple.cc @@ -82,16 +82,16 @@ void type_call() if constexpr (std::tuple_size_v<Tuple> == 3) { using TupleElement = typename Dune::XT::Common::list_content<Tuple>::template head<int, int>; using Type = typename TupleElement::type; - static_assert(std::is_same<TupleElement, tplA<int, int>>::value, ""); - static_assert(std::is_same<Type, int>::value, ""); + static_assert(std::is_same<TupleElement, tplA<int, int>>::value); + static_assert(std::is_same<Type, int>::value); } else if constexpr (std::tuple_size_v<Tuple> == 2) { using TupleElement = typename Dune::XT::Common::list_content<Tuple>::template head<int, int>; using Type = typename TupleElement::type; - static_assert(std::is_same<TupleElement, tplB<int, int>>::value, ""); - static_assert(std::is_same<Type, int>::value, ""); + static_assert(std::is_same<TupleElement, tplB<int, int>>::value); + static_assert(std::is_same<Type, int>::value); } else if constexpr (std::tuple_size_v<Tuple> == 1) { using TupleElement = typename Dune::XT::Common::list_content<Tuple>::template head<int, int>; - static_assert(std::is_same<TupleElement, int>::value, ""); + static_assert(std::is_same<TupleElement, int>::value); } using Tail = typename Tuple::template tail_type<int, int>; diff --git a/dune/xt/test/grid/periodic_gridview.cc b/dune/xt/test/grid/periodic_gridview.cc index 01567abf9..6ff220e88 100644 --- a/dune/xt/test/grid/periodic_gridview.cc +++ b/dune/xt/test/grid/periodic_gridview.cc @@ -52,8 +52,8 @@ struct PeriodicViewTest : public testing::Test Configuration grid_config = DXTC_CONFIG.sub("test_grid_periodicview"); const bool is_simplex = Common::from_string<bool>(grid_config["is_simplex"]); const bool is_cube = !is_simplex; - const DomainType lower_left = Common::from_string<DomainType>(grid_config["lower_left"]); - const DomainType upper_right = Common::from_string<DomainType>(grid_config["upper_right"]); + const auto lower_left = Common::from_string<DomainType>(grid_config["lower_left"]); + const auto upper_right = Common::from_string<DomainType>(grid_config["upper_right"]); const auto num_elements = Common::from_string<std::array<unsigned int, dimDomain>>(grid_config["num_elements"]); for (const auto& elements : num_elements) if (elements != num_elements[0]) @@ -74,7 +74,7 @@ struct PeriodicViewTest : public testing::Test // create periodic grid_view std::bitset<dimDomain> periodic_directions; if (is_partially_periodic) - periodic_directions[0] = 1; + periodic_directions[0] = true; else if (!is_nonperiodic) periodic_directions.set(); const PeriodicGridViewType periodic_grid_view(grid_view, periodic_directions); diff --git a/dune/xt/test/la/eigensolver.hh b/dune/xt/test/la/eigensolver.hh index f46f3bda9..d1df36126 100644 --- a/dune/xt/test/la/eigensolver.hh +++ b/dune/xt/test/la/eigensolver.hh @@ -45,8 +45,7 @@ struct EigenSolverTest : public ::testing::Test using M = Common::MatrixAbstraction<MatrixType>; EigenSolverTest() - : all_matrices_and_expected_eigenvalues_and_vectors_are_computed_(false) - , broken_matrix_(M::create(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) + : broken_matrix_(M::create(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) , unit_matrix_( eye_matrix<MatrixType>(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) { @@ -229,7 +228,7 @@ struct EigenSolverTest : public ::testing::Test } } // ... gives_correct_eigendecomposition(...) - bool all_matrices_and_expected_eigenvalues_and_vectors_are_computed_; + bool all_matrices_and_expected_eigenvalues_and_vectors_are_computed_{false}; MatrixType broken_matrix_; MatrixType unit_matrix_; MatrixType matrix_; diff --git a/dune/xt/test/la/generalized-eigensolver.hh b/dune/xt/test/la/generalized-eigensolver.hh index 6ace429d6..59584d46d 100644 --- a/dune/xt/test/la/generalized-eigensolver.hh +++ b/dune/xt/test/la/generalized-eigensolver.hh @@ -43,8 +43,7 @@ struct GeneralizedEigenSolverTest : public ::testing::Test using M = Common::MatrixAbstraction<MatrixType>; GeneralizedEigenSolverTest() - : all_matrices_and_expected_eigenvalues_and_vectors_are_computed_(false) - , broken_matrix_(M::create(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) + : broken_matrix_(M::create(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) , unit_matrix_( eye_matrix<MatrixType>(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) { @@ -195,7 +194,7 @@ struct GeneralizedEigenSolverTest : public ::testing::Test } } // ... gives_correct_eigenvalues(...) - bool all_matrices_and_expected_eigenvalues_and_vectors_are_computed_; + bool all_matrices_and_expected_eigenvalues_and_vectors_are_computed_{false}; MatrixType broken_matrix_; MatrixType unit_matrix_; MatrixType matrix_; diff --git a/dune/xt/test/la/matrixinverter.hh b/dune/xt/test/la/matrixinverter.hh index 58fe6be18..0034da55a 100644 --- a/dune/xt/test/la/matrixinverter.hh +++ b/dune/xt/test/la/matrixinverter.hh @@ -35,8 +35,7 @@ struct MatrixInverterTest : public ::testing::Test using ScalarType = typename M::ScalarType; MatrixInverterTest() - : all_matrices_and_inverse_matrices_are_computed_(false) - , broken_matrix_(M::create(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) + : broken_matrix_(M::create(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) , unit_matrix_( eye_matrix<MatrixType>(M::has_static_size ? M::static_rows : 1, M::has_static_size ? M::static_cols : 1)) { @@ -145,7 +144,7 @@ struct MatrixInverterTest : public ::testing::Test } - bool all_matrices_and_inverse_matrices_are_computed_; + bool all_matrices_and_inverse_matrices_are_computed_{false}; MatrixType broken_matrix_; MatrixType unit_matrix_; MatrixType matrix_; diff --git a/python/dune/xt/common/empty.cc b/python/dune/xt/common/empty.cc index 27834f619..43b381843 100644 --- a/python/dune/xt/common/empty.cc +++ b/python/dune/xt/common/empty.cc @@ -12,6 +12,7 @@ #include "config.h" #include <string> +#include <utility> #include <vector> #include <dune/common/parallel/mpihelper.hh> @@ -25,8 +26,8 @@ struct Pet { - Pet(const std::string& name_) - : name(name_) + Pet(std::string name_) + : name(std::move(name_)) {} void setName(const std::string& name_) { diff --git a/python/dune/xt/functions/spe10.hh b/python/dune/xt/functions/spe10.hh index 9016fb9b2..af7e1398f 100644 --- a/python/dune/xt/functions/spe10.hh +++ b/python/dune/xt/functions/spe10.hh @@ -147,7 +147,7 @@ void bind_Spe10Model1Function(pybind11::module& m, const std::string& grid_id) template <class G> auto bind_Spe10Model2Function(pybind11::module& m, const std::string& grid_id) { - static_assert(G::dimension == 3, ""); + static_assert(G::dimension == 3); namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/grid/element.cc b/python/dune/xt/grid/element.cc index fc7c0307b..3a1f34e86 100644 --- a/python/dune/xt/grid/element.cc +++ b/python/dune/xt/grid/element.cc @@ -79,7 +79,7 @@ public: }); c.def_property_readonly("corners", [](type& self) { using XT::Common::numeric_cast; - const size_t num_corners = numeric_cast<size_t>(self.geometry().corners()); + const auto num_corners = numeric_cast<size_t>(self.geometry().corners()); py::array_t<double> result(/*shape=*/{num_corners, d}); auto access_to_result = result.mutable_unchecked<2>(); for (size_t cc = 0; cc < num_corners; ++cc) { -- GitLab From 4eb355a9dfd8e0f4c264f9b722f403824ecabff3 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 09:54:26 +0100 Subject: [PATCH 07/19] [clang-tidy] apply misc-redundant-expression, misc-static-assert, misc-unused-alias-decls, misc-unused-parameters, misc-unused-using-decls --- dune/xt/test/common/configuration.cc | 1 - dune/xt/test/common/float_cmp.cc | 1 - python/dune/xt/common/logging.cc | 1 - python/dune/xt/common/timedlogging.cc | 1 - python/dune/xt/functions/expression.cc | 4 ---- python/dune/xt/functions/gridfunction.cc | 4 ---- python/dune/xt/grid/dd_glued_gridprovider/cube.cc | 3 +-- python/dune/xt/grid/dd_glued_gridprovider/provider.cc | 2 -- python/dune/xt/grid/element.cc | 2 +- python/dune/xt/grid/functors/boundary-detector.cc | 6 ++---- python/dune/xt/grid/gridprovider/cube.cc | 2 -- python/dune/xt/grid/gridprovider/gmsh.cc | 1 - python/dune/xt/grid/intersection.cc | 5 ++--- 13 files changed, 6 insertions(+), 27 deletions(-) diff --git a/dune/xt/test/common/configuration.cc b/dune/xt/test/common/configuration.cc index d4d5eb80c..36669cdd2 100644 --- a/dune/xt/test/common/configuration.cc +++ b/dune/xt/test/common/configuration.cc @@ -38,7 +38,6 @@ std::ostream& test_out = DXTC_LOG.devnull(); using namespace Dune::XT::Common; -using Dune::XT::Common::Exceptions::results_are_not_as_expected; using namespace Dune::XT::Common::FloatCmp; struct CreateByOperator diff --git a/dune/xt/test/common/float_cmp.cc b/dune/xt/test/common/float_cmp.cc index 2a39f0e40..fb7203a38 100644 --- a/dune/xt/test/common/float_cmp.cc +++ b/dune/xt/test/common/float_cmp.cc @@ -26,7 +26,6 @@ #include <dune/xt/common/fmatrix.hh> using namespace Dune; -using XT::Common::create; using XT::Common::FloatCmp::Style; // add operator+= for std::array and std::vector diff --git a/python/dune/xt/common/logging.cc b/python/dune/xt/common/logging.cc index 7bb15e36c..5554a8300 100644 --- a/python/dune/xt/common/logging.cc +++ b/python/dune/xt/common/logging.cc @@ -25,7 +25,6 @@ PYBIND11_MODULE(logging, m) { - namespace py = pybind11; using namespace pybind11::literals; using namespace Dune::XT::Common; diff --git a/python/dune/xt/common/timedlogging.cc b/python/dune/xt/common/timedlogging.cc index c77a9e576..f10b758a4 100644 --- a/python/dune/xt/common/timedlogging.cc +++ b/python/dune/xt/common/timedlogging.cc @@ -20,7 +20,6 @@ PYBIND11_MODULE(timedlogging, m) { - namespace py = pybind11; using namespace pybind11::literals; using namespace Dune::XT::Common; diff --git a/python/dune/xt/functions/expression.cc b/python/dune/xt/functions/expression.cc index 51544a9c2..c63e2af09 100644 --- a/python/dune/xt/functions/expression.cc +++ b/python/dune/xt/functions/expression.cc @@ -69,7 +69,6 @@ class ExpressionFunction static void factory(pybind11::module& m, const std::string& ClassId) { - namespace py = pybind11; using namespace pybind11::literals; m.def( @@ -128,7 +127,6 @@ class ExpressionFunction static void factory(pybind11::module& m, const std::string& ClassId) { - namespace py = pybind11; using namespace pybind11::literals; m.def( @@ -197,7 +195,6 @@ class ExpressionFunction static void factory(pybind11::module& m, const std::string& ClassId) { - namespace py = pybind11; using namespace pybind11::literals; m.def( @@ -237,7 +234,6 @@ class ExpressionFunction public: static bound_type bind(pybind11::module& m, const std::string& class_id = "expression_function") { - namespace py = pybind11; using namespace pybind11::literals; std::string class_name = class_id + "_" + Common::to_string(d) + "_to_" + Common::to_string(r); diff --git a/python/dune/xt/functions/gridfunction.cc b/python/dune/xt/functions/gridfunction.cc index b24818e8c..8bd845be6 100644 --- a/python/dune/xt/functions/gridfunction.cc +++ b/python/dune/xt/functions/gridfunction.cc @@ -70,7 +70,6 @@ private: static void factory(pybind11::module& m, const std::string& FactoryName) { - namespace py = pybind11; using namespace pybind11::literals; // without dimRange @@ -169,7 +168,6 @@ private: static void factory(pybind11::module& m, const std::string& FactoryName) { - namespace py = pybind11; using namespace pybind11::literals; // without dimRange @@ -336,7 +334,6 @@ private: static void factory(pybind11::module& m, const std::string& FactoryName) { - namespace py = pybind11; using namespace pybind11::literals; // without dimRange @@ -468,7 +465,6 @@ private: static void factory(pybind11::module& m, const std::string& FactoryName) { - namespace py = pybind11; using namespace pybind11::literals; // we have the scalar variants ... diff --git a/python/dune/xt/grid/dd_glued_gridprovider/cube.cc b/python/dune/xt/grid/dd_glued_gridprovider/cube.cc index e83e26611..ad41bd8d5 100644 --- a/python/dune/xt/grid/dd_glued_gridprovider/cube.cc +++ b/python/dune/xt/grid/dd_glued_gridprovider/cube.cc @@ -28,7 +28,6 @@ struct make_cube_dd_grid { static void bind(pybind11::module& m) { - namespace py = pybind11; using namespace pybind11::literals; m.def( @@ -39,7 +38,7 @@ struct make_cube_dd_grid }, "macro_grid"_a, "num_refinements"_a = 0, - py::keep_alive<0, 1>()); + pybind11::keep_alive<0, 1>()); } // ... bind(...) }; // struct make_cube_dd_grid<...> diff --git a/python/dune/xt/grid/dd_glued_gridprovider/provider.cc b/python/dune/xt/grid/dd_glued_gridprovider/provider.cc index 8d6e8213f..a45a29794 100644 --- a/python/dune/xt/grid/dd_glued_gridprovider/provider.cc +++ b/python/dune/xt/grid/dd_glued_gridprovider/provider.cc @@ -214,7 +214,6 @@ public: const std::string& grid_id = grid_name<typename CGV::MacroGridType>::value(), const std::string& class_id = "coupling_grid_provider") { - namespace py = pybind11; using namespace pybind11::literals; const std::string class_name = class_id + "_" + grid_id; @@ -239,7 +238,6 @@ struct MacroGridBasedBoundaryInfo const std::string& grid_id = grid_name<G>::value(), const std::string& class_id = "macro_grid_based_boundary_info") { - namespace py = pybind11; using namespace pybind11::literals; const std::string class_name = class_id + "_" + grid_id; const auto ClassName = XT::Common::to_camel_case(class_name); diff --git a/python/dune/xt/grid/element.cc b/python/dune/xt/grid/element.cc index 3a1f34e86..efc607261 100644 --- a/python/dune/xt/grid/element.cc +++ b/python/dune/xt/grid/element.cc @@ -47,7 +47,7 @@ public: const std::string& grid_id = XT::Grid::bindings::grid_name<G>::value(), const std::string& layer_id = "") { - namespace py = pybind11; + namespace py = pybind11; // NOLINT(misc-unused-alias-decls) using namespace pybind11::literals; std::string class_name = class_id; diff --git a/python/dune/xt/grid/functors/boundary-detector.cc b/python/dune/xt/grid/functors/boundary-detector.cc index a829d3092..bfef610a4 100644 --- a/python/dune/xt/grid/functors/boundary-detector.cc +++ b/python/dune/xt/grid/functors/boundary-detector.cc @@ -81,7 +81,6 @@ public: static void bind_leaf_factory(pybind11::module& m, const std::string& class_id = "boundary_detector_functor") { - namespace py = pybind11; using namespace pybind11::literals; m.def( Common::to_camel_case(class_id).c_str(), @@ -95,12 +94,11 @@ public: "boundary_info"_a, "boundary_type"_a, "logging_prefix"_a = "", - py::keep_alive<0, 2>()); + pybind11::keep_alive<0, 2>()); } // ... bind_leaf_factory(...) static void bind_coupling_factory(pybind11::module& m, const std::string& class_id = "boundary_detector_functor") { - namespace py = pybind11; using namespace pybind11::literals; m.def( Common::to_camel_case(class_id).c_str(), @@ -114,7 +112,7 @@ public: "boundary_info"_a, "boundary_type"_a, "logging_prefix"_a = "", - py::keep_alive<0, 2>()); + pybind11::keep_alive<0, 2>()); } // ... bind_coupling_factory(...) }; // class BoundaryDetectorFunctor diff --git a/python/dune/xt/grid/gridprovider/cube.cc b/python/dune/xt/grid/gridprovider/cube.cc index 1b18c8b12..30b40671f 100644 --- a/python/dune/xt/grid/gridprovider/cube.cc +++ b/python/dune/xt/grid/gridprovider/cube.cc @@ -28,7 +28,6 @@ struct make_cube_grid { static void bind(pybind11::module& m) { - namespace py = pybind11; using namespace pybind11::literals; using D = typename G::ctype; static constexpr size_t d = G::dimension; @@ -60,7 +59,6 @@ struct make_cube_grid<G, void> { static void bind(pybind11::module& m) { - namespace py = pybind11; using namespace pybind11::literals; using D = typename G::ctype; static constexpr size_t d = G::dimension; diff --git a/python/dune/xt/grid/gridprovider/gmsh.cc b/python/dune/xt/grid/gridprovider/gmsh.cc index ae4ef9ffb..f4a099da1 100644 --- a/python/dune/xt/grid/gridprovider/gmsh.cc +++ b/python/dune/xt/grid/gridprovider/gmsh.cc @@ -31,7 +31,6 @@ struct make_gmsh_grid static void bind(pybind11::module& m) { - namespace py = pybind11; using namespace pybind11::literals; m.def( diff --git a/python/dune/xt/grid/intersection.cc b/python/dune/xt/grid/intersection.cc index 8f7bcbb3b..3b250733a 100644 --- a/python/dune/xt/grid/intersection.cc +++ b/python/dune/xt/grid/intersection.cc @@ -54,7 +54,6 @@ public: const std::string& layer_id = "", const std::string& class_id = "intersection") { - namespace py = pybind11; using namespace pybind11::literals; std::string class_name = class_id; @@ -85,9 +84,9 @@ public: return ss.str(); }); c.def( - "__eq__", [](type& self, const type& other) { return self == other; }, py::is_operator()); + "__eq__", [](type& self, const type& other) { return self == other; }, pybind11::is_operator()); c.def( - "__neq__", [](type& self, const type& other) { return self != other; }, py::is_operator()); + "__neq__", [](type& self, const type& other) { return self != other; }, pybind11::is_operator()); // methods c.def( -- GitLab From 822c04160e068d0013ee3ab04024a014535bbbed Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 10:50:41 +0100 Subject: [PATCH 08/19] Fix error introduced by clang-tidy --- dune/xt/common/logging.hh | 7 ++++--- dune/xt/common/logstreams.hh | 6 ++---- dune/xt/common/tuple.hh | 3 ++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dune/xt/common/logging.hh b/dune/xt/common/logging.hh index 90638db2a..a90c5c4bd 100644 --- a/dune/xt/common/logging.hh +++ b/dune/xt/common/logging.hh @@ -40,6 +40,10 @@ private: public: ~Logging(); + // satisfy stricter warnings wrt copying + Logging(const Logging&) = delete; + Logging& operator=(const Logging&) = delete; + /** \brief setup loglevel, logfilename * \param logflags any OR'd combination of flags * \param logfile filename for log, can contain paths, but creation will fail if dir is non-existant @@ -138,9 +142,6 @@ private: EmptyLogStream emptyLogStream_; friend Logging& Logger(); - // satisfy stricter warnings wrt copying - Logging(const Logging&) = delete; - Logging& operator=(const Logging&) = delete; }; DUNE_EXPORT inline Logging& Logger() diff --git a/dune/xt/common/logstreams.hh b/dune/xt/common/logstreams.hh index 3f9c953df..bedc475b4 100644 --- a/dune/xt/common/logstreams.hh +++ b/dune/xt/common/logstreams.hh @@ -52,6 +52,7 @@ public: static constexpr PriorityType default_suspend_priority = 0; SuspendableStrBuffer(int loglevel, int& logflags); + SuspendableStrBuffer(const SuspendableStrBuffer&) = delete; /** \brief stop accepting input into the buffer * the suspend_priority_ mechanism provides a way to silence streams from 'higher' modules @@ -77,8 +78,6 @@ private: return (!is_suspended_) && (logflags_ & loglevel_); } - SuspendableStrBuffer(const SuspendableStrBuffer&) = delete; - int& logflags_; int loglevel_; int suspended_logflags_; @@ -150,12 +149,11 @@ class TimedPrefixedStreamBuffer : public std::basic_stringbuf<char, std::char_tr public: TimedPrefixedStreamBuffer(const Timer& timer, std::string prefix, std::ostream& out = std::cout); + TimedPrefixedStreamBuffer(const TimedPrefixedStreamBuffer&) = delete; int sync() override; private: - TimedPrefixedStreamBuffer(const TimedPrefixedStreamBuffer&) = delete; - std::string elapsed_time_str() const; const Timer& timer_; diff --git a/dune/xt/common/tuple.hh b/dune/xt/common/tuple.hh index 55f27e8e2..e4159803c 100644 --- a/dune/xt/common/tuple.hh +++ b/dune/xt/common/tuple.hh @@ -13,6 +13,7 @@ #ifndef DUNE_XT_COMMON_TUPLE_HH #define DUNE_XT_COMMON_TUPLE_HH +#include <tuple> #include <type_traits> #include <utility> @@ -305,7 +306,7 @@ namespace internal { template <std::size_t> struct Any { - Any(...) = default; + Any(...){}; // NOLINT(modernize-use-equals-default) }; template <typename T> -- GitLab From 3849356b31475ed1f9caa5dffe71baf869a2fbbc Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 12:09:45 +0100 Subject: [PATCH 09/19] [clang-tidy] apply additional misc and readability checks --- dune/xt/common/parameter.hh | 2 +- dune/xt/common/string_internal.hh | 2 +- dune/xt/common/timedlogging.hh | 6 +++--- dune/xt/common/type_traits.hh | 4 ++-- dune/xt/common/vector.hh | 3 +-- dune/xt/grid/gridprovider/coupling.hh | 2 +- dune/xt/grid/gridprovider/provider.hh | 2 +- dune/xt/grid/output/entity_visualization.hh | 4 ++-- dune/xt/la/algorithms/cholesky.hh | 4 ++-- dune/xt/la/algorithms/qr.hh | 2 +- dune/xt/la/algorithms/triangular_solves.hh | 2 +- dune/xt/la/container/container-interface.hh | 4 ++-- dune/xt/la/container/eigen/sparse.hh | 4 ++-- dune/xt/la/container/io.hh | 2 +- 14 files changed, 21 insertions(+), 22 deletions(-) diff --git a/dune/xt/common/parameter.hh b/dune/xt/common/parameter.hh index 0ae22c2b4..374ea9ee2 100644 --- a/dune/xt/common/parameter.hh +++ b/dune/xt/common/parameter.hh @@ -109,7 +109,7 @@ protected: { if (dict_.empty()) return "{}"; - DXT_ASSERT(keys_.size() > 0); + DXT_ASSERT(!keys_.empty()); const auto whitespaced_prefix = whitespaceify(prefix); std::stringstream ss; ss << "{" << keys_[0] << ": " << dict_.at(keys_[0]); diff --git a/dune/xt/common/string_internal.hh b/dune/xt/common/string_internal.hh index f944c3d1c..8c04fd5ec 100644 --- a/dune/xt/common/string_internal.hh +++ b/dune/xt/common/string_internal.hh @@ -156,7 +156,7 @@ template <class ComplexType> ComplexType complex_from_string(std::string ss, const size_t /*size*/ = 0, const size_t /*cols*/ = 0) { boost::algorithm::trim(ss); - if (ss.size() < 1) + if (ss.empty()) DUNE_THROW(Exceptions::conversion_error, "Error converting " << ss << " (too short)"); using namespace std; using T = typename ComplexType::value_type; diff --git a/dune/xt/common/timedlogging.hh b/dune/xt/common/timedlogging.hh index 5d2111385..e601966e8 100644 --- a/dune/xt/common/timedlogging.hh +++ b/dune/xt/common/timedlogging.hh @@ -256,15 +256,15 @@ public: static constexpr bool default_enable_warnings = true; static constexpr bool default_enable_colors = true; - static const std::string default_info_color() + static std::string default_info_color() { return "blue"; } - static const std::string default_debug_color() + static std::string default_debug_color() { return "darkgray"; } - static const std::string default_warning_color() + static std::string default_warning_color() { return "red"; } diff --git a/dune/xt/common/type_traits.hh b/dune/xt/common/type_traits.hh index 611a4b5e7..565e5d472 100644 --- a/dune/xt/common/type_traits.hh +++ b/dune/xt/common/type_traits.hh @@ -34,7 +34,7 @@ template <> \ struct Typename<NAME> \ { \ - static const std::string value(bool /*fail_wo_typeid*/ = false) \ + static std::string value(bool /*fail_wo_typeid*/ = false) \ { \ return #NAME; \ } \ @@ -212,7 +212,7 @@ constexpr size_t default_max_highlight_level{1000}; template <class T> void real_type_id(T& obj, const std::string& name = "", size_t maxlevel = default_max_highlight_level) { - std::cout << name << (name == "" ? "" : "'s type is ") << highlight_template(demangled_type_id(obj), maxlevel) + std::cout << name << (name.empty() ? "" : "'s type is ") << highlight_template(demangled_type_id(obj), maxlevel) << std::endl; } diff --git a/dune/xt/common/vector.hh b/dune/xt/common/vector.hh index 9d0e97da5..f55e737e2 100644 --- a/dune/xt/common/vector.hh +++ b/dune/xt/common/vector.hh @@ -166,9 +166,8 @@ struct VectorAbstraction<std::vector<T, Allocator>> , public internal::HasSubscriptOperatorForVectorAbstraction<std::vector<T, Allocator>, T> { static constexpr bool is_contiguous = true; - static constexpr bool static_size = std::numeric_limits<size_t>::max(); - template <size_t SIZE = static_size> + template <size_t SIZE = std::numeric_limits<size_t>::max()> static inline std::vector<T, Allocator> create(const size_t sz, const T& val = T(0)) { return std::vector<T, Allocator>(sz, val); diff --git a/dune/xt/grid/gridprovider/coupling.hh b/dune/xt/grid/gridprovider/coupling.hh index 6ba252337..95a8158c9 100644 --- a/dune/xt/grid/gridprovider/coupling.hh +++ b/dune/xt/grid/gridprovider/coupling.hh @@ -30,7 +30,7 @@ public: using CouplingGridViewType = CouplingGridViewImp; - static const std::string static_id() + static std::string static_id() { return "xt.grid.couplinggridprovider"; } diff --git a/dune/xt/grid/gridprovider/provider.hh b/dune/xt/grid/gridprovider/provider.hh index 0ca410710..0a95015e8 100644 --- a/dune/xt/grid/gridprovider/provider.hh +++ b/dune/xt/grid/gridprovider/provider.hh @@ -57,7 +57,7 @@ public: using LeafGridViewType = typename Layer<GridType, Layers::leaf, Backends::view>::type; - static const std::string static_id() + static std::string static_id() { return "xt.grid.gridprovider"; } diff --git a/dune/xt/grid/output/entity_visualization.hh b/dune/xt/grid/output/entity_visualization.hh index 0b1d8e8b7..d201e0422 100644 --- a/dune/xt/grid/output/entity_visualization.hh +++ b/dune/xt/grid/output/entity_visualization.hh @@ -67,11 +67,11 @@ struct ElementVisualization virtual ~FunctorBase() = default; - const std::string filename() const + std::string filename() const { return filename_; } - const std::string dir() const + std::string dir() const { return dir_; } diff --git a/dune/xt/la/algorithms/cholesky.hh b/dune/xt/la/algorithms/cholesky.hh index c4384436a..2d78b2d36 100644 --- a/dune/xt/la/algorithms/cholesky.hh +++ b/dune/xt/la/algorithms/cholesky.hh @@ -220,7 +220,7 @@ struct CholeskySolver assert(size <= size_t(std::numeric_limits<int>::max())); int info = Common::Lapacke::dpotrf_work( lapacke_storage_layout, 'L', static_cast<int>(size), M::data(A), static_cast<int>(size)); - if (info) + if (info != 0) DUNE_THROW(Dune::MathError, "Cholesky factorization using Lapacke::dpotrf failed with status " + Common::to_string(info) + "!"); #endif // HAVE_MKL || HAVE_LAPACKE @@ -284,7 +284,7 @@ struct LDLTSolver Common::data(subdiag), Common::data(rhs), is_row_major ? rhs_cols : static_cast<int>(size)); - if (info) + if (info != 0) DUNE_THROW(Dune::MathError, "Lapack dpttrs failed!"); #endif // HAVE_MKL || HAVE_LAPACKE } else { diff --git a/dune/xt/la/algorithms/qr.hh b/dune/xt/la/algorithms/qr.hh index 1dacba9eb..fe704082c 100644 --- a/dune/xt/la/algorithms/qr.hh +++ b/dune/xt/la/algorithms/qr.hh @@ -400,7 +400,7 @@ private: if (m != last_m || n != last_n) { // query workspace size Common::Lapacke::dgeqp3_work(matrix_layout, m, n, a, lda, jpvt, tau, work.data(), -1); - work.resize(static_cast<size_t>(work[0] + 0.5)); + work.resize(static_cast<size_t>(work[0] + 0.1)); last_m = m; last_n = n; } diff --git a/dune/xt/la/algorithms/triangular_solves.hh b/dune/xt/la/algorithms/triangular_solves.hh index dd42014aa..eea0d3e3f 100644 --- a/dune/xt/la/algorithms/triangular_solves.hh +++ b/dune/xt/la/algorithms/triangular_solves.hh @@ -224,7 +224,7 @@ struct TriangularSolver } else if (Common::Cblas::available() && (storage_layout == Common::StorageLayout::dense_row_major || storage_layout == Common::StorageLayout::dense_column_major) - && num_rows) { + && (num_rows != 0)) { const int blas_storage_layout = (storage_layout == Common::StorageLayout::dense_row_major) ? Common::Cblas::row_major() : Common::Cblas::col_major(); diff --git a/dune/xt/la/container/container-interface.hh b/dune/xt/la/container/container-interface.hh index 1ab8f0723..92b847c63 100644 --- a/dune/xt/la/container/container-interface.hh +++ b/dune/xt/la/container/container-interface.hh @@ -54,7 +54,7 @@ struct LockGuard LockGuard(std::vector<std::mutex>& mutexes, const size_t ii, const size_t container_size) : mutexes_(mutexes) { - if (mutexes_.size()) { + if (!mutexes_.empty()) { index_ = ii * mutexes_.size() / container_size; mutexes_[index_].lock(); } @@ -62,7 +62,7 @@ struct LockGuard ~LockGuard() { - if (mutexes_.size()) + if (!mutexes_.empty()) mutexes_[index_].unlock(); } diff --git a/dune/xt/la/container/eigen/sparse.hh b/dune/xt/la/container/eigen/sparse.hh index f9e8953f9..543876b7b 100644 --- a/dune/xt/la/container/eigen/sparse.hh +++ b/dune/xt/la/container/eigen/sparse.hh @@ -119,7 +119,7 @@ public: for (size_t row = 0; row < size_t(pattern_in.size()); ++row) { backend_->startVec(static_cast<EIGEN_size_t>(row)); const auto& columns = pattern_in.inner(row); - for (auto& column : columns) { + for (const auto& column : columns) { # ifndef NDEBUG if (column >= cc) DUNE_THROW(Common::Exceptions::shapes_do_not_match, @@ -129,7 +129,7 @@ public: backend_->insertBackByOuterInner(static_cast<EIGEN_size_t>(row), static_cast<EIGEN_size_t>(column)); } // create entry (insertBackByOuterInner() can not handle empty rows) - if (columns.size() == 0) + if (columns.empty()) backend_->insertBackByOuterInner(static_cast<EIGEN_size_t>(row), 0); } backend_->finalize(); diff --git a/dune/xt/la/container/io.hh b/dune/xt/la/container/io.hh index a36bae9ab..4b32964e9 100644 --- a/dune/xt/la/container/io.hh +++ b/dune/xt/la/container/io.hh @@ -92,7 +92,7 @@ typename std::enable_if<is_matrix<M>::value, M>::type from_file(const std::strin max_col = std::max(max_col, jj); values.emplace_back(std::tuple<size_t, size_t, R>(ii, jj, value)); } - if (rows.size() == 0) + if (rows.empty()) DUNE_THROW(IOError, "Given file '" << filename << "' must not be empty!"); const size_t matrix_rows = std::max(min_rows, ssize_t(max_row) + 1); const size_t matrix_cols = std::max(min_cols, ssize_t(max_col) + 1); -- GitLab From db8d694b57a04948f83a0e095c5c3ef73b73a586 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 12:11:38 +0100 Subject: [PATCH 10/19] Remove deprecated stuff --- dune/xt/common/python.cc | 28 ------ dune/xt/common/python.hh | 8 -- dune/xt/functions/constant.hh | 1 + dune/xt/functions/interfaces/function.hh | 75 -------------- dune/xt/functions/interfaces/grid-function.hh | 97 ------------------- dune/xt/grid/dd/glued.hh | 6 +- dune/xt/grid/intersection.hh | 11 --- dune/xt/grid/type_traits.hh | 8 -- dune/xt/test/common.hh | 5 - python/dune/xt/grid/available_types.hh | 31 ------ python/dune/xt/grid/layers.bindings.hh | 10 -- 11 files changed, 5 insertions(+), 275 deletions(-) delete mode 100644 python/dune/xt/grid/available_types.hh diff --git a/dune/xt/common/python.cc b/dune/xt/common/python.cc index 873473d1c..de77b4ffb 100644 --- a/dune/xt/common/python.cc +++ b/dune/xt/common/python.cc @@ -44,32 +44,4 @@ void guarded_bind(const std::function<void()>& registrar) } // ... guarded_bind(...) -void add_initialization(pybind11::module& /*m*/, const std::string& /*logger_name*/, const std::string& /*so_name*/) {} - - -void try_register(pybind11::module& m, const std::function<void(pybind11::module&)>& registrar) -{ - try { - registrar(m); - } catch (std::runtime_error& err) { - const std::string what{err.what()}; - /* pybind11 error msg format - * ("generic_type: type \"" + std::string(rec->name) + - "\" is already registered!") - */ - const auto reg_pos = what.find("already registered"); - const auto def_pos = what.find("already defined"); - size_t npos{std::string::npos}, left{0}, right{std::string::npos}; - if ((def_pos == npos && reg_pos == npos) || what.size() < 2) - throw err; - - std::string type{}; - left = what.find('\"'); - right = what.rfind('\"'); - type = what.substr(left + 1, right - left - 1); - DXTC_LOG_DEBUG << "try_register: added type " << type << std::endl; - } -} // ... try_register(...) - - } // namespace Dune::XT::Common::bindings diff --git a/dune/xt/common/python.hh b/dune/xt/common/python.hh index 9156dc4ca..87dd82ed0 100644 --- a/dune/xt/common/python.hh +++ b/dune/xt/common/python.hh @@ -24,14 +24,6 @@ namespace Dune::XT::Common::bindings { void guarded_bind(const std::function<void()>& registrar); -[[deprecated("This is not required any more (08.08.2019)!")]] void -add_initialization(pybind11::module& /*m*/, const std::string& /*logger_name*/, const std::string& /*so_name*/ = ""); - - -[[deprecated("use guarded_bind() instead (08.08.2019)!")]] void -try_register(pybind11::module& m, const std::function<void(pybind11::module&)>& registrar); - - } // namespace Dune::XT::Common::bindings #endif // DUNE_XT_COMMON_PYTHON_HH diff --git a/dune/xt/functions/constant.hh b/dune/xt/functions/constant.hh index f2367631b..8ad00e462 100644 --- a/dune/xt/functions/constant.hh +++ b/dune/xt/functions/constant.hh @@ -18,6 +18,7 @@ #include <dune/xt/common/string.hh> #include <dune/xt/functions/base/function-as-flux-function.hh> +#include <dune/xt/functions/base/function-as-grid-function.hh> #include <dune/xt/functions/interfaces/function.hh> #include <dune/xt/functions/interfaces/flux-function.hh> #include <dune/xt/functions/interfaces/grid-function.hh> diff --git a/dune/xt/functions/interfaces/function.hh b/dune/xt/functions/interfaces/function.hh index ade23db2d..8d8eba526 100644 --- a/dune/xt/functions/interfaces/function.hh +++ b/dune/xt/functions/interfaces/function.hh @@ -53,11 +53,6 @@ template <class, class> class FractionFunction; -// remove this once removing as_grid_function -template <class, size_t, size_t, class> -class FunctionAsGridFunctionWrapper; - - /** * \brief Interface for functions (in the C^\infty sense) which can thus be evaluated in global coordinates. * @@ -308,75 +303,6 @@ public: DerivativeRangeSelector::convert(this->derivative(alpha, point_in_reference_element, param), result); } - /** - * \} - * \name ´´These methods are provided.'' - * \{ - **/ - - /** - * \note This function keeps a map of all wrappers in a local static map, to avoid temporaries. - * \todo Check if this implementation is thread safe! - */ - // When removing this, also remove - // * the dune/xt/functions/base/function-as-grid-function.hh include below and - // * the FunctionAsGridFunctionWrapper forward above! - template <class E> - [[deprecated("Use make_grid_function instead (18.09.2020)!")]] const typename std:: - enable_if<XT::Grid::is_entity<E>::value && E::dimension == d, FunctionAsGridFunctionWrapper<E, r, rC, R>>::type& - as_grid_function() const - { - static std::map<const ThisType*, std::unique_ptr<FunctionAsGridFunctionWrapper<E, r, rC, R>>> wrappers; - if (wrappers.find(this) == wrappers.end()) - wrappers[this] = std::make_unique<FunctionAsGridFunctionWrapper<E, r, rC, R>>(*this); - return *(wrappers[this]); - } - - // When removing this, also remove - // * the dune/xt/functions/base/function-as-grid-function.hh include below and - // * the FunctionAsGridFunctionWrapper forward above! - template <class ViewTraits> - [[deprecated("Use make_grid_function instead (18.09.2020)!")]] const typename std::enable_if< - (ViewTraits::Grid::dimension == d), - FunctionAsGridFunctionWrapper<typename ViewTraits::template Codim<0>::Entity, r, rC, R>>::type& - as_grid_function(const GridView<ViewTraits>& /*grid_view*/) const - { - return this->as_grid_function<typename ViewTraits::template Codim<0>::Entity>(); - } - - /** - * \copydoc GridFunctionInterface::visualize - */ - template <class GridLayerType> - [[deprecated("Use visualize(*this, ...) from <dune/xt/functions/visualization.hh> instead (24.09.2020)!")]] - typename std::enable_if<Grid::is_layer<GridLayerType>::value, void>::type - visualize(const GridLayerType& grid_layer, - const std::string path, - const bool subsampling = true, - const VTK::OutputType vtk_output_type = VTK::appendedraw) const - { - this->as_grid_function<XT::Grid::extract_entity_t<GridLayerType>>().visualize( - grid_layer, path, subsampling, vtk_output_type); - } - - /** - * \copydoc GridFunctionInterface::visualize_gradient - */ - template <class GridLayerType> - [[deprecated("Use visualize_gradient(*this, ...) from <dune/xt/functions/visualization.hh> instead (24.09.2020)!")]] - typename std::enable_if<Grid::is_layer<GridLayerType>::value, void>::type - visualize_gradient(const GridLayerType& grid_layer, - const std::string path, - const bool subsampling = true, - const VTK::OutputType vtk_output_type = VTK::appendedraw) const - { - this->as_grid_function<XT::Grid::extract_entity_t<GridLayerType>>().visualize_gradient( - grid_layer, path, subsampling, vtk_output_type); - } - - /** - * \} - **/ protected: #ifndef DUNE_XT_FUNCTIONS_DISABLE_CHECKS static void assert_correct_dims(const size_t row, const size_t col, const std::string& caller) @@ -440,6 +366,5 @@ private: #include <dune/xt/functions/base/combined-functions.hh> -#include <dune/xt/functions/base/function-as-grid-function.hh> // remove this once removing as_grid_function #endif // DUNE_XT_FUNCTIONS_INTERFACES_FUNCTION_HH diff --git a/dune/xt/functions/interfaces/grid-function.hh b/dune/xt/functions/interfaces/grid-function.hh index f9296c762..b896f5a48 100644 --- a/dune/xt/functions/interfaces/grid-function.hh +++ b/dune/xt/functions/interfaces/grid-function.hh @@ -227,103 +227,6 @@ public: } // ... operator/(...) /// \} - - /** - * \note We use the SubsamplingVTKWriter (which is better for higher orders) by default: the grid you see in the - * visualization may thus be a refinement of the actual grid! - */ - template <class GridViewType> - [[deprecated("Use visualize(*this, ...) from <dune/xt/functions/visualization.hh> instead (24.09.2020)!")]] void - visualize(const GridViewType& grid_view, - const std::string path, - const bool subsampling = true, - const VTK::OutputType vtk_output_type = VTK::appendedraw, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<r, rC, R>& visualizer = default_visualizer<r, rC, R>()) const - { - static_assert(Grid::is_view<GridViewType>::value); - auto vtk_writer = create_vtkwriter(grid_view, subsampling); - add_to_vtkwriter(*vtk_writer, param, visualizer); - write_visualization(*vtk_writer, path, vtk_output_type); - } // ... visualize(...) - - /** - * \note We use the SubsamplingVTKWriter (which is better for higher orders) by default: the grid you see in the - * visualization may thus be a refinement of the actual grid! - * \note Not yet implemented for vector-valued functions. - */ - template <class GridViewType> - [[deprecated( - "Use visualize_gradient(*this, ...) from <dune/xt/functions/visualization.hh> instead (24.09.2020)!")]] void - visualize_gradient(const GridViewType& grid_view, - const std::string path, - const bool subsampling = true, - const VTK::OutputType vtk_output_type = VTK::appendedraw, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<d, 1, R>& visualizer = default_visualizer<d, 1, R>()) const - { - static_assert(Grid::is_view<GridViewType>::value); - auto vtk_writer = create_vtkwriter(grid_view, subsampling); - add_gradient_to_vtkwriter(*vtk_writer, param, visualizer); - write_visualization(*vtk_writer, path, vtk_output_type); - } // ... visualize_gradient(...) - - template <class GridViewType> - [[deprecated( - "Use internal::create_vtkwriter(...) from <dune/xt/functions/visualization.hh> instead (24.09.2020)!")]] std:: - unique_ptr<VTKWriter<GridViewType>> - create_vtkwriter(const GridViewType& grid_view, const bool subsampling = true) const - { - static_assert(Grid::is_view<GridViewType>::value); - return subsampling ? std::make_unique<SubsamplingVTKWriter<GridViewType>>(grid_view, /*subsampling_level=*/2) - : std::make_unique<VTKWriter<GridViewType>>(grid_view, VTK::nonconforming); - } - - template <class GridViewType> - [[deprecated( - "Use internal::add_to_vtkwriter(...) from <dune/xt/functions/visualization.hh> instead (24.09.2020)!")]] void - add_to_vtkwriter(VTKWriter<GridViewType>& vtk_writer, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<r, rC, R>& visualizer = default_visualizer<r, rC, R>()) const - { - static_assert(Grid::is_view<GridViewType>::value); - const auto adapter = - std::make_shared<VisualizationAdapter<GridViewType, range_dim, range_dim_cols, RangeFieldType>>( - *this, visualizer, "", param); - vtk_writer.addVertexData(adapter); - } - - template <class GridViewType> - [[deprecated("Use internal::add_gradient_to_vtkwriter(...) from <dune/xt/functions/visualization.hh> instead " - "(24.09.2020)!")]] void - add_gradient_to_vtkwriter(VTKWriter<GridViewType>& vtk_writer, - const XT::Common::Parameter& param = {}, - const VisualizerInterface<d, 1, R>& visualizer = default_visualizer<d, 1, R>()) const - { - static_assert(Grid::is_view<GridViewType>::value); - const auto adapter = - std::make_shared<GradientVisualizationAdapter<GridViewType, range_dim, range_dim_cols, RangeFieldType>>( - *this, visualizer, "", param); - vtk_writer.addCellData(adapter); - } - - template <class GridViewType> - [[deprecated("Use internal::write_visualization(...) from <dune/xt/functions/visualization.hh> instead " - "(24.09.2020)!")]] void - write_visualization(VTKWriter<GridViewType>& vtk_writer, - const std::string path, - const VTK::OutputType vtk_output_type = VTK::appendedraw) const - { - static_assert(Grid::is_view<GridViewType>::value); - if (path.empty()) - DUNE_THROW(Exceptions::wrong_input_given, "path must not be empty!"); - const auto directory = Common::directory_only(path); - Common::test_create_directory(directory); - if (MPIHelper::getCollectiveCommunication().size() == 1) - vtk_writer.write(path, vtk_output_type); - else - vtk_writer.pwrite(Common::filename_only(path), directory, "", vtk_output_type); - } }; // class GridFunctionInterface diff --git a/dune/xt/grid/dd/glued.hh b/dune/xt/grid/dd/glued.hh index 0be3204af..654d4f7b4 100644 --- a/dune/xt/grid/dd/glued.hh +++ b/dune/xt/grid/dd/glued.hh @@ -31,9 +31,11 @@ #include <dune/xt/common/float_cmp.hh> #include <dune/xt/common/ranges.hh> #include <dune/xt/common/timedlogging.hh> +#include <dune/xt/functions/base/function-as-grid-function.hh> #include <dune/xt/functions/base/visualization.hh> -#include <dune/xt/functions/interfaces/function.hh> #include <dune/xt/functions/constant.hh> +#include <dune/xt/functions/grid-function.hh> +#include <dune/xt/functions/interfaces/function.hh> #include <dune/xt/grid/intersection.hh> #include <dune/xt/grid/layers.hh> #include <dune/xt/grid/gridprovider/provider.hh> @@ -721,7 +723,7 @@ public: for (size_t subdomain = 0; subdomain < macro_leaf_view_size_; ++subdomain) { if (std::find(subdomains.begin(), subdomains.end(), subdomain) != subdomains.end()) { auto visualization_adapter = std::make_shared<XT::Functions::VisualizationAdapter<LocalViewType, 1, 1, double>>( - func.template as_grid_function<typename LocalViewType::template Codim<0>::Entity>(), func.name()); + XT::Functions::make_grid_function<typename LocalViewType::template Codim<0>::Entity>(func), func.name()); vtk_writer.addVertexData(subdomain, visualization_adapter); } } diff --git a/dune/xt/grid/intersection.hh b/dune/xt/grid/intersection.hh index 784ac9342..9f6fe9929 100644 --- a/dune/xt/grid/intersection.hh +++ b/dune/xt/grid/intersection.hh @@ -184,17 +184,6 @@ bool contains(const Dune::Intersection<G, I>& intersection, } // namespace XT::Grid - - -// DXT_DEPRECATED_MSG did not work here -template <class G, class I> -[[deprecated("Use out << print(intersection) from <dune/xt/grid/print.hh> instead (05.07.2020)!")]] void -operator<<(std::ostream& /*out*/, const Dune::Intersection<G, I>& intersection) -{ - XT::Common::print(intersection); -} - - } // namespace Dune #endif // DUNE_XT_GRID_INTERSECTION_HH diff --git a/dune/xt/grid/type_traits.hh b/dune/xt/grid/type_traits.hh index 7bd508f6b..a7c575f9e 100644 --- a/dune/xt/grid/type_traits.hh +++ b/dune/xt/grid/type_traits.hh @@ -467,14 +467,6 @@ struct extract_iterator<T, c, pit, false, true> template <class T, int c = 0, PartitionIteratorType pit = All_Partition> using extract_iterator_t = typename extract_iterator<T, c, pit>::type; -template <class T, PartitionIteratorType pit, int c = 0, bool view = is_view<T>::value, bool part = is_part<T>::value> -struct [[deprecated("Use extract_iterator instead (24.04.2018)!")]] extract_partition_iterator - : public extract_iterator<T, c, pit, view, part>{}; - -template <class T, PartitionIteratorType pit, int c = 0> -using extract_partition_iterator_t [[deprecated("Use extract_iterator_t instead (24.04.2018)!")]] = - extract_iterator_t<T, c, pit>; - //! struct to be used as comparison function e.g. in a std::map<Entity, EntityLess> template <class GV> struct EntityLess diff --git a/dune/xt/test/common.hh b/dune/xt/test/common.hh index e828b9082..b2ac86242 100644 --- a/dune/xt/test/common.hh +++ b/dune/xt/test/common.hh @@ -115,11 +115,6 @@ void check_eoc_study_for_success( const double& zero_tolerance = 1e-15); -[[deprecated("Does not make any sense with the new ConvergenceStudy (25.01.2019)!")]] void -print_collected_eoc_study_results(const std::map<std::string, std::vector<double>>& results, - std::ostream& out = std::cout); - - // returns unsigned int on purpose, see GridProvider unsigned int grid_elements(); diff --git a/python/dune/xt/grid/available_types.hh b/python/dune/xt/grid/available_types.hh deleted file mode 100644 index b13859b33..000000000 --- a/python/dune/xt/grid/available_types.hh +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of the dune-xt project: -// https://zivgitlab.uni-muenster.de/ag-ohlberger/dune-community/dune-xt -// Copyright 2009-2021 dune-xt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2019) -// René Fritze (2018 - 2020) -// Tobias Leibner (2020) -// -// reserved. License: Dual licensed as BSD 2-Clause License -// (http://opensource.org/licenses/BSD-2-Clause) - -#warning This header is deprecated, include <dune/xt/grid/grids.hh> instead (31.07.2019)! - -#ifndef PYTHON_DUNE_XT_GRID_TYPES_HH -# define PYTHON_DUNE_XT_GRID_TYPES_HH - -# include <dune/xt/grid/grids.hh> - -namespace Dune::XT::Grid::bindings { - - -using AvailableTypes [[deprecated("Use XT::Grid::AvailableGridTypes instead (31.07.2019)!")]] = - Dune::XT::Grid::AvailableGridTypes; - - -} // namespace Dune::XT::Grid::bindings - -#endif // PYTHON_DUNE_XT_GRID_TYPES_HH diff --git a/python/dune/xt/grid/layers.bindings.hh b/python/dune/xt/grid/layers.bindings.hh index 561fcd2e0..fd9349069 100644 --- a/python/dune/xt/grid/layers.bindings.hh +++ b/python/dune/xt/grid/layers.bindings.hh @@ -40,16 +40,6 @@ struct backend_name<Backends::view> }; -template <Layers layer> -struct layer_name -{ - [[deprecated("use layer_names[layer] directly. 2018/7/2")]] static std::string value() - { - return layer_names[layer]; - } -}; - - } // namespace Dune::XT::Grid::bindings #endif // DUNE_XT_GRID_LAYERS_BINDINGS_HH -- GitLab From a922bb15ddb1e388198e586b11f3a8fe46fb5009 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 12:12:43 +0100 Subject: [PATCH 11/19] Fix warnings and enable -Werror on CI --- CMakeLists.txt | 4 ++++ cmake/modules/DuneXTTesting.cmake | 6 +++--- dune/xt/grid/view/coupling.hh | 4 ++-- dune/xt/test/grid/dd_glued.hh | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81ac4cf42..7919a7b27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,10 @@ cmake_minimum_required(VERSION 3.13) project("dune-xt" CXX) +if("${TRAVIS}" EQUAL "1") + add_compile_options(-Werror -Wno-error=unknown-pragmas -Wno-error=pedantic) +endif() + # local environment set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../local/bin:$ENV{PATH}") set(ENV{LD_LIBRARY_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../local/lib:$ENV{LD_LIBRARY_PATH}") diff --git a/cmake/modules/DuneXTTesting.cmake b/cmake/modules/DuneXTTesting.cmake index cd26fcbbc..76792c04e 100644 --- a/cmake/modules/DuneXTTesting.cmake +++ b/cmake/modules/DuneXTTesting.cmake @@ -184,11 +184,11 @@ macro(ADD_SUBDIR_TESTS subdir) add_custom_target(${subdir}_test_templates SOURCES ${test_templates}) # this excludes meta-ini variation test cases because there binary name != test name - foreach(test ${${subdir}_xt_test_binaries}) - if(TARGET test) + foreach(test ${${subdir}_dxt_test_binaries}) + if(TEST test) set_tests_properties(${test} PROPERTIES TIMEOUT ${DXT_TEST_TIMEOUT}) set_tests_properties(${test} PROPERTIES LABELS ${subdir}) - endif(TARGET test) + endif(TEST test) endforeach() add_custom_target(${subdir}_test_binaries DEPENDS ${${subdir}_dxt_test_binaries}) diff --git a/dune/xt/grid/view/coupling.hh b/dune/xt/grid/view/coupling.hh index 83960d13c..9cad8d2d8 100644 --- a/dune/xt/grid/view/coupling.hh +++ b/dune/xt/grid/view/coupling.hh @@ -260,7 +260,7 @@ public: { // initialize variables inside_elements_ = std::make_shared<std::vector<LocalElementType>>(); - inside_elements_ids_ = std::make_shared<std::vector<int>>(); + inside_elements_ids_ = std::make_shared<std::vector<unsigned int>>(); coupling_intersections_ = std::make_shared< std::vector<std::set<CorrectedCouplingIntersectionType, CompareType<CorrectedCouplingIntersectionType>>>>(); local_to_inside_indices_ = std::make_shared<std::vector<std::pair<size_t, size_t>>>(); @@ -386,7 +386,7 @@ private: const LocalGridProviderType& local_inside_grid_; size_t coupling_size_; std::shared_ptr<std::vector<LocalElementType>> inside_elements_; - std::shared_ptr<std::vector<int>> inside_elements_ids_; + std::shared_ptr<std::vector<unsigned int>> inside_elements_ids_; std::shared_ptr< std::vector<std::set<CorrectedCouplingIntersectionType, CompareType<CorrectedCouplingIntersectionType>>>> coupling_intersections_; diff --git a/dune/xt/test/grid/dd_glued.hh b/dune/xt/test/grid/dd_glued.hh index a4404b6b5..3f09a7614 100644 --- a/dune/xt/test/grid/dd_glued.hh +++ b/dune/xt/test/grid/dd_glued.hh @@ -183,7 +183,7 @@ struct GluedDdGridTest : public ::testing::Test ASSERT_NE(macro_grid_, nullptr) << "This should not happen!"; ASSERT_NE(dd_grid_, nullptr) << "This should not happen!"; - for (int ss = 0; ss < dd_grid_->num_subdomains(); ss++) { + for (size_t ss = 0; ss < dd_grid_->num_subdomains(); ss++) { auto local_grid = dd_grid_->local_grid(ss); EXPECT_EQ(macro_grid_->dimDomain, local_grid.dimDomain); } -- GitLab From 722806605bcb281c4410f5c24e95aedb51c6c88d Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 14:44:04 +0100 Subject: [PATCH 12/19] Update .vcsetup --- .vcsetup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vcsetup b/.vcsetup index d46933715..ce8e39341 160000 --- a/.vcsetup +++ b/.vcsetup @@ -1 +1 @@ -Subproject commit d469337152f3aa2fb253d1dbd86c56d8d71e8d0b +Subproject commit ce8e3934191659ffa6d49e4a51e3ccb8f3b00719 -- GitLab From 0c7188b2bcb999e44fb66ba08873c30f6f7a2588 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 14:46:42 +0100 Subject: [PATCH 13/19] [dune.module] Require core modules in version 2.8 --- dune.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dune.module b/dune.module index 9f4ff5f21..9e1a2958c 100755 --- a/dune.module +++ b/dune.module @@ -14,5 +14,5 @@ Module: dune-xt Version: 2021.1.4 Maintainer: dune-xt@dune-community.ovh -Depends: dune-common (>= 2.6) dune-geometry (>= 2.6) dune-grid (>= 2.6) dune-istl (>= 2.6) -Suggests: dune-testtools (>= 2.6) dune-alugrid (>= 2.6) dune-grid-glue (>= 2.6) dune-uggrid (>= 2.6) +Depends: dune-common (>= 2.8) dune-geometry (>= 2.8) dune-grid (>= 2.8) dune-istl (>= 2.8) +Suggests: dune-testtools (>= 2.8) dune-alugrid (>= 2.8) dune-grid-glue (>= 2.8) dune-uggrid (>= 2.8) -- GitLab From 52407acdbaab84995d43e66cedd99c402f9176d0 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Fri, 3 Dec 2021 16:52:12 +0100 Subject: [PATCH 14/19] [clang-tidy] apply bugprone checks --- dune/xt/common/configuration.cc | 11 ++++----- dune/xt/common/configuration.hh | 3 +-- dune/xt/common/convergence-study.cc | 2 +- dune/xt/common/localization-study.cc | 8 +++---- dune/xt/common/localization-study.hh | 2 +- dune/xt/common/logstreams.cc | 2 +- dune/xt/common/logstreams.hh | 4 ++-- dune/xt/common/memory.hh | 6 ++++- dune/xt/common/misc.cc | 2 +- dune/xt/common/parameter.cc | 4 ---- dune/xt/common/parameter.hh | 2 +- dune/xt/common/string.cc | 2 +- dune/xt/common/string_internal.hh | 2 +- dune/xt/grid/gridprovider/cube.hh | 4 ++-- dune/xt/grid/gridprovider/eoc.hh | 2 +- dune/xt/grid/gridprovider/starcd.hh | 2 +- dune/xt/grid/structuredgridfactory.hh | 10 ++++---- dune/xt/grid/view/coupling.hh | 1 - dune/xt/test/common/memory.cc | 2 +- dune/xt/test/common/numeric.cc | 8 +++---- dune/xt/test/common/validation.cc | 2 +- dune/xt/test/grid/periodic_gridview.cc | 27 ++++++++++++++-------- python/dune/xt/common/fmatrix.hh | 2 +- python/dune/xt/common/fvector.hh | 2 +- python/dune/xt/grid/functors/refinement.cc | 6 ++--- 25 files changed, 60 insertions(+), 58 deletions(-) diff --git a/dune/xt/common/configuration.cc b/dune/xt/common/configuration.cc index 15ca4659a..8aae95212 100644 --- a/dune/xt/common/configuration.cc +++ b/dune/xt/common/configuration.cc @@ -35,8 +35,7 @@ ConfigurationDefaults::ConfigurationDefaults(bool warn_on_default_access_in, {} Configuration::Configuration() - : BaseType() - , warn_on_default_access_(ConfigurationDefaults().warn_on_default_access) + : warn_on_default_access_(ConfigurationDefaults().warn_on_default_access) , log_on_exit_(ConfigurationDefaults().log_on_exit) , logfile_(ConfigurationDefaults().logfile) { @@ -200,9 +199,9 @@ void Configuration::report(std::ostream& out, const std::string& prefix) const if (empty()) return; - if (getSubKeys().size() == 0) { + if (getSubKeys().empty()) { report_as_sub(out, prefix, ""); - } else if (getValueKeys().size() == 0) { + } else if (getValueKeys().empty()) { const std::string common_prefix = find_common_prefix(*this, ""); if (!common_prefix.empty()) { out << prefix << "[" << common_prefix << "]" << std::endl; @@ -320,7 +319,7 @@ void Configuration::report_as_sub(std::ostream& out, const std::string& prefix, } for (const auto& subkey : getSubKeys()) { Configuration sub_tree(sub(subkey)); - if (sub_tree.getValueKeys().size()) + if (!sub_tree.getValueKeys().empty()) out << prefix << "[" << sub_path << subkey << "]" << std::endl; sub_tree.report_as_sub(out, prefix, sub_path + subkey + "."); } @@ -330,7 +329,7 @@ std::string Configuration::find_common_prefix(const BaseType& subtree, const std { const auto& valuekeys = subtree.getValueKeys(); const auto& subkeys = subtree.getSubKeys(); - if (valuekeys.size() == 0 && subkeys.size() == 1) { + if (valuekeys.empty() && subkeys.size() == 1) { // we append the subs name if (previous_prefix.empty()) return find_common_prefix(subtree.sub(subkeys[0]), subkeys[0]); diff --git a/dune/xt/common/configuration.hh b/dune/xt/common/configuration.hh index 4571ec9c9..a93b7880e 100644 --- a/dune/xt/common/configuration.hh +++ b/dune/xt/common/configuration.hh @@ -90,8 +90,7 @@ some_function_which_expects_a_config({{"type", "custom"}, {"tolerance", "1e-10"} Configuration(const std::vector<std::string>& keys, const std::initializer_list<T> values_in, const ConfigurationDefaults& defaults = ConfigurationDefaults()) - : BaseType() - , warn_on_default_access_(defaults.warn_on_default_access) + : warn_on_default_access_(defaults.warn_on_default_access) , log_on_exit_(defaults.log_on_exit) , logfile_(defaults.logfile) { diff --git a/dune/xt/common/convergence-study.cc b/dune/xt/common/convergence-study.cc index a90766f29..4524f7021 100644 --- a/dune/xt/common/convergence-study.cc +++ b/dune/xt/common/convergence-study.cc @@ -114,7 +114,7 @@ void ConvergenceStudy::print_eoc(std::ostream& out, { const int inf_rate_threshold{999}; const double expected_rate_tolerance{0.9}; - auto& self = *this; + const auto& self = *this; const double quantity_old = extract(data, level - 1, type, id); if (FloatCmp::eq(quantity_old, 0.)) out << lfill("inf", len); diff --git a/dune/xt/common/localization-study.cc b/dune/xt/common/localization-study.cc index 7fda7c0ed..c204d2c50 100644 --- a/dune/xt/common/localization-study.cc +++ b/dune/xt/common/localization-study.cc @@ -41,13 +41,13 @@ std::vector<std::string> LocalizationStudy::used_indicators() const } // ... used_indicators(...) -void LocalizationStudy::run(std::ostream& out) +void LocalizationStudy::run(std::ostream& out) const { boost::io::ios_all_saver guard(out); - if (provided_indicators().size() == 0) + if (provided_indicators().empty()) DUNE_THROW(Dune::InvalidStateException, "You have to provide at least one indicator!"); const auto actually_used_indicators = used_indicators(); - if (actually_used_indicators.size() == 0) + if (actually_used_indicators.empty()) DUNE_THROW(Dune::InvalidStateException, "There are no common indicators in 'provided_indicators()' and 'only_these_indicators'!"); @@ -79,7 +79,7 @@ void LocalizationStudy::run(std::ostream& out) out << thick_delimiter << std::endl; // comput reference indicators const auto reference_indicators = compute_reference_indicators(); - if (reference_indicators.size() == 0) + if (reference_indicators.empty()) DUNE_THROW(Exceptions::requirements_not_met, "Given reference indicators must not be empty!"); // loop over all indicators for (size_t ind = 0; ind < actually_used_indicators.size(); ++ind) { diff --git a/dune/xt/common/localization-study.hh b/dune/xt/common/localization-study.hh index aa8397474..3bdc8a16a 100644 --- a/dune/xt/common/localization-study.hh +++ b/dune/xt/common/localization-study.hh @@ -40,7 +40,7 @@ public: std::vector<std::string> used_indicators() const; - /*std::map< std::string, std::vector< double > >*/ void run(std::ostream& out = std::cout); + /*std::map< std::string, std::vector< double > >*/ void run(std::ostream& out = std::cout) const; private: const std::vector<std::string> only_these_indicators_; diff --git a/dune/xt/common/logstreams.cc b/dune/xt/common/logstreams.cc index 9cc617586..602549eda 100644 --- a/dune/xt/common/logstreams.cc +++ b/dune/xt/common/logstreams.cc @@ -95,7 +95,7 @@ int TimedPrefixedStreamBuffer::sync() prefix_needed_ = false; } auto lines = tokenize(tmp_str, "\n", boost::algorithm::token_compress_off); - DXT_ASSERT(lines.size() > 0); + DXT_ASSERT(!lines.empty()); out_ << lines[0]; for (size_t ii = 1; ii < lines.size() - 1; ++ii) out_ << "\n" << elapsed_time_str() << prefix_ << lines[ii]; diff --git a/dune/xt/common/logstreams.hh b/dune/xt/common/logstreams.hh index bedc475b4..0d76420a7 100644 --- a/dune/xt/common/logstreams.hh +++ b/dune/xt/common/logstreams.hh @@ -75,7 +75,7 @@ protected: private: inline bool enabled() const { - return (!is_suspended_) && (logflags_ & loglevel_); + return (!is_suspended_) && ((logflags_ & loglevel_) != 0); } int& logflags_; @@ -185,7 +185,7 @@ public: } //! dump buffer into file/stream and clear it - virtual LogStream& flush(); + LogStream& flush(); /** \brief forwards suspend to buffer * the suspend_priority_ mechanism provides a way to silence streams from 'higher' modules diff --git a/dune/xt/common/memory.hh b/dune/xt/common/memory.hh index 5a3b71bc7..ba0b4ffe9 100644 --- a/dune/xt/common/memory.hh +++ b/dune/xt/common/memory.hh @@ -113,6 +113,10 @@ public: : tt_(tt) {} + explicit ConstAccessByValue(const T& tt) + : tt_(tt) + {} + const T& access() const final { return tt_; @@ -319,7 +323,7 @@ public: // We have to disable this constructor if T is not a complete type to avoid compilation failures template <class S, typename std::enable_if_t<std::is_constructible<T, S&&>::value, bool> = true> explicit ConstStorageProvider(S&& tt) - : storage_(new internal::ConstAccessByValue<T>(std::move(tt))) + : storage_(new internal::ConstAccessByValue<T>(std::forward<S>(tt))) {} explicit ConstStorageProvider(std::shared_ptr<const T> tt) diff --git a/dune/xt/common/misc.cc b/dune/xt/common/misc.cc index 3a46a1ba6..6c8331db6 100644 --- a/dune/xt/common/misc.cc +++ b/dune/xt/common/misc.cc @@ -27,7 +27,7 @@ void dump_environment(boost::filesystem::ofstream& file, const std::string& csv_ { using namespace std; vector<string> header, values; - for (char** current = environ; *current; current++) { + for (char** current = environ; *current != nullptr; current++) { string line(*current); const auto tokens = tokenize(line, "="); if (tokens.size() == 2) { diff --git a/dune/xt/common/parameter.cc b/dune/xt/common/parameter.cc index 82ab13f82..826c273d4 100644 --- a/dune/xt/common/parameter.cc +++ b/dune/xt/common/parameter.cc @@ -41,10 +41,6 @@ template class SimpleDict<std::vector<double>>; // ========================= // ===== ParameterType ===== // ========================= -ParameterType::ParameterType() - : BaseType() -{} - ParameterType::ParameterType(const std::string& key) : BaseType(key, 1) {} diff --git a/dune/xt/common/parameter.hh b/dune/xt/common/parameter.hh index 374ea9ee2..bfa98f7ea 100644 --- a/dune/xt/common/parameter.hh +++ b/dune/xt/common/parameter.hh @@ -178,7 +178,7 @@ class ParameterType : public internal::SimpleDict<size_t> using BaseType = internal::SimpleDict<size_t>; public: - ParameterType(); + ParameterType() = default; ParameterType(const ParameterType& other) = default; diff --git a/dune/xt/common/string.cc b/dune/xt/common/string.cc index a418dc323..7d3e40ba2 100644 --- a/dune/xt/common/string.cc +++ b/dune/xt/common/string.cc @@ -41,7 +41,7 @@ std::string to_camel_case(const std::string& ss) { std::stringstream out; for (auto&& word : tokenize(ss, "_", boost::algorithm::token_compress_on)) { - if (word.size() > 0) { + if (!word.empty()) { out << to_upper(word.substr(0, 1)); out << word.substr(1); } diff --git a/dune/xt/common/string_internal.hh b/dune/xt/common/string_internal.hh index 8c04fd5ec..ef3df628b 100644 --- a/dune/xt/common/string_internal.hh +++ b/dune/xt/common/string_internal.hh @@ -217,7 +217,7 @@ VectorType vector_from_string(std::string vector_str, const size_t size, DXTC_DE const size_t automatic_size = (size == 0 ? 1 : size); const size_t actual_size = VectorAbstraction<VectorType>::has_static_size ? VectorAbstraction<VectorType>::static_size : automatic_size; - if (actual_size > automatic_size && automatic_size != 1) + if (actual_size > automatic_size && automatic_size != 1) // NOLINT(misc-redundant-expression) DUNE_THROW(Exceptions::conversion_error, "Vector expression (see below) has only " << automatic_size << " elements but " << actual_size << " elements are required for this VectorType (" diff --git a/dune/xt/grid/gridprovider/cube.hh b/dune/xt/grid/gridprovider/cube.hh index bebbdcea5..c722f134b 100644 --- a/dune/xt/grid/gridprovider/cube.hh +++ b/dune/xt/grid/gridprovider/cube.hh @@ -179,7 +179,7 @@ public: std::array<unsigned int, d> overlap_size_array; if (overlap_size.size() >= d) { overlap_size_array = Common::make_array<unsigned int, d>(overlap_size); - } else if (overlap_size.size() >= 1) { + } else if (!overlap_size.empty()) { overlap_size_array = Common::make_array<unsigned int, d>(overlap_size); } else { DUNE_THROW(Common::Exceptions::wrong_input_given, @@ -199,7 +199,7 @@ public: std::array<unsigned int, d> num_elements_array; if (num_elements.size() >= d) { num_elements_array = Common::make_array<unsigned int, d>(num_elements); - } else if (num_elements.size() >= 1) { + } else if (!num_elements.empty()) { num_elements_array = Common::make_array<unsigned int, d>(num_elements); } else { DUNE_THROW(Common::Exceptions::wrong_input_given, diff --git a/dune/xt/grid/gridprovider/eoc.hh b/dune/xt/grid/gridprovider/eoc.hh index 663e84600..3364fc6d2 100644 --- a/dune/xt/grid/gridprovider/eoc.hh +++ b/dune/xt/grid/gridprovider/eoc.hh @@ -51,7 +51,7 @@ public: size_t num_refinements() const { - assert(levels_.size() > 0); + assert(!levels_.empty()); return levels_.size() - 1; } diff --git a/dune/xt/grid/gridprovider/starcd.hh b/dune/xt/grid/gridprovider/starcd.hh index 1b4ae7027..89bdc5d84 100644 --- a/dune/xt/grid/gridprovider/starcd.hh +++ b/dune/xt/grid/gridprovider/starcd.hh @@ -65,7 +65,7 @@ class StarCDGridProviderFactory public: static constexpr bool available = true; - static const std::string static_id() + static std::string static_id() { return starcd_gridprovider_id(); } diff --git a/dune/xt/grid/structuredgridfactory.hh b/dune/xt/grid/structuredgridfactory.hh index 07ff30f3a..d9411d889 100644 --- a/dune/xt/grid/structuredgridfactory.hh +++ b/dune/xt/grid/structuredgridfactory.hh @@ -92,7 +92,7 @@ public: std::array<unsigned int, GridType::dimension> = default_overlap<GridType>(), DXTC_MPI_ONLY Dune::MPIHelper::MPICommunicator mpi_comm = Dune::MPIHelper::getCommunicator()) { - if (Dune::MPIHelper::isFake) + if (Dune::MPIHelper::isFake) // NOLINT(readability-implicit-bool-conversion) return Dune::StructuredGridFactory<GridType>::createCubeGrid(lowerLeft, upperRight, elements); # if HAVE_MPI if (mpi_comm == MPI_COMM_WORLD) @@ -107,7 +107,7 @@ public: const std::array<unsigned int, dim>& elements, DXTC_MPI_ONLY Dune::MPIHelper::MPICommunicator mpi_comm = Dune::MPIHelper::getCommunicator()) { - if (Dune::MPIHelper::isFake) + if (Dune::MPIHelper::isFake) // NOLINT(readability-implicit-bool-conversion) return Dune::StructuredGridFactory<GridType>::createSimplexGrid(lowerLeft, upperRight, elements); # if HAVE_MPI if (mpi_comm == MPI_COMM_WORLD) @@ -141,7 +141,7 @@ public: } if (warn || sum >= dim) DXTC_LOG_INFO << "Ignoring non-default overlap for alberta cube creation"; - if (Dune::MPIHelper::isFake) + if (Dune::MPIHelper::isFake) // NOLINT(readability-implicit-bool-conversion) return Dune::StructuredGridFactory<GridType>::createCubeGrid(lowerLeft, upperRight, elements); # if HAVE_MPI if (mpi_comm == MPI_COMM_WORLD) @@ -156,7 +156,7 @@ public: const std::array<unsigned int, dim>& elements, DXTC_MPI_ONLY Dune::MPIHelper::MPICommunicator mpi_comm = Dune::MPIHelper::getCommunicator()) { - if (Dune::MPIHelper::isFake) + if (Dune::MPIHelper::isFake) // NOLINT(readability-implicit-bool-conversion) return Dune::StructuredGridFactory<GridType>::createSimplexGrid(lowerLeft, upperRight, elements); # if HAVE_MPI if (mpi_comm == MPI_COMM_WORLD) @@ -184,7 +184,7 @@ public: std::array<unsigned int, GridType::dimension> = default_overlap<GridType>(), DXTC_MPI_ONLY Dune::MPIHelper::MPICommunicator mpi_comm = Dune::MPIHelper::getCommunicator()) { - if (Dune::MPIHelper::isFake) + if (Dune::MPIHelper::isFake) // NOLINT(readability-implicit-bool-conversion) return Dune::StructuredGridFactory<GridType>::createCubeGrid(lowerLeft, upperRight, elements); # if HAVE_MPI if (mpi_comm == MPI_COMM_WORLD) diff --git a/dune/xt/grid/view/coupling.hh b/dune/xt/grid/view/coupling.hh index 9cad8d2d8..16c254ac1 100644 --- a/dune/xt/grid/view/coupling.hh +++ b/dune/xt/grid/view/coupling.hh @@ -229,7 +229,6 @@ public: struct Codim : public Traits::template Codim<cd> {}; -public: CouplingGridViewWrapper(const MacroElementType& ss, const MacroElementType& nn, GridGlueType& dd_grid, diff --git a/dune/xt/test/common/memory.cc b/dune/xt/test/common/memory.cc index 2eac0235e..1788520d8 100644 --- a/dune/xt/test/common/memory.cc +++ b/dune/xt/test/common/memory.cc @@ -65,7 +65,7 @@ struct ScopeTest : public testing::Test CSP{e}; } }; -constexpr typename ScopeTest::T ScopeTest::constant; + TEST_F(ScopeTest, All) { diff --git a/dune/xt/test/common/numeric.cc b/dune/xt/test/common/numeric.cc index 95e580238..5f5b9f751 100644 --- a/dune/xt/test/common/numeric.cc +++ b/dune/xt/test/common/numeric.cc @@ -22,12 +22,12 @@ GTEST_TEST(MoveIfTest, All) double expected3 = 39916800; // 11! EXPECT_EQ(Dune::XT::Common::reduce(vals2.begin(), vals2.end(), 0.), expected1); EXPECT_EQ(Dune::XT::Common::transform_reduce(vals1.begin(), vals1.end(), vals2.begin(), 0.), expected1); - EXPECT_EQ(Dune::XT::Common::reduce(vals2.begin(), vals2.end(), 0., std::plus<double>()), expected1); + EXPECT_EQ(Dune::XT::Common::reduce(vals2.begin(), vals2.end(), 0., std::plus<>()), expected1); EXPECT_EQ(Dune::XT::Common::transform_reduce( - vals1.begin(), vals1.end(), vals2.begin(), 0., std::plus<double>(), std::multiplies<double>()), + vals1.begin(), vals1.end(), vals2.begin(), 0., std::plus<>(), std::multiplies<>()), expected1); - EXPECT_EQ(Dune::XT::Common::reduce(vals2.begin(), vals2.end(), 1., std::multiplies<double>()), expected2); + EXPECT_EQ(Dune::XT::Common::reduce(vals2.begin(), vals2.end(), 1., std::multiplies<>()), expected2); EXPECT_EQ(Dune::XT::Common::transform_reduce( - vals1.begin(), vals1.end(), vals2.begin(), 1., std::multiplies<double>(), std::plus<double>()), + vals1.begin(), vals1.end(), vals2.begin(), 1., std::multiplies<>(), std::plus<>()), expected3); } diff --git a/dune/xt/test/common/validation.cc b/dune/xt/test/common/validation.cc index 8a8cf584b..5ec6c9e30 100644 --- a/dune/xt/test/common/validation.cc +++ b/dune/xt/test/common/validation.cc @@ -41,7 +41,7 @@ struct ValidationTest : public testing::Test const int eps_fac = 4; const S scalar_eps = Epsilon<S>::value; - void all() + void all() const { using namespace boost::assign; { diff --git a/dune/xt/test/grid/periodic_gridview.cc b/dune/xt/test/grid/periodic_gridview.cc index 6ff220e88..6a61e054e 100644 --- a/dune/xt/test/grid/periodic_gridview.cc +++ b/dune/xt/test/grid/periodic_gridview.cc @@ -129,7 +129,7 @@ struct PeriodicViewTest : public testing::Test const auto global_intersection_coords = intersection.geometry().center(); const auto global_outside_intersection_coords = intersection_in_outside.geometry().center(); size_t coord_difference_count = 0; - size_t differing_coordinate; + size_t differing_coordinate = 0; for (size_t ii = 0; ii < dimDomain; ++ii) { if (Dune::XT::Common::FloatCmp::ne(global_outside_intersection_coords[ii], global_intersection_coords[ii])) { @@ -189,17 +189,24 @@ struct PeriodicViewTest : public testing::Test // the nonperiodic grid has (elements_per_direction-1)**dimDomain inner vertices size_t expected_num_vertices = std::pow(elements_per_direction - 1, dimDomain); // add number of vertices on faces (codim 1) - expected_num_vertices += std::pow(elements_per_direction - 1, dimDomain - 1) * (num_faces - num_periodic_faces / 2); + expected_num_vertices += + static_cast<size_t>(std::pow(elements_per_direction - 1, dimDomain - 1)) * (num_faces - num_periodic_faces / 2); // add number of vertices on edges (codim 2) const size_t num_edges = dimDomain == 1 ? 0 : (dimDomain == 2 ? 4 : 12); - size_t num_periodic_edges = is_partially_periodic ? num_periodic_faces * std::pow(2, dimDomain - 1) : num_edges; - if (is_nonperiodic) - num_periodic_edges = 0; - expected_num_vertices += - dimDomain == 1 - ? 0 - : std::pow(elements_per_direction - 1, dimDomain - 2) - * ((num_edges - num_periodic_edges) + num_periodic_edges / (is_partially_periodic ? 2 : 4)); + if constexpr (dimDomain == 1) + expected_num_vertices += 0; + else { + size_t num_periodic_edges; + if (is_nonperiodic) + num_periodic_edges = 0; + else if (is_partially_periodic) + num_periodic_edges = num_periodic_faces * std::pow(2, dimDomain - 1); + else + num_periodic_edges = num_edges; + expected_num_vertices += + static_cast<size_t>(std::pow(elements_per_direction - 1, dimDomain - 2)) + * ((num_edges - num_periodic_edges) + num_periodic_edges / (is_partially_periodic ? 2 : 4)); + } // add vertices on corners (codim 3) of grid if constexpr (dimDomain == 3) expected_num_vertices += is_partially_periodic ? 4 : (is_nonperiodic ? 8 : 1); diff --git a/python/dune/xt/common/fmatrix.hh b/python/dune/xt/common/fmatrix.hh index 540555c2a..2f62cbaa5 100644 --- a/python/dune/xt/common/fmatrix.hh +++ b/python/dune/xt/common/fmatrix.hh @@ -60,7 +60,7 @@ struct FieldMatrix_type_caster { list l(ROWS); for (size_t ii = 0; ii < src.size(); ++ii) { - object val = reinterpret_steal<object>(row_conv::cast(src[ii], policy, parent)); + auto val = reinterpret_steal<object>(row_conv::cast(src[ii], policy, parent)); if (!val) return handle(); PyList_SET_ITEM(l.ptr(), ii, val.release().ptr()); // steals a reference diff --git a/python/dune/xt/common/fvector.hh b/python/dune/xt/common/fvector.hh index c10341061..4211c3799 100644 --- a/python/dune/xt/common/fvector.hh +++ b/python/dune/xt/common/fvector.hh @@ -56,7 +56,7 @@ struct FieldVector_type_caster { list l(SZ); for (size_t ii = 0; ii < src.size(); ++ii) { - object val = reinterpret_steal<object>(value_conv::cast(src[ii], policy, parent)); + auto val = reinterpret_steal<object>(value_conv::cast(src[ii], policy, parent)); if (!val) return handle(); PyList_SET_ITEM(l.ptr(), ii, val.release().ptr()); // steals a reference diff --git a/python/dune/xt/grid/functors/refinement.cc b/python/dune/xt/grid/functors/refinement.cc index f43bc60b3..3d1bb3242 100644 --- a/python/dune/xt/grid/functors/refinement.cc +++ b/python/dune/xt/grid/functors/refinement.cc @@ -76,7 +76,6 @@ public: static void bind_leaf_factory(pybind11::module& m, const std::string& class_id = "maximum_element_volume_refine_functor") { - namespace py = pybind11; using namespace pybind11::literals; m.def( Common::to_camel_case(class_id).c_str(), @@ -85,13 +84,12 @@ public: }, "grid_provider"_a, "volume"_a, - py::keep_alive<0, 1>()); + pybind11::keep_alive<0, 1>()); } // ... bind_leaf_factory(...) static void bind_coupling_factory(pybind11::module& m, const std::string& class_id = "maximum_element_volume_refine_functor") { - namespace py = pybind11; using namespace pybind11::literals; m.def( Common::to_camel_case(class_id).c_str(), @@ -100,7 +98,7 @@ public: }, "coupling_grid_provider"_a, "volume"_a, - py::keep_alive<0, 1>()); + pybind11::keep_alive<0, 1>()); } }; // class MaximumEntityVolumeRefineFunctor -- GitLab From 0976118bfa71e06f0d14d2093efd11f2d3e1cf31 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Mon, 6 Dec 2021 15:09:08 +0100 Subject: [PATCH 15/19] Apply clang-format 13 --- .vcsetup | 2 +- dune/pybindxi/cast.h | 27 +++++++----- dune/pybindxi/detail/common.h | 10 +++-- dune/pybindxi/eigen.h | 17 +++---- dune/pybindxi/numpy.h | 5 ++- dune/pybindxi/operators.h | 28 +++++++----- dune/pybindxi/pytypes.h | 6 +-- dune/xt/functions/derivatives.hh | 2 +- dune/xt/functions/expression/mathexpr.cc | 2 +- dune/xt/la/eigen-solver/default.hh | 39 +++++++++-------- dune/xt/la/eigen-solver/fmatrix.hh | 56 ++++++++++++------------ 11 files changed, 106 insertions(+), 88 deletions(-) diff --git a/.vcsetup b/.vcsetup index ce8e39341..54b1404db 160000 --- a/.vcsetup +++ b/.vcsetup @@ -1 +1 @@ -Subproject commit ce8e3934191659ffa6d49e4a51e3ccb8f3b00719 +Subproject commit 54b1404db8322a29e93bbb9ad7d9f0ea06be046d diff --git a/dune/pybindxi/cast.h b/dune/pybindxi/cast.h index f67af5904..02514bb3f 100644 --- a/dune/pybindxi/cast.h +++ b/dune/pybindxi/cast.h @@ -129,7 +129,7 @@ public: { \ return value; \ } \ - operator type &&()&& \ + operator type&&()&& \ { \ return std::move(value); \ } \ @@ -446,8 +446,11 @@ struct string_caster #endif } - auto utfNbytes = reinterpret_steal<object>( - PyUnicode_AsEncodedString(load_src.ptr(), UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr)); + auto utfNbytes = reinterpret_steal<object>(PyUnicode_AsEncodedString(load_src.ptr(), + UTF_N == 8 ? "utf-8" + : UTF_N == 16 ? "utf-16" + : "utf-32", + nullptr)); if (!utfNbytes) { PyErr_Clear(); return false; @@ -484,9 +487,9 @@ private: static handle decode_utfN(const char* buffer, ssize_t nbytes) { #if !defined(PYPY_VERSION) - return UTF_N == 8 ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr) - : UTF_N == 16 ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr) - : PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr); + return UTF_N == 8 ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr) + : UTF_N == 16 ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr) + : PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr); #else // PyPy segfaults when on PyUnicode_DecodeUTF16 (and possibly on PyUnicode_DecodeUTF32 as well), // so bypass the whole thing by just passing the encoding as a string value, which works properly: @@ -1117,13 +1120,13 @@ object cast(T&& value, return_value_policy policy = return_value_policy::automat { using no_ref_T = typename std::remove_reference<T>::type; if (policy == return_value_policy::automatic) - policy = std::is_pointer<no_ref_T>::value - ? return_value_policy::take_ownership - : std::is_lvalue_reference<T>::value ? return_value_policy::copy : return_value_policy::move; + policy = std::is_pointer<no_ref_T>::value ? return_value_policy::take_ownership + : std::is_lvalue_reference<T>::value ? return_value_policy::copy + : return_value_policy::move; else if (policy == return_value_policy::automatic_reference) - policy = std::is_pointer<no_ref_T>::value - ? return_value_policy::reference - : std::is_lvalue_reference<T>::value ? return_value_policy::copy : return_value_policy::move; + policy = std::is_pointer<no_ref_T>::value ? return_value_policy::reference + : std::is_lvalue_reference<T>::value ? return_value_policy::copy + : return_value_policy::move; return reinterpret_steal<object>(detail::make_caster<T>::cast(std::forward<T>(value), policy, parent)); } diff --git a/dune/pybindxi/detail/common.h b/dune/pybindxi/detail/common.h index 5a7248e96..da586e0fd 100644 --- a/dune/pybindxi/detail/common.h +++ b/dune/pybindxi/detail/common.h @@ -983,9 +983,11 @@ struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>::value>> std::is_same<T, bool>::value ? 0 : 1 - + (std::is_integral<T>::value - ? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value - : 8 + (std::is_same<T, double>::value ? 1 : std::is_same<T, long double>::value ? 2 : 0)); + + (std::is_integral<T>::value ? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value + : 8 + + (std::is_same<T, double>::value ? 1 + : std::is_same<T, long double>::value ? 2 + : 0)); }; PYBIND11_NAMESPACE_END(detail) @@ -1121,7 +1123,7 @@ public: {} // Moves the vector out of an rvalue any_container - operator std::vector<T> &&() && + operator std::vector<T>&&() && { return std::move(v); } diff --git a/dune/pybindxi/eigen.h b/dune/pybindxi/eigen.h index d1d0cb4ba..86d16323a 100644 --- a/dune/pybindxi/eigen.h +++ b/dune/pybindxi/eigen.h @@ -162,7 +162,9 @@ struct EigenProps using if_zero = std::integral_constant<EigenIndex, i == 0 ? ifzero : i>; static constexpr EigenIndex inner_stride = if_zero<StrideType::InnerStrideAtCompileTime, 1>::value, outer_stride = if_zero < StrideType::OuterStrideAtCompileTime, - vector ? size : row_major ? cols : rows > ::value; + vector ? size + : row_major ? cols + : rows > ::value; static constexpr bool dynamic_stride = inner_stride == Eigen::Dynamic && outer_stride == Eigen::Dynamic; static constexpr bool requires_row_major = !dynamic_stride && !vector && (row_major ? inner_stride : outer_stride) == 1; @@ -388,7 +390,7 @@ public: { return value; } - operator Type &&() && + operator Type&&() && { return std::move(value); } @@ -458,12 +460,11 @@ private: using props = EigenProps<Type>; using Scalar = typename props::Scalar; using MapType = Eigen::Map<PlainObjectType, 0, StrideType>; - using Array = - array_t<Scalar, - array::forcecast - | ((props::row_major ? props::inner_stride : props::outer_stride) == 1 - ? array::c_style - : (props::row_major ? props::outer_stride : props::inner_stride) == 1 ? array::f_style : 0)>; + using Array = array_t<Scalar, + array::forcecast + | ((props::row_major ? props::inner_stride : props::outer_stride) == 1 ? array::c_style + : (props::row_major ? props::outer_stride : props::inner_stride) == 1 ? array::f_style + : 0)>; static constexpr bool need_writeable = is_eigen_mutable_map<Type>::value; // Delay construction (these have no default constructor) std::unique_ptr<MapType> map; diff --git a/dune/pybindxi/numpy.h b/dune/pybindxi/numpy.h index 7e45c2c96..8d3a991ff 100644 --- a/dune/pybindxi/numpy.h +++ b/dune/pybindxi/numpy.h @@ -1759,8 +1759,9 @@ broadcast_trivial broadcast(const std::array<buffer_info, N>& buffers, ssize_t& } } - return trivial_broadcast_c ? broadcast_trivial::c_trivial - : trivial_broadcast_f ? broadcast_trivial::f_trivial : broadcast_trivial::non_trivial; + return trivial_broadcast_c ? broadcast_trivial::c_trivial + : trivial_broadcast_f ? broadcast_trivial::f_trivial + : broadcast_trivial::non_trivial; } template <typename T> diff --git a/dune/pybindxi/operators.h b/dune/pybindxi/operators.h index 0f05eed67..b8ecdc235 100644 --- a/dune/pybindxi/operators.h +++ b/dune/pybindxi/operators.h @@ -112,8 +112,12 @@ struct op_ cl.def(op::name(), &op::execute, is_operator(), extra...); #if PY_MAJOR_VERSION < 3 if (id == op_truediv || id == op_itruediv) - cl.def( - id == op_itruediv ? "__idiv__" : ot == op_l ? "__div__" : "__rdiv__", &op::execute, is_operator(), extra...); + cl.def(id == op_itruediv ? "__idiv__" + : ot == op_l ? "__div__" + : "__rdiv__", + &op::execute, + is_operator(), + extra...); #endif } template <typename Class, typename... Extra> @@ -126,8 +130,12 @@ struct op_ cl.def(op::name(), &op::execute_cast, is_operator(), extra...); #if PY_MAJOR_VERSION < 3 if (id == op_truediv || id == op_itruediv) - cl.def( - id == op_itruediv ? "__idiv__" : ot == op_l ? "__div__" : "__rdiv__", &op::execute, is_operator(), extra...); + cl.def(id == op_itruediv ? "__idiv__" + : ot == op_l ? "__div__" + : "__rdiv__", + &op::execute, + is_operator(), + extra...); #endif } }; @@ -231,15 +239,15 @@ PYBIND11_BINARY_OPERATOR(mul, rmul, operator*, l* r) PYBIND11_BINARY_OPERATOR(truediv, rtruediv, operator/, l / r) PYBIND11_BINARY_OPERATOR(mod, rmod, operator%, l % r) PYBIND11_BINARY_OPERATOR(lshift, rlshift, operator<<, l << r) -PYBIND11_BINARY_OPERATOR(rshift, rrshift, operator>>, l>> r) +PYBIND11_BINARY_OPERATOR(rshift, rrshift, operator>>, l >> r) PYBIND11_BINARY_OPERATOR(and, rand, operator&, l& r) PYBIND11_BINARY_OPERATOR(xor, rxor, operator^, l ^ r) PYBIND11_BINARY_OPERATOR(eq, eq, operator==, l == r) PYBIND11_BINARY_OPERATOR(ne, ne, operator!=, l != r) PYBIND11_BINARY_OPERATOR(or, ror, operator|, l | r) -PYBIND11_BINARY_OPERATOR(gt, lt, operator>, l> r) +PYBIND11_BINARY_OPERATOR(gt, lt, operator>, l > r) PYBIND11_BINARY_OPERATOR(ge, le, operator>=, l >= r) -PYBIND11_BINARY_OPERATOR(lt, gt, operator<, l<r) +PYBIND11_BINARY_OPERATOR(lt, gt, operator<, l < r) PYBIND11_BINARY_OPERATOR(le, ge, operator<=, l <= r) // PYBIND11_BINARY_OPERATOR(pow, rpow, pow, std::pow(l, r)) PYBIND11_INPLACE_OPERATOR(iadd, operator+=, l += r) @@ -252,14 +260,14 @@ PYBIND11_INPLACE_OPERATOR(irshift, operator>>=, l >>= r) PYBIND11_INPLACE_OPERATOR(iand, operator&=, l &= r) PYBIND11_INPLACE_OPERATOR(ixor, operator^=, l ^= r) PYBIND11_INPLACE_OPERATOR(ior, operator|=, l |= r) -PYBIND11_UNARY_OPERATOR(neg, operator-, - l) -PYBIND11_UNARY_OPERATOR(pos, operator+, + l) +PYBIND11_UNARY_OPERATOR(neg, operator-, -l) +PYBIND11_UNARY_OPERATOR(pos, operator+, +l) // WARNING: This usage of `abs` should only be done for existing STL overloads. // Adding overloads directly in to the `std::` namespace is advised against: // https://en.cppreference.com/w/cpp/language/extending_std PYBIND11_UNARY_OPERATOR(abs, abs, std::abs(l)) PYBIND11_UNARY_OPERATOR(hash, hash, std::hash<L>()(l)) -PYBIND11_UNARY_OPERATOR(invert, operator~,(~l)) +PYBIND11_UNARY_OPERATOR(invert, operator~, (~l)) PYBIND11_UNARY_OPERATOR(bool, operator!, !!l) PYBIND11_UNARY_OPERATOR(int, int_, (int)l) PYBIND11_UNARY_OPERATOR(float, float_, (double)l) diff --git a/dune/pybindxi/pytypes.h b/dune/pybindxi/pytypes.h index 7336eb57b..a74607e54 100644 --- a/dune/pybindxi/pytypes.h +++ b/dune/pybindxi/pytypes.h @@ -1748,9 +1748,9 @@ public: template <typename T, detail::enable_if_t<std::is_integral<T>::value, int> = 0> operator T() const { - return std::is_unsigned<T>::value - ? detail::as_unsigned<T>(m_ptr) - : sizeof(T) <= sizeof(long) ? (T)PyLong_AsLong(m_ptr) : (T)PYBIND11_LONG_AS_LONGLONG(m_ptr); + return std::is_unsigned<T>::value ? detail::as_unsigned<T>(m_ptr) + : sizeof(T) <= sizeof(long) ? (T)PyLong_AsLong(m_ptr) + : (T)PYBIND11_LONG_AS_LONGLONG(m_ptr); } }; diff --git a/dune/xt/functions/derivatives.hh b/dune/xt/functions/derivatives.hh index 8cb6fde49..6072e6141 100644 --- a/dune/xt/functions/derivatives.hh +++ b/dune/xt/functions/derivatives.hh @@ -22,7 +22,7 @@ namespace Dune::XT::Functions { template <class E, class R> DivergenceElementFunction<ElementFunctionInterface<E, E::dimension, 1, R>> - divergence(ElementFunctionInterface<E, E::dimension, 1, R>& func) +divergence(ElementFunctionInterface<E, E::dimension, 1, R>& func) { return DivergenceElementFunction<ElementFunctionInterface<E, E::dimension, 1, R>>(func); } diff --git a/dune/xt/functions/expression/mathexpr.cc b/dune/xt/functions/expression/mathexpr.cc index d824d3366..2d67d0a02 100644 --- a/dune/xt/functions/expression/mathexpr.cc +++ b/dune/xt/functions/expression/mathexpr.cc @@ -1550,7 +1550,7 @@ ROperation ROperation::Diff(const RVar& var) const ppop1 = new ROperation*[j]; for (i = 0; i < j; i++) ppop1[i] = new ROperation(NthMember(i + 1).Diff(var)); - op2 = ApplyOperator(pfunc->nvars, ppop1, &operator,); + op2 = ApplyOperator(pfunc->nvars, ppop1, &operator, ); for (i = 0; i < pfunc->nvars; i++) delete ppop1[i]; delete[] ppop1; diff --git a/dune/xt/la/eigen-solver/default.hh b/dune/xt/la/eigen-solver/default.hh index 06076cff7..d563f8f08 100644 --- a/dune/xt/la/eigen-solver/default.hh +++ b/dune/xt/la/eigen-solver/default.hh @@ -103,26 +103,27 @@ protected: } } else #endif // HAVE_LAPACKE || HAVE_MKL - if (type == "shifted_qr") { - if (options_->template get<bool>("compute_eigenvalues") || options_->template get<bool>("compute_eigenvectors")) { - eigenvalues_ = std::make_unique<std::vector<ComplexType>>(rows); - eigenvectors_ = ComplexM::make_unique(rows, cols); - std::vector<RealType> real_eigenvalues(rows); - auto real_eigenvectors = RealM::make_unique(rows, cols); - internal::compute_real_eigenvalues_and_real_right_eigenvectors_using_qr( - matrix_, real_eigenvalues, *real_eigenvectors); - for (size_t ii = 0; ii < rows; ++ii) { - (*eigenvalues_)[ii] = real_eigenvalues[ii]; - for (size_t jj = 0; jj < cols; ++jj) - ComplexM::set_entry(*eigenvectors_, ii, jj, RealM::get_entry(*real_eigenvectors, ii, jj)); + if (type == "shifted_qr") { + if (options_->template get<bool>("compute_eigenvalues") + || options_->template get<bool>("compute_eigenvectors")) { + eigenvalues_ = std::make_unique<std::vector<ComplexType>>(rows); + eigenvectors_ = ComplexM::make_unique(rows, cols); + std::vector<RealType> real_eigenvalues(rows); + auto real_eigenvectors = RealM::make_unique(rows, cols); + internal::compute_real_eigenvalues_and_real_right_eigenvectors_using_qr( + matrix_, real_eigenvalues, *real_eigenvectors); + for (size_t ii = 0; ii < rows; ++ii) { + (*eigenvalues_)[ii] = real_eigenvalues[ii]; + for (size_t jj = 0; jj < cols; ++jj) + ComplexM::set_entry(*eigenvectors_, ii, jj, RealM::get_entry(*real_eigenvectors, ii, jj)); + } } - } - } else - DUNE_THROW(Common::Exceptions::internal_error, - "Given type '" << type << "' is none of EigenSolverOptions<...>::types()," - << " and internal::EigenSolverBase promised to check this!" - << "\n\nThese are the available types:\n\n" - << EigenSolverOptions<MatrixType>::types()); + } else + DUNE_THROW(Common::Exceptions::internal_error, + "Given type '" << type << "' is none of EigenSolverOptions<...>::types()," + << " and internal::EigenSolverBase promised to check this!" + << "\n\nThese are the available types:\n\n" + << EigenSolverOptions<MatrixType>::types()); } //... compute(...) using BaseType::eigenvalues_; diff --git a/dune/xt/la/eigen-solver/fmatrix.hh b/dune/xt/la/eigen-solver/fmatrix.hh index 03d405d1e..93a43841b 100644 --- a/dune/xt/la/eigen-solver/fmatrix.hh +++ b/dune/xt/la/eigen-solver/fmatrix.hh @@ -148,34 +148,36 @@ protected: } } else #endif // HAVE_EIGEN - if (type == "numpy") { - if (options_->template get<bool>("compute_eigenvalues") || options_->template get<bool>("compute_eigenvectors")) { - eigenvalues_ = std::make_unique<std::vector<XT::Common::complex_t<K>>>(SIZE); - eigenvectors_ = std::make_unique<Dune::FieldMatrix<XT::Common::complex_t<K>, SIZE, SIZE>>(); - internal::compute_eigenvalues_and_right_eigenvectors_of_a_fieldmatrix_using_numpy( - matrix_, *eigenvalues_, *eigenvectors_); - } - } else if (type == "shifted_qr") { - if (options_->template get<bool>("compute_eigenvalues") || options_->template get<bool>("compute_eigenvectors")) { - eigenvalues_ = std::make_unique<std::vector<XT::Common::complex_t<K>>>(SIZE); - eigenvectors_ = std::make_unique<Dune::FieldMatrix<XT::Common::complex_t<K>, SIZE, SIZE>>(); - std::vector<XT::Common::real_t<K>> real_eigenvalues(SIZE); - auto real_eigenvectors = std::make_unique<Dune::FieldMatrix<XT::Common::real_t<K>, SIZE, SIZE>>(); - internal::compute_real_eigenvalues_and_real_right_eigenvectors_using_qr( - matrix_, real_eigenvalues, *real_eigenvectors); - for (size_t ii = 0; ii < SIZE; ++ii) { - (*eigenvalues_)[ii] = real_eigenvalues[ii]; - for (size_t jj = 0; jj < SIZE; ++jj) - (*eigenvectors_)[ii][jj] = (*real_eigenvectors)[ii][jj]; + if (type == "numpy") { + if (options_->template get<bool>("compute_eigenvalues") + || options_->template get<bool>("compute_eigenvectors")) { + eigenvalues_ = std::make_unique<std::vector<XT::Common::complex_t<K>>>(SIZE); + eigenvectors_ = std::make_unique<Dune::FieldMatrix<XT::Common::complex_t<K>, SIZE, SIZE>>(); + internal::compute_eigenvalues_and_right_eigenvectors_of_a_fieldmatrix_using_numpy( + matrix_, *eigenvalues_, *eigenvectors_); } - } - } else - DUNE_THROW(Common::Exceptions::internal_error, - "Given type '" << type - << "' is none of EigenSolverOptions<Dune::FieldMatrix<K, ROWS, " - "COLS>>::types(), and internal::EigenSolverBase promised to check this!" - << "\n\nThese are the available types:\n\n" - << EigenSolverOptions<MatrixType>::types()); + } else if (type == "shifted_qr") { + if (options_->template get<bool>("compute_eigenvalues") + || options_->template get<bool>("compute_eigenvectors")) { + eigenvalues_ = std::make_unique<std::vector<XT::Common::complex_t<K>>>(SIZE); + eigenvectors_ = std::make_unique<Dune::FieldMatrix<XT::Common::complex_t<K>, SIZE, SIZE>>(); + std::vector<XT::Common::real_t<K>> real_eigenvalues(SIZE); + auto real_eigenvectors = std::make_unique<Dune::FieldMatrix<XT::Common::real_t<K>, SIZE, SIZE>>(); + internal::compute_real_eigenvalues_and_real_right_eigenvectors_using_qr( + matrix_, real_eigenvalues, *real_eigenvectors); + for (size_t ii = 0; ii < SIZE; ++ii) { + (*eigenvalues_)[ii] = real_eigenvalues[ii]; + for (size_t jj = 0; jj < SIZE; ++jj) + (*eigenvectors_)[ii][jj] = (*real_eigenvectors)[ii][jj]; + } + } + } else + DUNE_THROW(Common::Exceptions::internal_error, + "Given type '" << type + << "' is none of EigenSolverOptions<Dune::FieldMatrix<K, ROWS, " + "COLS>>::types(), and internal::EigenSolverBase promised to check this!" + << "\n\nThese are the available types:\n\n" + << EigenSolverOptions<MatrixType>::types()); } //... compute(...) using BaseType::eigenvalues_; -- GitLab From 42323da48ad259955e0f082299bbbba28b35803d Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Mon, 13 Dec 2021 11:27:15 +0100 Subject: [PATCH 16/19] Update .vcsetup --- .vcsetup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vcsetup b/.vcsetup index 54b1404db..6d6fcbd82 160000 --- a/.vcsetup +++ b/.vcsetup @@ -1 +1 @@ -Subproject commit 54b1404db8322a29e93bbb9ad7d9f0ea06be046d +Subproject commit 6d6fcbd8272d8c2e9bae70afe0f3841e6f9d1c80 -- GitLab From 4ab5605f4c3e99cda0e6086f65f4b520c7469ebc Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Wed, 15 Dec 2021 12:03:57 +0100 Subject: [PATCH 17/19] [test.periodic_gridview] remove unnecessary statement, cleanup --- dune/xt/test/grid/periodic_gridview.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/dune/xt/test/grid/periodic_gridview.cc b/dune/xt/test/grid/periodic_gridview.cc index 6a61e054e..c37e0b427 100644 --- a/dune/xt/test/grid/periodic_gridview.cc +++ b/dune/xt/test/grid/periodic_gridview.cc @@ -161,20 +161,18 @@ struct PeriodicViewTest : public testing::Test } // the cube/rectangle grid has 2*dimDomain faces - const size_t num_faces = 2 * dimDomain; + constexpr size_t num_faces = 2 * dimDomain; /* on each face, there are elements_per_direction**(dimDomain-1) intersections. For a simplex grid in 3 dimensions, * there are twice as * much. */ size_t num_intersections_on_face = std::pow(elements_per_direction, dimDomain - 1); - assert(dimDomain == Common::from_string<int>(grid_config["dimDomain"])); - const auto domainDim = Common::from_string<int>(grid_config["dimDomain"]); - if (is_simplex && domainDim == 3) // use dimDomain from config here to avoid "code will never be executed" warning - num_intersections_on_face *= 2; + if constexpr (dimDomain == 3) { + if (is_simplex) + num_intersections_on_face *= 2; + } /* In a fully periodic grid, all intersections are periodic. In a partially periodic grid, only the intersections on * two faces are periodic. In a nonperiodic grid, no intersections are periodic. */ - size_t num_periodic_faces = is_partially_periodic ? 2 : num_faces; - if (is_nonperiodic) - num_periodic_faces *= 0; + const size_t num_periodic_faces = is_nonperiodic ? 0 : (is_partially_periodic ? 2 : num_faces); const size_t expected_num_periodic_intersections = num_periodic_faces * num_intersections_on_face; EXPECT_EQ(expected_num_periodic_intersections, periodic_count); // The boundary count should be the number of interfaces on the boundary without the periodic interfaces @@ -191,11 +189,9 @@ struct PeriodicViewTest : public testing::Test // add number of vertices on faces (codim 1) expected_num_vertices += static_cast<size_t>(std::pow(elements_per_direction - 1, dimDomain - 1)) * (num_faces - num_periodic_faces / 2); - // add number of vertices on edges (codim 2) - const size_t num_edges = dimDomain == 1 ? 0 : (dimDomain == 2 ? 4 : 12); - if constexpr (dimDomain == 1) - expected_num_vertices += 0; - else { + if constexpr (dimDomain > 1) { + // add number of vertices on edges (codim 2) + constexpr size_t num_edges = dimDomain == 2 ? 4 : 12; size_t num_periodic_edges; if (is_nonperiodic) num_periodic_edges = 0; -- GitLab From c4ba3307168e758ad6f9fc8db23a1d432281761a Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Wed, 15 Dec 2021 16:34:03 +0100 Subject: [PATCH 18/19] Add back clang-tidy cmake infrastructure --- .vcsetup | 2 +- CMakeLists.txt | 1 + apply_clang_tidy.sh | 27 --------- cmake/modules/CMakeLists.txt | 1 + cmake/modules/DuneXTTesting.cmake | 12 +--- cmake/modules/FindClangTidy.cmake | 45 +++++++++++++++ cmake/modules/XtTooling.cmake | 92 ++++++++++++++++++++++++++++++- 7 files changed, 141 insertions(+), 39 deletions(-) delete mode 100755 apply_clang_tidy.sh create mode 100644 cmake/modules/FindClangTidy.cmake diff --git a/.vcsetup b/.vcsetup index 6d6fcbd82..86ebedc6c 160000 --- a/.vcsetup +++ b/.vcsetup @@ -1 +1 @@ -Subproject commit 6d6fcbd8272d8c2e9bae70afe0f3841e6f9d1c80 +Subproject commit 86ebedc6c9286805942274f97997af9bf63dad6e diff --git a/CMakeLists.txt b/CMakeLists.txt index 7919a7b27..9cc8a9f19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,7 @@ add_subdirectory(dune) add_subdirectory("cmake/modules") add_subdirectory(doc/doxygen) +add_tidy(${CMAKE_CURRENT_SOURCE_DIR}) add_pylicense() finalize_dune_project(GENERATE_CONFIG_H_CMAKE) diff --git a/apply_clang_tidy.sh b/apply_clang_tidy.sh deleted file mode 100755 index 288a4857e..000000000 --- a/apply_clang_tidy.sh +++ /dev/null @@ -1,27 +0,0 @@ -# This script assumes that clang-tidy is installed and in the PATH. -# In addition, clang-tidy needs a compilation database, so you have to run -# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . -# in your build directory and then copy or symlink the resulting -# compile_commands.json to the source directory. - -# It is possible to run clang-tidy on the whole directory at once, using parallelism and all. -# However, even with the run-clang-tidy.py script and -j1, the fixes are applied several -# times to each header (once for each compilation unit in which the header is included), -# resulting in messed up files. We thus simply run clang-tidy sequentially for each -# compilation unit. This takes a long time, but since we only have to do this every -# now and then and can do other stuff while waiting for the script, this should be fine. - -# Headerchecks -BUILD_DIR=../build/clang-debug/dune-xt -CLANG_TIDY_BINARY=clang-tidy -for file in `find ${BUILD_DIR}/headercheck -name *.hh.cc`; do - ${CLANG_TIDY_BINARY} --config-file=.clang-tidy -fix ${file} -done -# Regular C++ files -for file in `find dune/xt/ -name *.cc`; do - ${CLANG_TIDY_BINARY} --config-file=.clang-tidy -fix ${file} -done -# Python bindings -for file in `find python/ -name *.cc`; do - ${CLANG_TIDY_BINARY} --config-file=.clang-tidy -fix ${file} -done diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index ea3c79543..47a32a45b 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -18,6 +18,7 @@ install( DuneXtVersionHelper.cmake DunePybindxiMacros.cmake DunePybindxiUtils.cmake + FindClangTidy.cmake FindEigen3.cmake FindFASP.cmake FindLIKWID.cmake diff --git a/cmake/modules/DuneXTTesting.cmake b/cmake/modules/DuneXTTesting.cmake index 76792c04e..4a51d4126 100644 --- a/cmake/modules/DuneXTTesting.cmake +++ b/cmake/modules/DuneXTTesting.cmake @@ -12,18 +12,11 @@ # Tobias Leibner (2015 - 2020) # ~~~ -macro(DXT_HEADERCHECK_TARGET_NAME arg) - string(REGEX REPLACE ".*/([^/]*)" "\\1" simple ${arg}) - string(REPLACE ${PROJECT_SOURCE_DIR} "" rel ${arg}) - string(REGEX REPLACE "(.*)/[^/]*" "\\1" relpath ${rel}) - string(REGEX REPLACE "/" "_" targname ${rel}) - set(targname "headercheck_${targname}") -endmacro(DXT_HEADERCHECK_TARGET_NAME) +include(XtTooling) macro(GET_HEADERCHECK_TARGETS subdir) file(GLOB_RECURSE bindir_header "${CMAKE_BINARY_DIR}/*.hh") list(APPEND dxt_ignore_header ${bindir_header}) - if(ENABLE_HEADERCHECK) file(GLOB_RECURSE headerlist "${CMAKE_SOURCE_DIR}/dune/xt/${subdir}/*.hh" "${CMAKE_SOURCE_DIR}/dune/xt/test/${subdir}/*.hh" "${CMAKE_SOURCE_DIR}/python/dune/xt/${subdir}/*.hh") @@ -34,7 +27,8 @@ macro(GET_HEADERCHECK_TARGETS subdir) continue() endif() # do some name conversion set(targname ${header}) - dxt_headercheck_target_name(${targname}) + dxt_path_to_headercheck_name(targname) + set(targname "headercheck_${targname}") list(APPEND ${subdir}_dxt_headercheck_targets "${targname}") add_dependencies(${subdir}_headercheck ${targname}) endforeach(header ${headerlist}) diff --git a/cmake/modules/FindClangTidy.cmake b/cmake/modules/FindClangTidy.cmake new file mode 100644 index 000000000..72b3173fb --- /dev/null +++ b/cmake/modules/FindClangTidy.cmake @@ -0,0 +1,45 @@ +# ~~~ +# This file is part of the dune-xt project: +# https://zivgitlab.uni-muenster.de/ag-ohlberger/dune-community/dune-xt +# Copyright 2009-2021 dune-xt developers and contributors. All rights reserved. +# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +# or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +# with "runtime exception" (http://www.dune-project.org/license.html) +# Authors: +# Felix Schindler (2017) +# René Fritze (2016, 2018 - 2020) +# Tobias Leibner (2020) +# +# Use this module by invoking find_package with the form:: +# +# find_package(ClangTidy +# [version] # Minimum version e.g. 3.7 +# ) +# +# optionally pass the minimal version you require like so find_package(ClangTidy 3.7) +# this module set ClangTidy_EXECUTABLE, ClangTidy_VERSION +# and ClangTidy_FOUND accordingly +# ~~~ + +find_program( + ClangTidy_EXECUTABLE + NAMES clang-tidy + clang-tidy-8 + clang-tidy-9 + clang-tidy-10 + clang-tidy-11 + clang-tidy-12 + clang-tidy-13 + clang-tidy-14) +if(EXISTS ${ClangTidy_EXECUTABLE}) + execute_process(COMMAND ${ClangTidy_EXECUTABLE} -version OUTPUT_VARIABLE clang_out) + string(REGEX REPLACE ".*LLVM version ([0-9]+)\.[0-9]+\.[0-9]*.*" "\\1" ClangTidy_VERSION ${clang_out}) +endif() + +find_program(RunTidy_EXECUTABLE NAMES run-clang-tidy-${ClangTidy_VERSION}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + ClangTidy + REQUIRED_VARS ClangTidy_EXECUTABLE + VERSION_VAR ClangTidy_VERSION) diff --git a/cmake/modules/XtTooling.cmake b/cmake/modules/XtTooling.cmake index f881b4154..b6013ac81 100644 --- a/cmake/modules/XtTooling.cmake +++ b/cmake/modules/XtTooling.cmake @@ -16,9 +16,97 @@ macro(ADD_FORMAT) add_custom_target("format" echo 'clang-format is now a pre-commit hook' && false) endmacro(ADD_FORMAT) +# Converts the path to a source file to a unique name that can be used as a target name. If arg points to a header file, +# the corresponding headercheck target is headercheck_${arg} after calling this function. Example: +# /home/user/dune-xt-super/dune-xt/dune/xt/common/algorithm.hh becomes _dune_xt_common_algorithm.hh +function(dxt_path_to_headercheck_name arg) + string(REPLACE ${PROJECT_SOURCE_DIR} "" rel ${${arg}}) + string(REGEX REPLACE "/" "_" final ${rel}) + set(${arg} + ${final} + PARENT_SCOPE) +endfunction() + +# Creates targets tidy_* and fix_tidy_* for all source files. These targets apply clang-tidy and clang-tidy -fix, +# respectively, to that file. This macro also creates unqualified tidy and fix_tidy targets which apply clang-tidy to +# all source files. In addition, a target fix_tidy_parallel is created which may be used to run several clang-tidy -fix +# targets in parallel (Parallelity is controlled by the build system, e.g. ninja -j8 fix_tidy_parallel will run 8 +# targets in parallel). Note that fix_tidy_parallel may apply the fixes several times to each header (once for each +# compilation unit in which the header is included) and thus often produces broken source files. So if you expect more +# than a few fixes you probably want to avoid clang_tidy_parallel and just do something else while waiting for the +# fix_tidy command to be finished. macro(ADD_TIDY) - add_custom_target("tidy" echo 'clang-tidy support was removed' && false) -endmacro(ADD_TIDY) + find_package(ClangTidy 12) + if(ClangTidy_FOUND) + dune_symlink_to_source_files(FILES .clang-tidy) + message(STATUS "adding tidy target") + set(BASE ${PROJECT_SOURCE_DIR}/dune/xt/) + file( + GLOB_RECURSE + _files + "${BASE}/*.hh" + "${BASE}/*.h" + "${BASE}/*.cc" + "${BASE}/*.cxx" + "${BASE}/*.cpp" + "${BASE}/*.c") + set(BASE ${PROJECT_SOURCE_DIR}/python/) + file( + GLOB_RECURSE + _pyfiles + "${BASE}/*.hh" + "${BASE}/*.h" + "${BASE}/*.cc" + "${BASE}/*.cxx" + "${BASE}/*.cpp" + "${BASE}/*.c") + list(APPEND _files ${_pyfiles}) + list(REMOVE_DUPLICATES _files) + set(TIDY_ARGS --config-file=${CMAKE_SOURCE_DIR}/.clang-tidy -extra-arg-before='-includeconfig.h' + -p=${CMAKE_BINARY_DIR}) + set(fix_tidy_commands) + add_custom_target(tidy) + add_custom_target( + fix_tidy_parallel + COMMENT "If your fixes have been applied several times to each file, run this command sequentially (-j1)") + foreach(file ${_files}) + if(${file} MATCHES ".*/functions/expression/mathexpr.*" OR ${file} MATCHES ".*/test/gtest/gtest.*") + continue() + endif() + set(targname ${file}) + dxt_path_to_headercheck_name(targname) + # Add targets for individual files + add_custom_target( + tidy_${targname} + ${ClangTidy_EXECUTABLE} ${TIDY_ARGS} ${file} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + add_custom_target( + fix_tidy_${targname} + ${ClangTidy_EXECUTABLE} ${TIDY_ARGS} -fix ${file} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + # Add these targets as dependency to the global targets + add_dependencies(tidy tidy_${targname}) + add_dependencies(fix_tidy_parallel fix_tidy_${targname}) + # In addition, store the commands in a list to apply them all sequentially in the fix_tidy target) + list( + APPEND + fix_tidy_commands + COMMAND + ${ClangTidy_EXECUTABLE} + ${TIDY_ARGS} + -fix + ${file}) + endforeach() + add_custom_target( + fix_tidy + ${fix_tidy_commands} + COMMENT "Running clang-tidy -fix for all files, this will take a very long time..." + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + else() + message(WARNING "not adding tidy target because clang-tidy is missing or" + "wrong version: ${ClangTidy_EXECUTABLE} ${ClangTidy_VERSION}") + endif(ClangTidy_FOUND) +endmacro() macro(ADD_FORCED_DOXYGEN_TARGET) add_doxygen_target() -- GitLab From e31a3826980be2c38a774072f25745760989506a Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Wed, 15 Dec 2021 16:47:04 +0100 Subject: [PATCH 19/19] Some more clang-tidy fixes --- dune/xt/test/common.cxx | 12 ++++++------ .../dune/xt/functions/interfaces/element-function.hh | 1 - python/dune/xt/functions/interfaces/grid-function.hh | 1 - python/dune/xt/la/container/matrix-interface.hh | 2 -- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dune/xt/test/common.cxx b/dune/xt/test/common.cxx index d99823514..97b3f1da3 100644 --- a/dune/xt/test/common.cxx +++ b/dune/xt/test/common.cxx @@ -30,9 +30,9 @@ void busywait(const size_t ms) // "round" up to next full 10 ms to align with native timer res const size_t milliseconds = (ms / 10) * 10 + 10; timeval start, end; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); do { - gettimeofday(&end, NULL); + gettimeofday(&end, nullptr); } while (((end.tv_sec - start.tv_sec) * 1e6) + ((end.tv_usec - start.tv_usec)) < milliseconds * 1000); } // ... busywait(...) @@ -91,19 +91,19 @@ std::string get_unique_test_name() }; std::string result; const auto* test_case_name = test_info->test_case_name(); - if (test_case_name) { + if (test_case_name != nullptr) { result += replace_if(test_case_name); } const auto* name = test_info->name(); - if (name) { + if (name != nullptr) { result += result.empty() ? "" : "." + replace_if(name); } const auto* type_param = test_info->type_param(); - if (type_param) { + if (type_param != nullptr) { result += result.empty() ? "" : "." + replace_if(type_param); } const auto* value_param = test_info->value_param(); - if (value_param) { + if (value_param != nullptr) { result += result.empty() ? "" : "." + replace_if(value_param); } std::replace(result.begin(), result.end(), '/', '.'); diff --git a/python/dune/xt/functions/interfaces/element-function.hh b/python/dune/xt/functions/interfaces/element-function.hh index 62207ecea..084dfd19a 100644 --- a/python/dune/xt/functions/interfaces/element-function.hh +++ b/python/dune/xt/functions/interfaces/element-function.hh @@ -324,7 +324,6 @@ public: const std::string& layer_id = "", const std::string& class_id = "element_function_set_interface") { - namespace py = pybind11; using namespace pybind11::literals; const auto ClassName = Common::to_camel_case(class_name(grid_id, layer_id, class_id)); diff --git a/python/dune/xt/functions/interfaces/grid-function.hh b/python/dune/xt/functions/interfaces/grid-function.hh index a3a1ddde8..db3eef4d6 100644 --- a/python/dune/xt/functions/interfaces/grid-function.hh +++ b/python/dune/xt/functions/interfaces/grid-function.hh @@ -170,7 +170,6 @@ public: const std::string& layer_id = "", const std::string& class_id = "grid_function_interface") { - namespace py = pybind11; using namespace pybind11::literals; const auto ClassName = Common::to_camel_case(class_name(grid_id, layer_id, class_id)); diff --git a/python/dune/xt/la/container/matrix-interface.hh b/python/dune/xt/la/container/matrix-interface.hh index 285ecd5a8..6d4c74e5c 100644 --- a/python/dune/xt/la/container/matrix-interface.hh +++ b/python/dune/xt/la/container/matrix-interface.hh @@ -290,8 +290,6 @@ auto bind_Matrix(pybind11::module& m) template <class M, class V> void addbind_Matrix_Vector_interaction(pybind11::class_<M>& mat, pybind11::class_<V>& vec) { - namespace py = pybind11; - mat.def( "mv", [](const M& self, const V& xx, V& yy) { self.mv(xx, yy); }, "source", "range"); mat.def( -- GitLab