]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix warnings when compiling with nvcc
authorBruno Turcksin <bruno.turcksin@gmail.com>
Thu, 25 May 2023 20:48:20 +0000 (20:48 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 31 May 2023 19:49:51 +0000 (19:49 +0000)
examples/step-47/step-47.cc
examples/step-7/step-7.cc
examples/step-85/step-85.cc
include/deal.II/base/numbers.h
include/deal.II/base/tensor.h

index 44dfb405b96b8028fbc2bc637a0e3540bb1fcae6..d68eb2b8b5141c965b46f6c0c700c5de3b0308ee 100644 (file)
@@ -87,6 +87,8 @@ namespace Step47
     public:
       static_assert(dim == 2, "Only dim==2 is implemented.");
 
+      Solution() = default;
+
       virtual double value(const Point<dim> &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<dim> &p,
                            const unsigned int /*component*/ = 0) const override
 
index 89d5ae6a3305c55bcc747f88c3afdbf9f3d17466..823d8d4d59c9bec256d95f8422876b5cc8fd0438 100644 (file)
@@ -268,6 +268,8 @@ namespace Step7
   class RightHandSide : public Function<dim>, protected SolutionBase<dim>
   {
   public:
+    RightHandSide() = default;
+
     virtual double value(const Point<dim> & p,
                          const unsigned int component = 0) const override;
   };
index 9f4e774c3c8a5335904b2fd25516cd8dea0e143a..3ab68a218cdd498ed0d56691340baa90f3eb5319 100644 (file)
@@ -582,6 +582,8 @@ namespace Step85
   class AnalyticalSolution : public Function<dim>
   {
   public:
+    AnalyticalSolution() = default;
+
     double value(const Point<dim> & point,
                  const unsigned int component = 0) const override;
   };
index 412a8a76d1c5b49484e054f9672b47617c738e22..52d6c1f8461e6c01bbeff06e13b1dd5d59c98b4e 100644 (file)
@@ -326,7 +326,7 @@ namespace numbers
    * of @p value_1.
    */
   template <typename Number1, typename Number2>
-  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 <typename Number>
-  constexpr bool
+  constexpr DEAL_II_HOST_DEVICE bool
   value_is_zero(const Number &value);
 
   /**
@@ -919,7 +919,7 @@ namespace numbers
 
 
   template <typename Number1, typename Number2>
-  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<Number1>::value(value_2));
@@ -935,7 +935,7 @@ namespace numbers
 
 
   template <typename Number>
-  constexpr bool
+  constexpr DEAL_II_HOST_DEVICE bool
   value_is_zero(const Number &value)
   {
     return values_are_equal(value, 0.0);
index 740acd27523ef5dcaf11c37adf567b93a85c19bc..e197a695fec6fbd733130c329333c124ade05a1a 100644 (file)
@@ -693,8 +693,8 @@ public:
    * value allowed for <tt>d</tt>, allowing the intuitive notation
    * <tt>t=0</tt> 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<rank_> &indices);
 
   /**
@@ -853,7 +853,7 @@ public:
    * $[0, \text{dim}^{\text{rank}}-1]$, return which set of indices it would
    * correspond to.
    */
-  static constexpr TableIndices<rank_>
+  DEAL_II_HOST_DEVICE static constexpr TableIndices<rank_>
   unrolled_to_component_indices(const unsigned int i);
 
   /**
@@ -1559,8 +1559,9 @@ Tensor<rank_, dim, Number>::operator=(const Tensor<rank_, dim, OtherNumber> &t)
 
 
 template <int rank_, int dim, typename Number>
-constexpr inline DEAL_II_ALWAYS_INLINE Tensor<rank_, dim, Number> &
-Tensor<rank_, dim, Number>::operator=(const Number &d) &
+constexpr DEAL_II_HOST_DEVICE inline DEAL_II_ALWAYS_INLINE
+  Tensor<rank_, dim, Number> &
+  Tensor<rank_, dim, Number>::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 <int dim>
-  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 <int dim>
-  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 <int rank_, int dim, typename Number>
 constexpr inline TableIndices<rank_>
 Tensor<rank_, dim, Number>::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<rank_> indices;
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.