MatrixMarketSpecializations.hpp
Go to the documentation of this file.
1/*
2 The content of this file is based on the file dune/istl/matrixmarket.hh in
3 the Dune module dune-istl.
4
5 The license of this file is therefore the same as that of Dune, see
6 https://www.dune-project.org/about/license/
7*/
8
9#ifndef OPM_MATRIXMARKETSPECIALIZATIONS_HEADER_INCLUDED
10#define OPM_MATRIXMARKETSPECIALIZATIONS_HEADER_INCLUDED
11
12#include <dune/istl/matrixmarket.hh>
13#include <dune/istl/multitypeblockvector.hh>
14
15namespace Opm
16{
17template<typename T, int i, int j>
18class MatrixBlock;
19}
20
21namespace Dune
22{
23 template <typename... Args>
24 void writeMatrixMarket(const Dune::MultiTypeBlockVector<Args...>& vector, std::ostream& os)
25 {
26 os << "%%MatrixMarket matrix array real general" << std::endl;
27 using namespace Dune::Hybrid;
28 forEach(integralRange(Hybrid::size(vector)), [&](auto&& i)
29 {
30 Dune::writeMatrixMarket(vector[i], os);
31 });
32 };
33
34namespace MatrixMarketImpl
35{
36
37 template <typename T, int i, int j, typename A>
38 struct mm_header_printer<BCRSMatrix<Opm::MatrixBlock<T,i,j>, A>>
39 {
40 static void print(std::ostream& os)
41 {
42 os << "%%MatrixMarket matrix coordinate ";
43 os << mm_numeric_type<T>::str() << " general" << std::endl;
44 }
45 };
46
47 template <typename T, int i, int j, typename A>
48 struct mm_block_structure_header<BCRSMatrix<Opm::MatrixBlock<T,i,j>, A>>
49 {
50 using M = BCRSMatrix<Opm::MatrixBlock<T,i,j>, A>;
51 static void print(std::ostream& os, const M&)
52 {
53 os << "% ISTL_STRUCT blocked ";
54 os << i << " " << j << std::endl;
55 }
56 };
57} // namespace MatrixMarketImpl
58
59namespace MatrixMarketImpl
60{
61 template <typename T, int i, int j, typename A>
62 struct mm_multipliers<BCRSMatrix<Opm::MatrixBlock<T,i,j>, A>>
63 {
64 enum {
65 rows = i,
66 cols = j
67 };
68 };
69} // namespace MatrixMarketImpl
70
71} // namespace Dune
72
73#endif
Definition: fvbaseprimaryvariables.hh:161
void writeMatrixMarket(const Dune::MultiTypeBlockVector< Args... > &vector, std::ostream &os)
Definition: MatrixMarketSpecializations.hpp:24
Definition: blackoilbioeffectsmodules.hh:45
static void print(std::ostream &os, const M &)
Definition: MatrixMarketSpecializations.hpp:51
BCRSMatrix< Opm::MatrixBlock< T, i, j >, A > M
Definition: MatrixMarketSpecializations.hpp:50
static void print(std::ostream &os)
Definition: MatrixMarketSpecializations.hpp:40