Skip to content

Commit

Permalink
Replace comment with "ifdef DISABLE_OUTPUT"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kjell W. Kongsvik committed Mar 29, 2016
1 parent 8e68a4d commit 77a6c42
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 164 deletions.
148 changes: 81 additions & 67 deletions opm/core/simulator/SimulatorCompressibleTwophase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
#include <opm/core/simulator/SimulatorTimer.hpp>
#include <opm/core/utility/StopWatch.hpp>
// 17.03.2016 Temporarily removed while moving functionality to opm-output
// #include <opm/core/io/vtk/writeVtkData.hpp>
#ifdef DISABLE_OUTPUT
#include <opm/core/io/vtk/writeVtkData.hpp>
#endif
#include <opm/core/utility/miscUtilities.hpp>
#include <opm/core/utility/miscUtilitiesBlackoil.hpp>

Expand Down Expand Up @@ -140,71 +142,75 @@ namespace Opm


// 17.03.2016 Temporarily removed while moving functionality to opm-output
// static void outputStateVtk(const UnstructuredGrid& grid,
// const Opm::BlackoilState& state,
// const int step,
// const std::string& output_dir)
// {
// // Write data in VTK format.
// std::ostringstream vtkfilename;
// vtkfilename << output_dir << "/vtk_files";
// boost::filesystem::path fpath(vtkfilename.str());
// try {
// create_directories(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());
// if (!vtkfile) {
// OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str());
// }
// Opm::DataMap dm;
// dm["saturation"] = &state.saturation();
// dm["pressure"] = &state.pressure();
// std::vector<double> cell_velocity;
// Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
// dm["velocity"] = &cell_velocity;
// Opm::writeVtkData(grid, dm, vtkfile);
// }
#ifdef DISABLE_OUTPUT
static void outputStateVtk(const UnstructuredGrid& grid,
const Opm::BlackoilState& state,
const int step,
const std::string& output_dir)
{
// Write data in VTK format.
std::ostringstream vtkfilename;
vtkfilename << output_dir << "/vtk_files";
boost::filesystem::path fpath(vtkfilename.str());
try {
create_directories(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());
if (!vtkfile) {
OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str());
}
Opm::DataMap dm;
dm["saturation"] = &state.saturation();
dm["pressure"] = &state.pressure();
std::vector<double> cell_velocity;
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
dm["velocity"] = &cell_velocity;
Opm::writeVtkData(grid, dm, vtkfile);
}
#endif


// 17.03.2016 Temporarily removed while moving functionality to opm-output
// static void outputStateMatlab(const UnstructuredGrid& grid,
// const Opm::BlackoilState& state,
// const int step,
// const std::string& output_dir)
// {
// Opm::DataMap dm;
// dm["saturation"] = &state.saturation();
// dm["pressure"] = &state.pressure();
// dm["surfvolume"] = &state.surfacevol();
// std::vector<double> 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) {
// std::ostringstream fname;
// fname << output_dir << "/" << it->first;
// boost::filesystem::path fpath = fname.str();
// try {
// create_directories(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());
// if (!file) {
// OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
// }
// file.precision(15);
// const std::vector<double>& d = *(it->second);
// std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
// }
// }
#ifdef DISABLE_OUTPUT
static void outputStateMatlab(const UnstructuredGrid& grid,
const Opm::BlackoilState& state,
const int step,
const std::string& output_dir)
{
Opm::DataMap dm;
dm["saturation"] = &state.saturation();
dm["pressure"] = &state.pressure();
dm["surfvolume"] = &state.surfacevol();
std::vector<double> 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) {
std::ostringstream fname;
fname << output_dir << "/" << it->first;
boost::filesystem::path fpath = fname.str();
try {
create_directories(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());
if (!file) {
OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
}
file.precision(15);
const std::vector<double>& d = *(it->second);
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
}
}
#endif


