Pteros  2.0
Molecular modeling library for human beings!
distance_search_base.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 "pteros/core/periodic_box.h"
35 #include "pteros/core/grid.h"
36 
37 namespace pteros {
38 
39  struct PlannedPair {
40  Eigen::Vector3i c1;
41  Eigen::Vector3i c2;
42  Eigen::Vector3i wrapped;
43  };
44 
45 
46  class DistanceSearchBase {
47  protected:
48  // Min and max of the bounding box (for non-periodic case)
49  Eigen::Vector3f min,max;
50  // Current periodic box (for periodic case)
51  PeriodicBox box;
52  // Grid dimensions
53  Eigen::Vector3i Ngrid;
54  // Grids with coordinates
55  Grid grid1,grid2;
56  // Cut-off
57  float cutoff;
58  // If true absolute index rather then selection index is returned in the bond list
59  bool abs_index;
60  // Periodic dimensions
61  Eigen::Vector3i periodic_dims;
62  // Is periodicity required?
63  bool is_periodic;
64 
65  // Periodic grid size
66  void set_grid_size(const Eigen::Vector3f& min,
67  const Eigen::Vector3f& max);
68  // Non-periodic grid size
69  void set_grid_size(const PeriodicBox& box);
70  // Create single grid
71  void create_grid(const Selection &sel);
72  // Create two grids
73  void create_grids(const Selection &sel1, const Selection &sel2);
74 
75  // Neighbours stencil
76  const std::vector<Eigen::Vector3i> stencil = {
77  // Center
78  {0,0,0},{0,0,0},
79  // Edges
80  {0,0,0},{1,0,0}, //X
81  {0,0,0},{0,1,0}, //Y
82  {0,0,0},{0,0,1}, //Z
83  // Face angles
84  {0,0,0},{1,1,0}, //XY
85  {0,0,0},{1,0,1}, //XZ
86  {0,0,0},{0,1,1}, //YZ
87  // Far angle
88  {0,0,0},{1,1,1}, //XYZ
89  // Face-diagonals
90  {1,0,0},{0,1,0}, // XY
91  {1,0,0},{0,0,1}, // XZ
92  {0,1,0},{0,0,1}, // YZ
93  // Cross-diagonals
94  {1,1,0},{0,0,1}, // XY-Z
95  {1,0,1},{0,1,0}, // XZ-Y
96  {0,1,1},{1,0,0}, // YZ-X
97  };
98 
99  Eigen::Vector3i index_to_pos(int i);
100  bool process_neighbour_pair(PlannedPair &pair);
101  };
102 
103 }
104 
105 
106 
107