2#ifndef STORMM_COORDINATE_SERIES_H
3#define STORMM_COORDINATE_SERIES_H
6#include "Accelerator/gpu_details.h"
7#include "Accelerator/hybrid.h"
8#include "Accelerator/hybrid_util.h"
9#include "Constants/behavior.h"
10#include "Constants/fixed_precision.h"
11#include "Constants/hpc_bounds.h"
12#include "DataTypes/common_types.h"
13#include "FileManagement/file_enumerators.h"
14#include "FileManagement/file_listing.h"
15#include "FileManagement/file_util.h"
16#include "Math/rounding.h"
17#include "amber_ascii.h"
18#include "coordinateframe.h"
19#include "phasespace.h"
20#include "trajectory_enumerators.h"
26using card::deepRecast;
27using card::default_hpc_format;
28using card::GpuDetails;
30using card::HybridTargetLevel;
31using constants::CartesianDimension;
32using data_types::isFloatingPointScalarType;
33using data_types::isSignedIntegralScalarType;
34using diskutil::detectCoordinateFileKind;
35using diskutil::DataFormat;
36using diskutil::DrivePathType;
37using diskutil::getDrivePathType;
38using diskutil::getTrajectoryFormat;
39using numerics::default_trajpos_scale_bits;
44struct ValidCoordinateTypes {
46 ValidCoordinateTypes(
size_t double_id_in,
size_t float_id_in,
size_t short_id_in,
47 size_t int_id_in,
size_t llint_id_in);
53 ValidCoordinateTypes(ValidCoordinateTypes &&original) =
default;
54 ValidCoordinateTypes& operator=(
const ValidCoordinateTypes &original) =
default;
55 ValidCoordinateTypes& operator=(ValidCoordinateTypes &&original) =
default;
70 double gpos_scale_in,
double inv_gpos_scale_in, T* xcrd_in, T* ycrd_in,
71 T* zcrd_in,
double* umat_in,
double* invu_in,
double* boxdim_in);
103 double gpos_scale_in,
double inv_gpos_scale_in,
const T* xcrd_in,
104 const T* ycrd_in,
const T* zcrd_in,
const double* umat_in,
105 const double* invu_in,
const double* boxdim_in);
169 UnitCellType unit_cell_in = UnitCellType::NONE,
170 int globalpos_scale_bits_in = 0,
171 HybridFormat format_in = default_hpc_format);
173 explicit CoordinateSeries(
const std::string &file_name,
int atom_count_in = 0,
174 CoordinateFileKind file_kind = CoordinateFileKind::UNKNOWN,
175 const std::vector<int> &frame_numbers = {},
176 int replica_count = 1, UnitCellType unit_cell_in = UnitCellType::NONE,
177 int globalpos_scale_bits_in = 0,
178 HybridFormat format_in = default_hpc_format);
181 HybridFormat format_in = default_hpc_format);
184 HybridFormat format_in = default_hpc_format);
187 HybridFormat format_in = default_hpc_format);
190 int globalpos_scale_bits_in = 0,
191 HybridFormat format_in = default_hpc_format);
223 template <
typename Toriginal>
225 HybridFormat format_in = default_hpc_format);
261 template <
typename Treport> std::vector<Treport>
263 HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
265 template <
typename Treport> std::vector<Treport>
267 int globalpos_bits_out = -1,
268 HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
277 HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
285 HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
297 HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
316 CoordinateCycle time_point,
const GpuDetails &gpu)
const;
326 CoordinateCycle time_point, HybridTargetLevel tier)
const;
329 HybridTargetLevel tier)
const;
341 HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
350 HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
363 CoordinateFileKind output_kind = CoordinateFileKind::AMBER_CRD,
364 PrintSituation expectation = PrintSituation::UNKNOWN,
int low_index = 0,
365 int high_index = 0, HybridTargetLevel tier = HybridTargetLevel::HOST)
const;
508 int frame_index = -1);
511 int frame_index = -1);
518 TrajectoryKind kind = TrajectoryKind::POSITIONS,
519 CoordinateCycle orientation = CoordinateCycle::WHITE);
521 TrajectoryKind kind = TrajectoryKind::POSITIONS,
522 CoordinateCycle orientation = CoordinateCycle::WHITE);
524 TrajectoryKind kind = TrajectoryKind::POSITIONS,
525 CoordinateCycle orientation = CoordinateCycle::WHITE);
527 TrajectoryKind kind = TrajectoryKind::POSITIONS,
528 CoordinateCycle orientation = CoordinateCycle::WHITE);
547 CoordinateFileKind file_kind = CoordinateFileKind::UNKNOWN,
548 const std::vector<int> &frame_numbers = {},
int replica_count = 1,
549 int frame_index_start = -1);
595 void resize(
int new_frame_count,
const PhaseSpace &ps,
int atom_start = 0,
int atom_end = 0);
596 void resize(
int new_frame_count,
PhaseSpace *ps,
int atom_start = 0,
int atom_end = 0);
634 int globalpos_scale_bits;
637 UnitCellType unit_cell;
638 double globalpos_scale;
641 double inverse_globalpos_scale;
662 void allocate(
int new_frame_capacity);
699template <
typename Torig,
typename Tnew>
701 int globalpos_scale_bits_in);
706#include "coordinate_series.tpp"
Pertinent aspects of one particular GPU. Condensing the data for each GPU in this manner helps to ens...
Definition gpu_details.h:27
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
CoordinateSeries(int natom_in=0, int nframe_in=0, UnitCellType unit_cell_in=UnitCellType::NONE, int globalpos_scale_bits_in=0, HybridFormat format_in=default_hpc_format)
There are several options for constructing this collection of coordinate frames.
Store the coordinates and box information for a frame, only. This abridged struct can serve when the ...
Definition coordinateframe.h:111
Store the coordinates and box information for a series of frames, in one of several levels of precisi...
Definition coordinate_series.h:137
CoordinateSeries(const CoordinateSeries< Toriginal > &original, int globalpos_scale_bits_in=0, HybridFormat format_in=default_hpc_format)
Special copy constructor to take a CoordinateSeries of one data type into another....
const Hybrid< T > & getCoordinateReference(CartesianDimension dim) const
Get a const reference to the one of the Cartesian coordinate arrays.
const Hybrid< double > & getBoxTransforms() const
Get a const reference to the box space transformation matrices.
CoordinateSeries(int natom_in=0, int nframe_in=0, UnitCellType unit_cell_in=UnitCellType::NONE, int globalpos_scale_bits_in=0, HybridFormat format_in=default_hpc_format)
There are several options for constructing this collection of coordinate frames.
int getFrameCount() const
Get the number of frames in the series.
const CoordinateSeriesReader< T > data(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the abstract for this object, containing C-style pointers for the most rapid access to any of its...
std::vector< double > getBoxSpaceTransform(int frame_index, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the transformation matrix to take coordinates into box (fractional) space. The result should be i...
int getFrameCapacity() const
Get the maximum number of frames that the object can hold.
std::vector< double > getInverseTransform(int frame_index, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the transformation matrix to take coordinates from fractional space back into real space....
void importFrame(const CoordinateFrameReader &cfr, int atom_start, int atom_end, int frame_index=-1)
Import coordinates from a CoordinateFrame or PhaseSpace object. The original object must have the sam...
void reserve(const int new_frame_capacity)
Reserve capacity in this series. The new frames will be uninitialized.
UnitCellType getUnitCellType() const
Get the unit cell type of the coordinate system.
const Hybrid< double > * getInverseTransformPointer() const
Get a const pointer to the box space transformation matrices.
const Hybrid< T > * getCoordinatePointer(CartesianDimension dim) const
Get a const pointer to one of the Cartesian coordinate arrays.
const Hybrid< double > * getBoxTransformPointer() const
Get a const pointer to the box space transformation matrices.
void extractFrame(CoordinateFrame *cf, size_t frame_index, const GpuDetails &gpu) const
Extract coordinates to a pre-existing object.
CoordinateFrame exportFrame(size_t frame_index, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Prepare a CoordinateFrame object based on one frame of the series, accomplishing any necessary data c...
CoordinateSeries(const CoordinateSeries &original)=default
Use the default copy and move constructors, copy and move assignment operators. This object has no co...
void pushBack(const CoordinateFrameReader &cfr, int atom_start=0, int atom_end=0)
Push a coordinate set to the back of the list. This invokes the import member function after realloca...
std::vector< double > getBoxDimensions(int frame_index, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the box dimensions in their pure form for a particular frame.
void exportToFile(const std::string &file_name, CoordinateFileKind output_kind=CoordinateFileKind::AMBER_CRD, PrintSituation expectation=PrintSituation::UNKNOWN, int low_index=0, int high_index=0, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Export the contents of this coordinate series to a trajectory file.
const CoordinateSeries< T > * getSelfPointer() const
Get a const pointer to the object iself, so that it may be passed to functions by const reference and...
HybridFormat getFormat() const
Get the memory format.
const Hybrid< double > & getInverseTransforms() const
Get a const reference to the box space transformation matrices.
const Hybrid< double > * getBoxDimensionPointer() const
Get a const pointer to the list of box dimensions for all frames.
const CoordinateSeriesReader< void > templateFreeData(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the object's abstract, with all templated type pointers cast to void pointers....
const Hybrid< T > * getFramesHandle(CartesianDimension dim) const
Get a pointer to one of the coordinate arrays.
void importFromFile(const std::string &file_name, CoordinateFileKind file_kind=CoordinateFileKind::UNKNOWN, const std::vector< int > &frame_numbers={}, int replica_count=1, int frame_index_start=-1)
Import coordinates from a file. This function accepts directives to read a subset of the coordinates ...
int getAtomCount() const
Get the number of atoms in each frame of the series.
int getFixedPrecisionBits() const
Get the fixed precision bits after the decimal (if applicable, warn if the data type is non-integer).
CoordinateSeries(const CoordinateSeries &original, HybridFormat format_in)
A special copy constructor can create an object with an altered memory format.
const Hybrid< double > * getBoxTransformsHandle() const
Get a pointer to the box space transform. Overloading follows from getCoordinateHandle(),...
void shrinkToFit()
Shrink the object's various arrays to accommodate only the current frame and atom counts....
const Hybrid< double > * getInverseTransformsHandle() const
Get a pointer to the inverse transform that takes coordinates back into real space....
std::vector< Treport > getInterlacedCoordinates(int frame_index, int globalpos_bits_out=-1, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the interlaced coordinates of one frame.
PhaseSpace exportPhaseSpace(size_t frame_index, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Prepare a PhaseSpace object based on one frame of the series, accomplishing any data conversions need...
void resize(int new_frame_count)
Resize the series, allocating new capacity if needed, initializing new frames with the provided coord...
const Hybrid< double > * getBoxDimensionsHandle() const
Get a pointer to the transform that takes coordinates back into real space. Overloading follows from ...
An object to complement a topology and hold positions, velocities, and forces of all particles in a s...
Definition phasespace.h:141
CoordinateSeriesReader(int natom_in, int nframe_in, UnitCellType unit_cell_in, int gpos_bits_in, double gpos_scale_in, double inv_gpos_scale_in, const T *xcrd_in, const T *ycrd_in, const T *zcrd_in, const double *umat_in, const double *invu_in, const double *boxdim_in)
The basic constructor feeds all arguments straight to the inline initialization list....
CoordinateSeriesWriter(int natom_in, int nframe_in, UnitCellType unit_cell_in, int gpos_bits_in, double gpos_scale_in, double inv_gpos_scale_in, T *xcrd_in, T *ycrd_in, T *zcrd_in, double *umat_in, double *invu_in, double *boxdim_in)
The constructor feeds all arguments straight to the inline initialization list.
Collect C-style pointers for the elements of a read-only CoordinateFrame object.
Definition coordinateframe.h:65
Collect C-style pointers for the elements of a writable CoordinateFrame object.
Definition coordinateframe.h:30
Collect C-style pointers and critical constants for a read-only CoordinateSeries object.
Definition coordinate_series.h:96
CoordinateSeriesReader(int natom_in, int nframe_in, UnitCellType unit_cell_in, int gpos_bits_in, double gpos_scale_in, double inv_gpos_scale_in, const T *xcrd_in, const T *ycrd_in, const T *zcrd_in, const double *umat_in, const double *invu_in, const double *boxdim_in)
The basic constructor feeds all arguments straight to the inline initialization list....
const UnitCellType unit_cell
The type of unit cell (i.e. ORTHORHOMBIC, could also be NONE)
Definition coordinate_series.h:118
const int nframe
The number of frames in the series.
Definition coordinate_series.h:117
const T * zcrd
Cartesian Z coordinates of all atoms.
Definition coordinate_series.h:124
const double * umat
Definition coordinate_series.h:125
CoordinateSeriesReader(const CoordinateSeriesReader &original)=default
Copy and move constructors. The move assignment operator is implicitly deleted.
const int gpos_bits
Global position coordinate bits after the decimal.
Definition coordinate_series.h:119
const T * xcrd
Cartesian X coordinates of all atoms.
Definition coordinate_series.h:122
const double * invu
Inverse transformation matrix out of box space.
Definition coordinate_series.h:127
const double * boxdim
Box dimensions (these will be consistent with umat and invu)
Definition coordinate_series.h:128
const T * ycrd
Cartesian Y coordinates of all atoms.
Definition coordinate_series.h:123
const int natom
The number of atoms in the system.
Definition coordinate_series.h:116
const double gpos_scale
Global position coordinate scaling factor.
Definition coordinate_series.h:120
const double inv_gpos_scale
Inverse global coordinate scaling factor.
Definition coordinate_series.h:121
Collect C-style pointers and critical constants for a writeable CoordinateSeries object.
Definition coordinate_series.h:66
const double inv_gpos_scale
Inverse global coordinate scaling factor.
Definition coordinate_series.h:85
const UnitCellType unit_cell
The type of unit cell (i.e. ORTHORHOMBIC, could also be NONE)
Definition coordinate_series.h:82
double * umat
Definition coordinate_series.h:89
double * invu
Inverse transformation matrix out of box space.
Definition coordinate_series.h:91
const int natom
The number of atoms in the system.
Definition coordinate_series.h:80
T * zcrd
Cartesian Z coordinates of all atoms.
Definition coordinate_series.h:88
double * boxdim
Box dimensions (these will be consistent with umat and invu)
Definition coordinate_series.h:92
const double gpos_scale
Global position coordinate scaling factor.
Definition coordinate_series.h:84
CoordinateSeriesWriter(const CoordinateSeriesWriter &original)=default
Copy and move constructors. The move assignment operator is implicitly deleted.
const int nframe
The number of frames in the series.
Definition coordinate_series.h:81
T * ycrd
Cartesian Y coordinates of all atoms.
Definition coordinate_series.h:87
T * xcrd
Cartesian X coordinates of all atoms.
Definition coordinate_series.h:86
CoordinateSeriesWriter(int natom_in, int nframe_in, UnitCellType unit_cell_in, int gpos_bits_in, double gpos_scale_in, double inv_gpos_scale_in, T *xcrd_in, T *ycrd_in, T *zcrd_in, double *umat_in, double *invu_in, double *boxdim_in)
The constructor feeds all arguments straight to the inline initialization list.
const int gpos_bits
Global position coordinate bits after the decimal.
Definition coordinate_series.h:83
size_t llint_id
Long long (64-bit integer) data type identifier.
Definition coordinate_series.h:62
size_t short_id
Short (16-bit integer) data type identifier.
Definition coordinate_series.h:60
size_t float_id
Single-precision real data type identifier.
Definition coordinate_series.h:59
size_t double_id
Double-precision real data type identifier.
Definition coordinate_series.h:58
ValidCoordinateTypes(const ValidCoordinateTypes &original)=default
The copy and move constructors as well as assignment operators can all take their default forms for t...
size_t int_id
Typical / long (32-bit integer) data type identifier.
Definition coordinate_series.h:61