diff --git a/ProcessLib/Output.cpp b/ProcessLib/Output.cpp index 501da2484c5d3c6bdecabc58b053c04c14621faf..62c3bcfed13af015b4b0b1346588ef284ffe46bb 100644 --- a/ProcessLib/Output.cpp +++ b/ProcessLib/Output.cpp @@ -165,13 +165,6 @@ void Output::doOutputAlways(Process const& process, const double t, GlobalVector const& x) { - // For the staggered scheme for the coupling, only the last process, which - // gives the latest solution within a coupling loop, is allowed to make - // output. - if(process_id != static_cast<int>(_single_process_data.size()) - 1 && - !process.isMonolithicSchemeUsed()) - return; - BaseLib::RunTime time_output; time_output.start(); @@ -185,17 +178,29 @@ void Output::doOutputAlways(Process const& process, std::string const output_file_path = BaseLib::joinPaths(_output_directory, output_file_name); - DBUG("output to %s", output_file_path.c_str()); + // For the staggered scheme for the coupling, only the last process, which + // gives the latest solution within a coupling loop, is allowed to make + // output. + const bool make_output = + process_id == static_cast<int>(_single_process_data.size()) - 1 || + process.isMonolithicSchemeUsed(); + if (make_output) + { + DBUG("output to %s", output_file_path.c_str()); + } - doProcessOutput(output_file_path, _output_file_compression, + // Need to add variables of process to vtu even no output takes place. + doProcessOutput(output_file_path, make_output, _output_file_compression, _output_file_data_mode, t, x, process.getMesh(), process.getDOFTable(), process.getProcessVariables(), process.getSecondaryVariables(), process_output); - spd_ptr->pvd_file.addVTUFile(output_file_name, t); - - INFO("[time] Output of timestep %d took %g s.", timestep, - time_output.elapsed()); + if (make_output) + { + spd_ptr->pvd_file.addVTUFile(output_file_name, t); + INFO("[time] Output of timestep %d took %g s.", timestep, + time_output.elapsed()); + } } void Output::doOutput(Process const& process, @@ -244,13 +249,6 @@ void Output::doOutputNonlinearIteration(Process const& process, return; } - // For the staggered scheme for the coupling, only the last process, which - // gives the latest solution within a coupling loop, is allowed to make - // output. - if((process_id != static_cast<int>(_single_process_data.size()) - 1 && - !process.isMonolithicSchemeUsed())) - return; - BaseLib::RunTime time_output; time_output.start(); @@ -264,13 +262,27 @@ void Output::doOutputNonlinearIteration(Process const& process, + "_nliter_" + std::to_string(iteration) + ".vtu"; std::string const output_file_path = BaseLib::joinPaths(_output_directory, output_file_name); - DBUG("output iteration results to %s", output_file_path.c_str()); - doProcessOutput(output_file_path, _output_file_compression, + + // For the staggered scheme for the coupling, only the last process, which + // gives the latest solution within a coupling loop, is allowed to make + // output. + const bool make_output = + process_id == static_cast<int>(_single_process_data.size()) - 1 || + process.isMonolithicSchemeUsed(); + if (make_output) + { + DBUG("output iteration results to %s", output_file_path.c_str()); + } + + doProcessOutput(output_file_path, make_output, _output_file_compression, _output_file_data_mode, t, x, process.getMesh(), process.getDOFTable(), process.getProcessVariables(), process.getSecondaryVariables(), process_output); - INFO("[time] Output took %g s.", time_output.elapsed()); + if (make_output) + { + INFO("[time] Output took %g s.", time_output.elapsed()); + } } } // namespace ProcessLib diff --git a/ProcessLib/ProcessOutput.cpp b/ProcessLib/ProcessOutput.cpp index 8b1217477ec8ce13454ff92d34e16d23e183e8d2..e00be2d809a93887705d3994d916896187c19fb8 100644 --- a/ProcessLib/ProcessOutput.cpp +++ b/ProcessLib/ProcessOutput.cpp @@ -41,6 +41,7 @@ ProcessOutput::ProcessOutput(BaseLib::ConfigTree const& output_config) } void doProcessOutput(std::string const& file_name, + bool const make_output, bool const compress_output, int const data_mode, const double t, @@ -225,6 +226,11 @@ void doProcessOutput(std::string const& file_name, (void)t; #endif // USE_PETSC + if (!make_output) + { + return; + } + // Write output file DBUG("Writing output to \'%s\'.", file_name.c_str()); MeshLib::IO::VtuInterface vtu_interface(&mesh, data_mode, compress_output); diff --git a/ProcessLib/ProcessOutput.h b/ProcessLib/ProcessOutput.h index c44b9833008e46f1180cb8e4e5217d08039eafc4..e55172a364f0fa9cba35e04e36dc4dd71a16d5b2 100644 --- a/ProcessLib/ProcessOutput.h +++ b/ProcessLib/ProcessOutput.h @@ -33,6 +33,7 @@ struct ProcessOutput final /// See Output::_output_file_data_mode documentation for the data_mode /// parameter. void doProcessOutput(std::string const& file_name, + bool const make_output, bool const compress_output, int const data_mode, const double t,