OGS
XdmfWriter.cpp
Go to the documentation of this file.
1
10#include "XdmfWriter.h"
11
12#include <fstream>
13
14#include "BaseLib/Logging.h"
15#include "BaseLib/RunTime.h"
16#include "writeXdmf.h"
17
18namespace MeshLib::IO
19{
20XdmfWriter::XdmfWriter(std::string xdmf_filename,
21 std::function<std::string(std::vector<double>)>
22 xdmf_writer_fn)
23 : filename(std::move(xdmf_filename)), xdmf_writer(xdmf_writer_fn)
24{
25}
26
28{
29 BaseLib::RunTime time_output;
30 time_output.start();
31 std::ofstream fout;
32 fout.open(filename);
33 fout << xdmf_writer(times);
34
35 INFO("[time] Output of XDMF to {:s} took {:g} s.",
37 time_output.elapsed());
38}
39
40void XdmfWriter::addTimeStep(double const& time_step)
41{
42 times.push_back(time_step);
43}
44
45} // namespace MeshLib::IO
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
Definition of the RunTime class.
Collects and holds all metadata for writing XDMF file.
Count the running time.
Definition RunTime.h:29
double elapsed() const
Get the elapsed time in seconds.
Definition RunTime.h:42
void start()
Start the timer.
Definition RunTime.h:32
std::function< std::string(std::vector< double >)> xdmf_writer
Definition XdmfWriter.h:47
std::vector< double > times
Definition XdmfWriter.h:46
XdmfWriter(std::string xdmf_filename, std::function< std::string(std::vector< double >)> xdmf_writer_fn)
Writes xdmf string into file on class destruction.
void addTimeStep(double const &time_step)
Adds data for lazy (xdmf) writing algorithm.
write_xdmf generates a function based on spatial mesh data. The generated function finally generates ...