From c5d2598c3b81255cc1ad830a41f9953c5b77c3ab Mon Sep 17 00:00:00 2001 From: Felix Schindler <felix.schindler@wwu.de> Date: Thu, 2 Jul 2020 17:14:53 +0200 Subject: [PATCH] fix some warnings --- dune/xt/functions/grid-function.hh | 81 ++++++++++++------- dune/xt/grid/boundaryinfo/interfaces.hh | 8 +- python/dune/xt/common/empty.cc | 8 +- python/dune/xt/grid/boundaryinfo/types.cc | 2 +- python/dune/xt/grid/gridprovider.hh | 4 +- .../xt/la/container/container-interface.hh | 10 +-- 6 files changed, 68 insertions(+), 45 deletions(-) diff --git a/dune/xt/functions/grid-function.hh b/dune/xt/functions/grid-function.hh index f4d304436..0fd72df50 100644 --- a/dune/xt/functions/grid-function.hh +++ b/dune/xt/functions/grid-function.hh @@ -126,31 +126,38 @@ public: using typename BaseType::LocalFunctionType; GridFunction(const typename RangeTypeSelector<R, r, rC>::type& value) - : storage_(new FunctionAsGridFunctionWrapper<E, r, rC, R>(new ConstantFunction<d, r, rC, R>(value))) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, r, rC, R>(new ConstantFunction<d, r, rC, R>(value))) {} GridFunction(const FunctionInterface<d, r, rC, R>& func) - : storage_(new FunctionAsGridFunctionWrapper<E, r, rC, R>(func)) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, r, rC, R>(func)) {} GridFunction(FunctionInterface<d, r, rC, R>*&& func_ptr) - : storage_(new FunctionAsGridFunctionWrapper<E, r, rC, R>(std::move(func_ptr))) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, r, rC, R>(std::move(func_ptr))) {} GridFunction(const GridFunctionInterface<E, r, rC, R>& func) - : storage_(func) + : BaseType() + , storage_(func) {} GridFunction(GridFunctionInterface<E, r, rC, R>*&& func_ptr) - : storage_(std::move(func_ptr)) + : BaseType() + , storage_(std::move(func_ptr)) {} GridFunction(const ThisType& other) - : storage_(other.storage_) + : BaseType(other) + , storage_(other.storage_) {} GridFunction(ThisType&& source) - : storage_(std::move(source.storage_)) + : BaseType(source) + , storage_(std::move(source.storage_)) {} std::unique_ptr<LocalFunctionType> local_function() const override final @@ -192,58 +199,70 @@ public: using typename BaseType::LocalFunctionType; GridFunction(const R& value) - : storage_(new ProductGridFunction<GridFunction<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( + : BaseType() + , storage_(new ProductGridFunction<GridFunction<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( new GridFunction<E, 1, 1, R>(value), std::move(unit_matrix()), "")) {} GridFunction(const FieldMatrix<R, r, r>& value) // <- Must not be XT::Common::FieldMatrix! - : storage_(new FunctionAsGridFunctionWrapper<E, r, r, R>(new ConstantFunction<d, r, r, R>(value))) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, r, r, R>(new ConstantFunction<d, r, r, R>(value))) {} GridFunction(const FunctionInterface<d, 1, 1, R>& func) - : storage_(new ProductGridFunction<FunctionAsGridFunctionWrapper<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( + : BaseType() + , storage_(new ProductGridFunction<FunctionAsGridFunctionWrapper<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( new FunctionAsGridFunctionWrapper<E, 1, 1, R>(func), std::move(unit_matrix()), func.name())) {} GridFunction(FunctionInterface<d, 1, 1, R>*&& func_ptr) - : storage_(new ProductGridFunction<FunctionAsGridFunctionWrapper<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( + : BaseType() + , storage_(new ProductGridFunction<FunctionAsGridFunctionWrapper<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( new FunctionAsGridFunctionWrapper<E, 1, 1, R>(std::move(func_ptr)), std::move(unit_matrix()), func_ptr->name())) {} GridFunction(const FunctionInterface<d, r, r, R>& func) - : storage_(new FunctionAsGridFunctionWrapper<E, r, r, R>(func)) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, r, r, R>(func)) {} GridFunction(FunctionInterface<d, r, r, R>*&& func_ptr) - : storage_(new FunctionAsGridFunctionWrapper<E, r, r, R>(std::move(func_ptr))) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, r, r, R>(std::move(func_ptr))) {} GridFunction(const GridFunctionInterface<E, 1, 1, R>& func) - : storage_(new ProductGridFunction<GridFunction<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( + : BaseType() + , storage_(new ProductGridFunction<GridFunction<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( new GridFunction<E, 1, 1, R>(func), std::move(unit_matrix()), func.name())) {} GridFunction(GridFunctionInterface<E, 1, 1, R>*&& func_ptr) - : storage_(new ProductGridFunction<GridFunctionInterface<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( + : BaseType() + , storage_(new ProductGridFunction<GridFunctionInterface<E, 1, 1, R>, GridFunctionInterface<E, r, r, R>>( std::move(func_ptr), std::move(unit_matrix()), func_ptr->name())) {} GridFunction(const GridFunctionInterface<E, r, r, R>& func) - : storage_(func) + : BaseType() + , storage_(func) {} GridFunction(GridFunctionInterface<E, r, r, R>*&& func_ptr) - : storage_(std::move(func_ptr)) + : BaseType() + , storage_(std::move(func_ptr)) {} GridFunction(const ThisType& other) - : storage_(other.storage_) + : BaseType(other) + , storage_(other.storage_) {} GridFunction(ThisType&& source) - : storage_(std::move(source.storage_)) + : BaseType(source) + , storage_(std::move(source.storage_)) {} std::unique_ptr<LocalFunctionType> local_function() const override final @@ -279,35 +298,43 @@ public: using typename BaseType::LocalFunctionType; GridFunction(const R& value) - : storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(new ConstantFunction<d, 1, 1, R>(value))) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(new ConstantFunction<d, 1, 1, R>(value))) {} GridFunction(const FieldVector<R, 1>& value) // <- Must not be XT::Common::FieldVector! - : storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(new ConstantFunction<d, 1, 1, R>(value))) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(new ConstantFunction<d, 1, 1, R>(value))) {} GridFunction(const FunctionInterface<d, 1, 1, R>& func) - : storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(func)) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(func)) {} GridFunction(FunctionInterface<d, 1, 1, R>*&& func_ptr) - : storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(std::move(func_ptr))) + : BaseType() + , storage_(new FunctionAsGridFunctionWrapper<E, 1, 1, R>(std::move(func_ptr))) {} GridFunction(const GridFunctionInterface<E, 1, 1, R>& func) - : storage_(func) + : BaseType() + , storage_(func) {} GridFunction(GridFunctionInterface<E, 1, 1, R>*&& func_ptr) - : storage_(std::move(func_ptr)) + : BaseType() + , storage_(std::move(func_ptr)) {} GridFunction(const ThisType& other) - : storage_(other.storage_) + : BaseType(other) + , storage_(other.storage_) {} GridFunction(ThisType&& source) - : storage_(std::move(source.storage_)) + : BaseType(source) + , storage_(std::move(source.storage_)) {} std::unique_ptr<LocalFunctionType> local_function() const override final diff --git a/dune/xt/grid/boundaryinfo/interfaces.hh b/dune/xt/grid/boundaryinfo/interfaces.hh index d7c26da5b..44c19e440 100644 --- a/dune/xt/grid/boundaryinfo/interfaces.hh +++ b/dune/xt/grid/boundaryinfo/interfaces.hh @@ -76,12 +76,8 @@ public: typedef Common::FieldVector<DomainFieldType, dimDomain> DomainType; typedef Common::FieldVector<DomainFieldType, dimWorld> WorldType; - BoundaryInfo(const std::string& logging_prefix = "", - const std::string& logging_id = "", - const bool logging_disabled = true) - : Logger(logging_prefix.empty() ? "xt.grid" : logging_prefix, - logging_id.empty() ? "BoundaryInfo" : logging_id, - logging_disabled) + BoundaryInfo(const std::string& log_prefix = "", const std::string& log_id = "", const bool logging_disabled = true) + : Logger(log_prefix.empty() ? "xt.grid" : log_prefix, log_id.empty() ? "BoundaryInfo" : log_id, logging_disabled) {} BoundaryInfo(const ThisType&) = default; diff --git a/python/dune/xt/common/empty.cc b/python/dune/xt/common/empty.cc index 0460a9222..a75bf3e0c 100644 --- a/python/dune/xt/common/empty.cc +++ b/python/dune/xt/common/empty.cc @@ -26,8 +26,8 @@ struct Pet { - Pet(const std::string& name) - : name(name) + Pet(const std::string& name_) + : name(name_) {} void setName(const std::string& name_) { @@ -42,8 +42,8 @@ struct Pet }; struct Dog : Pet { - Dog(const std::string& name) - : Pet(name) + Dog(const std::string& name_) + : Pet(name_) {} std::string bark() const { diff --git a/python/dune/xt/grid/boundaryinfo/types.cc b/python/dune/xt/grid/boundaryinfo/types.cc index 6c4b3aff1..417fb6bda 100644 --- a/python/dune/xt/grid/boundaryinfo/types.cc +++ b/python/dune/xt/grid/boundaryinfo/types.cc @@ -39,7 +39,7 @@ PYBIND11_MODULE(_grid_boundaryinfo_types, m) #define BIND_(NAME) \ py::class_<NAME, BoundaryType>(m, #NAME, #NAME) \ .def(py::init([]() { return std::make_unique<NAME>(); })) \ - .def("__repr__", [](const NAME& self) { return std::string(#NAME) + "()"; }) + .def("__repr__", [](const NAME&) { return std::string(#NAME) + "()"; }) BIND_(NoBoundary); BIND_(UnknownBoundary); diff --git a/python/dune/xt/grid/gridprovider.hh b/python/dune/xt/grid/gridprovider.hh index c69fb6015..ac5805399 100644 --- a/python/dune/xt/grid/gridprovider.hh +++ b/python/dune/xt/grid/gridprovider.hh @@ -46,7 +46,7 @@ public: { namespace py = pybind11; using namespace pybind11::literals; - const size_t dim = type::GridType::dimension; + const int dim = type::GridType::dimension; const std::string class_name = class_id + "_" + grid_id; const auto ClassName = XT::Common::to_camel_case(class_name); @@ -59,7 +59,7 @@ public: "dim = " << dim << "\n codim = " << codim); auto grid_view = self.leaf_view(); MultipleCodimMultipleGeomTypeMapper<decltype(grid_view)> mapper(grid_view, [codim](GeometryType gt, int dimgrid) { - return dimgrid - gt.dim() == codim; + return dimgrid - Common::numeric_cast<int>(gt.dim()) == codim; }); return mapper.size(); }, "codim"_a); diff --git a/python/dune/xt/la/container/container-interface.hh b/python/dune/xt/la/container/container-interface.hh index 1004eb252..fc04bbc13 100644 --- a/python/dune/xt/la/container/container-interface.hh +++ b/python/dune/xt/la/container/container-interface.hh @@ -116,14 +116,14 @@ bind_ProvidesDataAccess(pybind11::module& m, const std::string& class_id, const py::class_<C> c(m, class_id.c_str(), help_id.c_str(), py::buffer_protocol()); - c.def_buffer([](C &m) -> py::buffer_info { + c.def_buffer([](C &mat) -> py::buffer_info { return py::buffer_info( - m.data(), /* Pointer to buffer */ + mat.data(), /* Pointer to buffer */ sizeof(D), /* Size of one scalar */ py::format_descriptor<D>::format(), /* Python struct-style format descriptor */ - 2, /* Number of dimensions */ - { m.rows(), m.cols() }, /* Buffer dimensions */ - { sizeof(D) * m.cols(), /* Strides (in bytes) for each index */ + 2, /* Number of dimensions */ + { mat.rows(), mat.cols() }, /* Buffer dimensions */ + { sizeof(D) * mat.cols(), /* Strides (in bytes) for each index */ sizeof(D) } ); }); -- GitLab