/** * \file * \copyright * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.org/project/license * */ #pragma once #include "NumLib/Fem/CoordinatesMapping/ShapeMatrices.h" #include namespace detail { /// Forwards the Eigen::Matrix type for general N and M. /// There is a partial specialization for M = 1 to store the matrix in /// column major storage order. template struct EigenMatrixType { using type = Eigen::Matrix; }; /// Specialization for Nx1 matrices which can be stored only in column major /// form in Eigen-3.2.5. template struct EigenMatrixType { using type = Eigen::Matrix; }; /// Specialization for 0xM matrices. Using fixed size Eigen matrices here /// would lead to zero sized arrays, which cause compilation errors on /// some compilers. template struct EigenMatrixType<0, M> { using type = Eigen::Matrix; }; template <> struct EigenMatrixType<0, 1> { using type = Eigen::Matrix; }; } // namespace detail /// An implementation of ShapeMatrixPolicy using fixed size (compile-time) eigen /// matrices and vectors. template struct EigenFixedShapeMatrixPolicy { template using VectorType = typename ::detail::EigenMatrixType::type; template using RowVectorType = typename ::detail::EigenMatrixType<1, N>::type; template using MatrixType = typename ::detail::EigenMatrixType::type; using NodalMatrixType = MatrixType; using NodalVectorType = VectorType; using NodalRowVectorType = RowVectorType; using DimNodalMatrixType = MatrixType; using DimMatrixType = MatrixType; using GlobalDimNodalMatrixType = MatrixType; using GlobalDimMatrixType = MatrixType; using GlobalDimVectorType = VectorType; using ShapeMatrices = NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType>; }; /// An implementation of ShapeMatrixPolicy using dynamic size eigen matrices and /// vectors. template struct EigenDynamicShapeMatrixPolicy { // Dynamic size local matrices are much slower in allocation than their // fixed counterparts. template using VectorType = Eigen::Matrix; template using RowVectorType = Eigen::Matrix; template using MatrixType = Eigen::Matrix; using NodalMatrixType = MatrixType<0,0>; using NodalVectorType = VectorType<0>; using NodalRowVectorType = RowVectorType<0>; using DimNodalMatrixType = MatrixType<0,0>; using DimMatrixType = MatrixType<0,0>; using GlobalDimNodalMatrixType = MatrixType<0,0>; using GlobalDimMatrixType = MatrixType<0,0>; using GlobalDimVectorType = VectorType<0>; using ShapeMatrices = NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType>; }; #ifdef OGS_EIGEN_DYNAMIC_SHAPE_MATRICES template using ShapeMatrixPolicyType = EigenDynamicShapeMatrixPolicy; const unsigned OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG = 1; #else template using ShapeMatrixPolicyType = EigenFixedShapeMatrixPolicy; const unsigned OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG = 0; #endif //static_assert(std::is_class::value, //"ShapeMatrixPolicyType was not defined.");