From 59a32fb3a8a8548c9df3668373c9b5c6f5235fee Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 22 Apr 2021 08:06:58 -0600 Subject: [PATCH] Check whether the output directory exists. --- examples/step-70/step-70.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/step-70/step-70.cc b/examples/step-70/step-70.cc index 011964a3e1..720055aa72 100644 --- a/examples/step-70/step-70.cc +++ b/examples/step-70/step-70.cc @@ -144,6 +144,7 @@ namespace LA #endif #include +#include #include #include #include @@ -769,8 +770,11 @@ namespace Step70 // In the constructor, we create the mpi_communicator as well as // the triangulations and dof_handler for both the fluid and the solid. - // Using the mpi_communicator, both the ConditionalOStream and TimerOutput + // Using the `mpi_communicator`, both the ConditionalOStream and TimerOutput // object are constructed. + // + // In the constructor, we also check whether the output directory + // specified in the input file exists and, if not, create it. template StokesImmersedProblem::StokesImmersedProblem( const StokesImmersedProblemParameters &par) @@ -792,7 +796,17 @@ namespace Step70 Triangulation::smoothing_on_coarsening)) , fluid_dh(fluid_tria) , solid_dh(solid_tria) - {} + { + if (std::filesystem::exists(par.output_directory)) + { + Assert(std::filesystem::is_directory(par.output_directory), + ExcMessage("You specified <" + par.output_directory + + "> as the output directory in the input file, " + "but this is not in fact a directory.")); + } + else + std::filesystem::create_directory(par.output_directory); + } // In order to generate the grid, we first try to use the functions in the -- 2.39.5