Permalink
Browse files

Merge pull request #12614 from lindsayad/rank-four-tensor-ops

Move operator*(const Scalar & scalar) into header for RankFourTensor
  • Loading branch information...
lindsayad committed Dec 15, 2018
2 parents f63fad3 + 3bf6469 commit bd7c23f5360ef2a409533097255d67c9fef5de31
Showing with 28 additions and 38 deletions.
  1. +28 −0 framework/include/utils/RankFourTensor.h
  2. +0 −38 framework/src/utils/RankFourTensor.C
@@ -426,6 +426,34 @@ RankFourTensorTempl<T>::RankFourTensorTempl(const RankFourTensorTempl<T2> & copy
_vals[i] = copy._vals[i];
}

template <typename T>
template <typename T2>
auto RankFourTensorTempl<T>::operator*(const T2 & b) const ->
typename std::enable_if<ScalarTraits<T2>::value,
RankFourTensorTempl<decltype(T() * T2())>>::type
{
typedef decltype(T() * T2()) ValueType;
RankFourTensorTempl<ValueType> result;

for (unsigned int i = 0; i < N4; ++i)
result._vals[i] = _vals[i] * b;

return result;
}

template <typename T>
template <typename T2>
auto
RankFourTensorTempl<T>::operator/(const T2 & b) const ->
typename std::enable_if<ScalarTraits<T2>::value,
RankFourTensorTempl<decltype(T() / T2())>>::type
{
RankFourTensorTempl<decltype(T() / T2())> result;
for (unsigned int i = 0; i < N4; ++i)
result._vals[i] = _vals[i] / b;
return result;
}

typedef RankFourTensorTempl<Real> RankFourTensor;
typedef RankFourTensorTempl<ADReal> ADRankFourTensor;

@@ -136,21 +136,6 @@ auto RankFourTensorTempl<T>::operator*(const Tensor<T2> & b) const ->
return result;
}

template <typename T>
template <typename T2>
auto RankFourTensorTempl<T>::operator*(const T2 & b) const ->
typename std::enable_if<ScalarTraits<T2>::value,
RankFourTensorTempl<decltype(T() * T2())>>::type
{
typedef decltype(T() * T2()) ValueType;
RankFourTensorTempl<ValueType> result;

for (unsigned int i = 0; i < N4; ++i)
result._vals[i] = _vals[i] * b;

return result;
}

template <typename T>
RankFourTensorTempl<T> &
RankFourTensorTempl<T>::operator*=(const T & a)
@@ -160,19 +145,6 @@ RankFourTensorTempl<T>::operator*=(const T & a)
return *this;
}

template <typename T>
template <typename T2>
auto
RankFourTensorTempl<T>::operator/(const T2 & b) const ->
typename std::enable_if<ScalarTraits<T2>::value,
RankFourTensorTempl<decltype(T() / T2())>>::type
{
RankFourTensorTempl<decltype(T() / T2())> result;
for (unsigned int i = 0; i < N4; ++i)
result._vals[i] = _vals[i] / b;
return result;
}

template <typename T>
RankFourTensorTempl<T> &
RankFourTensorTempl<T>::operator/=(const T & a)
@@ -951,16 +923,6 @@ RankTwoTensorMultInstantiate(RankTwoTensorTempl);
RankTwoTensorMultInstantiate(TensorValue);
RankTwoTensorMultInstantiate(TypeTensor);

template RankFourTensorTempl<Real> RankFourTensorTempl<Real>::operator*(const Real & a) const;
template RankFourTensorTempl<ADReal> RankFourTensorTempl<ADReal>::operator*(const Real & a) const;
template RankFourTensorTempl<ADReal> RankFourTensorTempl<Real>::operator*(const ADReal & a) const;
template RankFourTensorTempl<ADReal> RankFourTensorTempl<ADReal>::operator*(const ADReal & a) const;

template RankFourTensorTempl<Real> RankFourTensorTempl<Real>::operator/(const Real & a) const;
template RankFourTensorTempl<ADReal> RankFourTensorTempl<ADReal>::operator/(const Real & a) const;
template RankFourTensorTempl<ADReal> RankFourTensorTempl<Real>::operator/(const ADReal & a) const;
template RankFourTensorTempl<ADReal> RankFourTensorTempl<ADReal>::operator/(const ADReal & a) const;

template RankFourTensorTempl<Real> RankFourTensorTempl<Real>::
operator+(const RankFourTensorTempl<Real> & a) const;
template RankFourTensorTempl<ADReal> RankFourTensorTempl<ADReal>::

0 comments on commit bd7c23f

Please sign in to comment.