static void outputWaterCut(const Opm::Watercut& watercut,
Expand Down Expand Up @@ -351,9 +357,13 @@ namespace Opm
timer.report(std::cout);
if (output_ && (timer.currentStepNum() % output_interval_ == 0)) {
if (output_vtk_) {
// outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#endif
}
// outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#endif
}

SimulatorReport sreport;
Expand Down Expand Up @@ -518,9 +528,13 @@ namespace Opm

if (output_) {
if (output_vtk_) {
// outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#endif
}
// outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#endif
outputWaterCut(watercut, output_dir_);
if (wells_) {
outputWellReport(wellreport, output_dir_);
Expand Down
147 changes: 80 additions & 67 deletions opm/core/simulator/SimulatorIncompTwophase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#include <opm/core/simulator/SimulatorTimer.hpp>
#include <opm/core/utility/StopWatch.hpp>
// 17.03.2016 Temporarily removed while moving functionality to opm-output
// #include <opm/core/io/vtk/writeVtkData.hpp>
#ifdef DISABLE_OUTPUT
#include <opm/core/io/vtk/writeVtkData.hpp>
#endif
#include <opm/core/utility/miscUtilities.hpp>
#include <opm/core/utility/Event.hpp>

Expand Down Expand Up @@ -182,35 +184,36 @@ namespace Opm


// 17.03.2016 Temporarily removed while moving functionality to opm-output
// static void outputStateVtk(const UnstructuredGrid& grid,
// const Opm::TwophaseState& state,
// const int step,
// const std::string& output_dir)
// {
// // Write data in VTK format.
// std::ostringstream vtkfilename;
// vtkfilename << output_dir << "/vtk_files";
// boost::filesystem::path fpath(vtkfilename.str());
// try {
// create_directories(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());
// if (!vtkfile) {
// OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str());
// }
// Opm::DataMap dm;
// dm["saturation"] = &state.saturation();
// dm["pressure"] = &state.pressure();
// std::vector<double> cell_velocity;
// Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
// dm["velocity"] = &cell_velocity;
// Opm::writeVtkData(grid, dm, vtkfile);
// }

#ifdef DISABLE_OUTPUT
static void outputStateVtk(const UnstructuredGrid& grid,
const Opm::TwophaseState& state,
const int step,
const std::string& output_dir)
{
// Write data in VTK format.
std::ostringstream vtkfilename;
vtkfilename << output_dir << "/vtk_files";
boost::filesystem::path fpath(vtkfilename.str());
try {
create_directories(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());
if (!vtkfile) {
OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str());
}
Opm::DataMap dm;
dm["saturation"] = &state.saturation();
dm["pressure"] = &state.pressure();
std::vector<double> cell_velocity;
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
dm["velocity"] = &cell_velocity;
Opm::writeVtkData(grid, dm, vtkfile);
}
#endif
static void outputVectorMatlab(const std::string& name,
const std::vector<int>& vec,
const int step,
Expand All @@ -234,39 +237,41 @@ namespace Opm
}

// 17.03.2016 Temporarily removed while moving functionality to opm-output
// static void outputStateMatlab(const UnstructuredGrid& grid,
// const Opm::TwophaseState& state,
// const int step,
// const std::string& output_dir)
// {
// Opm::DataMap dm;
// dm["saturation"] = &state.saturation();
// dm["pressure"] = &state.pressure();
// std::vector<double> 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) {
// std::ostringstream fname;
// fname << output_dir << "/" << it->first;
// boost::filesystem::path fpath = fname.str();
// try {
// create_directories(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());
// if (!file) {
// OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
// }
// file.precision(15);
// const std::vector<double>& d = *(it->second);
// std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
// }
// }
#ifdef DISABLE_OUTPUT
static void outputStateMatlab(const UnstructuredGrid& grid,
const Opm::TwophaseState& state,
const int step,
const std::string& output_dir)
{
Opm::DataMap dm;
dm["saturation"] = &state.saturation();
dm["pressure"] = &state.pressure();
std::vector<double> 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) {
std::ostringstream fname;
fname << output_dir << "/" << it->first;
boost::filesystem::path fpath = fname.str();
try {
create_directories(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());
if (!file) {
OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
}
file.precision(15);
const std::vector<double>& d = *(it->second);
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
}
}
#endif


static void outputWaterCut(const Opm::Watercut& watercut,
Expand Down Expand Up @@ -464,9 +469,13 @@ namespace Opm
timer.report(*log_);
if (output_ && (timer.currentStepNum() % output_interval_ == 0)) {
if (output_vtk_) {
// outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#endif
}
// outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#endif
if (use_reorder_) {
// This use of dynamic_cast is not ideal, but should be safe.
outputVectorMatlab(std::string("reorder_it"),
Expand Down Expand Up @@ -624,9 +633,13 @@ namespace Opm

if (output_) {
if (output_vtk_) {
// outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
#endif
}
// outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#ifdef DISABLE_OUTPUT
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
#endif
if (use_reorder_) {
// This use of dynamic_cast is not ideal, but should be safe.
outputVectorMatlab(std::string("reorder_it"),
Expand Down
Loading

0 comments on commit 77a6c42

Please sign in to comment.