21  template <
bool strainlike = false>
 
   22  struct VectorizeWithVoigt
 
   24    template <
typename Derived>
 
   25    static auto transform(
const Eigen::DenseBase<Derived>& mat) {
 
   26      return toVoigt(mat.derived(), strainlike);
 
   30  struct VectorizeGeneric
 
   32    template <
typename Derived>
 
   33    static auto transform(
const Eigen::DenseBase<Derived>& mat) {
 
   34      return mat.derived().reshaped().eval();
 
   38  template <
bool strainlike = false>
 
   39  struct MatricizeWithVoigt
 
   41    template <
typename Derived, 
int RowsAtCompileTime, 
int ColsAtCompileTime>
 
   42    static auto transform(
const Eigen::DenseBase<Derived>& vec, 
int rows = RowsAtCompileTime,
 
   43                          int cols = ColsAtCompileTime) {
 
   44      assert(rows == RowsAtCompileTime && cols == ColsAtCompileTime &&
 
   45             "Only the fixed size values work for voigt matrices and vectors");
 
   46      static_assert(RowsAtCompileTime != Eigen::Dynamic and ColsAtCompileTime != Eigen::Dynamic,
 
   47                    "Voigt notation only available for fixed size vectors and matrices");
 
   48      return fromVoigt(vec.derived(), strainlike);
 
   52  struct MatricizeGeneric
 
   54    template <
typename Derived, 
int RowsAtCompileTime, 
int ColsAtCompileTime>
 
   55    static auto transform(
const Eigen::DenseBase<Derived>& vec, 
int rows = RowsAtCompileTime,
 
   56                          int cols = ColsAtCompileTime) {
 
   57      return vec.derived().reshaped(Eigen::fix<RowsAtCompileTime>(rows), Eigen::fix<ColsAtCompileTime>(cols)).eval();
 
   63namespace ResultTypes {
 
   64#define REGISTER_RESULTTYPE_IMPL(resultTypeName, rowsExpr, colsExpr, MaxRowsExpr, MaxColsExpr, VectorizeStruct, \ 
   66  template <typename ScalarType, int gridDim, int worldDim>                                                     \ 
   67  struct resultTypeName                                                                                         \ 
   69    friend std::string toString(resultTypeName) { return #resultTypeName; }                                     \ 
   71    using type       = Eigen::Matrix<ScalarType, rowsExpr, colsExpr, 0, MaxRowsExpr, MaxColsExpr>;              \ 
   72    using Vectorizer = VectorizeStruct;                                                                         \ 
   73    using Matricizer = MatricizeStruct;                                                                         \ 
   75    template <typename ScalarType_, int gridDim_, int worldDim_>                                                \ 
   76    using Rebind = resultTypeName<ScalarType_, gridDim_, worldDim_>;                                            \ 
   86#define REGISTER_SIMPLE_SYMMETRIC_RESULTTYPE(resultTypeName, rowsExpr, colsExpr, strainlike) \ 
   87  REGISTER_RESULTTYPE_IMPL(resultTypeName, rowsExpr, colsExpr, rowsExpr, colsExpr,           \ 
   88                           Ikarus::Impl::VectorizeWithVoigt<strainlike>, Ikarus::Impl::MatricizeWithVoigt<strainlike>) 
   97#define REGISTER_RESULTTYPE(resultTypeName, rowsExpr, colsExpr)                                \ 
   98  REGISTER_RESULTTYPE_IMPL(resultTypeName, rowsExpr, colsExpr, Ikarus::Impl::VectorizeGeneric, \ 
   99                           Ikarus::Impl::MatricizeGeneric) 
  109#define REGISTER_RESERVED_RESULTTYPE(resultTypeName, rowsExpr, colsExpr, MaxRowsExpr, MaxColsExpr) \ 
  110  REGISTER_RESULTTYPE_IMPL(resultTypeName, rowsExpr, colsExpr, MaxRowsExpr, MaxColsExpr,           \ 
  111                           Ikarus::Impl::VectorizeGeneric, Ikarus::Impl::MatricizeGeneric) 
  119#define REGISTER_SIMPLE_RESULTTYPE(resultTypeName, rowsExpr, colsExpr) \ 
  120  REGISTER_RESERVED_RESULTTYPE(resultTypeName, rowsExpr, colsExpr, rowsExpr, colsExpr) 
  162template <
typename RT, ResultShape storedResultShape = ResultShape::Vector>
 
  166  using ResultTypeValueType                       = 
typename RT::type;
 
  167  static constexpr Eigen::Index rowsAtCompileTime = ResultTypeValueType::RowsAtCompileTime;
 
  168  static constexpr Eigen::Index colsAtCompileTime = ResultTypeValueType::ColsAtCompileTime;
 
  172  using VecType = std::invoke_result_t<
decltype(&RT::Vectorizer::template transform<ResultTypeValueType>),
 
  173                                       const ResultTypeValueType&>;
 
  175      std::invoke_result_t<
decltype(&RT::Matricizer::template transform<VecType, rowsAtCompileTime, colsAtCompileTime>),
 
  177  using StoredType = std::conditional_t<storedValueIsVector, VecType, MatType>;
 
  185    if constexpr (storedValueIsVector)
 
  188      return RT::Vectorizer::transform(value_);
 
  197  auto asMat(Eigen::Index rows = rowsAtCompileTime, Eigen::Index cols = colsAtCompileTime)
 const {
 
  198    if constexpr (storedValueIsVector) {
 
  199      if constexpr (rowsAtCompileTime == Eigen::Dynamic)
 
  200        assert(rows != rowsAtCompileTime &&
 
  201               "For dynamic size result types you have to pass rows by hand, since it is not clear how the result " 
  202               "should be reshaped");
 
  203      if constexpr (colsAtCompileTime == Eigen::Dynamic)
 
  204        assert(cols != colsAtCompileTime &&
 
  205               "For dynamic size result types you have to pass cols by hand, since it is not clear how the result " 
  206               "should be reshaped");
 
  207      return RT::Matricizer::template transform<VecType, rowsAtCompileTime, colsAtCompileTime>(value_, rows, cols);
 
  215    this->value_ = value;
 
  219    this->value_ = std::move(value);
 
  228  template <
template <
typename, 
int, 
int> 
class RT>
 
  229  using DummyRT = RT<double, 1, 1>;
 
  237template <
template <
typename, 
int, 
int> 
class RT>
 
  239  return Impl::DummyRT<RT>{};
 
  247template <
template <
typename, 
int, 
int> 
class RT>
 
  249  return toString(Impl::DummyRT<RT>{});
 
  257template <
template <
typename, 
int, 
int> 
class RT1, 
template <
typename, 
int, 
int> 
class RT2>
 
  258constexpr static bool isSameResultType = std::is_same_v<Impl::DummyRT<RT1>, Impl::DummyRT<RT2>>;
 
  261  template <
typename T, 
typename Tuple>
 
  264  template <
typename T, 
typename... Us>
 
  265  struct hasType<T, std::tuple<Us...>> : std::disjunction<std::is_same<T, Us>...>
 
  275template <
template <
typename, 
int, 
int> 
typename... ResultTypes>
 
  282  template <
template <
typename, 
int, 
int> 
typename RT>
 
Helper for the Eigen::Tensor types.
 
auto fromVoigt(const Eigen::Matrix< ST, size, 1, Options, maxSize, 1 > &EVoigt, bool isStrain=true)
Converts a vector given in Voigt notation to a matrix.
Definition: tensorutils.hh:296
 
constexpr Eigen::Index toVoigt(Eigen::Index i, Eigen::Index j) noexcept
Converts 2D indices to Voigt notation index.
Definition: tensorutils.hh:182
 
Definition: assemblermanipulatorbuildingblocks.hh:22
 
auto makeRT()
Creates a dummy resultType which can be stored in a variable.
Definition: feresulttypes.hh:238
 
static constexpr bool isSameResultType
Meta variable to test whether two ResultType templates are the same.
Definition: feresulttypes.hh:258
 
ResultShape
Definition: feresulttypes.hh:151
 
constexpr std::string toString(DBCOption _e)
Definition: dirichletbcenforcement.hh:8
 
REGISTER_SIMPLE_SYMMETRIC_RESULTTYPE(linearStress, worldDim, worldDim, false)
 
REGISTER_SIMPLE_RESULTTYPE(director, worldDim, 1)
 
Container that is used for FE Results. It gives access to the stored value, but can also be used to a...
Definition: feresulttypes.hh:164
 
std::conditional_t< storedValueIsVector, VecType, MatType > StoredType
Definition: feresulttypes.hh:177
 
std::invoke_result_t< decltype(&RT::Matricizer::template transform< VecType, rowsAtCompileTime, colsAtCompileTime >), const VecType &, int, int > MatType
Definition: feresulttypes.hh:176
 
ResultWrapper(StoredType &&value)
Definition: feresulttypes.hh:212
 
ResultWrapper & operator=(StoredType &&value)
Definition: feresulttypes.hh:218
 
std::invoke_result_t< decltype(&RT::Vectorizer::template transform< ResultTypeValueType >), const ResultTypeValueType & > VecType
Definition: feresulttypes.hh:173
 
ResultWrapper & operator=(const StoredType &value)
Definition: feresulttypes.hh:214
 
auto asVec() const
Returns the stored value as Vector.
Definition: feresulttypes.hh:184
 
ResultWrapper(const StoredType &value)
Definition: feresulttypes.hh:213
 
auto asMat(Eigen::Index rows=rowsAtCompileTime, Eigen::Index cols=colsAtCompileTime) const
Returns the stored value as Matrix (if possible)
Definition: feresulttypes.hh:197
 
RT ResultType
Definition: feresulttypes.hh:178
 
Base class for element definitions that provides common functionality for ResultTypes.
Definition: feresulttypes.hh:277
 
std::tuple< decltype(makeRT< ResultTypes >())... > SupportedResultTypes
Definition: feresulttypes.hh:287
 
static consteval bool supportsResultType()
Returns whether a ResultType is provided by the element.
Definition: feresulttypes.hh:283