From: David Wells Date: Fri, 30 Oct 2020 18:02:35 +0000 (-0400) Subject: Convert most DEAL_II_CONSTEXPR to constexpr. X-Git-Tag: v9.3.0-rc1~181^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94147375f47b00ef6311da825dfe9661a13b6d7d;p=dealii.git Convert most DEAL_II_CONSTEXPR to constexpr. Now that we require C++14 we can treat this differently. Not everything can be converted yet - some older compilers encounter internal compiler errors when we try to mark more things as constexpr. --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 3069872708..46386b90f0 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -57,16 +57,16 @@ constexpr DEAL_II_ALWAYS_INLINE SymmetricTensor<4, dim, Number> invert(const SymmetricTensor<4, dim, Number> &); template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number - trace(const SymmetricTensor<2, dim2, Number> &); +constexpr inline DEAL_II_ALWAYS_INLINE Number + trace(const SymmetricTensor<2, dim2, Number> &); template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> - deviator(const SymmetricTensor<2, dim, Number> &); +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> + deviator(const SymmetricTensor<2, dim, Number> &); template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number - determinant(const SymmetricTensor<2, dim, Number> &); +constexpr inline DEAL_II_ALWAYS_INLINE Number + determinant(const SymmetricTensor<2, dim, Number> &); @@ -410,8 +410,8 @@ namespace internal /** * Index operator. */ - DEAL_II_CONSTEXPR Accessor - operator[](const unsigned int i); + constexpr Accessor + operator[](const unsigned int i); /** * Index operator. @@ -492,7 +492,7 @@ namespace internal /** * Index operator. */ - DEAL_II_CONSTEXPR reference operator[](const unsigned int); + constexpr reference operator[](const unsigned int); /** * Index operator. @@ -660,8 +660,7 @@ public: * the object from the internal namespace is to work around bugs in some * older compilers. */ - DEAL_II_CONSTEXPR - SymmetricTensor(const Number (&array)[n_independent_components]); + constexpr SymmetricTensor(const Number (&array)[n_independent_components]); /** * Copy constructor from tensors with different underlying scalar type. This @@ -704,8 +703,8 @@ public: * @p Number. */ template - DEAL_II_CONSTEXPR SymmetricTensor & - operator=(const SymmetricTensor &rhs); + constexpr SymmetricTensor & + operator=(const SymmetricTensor &rhs); /** * This operator assigns a scalar to a tensor. To avoid confusion with what @@ -713,8 +712,8 @@ public: * value allowed for d, allowing the intuitive notation * $\mathbf A = 0$ to reset all elements of the tensor to zero. */ - DEAL_II_CONSTEXPR SymmetricTensor & - operator=(const Number &d); + constexpr SymmetricTensor & + operator=(const Number &d); /** * Convert the present symmetric tensor into a full tensor with the same @@ -738,36 +737,36 @@ public: * Add another tensor. */ template - DEAL_II_CONSTEXPR SymmetricTensor & - operator+=(const SymmetricTensor &); + constexpr SymmetricTensor & + operator+=(const SymmetricTensor &); /** * Subtract another tensor. */ template - DEAL_II_CONSTEXPR SymmetricTensor & - operator-=(const SymmetricTensor &); + constexpr SymmetricTensor & + operator-=(const SymmetricTensor &); /** * Scale the tensor by factor, i.e. multiply all components by * factor. */ template - DEAL_II_CONSTEXPR SymmetricTensor & - operator*=(const OtherNumber &factor); + constexpr SymmetricTensor & + operator*=(const OtherNumber &factor); /** * Scale the tensor by 1/factor. */ template - DEAL_II_CONSTEXPR SymmetricTensor & - operator/=(const OtherNumber &factor); + constexpr SymmetricTensor & + operator/=(const OtherNumber &factor); /** * Unary minus operator. Negate all entries of a tensor. */ - DEAL_II_CONSTEXPR SymmetricTensor - operator-() const; + constexpr SymmetricTensor + operator-() const; /** * Double contraction product between the present symmetric tensor and a @@ -812,14 +811,14 @@ public: /** * Return a read-write reference to the indicated element. */ - DEAL_II_CONSTEXPR Number & - operator()(const TableIndices &indices); + constexpr Number & + operator()(const TableIndices &indices); /** * Return a @p const reference to the value referred to by the argument. */ - DEAL_II_CONSTEXPR const Number & - operator()(const TableIndices &indices) const; + constexpr const Number & + operator()(const TableIndices &indices) const; /** * Access the elements of a row of this symmetric tensor. This function is @@ -833,7 +832,7 @@ public: * Access the elements of a row of this symmetric tensor. This function is * called for non-constant tensors. */ - DEAL_II_CONSTEXPR internal::SymmetricTensorAccessors:: + constexpr internal::SymmetricTensorAccessors:: Accessor operator[](const unsigned int row); @@ -849,7 +848,7 @@ public: * * Exactly the same as operator(). */ - DEAL_II_CONSTEXPR Number &operator[](const TableIndices &indices); + constexpr Number &operator[](const TableIndices &indices); /** * Access to an element according to unrolled index. The function @@ -857,8 +856,8 @@ public: * s[s.unrolled_to_component_indices(unrolled_index)], but more * efficiently. */ - DEAL_II_CONSTEXPR const Number & - access_raw_entry(const unsigned int unrolled_index) const; + constexpr const Number & + access_raw_entry(const unsigned int unrolled_index) const; /** * Access to an element according to unrolled index. The function @@ -866,8 +865,8 @@ public: * s[s.unrolled_to_component_indices(unrolled_index)], but more * efficiently. */ - DEAL_II_CONSTEXPR Number & - access_raw_entry(const unsigned int unrolled_index); + constexpr Number & + access_raw_entry(const unsigned int unrolled_index); /** * Return the Frobenius-norm of a tensor, i.e. the square root of the sum of @@ -911,7 +910,7 @@ public: * and indeed the state where all elements have a zero value is the state * right after construction of such an object. */ - DEAL_II_CONSTEXPR void + constexpr void clear(); /** @@ -953,16 +952,16 @@ private: // Make a few more functions friends. template - friend DEAL_II_CONSTEXPR Number2 - trace(const SymmetricTensor<2, dim2, Number2> &d); + friend constexpr Number2 + trace(const SymmetricTensor<2, dim2, Number2> &d); template - friend DEAL_II_CONSTEXPR Number2 - determinant(const SymmetricTensor<2, dim2, Number2> &t); + friend constexpr Number2 + determinant(const SymmetricTensor<2, dim2, Number2> &t); template - friend DEAL_II_CONSTEXPR SymmetricTensor<2, dim2, Number2> - deviator(const SymmetricTensor<2, dim2, Number2> &t); + friend constexpr SymmetricTensor<2, dim2, Number2> + deviator(const SymmetricTensor<2, dim2, Number2> &t); template friend DEAL_II_CONSTEXPR SymmetricTensor<2, dim2, Number2> @@ -1015,7 +1014,7 @@ namespace internal template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE + constexpr inline DEAL_II_ALWAYS_INLINE Accessor Accessor:: operator[](const unsigned int i) @@ -1050,7 +1049,7 @@ namespace internal template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE + constexpr inline DEAL_II_ALWAYS_INLINE typename Accessor::reference Accessor:: operator[](const unsigned int i) @@ -1105,7 +1104,7 @@ SymmetricTensor::SymmetricTensor( template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor::SymmetricTensor( const Number (&array)[n_independent_components]) : data( @@ -1120,10 +1119,9 @@ SymmetricTensor::SymmetricTensor( template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor & - SymmetricTensor:: - operator=(const SymmetricTensor &t) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor & + SymmetricTensor:: + operator=(const SymmetricTensor &t) { data = t.data; return *this; @@ -1132,9 +1130,8 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor & - SymmetricTensor::operator=(const Number &d) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor & +SymmetricTensor::operator=(const Number &d) { Assert(numbers::value_is_zero(d), ExcMessage("Only assignment with zero is allowed")); @@ -1151,9 +1148,8 @@ namespace internal namespace SymmetricTensorImplementation { template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - dealii::Tensor<2, dim, Number> - convert_to_tensor(const dealii::SymmetricTensor<2, dim, Number> &s) + constexpr inline DEAL_II_ALWAYS_INLINE dealii::Tensor<2, dim, Number> + convert_to_tensor(const dealii::SymmetricTensor<2, dim, Number> &s) { dealii::Tensor<2, dim, Number> t; @@ -1173,8 +1169,8 @@ namespace internal template - DEAL_II_CONSTEXPR dealii::Tensor<4, dim, Number> - convert_to_tensor(const dealii::SymmetricTensor<4, dim, Number> &st) + constexpr dealii::Tensor<4, dim, Number> + convert_to_tensor(const dealii::SymmetricTensor<4, dim, Number> &st) { // utilize the symmetry properties of SymmetricTensor<4,dim> // discussed in the class documentation to avoid accessing all @@ -1197,7 +1193,7 @@ namespace internal template struct Inverse<2, 1, Number> { - DEAL_II_CONSTEXPR static inline DEAL_II_ALWAYS_INLINE + constexpr static inline DEAL_II_ALWAYS_INLINE dealii::SymmetricTensor<2, 1, Number> value(const dealii::SymmetricTensor<2, 1, Number> &t) { @@ -1213,7 +1209,7 @@ namespace internal template struct Inverse<2, 2, Number> { - DEAL_II_CONSTEXPR static inline DEAL_II_ALWAYS_INLINE + constexpr static inline DEAL_II_ALWAYS_INLINE dealii::SymmetricTensor<2, 2, Number> value(const dealii::SymmetricTensor<2, 2, Number> &t) { @@ -1240,7 +1236,7 @@ namespace internal template struct Inverse<2, 3, Number> { - DEAL_II_CONSTEXPR static dealii::SymmetricTensor<2, 3, Number> + constexpr static dealii::SymmetricTensor<2, 3, Number> value(const dealii::SymmetricTensor<2, 3, Number> &t) { dealii::SymmetricTensor<2, 3, Number> tmp; @@ -1307,7 +1303,7 @@ namespace internal template struct Inverse<4, 1, Number> { - DEAL_II_CONSTEXPR static inline dealii::SymmetricTensor<4, 1, Number> + constexpr static inline dealii::SymmetricTensor<4, 1, Number> value(const dealii::SymmetricTensor<4, 1, Number> &t) { dealii::SymmetricTensor<4, 1, Number> tmp; @@ -1320,7 +1316,7 @@ namespace internal template struct Inverse<4, 2, Number> { - DEAL_II_CONSTEXPR static inline dealii::SymmetricTensor<4, 2, Number> + constexpr static inline dealii::SymmetricTensor<4, 2, Number> value(const dealii::SymmetricTensor<4, 2, Number> &t) { dealii::SymmetricTensor<4, 2, Number> tmp; @@ -1526,10 +1522,9 @@ operator!=(const SymmetricTensor &t) const template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor & - SymmetricTensor:: - operator+=(const SymmetricTensor &t) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor & + SymmetricTensor:: + operator+=(const SymmetricTensor &t) { data += t.data; return *this; @@ -1539,10 +1534,9 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor & - SymmetricTensor:: - operator-=(const SymmetricTensor &t) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor & + SymmetricTensor:: + operator-=(const SymmetricTensor &t) { data -= t.data; return *this; @@ -1552,9 +1546,8 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor & - SymmetricTensor::operator*=(const OtherNumber &d) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor & +SymmetricTensor::operator*=(const OtherNumber &d) { data *= d; return *this; @@ -1564,9 +1557,8 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor & - SymmetricTensor::operator/=(const OtherNumber &d) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor & +SymmetricTensor::operator/=(const OtherNumber &d) { data /= d; return *this; @@ -1575,9 +1567,8 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor - SymmetricTensor::operator-() const +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor +SymmetricTensor::operator-() const { SymmetricTensor tmp = *this; tmp.data = -tmp.data; @@ -1587,7 +1578,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE void +constexpr inline DEAL_II_ALWAYS_INLINE void SymmetricTensor::clear() { data.clear(); @@ -1809,10 +1800,10 @@ namespace internal Type Uninitialized::value; template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number & - symmetric_tensor_access(const TableIndices<2> &indices, - typename SymmetricTensorAccessors:: - StorageType<2, dim, Number>::base_tensor_type &data) + constexpr inline DEAL_II_ALWAYS_INLINE Number & + symmetric_tensor_access(const TableIndices<2> &indices, + typename SymmetricTensorAccessors:: + StorageType<2, dim, Number>::base_tensor_type &data) { // 1d is very simple and done first if (dim == 1) @@ -1855,10 +1846,10 @@ namespace internal template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE const Number & - symmetric_tensor_access(const TableIndices<2> &indices, - const typename SymmetricTensorAccessors:: - StorageType<2, dim, Number>::base_tensor_type &data) + constexpr inline DEAL_II_ALWAYS_INLINE const Number & + symmetric_tensor_access(const TableIndices<2> &indices, + const typename SymmetricTensorAccessors:: + StorageType<2, dim, Number>::base_tensor_type &data) { // 1d is very simple and done first if (dim == 1) @@ -1901,7 +1892,7 @@ namespace internal template - DEAL_II_CONSTEXPR inline Number & + constexpr inline Number & symmetric_tensor_access(const TableIndices<4> &indices, typename SymmetricTensorAccessors:: StorageType<4, dim, Number>::base_tensor_type &data) @@ -1948,10 +1939,10 @@ namespace internal template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE const Number & - symmetric_tensor_access(const TableIndices<4> &indices, - const typename SymmetricTensorAccessors:: - StorageType<4, dim, Number>::base_tensor_type &data) + constexpr inline DEAL_II_ALWAYS_INLINE const Number & + symmetric_tensor_access(const TableIndices<4> &indices, + const typename SymmetricTensorAccessors:: + StorageType<4, dim, Number>::base_tensor_type &data) { switch (dim) { @@ -1998,9 +1989,9 @@ namespace internal template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number & - SymmetricTensor:: - operator()(const TableIndices &indices) +constexpr inline DEAL_II_ALWAYS_INLINE Number & + SymmetricTensor:: + operator()(const TableIndices &indices) { for (unsigned int r = 0; r < rank; ++r) AssertIndexRange(indices[r], dimension); @@ -2010,9 +2001,9 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number & template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE const Number & - SymmetricTensor:: - operator()(const TableIndices &indices) const +constexpr inline DEAL_II_ALWAYS_INLINE const Number & + SymmetricTensor:: + operator()(const TableIndices &indices) const { for (unsigned int r = 0; r < rank; ++r) AssertIndexRange(indices[r], dimension); @@ -2064,8 +2055,8 @@ constexpr DEAL_II_ALWAYS_INLINE internal::SymmetricTensorAccessors:: template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE internal:: - SymmetricTensorAccessors::Accessor +constexpr inline DEAL_II_ALWAYS_INLINE internal::SymmetricTensorAccessors:: + Accessor SymmetricTensor::operator[](const unsigned int row) { return internal::SymmetricTensorAccessors:: @@ -2088,9 +2079,9 @@ constexpr DEAL_II_ALWAYS_INLINE const Number & template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number & - SymmetricTensor:: - operator[](const TableIndices &indices) +constexpr inline DEAL_II_ALWAYS_INLINE Number & + SymmetricTensor:: + operator[](const TableIndices &indices) { return operator()(indices); } @@ -2161,7 +2152,7 @@ namespace internal template -DEAL_II_CONSTEXPR inline const Number & +constexpr inline const Number & SymmetricTensor::access_raw_entry( const unsigned int index) const { @@ -2173,7 +2164,7 @@ SymmetricTensor::access_raw_entry( template -DEAL_II_CONSTEXPR inline Number & +constexpr inline Number & SymmetricTensor::access_raw_entry(const unsigned int index) { AssertIndexRange(index, n_independent_components); @@ -2186,7 +2177,7 @@ SymmetricTensor::access_raw_entry(const unsigned int index) namespace internal { template - DEAL_II_CONSTEXPR inline typename numbers::NumberTraits::real_type + constexpr inline typename numbers::NumberTraits::real_type compute_norm(const typename SymmetricTensorAccessors:: StorageType<2, dim, Number>::base_tensor_type &data) { @@ -2230,7 +2221,7 @@ namespace internal template - DEAL_II_CONSTEXPR inline typename numbers::NumberTraits::real_type + constexpr inline typename numbers::NumberTraits::real_type compute_norm(const typename SymmetricTensorAccessors:: StorageType<4, dim, Number>::base_tensor_type &data) { @@ -2291,7 +2282,7 @@ namespace internal // // this function is for rank-2 tensors template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE unsigned int + constexpr inline DEAL_II_ALWAYS_INLINE unsigned int component_to_unrolled_index(const TableIndices<2> &indices) { AssertIndexRange(indices[0], dim); @@ -2355,7 +2346,7 @@ namespace internal // this function is for tensors of ranks not already handled // above template - DEAL_II_CONSTEXPR inline unsigned int + constexpr inline unsigned int component_to_unrolled_index(const TableIndices &indices) { (void)indices; @@ -2389,9 +2380,9 @@ namespace internal // // this function is for rank-2 tensors template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE TableIndices<2> - unrolled_to_component_indices(const unsigned int i, - const std::integral_constant &) + constexpr inline DEAL_II_ALWAYS_INLINE TableIndices<2> + unrolled_to_component_indices(const unsigned int i, + const std::integral_constant &) { Assert( (i < dealii::SymmetricTensor<2, dim, double>::n_independent_components), @@ -2449,7 +2440,7 @@ namespace internal // this function is for tensors of a rank not already handled // above template - DEAL_II_CONSTEXPR inline + constexpr inline typename std::enable_if>::type unrolled_to_component_indices(const unsigned int i, const std::integral_constant &) @@ -2507,7 +2498,7 @@ SymmetricTensor::serialize(Archive &ar, const unsigned int) * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor::type> operator+(const SymmetricTensor & left, const SymmetricTensor &right) @@ -2532,7 +2523,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor::type> operator-(const SymmetricTensor & left, const SymmetricTensor &right) @@ -2627,8 +2618,8 @@ constexpr DEAL_II_ALWAYS_INLINE * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number - determinant(const SymmetricTensor<2, dim, Number> &t) +constexpr inline DEAL_II_ALWAYS_INLINE Number + determinant(const SymmetricTensor<2, dim, Number> &t) { switch (dim) { @@ -2685,8 +2676,8 @@ constexpr DEAL_II_ALWAYS_INLINE Number * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number - trace(const SymmetricTensor<2, dim, Number> &d) +constexpr inline DEAL_II_ALWAYS_INLINE Number + trace(const SymmetricTensor<2, dim, Number> &d) { Number t = d.data[0]; for (unsigned int i = 1; i < dim; ++i) @@ -3194,8 +3185,8 @@ constexpr DEAL_II_ALWAYS_INLINE SymmetricTensor * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> - deviator(const SymmetricTensor<2, dim, Number> &t) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> + deviator(const SymmetricTensor<2, dim, Number> &t) { SymmetricTensor<2, dim, Number> tmp = t; @@ -3471,7 +3462,7 @@ invert(const SymmetricTensor<4, dim, Number> &t) * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline SymmetricTensor<4, dim, Number> +constexpr inline SymmetricTensor<4, dim, Number> outer_product(const SymmetricTensor<2, dim, Number> &t1, const SymmetricTensor<2, dim, Number> &t2) { @@ -3497,8 +3488,8 @@ outer_product(const SymmetricTensor<2, dim, Number> &t1, * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> - symmetrize(const Tensor<2, dim, Number> &t) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> + symmetrize(const Tensor<2, dim, Number> &t) { SymmetricTensor<2, dim, Number> result; for (unsigned int d = 0; d < dim; ++d) @@ -3521,9 +3512,8 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - SymmetricTensor - operator*(const SymmetricTensor &t, const Number &factor) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor + operator*(const SymmetricTensor &t, const Number &factor) { SymmetricTensor tt = t; tt *= factor; @@ -3575,7 +3565,7 @@ constexpr DEAL_II_ALWAYS_INLINE SymmetricTensor * @relatesalso EnableIfScalar */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor< +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor< rank_, dim, typename ProductType &t, * @relatesalso EnableIfScalar */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor< +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor< rank_, dim, typename ProductType -DEAL_II_CONSTEXPR inline SymmetricTensor< +constexpr inline SymmetricTensor< rank_, dim, typename ProductType &t, * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor - operator*(const SymmetricTensor &t, const double factor) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor + operator*(const SymmetricTensor &t, const double factor) { SymmetricTensor tt(t); tt *= factor; @@ -3665,8 +3655,8 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor - operator*(const double factor, const SymmetricTensor &t) +constexpr inline DEAL_II_ALWAYS_INLINE SymmetricTensor + operator*(const double factor, const SymmetricTensor &t) { SymmetricTensor tt(t); tt *= factor; @@ -3681,7 +3671,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline SymmetricTensor +constexpr inline SymmetricTensor operator/(const SymmetricTensor &t, const double factor) { SymmetricTensor tt(t); @@ -3721,7 +3711,7 @@ scalar_product(const SymmetricTensor<2, dim, Number> & t1, * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE typename ProductType::type scalar_product(const SymmetricTensor<2, dim, Number> &t1, const Tensor<2, dim, OtherNumber> & t2) @@ -3772,7 +3762,7 @@ scalar_product(const Tensor<2, dim, Number> & t1, * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE void double_contract( +constexpr inline DEAL_II_ALWAYS_INLINE void double_contract( SymmetricTensor<2, 1, typename ProductType::type> &tmp, const SymmetricTensor<4, 1, Number> & t, const SymmetricTensor<2, 1, OtherNumber> & s) @@ -3797,7 +3787,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE void double_contract( * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline void double_contract( +constexpr inline void double_contract( SymmetricTensor<2, 1, typename ProductType::type> &tmp, const SymmetricTensor<2, 1, Number> & s, const SymmetricTensor<4, 1, OtherNumber> & t) @@ -3822,7 +3812,7 @@ DEAL_II_CONSTEXPR inline void double_contract( * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline void double_contract( +constexpr inline void double_contract( SymmetricTensor<2, 2, typename ProductType::type> &tmp, const SymmetricTensor<4, 2, Number> & t, const SymmetricTensor<2, 2, OtherNumber> & s) @@ -3852,7 +3842,7 @@ DEAL_II_CONSTEXPR inline void double_contract( * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline void double_contract( +constexpr inline void double_contract( SymmetricTensor<2, 2, typename ProductType::type> &tmp, const SymmetricTensor<2, 2, Number> & s, const SymmetricTensor<4, 2, OtherNumber> & t) @@ -3882,7 +3872,7 @@ DEAL_II_CONSTEXPR inline void double_contract( * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline void double_contract( +constexpr inline void double_contract( SymmetricTensor<2, 3, typename ProductType::type> &tmp, const SymmetricTensor<4, 3, Number> & t, const SymmetricTensor<2, 3, OtherNumber> & s) @@ -3913,7 +3903,7 @@ DEAL_II_CONSTEXPR inline void double_contract( * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR inline void double_contract( +constexpr inline void double_contract( SymmetricTensor<2, 3, typename ProductType::type> &tmp, const SymmetricTensor<2, 3, Number> & s, const SymmetricTensor<4, 3, OtherNumber> & t) @@ -3936,10 +3926,9 @@ DEAL_II_CONSTEXPR inline void double_contract( * @relatesalso SymmetricTensor */ template -DEAL_II_CONSTEXPR - Tensor<1, dim, typename ProductType::type> - operator*(const SymmetricTensor<2, dim, Number> &src1, - const Tensor<1, dim, OtherNumber> & src2) +constexpr Tensor<1, dim, typename ProductType::type> +operator*(const SymmetricTensor<2, dim, Number> &src1, + const Tensor<1, dim, OtherNumber> & src2) { Tensor<1, dim, typename ProductType::type> dest; for (unsigned int i = 0; i < dim; ++i) diff --git a/include/deal.II/base/table_indices.h b/include/deal.II/base/table_indices.h index a72f4b65be..78a38ee9c4 100644 --- a/include/deal.II/base/table_indices.h +++ b/include/deal.II/base/table_indices.h @@ -66,12 +66,12 @@ public: /** * Read-only access the value of the ith index. */ - DEAL_II_CONSTEXPR std::size_t operator[](const unsigned int i) const; + constexpr std::size_t operator[](const unsigned int i) const; /** * Write access the value of the ith index. */ - DEAL_II_CONSTEXPR std::size_t &operator[](const unsigned int i); + constexpr std::size_t &operator[](const unsigned int i); /** * Compare two index fields for equality. @@ -125,8 +125,8 @@ constexpr TableIndices::TableIndices(const T... args) template -DEAL_II_CONSTEXPR inline std::size_t TableIndices:: - operator[](const unsigned int i) const +constexpr inline std::size_t TableIndices:: + operator[](const unsigned int i) const { AssertIndexRange(i, N); return indices[i]; @@ -134,8 +134,7 @@ DEAL_II_CONSTEXPR inline std::size_t TableIndices:: template -DEAL_II_CONSTEXPR inline std::size_t &TableIndices:: - operator[](const unsigned int i) +constexpr inline std::size_t &TableIndices::operator[](const unsigned int i) { AssertIndexRange(i, N); return indices[i]; diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index f5894dc944..c07b062bcf 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -200,7 +200,7 @@ public: * * @note This function can also be used in CUDA device code. */ - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV operator Number &(); + constexpr DEAL_II_CUDA_HOST_DEV operator Number &(); /** * Return a reference to the encapsulated Number object. Since rank-0 @@ -210,7 +210,7 @@ public: * * @note This function can also be used in CUDA device code. */ - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV operator const Number &() const; + constexpr DEAL_II_CUDA_HOST_DEV operator const Number &() const; /** * Assignment from tensors with different underlying scalar type. This @@ -220,8 +220,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator=(const Tensor<0, dim, OtherNumber> &rhs); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator=(const Tensor<0, dim, OtherNumber> &rhs); #ifdef __INTEL_COMPILER /** @@ -232,8 +232,8 @@ public: * * @note This function can also be used in CUDA device code. */ - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator=(const Tensor<0, dim, Number> &rhs); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator=(const Tensor<0, dim, Number> &rhs); #endif /** @@ -243,14 +243,14 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator=(const OtherNumber &d); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator=(const OtherNumber &d); /** * Test for equality of two tensors. */ template - DEAL_II_CONSTEXPR bool + constexpr bool operator==(const Tensor<0, dim, OtherNumber> &rhs) const; /** @@ -266,8 +266,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator+=(const Tensor<0, dim, OtherNumber> &rhs); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator+=(const Tensor<0, dim, OtherNumber> &rhs); /** * Subtract another scalar. @@ -275,8 +275,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator-=(const Tensor<0, dim, OtherNumber> &rhs); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator-=(const Tensor<0, dim, OtherNumber> &rhs); /** * Multiply the scalar with a factor. @@ -284,8 +284,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator*=(const OtherNumber &factor); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator*=(const OtherNumber &factor); /** * Divide the scalar by factor. @@ -293,8 +293,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator/=(const OtherNumber &factor); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator/=(const OtherNumber &factor); /** * Tensor with inverted entries. @@ -316,7 +316,7 @@ public: * and indeed the state where all elements have a zero value is the state * right after construction of such an object. */ - DEAL_II_CONSTEXPR void + constexpr void clear(); /** @@ -333,8 +333,8 @@ public: * * @note This function can also be used in CUDA device code. */ - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV real_type - norm_square() const; + constexpr DEAL_II_CUDA_HOST_DEV real_type + norm_square() const; /** * Read or write the data of this object to or from a stream for the purpose @@ -552,8 +552,7 @@ public: * * @note This function can also be used in CUDA device code. */ - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV value_type & - operator[](const unsigned int i); + constexpr DEAL_II_CUDA_HOST_DEV value_type &operator[](const unsigned int i); /** * Read-only access operator. @@ -566,13 +565,12 @@ public: /** * Read access using TableIndices indices */ - DEAL_II_CONSTEXPR const Number & - operator[](const TableIndices &indices) const; + constexpr const Number &operator[](const TableIndices &indices) const; /** * Read and write access using TableIndices indices */ - DEAL_II_CONSTEXPR Number &operator[](const TableIndices &indices); + constexpr Number &operator[](const TableIndices &indices); /** * Return a pointer to the first element of the underlying storage. @@ -606,8 +604,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator=(const Tensor &rhs); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator=(const Tensor &rhs); /** * This operator assigns a scalar to a tensor. To avoid confusion with what @@ -615,14 +613,14 @@ public: * value allowed for d, allowing the intuitive notation * t=0 to reset all elements of the tensor to zero. */ - DEAL_II_CONSTEXPR Tensor & - operator=(const Number &d); + constexpr Tensor & + operator=(const Number &d); /** * Test for equality of two tensors. */ template - DEAL_II_CONSTEXPR bool + constexpr bool operator==(const Tensor &) const; /** @@ -638,8 +636,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator+=(const Tensor &); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator+=(const Tensor &); /** * Subtract another tensor. @@ -647,8 +645,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator-=(const Tensor &); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator-=(const Tensor &); /** * Scale the tensor by factor, i.e. multiply all components by @@ -657,8 +655,8 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator*=(const OtherNumber &factor); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator*=(const OtherNumber &factor); /** * Scale the vector by 1/factor. @@ -666,16 +664,16 @@ public: * @note This function can also be used in CUDA device code. */ template - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor & - operator/=(const OtherNumber &factor); + constexpr DEAL_II_CUDA_HOST_DEV Tensor & + operator/=(const OtherNumber &factor); /** * Unary minus operator. Negate all entries of a tensor. * * @note This function can also be used in CUDA device code. */ - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV Tensor - operator-() const; + constexpr DEAL_II_CUDA_HOST_DEV Tensor + operator-() const; /** * Reset all values to zero. @@ -689,7 +687,7 @@ public: * and indeed the state where all elements have a zero value is the state * right after construction of such an object. */ - DEAL_II_CONSTEXPR void + constexpr void clear(); /** @@ -709,7 +707,7 @@ public: * * @note This function can also be used in CUDA device code. */ - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV + constexpr DEAL_II_CUDA_HOST_DEV typename numbers::NumberTraits::real_type norm_square() const; @@ -728,7 +726,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 DEAL_II_CONSTEXPR unsigned int + static constexpr unsigned int component_to_unrolled_index(const TableIndices &indices); /** @@ -736,8 +734,8 @@ public: * $[0, \text{dim}^{\text{rank}}-1]$, return which set of indices it would * correspond to. */ - static DEAL_II_CONSTEXPR TableIndices - unrolled_to_component_indices(const unsigned int i); + static constexpr TableIndices + unrolled_to_component_indices(const unsigned int i); /** * Determine an estimate for the memory consumption (in bytes) of this @@ -846,8 +844,8 @@ namespace internal return t; } - static DEAL_II_CONSTEXPR DEAL_II_ALWAYS_INLINE Tensor - value(const T &t) + static constexpr DEAL_II_ALWAYS_INLINE Tensor + value(const T &t) { Tensor tmp; tmp = t; @@ -925,7 +923,7 @@ Tensor<0, dim, Number>::end_raw() const template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number>::operator Number &() { // We cannot use Assert inside a CUDA kernel @@ -938,7 +936,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number>::operator const Number &() const { // We cannot use Assert inside a CUDA kernel @@ -952,7 +950,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & Tensor<0, dim, Number>::operator=(const Tensor<0, dim, OtherNumber> &p) { @@ -963,7 +961,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE # ifdef __INTEL_COMPILER template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & Tensor<0, dim, Number>::operator=(const Tensor<0, dim, Number> &p) { @@ -975,7 +973,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & Tensor<0, dim, Number>::operator=(const OtherNumber &d) { @@ -986,7 +984,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline bool +constexpr inline bool Tensor<0, dim, Number>::operator==(const Tensor<0, dim, OtherNumber> &p) const { # if defined(DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING) @@ -1012,7 +1010,7 @@ Tensor<0, dim, Number>::operator!=(const Tensor<0, dim, OtherNumber> &p) const template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & Tensor<0, dim, Number>::operator+=(const Tensor<0, dim, OtherNumber> &p) { @@ -1023,7 +1021,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & Tensor<0, dim, Number>::operator-=(const Tensor<0, dim, OtherNumber> &p) { @@ -1038,16 +1036,16 @@ namespace internal namespace ComplexWorkaround { template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV void - multiply_assign_scalar(Number &val, const OtherNumber &s) + constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV void + multiply_assign_scalar(Number &val, const OtherNumber &s) { val *= s; } # ifdef __CUDA_ARCH__ template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV void - multiply_assign_scalar(std::complex &, const OtherNumber &) + constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV void + multiply_assign_scalar(std::complex &, const OtherNumber &) { printf("This function is not implemented for std::complex!\n"); assert(false); @@ -1059,7 +1057,7 @@ namespace internal template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & Tensor<0, dim, Number>::operator*=(const OtherNumber &s) { @@ -1071,7 +1069,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & +constexpr inline DEAL_II_CUDA_HOST_DEV Tensor<0, dim, Number> & Tensor<0, dim, Number>::operator/=(const OtherNumber &s) { value /= s; @@ -1098,7 +1096,7 @@ Tensor<0, dim, Number>::norm() const template -DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE +constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE typename Tensor<0, dim, Number>::real_type Tensor<0, dim, Number>::norm_square() const { @@ -1125,7 +1123,7 @@ Tensor<0, dim, Number>::unroll_recursion(Vector &result, template -DEAL_II_CONSTEXPR inline void +constexpr inline void Tensor<0, dim, Number>::clear() { // Some auto-differentiable numbers need explicit @@ -1227,7 +1225,7 @@ namespace internal namespace TensorSubscriptor { template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE + constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV ArrayElementType & subscript(ArrayElementType * values, const unsigned int i, @@ -1255,7 +1253,7 @@ namespace internal Type Uninitialized::value; template - DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE + constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV ArrayElementType & subscript(ArrayElementType *, const unsigned int, @@ -1275,7 +1273,7 @@ namespace internal template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV typename Tensor::value_type &Tensor:: operator[](const unsigned int i) { @@ -1298,9 +1296,9 @@ constexpr DEAL_II_ALWAYS_INLINE template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE const Number & - Tensor:: - operator[](const TableIndices &indices) const +constexpr inline DEAL_II_ALWAYS_INLINE const Number & + Tensor:: + operator[](const TableIndices &indices) const { # ifndef DEAL_II_COMPILER_CUDA_AWARE Assert(dim != 0, @@ -1313,8 +1311,8 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE const Number & template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Number & - Tensor::operator[](const TableIndices &indices) +constexpr inline DEAL_II_ALWAYS_INLINE Number &Tensor:: + operator[](const TableIndices &indices) { # ifndef DEAL_II_COMPILER_CUDA_AWARE Assert(dim != 0, @@ -1366,7 +1364,7 @@ Tensor::end_raw() const template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Tensor & +constexpr inline DEAL_II_ALWAYS_INLINE Tensor & Tensor::operator=(const Tensor &t) { // The following loop could be written more concisely using std::copy, but @@ -1378,7 +1376,7 @@ Tensor::operator=(const Tensor &t) template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Tensor & +constexpr inline DEAL_II_ALWAYS_INLINE Tensor & Tensor::operator=(const Number &d) { Assert(numbers::value_is_zero(d), ExcScalarAssignmentOnlyForZeroValue()); @@ -1392,7 +1390,7 @@ Tensor::operator=(const Number &d) template template -DEAL_II_CONSTEXPR inline bool +constexpr inline bool Tensor:: operator==(const Tensor &p) const { @@ -1410,7 +1408,7 @@ operator==(const Tensor &p) const // implement this function here template <> template <> -DEAL_II_CONSTEXPR inline bool +constexpr inline bool Tensor<1, 0, double>::operator==(const Tensor<1, 0, double> &) const { return true; @@ -1429,7 +1427,7 @@ operator!=(const Tensor &p) const template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor & Tensor:: operator+=(const Tensor &p) @@ -1442,7 +1440,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor & Tensor:: operator-=(const Tensor &p) @@ -1455,7 +1453,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor & Tensor::operator*=(const OtherNumber &s) { @@ -1478,9 +1476,9 @@ namespace internal typename ProductType::type>::value && !std::is_same::value, int>::type = 0> - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE void - division_operator(Tensor (&t)[dim], - const OtherNumber &factor) + constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE void + division_operator(Tensor (&t)[dim], + const OtherNumber &factor) { const Number inverse_factor = Number(1.) / factor; // recurse over the base objects @@ -1498,9 +1496,9 @@ namespace internal typename ProductType::type>::value || std::is_same::value, int>::type = 0> - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE void - division_operator(Tensor (&t)[dim], - const OtherNumber &factor) + constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE void + division_operator(Tensor (&t)[dim], + const OtherNumber &factor) { // recurse over the base objects for (unsigned int d = 0; d < dim; ++d) @@ -1512,7 +1510,7 @@ namespace internal template template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor & Tensor::operator/=(const OtherNumber &s) { @@ -1522,7 +1520,7 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV Tensor Tensor::operator-() const { @@ -1544,7 +1542,7 @@ Tensor::norm() const template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV +constexpr inline DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV typename numbers::NumberTraits::real_type Tensor::norm_square() const { @@ -1582,7 +1580,7 @@ Tensor::unroll_recursion(Vector &result, template -DEAL_II_CONSTEXPR inline unsigned int +constexpr inline unsigned int Tensor::component_to_unrolled_index( const TableIndices &indices) { @@ -1601,7 +1599,7 @@ namespace internal // and rank=2. Make sure we don't have compiler warnings. template - inline DEAL_II_CONSTEXPR unsigned int + inline constexpr unsigned int mod(const unsigned int x) { return x % dim; @@ -1616,7 +1614,7 @@ namespace internal } template - inline DEAL_II_CONSTEXPR unsigned int + inline constexpr unsigned int div(const unsigned int x) { return x / dim; @@ -1635,7 +1633,7 @@ namespace internal template -DEAL_II_CONSTEXPR inline TableIndices +constexpr inline TableIndices Tensor::unrolled_to_component_indices(const unsigned int i) { AssertIndexRange(i, n_independent_components); @@ -1655,7 +1653,7 @@ Tensor::unrolled_to_component_indices(const unsigned int i) template -DEAL_II_CONSTEXPR inline void +constexpr inline void Tensor::clear() { for (unsigned int i = 0; i < dim; ++i) @@ -1747,7 +1745,7 @@ operator<<(std::ostream &out, const Tensor<0, dim, Number> &p) * @relatesalso Tensor */ template -DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE +constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE typename ProductType::type operator*(const Other &object, const Tensor<0, dim, Number> &t) { @@ -1767,7 +1765,7 @@ DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE * @relatesalso Tensor */ template -DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE +constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE typename ProductType::type operator*(const Tensor<0, dim, Number> &t, const Other &object) { @@ -1863,12 +1861,12 @@ constexpr DEAL_II_ALWAYS_INLINE DEAL_II_CUDA_HOST_DEV * @relatesalso Tensor */ template -DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE - Tensor::type>::type> - operator*(const Tensor &t, const OtherNumber &factor) + operator*(const Tensor &t, const OtherNumber &factor) { // recurse over the base objects Tensor::type> tt; @@ -1891,12 +1889,12 @@ DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE * @relatesalso Tensor */ template -DEAL_II_CUDA_HOST_DEV DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE - Tensor::type, OtherNumber>::type> - operator*(const Number &factor, const Tensor &t) + operator*(const Number &factor, const Tensor &t) { // simply forward to the operator above return t * factor; @@ -1915,10 +1913,10 @@ namespace internal !std::is_integral< typename ProductType::type>::value, int>::type = 0> - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE - Tensor::type> - division_operator(const Tensor &t, - const OtherNumber & factor) + constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE + Tensor::type> + division_operator(const Tensor &t, + const OtherNumber & factor) { Tensor::type> tt; const Number inverse_factor = Number(1.) / factor; @@ -1937,10 +1935,10 @@ namespace internal std::is_integral< typename ProductType::type>::value, int>::type = 0> - DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE - Tensor::type> - division_operator(const Tensor &t, - const OtherNumber & factor) + constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE + Tensor::type> + division_operator(const Tensor &t, + const OtherNumber & factor) { Tensor::type> tt; // recurse over the base objects @@ -1962,12 +1960,12 @@ namespace internal * @relatesalso Tensor */ template -DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE - Tensor::type>::type> - operator/(const Tensor &t, const OtherNumber &factor) + operator/(const Tensor &t, const OtherNumber &factor) { return internal::TensorImplementation::division_operator(t, factor); } @@ -1983,9 +1981,9 @@ DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE * @relatesalso Tensor */ template -DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE - Tensor::type> - operator+(const Tensor & p, +constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE + Tensor::type> + operator+(const Tensor & p, const Tensor &q) { Tensor::type> tmp(p); @@ -2007,9 +2005,9 @@ DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE * @relatesalso Tensor */ template -DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE - Tensor::type> - operator-(const Tensor & p, +constexpr DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE + Tensor::type> + operator-(const Tensor & p, const Tensor &q) { Tensor::type> tmp(p); @@ -2027,10 +2025,10 @@ DEAL_II_CONSTEXPR DEAL_II_CUDA_HOST_DEV inline DEAL_II_ALWAYS_INLINE * @relatesalso Tensor */ template -inline DEAL_II_CONSTEXPR DEAL_II_ALWAYS_INLINE - Tensor<0, dim, typename ProductType::type> - schur_product(const Tensor<0, dim, Number> & src1, - const Tensor<0, dim, OtherNumber> &src2) +inline constexpr DEAL_II_ALWAYS_INLINE + Tensor<0, dim, typename ProductType::type> + schur_product(const Tensor<0, dim, Number> & src1, + const Tensor<0, dim, OtherNumber> &src2) { Tensor<0, dim, typename ProductType::type> tmp(src1); @@ -2056,10 +2054,10 @@ inline DEAL_II_CONSTEXPR DEAL_II_ALWAYS_INLINE * @relatesalso Tensor */ template -inline DEAL_II_CONSTEXPR DEAL_II_ALWAYS_INLINE - Tensor::type> - schur_product(const Tensor & src1, - const Tensor &src2) +inline constexpr DEAL_II_ALWAYS_INLINE + Tensor::type> + schur_product(const Tensor & src1, + const Tensor &src2) { Tensor::type> tmp; @@ -2105,7 +2103,7 @@ template = 1 && rank_2 >= 1>::type> -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE typename Tensor::type>::tensor_type @@ -2161,7 +2159,7 @@ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE typename Tensor::type>::tensor_type @@ -2179,11 +2177,13 @@ DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE using namespace TensorAccessors::internal; // Reorder index_1 to the end of src1: - ReorderedIndexView> + const ReorderedIndexView> reord_01 = reordered_index_view(src1); // Reorder index_2 to the end of src2: - ReorderedIndexView> + const ReorderedIndexView> reord_02 = reordered_index_view(src2); typename Tensor -DEAL_II_CONSTEXPR inline +constexpr inline typename Tensor::type>::tensor_type @@ -2315,7 +2315,7 @@ DEAL_II_CONSTEXPR inline * @relatesalso Tensor */ template -DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE +constexpr inline DEAL_II_ALWAYS_INLINE typename ProductType::type scalar_product(const Tensor & left, const Tensor &right) @@ -2352,7 +2352,7 @@ template