Skip to content

Commit ba499d9

Browse files
author
Martin D. Weinberg
committed
Some more comments only
1 parent 5539761 commit ba499d9

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

exputil/ParticleReader.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,8 @@ namespace PR {
857857
T mass;
858858
T pos[3];
859859
T vel[3];
860+
T pot;
861+
T potext;
860862
hvl_t iattrib;
861863
hvl_t dattrib;
862864
};
@@ -989,8 +991,10 @@ namespace PR {
989991
hsize_t dims3[1] = {3};
990992
H5::ArrayType array3_type(type, 1, dims3);
991993

992-
compound_type.insertMember("pos", HOFFSET(H5Particle<Scalar>, pos), array3_type);
993-
compound_type.insertMember("vel", HOFFSET(H5Particle<Scalar>, vel), array3_type);
994+
compound_type.insertMember("pos", HOFFSET(H5Particle<Scalar>, pos ), array3_type);
995+
compound_type.insertMember("vel", HOFFSET(H5Particle<Scalar>, vel ), array3_type);
996+
compound_type.insertMember("pot", HOFFSET(H5Particle<Scalar>, pot ), type);
997+
compound_type.insertMember("potext", HOFFSET(H5Particle<Scalar>, potext), type);
994998
compound_type.insertMember("iattrib", HOFFSET(H5Particle<Scalar>, iattrib), H5::VarLenType(H5::PredType::NATIVE_INT));
995999
compound_type.insertMember("dattrib", HOFFSET(H5Particle<Scalar>, dattrib), H5::VarLenType(type));
9961000

@@ -1059,6 +1063,9 @@ namespace PR {
10591063
P.vel[k] = h5part[n].vel[k];
10601064
}
10611065

1066+
P.pot = h5part[n].pot;
1067+
P.potext = h5part[n].potext;
1068+
10621069
// Unpack the variable length attribute arrays
10631070
//
10641071
if (Niattrib[curindx]>0) {

src/Component.cc

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,7 @@ void Component::write_HDF5(HighFive::Group& group, bool masses, bool IDs)
22932293
auto dcplI = HighFive::DataSetCreateProps{};
22942294
auto dcplD = HighFive::DataSetCreateProps{};
22952295

2296-
if (H5compress) {
2296+
if (H5compress or H5chunk) {
22972297
int chunk = H5chunk;
22982298

22992299
// Sanity
@@ -2349,20 +2349,23 @@ template
23492349
void Component::write_HDF5<double>
23502350
(HighFive::Group& group, bool masses, bool IDs);
23512351

2352-
// Helper structure
2352+
// Helper structure for reading and writing the HDF5 compound data
2353+
// type. Used by Component and ParticleReader.
23532354
template <typename T>
23542355
struct H5Particle
23552356
{
23562357
unsigned long id;
23572358
T mass;
23582359
T pos[3];
23592360
T vel[3];
2360-
hvl_t iattrib;
2361-
hvl_t dattrib;
2361+
T pot;
2362+
T potext;
2363+
hvl_t iattrib; // HDF5 variable length
2364+
hvl_t dattrib; // HDF5 variable length
23622365
};
23632366

2364-
2365-
//! Write HDF5 phase-space structure for this nodes particles only.
2367+
// Write HDF5 phase-space structure for this nodes particles only in
2368+
// PSP style
23662369
template <typename T>
23672370
void Component::write_H5(H5::Group& group)
23682371
{
@@ -2385,8 +2388,10 @@ void Component::write_H5(H5::Group& group)
23852388
hsize_t dims3[1] = {3};
23862389
H5::ArrayType array3_type(type, 1, dims3);
23872390

2388-
compound_type.insertMember("pos", HOFFSET(H5Particle<T>, pos), array3_type);
2389-
compound_type.insertMember("vel", HOFFSET(H5Particle<T>, vel), array3_type);
2391+
compound_type.insertMember("pos", HOFFSET(H5Particle<T>, pos ), array3_type);
2392+
compound_type.insertMember("vel", HOFFSET(H5Particle<T>, vel ), array3_type);
2393+
compound_type.insertMember("pot", HOFFSET(H5Particle<T>, pot ), type);
2394+
compound_type.insertMember("potext", HOFFSET(H5Particle<T>, potext), type);
23902395
compound_type.insertMember("iattrib", HOFFSET(H5Particle<T>, iattrib), H5::VarLenType(H5::PredType::NATIVE_INT));
23912396
compound_type.insertMember("dattrib", HOFFSET(H5Particle<T>, dattrib), H5::VarLenType(type));
23922397

@@ -2407,18 +2412,20 @@ void Component::write_H5(H5::Group& group)
24072412
h5_particles[n].pos[k] = P->pos[k];
24082413
h5_particles[n].vel[k] = P->vel[k];
24092414
}
2415+
h5_particles[n].pot = P->pot;
2416+
h5_particles[n].potext = P->potext;
24102417
h5_particles[n].iattrib.len = P->iattrib.size();
24112418
h5_particles[n].dattrib.len = P->dattrib.size();
24122419
h5_particles[n].iattrib.p = P->iattrib.data();
24132420
h5_particles[n].dattrib.p = P->dattrib.data();
24142421
}
24152422

2416-
// Set properties, if requested
2423+
// Set properties, if requested for chunking and compression
24172424
H5::DSetCreatPropList dcpl;
24182425

24192426
// This could be generalized by registering a user filter, like
24202427
// blosc. Right now, we're using the default (which is gzip)
2421-
if (H5compress) {
2428+
if (H5compress or H5chunk) {
24222429
int chunk = H5chunk;
24232430

24242431
// Sanity

0 commit comments

Comments
 (0)