Commented out usage of OutputWriter in simulator

This commit is contained in:
Kjell W. Kongsvik 2016-03-17 14:12:34 +01:00
parent 38628de09e
commit 3614defbd9
2 changed files with 140 additions and 133 deletions

View File

@ -34,7 +34,8 @@
#include <opm/core/simulator/SimulatorReport.hpp> #include <opm/core/simulator/SimulatorReport.hpp>
#include <opm/core/simulator/SimulatorTimer.hpp> #include <opm/core/simulator/SimulatorTimer.hpp>
#include <opm/core/utility/StopWatch.hpp> #include <opm/core/utility/StopWatch.hpp>
#include <opm/core/io/vtk/writeVtkData.hpp> // 17.03.2016 Temporarily removed while moving functionality to opm-output
// #include <opm/core/io/vtk/writeVtkData.hpp>
#include <opm/core/utility/miscUtilities.hpp> #include <opm/core/utility/miscUtilities.hpp>
#include <opm/core/utility/miscUtilitiesBlackoil.hpp> #include <opm/core/utility/miscUtilitiesBlackoil.hpp>
@ -138,70 +139,72 @@ namespace Opm
static void outputStateVtk(const UnstructuredGrid& grid, // 17.03.2016 Temporarily removed while moving functionality to opm-output
const Opm::BlackoilState& state, // static void outputStateVtk(const UnstructuredGrid& grid,
const int step, // const Opm::BlackoilState& state,
const std::string& output_dir) // const int step,
{ // const std::string& output_dir)
// Write data in VTK format. // {
std::ostringstream vtkfilename; // // Write data in VTK format.
vtkfilename << output_dir << "/vtk_files"; // std::ostringstream vtkfilename;
boost::filesystem::path fpath(vtkfilename.str()); // vtkfilename << output_dir << "/vtk_files";
try { // boost::filesystem::path fpath(vtkfilename.str());
create_directories(fpath); // try {
} // create_directories(fpath);
catch (...) { // }
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); // catch (...) {
} // OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu"; // }
std::ofstream vtkfile(vtkfilename.str().c_str()); // vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu";
if (!vtkfile) { // std::ofstream vtkfile(vtkfilename.str().c_str());
OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str()); // if (!vtkfile) {
} // OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str());
Opm::DataMap dm; // }
dm["saturation"] = &state.saturation(); // Opm::DataMap dm;
dm["pressure"] = &state.pressure(); // dm["saturation"] = &state.saturation();
std::vector<double> cell_velocity; // dm["pressure"] = &state.pressure();
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity); // std::vector<double> cell_velocity;
dm["velocity"] = &cell_velocity; // Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
Opm::writeVtkData(grid, dm, vtkfile); // dm["velocity"] = &cell_velocity;
} // Opm::writeVtkData(grid, dm, vtkfile);
// }
static void outputStateMatlab(const UnstructuredGrid& grid, // 17.03.2016 Temporarily removed while moving functionality to opm-output
const Opm::BlackoilState& state, // static void outputStateMatlab(const UnstructuredGrid& grid,
const int step, // const Opm::BlackoilState& state,
const std::string& output_dir) // const int step,
{ // const std::string& output_dir)
Opm::DataMap dm; // {
dm["saturation"] = &state.saturation(); // Opm::DataMap dm;
dm["pressure"] = &state.pressure(); // dm["saturation"] = &state.saturation();
dm["surfvolume"] = &state.surfacevol(); // dm["pressure"] = &state.pressure();
std::vector<double> cell_velocity; // dm["surfvolume"] = &state.surfacevol();
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity); // std::vector<double> cell_velocity;
dm["velocity"] = &cell_velocity; // Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
// dm["velocity"] = &cell_velocity;
// Write data (not grid) in Matlab format //
for (Opm::DataMap::const_iterator it = dm.begin(); it != dm.end(); ++it) { // // Write data (not grid) in Matlab format
std::ostringstream fname; // for (Opm::DataMap::const_iterator it = dm.begin(); it != dm.end(); ++it) {
fname << output_dir << "/" << it->first; // std::ostringstream fname;
boost::filesystem::path fpath = fname.str(); // fname << output_dir << "/" << it->first;
try { // boost::filesystem::path fpath = fname.str();
create_directories(fpath); // try {
} // create_directories(fpath);
catch (...) { // }
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); // catch (...) {
} // OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt"; // }
std::ofstream file(fname.str().c_str()); // fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
if (!file) { // std::ofstream file(fname.str().c_str());
OPM_THROW(std::runtime_error, "Failed to open " << fname.str()); // if (!file) {
} // OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
file.precision(15); // }
const std::vector<double>& d = *(it->second); // file.precision(15);
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n")); // const std::vector<double>& d = *(it->second);
} // std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
} // }
// }
static void outputWaterCut(const Opm::Watercut& watercut, static void outputWaterCut(const Opm::Watercut& watercut,
@ -348,9 +351,9 @@ namespace Opm
timer.report(std::cout); timer.report(std::cout);
if (output_ && (timer.currentStepNum() % output_interval_ == 0)) { if (output_ && (timer.currentStepNum() % output_interval_ == 0)) {
if (output_vtk_) { if (output_vtk_) {
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_); // outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
} }
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_); // outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
} }
SimulatorReport sreport; SimulatorReport sreport;
@ -515,9 +518,9 @@ namespace Opm
if (output_) { if (output_) {
if (output_vtk_) { if (output_vtk_) {
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_); // outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
} }
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_); // outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
outputWaterCut(watercut, output_dir_); outputWaterCut(watercut, output_dir_);
if (wells_) { if (wells_) {
outputWellReport(wellreport, output_dir_); outputWellReport(wellreport, output_dir_);

View File

@ -35,7 +35,8 @@
#include <opm/core/simulator/SimulatorReport.hpp> #include <opm/core/simulator/SimulatorReport.hpp>
#include <opm/core/simulator/SimulatorTimer.hpp> #include <opm/core/simulator/SimulatorTimer.hpp>
#include <opm/core/utility/StopWatch.hpp> #include <opm/core/utility/StopWatch.hpp>
#include <opm/core/io/vtk/writeVtkData.hpp> // 17.03.2016 Temporarily removed while moving functionality to opm-output
// #include <opm/core/io/vtk/writeVtkData.hpp>
#include <opm/core/utility/miscUtilities.hpp> #include <opm/core/utility/miscUtilities.hpp>
#include <opm/core/utility/Event.hpp> #include <opm/core/utility/Event.hpp>
@ -179,34 +180,36 @@ namespace Opm
os.precision(8); os.precision(8);
} }
static void outputStateVtk(const UnstructuredGrid& grid,
const Opm::TwophaseState& state, // 17.03.2016 Temporarily removed while moving functionality to opm-output
const int step, // static void outputStateVtk(const UnstructuredGrid& grid,
const std::string& output_dir) // const Opm::TwophaseState& state,
{ // const int step,
// Write data in VTK format. // const std::string& output_dir)
std::ostringstream vtkfilename; // {
vtkfilename << output_dir << "/vtk_files"; // // Write data in VTK format.
boost::filesystem::path fpath(vtkfilename.str()); // std::ostringstream vtkfilename;
try { // vtkfilename << output_dir << "/vtk_files";
create_directories(fpath); // boost::filesystem::path fpath(vtkfilename.str());
} // try {
catch (...) { // create_directories(fpath);
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); // }
} // catch (...) {
vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu"; // OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
std::ofstream vtkfile(vtkfilename.str().c_str()); // }
if (!vtkfile) { // vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu";
OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str()); // std::ofstream vtkfile(vtkfilename.str().c_str());
} // if (!vtkfile) {
Opm::DataMap dm; // OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str());
dm["saturation"] = &state.saturation(); // }
dm["pressure"] = &state.pressure(); // Opm::DataMap dm;
std::vector<double> cell_velocity; // dm["saturation"] = &state.saturation();
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity); // dm["pressure"] = &state.pressure();
dm["velocity"] = &cell_velocity; // std::vector<double> cell_velocity;
Opm::writeVtkData(grid, dm, vtkfile); // Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
} // dm["velocity"] = &cell_velocity;
// Opm::writeVtkData(grid, dm, vtkfile);
// }
static void outputVectorMatlab(const std::string& name, static void outputVectorMatlab(const std::string& name,
const std::vector<int>& vec, const std::vector<int>& vec,
@ -230,39 +233,40 @@ namespace Opm
std::copy(vec.begin(), vec.end(), std::ostream_iterator<double>(file, "\n")); std::copy(vec.begin(), vec.end(), std::ostream_iterator<double>(file, "\n"));
} }
static void outputStateMatlab(const UnstructuredGrid& grid, // 17.03.2016 Temporarily removed while moving functionality to opm-output
const Opm::TwophaseState& state, // static void outputStateMatlab(const UnstructuredGrid& grid,
const int step, // const Opm::TwophaseState& state,
const std::string& output_dir) // const int step,
{ // const std::string& output_dir)
Opm::DataMap dm; // {
dm["saturation"] = &state.saturation(); // Opm::DataMap dm;
dm["pressure"] = &state.pressure(); // dm["saturation"] = &state.saturation();
std::vector<double> cell_velocity; // dm["pressure"] = &state.pressure();
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity); // std::vector<double> cell_velocity;
dm["velocity"] = &cell_velocity; // Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
// dm["velocity"] = &cell_velocity;
// Write data (not grid) in Matlab format //
for (Opm::DataMap::const_iterator it = dm.begin(); it != dm.end(); ++it) { // // Write data (not grid) in Matlab format
std::ostringstream fname; // for (Opm::DataMap::const_iterator it = dm.begin(); it != dm.end(); ++it) {
fname << output_dir << "/" << it->first; // std::ostringstream fname;
boost::filesystem::path fpath = fname.str(); // fname << output_dir << "/" << it->first;
try { // boost::filesystem::path fpath = fname.str();
create_directories(fpath); // try {
} // create_directories(fpath);
catch (...) { // }
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); // catch (...) {
} // OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt"; // }
std::ofstream file(fname.str().c_str()); // fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
if (!file) { // std::ofstream file(fname.str().c_str());
OPM_THROW(std::runtime_error, "Failed to open " << fname.str()); // if (!file) {
} // OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
file.precision(15); // }
const std::vector<double>& d = *(it->second); // file.precision(15);
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n")); // const std::vector<double>& d = *(it->second);
} // std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
} // }
// }
static void outputWaterCut(const Opm::Watercut& watercut, static void outputWaterCut(const Opm::Watercut& watercut,
@ -460,9 +464,9 @@ namespace Opm
timer.report(*log_); timer.report(*log_);
if (output_ && (timer.currentStepNum() % output_interval_ == 0)) { if (output_ && (timer.currentStepNum() % output_interval_ == 0)) {
if (output_vtk_) { if (output_vtk_) {
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_); // outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
} }
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_); // outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
if (use_reorder_) { if (use_reorder_) {
// This use of dynamic_cast is not ideal, but should be safe. // This use of dynamic_cast is not ideal, but should be safe.
outputVectorMatlab(std::string("reorder_it"), outputVectorMatlab(std::string("reorder_it"),
@ -620,9 +624,9 @@ namespace Opm
if (output_) { if (output_) {
if (output_vtk_) { if (output_vtk_) {
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_); // outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
} }
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_); // outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
if (use_reorder_) { if (use_reorder_) {
// This use of dynamic_cast is not ideal, but should be safe. // This use of dynamic_cast is not ideal, but should be safe.
outputVectorMatlab(std::string("reorder_it"), outputVectorMatlab(std::string("reorder_it"),