STORMM Source Documentation
Loading...
Searching...
No Matches
coordinateframe.h
1// -*-c++-*-
2#ifndef STORMM_COORDINATE_FRAME_H
3#define STORMM_COORDINATE_FRAME_H
4
5#include <typeinfo>
6#include <typeindex>
7#include <sys/types.h>
8#include "copyright.h"
9#include "Accelerator/hybrid.h"
10#include "Accelerator/hybrid_util.h"
11#include "Constants/behavior.h"
12#include "Parsing/textfile.h"
13#include "Topology/atomgraph.h"
14#include "phasespace.h"
15#include "trajectory_enumerators.h"
16
17namespace stormm {
18namespace trajectory {
19
20using card::default_hpc_format;
21using card::Hybrid;
22using card::HybridFormat;
23using card::HybridKind;
24using card::HybridTargetLevel;
25using constants::ExceptionResponse;
26using parse::TextFile;
27using topology::AtomGraph;
28
31
38 CoordinateFrameWriter(int natom_in, UnitCellType unit_cell_in, double* xcrd_in, double* ycrd_in,
39 double* zcrd_in, double* umat_in, double* invu_in, double* boxdim_in);
40 CoordinateFrameWriter(PhaseSpace *ps, HybridTargetLevel tier = HybridTargetLevel::HOST);
41 CoordinateFrameWriter(PhaseSpace *ps, TrajectoryKind kind,
42 HybridTargetLevel tier = HybridTargetLevel::HOST);
43 CoordinateFrameWriter(PhaseSpace *ps, TrajectoryKind kind, CoordinateCycle orientation,
44 HybridTargetLevel tier = HybridTargetLevel::HOST);
46
49 CoordinateFrameWriter(const CoordinateFrameWriter &original) = default;
50 CoordinateFrameWriter(CoordinateFrameWriter &&original) = default;
52
53 const int natom;
54 const UnitCellType unit_cell;
55 double* xcrd;
56 double* ycrd;
57 double* zcrd;
58 double* umat;
60 double* invu;
61 double* boxdim;
62};
63
66
74 CoordinateFrameReader(int natom_in, UnitCellType unit_cell_in, const double* xcrd_in,
75 const double* ycrd_in, const double* zcrd_in, const double* umat_in,
76 const double* invu_in, const double* boxdim_in);
77 CoordinateFrameReader(const CoordinateFrameWriter &cfw);
78 CoordinateFrameReader(const PhaseSpace &ps, HybridTargetLevel tier = HybridTargetLevel::HOST);
79 CoordinateFrameReader(const PhaseSpace *ps, HybridTargetLevel tier = HybridTargetLevel::HOST);
80 CoordinateFrameReader(const PhaseSpace *ps, TrajectoryKind kind, CoordinateCycle orientation,
81 HybridTargetLevel tier = HybridTargetLevel::HOST);
82 CoordinateFrameReader(const PhaseSpace &ps, TrajectoryKind kind, CoordinateCycle orientation,
83 HybridTargetLevel tier = HybridTargetLevel::HOST);
84 CoordinateFrameReader(const PhaseSpace *ps, TrajectoryKind kind,
85 HybridTargetLevel tier = HybridTargetLevel::HOST);
86 CoordinateFrameReader(const PhaseSpace &ps, TrajectoryKind kind,
87 HybridTargetLevel tier = HybridTargetLevel::HOST);
89
92 CoordinateFrameReader(const CoordinateFrameReader &original) = default;
93 CoordinateFrameReader(CoordinateFrameReader &&original) = default;
95
96 const int natom;
97 const UnitCellType unit_cell;
98 const double* xcrd;
99 const double* ycrd;
100 const double* zcrd;
101 const double* umat;
103 const double* invu;
104 const double* boxdim;
105};
106
112public:
113
136 CoordinateFrame(int natom_in = 0, UnitCellType unit_cell_in = UnitCellType::NONE,
137 HybridFormat format_in = default_hpc_format);
138
139 CoordinateFrame(int natom_in, UnitCellType unit_cell_in, const double* xcrd_in,
140 const double* ycrd_in, const double* zcrd_in, const double* umat_in = nullptr,
141 const double* invu_in = nullptr, const double* boxdim_in = nullptr,
142 HybridFormat format_in = default_hpc_format);
143
144 CoordinateFrame(const std::string &file_name_in,
145 CoordinateFileKind file_kind = CoordinateFileKind::UNKNOWN,
146 int frame_number_in = 0, HybridFormat format_in = default_hpc_format);
147
148 CoordinateFrame(const TextFile &tf, CoordinateFileKind file_kind = CoordinateFileKind::UNKNOWN,
149 int frame_number_in = 0, HybridFormat format_in = default_hpc_format);
150
151 CoordinateFrame(const PhaseSpace *ps);
152
153 CoordinateFrame(const PhaseSpace &ps);
155
171 CoordinateFrame(const CoordinateFrame &original);
172 CoordinateFrame(const CoordinateFrame &original, HybridFormat format_in);
174
180
187
192
205 void buildFromFile(const std::string &file_name_in, const CoordinateFileKind file_kind,
206 int frame_number = 0);
207
208 void buildFromFile(const TextFile &tf, const CoordinateFileKind file_kind,
209 int frame_number = 0);
211
229 template <typename T>
230 void fill(const T* xcrd, const T* ycrd, const T* zcrd, int scale_bits = 0,
231 const double* box_dims = nullptr);
232
233 template <typename T>
234 void fill(const std::vector<T> &xcrd, const std::vector<T> &ycrd, const std::vector<T> &zcrd,
235 int scale_bits = 0, const std::vector<double> &box_dims = {});
237
239 HybridFormat getFormat() const;
240
242 std::string getFileName() const;
243
245 int getFrameNumber() const;
246
248 int getAtomCount() const;
249
251 UnitCellType getUnitCellType() const;
252
265 std::vector<double>
266 getInterlacedCoordinates(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
267
268 std::vector<double>
269 getInterlacedCoordinates(int low_index, int high_index,
270 HybridTargetLevel tier = HybridTargetLevel::HOST) const;
272
277 std::vector<double> getBoxSpaceTransform(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
278
283 std::vector<double> getInverseTransform(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
284
292 std::vector<double> getBoxDimensions(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
293
302 const Hybrid<double>* getCoordinateHandle(CartesianDimension dim) const;
303 Hybrid<double>* getCoordinateHandle(CartesianDimension dim);
305
312
319
326
333 const Hybrid<double>* getStorageHandle() const;
336
338 const CoordinateFrame* getSelfPointer() const;
339
350 void exportToFile(const std::string &file_name,
351 CoordinateFileKind output_kind = CoordinateFileKind::AMBER_CRD,
352 PrintSituation expectation = PrintSituation::UNKNOWN,
353 HybridTargetLevel tier = HybridTargetLevel::HOST) const;
354
362 const CoordinateFrameReader data(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
363 CoordinateFrameWriter data(HybridTargetLevel tier = HybridTargetLevel::HOST);
365
366#ifdef STORMM_USE_HPC
368 void upload();
369
371 void download();
372
381 const CoordinateFrameReader deviceViewToHostData() const;
382 CoordinateFrameWriter deviceViewToHostData();
384#endif
385
390 void setFrameNumber(int frame_number_in);
391
392private:
393 HybridFormat format;
394 std::string file_name;
395 int frame_number;
397 int atom_count;
398 UnitCellType unit_cell;
400 Hybrid<double> x_coordinates;
401 Hybrid<double> y_coordinates;
402 Hybrid<double> z_coordinates;
403 Hybrid<double> box_space_transform;
404 Hybrid<double> inverse_transform;
405 Hybrid<double> box_dimensions;
407
416 Hybrid<double> storage;
417
420 void allocate();
421};
422
424static const size_t coordinateframe_type_index =
425 std::type_index(typeid(CoordinateFrame)).hash_code();
426
440std::vector<CoordinateFrame> getSelectedFrames(const TextFile &tf, CoordinateFileKind kind,
441 int atom_count, UnitCellType unit_cell,
442 const std::vector<int> &frame_numbers);
443
444std::vector<CoordinateFrame> getSelectedFrames(const std::string &file_name, int atom_count,
445 UnitCellType unit_cell,
446 const std::vector<int> &frame_numbers);
448
461std::vector<CoordinateFrame> getAllFrames(const TextFile &tf, const int atom_count,
462 const UnitCellType unit_cell,
463 const ExceptionResponse policy);
464
465std::vector<CoordinateFrame> getAllFrames(const std::string &file_name, const int atom_count,
466 const UnitCellType unit_cell,
467 const ExceptionResponse policy);
469
470} // namespace trajectory
471} // namespace stormm
472
473#include "coordinateframe.tpp"
474
475// As with common types and STORMM vector types, define the type indices for general use in the
476// STORMM namespace.
477namespace stormm {
478using trajectory::coordinateframe_type_index;
479} // namespace stormm
480
481#endif
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
CoordinateFrame(int natom_in=0, UnitCellType unit_cell_in=UnitCellType::NONE, HybridFormat format_in=default_hpc_format)
There are several options for construction of this abridged, coordinate-only object.
Definition coordinateframe.cpp:180
Store the coordinates and box information for a frame, only. This abridged struct can serve when the ...
Definition coordinateframe.h:111
const Hybrid< double > * getStorageHandle() const
Get a pointer to the storage array accessible outside the object.
Definition coordinateframe.cpp:844
HybridFormat getFormat() const
Get the format of the object.
Definition coordinateframe.cpp:684
CoordinateFrame(int natom_in=0, UnitCellType unit_cell_in=UnitCellType::NONE, HybridFormat format_in=default_hpc_format)
There are several options for construction of this abridged, coordinate-only object.
Definition coordinateframe.cpp:180
int getFrameNumber() const
Get the frame number, if this coordinate set originated in a trajectory.
Definition coordinateframe.cpp:694
void exportToFile(const std::string &file_name, CoordinateFileKind output_kind=CoordinateFileKind::AMBER_CRD, PrintSituation expectation=PrintSituation::UNKNOWN, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Export the contents of this coordinate series to a trajectory, restart, or input coordinates file.
Definition coordinateframe.cpp:859
std::vector< double > getInterlacedCoordinates(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the coordinates returned in an X/Y/Z interlaced manner.
Definition coordinateframe.cpp:710
int getAtomCount() const
Get the number of atoms in the frame.
Definition coordinateframe.cpp:699
const CoordinateFrameReader 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...
Definition coordinateframe.cpp:935
const Hybrid< double > * getBoxDimensionsHandle() const
Get a pointer to the transform that takes coordinates back into real space. Overloading follows from ...
Definition coordinateframe.cpp:834
void setFrameNumber(int frame_number_in)
Set the frame number, for bookkeeping purposes. This function exists that the frame number does not b...
Definition coordinateframe.cpp:993
std::vector< double > getBoxDimensions(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the box dimensions in their pure form. Holding the box dimensions and the transformation matrices...
Definition coordinateframe.cpp:774
std::vector< double > getInverseTransform(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the transformation matrix to take coordinates from fractional space back into real space....
Definition coordinateframe.cpp:760
CoordinateFrame & operator=(const CoordinateFrame &other)
Copy assignment operator likewise handles reassignment of internal POINTER-kind Hybrid objects.
Definition coordinateframe.cpp:468
const Hybrid< double > * getInverseTransformHandle() const
Get a pointer to the inverse transform that takes coordinates back into real space....
Definition coordinateframe.cpp:824
UnitCellType getUnitCellType() const
Get the unit cell type of the coordinate system.
Definition coordinateframe.cpp:704
void fill(const T *xcrd, const T *ycrd, const T *zcrd, int scale_bits=0, const double *box_dims=nullptr)
Fill the object from information in three arrays.
const CoordinateFrame * getSelfPointer() const
Get a pointer to the object itself, useful when working with a const reference.
Definition coordinateframe.cpp:854
std::vector< double > getBoxSpaceTransform(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the transformation matrix to take coordinates into box (fractional) space. The result should be i...
Definition coordinateframe.cpp:746
const Hybrid< double > * getCoordinateHandle(CartesianDimension dim) const
Get a pointer to one of the coordinate arrays.
Definition coordinateframe.cpp:788
std::string getFileName() const
Get the file name that originated this coordinate set.
Definition coordinateframe.cpp:689
void buildFromFile(const std::string &file_name_in, const CoordinateFileKind file_kind, int frame_number=0)
Fill the object from information some coordinate, restart, or trajectory file.
Definition coordinateframe.cpp:535
const Hybrid< double > * getBoxTransformHandle() const
Get a pointer to the box space transform. Overloading follows from getCoordinateHandle(),...
Definition coordinateframe.cpp:814
An object to complement a topology and hold positions, velocities, and forces of all particles in a s...
Definition phasespace.h:141
CoordinateFrameReader(int natom_in, UnitCellType unit_cell_in, const double *xcrd_in, const double *ycrd_in, const double *zcrd_in, const double *umat_in, const double *invu_in, const double *boxdim_in)
The constructor feeds all arguments straight to the inline initialization list.
Definition coordinateframe.cpp:94
CoordinateFrameWriter(int natom_in, UnitCellType unit_cell_in, double *xcrd_in, double *ycrd_in, double *zcrd_in, double *umat_in, double *invu_in, double *boxdim_in)
The constructor feeds all arguments straight to the inline initialization list.
Definition coordinateframe.cpp:33
Collect C-style pointers for the elements of a read-only CoordinateFrame object.
Definition coordinateframe.h:65
CoordinateFrameReader(const CoordinateFrameReader &original)=default
Copy and move constructors. The move assignment operator is implicitly deleted.
const double * umat
Definition coordinateframe.h:101
const double * ycrd
Cartesian Y coordinates of all atoms.
Definition coordinateframe.h:99
CoordinateFrameReader(int natom_in, UnitCellType unit_cell_in, const double *xcrd_in, const double *ycrd_in, const double *zcrd_in, const double *umat_in, const double *invu_in, const double *boxdim_in)
The constructor feeds all arguments straight to the inline initialization list.
Definition coordinateframe.cpp:94
const double * xcrd
Cartesian X coordinates of all atoms.
Definition coordinateframe.h:98
const double * invu
Inverse transformation matrix out of box space.
Definition coordinateframe.h:103
const double * zcrd
Cartesian Z coordinates of all atoms.
Definition coordinateframe.h:100
const int natom
The number of atoms in the system.
Definition coordinateframe.h:96
const UnitCellType unit_cell
The type of unit cell (i.e. ORTHORHOMBIC, could also be NONE)
Definition coordinateframe.h:97
const double * boxdim
Box dimensions (these will be consistent with umat and invu)
Definition coordinateframe.h:104
Collect C-style pointers for the elements of a writable CoordinateFrame object.
Definition coordinateframe.h:30
double * invu
Inverse transformation matrix out of box space.
Definition coordinateframe.h:60
CoordinateFrameWriter(int natom_in, UnitCellType unit_cell_in, double *xcrd_in, double *ycrd_in, double *zcrd_in, double *umat_in, double *invu_in, double *boxdim_in)
The constructor feeds all arguments straight to the inline initialization list.
Definition coordinateframe.cpp:33
CoordinateFrameWriter(const CoordinateFrameWriter &original)=default
Copy and move constructors. The move assignment operator is implicitly deleted.
const int natom
The number of atoms in the system.
Definition coordinateframe.h:53
double * zcrd
Cartesian Z coordinates of all atoms.
Definition coordinateframe.h:57
const UnitCellType unit_cell
The type of unit cell (i.e. ORTHORHOMBIC, could also be NONE)
Definition coordinateframe.h:54
double * umat
Definition coordinateframe.h:58
double * boxdim
Box dimensions (these will be consistent with umat and invu)
Definition coordinateframe.h:61
double * xcrd
Cartesian X coordinates of all atoms.
Definition coordinateframe.h:55
double * ycrd
Cartesian Y coordinates of all atoms.
Definition coordinateframe.h:56