From bf7277a6056ec2b79ac6a8a7af7952b5b601d0c8 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Thu, 25 May 2023 20:48:20 +0000 Subject: [PATCH] Fix warnings when compiling with nvcc --- examples/step-47/step-47.cc | 4 ++++ examples/step-7/step-7.cc | 2 ++ examples/step-85/step-85.cc | 2 ++ include/deal.II/base/numbers.h | 8 ++++---- include/deal.II/base/tensor.h | 26 +++++++++++++++----------- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/step-47/step-47.cc b/examples/step-47/step-47.cc index 44dfb405b9..d68eb2b8b5 100644 --- a/examples/step-47/step-47.cc +++ b/examples/step-47/step-47.cc @@ -87,6 +87,8 @@ namespace Step47 public: static_assert(dim == 2, "Only dim==2 is implemented."); + Solution() = default; + virtual double value(const Point &p, const unsigned int /*component*/ = 0) const override { @@ -127,6 +129,8 @@ namespace Step47 public: static_assert(dim == 2, "Only dim==2 is implemented"); + RightHandSide() = default; + virtual double value(const Point &p, const unsigned int /*component*/ = 0) const override diff --git a/examples/step-7/step-7.cc b/examples/step-7/step-7.cc index 89d5ae6a33..823d8d4d59 100644 --- a/examples/step-7/step-7.cc +++ b/examples/step-7/step-7.cc @@ -268,6 +268,8 @@ namespace Step7 class RightHandSide : public Function, protected SolutionBase { public: + RightHandSide() = default; + virtual double value(const Point & p, const unsigned int component = 0) const override; }; diff --git a/examples/step-85/step-85.cc b/examples/step-85/step-85.cc index 9f4e774c3c..3ab68a218c 100644 --- a/examples/step-85/step-85.cc +++ b/examples/step-85/step-85.cc @@ -582,6 +582,8 @@ namespace Step85 class AnalyticalSolution : public Function { public: + AnalyticalSolution() = default; + double value(const Point & point, const unsigned int component = 0) const override; }; diff --git a/include/deal.II/base/numbers.h b/include/deal.II/base/numbers.h index 412a8a76d1..52d6c1f846 100644 --- a/include/deal.II/base/numbers.h +++ b/include/deal.II/base/numbers.h @@ -326,7 +326,7 @@ namespace numbers * of @p value_1. */ template - constexpr bool + constexpr DEAL_II_HOST_DEVICE bool values_are_equal(const Number1 &value_1, const Number2 &value_2); /** @@ -351,7 +351,7 @@ namespace numbers * by the input arguments. */ template - constexpr bool + constexpr DEAL_II_HOST_DEVICE bool value_is_zero(const Number &value); /** @@ -919,7 +919,7 @@ namespace numbers template - constexpr bool + constexpr DEAL_II_HOST_DEVICE bool values_are_equal(const Number1 &value_1, const Number2 &value_2) { return (value_1 == dealii::internal::NumberType::value(value_2)); @@ -935,7 +935,7 @@ namespace numbers template - constexpr bool + constexpr DEAL_II_HOST_DEVICE bool value_is_zero(const Number &value) { return values_are_equal(value, 0.0); diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 740acd2752..e197a695fe 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -693,8 +693,8 @@ public: * value allowed for d, allowing the intuitive notation * t=0 to reset all elements of the tensor to zero. */ - constexpr Tensor & - operator=(const Number &d) &; + constexpr DEAL_II_HOST_DEVICE Tensor & + operator=(const Number &d) &; /** * Assign a scalar to the current object. This overload is used for @@ -845,7 +845,7 @@ public: * Return an unrolled index in the range $[0,\text{dim}^{\text{rank}}-1]$ * for the element of the tensor indexed by the argument to the function. */ - static constexpr unsigned int + DEAL_II_HOST_DEVICE static constexpr unsigned int component_to_unrolled_index(const TableIndices &indices); /** @@ -853,7 +853,7 @@ public: * $[0, \text{dim}^{\text{rank}}-1]$, return which set of indices it would * correspond to. */ - static constexpr TableIndices + DEAL_II_HOST_DEVICE static constexpr TableIndices unrolled_to_component_indices(const unsigned int i); /** @@ -1559,8 +1559,9 @@ Tensor::operator=(const Tensor &t) template -constexpr inline DEAL_II_ALWAYS_INLINE Tensor & -Tensor::operator=(const Number &d) & +constexpr DEAL_II_HOST_DEVICE inline DEAL_II_ALWAYS_INLINE + Tensor & + Tensor::operator=(const Number &d) & { Assert(numbers::value_is_zero(d), ExcScalarAssignmentOnlyForZeroValue()); (void)d; @@ -1820,14 +1821,14 @@ namespace internal // and rank=2. Make sure we don't have compiler warnings. template - inline constexpr unsigned int + DEAL_II_HOST_DEVICE inline constexpr unsigned int mod(const unsigned int x) { return x % dim; } template <> - inline unsigned int + DEAL_II_HOST_DEVICE inline unsigned int mod<0>(const unsigned int x) { Assert(false, ExcInternalError()); @@ -1835,14 +1836,14 @@ namespace internal } template - inline constexpr unsigned int + DEAL_II_HOST_DEVICE inline constexpr unsigned int div(const unsigned int x) { return x / dim; } template <> - inline unsigned int + DEAL_II_HOST_DEVICE inline unsigned int div<0>(const unsigned int x) { Assert(false, ExcInternalError()); @@ -1857,7 +1858,10 @@ template constexpr inline TableIndices Tensor::unrolled_to_component_indices(const unsigned int i) { - AssertIndexRange(i, n_independent_components); + // Work-around nvcc warning + unsigned int dummy = n_independent_components; + AssertIndexRange(i, dummy); + (void)dummy; TableIndices indices; -- 2.39.5