diff --git a/ProcessLib/Output/CreateOutput.cpp b/ProcessLib/Output/CreateOutput.cpp index 88487ce9da8fc1a740eb7e1ce26968fe119575c3..27bdb5fba71b9ae70841c5ec8dfeae98f3a78f13 100644 --- a/ProcessLib/Output/CreateOutput.cpp +++ b/ProcessLib/Output/CreateOutput.cpp @@ -131,17 +131,12 @@ std::unique_ptr<Output> createOutput( } } - std::vector<double> fixed_output_times; - auto fixed_output_times_ptr = + std::vector<double> fixed_output_times = //! \ogs_file_param{prj__time_loop__output__fixed_output_times} - config.getConfigParameterOptional<std::vector<double>>( - "fixed_output_times"); - if (fixed_output_times_ptr) - { - fixed_output_times = std::move(*fixed_output_times_ptr); - // Remove possible duplicated elements and sort. - BaseLib::makeVectorUnique(fixed_output_times); - } + config.getConfigParameter<std::vector<double>>("fixed_output_times", + {}); + // Remove possible duplicated elements and sort. + BaseLib::makeVectorUnique(fixed_output_times); bool const output_iteration_results = //! \ogs_file_param{prj__time_loop__output__output_iteration_results} diff --git a/ProcessLib/Output/Output.cpp b/ProcessLib/Output/Output.cpp index f18565d9e6c1217733df1efdef8859ffb5b05de0..f45fcdf93a81df3080f8c1cccc843b0e1f760572 100644 --- a/ProcessLib/Output/Output.cpp +++ b/ProcessLib/Output/Output.cpp @@ -78,30 +78,20 @@ bool Output::shallDoOutput(int timestep, double const t) } } - bool make_output = timestep % each_steps == 0; - - if (_fixed_output_times.empty()) + if (timestep % each_steps == 0) { - return make_output; + return true; } auto const fixed_output_time = std::lower_bound( cbegin(_fixed_output_times), cend(_fixed_output_times), t); if (fixed_output_time == cend(_fixed_output_times)) { - return make_output; - } - DBUG( - "Fixed time output; Found {} in list of output times for current time " - "{}.", - *fixed_output_time, t); - const double zero_threshold = std::numeric_limits<double>::min(); - if (std::fabs(*fixed_output_time - t) < zero_threshold) - { - make_output = true; + return false; } - return make_output; + return std::fabs(*fixed_output_time - t) < + std::numeric_limits<double>::min(); } Output::Output(std::string output_directory, std::string output_file_prefix, @@ -125,8 +115,12 @@ Output::Output(std::string output_directory, std::string output_file_prefix, _mesh_names_for_output(mesh_names_for_output), _meshes(meshes) { - assert( - std::is_sorted(cbegin(_fixed_output_times), cend(_fixed_output_times))); + if (!std::is_sorted(cbegin(_fixed_output_times), cend(_fixed_output_times))) + { + OGS_FATAL( + "Vector of fixed output time steps passed to the Output " + "constructor must be sorted"); + } } void Output::addProcess(ProcessLib::Process const& process,