STORMM Source Documentation
Loading...
Searching...
No Matches
tricubic_cell.h
1// -*-c++-*-
2#ifndef STORMM_TRICUBIC_CELL_H
3#define STORMM_TRICUBIC_CELL_H
4
5#include <vector>
6#include "copyright.h"
7#include "Accelerator/hybrid.h"
8#include "Constants/behavior.h"
9#include "Constants/scaling.h"
10#include "DataTypes/common_types.h"
11#include "DataTypes/stormm_vector_types.h"
12#include "Parsing/parse.h"
13#include "Reporting/error_format.h"
14#include "math_enumerators.h"
15#include "matrix_ops.h"
16
17namespace stormm {
18namespace stmath {
19
20using card::Hybrid;
21using card::HybridTargetLevel;
22using constants::CartesianDimension;
23using constants::UnitCellAxis;
24using data_types::isFloatingPointScalarType;
25
31public:
32
35 TricubicStencil(Interpolant kind_in = Interpolant::SMOOTHNESS);
36
43 TricubicStencil(const TricubicStencil &original) = default;
44 TricubicStencil(TricubicStencil &&original) = default;
45 TricubicStencil& operator=(const TricubicStencil &original) = default;
46 TricubicStencil& operator=(TricubicStencil &&original) = default;
48
50 Interpolant getKind() const;
51
55 const double* data(HybridTargetLevel tier = HybridTargetLevel::HOST) const;
56
57#ifdef STORMM_USE_HPC
58# ifdef STORMM_USE_CUDA
60 const double* getDeviceViewToHostData() const;
61# endif
62
64 void upload();
65
67 void download();
68#endif
69
71 std::vector<double> exportMatrix() const;
72
73private:
74 Interpolant kind;
75 Hybrid<double> transform;
77};
78
81template <typename T> class TricubicCell {
82public:
83
98
99 TricubicCell(const TricubicStencil weights_matrix, const std::vector<double> &bounds,
100 const std::vector<T> &f_in, const std::vector<T> &dx_in,
101 const std::vector<T> &dy_in, const std::vector<T> &dz_in,
102 const std::vector<T> &dxx_in, const std::vector<T> &dxy_in,
103 const std::vector<T> &dxz_in, const std::vector<T> &dyy_in,
104 const std::vector<T> &dyz_in, const std::vector<T> &dxxx_in,
105 const std::vector<T> &dxxy_in, const std::vector<T> &dxxz_in,
106 const std::vector<T> &dxyy_in, const std::vector<T> &dxyz_in);
107
108 TricubicCell(const TricubicStencil weights_matrix, const std::vector<double> &bounds,
109 const std::vector<T> &f_in, const std::vector<T> &dx_in,
110 const std::vector<T> &dy_in, const std::vector<T> &dz_in,
111 const std::vector<T> &dxy_in, const std::vector<T> &dxz_in,
112 const std::vector<T> &dyz_in, const std::vector<T> &dxyz_in);
114
120 T getCoefficient(int i, int j, int k) const;
121
126 std::vector<T> getCoefficients() const;
127
132 void setCoefficient(T value, int i, int j, int k);
133
138 T getData(FunctionLevel kind, int i, int j, int k) const;
139
141 void setData(T value, FunctionLevel kind, int i, int j, int k);
142
146 T getCellOrigin(CartesianDimension dim) const;
147
151 T getCellLength(CartesianDimension dim) const;
152
164 void fractionalPosition(T x, T y, T z, T *a_frac, T *b_frac, T *c_frac,
165 ExceptionResponse policy = ExceptionResponse::SILENT,
166 const char* caller = nullptr) const;
167
175 T evaluate(T x, T y, T z) const;
176
180 template <typename T3> T3 derivative(T x, T y, T z) const;
181
193 void secondDerivative(T x, T y, T z, T* result) const;
194 void secondDerivative(T x, T y, T z, std::vector<T> *result) const;
195 std::vector<T> secondDerivative(T x, T y, T z) const;
197
209 void thirdDerivative(T x, T y, T z, T* result) const;
210 void thirdDerivative(T x, T y, T z, std::vector<T> *result) const;
211 std::vector<T> thirdDerivative(T x, T y, T z) const;
213
214private:
215 T coefficients[64];
217
218 // The following arrays store their series of values in "Fortran" order: (X0, Y0, Z0),
219 // (X1, Y0, Z0), (X0, Y1, Z0), (X1, Y1, Z0), (X0, Y0, Z1), ...
220 T f[8];
221 T dx[8];
222 T dy[8];
223 T dz[8];
224 T dxx[8];
226 T dxy[8];
227 T dxz[8];
228 T dyy[8];
230 T dyz[8];
231 T dxxx[8];
233 T dxxy[8];
235 T dxxz[8];
237 T dxyy[8];
239 T dxyz[8];
240
241 // The grid cell boundaries are stored in double precision for accuracy considerations.
242 double origin_x;
243 double origin_y;
244 double origin_z;
245
248 double umat[9];
249
253 double invu[9];
254};
255
272double3 stencilInternalOffset(UnitCellAxis face_normal, int a_index, int b_index, int c_index,
273 const double* invu);
274
275double3 stencilInternalOffset(int a_index, int b_index, int c_index, const double* invu);
277
297void incorporateStencilOrigin(const int95_t orig_x, const int95_t orig_y, const int95_t orig_z,
298 const double3 pt_xyz, double scale_factor, int95_t *point_x,
299 int95_t *point_y, int95_t *point_z);
300
301template <typename T>
302void incorporateStencilOrigin(T orig_x, T orig_y, T orig_z, const double3 pt_xyz,
303 double scale_factor, T *point_x, T *point_y, T *point_z);
305
319template <typename T>
320void fvStencilCoordinates(T orig_x, T orig_y, T orig_z, double scale_factor,
321 UnitCellAxis face_normal, int a_index, int b_index, int c_index,
322 const double* invu, T *point_x, T *point_y, T *point_z);
323
324template <typename T>
325void fvStencilCoordinates(T orig_x, T orig_y, T orig_z, double scale_factor, int a_index,
326 int b_index, int c_index, const double* invu, T *point_x,
327 T *point_y, T *point_z);
328
329template <typename T>
330void fvStencilCoordinates(T orig_x, T orig_y, T orig_z, UnitCellAxis face_normal, int a_index,
331 int b_index, int c_index, const double* invu, T *point_x, T *point_y,
332 T *point_z);
333
334template <typename T>
335void fvStencilCoordinates(T orig_x, T orig_y, T orig_z, int a_index, int b_index, int c_index,
336 const double* invu, T *point_x, T *point_y, T *point_z);
338
339} // namespace stmath
340} // namespace stormm
341
342#include "tricubic_cell.tpp"
343
344#endif
An evolution of GpuBuffer in pmemd.cuda, the Composite array has elements that are accessible from ei...
Definition hybrid.h:202
void setCoefficient(T value, int i, int j, int k)
Set one of the 64 coefficients Aijk for the tricubic spline. Parameter descriptions follow from above...
void thirdDerivative(T x, T y, T z, T *result) const
Evaluate the second derivatives of a tricubic mesh element at a point and return the results along Ca...
T getCoefficient(int i, int j, int k) const
Retrieve one of the 64 coefficients Aijk for the tricubic spline.
T3 derivative(T x, T y, T z) const
Evaluate the first derivatives of a tricubic mesh element at a point and return the results along Car...
std::vector< T > getCoefficients() const
Get a Standard Template Library vector containing all coefficients in the element....
void setData(T value, FunctionLevel kind, int i, int j, int k)
Set one of the data items. Parameter descriptions follow from above.
T getCellOrigin(CartesianDimension dim) const
Get the cell origin along one dimension.
void fractionalPosition(T x, T y, T z, T *a_frac, T *b_frac, T *c_frac, ExceptionResponse policy=ExceptionResponse::SILENT, const char *caller=nullptr) const
Get the fractional position of a point in Cartesian coordinates within a mesh cell....
TricubicCell()
The constructor can take nothing and simply initialize all values to zero, or accept the tricubic wei...
T getData(FunctionLevel kind, int i, int j, int k) const
Get one of the data points from the boundary. Parameter descriptions follow from above,...
T evaluate(T x, T y, T z) const
Evaluate the function at a specific point in space. This will take into account the grid cell's origi...
void secondDerivative(T x, T y, T z, T *result) const
Evaluate the second derivatives of a tricubic mesh element at a point and return the results along Ca...
T getCellLength(CartesianDimension dim) const
Get the cell length along one dimension.
A bundle of a 64 x 64 matrix, encoding the transformation of function values and derivatives at a ste...
Definition tricubic_cell.h:30
TricubicStencil(Interpolant kind_in=Interpolant::SMOOTHNESS)
The constructor accepts the stencil type. Dimensions of the matrix and the geometry of each stencil o...
Definition tricubic_cell.cpp:9
std::vector< double > exportMatrix() const
Export the matrix as a Standard-Template Library vector.
Definition tricubic_cell.cpp:165
const double * data(HybridTargetLevel tier=HybridTargetLevel::HOST) const
Get a pointer to the matrix data on the host or device.
Definition tricubic_cell.cpp:141
Interpolant getKind() const
Get the type of interpolant.
Definition tricubic_cell.cpp:136
TricubicStencil(const TricubicStencil &original)=default
The copy and move constructors as well as assignment operators can all take their default forms....
Definition stormm_vector_types.h:117
A mixed tuple for 95-bit integer accumulation. This is the proper way to take double-precision floati...
Definition stormm_vector_types.h:265