-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissue380.cpp
More file actions
107 lines (86 loc) · 2.57 KB
/
Copy pathissue380.cpp
File metadata and controls
107 lines (86 loc) · 2.57 KB
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
#include <openPMD/openPMD.hpp>
#include <cstddef>
#include <iostream>
#include <memory>
using std::cout;
using namespace openPMD;
class Timer
{
public:
Timer(const std::string& tag)
:m_Tag(tag)
{
m_Start = std::chrono::system_clock::now();
}
~Timer()
{
m_End = std::chrono::system_clock::now();
double millis = std::chrono::duration_cast<std::chrono::milliseconds>(m_End - m_Start).count();
double secs = millis / 1000.0;
if (secs > 0)
std::cout << " [" << m_Tag << "] took:" << secs << " seconds" << std::endl;
else
std::cout << " [" << m_Tag << "] took:" << millis << " milli seconds" << std::endl;
}
private:
std::chrono::time_point<std::chrono::system_clock> m_Start;
std::chrono::time_point<std::chrono::system_clock> m_End;
std::string m_Tag;
};
int main(int argc, char *argv[])
{
Timer total("Total:");
if (argc < 4) {
std::cout<<" Please supply a file name, type, encoding "<<std::endl;
return 0;
}
std::string fileName = argv[1];
std::string type = argv[2];
std::string encoding = argv[3];
if (encoding == "f")
fileName +="%T";
fileName += ".";
fileName +=type;
std::cout<<fileName<<std::endl;
Access readMode = Access::READ_ONLY;
if (encoding == "v")
readMode = Access::READ_LINEAR;
Timer* openTimer = new Timer("opening series: ");
std::string jsonOptions = "{}";
if (argc >= 5) {
std::string arg4str = argv[4];
if (arg4str == "lazy")
jsonOptions = "{\"defer_iteration_parsing\": true}";
}
std::cout<<"Using json option: "<<jsonOptions<<std::endl;
Series series = Series(fileName, readMode, jsonOptions);
if ( Access::READ_ONLY == readMode )
cout << "Read a Series with openPMD standard version " << series.openPMD()<< '\n';
else
cout << "Stream READ .. "<<'\n';
cout << "The Series contains " << series.iterations.size() << " iterations\n";
delete openTimer;
/*
# for it in iterations:
# begin_time = time.time()
# Ex, info_Ex = ts.get_field( 'E', coord='x', iteration=it )
# end_time = time.time()
# print(f"Time to get fields: {end_time - begin_time:.4f} s")
*/
int counter = 0;
for (auto i : series.readIterations()) {
std::string s = std::to_string(counter);
Timer g(s);
counter ++;
//Timer g( "curr step");
auto ex = i.meshes["E"]["x"];
Extent extent = ex.getExtent();
auto all_data = ex.loadChunk<double>();
i.close();
//std::cout<< all_data.get()[0]<<std::endl;
//std::cout<< all_data.get()[1]<<std::endl;
//break;
}
series.close();
return 0;
}