Pteros  2.0
Molecular modeling library for human beings!
grid.h
1 /*
2  * This file is a part of
3  *
4  * ============================================
5  * ### Pteros molecular modeling library ###
6  * ============================================
7  *
8  * https://github.com/yesint/pteros
9  *
10  * (C) 2009-2021, Semen Yesylevskyy
11  *
12  * All works, which use Pteros, should cite the following papers:
13  *
14  * 1. Semen O. Yesylevskyy, "Pteros 2.0: Evolution of the fast parallel
15  * molecular analysis library for C++ and python",
16  * Journal of Computational Chemistry, 2015, 36(19), 1480–1488.
17  * doi: 10.1002/jcc.23943.
18  *
19  * 2. Semen O. Yesylevskyy, "Pteros: Fast and easy to use open-source C++
20  * library for molecular analysis",
21  * Journal of Computational Chemistry, 2012, 33(19), 1632–1636.
22  * doi: 10.1002/jcc.22989.
23  *
24  * This is free software distributed under Artistic License:
25  * http://www.opensource.org/licenses/artistic-license-2.0.php
26  *
27 */
28 
29 
30 #pragma once
31 
32 #include <Eigen/Core>
33 #include <vector>
34 #include <deque>
35 #include "pteros/core/selection.h"
36 #include <unsupported/Eigen/CXX11/Tensor>
37 
38 namespace pteros {
39 
40  class GridCell {
41  public:
42  void add_point(int ind, Vector3f_const_ref crd);
43  void clear();
44  int get_index(int i) const {return indexes[i];}
45  const std::vector<int>& get_indexes() const {return indexes;}
46  Eigen::Vector3f get_coord(int i) const {return coords[i];}
47  size_t size() const {return indexes.size();}
48 
49  Eigen::Vector3f get_average_coord();
50 
51  private:
52  std::vector<int> indexes;
53  std::vector<Eigen::Vector3f> coords;
54  };
55 
74  class Grid {
75  public:
76  Grid(){}
77  Grid(int X, int Y, int Z){ resize(X,Y,Z); }
78  virtual ~Grid(){}
79 
80  void clear();
81  void resize(int X, int Y, int Z);
82  GridCell& cell(int i, int j, int k){ return data(i,j,k); }
83  GridCell& cell(Vector3i_const_ref ind){ return data(ind(0),ind(1),ind(2)); }
84  const GridCell& cell(Vector3i_const_ref ind) const { return data(ind(0),ind(1),ind(2)); }
85 
87  void populate(const Selection& sel,bool abs_index = false);
88 
89  void populate(const Selection& sel,
90  Vector3f_const_ref min,
91  Vector3f_const_ref max,
92  bool abs_index);
93 
95  void populate_periodic(const Selection& sel,
96  Vector3i_const_ref pbc_dims = fullPBC,
97  bool abs_index = false);
98 
99  void populate_periodic(const Selection& sel,
100  const PeriodicBox& box,
101  Vector3i_const_ref pbc_dims = fullPBC,
102  bool abs_index = false);
103  private:
104  Eigen::Tensor<GridCell,3> data;
105  };
106 
107 }
108 
109 
110 
111 
pteros::Selection
Selection class.
Definition: selection.h:65
pteros::Grid
Sorting the atoms from given selection into the cells of 3D grid with given dimensions.
Definition: grid.h:74
pteros::Grid::populate
void populate(const Selection &sel, bool abs_index=false)
Non-periodic populate.
Definition: grid.cpp:53
pteros::PeriodicBox
Class encapsulating all operations with arbitrary triclinic periodic boxes This class stores the peri...
Definition: periodic_box.h:43
pteros::Grid::populate_periodic
void populate_periodic(const Selection &sel, Vector3i_const_ref pbc_dims=fullPBC, bool abs_index=false)
Periodic populate.
Definition: grid.cpp:91