diff --git a/include/TFEL/Material/FiniteStrainBehaviourTangentOperator.hxx b/include/TFEL/Material/FiniteStrainBehaviourTangentOperator.hxx index fc7fafe65..017170025 100644 --- a/include/TFEL/Material/FiniteStrainBehaviourTangentOperator.hxx +++ b/include/TFEL/Material/FiniteStrainBehaviourTangentOperator.hxx @@ -17,9 +17,7 @@ #include #include #include - #include "TFEL/Config/TFELConfig.hxx" - #include "TFEL/Metaprogramming/Implements.hxx" #include "TFEL/TypeTraits/BaseType.hxx" #include "TFEL/Math/Forward/st2tost2.hxx" @@ -28,7 +26,6 @@ #include "TFEL/Math/T2toST2/T2toST2Concept.hxx" #include "TFEL/Math/Forward/t2tot2.hxx" #include "TFEL/Math/T2toT2/T2toT2Concept.hxx" - #include "TFEL/Utilities/GenTypeBase.hxx" #include "TFEL/Material/FiniteStrainBehaviourTangentOperatorBase.hxx" @@ -115,28 +112,22 @@ namespace tfel::material { GenType::operator=(src); return *this; } // end of FiniteStrainBehaviourTangentOperator& operator= - /*! - * \param const T1&, the value affected to the GenType. - * \pre T1 must be a type that the GenType can hold. - */ + /*! + * \param const T1&, the value affected to the GenType. + * \pre T1 must be a type that the GenType can hold. + */ template - TFEL_INLINE - typename std::enable_if::value == - 1, - void>::type - set_uninitialised() { + TFEL_INLINE void set_uninitialised() requires( + tfel::meta::TLCountNbrOfT::value == 1) { GenType::template set_uninitialised(); } /*! - * assignement operator + * \brief assignement operator */ - template - std::enable_if_t< - tfel::math::implementsT2toST2Concept() && - tfel::math::getSpaceDimension() == N && - std::is_same_v, StressType>, - FiniteStrainBehaviourTangentOperator&> - operator=(const T& e) { + template + FiniteStrainBehaviourTangentOperator& operator=(const T& e) requires( + tfel::math::getSpaceDimension() == N && + std::is_same_v, StressType>) { using namespace tfel::math; if (this->template is*>()) { *(this->template get*>()) = e; @@ -152,11 +143,9 @@ namespace tfel::material { * \brief assignement operator */ template - std::enable_if_t< + FiniteStrainBehaviourTangentOperator& operator=(const T& e) requires( tfel::math::getSpaceDimension() == N && - std::is_same_v, StressType>, - FiniteStrainBehaviourTangentOperator&> - operator=(const T& e) { + std::is_same_v, StressType>) { using namespace tfel::math; if (this->template is*>()) { *(this->template get*>()) = e; diff --git a/include/TFEL/Math/ST2toST2/ConvertT2toST2ToST2toST2Expr.hxx b/include/TFEL/Math/ST2toST2/ConvertT2toST2ToST2toST2Expr.hxx index 0a4110636..5399e44ae 100644 --- a/include/TFEL/Math/ST2toST2/ConvertT2toST2ToST2toST2Expr.hxx +++ b/include/TFEL/Math/ST2toST2/ConvertT2toST2ToST2toST2Expr.hxx @@ -26,10 +26,8 @@ namespace tfel::math { template struct ConvertT2toST2ToST2toST2Expr; - /*! - * Partial specialisation for 1D stensor - */ - template + //! \brief partial specialisation in 1D + template struct Expr> : public ST2toST2ConceptBase< Expr>>, @@ -42,23 +40,22 @@ namespace tfel::math { /*! * \param[in] A : t2tost2 to be converted */ - template - Expr(const T2toST2Type& A) { + template + TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& A) noexcept { using tfel::fsalgo::copy; - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == getSpaceDimension()); static_assert(isAssignableTo, numeric_type>()); copy<9u>::exe(&A(0, 0), this->v); } // end of Expr - /*! - * \brief access operator - * \param[in] i : line index - * \param[in] j : column index - */ - const value_type& operator()(const unsigned short i, - const unsigned short j) const { + /*! + * \brief access operator + * \param[in] i : line index + * \param[in] j : column index + */ + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 3 + j]; } // end of operator() /*! @@ -66,16 +63,13 @@ namespace tfel::math { * In this case, the number of lines and columns * are deduced from the template parameter */ - RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr - // > + }; // end of Expr> - /*! - * Partial specialisation for 2D stensor - */ - template + //! \brief partial specialisation in 2D + template struct Expr> : public ST2toST2ConceptBase< Expr>>, @@ -89,9 +83,8 @@ namespace tfel::math { /*! * \param[in] A : t2tost2 to be converted */ - template - Expr(const T2toST2Type& A) { - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& A) noexcept { static_assert(getSpaceDimension() == getSpaceDimension()); static_assert(isAssignableTo, @@ -120,8 +113,8 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - const value_type& operator()(const unsigned short i, - const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 4 + j]; } // end of operator() /*! @@ -129,16 +122,13 @@ namespace tfel::math { * In this case, the number of lines and columns * are deduced from the template parameter */ - RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr - // > + }; // end of Expr> - /*! - * Partial specialisation for 3D stensor - */ - template + //! \brief partial specialisation in 3D + template struct Expr> : public ST2toST2ConceptBase< Expr>>, @@ -151,9 +141,8 @@ namespace tfel::math { /*! * \param[in] A : t2tost2 to be converted */ - template - Expr(const T2toST2Type& A) { - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& A) noexcept { static_assert(getSpaceDimension() == getSpaceDimension()); static_assert(isAssignableTo, @@ -202,8 +191,8 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - const value_type& operator()(const unsigned short i, - const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 6 + j]; } // end of operator() /*! @@ -211,11 +200,10 @@ namespace tfel::math { * In this case, the number of lines and columns * are deduced from the template parameter */ - RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr - // > + }; // end of Expr> } // end of namespace tfel::math diff --git a/include/TFEL/Math/ST2toST2/ConvertToTangentModuli.hxx b/include/TFEL/Math/ST2toST2/ConvertToTangentModuli.hxx index a9909838f..ca6e1706e 100644 --- a/include/TFEL/Math/ST2toST2/ConvertToTangentModuli.hxx +++ b/include/TFEL/Math/ST2toST2/ConvertToTangentModuli.hxx @@ -24,158 +24,129 @@ namespace tfel::math { - template - typename std::enable_if<((getSpaceDimension() == 1u) && - (getSpaceDimension() == 1u) && - implementsT2toST2Concept()), - st2tost2<1u, - result_type, - numeric_type, - OpMult>>>::type - convertToTangentModuli(const T2toST2Type& K, const TensorType& F) { - st2tost2<1u, result_type, - numeric_type, OpMult>> - C; - C(0, 0) = K(0, 0) * F(0); - C(0, 1) = K(0, 1) * F(1); - C(0, 2) = K(0, 2) * F(2); - C(1, 0) = K(1, 0) * F(0); - C(1, 1) = K(1, 1) * F(1); - C(1, 2) = K(1, 2) * F(2); - C(2, 0) = K(2, 0) * F(0); - C(2, 1) = K(2, 1) * F(1); - C(2, 2) = K(2, 2) * F(2); + template + TFEL_HOST_DEVICE constexpr auto convertToTangentModuli( + const T2toST2Type& K, const TensorType& F) noexcept // + requires(getSpaceDimension() == + getSpaceDimension()) { + constexpr auto N = getSpaceDimension(); + using value_type = result_type, + numeric_type, OpMult>; + auto C = st2tost2{}; + if constexpr (N == 1) { + C(0, 0) = K(0, 0) * F(0); + C(0, 1) = K(0, 1) * F(1); + C(0, 2) = K(0, 2) * F(2); + C(1, 0) = K(1, 0) * F(0); + C(1, 1) = K(1, 1) * F(1); + C(1, 2) = K(1, 2) * F(2); + C(2, 0) = K(2, 0) * F(0); + C(2, 1) = K(2, 1) * F(1); + C(2, 2) = K(2, 2) * F(2); + } else if constexpr (N == 2) { + constexpr const auto icste2 = Cste::isqrt2 / 2; + C(0, 0) = K(0, 0) * F(0) + K(0, 3) * F(3); + C(0, 3) = + (K(0, 0) * F(4) + K(0, 3) * F(1) + K(0, 4) * F(0) + K(0, 1) * F(3)) * + icste2; + C(0, 1) = K(0, 4) * F(4) + K(0, 1) * F(1); + C(0, 2) = K(0, 2) * F(2); + C(3, 0) = K(3, 0) * F(0) + K(3, 3) * F(3); + C(3, 3) = + (K(3, 0) * F(4) + K(3, 3) * F(1) + K(3, 4) * F(0) + K(3, 1) * F(3)) * + icste2; + C(3, 1) = K(3, 4) * F(4) + K(3, 1) * F(1); + C(3, 2) = K(3, 2) * F(2); + C(1, 0) = K(1, 0) * F(0) + K(1, 3) * F(3); + C(1, 3) = + (K(1, 0) * F(4) + K(1, 3) * F(1) + K(1, 4) * F(0) + K(1, 1) * F(3)) * + icste2; + C(1, 1) = K(1, 4) * F(4) + K(1, 1) * F(1); + C(1, 2) = K(1, 2) * F(2); + C(2, 0) = K(2, 0) * F(0) + K(2, 3) * F(3); + C(2, 3) = + (K(2, 0) * F(4) + K(2, 3) * F(1) + K(2, 4) * F(0) + K(2, 1) * F(3)) * + icste2; + C(2, 1) = K(2, 4) * F(4) + K(2, 1) * F(1); + C(2, 2) = K(2, 2) * F(2); + } else { + constexpr const auto icste2 = Cste::isqrt2 / 2; + C(0, 0) = K(0, 0) * F(0) + K(0, 3) * F(3) + K(0, 5) * F(5); + C(0, 3) = (K(0, 0) * F(4) + K(0, 3) * F(1) + K(0, 5) * F(7) + + K(0, 4) * F(0) + K(0, 1) * F(3) + K(0, 7) * F(5)) * + icste2; + C(0, 4) = (K(0, 0) * F(6) + K(0, 3) * F(8) + K(0, 5) * F(2) + + K(0, 6) * F(0) + K(0, 8) * F(3) + K(0, 2) * F(5)) * + icste2; + C(0, 1) = K(0, 4) * F(4) + K(0, 1) * F(1) + K(0, 7) * F(7); + C(0, 5) = (K(0, 4) * F(6) + K(0, 1) * F(8) + K(0, 7) * F(2) + + K(0, 6) * F(4) + K(0, 8) * F(1) + K(0, 2) * F(7)) * + icste2; + C(0, 2) = K(0, 6) * F(6) + K(0, 8) * F(8) + K(0, 2) * F(2); + C(3, 0) = K(3, 0) * F(0) + K(3, 3) * F(3) + K(3, 5) * F(5); + C(3, 3) = (K(3, 0) * F(4) + K(3, 3) * F(1) + K(3, 5) * F(7) + + K(3, 4) * F(0) + K(3, 1) * F(3) + K(3, 7) * F(5)) * + icste2; + C(3, 4) = (K(3, 0) * F(6) + K(3, 3) * F(8) + K(3, 5) * F(2) + + K(3, 6) * F(0) + K(3, 8) * F(3) + K(3, 2) * F(5)) * + icste2; + C(3, 1) = K(3, 4) * F(4) + K(3, 1) * F(1) + K(3, 7) * F(7); + C(3, 5) = (K(3, 4) * F(6) + K(3, 1) * F(8) + K(3, 7) * F(2) + + K(3, 6) * F(4) + K(3, 8) * F(1) + K(3, 2) * F(7)) * + icste2; + C(3, 2) = K(3, 6) * F(6) + K(3, 8) * F(8) + K(3, 2) * F(2); + C(4, 0) = K(4, 0) * F(0) + K(4, 3) * F(3) + K(4, 5) * F(5); + C(4, 3) = (K(4, 0) * F(4) + K(4, 3) * F(1) + K(4, 5) * F(7) + + K(4, 4) * F(0) + K(4, 1) * F(3) + K(4, 7) * F(5)) * + icste2; + C(4, 4) = (K(4, 0) * F(6) + K(4, 3) * F(8) + K(4, 5) * F(2) + + K(4, 6) * F(0) + K(4, 8) * F(3) + K(4, 2) * F(5)) * + icste2; + C(4, 1) = K(4, 4) * F(4) + K(4, 1) * F(1) + K(4, 7) * F(7); + C(4, 5) = (K(4, 4) * F(6) + K(4, 1) * F(8) + K(4, 7) * F(2) + + K(4, 6) * F(4) + K(4, 8) * F(1) + K(4, 2) * F(7)) * + icste2; + C(4, 2) = K(4, 6) * F(6) + K(4, 8) * F(8) + K(4, 2) * F(2); + C(1, 0) = K(1, 0) * F(0) + K(1, 3) * F(3) + K(1, 5) * F(5); + C(1, 3) = (K(1, 0) * F(4) + K(1, 3) * F(1) + K(1, 5) * F(7) + + K(1, 4) * F(0) + K(1, 1) * F(3) + K(1, 7) * F(5)) * + icste2; + C(1, 4) = (K(1, 0) * F(6) + K(1, 3) * F(8) + K(1, 5) * F(2) + + K(1, 6) * F(0) + K(1, 8) * F(3) + K(1, 2) * F(5)) * + icste2; + C(1, 1) = K(1, 4) * F(4) + K(1, 1) * F(1) + K(1, 7) * F(7); + C(1, 5) = (K(1, 4) * F(6) + K(1, 1) * F(8) + K(1, 7) * F(2) + + K(1, 6) * F(4) + K(1, 8) * F(1) + K(1, 2) * F(7)) * + icste2; + C(1, 2) = K(1, 6) * F(6) + K(1, 8) * F(8) + K(1, 2) * F(2); + C(5, 0) = K(5, 0) * F(0) + K(5, 3) * F(3) + K(5, 5) * F(5); + C(5, 3) = (K(5, 0) * F(4) + K(5, 3) * F(1) + K(5, 5) * F(7) + + K(5, 4) * F(0) + K(5, 1) * F(3) + K(5, 7) * F(5)) * + icste2; + C(5, 4) = (K(5, 0) * F(6) + K(5, 3) * F(8) + K(5, 5) * F(2) + + K(5, 6) * F(0) + K(5, 8) * F(3) + K(5, 2) * F(5)) * + icste2; + C(5, 1) = K(5, 4) * F(4) + K(5, 1) * F(1) + K(5, 7) * F(7); + C(5, 5) = (K(5, 4) * F(6) + K(5, 1) * F(8) + K(5, 7) * F(2) + + K(5, 6) * F(4) + K(5, 8) * F(1) + K(5, 2) * F(7)) * + icste2; + C(5, 2) = K(5, 6) * F(6) + K(5, 8) * F(8) + K(5, 2) * F(2); + C(2, 0) = K(2, 0) * F(0) + K(2, 3) * F(3) + K(2, 5) * F(5); + C(2, 3) = (K(2, 0) * F(4) + K(2, 3) * F(1) + K(2, 5) * F(7) + + K(2, 4) * F(0) + K(2, 1) * F(3) + K(2, 7) * F(5)) * + icste2; + C(2, 4) = (K(2, 0) * F(6) + K(2, 3) * F(8) + K(2, 5) * F(2) + + K(2, 6) * F(0) + K(2, 8) * F(3) + K(2, 2) * F(5)) * + icste2; + C(2, 1) = K(2, 4) * F(4) + K(2, 1) * F(1) + K(2, 7) * F(7); + C(2, 5) = (K(2, 4) * F(6) + K(2, 1) * F(8) + K(2, 7) * F(2) + + K(2, 6) * F(4) + K(2, 8) * F(1) + K(2, 2) * F(7)) * + icste2; + C(2, 2) = K(2, 6) * F(6) + K(2, 8) * F(8) + K(2, 2) * F(2); + } return C; } // end of convertToTangentModuli - template - typename std::enable_if<((getSpaceDimension() == 2u) && - (getSpaceDimension() == 2u) && - implementsT2toST2Concept()), - st2tost2<2u, - result_type, - numeric_type, - OpMult>>>::type - convertToTangentModuli(const T2toST2Type& K, const TensorType& F) { - using res = result_type, numeric_type, - OpMult>; - TFEL_HOST_DEVICE constexpr const auto icste2 = Cste::isqrt2 / 2; - st2tost2<2u, res> C; - C(0, 0) = K(0, 0) * F(0) + K(0, 3) * F(3); - C(0, 3) = - (K(0, 0) * F(4) + K(0, 3) * F(1) + K(0, 4) * F(0) + K(0, 1) * F(3)) * - icste2; - C(0, 1) = K(0, 4) * F(4) + K(0, 1) * F(1); - C(0, 2) = K(0, 2) * F(2); - C(3, 0) = K(3, 0) * F(0) + K(3, 3) * F(3); - C(3, 3) = - (K(3, 0) * F(4) + K(3, 3) * F(1) + K(3, 4) * F(0) + K(3, 1) * F(3)) * - icste2; - C(3, 1) = K(3, 4) * F(4) + K(3, 1) * F(1); - C(3, 2) = K(3, 2) * F(2); - C(1, 0) = K(1, 0) * F(0) + K(1, 3) * F(3); - C(1, 3) = - (K(1, 0) * F(4) + K(1, 3) * F(1) + K(1, 4) * F(0) + K(1, 1) * F(3)) * - icste2; - C(1, 1) = K(1, 4) * F(4) + K(1, 1) * F(1); - C(1, 2) = K(1, 2) * F(2); - C(2, 0) = K(2, 0) * F(0) + K(2, 3) * F(3); - C(2, 3) = - (K(2, 0) * F(4) + K(2, 3) * F(1) + K(2, 4) * F(0) + K(2, 1) * F(3)) * - icste2; - C(2, 1) = K(2, 4) * F(4) + K(2, 1) * F(1); - C(2, 2) = K(2, 2) * F(2); - return C; - } // end of convertToTangentModuli - - template - typename std::enable_if<((getSpaceDimension() == 3u) && - (getSpaceDimension() == 3u) && - implementsT2toST2Concept()), - st2tost2<3u, - result_type, - numeric_type, - OpMult>>>::type - convertToTangentModuli(const T2toST2Type& K, const TensorType& F) { - using res = result_type, numeric_type, - OpMult>; - TFEL_HOST_DEVICE constexpr const auto icste2 = Cste::isqrt2 / 2; - st2tost2<3u, res> C; - C(0, 0) = K(0, 0) * F(0) + K(0, 3) * F(3) + K(0, 5) * F(5); - C(0, 3) = (K(0, 0) * F(4) + K(0, 3) * F(1) + K(0, 5) * F(7) + - K(0, 4) * F(0) + K(0, 1) * F(3) + K(0, 7) * F(5)) * - icste2; - C(0, 4) = (K(0, 0) * F(6) + K(0, 3) * F(8) + K(0, 5) * F(2) + - K(0, 6) * F(0) + K(0, 8) * F(3) + K(0, 2) * F(5)) * - icste2; - C(0, 1) = K(0, 4) * F(4) + K(0, 1) * F(1) + K(0, 7) * F(7); - C(0, 5) = (K(0, 4) * F(6) + K(0, 1) * F(8) + K(0, 7) * F(2) + - K(0, 6) * F(4) + K(0, 8) * F(1) + K(0, 2) * F(7)) * - icste2; - C(0, 2) = K(0, 6) * F(6) + K(0, 8) * F(8) + K(0, 2) * F(2); - C(3, 0) = K(3, 0) * F(0) + K(3, 3) * F(3) + K(3, 5) * F(5); - C(3, 3) = (K(3, 0) * F(4) + K(3, 3) * F(1) + K(3, 5) * F(7) + - K(3, 4) * F(0) + K(3, 1) * F(3) + K(3, 7) * F(5)) * - icste2; - C(3, 4) = (K(3, 0) * F(6) + K(3, 3) * F(8) + K(3, 5) * F(2) + - K(3, 6) * F(0) + K(3, 8) * F(3) + K(3, 2) * F(5)) * - icste2; - C(3, 1) = K(3, 4) * F(4) + K(3, 1) * F(1) + K(3, 7) * F(7); - C(3, 5) = (K(3, 4) * F(6) + K(3, 1) * F(8) + K(3, 7) * F(2) + - K(3, 6) * F(4) + K(3, 8) * F(1) + K(3, 2) * F(7)) * - icste2; - C(3, 2) = K(3, 6) * F(6) + K(3, 8) * F(8) + K(3, 2) * F(2); - C(4, 0) = K(4, 0) * F(0) + K(4, 3) * F(3) + K(4, 5) * F(5); - C(4, 3) = (K(4, 0) * F(4) + K(4, 3) * F(1) + K(4, 5) * F(7) + - K(4, 4) * F(0) + K(4, 1) * F(3) + K(4, 7) * F(5)) * - icste2; - C(4, 4) = (K(4, 0) * F(6) + K(4, 3) * F(8) + K(4, 5) * F(2) + - K(4, 6) * F(0) + K(4, 8) * F(3) + K(4, 2) * F(5)) * - icste2; - C(4, 1) = K(4, 4) * F(4) + K(4, 1) * F(1) + K(4, 7) * F(7); - C(4, 5) = (K(4, 4) * F(6) + K(4, 1) * F(8) + K(4, 7) * F(2) + - K(4, 6) * F(4) + K(4, 8) * F(1) + K(4, 2) * F(7)) * - icste2; - C(4, 2) = K(4, 6) * F(6) + K(4, 8) * F(8) + K(4, 2) * F(2); - C(1, 0) = K(1, 0) * F(0) + K(1, 3) * F(3) + K(1, 5) * F(5); - C(1, 3) = (K(1, 0) * F(4) + K(1, 3) * F(1) + K(1, 5) * F(7) + - K(1, 4) * F(0) + K(1, 1) * F(3) + K(1, 7) * F(5)) * - icste2; - C(1, 4) = (K(1, 0) * F(6) + K(1, 3) * F(8) + K(1, 5) * F(2) + - K(1, 6) * F(0) + K(1, 8) * F(3) + K(1, 2) * F(5)) * - icste2; - C(1, 1) = K(1, 4) * F(4) + K(1, 1) * F(1) + K(1, 7) * F(7); - C(1, 5) = (K(1, 4) * F(6) + K(1, 1) * F(8) + K(1, 7) * F(2) + - K(1, 6) * F(4) + K(1, 8) * F(1) + K(1, 2) * F(7)) * - icste2; - C(1, 2) = K(1, 6) * F(6) + K(1, 8) * F(8) + K(1, 2) * F(2); - C(5, 0) = K(5, 0) * F(0) + K(5, 3) * F(3) + K(5, 5) * F(5); - C(5, 3) = (K(5, 0) * F(4) + K(5, 3) * F(1) + K(5, 5) * F(7) + - K(5, 4) * F(0) + K(5, 1) * F(3) + K(5, 7) * F(5)) * - icste2; - C(5, 4) = (K(5, 0) * F(6) + K(5, 3) * F(8) + K(5, 5) * F(2) + - K(5, 6) * F(0) + K(5, 8) * F(3) + K(5, 2) * F(5)) * - icste2; - C(5, 1) = K(5, 4) * F(4) + K(5, 1) * F(1) + K(5, 7) * F(7); - C(5, 5) = (K(5, 4) * F(6) + K(5, 1) * F(8) + K(5, 7) * F(2) + - K(5, 6) * F(4) + K(5, 8) * F(1) + K(5, 2) * F(7)) * - icste2; - C(5, 2) = K(5, 6) * F(6) + K(5, 8) * F(8) + K(5, 2) * F(2); - C(2, 0) = K(2, 0) * F(0) + K(2, 3) * F(3) + K(2, 5) * F(5); - C(2, 3) = (K(2, 0) * F(4) + K(2, 3) * F(1) + K(2, 5) * F(7) + - K(2, 4) * F(0) + K(2, 1) * F(3) + K(2, 7) * F(5)) * - icste2; - C(2, 4) = (K(2, 0) * F(6) + K(2, 3) * F(8) + K(2, 5) * F(2) + - K(2, 6) * F(0) + K(2, 8) * F(3) + K(2, 2) * F(5)) * - icste2; - C(2, 1) = K(2, 4) * F(4) + K(2, 1) * F(1) + K(2, 7) * F(7); - C(2, 5) = (K(2, 4) * F(6) + K(2, 1) * F(8) + K(2, 7) * F(2) + - K(2, 6) * F(4) + K(2, 8) * F(1) + K(2, 2) * F(7)) * - icste2; - C(2, 2) = K(2, 6) * F(6) + K(2, 8) * F(8) + K(2, 2) * F(2); - return C; - } - } // end of namespace tfel::math #endif /* LIB_TFEL_MATH_CONVERTTOTANGENTMODULI_HXX */ diff --git a/include/TFEL/Math/ST2toST2/ST2toST2Concept.hxx b/include/TFEL/Math/ST2toST2/ST2toST2Concept.hxx index a563e96b1..b9fc26262 100644 --- a/include/TFEL/Math/ST2toST2/ST2toST2Concept.hxx +++ b/include/TFEL/Math/ST2toST2/ST2toST2Concept.hxx @@ -54,7 +54,10 @@ namespace tfel::math { (requires(const T t, const unsigned short i, const unsigned short j) { t(i, j); }); - //! \brief partial specialisation for symmetric tensors + /*! + * \brief partial specialisation for fourth order tensor transforming a + * symmetric tensor in another symmetric tensor + */ template struct ConceptRebind { //! \brief a simple alias diff --git a/include/TFEL/Math/ST2toST2/st2tost2.ixx b/include/TFEL/Math/ST2toST2/st2tost2.ixx index 1bd809d32..bfdb26884 100644 --- a/include/TFEL/Math/ST2toST2/st2tost2.ixx +++ b/include/TFEL/Math/ST2toST2/st2tost2.ixx @@ -53,26 +53,25 @@ namespace tfel::math { template template - std::enable_if_t() == N && - isAssignableTo, T>(), - tfel::math::st2tost2> - st2tost2::stpd(const StensorType& s) { + TFEL_HOST_DEVICE constexpr auto + st2tost2::stpd(const StensorType& s) noexcept requires( + getSpaceDimension() == N && + isAssignableTo, T>()) { return StensorSymmetricProductDerivative::exe(s); } template - template - std::enable_if_t() && - getSpaceDimension() == N && - isAssignableTo, T>(), - Expr, ConvertT2toST2ToST2toST2Expr>> - st2tost2::convert(const T2toST2Type& src) { + template + TFEL_HOST_DEVICE constexpr auto + st2tost2::convert(const T2toST2Type& src) noexcept requires( + getSpaceDimension() == N && + isAssignableTo, T>()) { return Expr, ConvertT2toST2ToST2toST2Expr>(src); - } + } // end of convert template - st2tost2> st2tost2::fromRotationMatrix( - const rotation_matrix& r) { + TFEL_HOST_DEVICE constexpr auto st2tost2::fromRotationMatrix( + const rotation_matrix& r) noexcept { return st2tost2_internals::BuildFromRotationMatrix::exe(r); } // end of st2tost2::fromRotationMatrix @@ -245,21 +244,21 @@ namespace tfel::math { } // end of invert template - TFEL_HOST_DEVICE constexpr st2tost2(), - numeric_type> - change_basis(const ST2toST2Type& s, - const rotation_matrix>& r) noexcept { + TFEL_HOST_DEVICE constexpr auto change_basis( + const ST2toST2Type& s, + const rotation_matrix>& r) noexcept { constexpr auto N = getSpaceDimension(); + using Result = st2tost2>; if constexpr (N == 1) { - return s; + return Result{s}; } else { using st2tost2 = tfel::math::st2tost2>; const auto sr = st2tost2::fromRotationMatrix(r); const auto sir = st2tost2::fromRotationMatrix(transpose(r)); - return sr * s * sir; + return Result{sr * s * sir}; } - } // end of change_basie + } // end of change_basis template TFEL_HOST_DEVICE constexpr auto diff --git a/include/TFEL/Math/ST2toT2/ST2toT2Concept.hxx b/include/TFEL/Math/ST2toT2/ST2toT2Concept.hxx index 2133b121d..6ac2571c5 100644 --- a/include/TFEL/Math/ST2toT2/ST2toT2Concept.hxx +++ b/include/TFEL/Math/ST2toT2/ST2toT2Concept.hxx @@ -29,41 +29,52 @@ namespace tfel::math { * \brief Helper class to characterise st2tot2. */ struct ST2toT2Tag {}; - + /*! + * \brief an helper class that simply exposes publically a member named + * ConceptTag as an alias to T2toT2Tag. + * + * The main reason for this alias is to properly implement the `ConceptRebind` + * metafunction. + */ template - struct ST2toT2Concept { - typedef ST2toT2Tag ConceptTag; - - protected: - ST2toT2Concept() = default; - ST2toT2Concept(ST2toT2Concept&&) = default; - ST2toT2Concept(const ST2toT2Concept&) = default; - ST2toT2Concept& operator=(const ST2toT2Concept&) = default; - ~ST2toT2Concept() = default; + struct ST2toT2ConceptBase { + using ConceptTag = ST2toT2Tag; }; - + /*! + * \brief definition of the ST2toT2Concept + * + * A class matching this concept must expose the `ST2toT2Tag` and have + * appropriate access operators. + */ + template + concept ST2toT2Concept = + (std::is_same_v::ConceptTag, ST2toT2Tag>)&& // + (requires(const T t, const unsigned short i, const unsigned short j) { + t(i, j); + }); + //! \brief partial specialisation for fourth order tensor + template + struct ConceptRebind { + using type = ST2toT2ConceptBase; + }; + /*! + * \return the sum of the absolute values of all components of an + * linear application transforming a tensor in a tensor + * \param[in] t: fourth order tensor + */ + constexpr auto abs(const ST2toT2Concept auto&) noexcept; /*! * \brief an helper function which returns if the given type implements the * `ST2toT2Concept`. * \tparam ST2toT2Type: type tested + * \note function given for backward compatibility with versions prior + * to 5.0 */ template - TFEL_HOST_DEVICE constexpr bool implementsST2toT2Concept() { - return tfel::meta::implements(); + [[deprecated]] TFEL_HOST_DEVICE constexpr bool implementsST2toT2Concept() { + return ST2toT2Concept; } // end of implementsST2toT2Concept - //! paratial specialisation for symmetric tensors - template - struct ConceptRebind { - using type = ST2toT2Concept; - }; - - template - typename std::enable_if< - implementsST2toT2Concept(), - typename tfel::typetraits::AbsType>::type>::type - abs(const ST2toT2Type&); - } // end of namespace tfel::math #include "TFEL/Math/ST2toT2/ST2toT2Concept.ixx" diff --git a/include/TFEL/Math/ST2toT2/ST2toT2Concept.ixx b/include/TFEL/Math/ST2toT2/ST2toT2Concept.ixx index 3ea84ecce..27d57413f 100644 --- a/include/TFEL/Math/ST2toT2/ST2toT2Concept.ixx +++ b/include/TFEL/Math/ST2toT2/ST2toT2Concept.ixx @@ -19,21 +19,18 @@ namespace tfel::math { - template - typename std::enable_if< - implementsST2toT2Concept(), - typename tfel::typetraits::AbsType>::type>::type - abs(const ST2toT2Type& v) { + TFEL_HOST_DEVICE constexpr auto abs(const ST2toT2Concept auto& t) noexcept { + using ST2toT2Type = decltype(t); using NumType = numeric_type; using AbsNumType = typename tfel::typetraits::AbsType::type; constexpr auto tsize = TensorDimeToSize()>::value; constexpr auto ssize = StensorDimeToSize()>::value; - AbsNumType a(0); + auto a = AbsNumType{}; for (unsigned short i = 0; i < tsize; ++i) { for (unsigned short j = 0; j < ssize; ++j) { - a += abs(v(i, j)); + a += abs(t(i, j)); } } return a; diff --git a/include/TFEL/Math/ST2toT2/ST2toT2ConceptIO.hxx b/include/TFEL/Math/ST2toT2/ST2toT2ConceptIO.hxx index ea77f9b27..9022333d9 100644 --- a/include/TFEL/Math/ST2toT2/ST2toT2ConceptIO.hxx +++ b/include/TFEL/Math/ST2toT2/ST2toT2ConceptIO.hxx @@ -20,9 +20,9 @@ namespace tfel::math { // Serialisation operator - template - std::enable_if_t(), std::ostream&> - operator<<(std::ostream& os, const ST2toT2Type& s) { + TFEL_HOST std::ostream& operator<<(std::ostream& os, + const ST2toT2Concept auto& t) { + using ST2toT2Type = decltype(t); constexpr auto N = getSpaceDimension(); constexpr auto stensor_size = StensorDimeToSize::value; constexpr auto tensor_size = TensorDimeToSize::value; @@ -34,7 +34,7 @@ namespace tfel::math { os << "["; } for (unsigned short j = 0; j < stensor_size;) { - os << s(i, j); + os << t(i, j); if (++j != stensor_size) { os << ","; } diff --git a/include/TFEL/Math/ST2toT2/ST2toT2ConceptOperations.hxx b/include/TFEL/Math/ST2toT2/ST2toT2ConceptOperations.hxx index 4d5032798..ade2d7175 100644 --- a/include/TFEL/Math/ST2toT2/ST2toT2ConceptOperations.hxx +++ b/include/TFEL/Math/ST2toT2/ST2toT2ConceptOperations.hxx @@ -177,15 +177,13 @@ namespace tfel::math { Expr>>; }; - template - TFEL_MATH_INLINE typename std::enable_if< - implementsST2toT2Concept() && - !isInvalid>(), - BinaryOperationHandler>::type - operator|(const T1& a, const T2& b) { + template + TFEL_HOST_DEVICE constexpr auto + operator|(const T1& a, const T2& b) noexcept requires( + !isInvalid>()) { using Handle = BinaryOperationHandler; return Handle(a, b); - } + } // end of operator| } // end of namespace tfel::math diff --git a/include/TFEL/Math/ST2toT2/ST2toT2ST2toST2ProductExpr.hxx b/include/TFEL/Math/ST2toT2/ST2toT2ST2toST2ProductExpr.hxx index ce90d04cf..f888180bf 100644 --- a/include/TFEL/Math/ST2toT2/ST2toT2ST2toST2ProductExpr.hxx +++ b/include/TFEL/Math/ST2toT2/ST2toT2ST2toST2ProductExpr.hxx @@ -15,26 +15,25 @@ #define LIB_TFEL_MATH_ST2TOT2ST2TOST2PRODUCTEXPR_HXX #include "TFEL/Config/TFELConfig.hxx" - #include "TFEL/Math/General/EmptyRunTimeProperties.hxx" #include "TFEL/Math/ST2toT2/ST2toT2Concept.hxx" #include "TFEL/Math/ST2toST2/ST2toST2Concept.hxx" namespace tfel::math { - //! Empty structure used for partial specialisation of the - //! Expr class + /*! + * \brief empty structure used for partial specialisation of the + * Expr class + */ template struct TFEL_VISIBILITY_LOCAL ST2toT2ST2toST2ProductExpr { }; // end of struct ST2toT2ST2toST2ProductExpr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 1D + template struct TFEL_VISIBILITY_LOCAL Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder< TensorDimeToSize()>::value * @@ -50,10 +49,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, const ST2toST2Type2& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0); @@ -75,21 +73,17 @@ namespace tfel::math { const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 3 + j]; } // end of operator() - /*! - * \return the runtime properties - */ + //! \return the runtime properties TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 2D + template struct TFEL_VISIBILITY_LOCAL Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder< TensorDimeToSize()>::value * @@ -105,10 +99,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, const ST2toST2Type2& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + @@ -161,21 +154,17 @@ namespace tfel::math { const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 4 + j]; } // end of operator() - /*! - * \return the runtime properties - */ + //! \return the runtime properties TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 3D + template struct TFEL_VISIBILITY_LOCAL Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder< TensorDimeToSize()>::value * @@ -191,10 +180,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, const ST2toST2Type2& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + @@ -315,9 +303,7 @@ namespace tfel::math { const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 6 + j]; } // end of operator() - /*! - * \return the runtime properties - */ + //! \return the runtime properties TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } diff --git a/include/TFEL/Math/ST2toT2/ST2toT2StensorProductExpr.hxx b/include/TFEL/Math/ST2toT2/ST2toT2StensorProductExpr.hxx index 747a09d3f..e1395974d 100644 --- a/include/TFEL/Math/ST2toT2/ST2toT2StensorProductExpr.hxx +++ b/include/TFEL/Math/ST2toT2/ST2toT2StensorProductExpr.hxx @@ -28,9 +28,7 @@ namespace tfel::math { struct ST2toT2StensorProductExpr { }; // end of struct ST2toT2StensorProductExpr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 1D template struct Expr> : public TensorConceptBase< @@ -47,9 +45,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const ST2toT2Type& a, const StensorType& b) { - static_assert(implementsST2toT2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, + const StensorType& b) noexcept { static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = a(0, 0) * b(0) + a(0, 1) * b(1) + a(0, 2) * b(2); @@ -60,21 +58,27 @@ namespace tfel::math { * \brief access operator * \param[in] i : index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i) const { + TFEL_HOST_DEVICE constexpr const value_type& operator[]( + const unsigned short i) const noexcept { + return this->operator()(i); + } // end of operator() + /*! + * \brief access operator + * \param[in] i : index + */ + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i) const noexcept { return this->v[i]; } // end of operator() /*! * \return the runtime properties */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 2D template struct Expr> : public TensorConceptBase< @@ -91,9 +95,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const ST2toT2Type& a, const StensorType& b) { - static_assert(implementsST2toT2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, + const StensorType& b) noexcept { static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = @@ -111,21 +115,27 @@ namespace tfel::math { * \brief access operator * \param[in] i : index */ - TFEL_MATH_INLINE const value_type& operator()( + TFEL_HOST_DEVICE constexpr const value_type& operator[]( + const unsigned short i) const noexcept { + return this->operator()(i); + } // end of operator() + /*! + * \brief access operator + * \param[in] i : index + */ + TFEL_HOST_DEVICE constexpr const value_type& operator()( const unsigned short i) const { return this->v[i]; } // end of operator() /*! * \return the runtime properties */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 3D template struct Expr> : public TensorConceptBase< @@ -142,9 +152,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const ST2toT2Type& a, const StensorType& b) { - static_assert(implementsST2toT2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, + const StensorType& b) noexcept { static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = a(0, 0) * b(0) + a(0, 1) * b(1) + a(0, 2) * b(2) + @@ -170,14 +180,22 @@ namespace tfel::math { * \brief access operator * \param[in] i : index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i) const { + TFEL_HOST_DEVICE constexpr const value_type& operator[]( + const unsigned short i) const noexcept { + return this->operator()(i); + } // end of operator() + /*! + * \brief access operator + * \param[in] i : index + */ + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i) const noexcept { return this->v[i]; } // end of operator() /*! * \return the runtime properties */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr diff --git a/include/TFEL/Math/ST2toT2/ST2toT2T2toST2ProductExpr.hxx b/include/TFEL/Math/ST2toT2/ST2toT2T2toST2ProductExpr.hxx index ef1c36b94..077cf83e5 100644 --- a/include/TFEL/Math/ST2toT2/ST2toT2T2toST2ProductExpr.hxx +++ b/include/TFEL/Math/ST2toT2/ST2toT2T2toST2ProductExpr.hxx @@ -28,9 +28,7 @@ namespace tfel::math { struct TFEL_VISIBILITY_LOCAL ST2toT2T2toST2ProductExpr { }; // end of struct ST2toT2T2toST2ProductExpr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 1D template struct TFEL_VISIBILITY_LOCAL Expr> @@ -49,10 +47,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const ST2toT2Type& a, const T2toST2Type2& b) { - static_assert(implementsST2toT2Concept()); - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, + const T2toST2Type2& b) noexcept { static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0); @@ -70,21 +67,17 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i, const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 3 + j]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr + }; // end of Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 2D template struct TFEL_VISIBILITY_LOCAL Expr> @@ -103,10 +96,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const ST2toT2Type& a, const T2toST2Type2& b) { - static_assert(implementsST2toT2Concept()); - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, + const T2toST2Type2& b) noexcept { static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + @@ -165,21 +157,17 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i, const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 5 + j]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr + }; // end of Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 3D template struct TFEL_VISIBILITY_LOCAL Expr> @@ -198,10 +186,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const ST2toT2Type& a, const T2toST2Type2& b) { - static_assert(implementsST2toT2Concept()); - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const ST2toT2Type& a, + const T2toST2Type2& b) noexcept { static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + @@ -372,17 +359,15 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i, const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 9 + j]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr + }; // end of Expr } // end of namespace tfel::math diff --git a/include/TFEL/Math/ST2toT2/StensorProductLeftDerivativeExpr.hxx b/include/TFEL/Math/ST2toT2/StensorProductLeftDerivativeExpr.hxx index 24d0686a3..6aad7e04b 100644 --- a/include/TFEL/Math/ST2toT2/StensorProductLeftDerivativeExpr.hxx +++ b/include/TFEL/Math/ST2toT2/StensorProductLeftDerivativeExpr.hxx @@ -23,12 +23,10 @@ namespace tfel::math { struct StensorProductLeftDerivativeExpr { }; // end of struct StensorProductLeftDerivativeExpr - /*! - * Partial specialisation for 1D tensor - */ + //! \brief partial specialisation in 2D template struct Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder<9u, numeric_type> { static_assert(getSpaceDimension() == 1u); @@ -96,15 +94,12 @@ namespace tfel::math { TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct - // Expr > + }; // end of Expr> - /*! - * Partial specialisation for 2D tensor - */ + //! \brief partial specialisation in 2D template struct Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder<20u, numeric_type> { static_assert(getSpaceDimension() == 2u); @@ -203,15 +198,12 @@ namespace tfel::math { TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct - // Expr > + }; // end of Expr> - /*! - * Partial specialisation for 3D tensor - */ + //! \brief partial specialisation in 3D template struct Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder<54u, numeric_type> { static_assert(getSpaceDimension() == 3u); @@ -431,8 +423,7 @@ namespace tfel::math { TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct - // Expr > + }; // end of Expr> } // namespace tfel::math diff --git a/include/TFEL/Math/ST2toT2/StensorProductRightDerivativeExpr.hxx b/include/TFEL/Math/ST2toT2/StensorProductRightDerivativeExpr.hxx index b28847873..0fd914f3f 100644 --- a/include/TFEL/Math/ST2toT2/StensorProductRightDerivativeExpr.hxx +++ b/include/TFEL/Math/ST2toT2/StensorProductRightDerivativeExpr.hxx @@ -20,18 +20,17 @@ namespace tfel::math { /*! - * Empty structure allowing partial specialisation + * \brief empty structure allowing partial specialisation + * of the Expr class */ template struct StensorProductRightDerivativeExpr { }; // end of struct StensorProductRightDerivativeExpr - /*! - * Partial specialisation for 1D stensor - */ - template + //! \brief partial specialisation in 1D + template struct Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder<9u, numeric_type> { static_assert(getSpaceDimension() == 1u); @@ -99,15 +98,12 @@ namespace tfel::math { TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct - // Expr > + }; // end of Expr> - /*! - * Partial specialisation for 2D stensor - */ - template + //! \brief partial specialisation in 3D + template struct Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder<20u, numeric_type> { static_assert(getSpaceDimension() == 2u); @@ -206,15 +202,12 @@ namespace tfel::math { TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct - // Expr > + }; // end of Expr> - /*! - * Partial specialisation for 3D stensor - */ - template + //! \brief partial specialisation in 3D + template struct Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder<54u, numeric_type> { static_assert(getSpaceDimension() == 3u); @@ -435,8 +428,7 @@ namespace tfel::math { TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct - // Expr > + }; // end of Expr> } // end of namespace tfel::math diff --git a/include/TFEL/Math/ST2toT2/T2toST2ST2toT2ProductExpr.hxx b/include/TFEL/Math/ST2toT2/T2toST2ST2toT2ProductExpr.hxx index b4a89626e..0297685f0 100644 --- a/include/TFEL/Math/ST2toT2/T2toST2ST2toT2ProductExpr.hxx +++ b/include/TFEL/Math/ST2toT2/T2toST2ST2toT2ProductExpr.hxx @@ -29,10 +29,8 @@ namespace tfel::math { struct TFEL_VISIBILITY_LOCAL T2toST2ST2toT2ProductExpr { }; // end of struct T2toST2ST2toT2ProductExpr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 1D + template struct TFEL_VISIBILITY_LOCAL Expr> : public ST2toST2ConceptBase< @@ -52,12 +50,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const T2toST2Type& a, const ST2toT2Type2& b) { - //! a simple check - static_assert((implementsT2toST2Concept())); - //! a simple check - static_assert((implementsST2toT2Concept())); + template + TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, + const ST2toT2Type2& b) noexcept { //! a simple check static_assert((getSpaceDimension() == 1u)); //! a simple check @@ -77,22 +72,18 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i, const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 3 + j]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 2D + template struct TFEL_VISIBILITY_LOCAL Expr> : public ST2toST2ConceptBase< @@ -112,12 +103,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const T2toST2Type& a, const ST2toT2Type2& b) { - //! a simple check - static_assert((implementsT2toST2Concept())); - //! a simple check - static_assert((implementsST2toT2Concept())); + template + TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, + const ST2toT2Type2& b) noexcept { //! a simple check static_assert((getSpaceDimension() == 2u)); //! a simple check @@ -160,22 +148,18 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i, const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 4 + j]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 3D + template struct TFEL_VISIBILITY_LOCAL Expr> : public ST2toST2ConceptBase< @@ -195,12 +179,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const T2toST2Type& a, const ST2toT2Type2& b) { - //! a simple check - static_assert((implementsT2toST2Concept())); - //! a simple check - static_assert((implementsST2toT2Concept())); + template + TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, + const ST2toT2Type2& b) noexcept { //! a simple check static_assert((getSpaceDimension() == 3u)); //! a simple check @@ -319,14 +300,12 @@ namespace tfel::math { * \param[in] i : line index * \param[in] j : column index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i, const unsigned short j) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i, const unsigned short j) const noexcept { return this->v[i * 6 + j]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr diff --git a/include/TFEL/Math/ST2toT2/T2toT2ST2toT2ProductExpr.hxx b/include/TFEL/Math/ST2toT2/T2toT2ST2toT2ProductExpr.hxx index b2a506ac4..3b9b9885a 100644 --- a/include/TFEL/Math/ST2toT2/T2toT2ST2toT2ProductExpr.hxx +++ b/include/TFEL/Math/ST2toT2/T2toT2ST2toT2ProductExpr.hxx @@ -21,39 +21,38 @@ namespace tfel::math { - //! Empty structure used for partial specialisation of the - //! Expr class + /*! + * \brief empty structure used for partial specialisation of the + * Expr class + */ template struct TFEL_VISIBILITY_LOCAL T2toT2ST2toT2ProductExpr { }; // end of struct T2toT2ST2toT2ProductExpr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 1D + template struct TFEL_VISIBILITY_LOCAL Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder< TensorDimeToSize()>::value * StensorDimeToSize< getSpaceDimension()>::value, numeric_type> { + //! a simple check static_assert(getSpaceDimension() == 1u); //! a simple alias typedef EmptyRunTimeProperties RunTimeProperties; //! a simple alias typedef numeric_type value_type; - //! a simple check /*! * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toT2Type& a, const ST2toT2Type2& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0); @@ -81,13 +80,11 @@ namespace tfel::math { } }; // end of struct Expr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 2D + template struct TFEL_VISIBILITY_LOCAL Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder< TensorDimeToSize()>::value * @@ -103,10 +100,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toT2Type& a, const ST2toT2Type2& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + @@ -165,13 +161,11 @@ namespace tfel::math { } }; // end of struct Expr - /*! - * Partial specialisation - */ - template + //! \brief partial specialisation in 3D + template struct TFEL_VISIBILITY_LOCAL Expr> - : public ST2toT2Concept< + : public ST2toT2ConceptBase< Expr>>, public array_holder< TensorDimeToSize()>::value * @@ -188,10 +182,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toT2Type& a, const ST2toT2Type2& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + diff --git a/include/TFEL/Math/ST2toT2/TensorST2toT2ProductExpr.hxx b/include/TFEL/Math/ST2toT2/TensorST2toT2ProductExpr.hxx index f902ec5e3..2135670ef 100644 --- a/include/TFEL/Math/ST2toT2/TensorST2toT2ProductExpr.hxx +++ b/include/TFEL/Math/ST2toT2/TensorST2toT2ProductExpr.hxx @@ -22,14 +22,14 @@ namespace tfel::math { - //! Empty structure used for partial specialisation of the - //! Expr class + /*! + * \brief empty structure used for partial specialisation of the + * Expr class + */ template struct TensorST2toT2ProductExpr {}; // end of struct TensorST2toT2ProductExpr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 1D template struct Expr> : public StensorConceptBase< @@ -46,10 +46,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const TensorType& a, const ST2toT2Type& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = b(0, 0) * a(0) + b(1, 0) * a(1) + b(2, 0) * a(2); @@ -72,18 +71,13 @@ namespace tfel::math { const unsigned short i) const noexcept { return this->v[i]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_HOST_DEVICE constexpr RunTimeProperties getRunTimeProperties() const - noexcept { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 2D template struct Expr> : public StensorConceptBase< @@ -100,10 +94,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const TensorType& a, const ST2toT2Type& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = b(4, 0) * a(4) + b(3, 0) * a(3) + b(2, 0) * a(2) + @@ -131,18 +124,13 @@ namespace tfel::math { const unsigned short i) const noexcept { return this->v[i]; } // end of operator() - /*! - * \return the runtime properties - */ - TFEL_HOST_DEVICE constexpr RunTimeProperties getRunTimeProperties() const - noexcept { + //! \return the runtime properties + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr + }; // end of Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 2D template struct Expr> : public StensorConceptBase< @@ -159,10 +147,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const TensorType& a, const ST2toT2Type& b) noexcept { - static_assert(implementsST2toT2Concept()); static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = b(8, 0) * a(8) + b(7, 0) * a(7) + b(6, 0) * a(6) + @@ -200,13 +187,11 @@ namespace tfel::math { const unsigned short i) const noexcept { return this->v[i]; } // end of operator() - /*! - * \return the runtime properties - */ + //! \return the runtime properties TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } - }; // end of struct Expr + }; // end of Expr } // end of namespace tfel::math diff --git a/include/TFEL/Math/ST2toT2/st2tot2.ixx b/include/TFEL/Math/ST2toT2/st2tot2.ixx index 245064d53..052723f11 100644 --- a/include/TFEL/Math/ST2toT2/st2tot2.ixx +++ b/include/TFEL/Math/ST2toT2/st2tot2.ixx @@ -18,7 +18,6 @@ #include #include #include - #include "TFEL/FSAlgorithm/FSAlgorithm.hxx" #include "TFEL/Math/ST2toT2/StensorProductLeftDerivativeExpr.hxx" #include "TFEL/Math/ST2toT2/StensorProductRightDerivativeExpr.hxx" @@ -27,52 +26,58 @@ namespace tfel::math { template template - std::enable_if_t() == N && - isAssignableTo, T>(), - Expr, StensorProductLeftDerivativeExpr>> - st2tot2::tpld(const StensorType& b) { + TFEL_HOST_DEVICE constexpr auto + st2tot2::tpld(const StensorType& b) noexcept requires( + getSpaceDimension() == N && + isAssignableTo, T>()) { return Expr, StensorProductLeftDerivativeExpr>(b); } // end of st2tot2 template template - std::enable_if_t< - getSpaceDimension() == N && + TFEL_HOST_DEVICE constexpr auto st2tot2:: + tpld(const StensorType& b, const ST2toST2Type& C) noexcept requires( + getSpaceDimension() == N && getSpaceDimension() == N && isAssignableTo, numeric_type, OpMult>, - ValueType>(), - Expr, StensorProductLeftDerivativeExpr>> - st2tot2::tpld(const StensorType& b, const ST2toST2Type& C) { + ValueType>()) { return Expr, StensorProductLeftDerivativeExpr>(b, C); } template template - TFEL_HOST_DEVICE constexpr std::enable_if_t< + TFEL_HOST_DEVICE constexpr auto + st2tot2::tprd(const StensorType& a) noexcept requires( getSpaceDimension() == N && - isAssignableTo, T>(), - Expr, StensorProductRightDerivativeExpr>> - st2tot2::tprd(const StensorType& a) noexcept { + isAssignableTo, T>()) { return Expr, StensorProductRightDerivativeExpr>(a); } template template - TFEL_HOST_DEVICE constexpr std::enable_if_t< - getSpaceDimension() == N && + TFEL_HOST_DEVICE constexpr auto st2tot2:: + tprd(const StensorType& a, const ST2toST2Type& C) noexcept requires( + getSpaceDimension() == N && getSpaceDimension() == N && isAssignableTo, numeric_type, OpMult>, - T>(), - Expr, StensorProductRightDerivativeExpr>> - st2tot2::tprd(const StensorType& a, const ST2toST2Type& C) noexcept { + T>()) { return Expr, StensorProductRightDerivativeExpr>(a, C); } + template + TFEL_HOST_DEVICE constexpr void st2tot2::import( + const base_type* const src) noexcept { + tfel::fsalgo::transform< + TensorDimeToSize::value * + StensorDimeToSize::value>::exe(src, this->begin(), + [](const auto& v) { return T(v); }); + } // end of import + template TFEL_HOST_DEVICE constexpr void st2tot2::copy(const auto p) noexcept { tfel::fsalgo::copy::value * diff --git a/include/TFEL/Math/Stensor/stensor.ixx b/include/TFEL/Math/Stensor/stensor.ixx index 8d4a1020e..dda06605b 100644 --- a/include/TFEL/Math/Stensor/stensor.ixx +++ b/include/TFEL/Math/Stensor/stensor.ixx @@ -885,10 +885,9 @@ namespace tfel::math { } template - TFEL_HOST_DEVICE stensor(), - numeric_type> - change_basis(const StensorType& s, - const tmatrix<3u, 3u, base_type>>& r) { + TFEL_HOST_DEVICE constexpr auto change_basis( + const StensorType& s, + const tmatrix<3u, 3u, base_type>>& r) noexcept { stensor(), numeric_type> ns{s}; ns.changeBasis(r); return ns; diff --git a/include/TFEL/Math/T2toST2/LeftCauchyGreenTensorDerivativeExpr.hxx b/include/TFEL/Math/T2toST2/LeftCauchyGreenTensorDerivativeExpr.hxx index a4659a9de..565ddab85 100644 --- a/include/TFEL/Math/T2toST2/LeftCauchyGreenTensorDerivativeExpr.hxx +++ b/include/TFEL/Math/T2toST2/LeftCauchyGreenTensorDerivativeExpr.hxx @@ -34,7 +34,7 @@ namespace tfel::math { */ template struct Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder<9u, numeric_type> { static_assert(getSpaceDimension() == 1u); @@ -75,7 +75,7 @@ namespace tfel::math { */ template struct Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder<20u, numeric_type> { static_assert(getSpaceDimension() == 2u); @@ -128,7 +128,7 @@ namespace tfel::math { */ template struct Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder<54u, numeric_type> { static_assert(getSpaceDimension() == 3u); diff --git a/include/TFEL/Math/T2toST2/RightCauchyGreenTensorDerivativeExpr.hxx b/include/TFEL/Math/T2toST2/RightCauchyGreenTensorDerivativeExpr.hxx index 6acd379cb..2fbccabe9 100644 --- a/include/TFEL/Math/T2toST2/RightCauchyGreenTensorDerivativeExpr.hxx +++ b/include/TFEL/Math/T2toST2/RightCauchyGreenTensorDerivativeExpr.hxx @@ -34,7 +34,7 @@ namespace tfel::math { */ template struct Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder<9u, numeric_type> { static_assert(getSpaceDimension() == 1u); @@ -81,7 +81,7 @@ namespace tfel::math { */ template struct Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder<20u, numeric_type> { static_assert(getSpaceDimension() == 2u); @@ -139,7 +139,7 @@ namespace tfel::math { */ template struct Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder<54u, numeric_type> { static_assert(getSpaceDimension() == 3u); diff --git a/include/TFEL/Math/T2toST2/ST2toST2T2toST2ProductExpr.hxx b/include/TFEL/Math/T2toST2/ST2toST2T2toST2ProductExpr.hxx index e809b5fc0..d23e8a627 100644 --- a/include/TFEL/Math/T2toST2/ST2toST2T2toST2ProductExpr.hxx +++ b/include/TFEL/Math/T2toST2/ST2toST2T2toST2ProductExpr.hxx @@ -15,7 +15,6 @@ #define LIB_TFEL_MATH_ST2TOST2T2TOST2PRODUCTEXPR_HXX #include "TFEL/Config/TFELConfig.hxx" - #include "TFEL/Math/General/EmptyRunTimeProperties.hxx" #include "TFEL/Math/ST2toST2/ST2toST2Concept.hxx" #include "TFEL/Math/T2toST2/T2toST2Concept.hxx" @@ -31,10 +30,10 @@ namespace tfel::math { }; // end of struct ST2toST2T2toST2ProductExpr //! \brief partial specialisation in 1D - template + template struct TFEL_VISIBILITY_LOCAL Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder< StensorDimeToSize()>::value * @@ -49,10 +48,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const ST2toST2Type& a, const T2toST2Type2& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0); @@ -81,10 +79,10 @@ namespace tfel::math { }; // end of struct Expr //! \brief partial specialisation in 2D - template + template struct TFEL_VISIBILITY_LOCAL Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder< StensorDimeToSize()>::value * @@ -99,10 +97,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const ST2toST2Type& a, const T2toST2Type2& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + @@ -162,10 +159,10 @@ namespace tfel::math { }; // end of struct Expr //! \brief partial specialisation in 3D - template + template struct TFEL_VISIBILITY_LOCAL Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder< StensorDimeToSize()>::value * @@ -180,10 +177,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const ST2toST2Type& a, const T2toST2Type2& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + diff --git a/include/TFEL/Math/T2toST2/StensorT2toST2ProductExpr.hxx b/include/TFEL/Math/T2toST2/StensorT2toST2ProductExpr.hxx index 866a1cdc6..d2cd93753 100644 --- a/include/TFEL/Math/T2toST2/StensorT2toST2ProductExpr.hxx +++ b/include/TFEL/Math/T2toST2/StensorT2toST2ProductExpr.hxx @@ -21,15 +21,15 @@ namespace tfel::math { - //! Empty structure used for partial specialisation of the - //! Expr class + /*! + * \brief empty structure used for partial specialisation of the + * Expr class + */ template struct StensorT2toST2ProductExpr { }; // end of struct StensorT2toST2ProductExpr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 1D template struct Expr> : public TensorConceptBase< @@ -46,9 +46,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const StensorType& a, const T2toST2Type& b) { - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const StensorType& a, + const T2toST2Type& b) noexcept { static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = b(0, 0) * a(0) + b(1, 0) * a(1) + b(2, 0) * a(2); @@ -59,21 +59,19 @@ namespace tfel::math { * \brief access operator * \param[in] i : index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i) const noexcept { return this->v[i]; } // end of operator() /*! * \return the runtime properties */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 2D template struct Expr> : public TensorConceptBase< @@ -90,9 +88,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const StensorType& a, const T2toST2Type& b) { - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const StensorType& a, + const T2toST2Type& b) noexcept { static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = @@ -110,21 +108,19 @@ namespace tfel::math { * \brief access operator * \param[in] i : index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i) const noexcept { return this->v[i]; } // end of operator() /*! * \return the runtime properties */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 3D template struct Expr> : public TensorConceptBase< @@ -141,9 +137,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template - TFEL_MATH_INLINE Expr(const StensorType& a, const T2toST2Type& b) { - static_assert(implementsT2toST2Concept()); + template + TFEL_HOST_DEVICE constexpr Expr(const StensorType& a, + const T2toST2Type& b) noexcept { static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = b(5, 0) * a[5] + b(4, 0) * a[4] + b(3, 0) * a[3] + @@ -169,14 +165,14 @@ namespace tfel::math { * \brief access operator * \param[in] i : index */ - TFEL_MATH_INLINE const value_type& operator()( - const unsigned short i) const { + TFEL_HOST_DEVICE constexpr const value_type& operator()( + const unsigned short i) const noexcept { return this->v[i]; } // end of operator() /*! * \return the runtime properties */ - TFEL_MATH_INLINE RunTimeProperties getRunTimeProperties() const { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr diff --git a/include/TFEL/Math/T2toST2/T2toST2Concept.hxx b/include/TFEL/Math/T2toST2/T2toST2Concept.hxx index f83a1e4e4..022aee39e 100644 --- a/include/TFEL/Math/T2toST2/T2toST2Concept.hxx +++ b/include/TFEL/Math/T2toST2/T2toST2Concept.hxx @@ -32,41 +32,40 @@ namespace tfel::math { * \brief Helper class to characterise t2tost2. */ struct T2toST2Tag {}; - + /*! + * \brief an helper class that simply exposes publically a member named + * ConceptTag as an alias to T2toST2Tag. + * + * The main reason for this alias is to properly implement the `ConceptRebind` + * metafunction. + */ template - struct T2toST2Concept { - typedef T2toST2Tag ConceptTag; - - protected: - T2toST2Concept() = default; - T2toST2Concept(T2toST2Concept&&) = default; - T2toST2Concept(const T2toST2Concept&) = default; - T2toST2Concept& operator=(const T2toST2Concept&) = default; - ~T2toST2Concept() = default; + struct T2toST2ConceptBase { + using ConceptTag = T2toST2Tag; }; - /*! - * \brief an helper function which returns if the given type implements the - * `T2toST2Concept`. - * \tparam T2toST2Type: type tested + * \brief definition of the T2toST2Concept + * a class matching the stensor concept must expose the `T2toST2Tag` and have + * access operators. */ - template - TFEL_HOST_DEVICE constexpr bool implementsT2toST2Concept() { - return tfel::meta::implements(); - } // end of implementsT2toST2Concept - - //! paratial specialisation for T2toST2 + template + concept T2toST2Concept = + (std::is_same_v::ConceptTag, T2toST2Tag>)&& // + (requires(const T t, const unsigned short i, const unsigned short j) { + t(i, j); + }); + //! \brief partial specialisation for T2toST2 template struct ConceptRebind { - using type = T2toST2Concept; + using type = T2toST2ConceptBase; }; - - template - typename std::enable_if< - implementsT2toST2Concept(), - typename tfel::typetraits::AbsType>::type>::type - abs(const T2toST2Type&); - + /*! + * \return the sum of the absolute values of all components of an + * linear application transforming a symmetric tensor in an unsymmetric tensor + * \param[in] t: linear application transforming a symmetric tensor in an + * unsymmetric tensor + */ + TFEL_HOST_DEVICE constexpr void abs(const T2toST2Concept auto&) noexcept; /*! * \brief compute de derivative of the push-forward of a symmetric * second order tensor with respect to the deformation gradient, i.e. @@ -77,17 +76,16 @@ namespace tfel::math { * \param[in] : orginal tensor * \param[in] : deformation gradient */ - template - typename std::enable_if() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond && - isAssignableTo, - numeric_type>(), - void>::type + TFEL_HOST_DEVICE constexpr void computePushForwardDerivativeWithRespectToDeformationGradient( - T2toST2ResultType&, const StensorType&, const TensorType&); + T2toST2ResultType&, const StensorType&, const TensorType&) noexcept // + requires(tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond&& + isAssignableTo, + numeric_type>()); /*! * \brief compute the Cauchy stress derivative from the Kirchhoff * stress derivative with respect to the deformation gradient @@ -96,13 +94,17 @@ namespace tfel::math { * \param[in] s : Cauchy stress * \param[in] F : deformation gradient */ - template - typename std::enable_if< - implementsT2toST2Concept() && - implementsT2toST2Concept() && + TFEL_HOST_DEVICE constexpr void + computeCauchyStressDerivativeFromKirchhoffStressDerivative( + T2toST2ResultType&, + const T2toST2Type&, + const StensorType&, + const TensorType&) noexcept // + requires( getSpaceDimension() == getSpaceDimension() && getSpaceDimension() == @@ -114,12 +116,7 @@ namespace tfel::math { isAssignableTo, numeric_type, OpPlus>::Result, - numeric_type>(), - void>::type - computeCauchyStressDerivativeFromKirchhoffStressDerivative(T2toST2ResultType&, - const T2toST2Type&, - const StensorType&, - const TensorType&); + numeric_type>()); /*! * \brief compute the Kirchhoff stress derivative from the Cauchy * stress derivative with respect to the deformation gradient @@ -128,13 +125,17 @@ namespace tfel::math { * \param[in] s : Cauchy stress * \param[in] F : deformation gradient */ - template - typename std::enable_if< - implementsT2toST2Concept() && - implementsT2toST2Concept() && + TFEL_HOST_DEVICE constexpr void + computeKirchhoffStressDerivativeFromCauchyStressDerivative( + T2toST2ResultType&, + const T2toST2Type&, + const StensorType&, + const TensorType&) noexcept // + requires( getSpaceDimension() == getSpaceDimension() && getSpaceDimension() == @@ -146,12 +147,16 @@ namespace tfel::math { isAssignableTo, numeric_type, OpPlus>::Result, - numeric_type>(), - void>::type - computeKirchhoffStressDerivativeFromCauchyStressDerivative(T2toST2ResultType&, - const T2toST2Type&, - const StensorType&, - const TensorType&); + numeric_type>()); + /*! + * \brief an helper function which returns if the given type implements the + * `T2toST2Concept`. + * \tparam T2toST2Type: type tested + */ + template + [[deprecated]] TFEL_HOST_DEVICE constexpr bool implementsT2toST2Concept() { + return T2toST2Concept; + } // end of implementsT2toST2Concept } // end of namespace tfel::math diff --git a/include/TFEL/Math/T2toST2/T2toST2Concept.ixx b/include/TFEL/Math/T2toST2/T2toST2Concept.ixx index 8df41c86e..ff7094f24 100644 --- a/include/TFEL/Math/T2toST2/T2toST2Concept.ixx +++ b/include/TFEL/Math/T2toST2/T2toST2Concept.ixx @@ -20,37 +20,35 @@ namespace tfel::math { - template - typename std::enable_if< - implementsT2toST2Concept(), - typename tfel::typetraits::AbsType>::type>::type - abs(const T2toST2Type& v) { + TFEL_HOST_DEVICE constexpr auto abs(const T2toST2Concept auto& t) noexcept { + using T2toST2Type = decltype(t); using NumType = numeric_type; using AbsNumType = typename tfel::typetraits::AbsType::type; - AbsNumType a(0); + auto a = AbsNumType{}; constexpr auto ssize = StensorDimeToSize()>::value; constexpr auto tsize = TensorDimeToSize()>::value; for (unsigned short i = 0; i < ssize; ++i) { for (unsigned short j = 0; j < tsize; ++j) { - a += abs(v(i, j)); + a += abs(t(i, j)); } } return a; - } + } // end of abs - template - typename std::enable_if() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond && - isAssignableTo, - numeric_type>(), - void>::type + TFEL_HOST_DEVICE constexpr void computePushForwardDerivativeWithRespectToDeformationGradient( - T2toST2ResultType& dTdF, const StensorType& S, const TensorType& F) { + T2toST2ResultType& dTdF, + const StensorType& S, + const TensorType& F) noexcept // + requires(tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond&& + isAssignableTo, + numeric_type>()) { using value_type = numeric_type; constexpr auto N = getSpaceDimension(); static_assert(getSpaceDimension() == N); @@ -148,13 +146,17 @@ namespace tfel::math { } } // end of computePushForwardDerivativeWithRespectToDeformationGradient - template - typename std::enable_if< - implementsT2toST2Concept() && - implementsT2toST2Concept() && + TFEL_HOST_DEVICE constexpr void + computeCauchyStressDerivativeFromKirchhoffStressDerivative( + T2toST2ResultType& ds, + const T2toST2Type& dt_K, + const StensorType& s, + const TensorType& F) noexcept // + requires( getSpaceDimension() == getSpaceDimension() && getSpaceDimension() == @@ -166,25 +168,23 @@ namespace tfel::math { isAssignableTo, numeric_type, OpPlus>::Result, - numeric_type>(), - void>::type - computeCauchyStressDerivativeFromKirchhoffStressDerivative( - T2toST2ResultType& ds, - const T2toST2Type& dt_K, - const StensorType& s, - const TensorType& F) { + numeric_type>()) { const auto iJ = 1 / det(F); const auto dJ = computeDeterminantDerivative(F); ds = iJ * (dt_K - (s ^ dJ)); } - template - typename std::enable_if< - implementsT2toST2Concept() && - implementsT2toST2Concept() && + TFEL_HOST_DEVICE constexpr void + computeKirchhoffStressDerivativeFromCauchyStressDerivative( + T2toST2ResultType& dt_K, + const T2toST2Type& ds, + const StensorType& s, + const TensorType& F) noexcept // + requires( getSpaceDimension() == getSpaceDimension() && getSpaceDimension() == @@ -196,13 +196,7 @@ namespace tfel::math { isAssignableTo, numeric_type, OpPlus>::Result, - numeric_type>(), - void>::type - computeKirchhoffStressDerivativeFromCauchyStressDerivative( - T2toST2ResultType& dt_K, - const T2toST2Type& ds, - const StensorType& s, - const TensorType& F) { + numeric_type>()) { const auto J = det(F); const auto dJ = computeDeterminantDerivative(F); dt_K = J * ds + (s ^ dJ); diff --git a/include/TFEL/Math/T2toST2/T2toST2ConceptIO.hxx b/include/TFEL/Math/T2toST2/T2toST2ConceptIO.hxx index f30134a0e..83024df61 100644 --- a/include/TFEL/Math/T2toST2/T2toST2ConceptIO.hxx +++ b/include/TFEL/Math/T2toST2/T2toST2ConceptIO.hxx @@ -19,27 +19,27 @@ namespace tfel::math { - // Serialisation operator - template - std::enable_if_t(), std::ostream&> - operator<<(std::ostream& os, const T2toST2Type& s) { + //! \brief serialisation operator + TFEL_HOST std::ostream& operator<<(std::ostream& os, + const T2toST2Concept auto& t) { + using T2toST2Type = decltype(t); constexpr auto N = getSpaceDimension(); - constexpr auto stensor_size = StensorDimeToSize::value; - constexpr auto tensor_size = TensorDimeToSize::value; + constexpr auto ssize = StensorDimeToSize::value; + constexpr auto tsize = TensorDimeToSize::value; os << "["; - for (unsigned short i = 0; i < stensor_size;) { + for (unsigned short i = 0; i < ssize;) { if (i != 0) { os << " ["; } else { os << "["; } - for (unsigned short j = 0; j < tensor_size;) { - os << s(i, j); - if (++j != tensor_size) { + for (unsigned short j = 0; j < tsize;) { + os << t(i, j); + if (++j != tsize) { os << ","; } } - if (++i != stensor_size) { + if (++i != ssize) { os << "]\n"; } else { os << "]"; diff --git a/include/TFEL/Math/T2toST2/T2toST2ConceptOperations.hxx b/include/TFEL/Math/T2toST2/T2toST2ConceptOperations.hxx index 5a0149032..cfbb759af 100644 --- a/include/TFEL/Math/T2toST2/T2toST2ConceptOperations.hxx +++ b/include/TFEL/Math/T2toST2/T2toST2ConceptOperations.hxx @@ -144,14 +144,14 @@ namespace tfel::math { Expr>>; }; - template - TFEL_HOST_DEVICE constexpr auto - operator|(const StensorConcept auto& a, const T2& b) noexcept requires( - implementsT2toST2Concept() && - !isInvalid>()) { - typedef BinaryOperationHandler Handle; + TFEL_HOST_DEVICE constexpr auto operator|( + const StensorConcept auto& a, + const T2toST2Concept auto& b) noexcept // + requires(!isInvalid< + BinaryOperationResult>()) { + typedef BinaryOperationHandler Handle; return Handle(a, b); - } + } // end of operator | } // end of namespace tfel::math diff --git a/include/TFEL/Math/T2toST2/T2toST2T2toT2ProductExpr.hxx b/include/TFEL/Math/T2toST2/T2toST2T2toT2ProductExpr.hxx index 17d2da7de..88c1e222a 100644 --- a/include/TFEL/Math/T2toST2/T2toST2T2toT2ProductExpr.hxx +++ b/include/TFEL/Math/T2toST2/T2toST2T2toT2ProductExpr.hxx @@ -31,10 +31,10 @@ namespace tfel::math { }; // end of struct T2toST2T2toT2ProductExpr //! \brief partial specialisation in 1D - template + template struct TFEL_VISIBILITY_LOCAL Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder< StensorDimeToSize()>::value * @@ -49,10 +49,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, const T2toT2Type2& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0); @@ -81,10 +80,10 @@ namespace tfel::math { }; // end of struct Expr //! \brief partial specialisation in 2D - template + template struct TFEL_VISIBILITY_LOCAL Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder< StensorDimeToSize()>::value * @@ -99,10 +98,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, const T2toT2Type2& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + @@ -162,10 +160,10 @@ namespace tfel::math { }; // end of struct Expr //! \brief partial specialisation in 3D - template + template struct TFEL_VISIBILITY_LOCAL Expr> - : public T2toST2Concept< + : public T2toST2ConceptBase< Expr>>, public array_holder< StensorDimeToSize()>::value * @@ -180,10 +178,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, const T2toT2Type2& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = a(0, 0) * b(0, 0) + a(0, 1) * b(1, 0) + a(0, 2) * b(2, 0) + diff --git a/include/TFEL/Math/T2toST2/T2toST2TensorProductExpr.hxx b/include/TFEL/Math/T2toST2/T2toST2TensorProductExpr.hxx index 047fd4c72..8a75ddcb4 100644 --- a/include/TFEL/Math/T2toST2/T2toST2TensorProductExpr.hxx +++ b/include/TFEL/Math/T2toST2/T2toST2TensorProductExpr.hxx @@ -22,14 +22,14 @@ namespace tfel::math { - //! Empty structure used for partial specialisation of the - //! Expr class + /*! + * \brief empty structure used for partial specialisation of the + * Expr class + */ template struct T2toST2TensorProductExpr {}; // end of struct T2toST2TensorProductExpr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 1D template struct Expr> : public StensorConceptBase< @@ -44,10 +44,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, const TensorType& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 1u); static_assert(getSpaceDimension() == 1u); this->v[0] = a(0, 0) * b(0) + a(0, 1) * b(1) + a(0, 2) * b(2); @@ -56,6 +55,14 @@ namespace tfel::math { } // end of Expr //! using operator [] using array_holder<3u, value_type>::operator[]; + /*! + * \brief access operator + * \param[in] i : index + */ + TFEL_HOST_DEVICE constexpr const value_type& operator[]( + const unsigned short i) const noexcept { + return this->operator()(i); + } // end of operator() /*! * \brief access operator * \param[in] i : index @@ -65,15 +72,12 @@ namespace tfel::math { return this->v[i]; } // end of operator() //! \return the runtime properties - TFEL_HOST_DEVICE constexpr RunTimeProperties getRunTimeProperties() const - noexcept { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 2D template struct Expr> : public StensorConceptBase< @@ -88,10 +92,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, const TensorType& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 2u); static_assert(getSpaceDimension() == 2u); this->v[0] = a(0, 4) * b[4] + a(0, 3) * b[3] + a(0, 2) * b[2] + @@ -105,6 +108,14 @@ namespace tfel::math { } // end of Expr //! using operator [] using array_holder<4u, value_type>::operator[]; + /*! + * \brief access operator + * \param[in] i : index + */ + TFEL_HOST_DEVICE constexpr const value_type& operator[]( + const unsigned short i) const noexcept { + return this->operator()(i); + } // end of operator() /*! * \brief access operator * \param[in] i : index @@ -114,15 +125,12 @@ namespace tfel::math { return this->v[i]; } // end of operator() //! \return the runtime properties - TFEL_HOST_DEVICE constexpr RunTimeProperties getRunTimeProperties() const - noexcept { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr - /*! - * Partial specialisation - */ + //! \brief partial specialisation in 2D template struct Expr> : public StensorConceptBase< @@ -137,10 +145,9 @@ namespace tfel::math { * \param[in] a : first term of the product * \param[in] b : second term of the product */ - template + template TFEL_HOST_DEVICE constexpr Expr(const T2toST2Type& a, const TensorType& b) noexcept { - static_assert(implementsT2toST2Concept()); static_assert(getSpaceDimension() == 3u); static_assert(getSpaceDimension() == 3u); this->v[0] = a(0, 8) * b[8] + a(0, 7) * b[7] + a(0, 6) * b[6] + @@ -164,6 +171,14 @@ namespace tfel::math { } // end of Expr //! using operator [] using array_holder<6u, value_type>::operator[]; + /*! + * \brief access operator + * \param[in] i : index + */ + TFEL_HOST_DEVICE constexpr const value_type& operator[]( + const unsigned short i) const noexcept { + return this->operator()(i); + } // end of operator() /*! * \brief access operator * \param[in] i : index @@ -173,8 +188,7 @@ namespace tfel::math { return this->v[i]; } // end of operator() //! \return the runtime properties - TFEL_HOST_DEVICE constexpr RunTimeProperties getRunTimeProperties() const - noexcept { + TFEL_HOST_DEVICE constexpr auto getRunTimeProperties() const noexcept { return RunTimeProperties(); } }; // end of struct Expr diff --git a/include/TFEL/Math/T2toST2/t2tost2.ixx b/include/TFEL/Math/T2toST2/t2tost2.ixx index 8e7be7f25..23a3f4ebb 100644 --- a/include/TFEL/Math/T2toST2/t2tost2.ixx +++ b/include/TFEL/Math/T2toST2/t2tost2.ixx @@ -28,30 +28,37 @@ namespace tfel::math { template template - TFEL_HOST_DEVICE std::enable_if_t< + TFEL_HOST_DEVICE constexpr auto + t2tost2::dCdF(const TensorType& F) noexcept requires( getSpaceDimension() == N && - isAssignableTo, T>(), - Expr, RightCauchyGreenTensorDerivativeExpr>> - t2tost2::dCdF(const TensorType& F) { + isAssignableTo, T>()) { return Expr, RightCauchyGreenTensorDerivativeExpr>(F); } // end of t2tost2::dCdF template template - TFEL_HOST_DEVICE std::enable_if_t< + TFEL_HOST_DEVICE constexpr auto + t2tost2::dBdF(const TensorType& F) noexcept requires( getSpaceDimension() == N && - isAssignableTo, T>(), - Expr, LeftCauchyGreenTensorDerivativeExpr>> - t2tost2::dBdF(const TensorType& F) { + isAssignableTo, T>()) { return Expr, LeftCauchyGreenTensorDerivativeExpr>(F); } // end of t2tost2::dBdF template - template - TFEL_HOST_DEVICE void t2tost2::copy(const InputIterator src) { + TFEL_HOST_DEVICE constexpr void t2tost2::import( + const base_type* const src) noexcept { + tfel::fsalgo::transform::value * + TensorDimeToSize::value>::exe(src, this->begin(), + [](const auto& v) { + return T(v); + }); + } // end of import + + template + TFEL_HOST_DEVICE constexpr void t2tost2::copy(const auto p) noexcept { tfel::fsalgo::copy::value * - TensorDimeToSize::value>::exe(src, *this); - } + TensorDimeToSize::value>::exe(p, *this); + } // end of copy TFEL_HOST_DEVICE constexpr auto convertToT2toST2( const T2toT2Concept auto& t) noexcept { @@ -195,22 +202,20 @@ namespace tfel::math { } } - template - TFEL_HOST_DEVICE std::enable_if_t< - implementsT2toST2Concept() && - getSpaceDimension() == - getSpaceDimension() && - getSpaceDimension() == getSpaceDimension() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond, - t2tost2(), - typename ComputeBinaryResult, - numeric_type, - OpPlus>::Result>> + TFEL_HOST_DEVICE constexpr auto computeCauchyStressDerivativeFromKirchhoffStressDerivative( - const T2toST2Type& dt, const StensorType& s, const TensorType& F) { + const T2toST2Type& dt, + const StensorType& s, + const TensorType& F) noexcept // + requires(getSpaceDimension() == + getSpaceDimension() && + getSpaceDimension() == + getSpaceDimension() && + tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond) { using stress = typename ComputeBinaryResult, numeric_type, OpPlus>::Result; @@ -219,22 +224,20 @@ namespace tfel::math { return r; } - template - TFEL_HOST_DEVICE std::enable_if_t< - implementsT2toST2Concept() && - getSpaceDimension() == - getSpaceDimension() && - getSpaceDimension() == getSpaceDimension() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond, - t2tost2(), - typename ComputeBinaryResult, - numeric_type, - OpPlus>::Result>> + TFEL_HOST_DEVICE constexpr auto computeKirchhoffStressDerivativeFromCauchyStressDerivative( - const T2toST2Type& ds, const StensorType& s, const TensorType& F) { + const T2toST2Type& ds, + const StensorType& s, + const TensorType& F) noexcept // + requires(getSpaceDimension() == + getSpaceDimension() && + getSpaceDimension() == + getSpaceDimension() && + tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond) { using stress = typename ComputeBinaryResult, numeric_type, OpPlus>::Result; @@ -243,24 +246,43 @@ namespace tfel::math { return r; } - template + TFEL_HOST_DEVICE constexpr auto computePushForwardDerivative( + const T2toST2Type& K, + const StensorType& S, + const TensorType& F) noexcept // + requires(getSpaceDimension() == + getSpaceDimension() && + getSpaceDimension() == + getSpaceDimension() && + tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond) { + using stress = + typename ComputeBinaryResult, + numeric_type, OpPlus>::Result; + t2tost2(), stress> r; + computePushForwardDerivative(r, K, S, F); + return r; + } + + template - TFEL_HOST_DEVICE typename std::enable_if< - implementsT2toST2Concept() && - implementsT2toST2Concept() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond && - isAssignableTo, - numeric_type, - OpPlus>::Result, - numeric_type>(), - void>::type - computePushForwardDerivative(T2toST2ResultType& dT_dF, - const T2toST2Type& dS_dF, - const StensorType& S, - const TensorType& F) { + TFEL_HOST_DEVICE constexpr void computePushForwardDerivative( + T2toST2ResultType& dT_dF, + const T2toST2Type& dS_dF, + const StensorType& S, + const TensorType& F) noexcept // + requires(tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond&& + isAssignableTo< + typename ComputeBinaryResult, + numeric_type, + OpPlus>::Result, + numeric_type>()) { constexpr auto N = getSpaceDimension(); static_assert(getSpaceDimension() == N); static_assert(getSpaceDimension() == N); @@ -274,55 +296,21 @@ namespace tfel::math { dT_dF = d1 + d2 * dS_dF; } // end of computePushForwardDerivative - template - TFEL_HOST_DEVICE std::enable_if_t< - implementsT2toST2Concept() && - getSpaceDimension() == - getSpaceDimension() && - getSpaceDimension() == getSpaceDimension() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond, - t2tost2(), - typename ComputeBinaryResult, - numeric_type, - OpPlus>::Result>> - computePushForwardDerivative(const T2toST2Type& K, - const StensorType& S, - const TensorType& F) { - using stress = - typename ComputeBinaryResult, - numeric_type, OpPlus>::Result; - t2tost2(), stress> r; - computePushForwardDerivative(r, K, S, F); - return r; - } - - template - TFEL_HOST_DEVICE - std::enable_if_t<((implementsT2toST2Concept()) && - (getSpaceDimension() == 1u)), - t2tost2<1u, numeric_type>> - change_basis(const T2toST2Type& s, - const rotation_matrix>&) { - return s; - } // end of change_basis - - template - TFEL_HOST_DEVICE std::enable_if_t< - ((implementsT2toST2Concept()) && - (getSpaceDimension() != 1u)), - t2tost2(), numeric_type>> - change_basis(const T2toST2Type& s, - const rotation_matrix>& r) { + template + TFEL_HOST_DEVICE constexpr auto change_basis( + const T2toST2Type& s, + const rotation_matrix>& r) noexcept { constexpr auto N = getSpaceDimension(); - using t2tot2 = tfel::math::t2tot2>; - using st2tost2 = tfel::math::st2tost2>; - const auto sr = st2tost2::fromRotationMatrix(r); - const auto sir = t2tot2::fromRotationMatrix(transpose(r)); - return sr * s * sir; - return s; + using Result = t2tost2>; + if constexpr (N == 1) { + return Result{s}; + } else { + using t2tot2 = tfel::math::t2tot2>; + using st2tost2 = tfel::math::st2tost2>; + const auto sr = st2tost2::fromRotationMatrix(r); + const auto sir = t2tot2::fromRotationMatrix(transpose(r)); + return Result{sr * s * sir}; + } } // end of change_basis } // end of namespace tfel::math diff --git a/include/TFEL/Math/T2toT2/T2toT2Concept.hxx b/include/TFEL/Math/T2toT2/T2toT2Concept.hxx index 6bf517bf9..2d78dc0bf 100644 --- a/include/TFEL/Math/T2toT2/T2toT2Concept.hxx +++ b/include/TFEL/Math/T2toT2/T2toT2Concept.hxx @@ -32,7 +32,7 @@ namespace tfel::math { struct T2toT2Tag {}; /*! * \brief an helper class that simply exposes publically a member named - * ConceptTag as an alias to ST2toST2Tag. + * ConceptTag as an alias to T2toT2Tag. * * The main reason for this alias is to properly implement the `ConceptRebind` * metafunction. @@ -42,9 +42,10 @@ namespace tfel::math { using ConceptTag = T2toT2Tag; }; /*! - * \brief definition of the ST2toST2Concept - * a class matching the stensor concept must expose the `ST2toST2Tag` and have - * access operators. + * \brief definition of the T2toT2Concept + * + * A class matching this concept must expose the `T2toT2Tag` and have + * appropriate access operators. */ template concept T2toT2Concept = diff --git a/include/TFEL/Math/T2toT2/t2tot2.ixx b/include/TFEL/Math/T2toT2/t2tot2.ixx index 84871847f..f6833f9c3 100644 --- a/include/TFEL/Math/T2toT2/t2tot2.ixx +++ b/include/TFEL/Math/T2toT2/t2tot2.ixx @@ -361,15 +361,22 @@ namespace tfel::math { } // end of K template - template < - typename T2toST2Type, - std::enable_if_t<((implementsT2toST2Concept()) && - (isAssignableTo, T>()) && - (getSpaceDimension() == N)), - bool>> - constexpr t2tot2::t2tot2(const T2toST2Type& s) { + template + constexpr t2tot2::t2tot2(const T2toST2Type& s) noexcept requires( + (isAssignableTo, T>()) && + (getSpaceDimension() == N)) { convert(*this, s); - } // end of t2tot2::t2tot2 + } // end of t2tot2 + + template + TFEL_HOST_DEVICE constexpr void t2tot2::import( + const base_type* const src) noexcept { + tfel::fsalgo::transform::value * + TensorDimeToSize::value>::exe(src, this->begin(), + [](const auto& v) { + return T(v); + }); + } // end of import template TFEL_HOST_DEVICE constexpr void t2tot2::copy(const auto p) noexcept { @@ -447,13 +454,11 @@ namespace tfel::math { } } // end of computeDeterminantSecondDerivative - template - TFEL_HOST_DEVICE - std::enable_if_t<((implementsT2toST2Concept()) && - (isAssignableTo, T>())), - void> - convert(t2tot2(), T>& d, - const T2toST2Type& s) { + template + TFEL_HOST_DEVICE constexpr void convert( + t2tot2(), T>& d, + const T2toST2Type& s) noexcept // + requires(isAssignableTo, T>()) { constexpr auto N = getSpaceDimension(); static_assert((N == 1) || (N == 2) || (N == 3)); if constexpr (N == 1) { diff --git a/include/TFEL/Math/Tensor/tensor.ixx b/include/TFEL/Math/Tensor/tensor.ixx index 7c4b80a63..31b9ae272 100644 --- a/include/TFEL/Math/Tensor/tensor.ixx +++ b/include/TFEL/Math/Tensor/tensor.ixx @@ -137,9 +137,9 @@ namespace tfel::math { tfel::fsalgo::copy::value>::exe(p, *this); } // end of copy - template - TFEL_HOST_DEVICE TFEL_MATH_INLINE2 std::enable_if_t(), void> - exportToBaseTypeArray(const tensor& t, OutputIterator p) { + template + TFEL_HOST_DEVICE constexpr void exportToBaseTypeArray( + const tensor& t, const auto p) noexcept requires(isScalar()) { tfel::fsalgo::transform::value>::exe( t.cbegin(), p, [](const auto& v) { return base_type_cast(v); }); } diff --git a/include/TFEL/Math/st2tost2.hxx b/include/TFEL/Math/st2tost2.hxx index 8932c8397..4a7e42c83 100644 --- a/include/TFEL/Math/st2tost2.hxx +++ b/include/TFEL/Math/st2tost2.hxx @@ -147,19 +147,17 @@ namespace tfel::math { * convert a T2toST2 to a ST2toST2 * \param[in] src : T2toST2 to be converted */ - template - static TFEL_MATH_INLINE std::enable_if_t< - implementsT2toST2Concept() && - getSpaceDimension() == N && - isAssignableTo, ValueType>(), - Expr, ConvertT2toST2ToST2toST2Expr>> - convert(const T2toST2Type&); + template + TFEL_HOST_DEVICE static constexpr auto + convert(const T2toST2Type&) noexcept requires( + getSpaceDimension() == N && + isAssignableTo, ValueType>()); /*! * build the equivalent st2tost2 from a rotation matrix * \param[in] r : rotation matrix */ - static tfel::math::st2tost2> fromRotationMatrix( - const rotation_matrix&); + TFEL_HOST_DEVICE static constexpr auto fromRotationMatrix( + const rotation_matrix&) noexcept; /*! * \brief compute the derivative of the symmetric tensor product: * \f[ @@ -168,11 +166,10 @@ namespace tfel::math { * \param[in] s: second tensor of the product */ template - static TFEL_MATH_INLINE std::enable_if_t< + TFEL_HOST_DEVICE static constexpr auto + stpd(const StensorType&) noexcept requires( getSpaceDimension() == N && - isAssignableTo, ValueType>(), - tfel::math::st2tost2> - stpd(const StensorType&); + isAssignableTo, ValueType>()); // static constexpr st2tost2 Id() noexcept; static constexpr st2tost2 IxI() noexcept; @@ -216,16 +213,14 @@ namespace tfel::math { * \param[in] r : rotation matrix */ template - TFEL_HOST_DEVICE constexpr st2tost2(), - numeric_type> - change_basis(const ST2toST2Type&, - const rotation_matrix>&) noexcept; + TFEL_HOST_DEVICE constexpr auto change_basis( + const ST2toST2Type&, + const rotation_matrix>&) noexcept; /*! * \return the invert of a st2tost2 * \param[in] s : st2tost2 to be inverted */ TFEL_HOST constexpr auto invert(const ST2toST2Concept auto&); - /*! * \return the push-forward of a fourth order tensor: * \f[ diff --git a/include/TFEL/Math/st2tot2.hxx b/include/TFEL/Math/st2tot2.hxx index d0deb0937..0209475ca 100644 --- a/include/TFEL/Math/st2tot2.hxx +++ b/include/TFEL/Math/st2tot2.hxx @@ -39,13 +39,11 @@ namespace tfel::math { * \brief partial specialisation of the `DerivativeTypeDispatcher` * metafunction. */ - template + template struct DerivativeTypeDispatcher { - static_assert(implementsST2toT2Concept(), - "template argument ST2toT2Type is not a st2tot2"); static_assert(isScalar(), "template argument ScalarType is not a scalar"); static_assert(isScalar>(), @@ -59,13 +57,11 @@ namespace tfel::math { * \brief partial specialisation of the `DerivativeTypeDispatcher` * metafunction. */ - template + template struct DerivativeTypeDispatcher { - static_assert(implementsST2toT2Concept(), - "template argument ST2toT2Type is not a st2tot2"); static_assert(isScalar(), "template argument ScalarType is not a scalar"); static_assert(isScalar>(), @@ -100,7 +96,7 @@ namespace tfel::math { template struct st2tot2 - : ST2toT2Concept>, + : ST2toT2ConceptBase>, GenericFixedSizeArray< st2tot2, FixedSizeRowMajorMatrixPolicy::value, @@ -118,51 +114,47 @@ namespace tfel::math { * \return the left part of the derivative of a tensor product */ template - static TFEL_MATH_INLINE std::enable_if_t< + static TFEL_HOST_DEVICE constexpr auto + tpld(const StensorType&) noexcept requires( getSpaceDimension() == N && - isAssignableTo, ValueType>(), - Expr, StensorProductLeftDerivativeExpr>> - tpld(const StensorType&); + isAssignableTo, ValueType>()); /*! * \param[in] B : second tensor of the product * \param[in] C : derivative of the first tensor * \return the left part of the derivative of a tensor product */ template - static TFEL_MATH_INLINE std::enable_if_t< + static TFEL_HOST_DEVICE constexpr auto + tpld(const StensorType&, const ST2toST2Type&) noexcept requires( getSpaceDimension() == N && - getSpaceDimension() == N && - isAssignableTo, - numeric_type, - OpMult>, - ValueType>(), - Expr, StensorProductLeftDerivativeExpr>> - tpld(const StensorType&, const ST2toST2Type&); + getSpaceDimension() == N && + isAssignableTo, + numeric_type, + OpMult>, + ValueType>()); /*! * \param[in] A : first tensor of the product * \return the right part of the derivative of a tensor product */ template - TFEL_HOST_DEVICE static constexpr std::enable_if_t< + TFEL_HOST_DEVICE static constexpr auto + tprd(const StensorType&) noexcept requires( getSpaceDimension() == N && - isAssignableTo, ValueType>(), - Expr, StensorProductRightDerivativeExpr>> - tprd(const StensorType&) noexcept; + isAssignableTo, ValueType>()); /*! * \param[in] A : first tensor of the product * \param[in] C : derivative of the first tensor * \return the right part of the derivative of a tensor product */ template - TFEL_HOST_DEVICE static constexpr std::enable_if_t< + TFEL_HOST_DEVICE static constexpr auto + tprd(const StensorType&, const ST2toST2Type&) noexcept requires( getSpaceDimension() == N && - getSpaceDimension() == N && - isAssignableTo, - numeric_type, - OpMult>, - ValueType>(), - Expr, StensorProductRightDerivativeExpr>> - tprd(const StensorType&, const ST2toST2Type&) noexcept; + getSpaceDimension() == N && + isAssignableTo, + numeric_type, + OpMult>, + ValueType>()); // TFEL_MATH_FIXED_SIZE_ARRAY_DEFAULT_METHODS(st2tot2, GenericFixedSizeArrayBase); @@ -170,8 +162,9 @@ namespace tfel::math { using GenericFixedSizeArrayBase::operator[]; using GenericFixedSizeArrayBase::operator(); //! \brief import values from an external memory location - void import(const base_type* const); - // + TFEL_HOST_DEVICE constexpr void import( + const base_type* const) noexcept; + //! \brief copy from a range TFEL_HOST_DEVICE constexpr void copy(const auto) noexcept; }; diff --git a/include/TFEL/Math/stensor.hxx b/include/TFEL/Math/stensor.hxx index 01010f0e5..83e294ec1 100644 --- a/include/TFEL/Math/stensor.hxx +++ b/include/TFEL/Math/stensor.hxx @@ -767,10 +767,9 @@ namespace tfel::math { * \return the rotated symmetric tensor */ template - TFEL_HOST_DEVICE TFEL_MATH_INLINE2 - stensor(), numeric_type> - change_basis(const StensorType&, - const rotation_matrix>&); + TFEL_HOST_DEVICE constexpr auto change_basis( + const StensorType&, + const rotation_matrix>&) noexcept; /*! * \return the inverse of a symmetric tensor * \param[in] s: symmetric tensor diff --git a/include/TFEL/Math/t2tost2.hxx b/include/TFEL/Math/t2tost2.hxx index c12120ebb..c6b226fdb 100644 --- a/include/TFEL/Math/t2tost2.hxx +++ b/include/TFEL/Math/t2tost2.hxx @@ -46,13 +46,11 @@ namespace tfel::math { * \brief partial specialisation of the `DerivativeTypeDispatcher` * metafunction. */ - template + template struct DerivativeTypeDispatcher { - static_assert(implementsT2toST2Concept(), - "template argument T2toST2Type is not a t2tost2"); static_assert(isScalar(), "template argument ScalarType is not a scalar"); static_assert(isScalar>(), @@ -66,13 +64,11 @@ namespace tfel::math { * \brief partial specialisation of the `DerivativeTypeDispatcher` * metafunction. */ - template + template struct DerivativeTypeDispatcher { - static_assert(implementsT2toST2Concept(), - "template argument T2toST2Type is not a t2tost2"); static_assert(isScalar(), "template argument ScalarType is not a scalar"); static_assert(isScalar>(), @@ -107,7 +103,7 @@ namespace tfel::math { // template struct t2tost2 - : T2toST2Concept>, + : T2toST2ConceptBase>, GenericFixedSizeArray< t2tost2, FixedSizeRowMajorMatrixPolicy::value, @@ -126,22 +122,20 @@ namespace tfel::math { * with respect to the deformation gradient */ template - TFEL_HOST_DEVICE static TFEL_MATH_INLINE std::enable_if_t< + TFEL_HOST_DEVICE static TFEL_HOST_DEVICE constexpr auto + dCdF(const TensorType&) noexcept requires( getSpaceDimension() == N && - isAssignableTo, ValueType>(), - Expr, RightCauchyGreenTensorDerivativeExpr>> - dCdF(const TensorType&); + isAssignableTo, ValueType>()); /*! * \param[in] F : deformation gradient * \return the derivative of the Cauchy left symmetric tensor * with respect to the deformation gradient */ template - TFEL_HOST_DEVICE static TFEL_MATH_INLINE std::enable_if_t< + TFEL_HOST_DEVICE static TFEL_HOST_DEVICE constexpr auto + dBdF(const TensorType&) noexcept requires( getSpaceDimension() == N && - isAssignableTo, ValueType>(), - Expr, LeftCauchyGreenTensorDerivativeExpr>> - dBdF(const TensorType&); + isAssignableTo, ValueType>()); // TFEL_MATH_FIXED_SIZE_ARRAY_DEFAULT_METHODS(t2tost2, GenericFixedSizeArrayBase); @@ -149,13 +143,10 @@ namespace tfel::math { using GenericFixedSizeArrayBase::operator[]; using GenericFixedSizeArrayBase::operator(); //! \brief import values - template - TFEL_HOST_DEVICE - std::enable_if_t>, void> - import(const T2* const); - - template - TFEL_HOST_DEVICE TFEL_MATH_INLINE2 void copy(const InputIterator src); + TFEL_HOST_DEVICE constexpr void import( + const base_type* const) noexcept; + //! \brief copy from a range + TFEL_HOST_DEVICE constexpr void copy(const auto) noexcept; }; /*! @@ -174,30 +165,14 @@ namespace tfel::math { using ConstT2toST2View = ConstView>; /*! - * \return change the basis of a 1D t2tost2 - * \param[in] s: t2tost2 - * \param[in] r: rotation matrix - */ - template - TFEL_HOST_DEVICE - std::enable_if_t<((implementsT2toST2Concept()) && - (getSpaceDimension() == 1u)), - t2tost2<1u, numeric_type>> - change_basis(const T2toST2Type&, - const rotation_matrix>&); - /*! - * \return change the basis of a 2D or 3D t2tost2 + * \return change the basis of a t2tost2 * \param[in] s: t2tost2 * \param[in] r: rotation matrix */ - template - TFEL_HOST_DEVICE std::enable_if_t< - ((implementsT2toST2Concept()) && - (getSpaceDimension() != 1u)), - t2tost2(), numeric_type>> - change_basis(const T2toST2Type& s, - const rotation_matrix>&); - + template + TFEL_HOST_DEVICE constexpr auto change_basis( + const T2toST2Type&, + const rotation_matrix>&) noexcept; /*! * \brief convert a t2tot2 tensor to a t2tost2 * \param[in] t: fourth order tensor to be converted @@ -219,23 +194,20 @@ namespace tfel::math { * \param[in] s: Cauchy stress * \param[in] F: deformation gradient */ - template - TFEL_HOST_DEVICE std::enable_if_t< - implementsT2toST2Concept() && - getSpaceDimension() == - getSpaceDimension() && - getSpaceDimension() == getSpaceDimension() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond, - t2tost2(), - typename ComputeBinaryResult, - numeric_type, - OpPlus>::Result>> - computeCauchyStressDerivativeFromKirchhoffStressDerivative(const T2toST2Type&, - const StensorType&, - const TensorType&); + TFEL_HOST_DEVICE constexpr auto + computeCauchyStressDerivativeFromKirchhoffStressDerivative( + const T2toST2Type&, + const StensorType&, + const TensorType&) noexcept // + requires(getSpaceDimension() == + getSpaceDimension() && + getSpaceDimension() == + getSpaceDimension() && + tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond); /*! * \brief compute the Cauchy stress derivative from the Kirchhoff stress * derivative @@ -243,23 +215,20 @@ namespace tfel::math { * \param[in] s: Cauchy stress * \param[in] F: deformation gradient */ - template - TFEL_HOST_DEVICE std::enable_if_t< - implementsT2toST2Concept() && - getSpaceDimension() == - getSpaceDimension() && - getSpaceDimension() == getSpaceDimension() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond, - t2tost2(), - typename ComputeBinaryResult, - numeric_type, - OpPlus>::Result>> - computeKirchhoffStressDerivativeFromCauchyStressDerivative(const T2toST2Type&, - const StensorType&, - const TensorType&); + TFEL_HOST_DEVICE constexpr auto + computeKirchhoffStressDerivativeFromCauchyStressDerivative( + const T2toST2Type&, + const StensorType&, + const TensorType&) noexcept // + requires(getSpaceDimension() == + getSpaceDimension() && + getSpaceDimension() == + getSpaceDimension() && + tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond); /*! * \return the derivative of the push-forward of a symmetric * second order tensor with respect to the deformation gradient @@ -274,23 +243,19 @@ namespace tfel::math { * \param[in] : orginal tensor (second Piola-Kirschoff stress) * \param[in] : deformation gradient */ - template - TFEL_HOST_DEVICE std::enable_if_t< - implementsT2toST2Concept() && - getSpaceDimension() == - getSpaceDimension() && - getSpaceDimension() == getSpaceDimension() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond, - t2tost2(), - typename ComputeBinaryResult, - numeric_type, - OpPlus>::Result>> - computePushForwardDerivative(const T2toST2Type&, - const StensorType&, - const TensorType&); + TFEL_HOST_DEVICE constexpr auto computePushForwardDerivative( + const T2toST2Type&, + const StensorType&, + const TensorType&) noexcept // + requires(getSpaceDimension() == + getSpaceDimension() && + getSpaceDimension() == + getSpaceDimension() && + tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond); /*! * \brief compute de derivative of the push-forward of a symmetric * second order tensor with respect to the deformation gradient @@ -306,24 +271,22 @@ namespace tfel::math { * \param[in] : orginal tensor (second Piola-Kirschoff stress) * \param[in] : deformation gradient */ - template - TFEL_HOST_DEVICE typename std::enable_if< - implementsT2toST2Concept() && - implementsT2toST2Concept() && - tfel::typetraits::IsFundamentalNumericType< - numeric_type>::cond && - isAssignableTo, - numeric_type, - OpPlus>::Result, - numeric_type>(), - void>::type - computePushForwardDerivative(T2toST2ResultType&, - const T2toST2Type&, - const StensorType&, - const TensorType&); + TFEL_HOST_DEVICE constexpr void computePushForwardDerivative( + T2toST2ResultType&, + const T2toST2Type&, + const StensorType&, + const TensorType&) noexcept // + requires(tfel::typetraits::IsFundamentalNumericType< + numeric_type>::cond&& + isAssignableTo< + typename ComputeBinaryResult, + numeric_type, + OpPlus>::Result, + numeric_type>()); } // end of namespace tfel::math diff --git a/include/TFEL/Math/t2tot2.hxx b/include/TFEL/Math/t2tot2.hxx index a060dfefa..514a05875 100644 --- a/include/TFEL/Math/t2tot2.hxx +++ b/include/TFEL/Math/t2tot2.hxx @@ -184,20 +184,20 @@ namespace tfel::math { * \brief constructor from a t2tost2 * \param[in] v : values */ - template ()) && - (isAssignableTo, ValueType>()) && - (getSpaceDimension() == N)), - bool> = true> - TFEL_HOST_DEVICE constexpr t2tot2(const T2toST2Type&); + template + TFEL_HOST_DEVICE constexpr t2tot2(const T2toST2Type&) noexcept requires( + (isAssignableTo, ValueType>()) && + (getSpaceDimension() == N)); // TFEL_MATH_FIXED_SIZE_ARRAY_DEFAULT_METHODS(t2tot2, GenericFixedSizeArrayBase); //! exposing GenericFixedSizeArray access operator using GenericFixedSizeArrayBase::operator[]; using GenericFixedSizeArrayBase::operator(); - + //! \brief import values from an external memory location + TFEL_HOST_DEVICE constexpr void import( + const base_type* const) noexcept; + //! \brief copy from a range TFEL_HOST_DEVICE constexpr void copy(const auto) noexcept; }; @@ -225,7 +225,6 @@ namespace tfel::math { TFEL_HOST_DEVICE constexpr auto change_basis( const T2toT2Type&, const rotation_matrix>&) noexcept; - /*! * \return compute the derivative of the velocity gradient * \param[in] F: deformation gradient @@ -248,12 +247,11 @@ namespace tfel::math { computeDeterminantSecondDerivative(const TensorType&) noexcept requires( isScalar>()); - template - TFEL_HOST_DEVICE - std::enable_if_t<((implementsT2toST2Concept()) && - (isAssignableTo, T>())), - void> - convert(t2tot2(), T>&, const T2toST2Type&); + template + TFEL_HOST_DEVICE constexpr void convert( + t2tot2(), T>&, + const T2toST2Type&) noexcept // + requires(isAssignableTo, T>()); } // end of namespace tfel::math diff --git a/include/TFEL/Math/tensor.hxx b/include/TFEL/Math/tensor.hxx index 25f0fc30a..912185579 100644 --- a/include/TFEL/Math/tensor.hxx +++ b/include/TFEL/Math/tensor.hxx @@ -158,9 +158,9 @@ namespace tfel::math { template using ConstTensorView = ConstView>; - template - TFEL_HOST_DEVICE TFEL_MATH_INLINE2 std::enable_if_t(), void> - exportToBaseTypeArray(const tensor&, OutputIterator); + template + TFEL_HOST_DEVICE constexpr void exportToBaseTypeArray( + const tensor&, const auto) noexcept requires(isScalar()); /*! * \return the invert of a tensor * \param[in] t : tensor to be inverted