STORMM Source Documentation
Loading...
Searching...
No Matches
mesh_parameters.h
1// -*-c++-*-
2#ifndef STORMM_MESH_PARAMETERS_H
3#define STORMM_MESH_PARAMETERS_H
4
5#include <string>
6#include <vector>
7#include "copyright.h"
8#include "Constants/behavior.h"
9#include "DataTypes/common_types.h"
10#include "DataTypes/stormm_vector_types.h"
11#include "Math/math_enumerators.h"
12#include "Math/rounding.h"
13#include "Numerics/split_fixed_precision.h"
14#include "Topology/atomgraph.h"
15#include "Topology/atomgraph_abstracts.h"
16#include "Topology/atomgraph_enumerators.h"
17#include "Trajectory/coordinateframe.h"
18#include "Trajectory/coordinate_series.h"
19#include "Trajectory/phasespace.h"
20#include "structure_enumerators.h"
21
22namespace stormm {
23namespace structure {
24
25using constants::CartesianDimension;
26using constants::UnitCellAxis;
27using data_types::getStormmScalarTypeName;
28using data_types::isSignedIntegralScalarType;
29using data_types::isFloatingPointScalarType;
30using data_types::isFloatingPointHpcVectorType;
31using stmath::Interpolant;
32using stmath::roundUp;
33using topology::AtomGraph;
34using topology::NonbondedKit;
35using topology::UnitCellType;
36using trajectory::CoordinateFrame;
37using trajectory::CoordinateFrameReader;
38using trajectory::CoordinateSeries;
39using trajectory::CoordinateSeriesReader;
40using trajectory::determineUnitCellTypeByShape;
41
44constexpr int default_mesh_scaling_bits = 40;
45
48constexpr int mesh_nonoverflow_bits = 46;
49
57constexpr int max_mesh_definition_bits = 77;
58
62
64 MeshParamKit(int na_in, int nb_in, int nc_in, int95_t orig_x_in, int95_t orig_y_in,
65 int95_t orig_z_in, double scale_in, double inv_scale_in, int scale_bits_in,
66 const double* umat_in, const double* invu_in, const double* full_umat_in,
67 const double* full_invu_in, const double* widths_in, const int95_t* fp_invu_in,
68 double max_span_in, BoundaryCondition bounds_in, Interpolant stencil_kind_in,
69 UnitCellType unit_cell_in);
70
76 MeshParamKit(const MeshParamKit &original) = default;
77 MeshParamKit(MeshParamKit &&original) = default;
79
80 const int na;
81 const int nb;
82 const int nc;
86 const double scale;
88 const double inv_scale;
90 const float scale_f;
91 const float inv_scale_f;
92 const int scale_bits;
93 const double umat[9];
94 const double invu[9];
96 const double full_umat[9];
98 const double full_invu[9];
101 const double widths[3];
106 const int95_t fp_invu[9];
108 const double max_span;
110 const BoundaryCondition bounds;
111 const Interpolant stencil_kind;
113 const UnitCellType unit_cell;
116};
117
122public:
123
127 MeshParameters(int na_in, int nb_in, int nc_in, double origin_x_in, double origin_y_in,
128 double origin_z_in, const std::vector<double> &element_vectors,
129 int scale_bits_in = default_mesh_scaling_bits,
130 Interpolant stencil_kind_in = Interpolant::SMOOTHNESS);
131
133
134 MeshParameters(int na_in, int nb_in, int nc_in, double origin_x_in, double origin_y_in,
135 double origin_z_in, double element_x, double element_y, double element_z,
136 int scale_bits_in = default_mesh_scaling_bits,
137 Interpolant stencil_kind_in = Interpolant::SMOOTHNESS);
138
139 MeshParameters(int na_in, int nb_in, int nc_in, double origin_x_in, double origin_y_in,
140 double origin_z_in, double element_width,
141 int scale_bits_in = default_mesh_scaling_bits,
142 Interpolant stencil_kind_in = Interpolant::SMOOTHNESS);
144
148 MeshParameters(const MeshParameters &original) = default;
149 MeshParameters(MeshParameters &&original) = default;
150 MeshParameters& operator=(const MeshParameters &other) = default;
151 MeshParameters& operator=(MeshParameters &&other) = default;
153
164 int getAxisElementCount(UnitCellAxis dim) const;
165 int getAxisElementCount(CartesianDimension dim) const;
167
176 template <typename Tcoord> std::vector<Tcoord> getMeshOrigin() const;
177 double getMeshOrigin(CartesianDimension dim) const;
179
181 template <typename T3> T3 getMeshOriginAsTuple() const;
182
191 std::vector<int95_t> getMeshOriginAsFP() const;
192 int95_t getMeshOriginAsFP(CartesianDimension dim) const;
194
197 UnitCellType getMeshCellType() const;
198
200 BoundaryCondition getBoundaryConditions() const;
201
204 Interpolant getStencilKind() const;
205
216 template <typename Tcoord> std::vector<Tcoord> getMeshElementVector(UnitCellAxis dim) const;
217 template <typename Tcoord>
218 std::vector<Tcoord> getMeshElementVector(CartesianDimension dim) const;
220
232 template <typename T3> T3 getMeshElementVectorAsTuple(UnitCellAxis dim) const;
233 template <typename T3> T3 getMeshElementVectorAsTuple(CartesianDimension dim) const;
235
246 std::vector<int95_t> getMeshElementVectorAsFP(UnitCellAxis dim) const;
247 std::vector<int95_t> getMeshElementVectorAsFP(CartesianDimension dim) const;
249
252 template <typename Tcoord> std::vector<Tcoord> getMeshTransform() const;
253
256 template <typename Tcoord> std::vector<Tcoord> getMeshInverseTransform() const;
257
260 std::vector<int95_t> getMeshInverseTransformAsFP() const;
261
264 int getScalingBits() const;
265
267 double getScalingFactor() const;
268
270 double getInverseScalingFactor() const;
271
281 std::vector<int95_t> getAxisCoordinates(UnitCellAxis mesh_axis,
282 CartesianDimension cart_axis) const;
284
286 double getMaximumSpan() const;
287
289 std::string printDimensions() const;
290
292 MeshParamKit data() const;
293
295 const MeshParameters* getSelfPointer() const;
296
305 void setMeshDimension(int n_in, UnitCellAxis mesh_axis);
306 void setMeshDimension(const std::vector<int> &n_in);
308
319 void setOrigin(double v, CartesianDimension cart_axis);
320 void setOrigin(int95_t v, CartesianDimension cart_axis);
321 void setOrigin(const std::vector<double> &v);
322 void setOrigin(const std::vector<int95_t> &v);
324
328 void setScalingBits(int scale_bits_in);
329
331 void defineElement(const std::vector<double> &element_vectors);
332
336 void setBoundaryCondition(BoundaryCondition boundary_in);
337
342 void setStencilKind(Interpolant stencil_kind_in);
343
344private:
345 int na;
346 int nb;
347 int nc;
348 int95_t origin_x;
349 int95_t origin_y;
350 int95_t origin_z;
351 int scale_bits;
353 double scale_factor;
355 double inverse_scale_factor;
357 UnitCellType unit_cell;
358 BoundaryCondition boundary;
359 Interpolant stencil_kind;
364
369 double element_umat[9];
370
374 float sp_element_umat[9];
375
380 double element_invu[9];
381
383 float sp_element_invu[9];
384
388 double full_umat[9];
389
392 double full_invu[9];
393
398 double widths[3];
399
401 float sp_widths[3];
402
407 int95_t fp_element_invu[9];
408
410 double maximum_span;
411
413 void validateMeshDimensions() const;
414
416 void validateFixedPrecisionBits() const;
417
419 double maximumSpan() const;
420};
421
443MeshParameters getMeasurements(const AtomGraph *ag, const CoordinateFrame *cf, double padding,
444 double spacing, int scale_bits_in);
445
446MeshParameters getMeasurements(const AtomGraph *ag, const CoordinateFrame *cf,
447 const std::vector<double> &mesh_bounds, double spacing,
448 int scale_bits_in);
449
450MeshParameters getMeasurements(const AtomGraph *ag, const CoordinateFrame *cf, double padding,
451 const std::vector<double> &spacing, int scale_bits_in);
452
453template <typename Tcoord>
454MeshParameters getMeasurements(const AtomGraph &ag, const CoordinateSeries<Tcoord> &cs,
455 double padding, const std::vector<double> &spacing,
456 int scale_bits_in);
457
458MeshParameters getMeasurements(const std::vector<double> &mesh_bounds,
459 const std::vector<double> &spacing, int scale_bits_in);
461
462} // namespace structure
463} // namespace stormm
464
465#include "mesh_parameters.tpp"
466
467#endif
MeshParameters(int na_in, int nb_in, int nc_in, double origin_x_in, double origin_y_in, double origin_z_in, const std::vector< double > &element_vectors, int scale_bits_in=default_mesh_scaling_bits, Interpolant stencil_kind_in=Interpolant::SMOOTHNESS)
The constructor takes formal arguments for all member variables. Variants support triclinic and ortho...
Definition mesh_parameters.cpp:50
Encode the critical dimensions of a regular, rectilinear mesh. The locations of mesh points as well a...
Definition mesh_parameters.h:121
double getScalingFactor() const
Get the scaling factor for this mesh's fixed-precision format.
Definition mesh_parameters.cpp:197
int getAxisElementCount(UnitCellAxis dim) const
Get the number of points along one of the mesh axes.
Definition mesh_parameters.cpp:97
std::vector< int95_t > getAxisCoordinates(UnitCellAxis mesh_axis, CartesianDimension cart_axis) const
Get a vector of fixed-precision format coordinates of the line of grid points starting at the origin ...
Definition mesh_parameters.cpp:207
Interpolant getStencilKind() const
Get the type of stencil to use in producing tricubic coefficients for each mesh element.
Definition mesh_parameters.cpp:168
double getInverseScalingFactor() const
Get the inverse scaling factor for this mesh's fixed-precision format.
Definition mesh_parameters.cpp:202
std::vector< Tcoord > getMeshTransform() const
Get the entire element space matrix in any format. Real formats will have units of inverse Angstroms.
MeshParameters(const MeshParameters &original)=default
With no const members or pointers, the default copy and move constructors as well as copy and move as...
const MeshParameters * getSelfPointer() const
Get a pointer to the object itself.
Definition mesh_parameters.cpp:265
std::vector< Tcoord > getMeshElementVector(UnitCellAxis dim) const
Get the element vector along one of the unit cell axes in floating-point numbers.
T3 getMeshElementVectorAsTuple(UnitCellAxis dim) const
Get the element vector along one of the unit cell axes as a tuple of floating-point numbers.
std::vector< int95_t > getMeshElementVectorAsFP(UnitCellAxis dim) const
Get the element vector along one of the unit cell axes in fixed precision.
Definition mesh_parameters.cpp:173
std::vector< int95_t > getMeshInverseTransformAsFP() const
Get the inverse element transformation matrix in (authoritative) fixed-precision format.
Definition mesh_parameters.cpp:183
void setBoundaryCondition(BoundaryCondition boundary_in)
Set the boundary conditions in which the mesh shall operate.
Definition mesh_parameters.cpp:347
std::vector< int95_t > getMeshOriginAsFP() const
Get the Cartesian origin of the mesh in fixed-precision numbers.
Definition mesh_parameters.cpp:136
UnitCellType getMeshCellType() const
Get the type of mesh cell to understand whether the cell vectors are orthogonal to one another.
Definition mesh_parameters.cpp:158
BoundaryCondition getBoundaryConditions() const
Get the type of boundary conditions under which the mesh operates.
Definition mesh_parameters.cpp:163
void setMeshDimension(int n_in, UnitCellAxis mesh_axis)
Set the number of mesh elements along the "a", "b", or "c" axes.
Definition mesh_parameters.cpp:270
double getMaximumSpan() const
Get the maximum distance between any two vertices of the mesh element.
Definition mesh_parameters.cpp:238
void setStencilKind(Interpolant stencil_kind_in)
Set the type of stencil to be used in determining the interpolants for each mesh element.
Definition mesh_parameters.cpp:352
T3 getMeshOriginAsTuple() const
Get the Cartesian origin of the mesh as a tuple of floating-point numbers.
std::string printDimensions() const
Produce a description of the mesh element's dimensions suitable for printing.
Definition mesh_parameters.cpp:243
void defineElement(const std::vector< double > &element_vectors)
Define the basic element coordinates using three vectors in three-dimensional space.
Definition mesh_parameters.cpp:357
void setOrigin(double v, CartesianDimension cart_axis)
Set the origin's Cartesian X, Y, or Z coordinates.
Definition mesh_parameters.cpp:299
void setScalingBits(int scale_bits_in)
Set the scaling bits. This will also update the scaling factors.
Definition mesh_parameters.cpp:341
std::vector< Tcoord > getMeshInverseTransform() const
Get the inverse element transformation matrix in real-number format, with units of inverse Angstroms.
MeshParamKit data() const
Obtain the abstract for this object.
Definition mesh_parameters.cpp:258
int getScalingBits() const
Get the number of bits after the decimal in this mesh's fixed-precision coordinate representations.
Definition mesh_parameters.cpp:192
MeshParameters(int na_in, int nb_in, int nc_in, double origin_x_in, double origin_y_in, double origin_z_in, const std::vector< double > &element_vectors, int scale_bits_in=default_mesh_scaling_bits, Interpolant stencil_kind_in=Interpolant::SMOOTHNESS)
The constructor takes formal arguments for all member variables. Variants support triclinic and ortho...
Definition mesh_parameters.cpp:50
std::vector< Tcoord > getMeshOrigin() const
Get the Cartesian origin of the mesh in floating-point numbers.
A struct to hold information relating to an Amber topology. This struct's member functions are limite...
Definition atomgraph.h:50
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
A mixed tuple for 95-bit integer accumulation. This is the proper way to take double-precision floati...
Definition stormm_vector_types.h:265
MeshParamKit(int na_in, int nb_in, int nc_in, int95_t orig_x_in, int95_t orig_y_in, int95_t orig_z_in, double scale_in, double inv_scale_in, int scale_bits_in, const double *umat_in, const double *invu_in, const double *full_umat_in, const double *full_invu_in, const double *widths_in, const int95_t *fp_invu_in, double max_span_in, BoundaryCondition bounds_in, Interpolant stencil_kind_in, UnitCellType unit_cell_in)
The constructor takes arguments for all member variables.
Definition mesh_parameters.cpp:22
The abstract of a MeshParameters object is read-only (modify the original to get a new abstract if th...
Definition mesh_parameters.h:61
const float inv_scale_f
Single-precision form of inv_scale.
Definition mesh_parameters.h:91
const double full_invu[9]
Definition mesh_parameters.h:98
const double widths[3]
Definition mesh_parameters.h:101
const int nb
Number of mesh elements along the "b" (~y) axis.
Definition mesh_parameters.h:81
const int95_t orig_x
Cartesian X origin of the mesh in fixed-precision format.
Definition mesh_parameters.h:83
const int95_t orig_y
Cartesian Y origin of the mesh in fixed-precision format.
Definition mesh_parameters.h:84
const double scale
Definition mesh_parameters.h:86
const double invu[9]
Definition mesh_parameters.h:94
const Interpolant stencil_kind
Definition mesh_parameters.h:111
const double full_umat[9]
Definition mesh_parameters.h:96
const double inv_scale
Definition mesh_parameters.h:88
const int scale_bits
Bits after the decimal used in the fixed precision scaling.
Definition mesh_parameters.h:92
MeshParamKit(int na_in, int nb_in, int nc_in, int95_t orig_x_in, int95_t orig_y_in, int95_t orig_z_in, double scale_in, double inv_scale_in, int scale_bits_in, const double *umat_in, const double *invu_in, const double *full_umat_in, const double *full_invu_in, const double *widths_in, const int95_t *fp_invu_in, double max_span_in, BoundaryCondition bounds_in, Interpolant stencil_kind_in, UnitCellType unit_cell_in)
The constructor takes arguments for all member variables.
Definition mesh_parameters.cpp:22
const BoundaryCondition bounds
Boundary conditions for the mesh.
Definition mesh_parameters.h:110
const float scale_f
Single-precision form of scale.
Definition mesh_parameters.h:90
const int nc
Number of mesh elements along the "c" (~z) axis.
Definition mesh_parameters.h:82
const int95_t fp_invu[9]
Definition mesh_parameters.h:106
const double max_span
Definition mesh_parameters.h:108
const int na
Number of mesh elements along the "a" (~x) axis.
Definition mesh_parameters.h:80
const int95_t orig_z
Cartesian Z origin of the mesh in fixed-precision format.
Definition mesh_parameters.h:85
MeshParamKit(const MeshParamKit &original)=default
The default copy and move constructors will be valid for this object. Const members negate the use of...
const UnitCellType unit_cell
Definition mesh_parameters.h:113
const double umat[9]
Transformation matrix taking coordinates into element space.
Definition mesh_parameters.h:93