19#include "geom_utils.hpp"
30template<
typename AFields>
50 char *data[T::Nfields];
52 template<
typename Field>
53 static constexpr size_t get_field_idx ();
57 BaseProperties (
void *data_in_memory[T::Nfields],
size_t offset=0UL);
65 void *operator[] (
size_t idx)
const;
79 template<
typename Field>
86 using BaseProperties<
typename AFields::GroupFields>::BaseProperties;
90 GrpProperties (
size_t chunk_idx_,
void **data_in_memory,
size_t offset=0UL);
123 virtual bool grp_chunk (
size_t chunk_idx, std::string &fname)
const = 0;
135 virtual bool prt_chunk (
size_t chunk_idx, std::string &fname)
const = 0;
184 virtual void read_grp_meta (
size_t chunk_idx, std::shared_ptr<H5::H5File> fptr,
185 size_t &Ngroups)
const = 0;
202 virtual void read_prt_meta (
size_t chunk_idx, std::shared_ptr<H5::H5File> fptr,
203 coord_t &Bsize,
size_t &Nparts)
const = 0;
287template<
typename AFields>
291 for (
size_t ii=0; ii != T::Nfields; ++ii)
292 data[ii] = (
char *)(data_in_memory[ii]) + offset * T::strides_fcoord[ii];
295template<
typename AFields>
300 for (
size_t ii=0; ii != T::Nfields; ++ii)
301 data[ii] += T::strides_fcoord[ii];
304template<
typename AFields>
312template<
typename AFields>
320template<
typename AFields>
322template<
typename Field>
326 static_assert(T::field_type == Field::type);
329 return AFields::GroupFields::template idx<Field>;
331 return AFields::ParticleFields::template idx<Field>;
334template<
typename AFields>
336template<
typename Field>
340 constexpr size_t idx = get_field_idx<Field> ();
342 if constexpr (Field::dim == 1)
343 return (
typename Field::value_type) *(
typename Field::value_type *)data[idx];
345 if constexpr (Field::coord)
349 return (
typename Field::value_type *)data[idx];
352template<
typename AFields>
355 chunk_idx { chunk_idx_ }
358template<
typename AFields>
360 Callback<AFields>::template BaseProperties<typename AFields::ParticleFields> { data_in_memory, offset },
364template<
typename AFields>
365inline std::array<coord_t, 3>
368 std::array<coord_t, 3> out;
372 for (
size_t ii=0; ii != 3; ++ii)
373 out[ii] = grp_prt_detail::GeomUtils::periodic_dist(grp_coord[ii], prt_coord[ii], Bsize);
Type describing either a group or a particle.
Definition callback.hpp:47
auto get() const
Returns the individual properties.
Definition callback.hpp:338
auto coord() const
Definition callback.hpp:315
Specialization of the Callback::BaseProperties type to groups.
Definition callback.hpp:85
Templates to construct types that tell the code which data fields are to to be read from the group an...
float coord_t
Internal coordinate type.
Definition fields.hpp:28
Specialization of the Callback::BaseProperties type to particles.
Definition callback.hpp:95
The abstract base class the user should inherit from.
Definition callback.hpp:32
virtual bool grp_chunk(size_t chunk_idx, std::string &fname) const =0
Where to find the group files.
virtual void read_grp_meta_init(std::shared_ptr< H5::H5File > fptr)
Allows the user to read meta-data from the 0th group chunk.
Definition callback.hpp:161
virtual void read_grp_meta(size_t chunk_idx, std::shared_ptr< H5::H5File > fptr, size_t &Ngroups) const =0
Inform the code how many groups there are in a group chunk.
virtual coord_t grp_radius(const GrpProperties &grp) const =0
Inform the code how large this group is.
virtual bool prt_chunk(size_t chunk_idx, std::string &fname) const =0
Where to find the particle files.
virtual void prt_modify(PrtProperties &prt)
Modifications to particle properties.
Definition callback.hpp:281
virtual coord_t prt_coord_rescale() const
Rescaling of particle coordinates.
Definition callback.hpp:272
virtual void grp_action(const GrpProperties &grp)=0
Action to take for each group for which grp_select returned true.
virtual void read_prt_meta_init(std::shared_ptr< H5::H5File > fptr)
Allows the user to read meta-data from the 0th particle chunk.
Definition callback.hpp:171
virtual bool grp_select(const GrpProperties &grp) const
Inform the code whether a group should be considered.
Definition callback.hpp:215
virtual std::string prt_name() const =0
Where to find the particle fields in the hdf5 file.
virtual void read_prt_meta(size_t chunk_idx, std::shared_ptr< H5::H5File > fptr, coord_t &Bsize, size_t &Nparts) const =0
Inform the code how large the box is and how many particles there are in a particle chunk.
virtual void prt_action(size_t grp_idx, const GrpProperties &grp, const PrtProperties &prt, coord_t Rsq)=0
Action to take for each particle that falls within grp_radius from a group.
virtual std::string grp_name() const =0
Where to find the group fields in the hdf5 file.