STORMM Source Documentation
Loading...
Searching...
No Matches
condensate.h
1// -*-c++-*-
2#ifndef STORMM_CONDENSATE_H
3#define STORMM_CONDENSATE_H
4
5#include <typeinfo>
6#include <typeindex>
7#include <sys/types.h>
8#include "copyright.h"
9#include "Accelerator/gpu_details.h"
10#include "Accelerator/hybrid.h"
11#include "Accelerator/hybrid_util.h"
12#include "Constants/behavior.h"
13#include "Constants/hpc_bounds.h"
14#include "DataTypes/common_types.h"
15#include "Math/rounding.h"
16#include "Math/series_ops.h"
17#include "Topology/atomgraph_abstracts.h"
18#include "Trajectory/coordinateframe.h"
19#include "Trajectory/coordinate_series.h"
20#include "phasespace_synthesis.h"
21#include "synthesis_enumerators.h"
22
23namespace stormm {
24namespace synthesis {
25
26using card::default_hpc_format;
27using card::GpuDetails;
28using card::Hybrid;
29using card::HybridFormat;
30using card::HybridTargetLevel;
31using constants::CartesianDimension;
32using constants::PrecisionModel;
33using stmath::incrementingSeries;
34using stmath::roundUp;
35using topology::UnitCellType;
36using trajectory::CoordinateFrame;
37using trajectory::CoordinateSeries;
38using trajectory::CoordinateSeriesReader;
39
44
47 CondensateBorders(int system_count_in, const size_t* atom_starts_in, const int* atom_counts_in);
48
52 CondensateBorders(const CondensateBorders &original) = default;
53 CondensateBorders(CondensateBorders &&other) = default;
55
56 const int system_count;
58 const size_t* atom_starts;
59 const int* atom_counts;
60};
61
65
67 CondensateWriter(PrecisionModel mode_in, StructureSource basis_in, int system_count_in,
68 UnitCellType unit_cell_in, const size_t* atom_starts_in,
69 const int* atom_counts_in, float* xcrd_sp, float* ycrd_sp, float* zcrd_sp,
70 double* xcrd, double* ycrd, double* zcrd, double* umat_in, double* invu_in,
71 double* boxdim_in);
72
78 CondensateWriter(const CondensateWriter &original) = default;
79 CondensateWriter(CondensateWriter &&original) = default;
81
82 const PrecisionModel mode;
83 const StructureSource basis;
84 const int system_count;
85 const UnitCellType unit_cell;
86 const size_t* atom_starts;
87 const int* atom_counts;
88 float* xcrd_sp;
89 float* ycrd_sp;
90 float* zcrd_sp;
91 double* xcrd;
92 double* ycrd;
93 double* zcrd;
94 double* umat;
95 double* invu;
96 double* boxdims;
97};
98
103
107 CondensateReader(PrecisionModel mode_in, StructureSource basis_in, int system_count_in,
108 UnitCellType unit_cell_in, const size_t* atom_starts_in,
109 const int* atom_counts_in, const float* xcrd_sp, const float* ycrd_sp,
110 const float* zcrd_sp, const double* xcrd, const double* ycrd,
111 const double* zcrd, const double* umat_in, const double* invu_in,
112 const double* boxdim_in);
113
114 CondensateReader(const CondensateWriter &cdw);
116
122 CondensateReader(const CondensateReader &original) = default;
123 CondensateReader(CondensateReader &&original) = default;
125
126 const PrecisionModel mode;
127 const StructureSource basis;
128 const int system_count;
129 const UnitCellType unit_cell;
130 const size_t* atom_starts;
131 const int* atom_counts;
132 const float* xcrd_sp;
133 const float* ycrd_sp;
134 const float* zcrd_sp;
135 const double* xcrd;
136 const double* ycrd;
137 const double* zcrd;
138 const double* umat;
139 const double* invu;
140 const double* boxdims;
141};
142
147public:
148
158 Condensate(HybridFormat format_in = default_hpc_format);
159
160 Condensate(const PhaseSpaceSynthesis *poly_ps_in, PrecisionModel mode_in,
161 const GpuDetails &gpu = null_gpu);
162
163 Condensate(const PhaseSpaceSynthesis &poly_ps_in, PrecisionModel mode_in,
164 const GpuDetails &gpu = null_gpu);
165
166 template <typename T>
167 Condensate(const CoordinateSeries<T> *cs_in, PrecisionModel mode_in,
168 const GpuDetails &gpu = null_gpu);
169
170 template <typename T>
171 Condensate(const CoordinateSeries<T> &cs_in, PrecisionModel mode_in,
172 const GpuDetails &gpu = null_gpu);
174
183 Condensate(const Condensate &original);
184 Condensate(Condensate &&original);
185 Condensate& operator=(const Condensate &original);
186 Condensate& operator=(Condensate &&original);
188
190 HybridFormat getFormat() const;
191
193 PrecisionModel getMode() const;
194
196 StructureSource getBasis() const;
197
199 int getSystemCount() const;
200
202 bool ownsCoordinates() const;
203
207 size_t getAtomOffset(int system_index) const;
208
212 int getAtomCount(int system_index) const;
213
215 size_t getCoordinateSeriesTypeID() const;
216
220 template <typename T>
222
225
230 CoordinateFrame exportCoordinateFrame(int system_index,
231 HybridTargetLevel tier = HybridTargetLevel::HOST) const;
232
238 std::vector<double>
239 getInterlacedCoordinates(int system_index,
240 HybridTargetLevel tier = HybridTargetLevel::HOST) const;
241
244 const Condensate* getSelfPointer() const;
245
254 const CondensateReader data(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
255 CondensateWriter data(HybridTargetLevel tier = HybridTargetLevel::HOST);
257
264 const CondensateBorders borders(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
265
266#ifdef STORMM_USE_HPC
274 const CondensateReader deviceViewToHostData() const;
275 CondensateWriter deviceViewToHostData();
277
279 void upload();
280
282 void download();
283
295 void launchCondensateUpdate(const GpuDetails &gpu);
297#endif
298
307 void rebuild(const PhaseSpaceSynthesis *poly_ps_in,
308 PrecisionModel mode_in = PrecisionModel::SINGLE, const GpuDetails &gpu = null_gpu);
309
310 void rebuild(const PhaseSpaceSynthesis &poly_ps_in,
311 PrecisionModel mode_in = PrecisionModel::SINGLE, const GpuDetails &gpu = null_gpu);
312
313 template <typename T>
314 void rebuild(const CoordinateSeries<T> *cs_in,
315 const PrecisionModel mode_in = PrecisionModel::SINGLE,
316 const GpuDetails &gpu = null_gpu);
318
330 void update(HybridTargetLevel tier = HybridTargetLevel::HOST, const GpuDetails &gpu = null_gpu);
331
332 template <typename T>
333 void update(const CoordinateSeries<T> *cs_basis,
334 HybridTargetLevel tier = HybridTargetLevel::HOST, const GpuDetails &gpu = null_gpu);
335
336 template <typename T>
337 void update(const CoordinateSeries<T> &cs_basis,
338 HybridTargetLevel tier = HybridTargetLevel::HOST, const GpuDetails &gpu = null_gpu);
340
341private:
342 HybridFormat format;
344 PrecisionModel mode;
346 StructureSource basis;
348 int system_count;
349 UnitCellType unit_cell;
350 bool holds_own_data;
357 size_t csptr_data_type;
362 Hybrid<size_t> atom_starts;
366 Hybrid<int> atom_counts;
371 Hybrid<float> x_coordinates_sp;
372 Hybrid<float> y_coordinates_sp;
373 Hybrid<float> z_coordinates_sp;
374 Hybrid<double> x_coordinates;
375 Hybrid<double> y_coordinates;
376 Hybrid<double> z_coordinates;
377 Hybrid<double> box_transforms;
378 Hybrid<double> inv_transforms;
380 Hybrid<double> box_dimensions;
382
383 // Pointers to the original coordinate objects
384 PhaseSpaceSynthesis *pps_ptr;
389 CoordinateSeries<int> *cs_ptr;
395
396 // ARRAY-kind Hybrid objects targeted by POINTER-kind Hybrids of like types above
397 Hybrid<float> float_data;
398 Hybrid<double> double_data;
399
402 void repairPointers();
403
407 void validateSystemIndex(int index) const;
408};
409
411static const size_t condensate_type_index = std::type_index(typeid(Condensate)).hash_code();
412
413} // namespace synthesis
414} // namespace stormm
415
416#include "condensate.tpp"
417
418// As with common types and STORMM vector types, define the type indices for general use in the
419// STORMM namespace.
420namespace stormm {
421using synthesis::condensate_type_index;
422} // namespace stormm
423
424#endif
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
Condensate(HybridFormat format_in=default_hpc_format)
Definition condensate.cpp:55
Condense the data format, and possibly offer a reduced representation of coordinates,...
Definition condensate.h:146
const CondensateBorders borders(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the read-only summary of the system sizes. The data is never needed in as a collection of device ...
Definition condensate.cpp:466
const Condensate * getSelfPointer() const
Get a pointer to the original object, useful if a pointer is needed but the object was passed into a ...
Definition condensate.cpp:439
std::vector< double > getInterlacedCoordinates(int system_index, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Produce the interlaced coordinates of a specific system. As is the case with other coordinate objects...
Definition condensate.cpp:365
void rebuild(const PhaseSpaceSynthesis *poly_ps_in, PrecisionModel mode_in=PrecisionModel::SINGLE, const GpuDetails &gpu=null_gpu)
Rebuild the object using a different PhaseSpaceSynthesis or CoordinateSeries, and possibly a new comp...
Definition condensate.cpp:528
size_t getAtomOffset(int system_index) const
Get the starting index of atoms for one of the systems, using its index.
Definition condensate.cpp:243
int getAtomCount(int system_index) const
Get the number of atoms in one of the systems, using its index.
Definition condensate.cpp:248
const CoordinateSeries< T > * getSeriesPointer() const
Get a const pointer to the original coordinate series. The developer must supply the template type fo...
size_t getCoordinateSeriesTypeID() const
Get the data type of the CoordinateSeries upon which this object is based.
Definition condensate.cpp:253
Condensate(HybridFormat format_in=default_hpc_format)
Definition condensate.cpp:55
bool ownsCoordinates() const
Get an indication of whether the Condensate keeps its own copy of the coordinates.
Definition condensate.cpp:238
void update(HybridTargetLevel tier=HybridTargetLevel::HOST, const GpuDetails &gpu=null_gpu)
Reload the coordinates based on an updated coordinate synthesis or series, without re-computing the b...
Definition condensate.cpp:625
PrecisionModel getMode() const
Get the compression mode.
Definition condensate.cpp:223
const CondensateReader data(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get the appropriate abstract based on the const-ness of the object.
Definition condensate.cpp:444
CoordinateFrame exportCoordinateFrame(int system_index, HybridTargetLevel tier=HybridTargetLevel::HOST) const
Export a single frame as double-precision coordinates.
Definition condensate.cpp:263
const PhaseSpaceSynthesis * getSynthesisPointer() const
Get a const pointer to the original coordinate synthesis.
Definition condensate.cpp:258
HybridFormat getFormat() const
Get the memory layout of the object.
Definition condensate.cpp:218
int getSystemCount() const
Get the number of systems found in the condensate.
Definition condensate.cpp:233
StructureSource getBasis() const
Get the basis for the coordinates in the object: synthesis or series.
Definition condensate.cpp:228
A fixed-precision representation of coordinates, velocities, and forces to manage a set of simulation...
Definition phasespace_synthesis.h:325
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
const double * ycrd
Double-precision Cartesian Y coordinates.
Definition condensate.h:136
const double * zcrd
Double-precision Cartesian Z coordinates.
Definition condensate.h:137
const float * xcrd_sp
Single-precision Cartesian X coordinates.
Definition condensate.h:132
const float * zcrd_sp
Single-precision Cartesian Z coordinates.
Definition condensate.h:134
CondensateReader(PrecisionModel mode_in, StructureSource basis_in, int system_count_in, UnitCellType unit_cell_in, const size_t *atom_starts_in, const int *atom_counts_in, const float *xcrd_sp, const float *ycrd_sp, const float *zcrd_sp, const double *xcrd, const double *ycrd, const double *zcrd, const double *umat_in, const double *invu_in, const double *boxdim_in)
The constructor takes a straight list of all relevant constants and pointers. One overloaded form acc...
Definition condensate.cpp:32
const float * ycrd_sp
Single-precision Cartesian Y coordinates.
Definition condensate.h:133
const double * xcrd
Double-precision Cartesian X coordinates.
Definition condensate.h:135
float * zcrd_sp
Single-precision Cartesian Z coordinates.
Definition condensate.h:90
double * ycrd
Double-precision Cartesian Y coordinates.
Definition condensate.h:92
double * xcrd
Double-precision Cartesian X coordinates.
Definition condensate.h:91
float * ycrd_sp
Single-precision Cartesian Y coordinates.
Definition condensate.h:89
float * xcrd_sp
Single-precision Cartesian X coordinates.
Definition condensate.h:88
double * zcrd
Double-precision Cartesian Z coordinates.
Definition condensate.h:93
CondensateWriter(PrecisionModel mode_in, StructureSource basis_in, int system_count_in, UnitCellType unit_cell_in, const size_t *atom_starts_in, const int *atom_counts_in, float *xcrd_sp, float *ycrd_sp, float *zcrd_sp, double *xcrd, double *ycrd, double *zcrd, double *umat_in, double *invu_in, double *boxdim_in)
The constructor takes a straight list of all relevant constants and pointers.
Definition condensate.cpp:19
A read-only abstract for the system demarcations in the object. This information is sometimes critica...
Definition condensate.h:43
const size_t * atom_starts
Starting indices for the atoms of each system.
Definition condensate.h:58
CondensateBorders(int system_count_in, const size_t *atom_starts_in, const int *atom_counts_in)
The constructor accepts the total number of systems as well as pointers to the number of atoms and st...
Definition condensate.cpp:13
const int system_count
Definition condensate.h:56
CondensateBorders(const CondensateBorders &original)=default
Copy and move constructors–as with any object containing const members, the move assignment operator ...
const int * atom_counts
Atom counts for each system.
Definition condensate.h:59
Read-only abstract for the Condensate class. In most cases, the read-only abstract will be preferred ...
Definition condensate.h:102
const double * ycrd
Double-precision Cartesian Y coordinates.
Definition condensate.h:136
const double * zcrd
Double-precision Cartesian Z coordinates.
Definition condensate.h:137
const double * invu
Inverse box transform information for all systems.
Definition condensate.h:139
const UnitCellType unit_cell
The type of unit cell, common to all systems.
Definition condensate.h:129
const size_t * atom_starts
Starting indices of each system's atoms in the data arrays.
Definition condensate.h:130
const double * boxdims
Box dimensions for all systems.
Definition condensate.h:140
const float * xcrd_sp
Single-precision Cartesian X coordinates.
Definition condensate.h:132
const StructureSource basis
The original material on which the original object is based.
Definition condensate.h:127
const float * zcrd_sp
Single-precision Cartesian Z coordinates.
Definition condensate.h:134
CondensateReader(PrecisionModel mode_in, StructureSource basis_in, int system_count_in, UnitCellType unit_cell_in, const size_t *atom_starts_in, const int *atom_counts_in, const float *xcrd_sp, const float *ycrd_sp, const float *zcrd_sp, const double *xcrd, const double *ycrd, const double *zcrd, const double *umat_in, const double *invu_in, const double *boxdim_in)
The constructor takes a straight list of all relevant constants and pointers. One overloaded form acc...
Definition condensate.cpp:32
const float * ycrd_sp
Single-precision Cartesian Y coordinates.
Definition condensate.h:133
const double * xcrd
Double-precision Cartesian X coordinates.
Definition condensate.h:135
const double * umat
Box transform information for all systems.
Definition condensate.h:138
const int system_count
The number of systems held by the underlying Condensate.
Definition condensate.h:128
const PrecisionModel mode
The compression mode.
Definition condensate.h:126
CondensateReader(const CondensateReader &original)=default
The usual copy and move constructors aply for an abstract, with copy and move assignment operators be...
const int * atom_counts
Number of atoms in each system.
Definition condensate.h:131
Writeable abstract for the Condensate class, wherein coordinates (only) can be modified as a conseque...
Definition condensate.h:64
float * zcrd_sp
Single-precision Cartesian Z coordinates.
Definition condensate.h:90
const int * atom_counts
Number of atoms in each system.
Definition condensate.h:87
double * ycrd
Double-precision Cartesian Y coordinates.
Definition condensate.h:92
double * xcrd
Double-precision Cartesian X coordinates.
Definition condensate.h:91
float * ycrd_sp
Single-precision Cartesian Y coordinates.
Definition condensate.h:89
float * xcrd_sp
Single-precision Cartesian X coordinates.
Definition condensate.h:88
double * zcrd
Double-precision Cartesian Z coordinates.
Definition condensate.h:93
CondensateWriter(const CondensateWriter &original)=default
The usual copy and move constructors aply for an abstract, with copy and move assignment operators be...
const int system_count
The number of systems held by the underlying Condensate.
Definition condensate.h:84
double * invu
Inverse box transform information for all systems.
Definition condensate.h:95
const UnitCellType unit_cell
The type of unit cell, common to all systems.
Definition condensate.h:85
double * boxdims
Box dimensions for all systems.
Definition condensate.h:96
const StructureSource basis
The original material on which the original object is based.
Definition condensate.h:83
const size_t * atom_starts
Starting indices of each system's atoms in the data arrays.
Definition condensate.h:86
CondensateWriter(PrecisionModel mode_in, StructureSource basis_in, int system_count_in, UnitCellType unit_cell_in, const size_t *atom_starts_in, const int *atom_counts_in, float *xcrd_sp, float *ycrd_sp, float *zcrd_sp, double *xcrd, double *ycrd, double *zcrd, double *umat_in, double *invu_in, double *boxdim_in)
The constructor takes a straight list of all relevant constants and pointers.
Definition condensate.cpp:19
double * umat
Box transform information for all systems.
Definition condensate.h:94
const PrecisionModel mode
The compression mode.
Definition condensate.h:82