Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_ParticlesHDF5.H File Reference

Go to the source code of this file.

Functions

void WriteParticleRealDataHDF5 (void *data, size_t size, hid_t fid) const
 Write a contiguous chunk of real particle data to an HDF5 file.
 
void ReadParticleRealDataHDF5 (void *data, size_t size, hid_t fid)
 Read a contiguous chunk of real particle data from HDF5 file.
 
void CheckpointHDF5 (const std::string &dir, const std::string &name, const std::string &compression="None@0") const
 Writes a particle checkpoint to file, suitable for restarting.
 
void CheckpointHDF5 (const std::string &dir, const std::string &name, bool is_checkpoint, const Vector< std::string > &real_comp_names=Vector< std::string >(), const Vector< std::string > &int_comp_names=Vector< std::string >(), const std::string &compression="None@0") const
 Writes a particle checkpoint to file, suitable for restarting.
 
template<class F >
void WriteHDF5ParticleData (const std::string &dir, const std::string &name, const Vector< int > &write_real_comp, const Vector< int > &write_int_comp, const Vector< std::string > &real_comp_names, const Vector< std::string > &int_comp_names, const std::string &compression, F &&f, bool is_checkpoint=false) const
 Writes particle data to disk in the HDF5 format.
 
void CheckpointPreHDF5 ()
 Prepare metadata used by deferred HDF5 checkpoint writes.
 
void CheckpointPostHDF5 ()
 Finalize a checkpoint header handed off by CheckpointPreHDF5().
 
void RestartHDF5 (const std::string &dir, const std::string &file)
 Restart from checkpoint.
 
void RestartHDF5 (const std::string &dir, const std::string &file, bool is_checkpoint)
 Older version, for backwards compatibility.
 
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const std::string &compression) const
 This version of WritePlotFile writes all components and assigns component names.
 
template<class F , std::enable_if_t<!std::is_same_v< F, Vector< std::string > > > * = nullptr>
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const std::string &compression, F &&f) const
 This version of WritePlotFile writes all components and assigns component names.
 
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< std::string > &real_comp_names, const Vector< std::string > &int_comp_names, const std::string &compression) const
 This version of WritePlotFile writes all components and allows the user to specify the names of the components.
 
template<class F >
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< std::string > &real_comp_names, const Vector< std::string > &int_comp_names, const std::string &compression, F &&f) const
 This version of WritePlotFile writes all components and allows the user to specify the names of the components.
 
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< std::string > &real_comp_names, const std::string &compression) const
 This version of WritePlotFile writes all components and allows the user to specify the names of the components.
 
template<class F , std::enable_if_t<!std::is_same_v< F, Vector< std::string > > > * = nullptr>
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< std::string > &real_comp_names, const std::string &compression, F &&f) const
 This version of WritePlotFile writes all components and allows the user to specify the names of the components.
 
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< int > &write_real_comp, const Vector< int > &write_int_comp, const std::string &compression) const
 This version of WritePlotFile assigns component names, but allows the user to pass in a vector of ints that toggle on / off the writing of specific components.
 
template<class F >
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< int > &write_real_comp, const Vector< int > &write_int_comp, const std::string &compression, F &&f) const
 This version of WritePlotFile assigns component names, but allows the user to pass in a vector of ints that toggle on / off the writing of specific components.
 
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< int > &write_real_comp, const Vector< int > &write_int_comp, const Vector< std::string > &real_comp_names, const Vector< std::string > &int_comp_names, const std::string &compression) const
 This is the most general version of WritePlotFile, which takes component names and flags for whether to write each variable as components. Note that the user should pass in vectors containing names of all the components, whether they are written or not.
 
template<class F >
void WritePlotFileHDF5 (const std::string &dir, const std::string &name, const Vector< int > &write_real_comp, const Vector< int > &write_int_comp, const Vector< std::string > &real_comp_names, const Vector< std::string > &int_comp_names, const std::string &compression, F &&f) const
 This is the most general version of WritePlotFile, which takes component names and flags for whether to write each variable as components. Note that the user should pass in vectors containing names of all the components, whether they are written or not.
 
