diff --git a/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp b/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp index d20dd450c..9a9044fd5 100644 --- a/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp +++ b/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp @@ -67,6 +67,8 @@ class ISTLSolverEbosFlexible using MatrixType = typename SparseMatrixAdapter::IstlMatrix; #if HAVE_MPI using Communication = Dune::OwnerOverlapCopyCommunication; +#else + using Communication = int; // Dummy type. #endif using SolverType = Dune::FlexibleSolver; @@ -281,21 +283,14 @@ protected: void writeMatrix() { -#ifdef HAVE_MPI const int verbosity = prm_.get("verbosity"); const bool write_matrix = verbosity > 10; if (write_matrix) { - using block_type = typename MatrixType::block_type; - using value_type = typename block_type::value_type; - using BaseBlockType = Dune::FieldMatrix; - using BaseMatrixType = Dune::BCRSMatrix; - const BaseMatrixType* matrix = reinterpret_cast(this->matrix_); Opm::Helper::writeSystem(this->simulator_, //simulator is only used to get names - *matrix, + *(this->matrix_), this->rhs_, comm_.get()); } -#endif } const Simulator& simulator_; @@ -306,9 +301,7 @@ protected: VectorType rhs_; Dune::InverseOperatorResult res_; std::any parallelInformation_; -#if HAVE_MPI std::unique_ptr comm_; -#endif std::vector overlapRows_; std::vector interiorRows_; }; // end ISTLSolverEbosFlexible diff --git a/opm/simulators/linalg/WriteSystemMatrixHelper.hpp b/opm/simulators/linalg/WriteSystemMatrixHelper.hpp index f76985176..13c07489e 100644 --- a/opm/simulators/linalg/WriteSystemMatrixHelper.hpp +++ b/opm/simulators/linalg/WriteSystemMatrixHelper.hpp @@ -22,6 +22,46 @@ #include +namespace Dune +{ +namespace MatrixMarketImpl +{ + + template + struct mm_header_printer> + { + static void print(std::ostream& os) + { + using Value = typename Block::value_type; + os << "%%MatrixMarket matrix coordinate "; + os << mm_numeric_type::str() << " general" << std::endl; + } + }; + + template + struct mm_block_structure_header> + { + using M = BCRSMatrix; + static void print(std::ostream& os, const M&) + { + os << "% ISTL_STRUCT blocked "; + os << Block::rows << " " << Block::cols << std::endl; + } + }; + +} // namespace MatrixMarketImpl + +template +struct mm_multipliers> +{ + enum { + rows = Block::rows, + cols = Block::cols + }; +}; + +} // namespace Dune + namespace Opm { namespace Helper @@ -30,7 +70,7 @@ namespace Helper void writeSystem(const SimulatorType& simulator, const MatrixType& matrix, const VectorType& rhs, - const Communicator* comm) + [[maybe_unused]] const Communicator* comm) { std::string dir = simulator.problem().outputDir(); if (dir == ".") { @@ -56,18 +96,24 @@ namespace Helper std::string prefix = full_path.string(); { std::string filename = prefix + "matrix_istl"; +#if HAVE_MPI if (comm != nullptr) { // comm is not set in serial runs Dune::storeMatrixMarket(matrix, filename, *comm, true); - } else { - Dune::storeMatrixMarket(matrix, filename); + } else +#endif + { + Dune::storeMatrixMarket(matrix, filename + ".mm"); } } { std::string filename = prefix + "rhs_istl"; +#if HAVE_MPI if (comm != nullptr) { // comm is not set in serial runs Dune::storeMatrixMarket(rhs, filename, *comm, true); - } else { - Dune::storeMatrixMarket(rhs, filename); + } else +#endif + { + Dune::storeMatrixMarket(rhs, filename + ".mm"); } } }