preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Export.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <string_view>
5#include <vector>
6
7namespace precice::mesh {
8class Mesh;
9}
10
11namespace precice::io {
12
14class Export {
15public:
16 virtual ~Export() = default;
17
18 enum struct ExportKind : bool {
21 };
22
24 std::string_view participantName,
25 std::string_view location,
26 const mesh::Mesh &mesh,
27 ExportKind kind,
28 int frequency,
29 int rank,
30 int size)
31 : _participantName(participantName),
32 _location(location),
33 _mesh(&mesh),
34 _kind(kind),
35 _frequency(frequency),
36 _rank(rank),
37 _size(size) {};
38
39 Export(const Export &) = delete;
40 Export(Export &&) = delete;
41 Export &operator=(const Export &) = delete;
42 Export &operator=(Export &&) = delete;
43
50 virtual void doExport(int index, double time) = 0;
51
52 virtual void exportSeries() const = 0;
53
54protected:
55 bool isParallel() const;
56
57 std::string formatIndex(int index) const;
58
59 bool keepExport(int index) const
60 {
61 return (_kind == ExportKind::Iterations) || ((_frequency > 0) && (index % _frequency == 0));
62 }
63
66 const mesh::Mesh *const _mesh;
69 int _rank;
70 int _size;
71
72 struct Record {
74 double time;
75 };
76
78
79 void writeSeriesFile(std::string_view filename) const;
80
81 void recordExport(std::string filename, double time);
82};
83
84} // namespace precice::io
unsigned int index
Abstract base class of all classes exporting container data structures.
Definition Export.hpp:14
Export(std::string_view participantName, std::string_view location, const mesh::Mesh &mesh, ExportKind kind, int frequency, int rank, int size)
Definition Export.hpp:23
virtual void doExport(int index, double time)=0
Export the mesh and writes files.
void writeSeriesFile(std::string_view filename) const
Definition Export.cpp:21
std::string _location
Definition Export.hpp:65
Export(Export &&)=delete
bool isParallel() const
Definition Export.cpp:7
Export & operator=(const Export &)=delete
void recordExport(std::string filename, double time)
Definition Export.cpp:44
std::string _participantName
Definition Export.hpp:64
const mesh::Mesh *const _mesh
Definition Export.hpp:66
bool keepExport(int index) const
Definition Export.hpp:59
virtual void exportSeries() const =0
Export(const Export &)=delete
ExportKind _kind
Definition Export.hpp:67
std::vector< Record > _records
Definition Export.hpp:77
std::string formatIndex(int index) const
Definition Export.cpp:12
Export & operator=(Export &&)=delete
virtual ~Export()=default
Container and creator for meshes.
Definition Mesh.hpp:38
provides Import and Export of the coupling mesh and data.
provides Mesh, Data and primitives.