void WritePlotFilePreHDF5 ()
 Plotfile-friendly alias for CheckpointPreHDF5().
 
void WritePlotFilePostHDF5 ()
 Plotfile-friendly alias for CheckpointPostHDF5().
 
void WriteParticlesHDF5 (int level, hid_t grp, Vector< int > &which, Vector< int > &count, Vector< Long > &where, const Vector< int > &write_real_comp, const Vector< int > &write_int_comp, const std::string &compression, const Vector< std::map< std::pair< int, int >, IntVector > > &particle_io_flags, bool is_checkpoint) const
 Write all particles from one AMR level into the given HDF5 group.
 
template<class RTYPE >
void ReadParticlesHDF5 (hsize_t offset, hsize_t count, int grd, int lev, hid_t int_dset, hid_t real_dset, int finest_level_in_file, bool convert_ids)
 Read particle records from HDF5 datasets into a level/tile buffer.
 

Detailed Description

HDF5-specific ParticleContainer hooks (checkpointing, plotfile output, and supporting helpers shared by all particle types).

Function Documentation

◆ CheckpointHDF5() [1/2]

void CheckpointHDF5 ( const std::string &  dir,
const std::string &  name,
bool  is_checkpoint,
const Vector< std::string > &  real_comp_names = Vector< std::string >(),
const Vector< std::string > &  int_comp_names = Vector< std::string >(),
const std::string &  compression = "None@0" 
) const

Writes a particle checkpoint to file, suitable for restarting.

Parameters
dirDirectory that owns the per-type subdirectory.
nameParticle type subdirectory (e.g., "Tracer").
is_checkpointReserved for parity with ASCII checkpoints (ignored because HDF5 always writes id/cpu).
real_comp_namesOptional labels for each real component.
int_comp_namesOptional labels for each integer component.
compressionCompression scheme, e.g., "ZFP_ACCURACY@0.001".

◆ CheckpointHDF5() [2/2]

void CheckpointHDF5 ( const std::string &  dir,
const std::string &  name,
const std::string &  compression = "None@0" 
) const

Writes a particle checkpoint to file, suitable for restarting.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")

◆ CheckpointPostHDF5()

void CheckpointPostHDF5 ( )

Finalize a checkpoint header handed off by CheckpointPreHDF5().

Aggregates distributed offsets/counts, appends per-level bookkeeping, and removes empty per-file fragments when requested.

◆ CheckpointPreHDF5()

void CheckpointPreHDF5 ( )

Prepare metadata used by deferred HDF5 checkpoint writes.

Tallies particles/NextID values per level so CheckpointPostHDF5() can finish the header without revisiting particle data.

◆ ReadParticleRealDataHDF5()

void ReadParticleRealDataHDF5 ( void *  data,
size_t  size,
hid_t  fid 
)

Read a contiguous chunk of real particle data from HDF5 file.

Parameters
dataA pointer to the start of the buffer into which to read
sizeThe number of elements to read
fidThe istream from which to read the data

◆ ReadParticlesHDF5()

template<class RTYPE >
void ReadParticlesHDF5 ( hsize_t  offset,
hsize_t  count,
int  grd,
int  lev,
hid_t  int_dset,
hid_t  real_dset,
int  finest_level_in_file,
bool  convert_ids 
)
protected

Read particle records from HDF5 datasets into a level/tile buffer.

Template Parameters
RTYPEFloating-point storage type stored in the file.
Parameters
offsetStarting element offset inside the dataset.
countNumber of entries to load.
grdGrid index being populated.
levAMR level index being populated.
int_dsetHDF5 dataset handle for integer components.
real_dsetHDF5 dataset handle for real components.
finest_level_in_fileFinest level encoded in the file (for sanity checks).
convert_idsTrue when reading Version_Two_Dot_One checkpoints whose 64-bit id/cpu pairs were split into two 32-bit words and must be reassembled.

◆ RestartHDF5() [1/2]

void RestartHDF5 ( const std::string &  dir,
const std::string &  file 
)

