mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Use ensureDirectoryExists() instead of boost::filesystem directly.
Motivated by - proliferation of identical code - need to avoid strange behaviour with "." directory on some boost versions - potenial for further refactoring to avoid boost entirely
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include <opm/autodiff/createGlobalCellArray.hpp>
|
||||
#include <opm/autodiff/GridInit.hpp>
|
||||
#include <opm/simulators/ParallelFileMerger.hpp>
|
||||
#include <opm/simulators/ensureDirectoryExists.hpp>
|
||||
|
||||
#include <opm/core/wells.h>
|
||||
#include <opm/core/wells/WellsManager.hpp>
|
||||
@@ -378,15 +379,7 @@ namespace Opm
|
||||
// Write parameters used for later reference. (only if rank is zero)
|
||||
if (output_to_files_) {
|
||||
// Create output directory if needed.
|
||||
boost::filesystem::path fpath(output_dir_);
|
||||
if (!is_directory(fpath)) {
|
||||
try {
|
||||
create_directories(fpath);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
||||
}
|
||||
}
|
||||
ensureDirectoryExists(output_dir_);
|
||||
// Write simulation parameters.
|
||||
param_.writeParam(output_dir_ + "/simulation.param");
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define OPM_FLOW_MAIN_EBOS_HEADER_INCLUDED
|
||||
|
||||
#include <opm/simulators/ParallelFileMerger.hpp>
|
||||
#include <opm/simulators/ensureDirectoryExists.hpp>
|
||||
|
||||
#include <opm/autodiff/BlackoilModelEbos.hpp>
|
||||
#include <opm/autodiff/NewtonIterationBlackoilSimple.hpp>
|
||||
@@ -263,15 +264,7 @@ namespace Opm
|
||||
// Write parameters used for later reference. (only if rank is zero)
|
||||
if (output_to_files_) {
|
||||
// Create output directory if needed.
|
||||
boost::filesystem::path fpath(output_dir_);
|
||||
if (!is_directory(fpath)) {
|
||||
try {
|
||||
create_directories(fpath);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
||||
}
|
||||
}
|
||||
ensureDirectoryExists(output_dir_);
|
||||
// Write simulation parameters.
|
||||
param_.writeParam(output_dir_ + "/simulation.param");
|
||||
}
|
||||
|
||||
@@ -66,13 +66,7 @@ namespace Opm
|
||||
// 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);
|
||||
}
|
||||
ensureDirectoryExists(vtkfilename.str());
|
||||
vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu";
|
||||
std::ofstream vtkfile(vtkfilename.str().c_str());
|
||||
if (!vtkfile) {
|
||||
@@ -106,13 +100,7 @@ namespace Opm
|
||||
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);
|
||||
}
|
||||
ensureDirectoryExists(fname.str());
|
||||
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
|
||||
std::ofstream file(fname.str().c_str());
|
||||
if (!file) {
|
||||
@@ -161,13 +149,7 @@ namespace Opm
|
||||
std::ostringstream vtkpath;
|
||||
vtkpath << output_dir << "/vtk_files";
|
||||
vtkpath << "/output-" << std::setw(3) << std::setfill('0') << step;
|
||||
boost::filesystem::path fpath(vtkpath.str());
|
||||
try {
|
||||
create_directories(fpath);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
||||
}
|
||||
ensureDirectoryExists(vtkpath.str());
|
||||
vtkfilename << "output-" << std::setw(3) << std::setfill('0') << step;
|
||||
#if DUNE_VERSION_NEWER(DUNE_GRID, 2, 3)
|
||||
Dune::VTKWriter<Dune::CpGrid::LeafGridView> writer(grid.leafGridView(), Dune::VTK::nonconforming);
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
|
||||
#include <opm/simulators/ensureDirectoryExists.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@@ -123,13 +123,7 @@ namespace Opm
|
||||
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);
|
||||
}
|
||||
ensureDirectoryExists(fname.str());
|
||||
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
|
||||
std::ofstream file(fname.str().c_str());
|
||||
if (!file) {
|
||||
@@ -376,13 +370,7 @@ namespace Opm
|
||||
eclIO_ = std::move(eclIO);
|
||||
|
||||
// Ensure that output dir exists
|
||||
boost::filesystem::path fpath(outputDir_);
|
||||
try {
|
||||
create_directories(fpath);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
||||
}
|
||||
ensureDirectoryExists(outputDir_);
|
||||
|
||||
// create output thread if enabled and rank is I/O rank
|
||||
// async output is enabled by default if pthread are enabled
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
#include <opm/core/transport/reorder/TransportSolverTwophaseReorder.hpp>
|
||||
#include <opm/core/transport/implicit/TransportSolverTwophaseImplicit.hpp>
|
||||
#include <opm/autodiff/TransportSolverTwophaseAd.hpp>
|
||||
#include <opm/simulators/ensureDirectoryExists.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
@@ -177,13 +179,7 @@ namespace Opm
|
||||
// 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);
|
||||
}
|
||||
ensureDirectoryExists(vtkfilename.str());
|
||||
vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu";
|
||||
std::ofstream vtkfile(vtkfilename.str().c_str());
|
||||
if (!vtkfile) {
|
||||
@@ -205,13 +201,7 @@ namespace Opm
|
||||
{
|
||||
std::ostringstream fname;
|
||||
fname << output_dir << "/" << name;
|
||||
boost::filesystem::path fpath = fname.str();
|
||||
try {
|
||||
create_directories(fpath);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
||||
}
|
||||
ensureDirectoryExists(fname.str());
|
||||
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
|
||||
std::ofstream file(fname.str().c_str());
|
||||
if (!file) {
|
||||
@@ -236,13 +226,7 @@ namespace Opm
|
||||
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);
|
||||
}
|
||||
ensureDirectoryExists(fname.str());
|
||||
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
|
||||
std::ofstream file(fname.str().c_str());
|
||||
if (!file) {
|
||||
@@ -384,13 +368,7 @@ namespace Opm
|
||||
output_vtk_ = param.getDefault("output_vtk", true);
|
||||
output_dir_ = param.getDefault("output_dir", std::string("output"));
|
||||
// Ensure that output dir exists
|
||||
boost::filesystem::path fpath(output_dir_);
|
||||
try {
|
||||
create_directories(fpath);
|
||||
}
|
||||
catch (...) {
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
||||
}
|
||||
ensureDirectoryExists(output_dir_);
|
||||
output_interval_ = param.getDefault("output_interval", 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user