OpenLB 1.7
Loading...
Searching...
No Matches
CSVWriter.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Simon Großmann
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef CSV_WRITER_H
25#define CSV_WRITER_H
26
27#include <iomanip>
28#include <iostream>
29#include <vector>
30
31namespace olb {
32
33template< typename T >
34class CSV {
35public:
36
38 CSV(std::string name, char separator, std::vector<std::string> columnTags);
39 explicit CSV(std::string name = "unnamed");
40 CSV(std::string name, char separator);
41 CSV(std::string name, std::vector<std::string> columnTags);
42
47 void writeDataFile(T xValue, T yValue, const std::string& plotFileName, int precision = 16);
48 void writeDataFile(T xValue, const std::vector<T>& yValues, const std::string& plotFileName, int precision = 16);
50 void writeDataFile(T xValue, T yValue, int precision = 16);
52 void writeDataFile(T xValue,const std::vector<T>& yValues, int precision = 16);
53
56 void setColumnTags(const std::vector<std::string> columnTags, std::string& plotFileName);
57 void setColumnTags(const std::vector<std::string> columnTags);
58
60 void clearFile(std::string filename);
61 void clearFile();
62
63private:
64 std::string _name;
65 std::string _dataFile;
66 std::string _dir;
67 char _separator;
68 std::vector<std::string> _columnTags;
69
70 static constexpr int _rank {0}; // only process _rank will write output
71};
72
73
74} // namespace olb
75
76#endif
void clearFile()
Definition CSVWriter.hh:153
void writeDataFile(T xValue, T yValue, const std::string &plotFileName, int precision=16)
former datFileOut functions these functions create a datafile in the csv format in order to write in ...
Definition CSVWriter.hh:91
void setColumnTags(const std::vector< std::string > columnTags, std::string &plotFileName)
adds column tags at the beginning of the csv data file.
Definition CSVWriter.hh:119
CSV(std::string name, char separator, std::vector< std::string > columnTags)
Constructor with name for output file.
Definition CSVWriter.hh:39
Top level namespace for all of OpenLB.