Restart from checkpoint.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
fileThe name of the sub-directory for this particle type (i.e. "Tracer")

◆ RestartHDF5() [2/2]

void RestartHDF5 ( const std::string &  dir,
const std::string &  file,
bool  is_checkpoint 
)

Older version, for backwards compatibility.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
fileThe name of the sub-directory for this particle type (i.e. "Tracer")
is_checkpointWhether the particle id and cpu are included in the file.

◆ WriteHDF5ParticleData()

template<class F >
void WriteHDF5ParticleData ( const std::string &  dir,
const std::string &  name,
const Vector< int > &  write_real_comp,
const Vector< int > &  write_int_comp,
const Vector< std::string > &  real_comp_names,
const Vector< std::string > &  int_comp_names,
const std::string &  compression,
F &&  f,
bool  is_checkpoint = false 
) const

Writes particle data to disk in the HDF5 format.

Template Parameters
Ffunction type
Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
write_real_compfor each real component, whether or not we include that component in the file
write_int_compfor each integer component, whether or not we include that component in the file
real_comp_namesfor each real component, a name to label the data with
int_comp_namesfor each integer component, a name to label the data with
fcallable that returns whether a given particle should be written or not
is_checkpointWhether the particle id and cpu are included in the file.
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")

◆ WriteParticleRealDataHDF5()

void WriteParticleRealDataHDF5 ( void *  data,
size_t  size,
hid_t  fid 
) const

Write a contiguous chunk of real particle data to an HDF5 file.

Parameters
dataA pointer to the start of the buffer to write
sizeThe number of elements to write
fidThe HDF5 file ID

◆ WriteParticlesHDF5()

void WriteParticlesHDF5 ( int  level,
hid_t  grp,
Vector< int > &  which,
Vector< int > &  count,
Vector< Long > &  where,
const Vector< int > &  write_real_comp,
const Vector< int > &  write_int_comp,
const std::string &  compression,
const Vector< std::map< std::pair< int, int >, IntVector > > &  particle_io_flags,
bool  is_checkpoint 
) const

Write all particles from one AMR level into the given HDF5 group.

Parameters
levelAMR level whose particles are written.
grpOpen HDF5 group corresponding to level_d.
whichPlaceholder vector kept for API compatibility (unused by the HDF5 backend).
countPer-grid particle counts updated in place.
wherePlaceholder vector kept for API compatibility (unused by the HDF5 backend).
write_real_compFlags enabling each real component.
write_int_compFlags enabling each integer component.
compressionCompression string (ZFP_*, SZ, etc.).
particle_io_flagsPer-grid/tile masks returned by the filter functor.
is_checkpointReserved; the HDF5 writer always preserves id/cpu regardless of this flag.

◆ WritePlotFileHDF5() [1/10]

void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const std::string &  compression 
) const

This version of WritePlotFile writes all components and assigns component names.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")

◆ WritePlotFileHDF5() [2/10]

template<class F , std::enable_if_t<!std::is_same_v< F, Vector< std::string > > > * = nullptr>
void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const std::string &  compression,
F &&  f 
) const

This version of WritePlotFile writes all components and assigns component names.

This version also lets you pass in a functor to toggle whether each particle gets output.

Template Parameters
Ffunction type
Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")
fcallable that returns whether or not to write each particle

◆ WritePlotFileHDF5() [3/10]

void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< int > &  write_real_comp,
const Vector< int > &  write_int_comp,
const std::string &  compression 
) const

This version of WritePlotFile assigns component names, but allows the user to pass in a vector of ints that toggle on / off the writing of specific components.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
write_real_compfor each real component, whether to include that comp in the file
write_int_compfor each integer component, whether to include that comp in the file
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")

◆ WritePlotFileHDF5() [4/10]

template<class F >
void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< int > &  write_real_comp,
const Vector< int > &  write_int_comp,
const std::string &  compression,
F &&  f 
) const

This version of WritePlotFile assigns component names, but allows the user to pass in a vector of ints that toggle on / off the writing of specific components.

This version also lets you pass in a functor to toggle whether each particle gets output.

