preCICE v3.1.2
Loading...
Searching...
No Matches
TXTWriter.cpp
Go to the documentation of this file.
1#include "TXTWriter.hpp"
2#include <iomanip>
4
5namespace precice::io {
6
8 const std::string &filename)
9 : _file()
10{
11 _file.open(filename);
12 PRECICE_CHECK(_file, "TXT writer failed to open file \"{}\"", filename);
13
14 _file.setf(std::ios::showpoint);
15 _file.setf(std::ios::fixed);
17}
18
20{
21 _file.flush();
22}
23
24void TXTWriter::write(const Eigen::MatrixXd &matrix)
25{
26 for (long i = 0; i < matrix.rows(); i++) {
27 for (long j = 0; j < matrix.cols(); j++) {
28 _file << matrix(i, j) << ' ';
29 }
30 }
31 _file << '\n';
32}
33
34} // namespace precice::io
#define PRECICE_CHECK(check,...)
Definition LogMacros.hpp:35
TXTWriter(const std::string &filename)
Constructor, opens file and sets format.
Definition TXTWriter.cpp:7
void flush()
Flush the buffer to file.
Definition TXTWriter.cpp:19
void write(const Eigen::MatrixXd &matrix)
Writes (appends) the matrix to the file.
Definition TXTWriter.cpp:24
std::ofstream _file
Definition TXTWriter.hpp:31
T flush(T... args)
provides Import and Export of the coupling mesh and data.
T open(T... args)
T setf(T... args)
T setprecision(T... args)