20#ifndef OPM_WRITESYSTEMMATRIXHELPER_HEADER_INCLUDED
21#define OPM_WRITESYSTEMMATRIXHELPER_HEADER_INCLUDED
23#include <dune/istl/matrixmarket.hh>
33 template <
class SimulatorType,
class MatrixType,
class VectorType,
class Communicator>
35 const MatrixType& matrix,
36 const VectorType& rhs,
37 [[maybe_unused]]
const Communicator* comm)
39 std::string dir = simulator.problem().outputDir();
42 }
else if (!dir.empty() && dir.back() !=
'/') {
45 namespace fs = ::std::filesystem;
46 fs::path output_dir(dir);
47 fs::path subdir(
"reports");
48 output_dir = output_dir / subdir;
49 if (!(fs::exists(output_dir))) {
50 fs::create_directory(output_dir);
53 std::ostringstream oss;
54 oss <<
"prob_" << simulator.episodeIndex() <<
"_time_";
55 oss << std::setprecision(15) << std::setw(12) << std::setfill(
'0') << simulator.time() <<
"_";
56 int nit = simulator.model().newtonMethod().numIterations();
57 oss <<
"_nit_" << nit <<
"_";
58 std::string output_file(oss.str());
59 fs::path full_path = output_dir / output_file;
60 std::string prefix = full_path.string();
62 std::string filename = prefix +
"matrix_istl";
64 if (comm !=
nullptr) {
65 Dune::storeMatrixMarket(matrix, filename, *comm,
true);
69 Dune::storeMatrixMarket(matrix, filename +
".mm");
73 std::string filename = prefix +
"rhs_istl";
75 if (comm !=
nullptr) {
76 Dune::storeMatrixMarket(rhs, filename, *comm,
true);
80 Dune::storeMatrixMarket(rhs, filename +
".mm");
void writeSystem(const SimulatorType &simulator, const MatrixType &matrix, const VectorType &rhs, const Communicator *comm)
Definition: WriteSystemMatrixHelper.hpp:34
Definition: blackoilboundaryratevector.hh:37