-
Notifications
You must be signed in to change notification settings - Fork 2
/
h5cgnsfilesolutionwriter.cpp
108 lines (87 loc) · 2.11 KB
/
h5cgnsfilesolutionwriter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "error_macros.h"
#include "h5cgnsfilesolutionwriter.h"
#include "h5cgnsfile.h"
#include "iriclib_errorcodes.h"
#include "private/h5cgnsfilesolutionwriter_impl.h"
#include <Poco/File.h>
using namespace iRICLib;
H5CgnsFileSolutionWriter::H5CgnsFileSolutionWriter(Mode mode, H5CgnsFile* file) :
impl {new Impl {this}}
{
impl->m_mode = mode;
impl->m_file = file;
}
H5CgnsFileSolutionWriter::~H5CgnsFileSolutionWriter()
{
delete impl;
}
int H5CgnsFileSolutionWriter::writeSolStart()
{
return impl->writeSolStart();
}
int H5CgnsFileSolutionWriter::writeTime(double time)
{
return impl->writeTime(time);
}
int H5CgnsFileSolutionWriter::writeIteration(int iteration)
{
return impl->writeIteration(iteration);
}
int H5CgnsFileSolutionWriter::writeBaseIterativeData(const std::string& name, int value)
{
return impl->writeBaseIterativeData(name, value);
}
int H5CgnsFileSolutionWriter::writeBaseIterativeData(const std::string& name, double value)
{
return impl->writeBaseIterativeData(name, value);
}
int H5CgnsFileSolutionWriter::writeBaseIterativeData(const std::string& name, const std::string value)
{
return impl->writeBaseIterativeData(name, value);
}
H5CgnsFile* H5CgnsFileSolutionWriter::targetFile() const
{
if (impl->m_mode == Mode::Standard) {
return impl->m_file;
} else {
return impl->m_targetFile;
}
}
int H5CgnsFileSolutionWriter::flush()
{
delete impl->m_targetFile;
impl->m_targetFile = nullptr;
int ier = impl->m_file->flush();
RETURN_IF_ERR;
ier = impl->m_file->close();
RETURN_IF_ERR;
Poco::File tmpFile(impl->m_file->tmpFileName());
if (tmpFile.exists()) {
try {
tmpFile.remove();
} catch (...) {
// do nothing
}
}
Poco::File tmpFolder("tmp");
if (! tmpFolder.exists()) {
tmpFolder.createDirectory();
}
Poco::File cgnsFile(impl->m_file->fileName());
cgnsFile.copyTo(impl->m_file->tmpFileName());
ier = impl->m_file->open();
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}
int H5CgnsFileSolutionWriter::close()
{
Poco::File tmpFile(impl->m_file->tmpFileName());
if (tmpFile.exists()) {
try {
tmpFile.remove();
} catch (...) {
// do nothing
}
}
return IRIC_NO_ERROR;
}