-
Notifications
You must be signed in to change notification settings - Fork 2
/
h5cgnsgridcoordinates.cpp
159 lines (125 loc) · 5.03 KB
/
h5cgnsgridcoordinates.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "error_macros.h"
#include "h5cgnsbase.h"
#include "h5cgnsgridcoordinates.h"
#include "h5cgnszone.h"
#include "h5util.h"
#include "iriclib_errorcodes.h"
#include "internal/iric_logger.h"
#include "private/h5cgnsgridcoordinates_impl.h"
using namespace iRICLib;
#define LABEL "GridCoordinates_t"
std::string H5CgnsGridCoordinates::label()
{
return LABEL;
}
H5CgnsGridCoordinates::H5CgnsGridCoordinates(const std::string& name, hid_t groupId, H5CgnsZone* zone) :
impl {new Impl {}}
{
impl->m_name = name;
impl->m_groupId = groupId;
impl->m_zone = zone;
}
H5CgnsGridCoordinates::~H5CgnsGridCoordinates()
{
delete impl;
}
std::string H5CgnsGridCoordinates::name() const
{
return impl->m_name;
}
int H5CgnsGridCoordinates::readCoordinatesX(std::vector<double>* values) const
{
_IRIC_LOGGER_TRACE_CALL_START("H5Util::readDataArrayValue");
int ier = H5Util::readDataArrayValue(impl->m_groupId, "CoordinateX", values);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::readDataArrayValue", ier);
if (ier == IRIC_NO_ERROR) {return ier;}
_IRIC_LOGGER_TRACE_CALL_START("H5Util::readDataArrayValue");
ier = H5Util::readDataArrayValue(impl->m_groupId, "coordinateX", values);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::readDataArrayValue", ier);
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}
int H5CgnsGridCoordinates::readCoordinatesY(std::vector<double>* values) const
{
_IRIC_LOGGER_TRACE_CALL_START("H5Util::readDataArrayValue");
int ier = H5Util::readDataArrayValue(impl->m_groupId, "CoordinateY", values);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::readDataArrayValue", ier);
if (ier == IRIC_NO_ERROR) {return ier;}
_IRIC_LOGGER_TRACE_CALL_START("H5Util::readDataArrayValue");
ier = H5Util::readDataArrayValue(impl->m_groupId, "coordinateY", values);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::readDataArrayValue", ier);
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}
int H5CgnsGridCoordinates::readCoordinatesZ(std::vector<double>* values) const
{
_IRIC_LOGGER_TRACE_CALL_START("H5Util::readDataArrayValue");
int ier = H5Util::readDataArrayValue(impl->m_groupId, "CoordinateZ", values);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::readDataArrayValue", ier);
if (ier == IRIC_NO_ERROR) {return ier;}
_IRIC_LOGGER_TRACE_CALL_START("H5Util::readDataArrayValue");
ier = H5Util::readDataArrayValue(impl->m_groupId, "coordinateZ", values);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::readDataArrayValue", ier);
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}
int H5CgnsGridCoordinates::writeCoordinatesX(const std::vector<double>& coords) const
{
_IRIC_LOGGER_TRACE_CALL_START("H5Util::createDataArray");
int ier = H5Util::createDataArray(impl->m_groupId, "CoordinateX", coords, impl->dimensions());
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::createDataArray", ier);
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}
int H5CgnsGridCoordinates::writeCoordinatesY(const std::vector<double>& coords) const
{
_IRIC_LOGGER_TRACE_CALL_START("H5Util::createDataArray");
int ier = H5Util::createDataArray(impl->m_groupId, "CoordinateY", coords, impl->dimensions());
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::createDataArray", ier);
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}
int H5CgnsGridCoordinates::writeCoordinatesZ(const std::vector<double>& coords) const
{
_IRIC_LOGGER_TRACE_CALL_START("H5Util::createDataArray");
int ier = H5Util::createDataArray(impl->m_groupId, "CoordinateZ", coords, impl->dimensions());
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5Util::createDataArray", ier);
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}
int H5CgnsGridCoordinates::copyTo(H5CgnsGridCoordinates* coords)
{
int ier;
std::vector<double> buffer;
auto dim = impl->m_zone->base()->dimension();
// copy X
_IRIC_LOGGER_TRACE_CALL_START("H5CgnsGridCoordinates::readCoordinatesX");
ier = readCoordinatesX(&buffer);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5CgnsGridCoordinates::readCoordinatesX", ier);
RETURN_IF_ERR;
_IRIC_LOGGER_TRACE_CALL_START("H5CgnsGridCoordinates::writeCoordinatesX");
ier = coords->writeCoordinatesX(buffer);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5CgnsGridCoordinates::writeCoordinatesX", ier);
RETURN_IF_ERR;
if (dim == 1) {return IRIC_NO_ERROR;}
// copy Y
_IRIC_LOGGER_TRACE_CALL_START("H5CgnsGridCoordinates::readCoordinatesY");
ier = readCoordinatesY(&buffer);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5CgnsGridCoordinates::readCoordinatesY", ier);
RETURN_IF_ERR;
_IRIC_LOGGER_TRACE_CALL_START("H5CgnsGridCoordinates::writeCoordinatesY");
ier = coords->writeCoordinatesY(buffer);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5CgnsGridCoordinates::writeCoordinatesY", ier);
RETURN_IF_ERR;
if (dim == 2) {return IRIC_NO_ERROR;}
// copy Z
_IRIC_LOGGER_TRACE_CALL_START("H5CgnsGridCoordinates::readCoordinatesZ");
ier = readCoordinatesZ(&buffer);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5CgnsGridCoordinates::readCoordinatesZ", ier);
RETURN_IF_ERR;
_IRIC_LOGGER_TRACE_CALL_START("H5CgnsGridCoordinates::writeCoordinatesZ");
ier = coords->writeCoordinatesZ(buffer);
_IRIC_LOGGER_TRACE_CALL_END_WITHVAL("H5CgnsGridCoordinates::writeCoordinatesZ", ier);
RETURN_IF_ERR;
return IRIC_NO_ERROR;
}