|
1 | 1 | /* |
2 | | -Draft EXP ascii particle phase-space data HDF5 converter |
| 2 | +EXP ascii particle phase-space data HDF5 converter |
3 | 3 |
|
4 | 4 | This is a possible template for implementing HDF5 input files for |
5 | 5 | EXP. The code reads an ASCII file with particle data and writes it to |
@@ -128,9 +128,10 @@ void parse_particle_line(const std::string& line, |
128 | 128 | T val; |
129 | 129 |
|
130 | 130 | // Parse core PSP fields |
131 | | - if (!(iss >> data.m[particle_idx] |
132 | | - >> data.x[particle_idx] >> data.y[particle_idx] >> data.z[particle_idx] |
133 | | - >> data.u[particle_idx] >> data.v[particle_idx] >> data.w[particle_idx])) { |
| 131 | + if (!(iss |
| 132 | + >> data.m[particle_idx] |
| 133 | + >> data.x[particle_idx] >> data.y[particle_idx] >> data.z[particle_idx] |
| 134 | + >> data.u[particle_idx] >> data.v[particle_idx] >> data.w[particle_idx])) { |
134 | 135 | throw std::runtime_error("Failed to parse core fields at particle " + |
135 | 136 | std::to_string(particle_idx)); |
136 | 137 | } |
@@ -271,7 +272,8 @@ void ascii_to_hdf5_impl(const std::string& ascii_file, |
271 | 272 | // Define compression filters |
272 | 273 | DataSetCreateProps props; |
273 | 274 | hsize_t chunk = static_cast<hsize_t>(std::max(num_particles / 10, 1024)); |
274 | | - if (chunk > static_cast<hsize_t>(num_particles)) chunk = static_cast<hsize_t>(num_particles); |
| 275 | + if (chunk > static_cast<hsize_t>(num_particles)) |
| 276 | + chunk = static_cast<hsize_t>(num_particles); |
275 | 277 | props.add(Chunking(std::vector<hsize_t>{chunk})); |
276 | 278 | props.add(Shuffle()); |
277 | 279 | props.add(Deflate(4)); // This is a good compromise between |
@@ -391,9 +393,11 @@ ParticleDataVariant read_hdf5_data(const std::string& hdf5_file) |
391 | 393 |
|
392 | 394 | // Read core PSP fields |
393 | 395 | data.m = read_dataset("m"); |
| 396 | + |
394 | 397 | data.x = read_dataset("x"); |
395 | 398 | data.y = read_dataset("y"); |
396 | 399 | data.z = read_dataset("z"); |
| 400 | + |
397 | 401 | data.u = read_dataset("u"); |
398 | 402 | data.v = read_dataset("v"); |
399 | 403 | data.w = read_dataset("w"); |
|
0 commit comments