preCICE
v3.2.0
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Variables
_
a
b
c
d
e
f
h
i
m
n
p
r
s
t
Typedefs
b
d
e
g
l
m
p
r
s
t
u
v
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Variables
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
i
k
m
n
o
p
r
s
t
v
w
Enumerations
Enumerator
c
d
e
i
l
m
n
o
r
s
u
v
w
Related Symbols
Files
File List
File Members
All
_
a
b
c
d
e
g
i
j
m
n
o
p
r
s
t
v
Functions
a
b
c
g
m
p
r
s
t
v
Variables
Typedefs
Macros
b
d
m
n
p
t
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
src
io
Export.cpp
Go to the documentation of this file.
1
#include "
io/Export.hpp
"
2
#include <
filesystem
>
3
#include "
utils/fmt.hpp
"
4
5
namespace
precice::io
{
6
7
bool
Export::isParallel
()
const
8
{
9
return
_size
> 1;
10
};
7
bool
Export::isParallel
()
const
{
…
}
11
12
std::string
Export::formatIndex
(
int
index
)
const
13
{
14
if
(
index
== 0) {
15
return
"init"
;
16
}
17
using
std::string_literals::operator
""
s;
18
return
((
_kind
==
ExportKind::TimeWindows
) ?
"dt"
s :
"it"
s).append(
std::to_string
(
index
));
19
}
12
std::string
Export::formatIndex
(
int
index
)
const
{
…
}
20
21
void
Export::writeSeriesFile
(
std::string_view
filename)
const
22
{
23
if
(
_records
.empty())
24
return
;
25
26
namespace
fs
=
std::filesystem
;
27
fs::path
outfile(
_location
);
28
if
(not
_location
.
empty
()) {
29
fs::create_directories
(outfile);
30
}
31
outfile /= filename;
32
33
// Prepare filestream
34
std::ofstream
outFile(outfile.
string
(), std::ios::trunc);
35
36
outFile << R
"({ "file-series-version" : "1.0", "files" : [)";
37
38
for
(
std::size_t
i = 0; i <
_records
.size() - 1; ++i) {
39
outFile << fmt::format(R
"( {{ "name" : "{}", "time" : {} }},)",
_records
[i].filename,
_records
[i].time);
40
}
41
outFile << fmt::format(R
"( {{ "name" : "{}", "time" : {} }} ] }})",
_records
.back().filename,
_records
.back().time);
42
}
21
void
Export::writeSeriesFile
(
std::string_view
filename)
const
{
…
}
43
44
void
Export::recordExport
(
std::string
filename,
double
time)
45
{
46
_records
.push_back(
Record
{filename, time});
47
}
44
void
Export::recordExport
(
std::string
filename,
double
time) {
…
}
48
49
}
// namespace precice::io
Export.hpp
index
unsigned int index
Definition
SocketCommunication.cpp:724
std::ofstream
std::string
std::string_view
precice::io::Export::_size
int _size
Definition
Export.hpp:70
precice::io::Export::writeSeriesFile
void writeSeriesFile(std::string_view filename) const
Definition
Export.cpp:21
precice::io::Export::_location
std::string _location
Definition
Export.hpp:65
precice::io::Export::isParallel
bool isParallel() const
Definition
Export.cpp:7
precice::io::Export::recordExport
void recordExport(std::string filename, double time)
Definition
Export.cpp:44
precice::io::Export::_kind
ExportKind _kind
Definition
Export.hpp:67
precice::io::Export::_records
std::vector< Record > _records
Definition
Export.hpp:77
precice::io::Export::ExportKind::TimeWindows
@ TimeWindows
precice::io::Export::formatIndex
std::string formatIndex(int index) const
Definition
Export.cpp:12
std::filesystem::create_directories
T create_directories(T... args)
std::string::empty
T empty(T... args)
filesystem
fmt.hpp
precice::io
provides Import and Export of the coupling mesh and data.
Definition
Acceleration.hpp:10
std::filesystem
std::filesystem::path
std::size_t
std::filesystem::path::string
T string(T... args)
precice::io::Export::Record
Definition
Export.hpp:72
std::to_string
T to_string(T... args)