[Coupling] Check clashing names

parent 14ceff64
......@@ -18,6 +18,17 @@ RichardsTransportCouplingSimulation<Traits>::RichardsTransportCouplingSimulation
, _inifile_richards(inifile_richards)
, _inifile_transport(inifile_transport)
{
auto richards_file = _inifile_richards.get<std::string>("output.fileName");
auto transport_file = _inifile_transport.get<std::string>("output.fileName");
// avoid output overwriting
if (richards_file == transport_file) {
this->_log->error(
"Clashing names for Richards and Transport output filenames: {}",
richards_file);
DUNE_THROW(Dune::IOError,"Clashing names for VTKWriters!");
}
this->_log->trace("Setting up Richards model");
// create richards simulations
_richards = std::make_unique<RichardsSimulation>(_inifile_richards,grid_creator,helper);
......
......@@ -65,21 +65,21 @@ using Cube = Dune::Dorie::RichardsTransportCouplingSimulationTraits<Dune::Dorie:
const std::string adapt_policy_str = inifile.get<std::string>("adaptivity.policy");
const int FEorder_richards = richards_config.get<int>("numerics.FEorder");
const int FEorder_transport = transport_config.get<int>("numerics.FEorder");
const std::string outputPath_richards = richards_config.get<std::string>("output.outputPath");
const std::string outputPath_transport = transport_config.get<std::string>("output.outputPath");
auto path_richards = richards_config.get<std::string>("output.outputPath");
auto path_transport = transport_config.get<std::string>("output.outputPath");
// Attempt to create output directory
log->info("Creating output directory: {}", outputPath_richards);
mkdir(outputPath_richards.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
int result = access(outputPath_richards.c_str(), W_OK);
log->info("Creating output directory: {}", path_richards);
mkdir(path_richards.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
int result = access(path_richards.c_str(), W_OK);
if (result != 0)
DUNE_THROW(Dune::IOError,"Output folder " << outputPath_richards << " not writable");
DUNE_THROW(Dune::IOError,"Output folder " << path_richards << " not writable");
log->info("Creating output directory: {}", outputPath_transport);
mkdir(outputPath_transport.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
result = access(outputPath_transport.c_str(), W_OK);
log->info("Creating output directory: {}", path_transport);
mkdir(path_transport.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
result = access(path_transport.c_str(), W_OK);
if (result != 0)
DUNE_THROW(Dune::IOError,"Output folder " << outputPath_transport << " not writable");
DUNE_THROW(Dune::IOError,"Output folder " << path_transport << " not writable");
Dune::Dorie::AdaptivityPolicy adapt_policy = Dune::Dorie::AdaptivityPolicy::None;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment