-
Notifications
You must be signed in to change notification settings - Fork 0
/
Geometry.h
159 lines (128 loc) · 3.71 KB
/
Geometry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*******************************************************************************
GPU OPTIMIZED MONTE CARLO (GOMC) 2.31
Copyright (C) 2018 GOMC Group
A copy of the GNU General Public License can be found in the COPYRIGHT.txt
along with this program, also can be found at <http://www.gnu.org/licenses/>.
********************************************************************************/
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include "BasicTypes.h"
#include "SubdividedArray.h"
#include <vector>
namespace mol_setup
{
class Atom;
class Bond;
class Angle;
class Dihedral;
class MolKind;
}
namespace ff_setup
{
class Bond;
class FFBase;
}
class FFSetup;
// for 1-5 and more interaction
struct Nonbond {
uint* part1;
uint* part2;
uint count;
virtual void Init(const mol_setup::MolKind& molData);
Nonbond();
~Nonbond();
};
// for 1-4 interaction
struct Nonbond_1_4 : public Nonbond {
virtual void Init(const mol_setup::MolKind& molData);
};
// for 1-3 interaction, used for Martini ForceField
struct Nonbond_1_3 : public Nonbond {
virtual void Init(const mol_setup::MolKind& molData);
};
// for ewald correction energy calculation
struct EwaldNonbond : public Nonbond {
virtual void Init(const mol_setup::MolKind& molData);
};
//!List of all pairs of particles in bonds.
struct BondList {
uint* part1;
uint* part2;
uint* kinds;
uint count;
void Init(const std::vector<mol_setup::Bond>& bonds);
BondList();
~BondList();
};
//!List describing a geometry feature of a molecule by the bonds it contains.
/*!Contains bond indices as used in bondlist, bonds greater than bondList.count
* represent bonds that need to be flipped to describe the feature in the same
* order as the PSF file (head to tail). Bonds are used to avoid recalcuating
* vectors
*/
class GeomFeature
{
public:
//!Prepares topology data for a geometry feature
void Init(const std::vector<mol_setup::Angle>& angles, const BondList& bList);
void Init(const std::vector<mol_setup::Dihedral>& dihs, const BondList& bList);
explicit GeomFeature(uint atomsPer);
~GeomFeature();
//Return number of features in molecule
uint Count() const
{
return count;
}
//!return bondIndex of a bond in a feature
//!/param feature index of angle/dihedral; in [0, Count)
//!/param b index of bond within feature; in [0, bondsPer)
uint GetBond(uint feature, uint b) const
{
return bondIndices[feature * bondsPer + b];
}
//!returns kind index of feature i
uint GetKind(uint i) const
{
return kinds[i];
}
private:
//number of bonds per feature e.g. dihedral = 3, angle = 2 etc
uint bondsPer;
//bond indices, size = count * bondsPer
//bonds needing reversal are represented as index + bondCount
uint* bondIndices;
//feature kind indices, size = count
uint* kinds;
//number of features. If count == 0, do not attempt to deref the arrays
uint count;
};
//List of all pairs that interact via nonbonded LJ potentials, i.e. all pairs
//that are at least 4 bonds apart.
//List of all pairs that interact via nonbonded LJ potentials, i.e. all pairs
//that are at least 4 bonds apart.
//Sorted (redundantly) into a series of lists of all partners of each particle
class SortedNonbond
{
public:
//!Returns iterable pointer to first pair containing atom
const uint* Begin(uint atom) const
{
return partners + subdiv.Begin(atom);
}
//!Returns pointer to position after the last pair containing atom
const uint* End(uint atom) const
{
return partners + subdiv.End(atom);
}
//!Initialize from a nonbond structure
void Init(const Nonbond& nb, uint numAtoms);
SortedNonbond() : partners(NULL) {}
~SortedNonbond()
{
delete[] partners;
}
private:
uint* partners;
SubdividedArray subdiv;
};
#endif