20 #ifndef OPM_WRITESYSTEMMATRIXHELPER_HEADER_INCLUDED
21 #define OPM_WRITESYSTEMMATRIXHELPER_HEADER_INCLUDED
23 #include <dune/istl/matrixmarket.hh>
24 #include <opm/simulators/linalg/MatrixMarketSpecializations.hpp>
31 template <
class SimulatorType,
class MatrixType,
class VectorType,
class Communicator>
32 void writeSystem(
const SimulatorType& simulator,
33 const MatrixType& matrix,
34 const VectorType& rhs,
35 [[maybe_unused]]
const Communicator* comm)
37 std::string dir = simulator.problem().outputDir();
40 }
else if (!dir.empty() && dir.back() !=
'/') {
43 namespace fs = ::Opm::filesystem;
44 fs::path output_dir(dir);
45 fs::path subdir(
"reports");
46 output_dir = output_dir / subdir;
47 if (!(fs::exists(output_dir))) {
48 fs::create_directory(output_dir);
51 std::ostringstream oss;
52 oss <<
"prob_" << simulator.episodeIndex() <<
"_time_";
53 oss << std::setprecision(15) << std::setw(12) << std::setfill(
'0') << simulator.time() <<
"_";
54 int nit = simulator.model().newtonMethod().numIterations();
55 oss <<
"_nit_" << nit <<
"_";
56 std::string output_file(oss.str());
57 fs::path full_path = output_dir / output_file;
58 std::string prefix = full_path.string();
60 std::string filename = prefix +
"matrix_istl";
62 if (comm !=
nullptr) {
63 Dune::storeMatrixMarket(matrix, filename, *comm,
true);
67 Dune::storeMatrixMarket(matrix, filename +
".mm");
71 std::string filename = prefix +
"rhs_istl";
73 if (comm !=
nullptr) {
74 Dune::storeMatrixMarket(rhs, filename, *comm,
true);
78 Dune::storeMatrixMarket(rhs, filename +
".mm");
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:26