diff --git a/dune/matrix-vector/CMakeLists.txt b/dune/matrix-vector/CMakeLists.txt index d25563c693555f5879255ec97904dfaf8a8b0e21..cbfd6a59eb21069e86cff070fecde0685935e3af 100644 --- a/dune/matrix-vector/CMakeLists.txt +++ b/dune/matrix-vector/CMakeLists.txt @@ -6,6 +6,7 @@ add_subdirectory(types) install(FILES addtodiagonal.hh algorithm.hh + asfieldmatrix.hh axpy.hh axy.hh blockmatrixview.hh diff --git a/dune/matrix-vector/asfieldmatrix.hh b/dune/matrix-vector/asfieldmatrix.hh new file mode 100644 index 0000000000000000000000000000000000000000..af4ba6a1a47b4e4ad615ecf1b8f5688b2704a504 --- /dev/null +++ b/dune/matrix-vector/asfieldmatrix.hh @@ -0,0 +1,53 @@ +#ifndef DUNE_MATRIX_VECTOR_ASFIELDMATRIX_HH +#define DUNE_MATRIX_VECTOR_ASFIELDMATRIX_HH + +#include <dune/common/fmatrix.hh> +#include <dune/common/diagonalmatrix.hh> +#include <dune/istl/scaledidmatrix.hh> +#include <dune/istl/bcrsmatrix.hh> +#include <dune/istl/multitypeblockmatrix.hh> +#include <dune/matrix-vector/types/multitypematrix.hh> + +namespace Dune { +namespace MatrixVector { + +template <class> +struct AsFieldMatrix; + +template <class M> +using AsFieldMatrix_t = typename AsFieldMatrix<M>::type; + +template <class K, int n, int m> +struct AsFieldMatrix<FieldMatrix<K, n, m>> { + using type = FieldMatrix<K, n, m>; +}; + +template <class K, int n> +struct AsFieldMatrix<DiagonalMatrix<K, n>> { + using type = FieldMatrix<K, n, n>; +}; + +template <class K, int n> +struct AsFieldMatrix<ScaledIdentityMatrix<K, n>> { + using type = FieldMatrix<K, n, n>; +}; + +template <class BlockMatrix> +struct AsFieldMatrix<BCRSMatrix<BlockMatrix>> { + using type = BCRSMatrix<AsFieldMatrix_t<BlockMatrix>>; +}; + +template <class... Args> +struct AsFieldMatrix<MultiTypeBlockMatrix<Args...>> { + using type = MultiTypeBlockMatrix<AsFieldMatrix_t<Args>...>; +}; + +template <class... Args> +struct AsFieldMatrix<MultiTypeMatrix<Args...>> { + using type = MultiTypeMatrix<AsFieldMatrix_t<Args>...>; +}; + +} // end namespace MatrixVector +} // end namespace Dune + +#endif // DUNE_MATRIX_VECTOR_ASFIELDMATRIX_HH