opm-simulators
MatrixMarketSpecializations.hpp
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 
15 namespace Opm
16 {
17 template<typename T, int i, int j>
18 class MatrixBlock;
19 }
20 
21 namespace 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 
34 namespace 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 
59 namespace 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
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45