-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathoutput.h
More file actions
239 lines (194 loc) · 7.79 KB
/
Copy pathoutput.h
File metadata and controls
239 lines (194 loc) · 7.79 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// Copyright 2020, the Aether Development Team (see doc/dev_team.md for members)
// Full license can be found in License.md
#ifndef INCLUDE_OUTPUT_H_
#define INCLUDE_OUTPUT_H_
#include "aether.h"
/**************************************************************
* \class Output
* \brief A containing to allow storage of variables for output
*
* Writing output is a multi-step process now:
* 1. Create a container to store the variables you want to output
* 2. Define the variables to output within the container
* 3. Store the variables
* 4. Write the output
*
* \author Aaron Ridley
* \date 2021/10/21
**************************************************************/
class OutputContainer {
public:
/**********************************************************************
\brief initialize the output container
**/
OutputContainer();
/**********************************************************************
\brief set the output type to binary
**/
void set_binary();
/**********************************************************************
\brief set output type to be netcdf
**/
void set_netcdf();
/**********************************************************************
\brief set output type to be hdf5
**/
void set_hdf5();
/**********************************************************************
\brief set the directory to output to
\param in_dir the directory name
**/
void set_directory(std::string in_dir);
/**********************************************************************
\brief set the filename to output to
\param in_filename the file name
**/
void set_filename(std::string in_filename);
/**********************************************************************
\brief store a variable to the list of variables to output
\param name name of the variable to output
\param unit units of the output
\param value the array of the data to output
**/
void store_variable(std::string name,
std::string unit,
arma_cube value);
/**********************************************************************
\brief store a variable to the list of variables to output
\param name name of the variable to output
\param long_name longer name of the variable to output
\param unit units of the output
\param value the array of the data to output
**/
void store_variable(std::string name,
std::string long_name,
std::string unit,
arma_cube value);
/**********************************************************************
\brief Get an arma_cube from the Container
\param iElement return the iElement arma_cube
**/
arma_cube get_element_value(int64_t iElement);
/**********************************************************************
\brief Get an arma_cube from the Container
\param var_to_get variable name to return the arma_cube
**/
arma_cube get_element_value(std::string var_to_get);
/**********************************************************************
\brief Get the variable name from the Container
\param iElement return the iElement name
**/
std::string get_element_name(int64_t iElement);
/**********************************************************************
\brief Get number of elements in output container
**/
int64_t get_nElements();
/**********************************************************************
\brief Get element number for specified name
\param var_to_find variable to find in the list
**/
int64_t find_element(std::string var_to_find);
/**********************************************************************
\brief set the time for the output
\param time the current time for the simulation
**/
void set_time(double time);
/**********************************************************************
\brief set the version of Aether
\param in_version the version number
**/
void set_version(float in_version);
/**********************************************************************
\brief write a file with the information in the container
**/
bool write();
/**********************************************************************
\brief write a json header file with the information in the container
**/
bool write_container_header();
/**********************************************************************
\brief write a binary file with the information in the container
**/
bool write_container_binary();
/**********************************************************************
\brief read a binary file with the information into a container
**/
bool read_container_binary();
/**********************************************************************
\brief write a netcdf file with the information in the container
**/
bool write_container_netcdf();
/**********************************************************************
\brief read from a file an load into the container
**/
bool read();
/**********************************************************************
\brief display information contained in the container
**/
void display();
/**********************************************************************
\brief read a netcdf file - put the information in the container
**/
bool read_container_netcdf();
/**********************************************************************
\brief clears the vector of variables
**/
void clear_variables();
private:
/// User can set the directory for output
std::string directory;
/// Filenames for basic types are standard, but can be set by the user.
/// The filename will be appended with _YYYYMMDD_HHMMSS.ext
std::string filename;
/// This is the container variable information
struct var_struct {
/// Name of the variable to output
std::string cName;
/// Long Name of the variable to output
std::string cLongName;
/// Unit of the variable to output
std::string cUnit;
/// 3D array of the variable to output (this can be N x M x L, or
/// 1 x M x L, or whatever, as long as it is 3D, any of the
/// dimensions can be 1):
arma_cube value;
};
/// The vector containing all of the variable information:
std::vector<var_struct> elements;
/// The time of the data
std::vector<int> itime;
/// The version of the code / data / whatever:
float version;
/// The frequency of the output for this particular container:
float dt_output;
/// This is to allow the user to select different output formats
int output_type;
/// These are the supported output types:
const int binary_type = 0;
const int netcdf_type = 1;
const int hdf5_type = 2;
};
/**********************************************************************
\brief Fills output containers and outputs them for common output types
This function takes user requested output types and fullfills them
if it understands the types. The supported output types are:
states - neutral/ion densities, bulk velocities, bulk
temperatures, and electric potential
neutrals - output all neutral densities, velocities, and temperature
ions - ion densities, (advected) ion velocities, ion temperatures,
electron temperature, electric potential
bfield - magnetic coordinates, magnetic field vector
\param neutrals all of the states for the neutrals
\param ions all of the states for the ions
\param grid The grid to define the neutrals on
\param time information about the current time
\param planet information about the planet
**/
bool output(const Neutrals &neutrals,
const Ions &ions,
const Grid &grid,
Times time,
const Planets &planet);
void output_binary_3d(std::ofstream &binary,
arma_cube value);
#endif // INCLUDE_OUTPUT_H_