Template Parameters
Ffunction type
Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
write_real_compfor each real component, whether to include that comp in the file
write_int_compfor each integer component, whether to include that comp in the file
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")
fcallable that returns whether or not to write each particle

◆ WritePlotFileHDF5() [5/10]

void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< int > &  write_real_comp,
const Vector< int > &  write_int_comp,
const Vector< std::string > &  real_comp_names,
const Vector< std::string > &  int_comp_names,
const std::string &  compression 
) const

This is the most general version of WritePlotFile, which takes component names and flags for whether to write each variable as components. Note that the user should pass in vectors containing names of all the components, whether they are written or not.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
write_real_compfor each real component, whether to include that comp in the file
write_int_compfor each integer component, whether to include that comp in the file
real_comp_namesfor each real component, a name to label the data with
int_comp_namesfor each integer component, a name to label the data with
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")

◆ WritePlotFileHDF5() [6/10]

template<class F >
void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< int > &  write_real_comp,
const Vector< int > &  write_int_comp,
const Vector< std::string > &  real_comp_names,
const Vector< std::string > &  int_comp_names,
const std::string &  compression,
F &&  f 
) const

This is the most general version of WritePlotFile, which takes component names and flags for whether to write each variable as components. Note that the user should pass in vectors containing names of all the components, whether they are written or not.

This version also lets you pass in a functor to toggle whether each particle gets output.

Template Parameters
Ffunction type
Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
write_real_compfor each real component, whether to include that comp in the file
write_int_compfor each integer component, whether to include that comp in the file
real_comp_namesfor each real component, a name to label the data with
int_comp_namesfor each integer component, a name to label the data with
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")
fcallable that returns whether or not to write each particle

◆ WritePlotFileHDF5() [7/10]

void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< std::string > &  real_comp_names,
const std::string &  compression 
) const

This version of WritePlotFile writes all components and allows the user to specify the names of the components.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
real_comp_namesfor each real component, a name to label the data with
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")

◆ WritePlotFileHDF5() [8/10]

template<class F , std::enable_if_t<!std::is_same_v< F, Vector< std::string > > > * = nullptr>
void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< std::string > &  real_comp_names,
const std::string &  compression,
F &&  f 
) const

This version of WritePlotFile writes all components and allows the user to specify the names of the components.

This version also lets you pass in a functor to toggle whether each particle gets output.

Template Parameters
Ffunction type
Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
real_comp_namesfor each real component, a name to label the data with
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")
fcallable that returns whether or not to write each particle

◆ WritePlotFileHDF5() [9/10]

void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< std::string > &  real_comp_names,
const Vector< std::string > &  int_comp_names,
const std::string &  compression 
) const

This version of WritePlotFile writes all components and allows the user to specify the names of the components.

Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
real_comp_namesfor each real component, a name to label the data with
int_comp_namesfor each integer component, a name to label the data with
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")

◆ WritePlotFileHDF5() [10/10]

template<class F >
void WritePlotFileHDF5 ( const std::string &  dir,
const std::string &  name,
const Vector< std::string > &  real_comp_names,
const Vector< std::string > &  int_comp_names,
const std::string &  compression,
F &&  f 
) const

This version of WritePlotFile writes all components and allows the user to specify the names of the components.

This version also lets you pass in a functor to toggle whether each particle gets output.

Template Parameters
Ffunction type
Parameters
dirThe base directory into which to write (i.e. "plt00000")
nameThe name of the sub-directory for this particle type (i.e. "Tracer")
real_comp_namesfor each real component, a name to label the data with
int_comp_namesfor each integer component, a name to label the data with
compressioncompression parameter (i.e. "ZFP_ACCURACY@0.001", "SZ@sz.config")
fcallable that returns whether or not to write each particle

◆ WritePlotFilePostHDF5()

void WritePlotFilePostHDF5 ( )

Plotfile-friendly alias for CheckpointPostHDF5().

◆ WritePlotFilePreHDF5()

void WritePlotFilePreHDF5 ( )

Plotfile-friendly alias for CheckpointPreHDF5().