Skip to content
Snippets Groups Projects
Commit d0ea102c authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[PL] restructured Output class

parent fe4fc9d2
No related branches found
No related tags found
No related merge requests found
......@@ -86,25 +86,20 @@ newInstance(const BaseLib::ConfigTree &config, std::string const& output_directo
return out;
}
void Output::
initialize(Output::ProcessIter first, const Output::ProcessIter& last)
void Output::addProcess(ProcessLib::Process const& process, const unsigned pcs_idx)
{
for (unsigned pcs_idx = 0; first != last; ++first, ++pcs_idx)
{
auto const filename = _output_file_prefix
+ "_pcs_" + std::to_string(pcs_idx)
+ ".pvd";
_single_process_data.emplace(std::piecewise_construct,
std::forward_as_tuple(&**first),
std::forward_as_tuple(pcs_idx, filename));
}
auto const filename =
_output_file_prefix + "_pcs_" + std::to_string(pcs_idx) + ".pvd";
_single_process_data.emplace(std::piecewise_construct,
std::forward_as_tuple(&process),
std::forward_as_tuple(pcs_idx, filename));
}
void Output::
doOutputAlways(Process const& process,
unsigned timestep,
const double t,
GlobalVector const& x)
void Output::doOutputAlways(Process const& process,
ProcessOutput const& process_output,
unsigned timestep,
const double t,
GlobalVector const& x)
{
BaseLib::RunTime time_output;
time_output.start();
......@@ -122,33 +117,36 @@ doOutputAlways(Process const& process,
+ "_t_" + std::to_string(t)
+ ".vtu";
DBUG("output to %s", output_file_name.c_str());
process.output(output_file_name, timestep, x);
doProcessOutput(output_file_name, x, process.getMesh(),
process.getDOFTable(), process.getProcessVariables(),
process.getSecondaryVariables(), process_output);
spd.pvd_file.addVTUFile(output_file_name, t);
INFO("[time] Output took %g s.", time_output.elapsed());
}
void Output::
doOutput(Process const& process,
unsigned timestep,
const double t,
GlobalVector const& x)
void Output::doOutput(Process const& process,
ProcessOutput const& process_output,
unsigned timestep,
const double t,
GlobalVector const& x)
{
if (shallDoOutput(timestep, _repeats_each_steps))
doOutputAlways(process, timestep, t, x);
doOutputAlways(process, process_output, timestep, t, x);
}
void Output::
doOutputLastTimestep(Process const& process,
unsigned timestep,
const double t,
GlobalVector const& x)
void Output::doOutputLastTimestep(Process const& process,
ProcessOutput const& process_output,
unsigned timestep,
const double t,
GlobalVector const& x)
{
if (!shallDoOutput(timestep, _repeats_each_steps))
doOutputAlways(process, timestep, t, x);
doOutputAlways(process, process_output, timestep, t, x);
}
void Output::doOutputNonlinearIteration(Process const& process,
ProcessOutput const& process_output,
const unsigned timestep, const double t,
GlobalVector const& x,
const unsigned iteration) const
......@@ -172,7 +170,9 @@ void Output::doOutputNonlinearIteration(Process const& process,
+ "_nliter_" + std::to_string(iteration)
+ ".vtu";
DBUG("output iteration results to %s", output_file_name.c_str());
process.output(output_file_name, timestep, x);
doProcessOutput(output_file_name, x, process.getMesh(),
process.getDOFTable(), process.getProcessVariables(),
process.getSecondaryVariables(), process_output);
INFO("[time] Output took %g s.", time_output.elapsed());
}
......
......@@ -13,6 +13,7 @@
#include "BaseLib/ConfigTree.h"
#include "MeshLib/IO/VtkIO/PVDFile.h"
#include "Process.h"
#include "ProcessOutput.h"
namespace ProcessLib
{
......@@ -29,38 +30,33 @@ public:
newInstance(const BaseLib::ConfigTree& config,
const std::string& output_directory);
using ProcessIter = std::vector<std::unique_ptr<ProcessLib::Process>>
::const_iterator;
//! Opens a PVD file for each process.
void initialize(ProcessIter first, const ProcessIter& last);
//! TODO doc. Opens a PVD file for each process.
void addProcess(ProcessLib::Process const& process, const unsigned pcs_idx);
//! Writes output for the given \c process if it should be written in the
//! given \c timestep.
void doOutput(
Process const& process, unsigned timestep,
const double t,
GlobalVector const& x);
void doOutput(Process const& process, ProcessOutput const& process_output,
unsigned timestep, const double t, GlobalVector const& x);
//! Writes output for the given \c process if it has not been written yet.
//! This method is intended for doing output after the last timestep in order
//! to make sure that its results are written.
void doOutputLastTimestep(
Process const& process, unsigned timestep,
const double t,
GlobalVector const& x);
void doOutputLastTimestep(Process const& process,
ProcessOutput const& process_output,
unsigned timestep, const double t,
GlobalVector const& x);
//! Writes output for the given \c process.
//! This method will always write.
//! It is intended to write output in error handling routines.
void doOutputAlways(
Process const& process, unsigned timestep,
const double t,
GlobalVector const& x);
void doOutputAlways(Process const& process,
ProcessOutput const& process_output, unsigned timestep,
const double t, GlobalVector const& x);
//! Writes output for the given \c process.
//! To be used for debug output after an iteration of the nonlinear solver.
void doOutputNonlinearIteration(Process const& process,
ProcessOutput const& process_output,
const unsigned timestep, const double t,
GlobalVector const& x,
const unsigned iteration) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment