31 map<const AtomID, set<AtomID> >
pairs;
38 pairs.insert(std::pair<
AtomID, set<AtomID> >(a, set<AtomID>()));
41 inline void ensure(vector<AtomID> ps){
42 vector<AtomID>::iterator it;
43 for(it=ps.begin(); it != ps.end(); ++it)
ensure(*it);
54 if(a1 > a2)
return pairs[a1].count(a2) > 0;
55 else return pairs[a2].count(a1) > 0;
63 if(a1 > a2){pairs[a1].insert(a2);}
64 else{pairs[a2].insert(a1);};
72 if(a1 > a2){pairs[a1].erase(a2);}
73 else{pairs[a2].erase(a1);};
86 inline set<AtomID>::iterator
begin(
const AtomID a){
return pairs[a].begin();};
88 inline set<AtomID>::iterator
end(
const AtomID a){
return pairs[a].end();};
92 map<
const AtomID, set<AtomID> >::const_iterator it=pairs.begin();
93 it != pairs.end(); ++it) N+= (
uint) it->second.size();
150 diameters.push_back(diameter);
152 lastlocs.push_back(a->x);
153 ignorechanged =
true;
160 inline vector<IDPair>::iterator
begin(){
return curpairs.begin();};
161 inline vector<IDPair>::iterator
end(){
return curpairs.end();};
205 Grid(sptr<OriginBox> box, sptr<AtomGroup> atoms,
const uint width=1);
210 Grid(sptr<OriginBox> box, sptr<AtomGroup> atoms, vector<uint> width);
216 Grid(sptr<OriginBox> box, sptr<AtomGroup> atoms,
const flt minwidth,
const flt goalwidth);
249 uint numcells(){
return widths[0] * widths[1] * widths[2];};
278 return !(*
this == other);
282 return (atom2 == other);
285 return !(atom2 == other);
288 end_type
end(){
return grid.
gridlocs[neighbor_cells.back()].end();};
295 vector<set<AtomID> >::iterator
cell1;
318 return !(*
this == other);
set< AtomID > * cell2
Definition: trackers.hpp:300
pair_iter pairs(AtomID a)
Get all pairs of a specific Atom.
Definition: trackers.cpp:227
void update(Box &newbox)
Calls update_list(false); exists as a requirement of StateTracker.
Definition: trackers.hpp:134
The basic class for representing each particle.
Definition: box.hpp:229
Grid & grid
Definition: trackers.hpp:294
vector< uint > neighbor_cells
Definition: trackers.hpp:259
Grid(sptr< OriginBox > box, sptr< AtomGroup > atoms, const uint width=1)
/param width Number of divisions along all axes
Definition: trackers.cpp:82
IDPair operator*()
Definition: trackers.hpp:314
iterator end()
Definition: trackers.cpp:223
Grid & grid
Definition: trackers.hpp:256
AtomID operator*()
Definition: trackers.hpp:274
void erase_pair(AtomID a1, AtomID a2)
Remove a pair from the list.
Definition: trackers.hpp:71
void ensure(vector< AtomID > ps)
Ensure that every Atom in input is in the overall list.
Definition: trackers.hpp:41
bool operator!=(const end_type other)
Definition: trackers.hpp:284
vector< IDPair > all_pairs()
Return a list of all pairs. SLOW function, but useful for debugging.
Definition: trackers.cpp:250
For iterating over all pairs of a single Atom.
Definition: trackers.hpp:254
a group of atoms, such as all of them (AtomVec), or a smaller group such as a molecule, sidebranch, etc.
Definition: box.hpp:312
void ensure(const AtomID a)
Ensure that a given Atom is in the overall list.
Definition: trackers.hpp:37
bool increment_atom2()
Definition: trackers.cpp:300
bool increment_atom1()
Definition: trackers.cpp:396
Maintains a Verlet list of "neighbors": molecules within a 'skin radius' of each other.
Definition: trackers.hpp:118
bool increment_cell2()
returns "successful increment", e.g.
Definition: trackers.cpp:292
sptr< OriginBox > box
Definition: trackers.hpp:180
sptr< AtomGroup > atoms
Definition: trackers.hpp:181
The main class for representing particles.
Definition: box.hpp:412
unsigned int uint
Definition: vec.hpp:20
PairList()
Definition: trackers.hpp:34
double flt
The basic floating point type used in the simulations.
Definition: vecrand.hpp:45
uint numcells()
Definition: trackers.hpp:247
set< AtomID > * cell2
Definition: trackers.hpp:261
void ignore(AtomID a, AtomID b)
Definition: trackers.hpp:146
set< AtomID >::iterator atom2
Definition: trackers.hpp:262
void add(AtomID a, flt diameter)
Definition: trackers.hpp:147
vector< uint > neighbors(uint i)
Definition: trackers.cpp:112
map< const AtomID, set< AtomID > > pairs
Definition: trackers.hpp:31
void add(AtomID a)
Definition: box.hpp:464
A mapping of Atom -> [list of Atom], used by NeighborList to keep track of what atoms are near what o...
Definition: trackers.hpp:29
flt time_to_edge(uint i)
Definition: trackers.hpp:238
set< AtomID >::iterator atom1
Definition: trackers.hpp:296
vector< uint >::iterator cellnum2
Definition: trackers.hpp:299
virtual uint size() const =0
Number of atoms in the group.
A pointer to an Atom, that also knows its own index in an AtomVec.
Definition: box.hpp:270
flt minwidth
minwidth is minimum size of a box, in real units.
Definition: trackers.hpp:190
virtual ~StateTracker()
Definition: trackers.hpp:20
virtual void update(Box &box)=0
This function is called once per timestep, when particles are in their set position.
flt skin
Definition: trackers.hpp:121
vector< flt > diameters
Definition: trackers.hpp:123
set< AtomID >::iterator atom2
Definition: trackers.hpp:301
For iterating over all possible pairs.
Definition: trackers.hpp:292
AtomVec & vec()
Definition: box.hpp:460
uint size() const
Number of atoms in list.
Definition: trackers.hpp:159
end_type end()
Definition: trackers.hpp:288
GridIterator & operator++()
Definition: trackers.cpp:431
NeighborList(sptr< Box > box, sptr< AtomVec > atoms, const flt skin)
Definition: trackers.cpp:10
set< AtomID >::iterator end_type
Definition: trackers.hpp:269
vector< set< AtomID > > gridlocs
Atoms in each grid location.
Definition: trackers.hpp:193
void make_grid()
Reshape the grid to optimize number of Atom pairs.
Definition: trackers.cpp:205
bool increment_cell2()
Definition: trackers.cpp:407
AtomID atom1
Definition: trackers.hpp:257
sptr< Box > box
Definition: trackers.hpp:120
bool operator==(const GridIterator &other)
Definition: trackers.cpp:438
set< AtomID > get_pairs(const AtomID a)
Get all atoms neighboring an Atom that are "lesser" than the Atom.
Definition: trackers.hpp:83
uint numpairs()
Definition: trackers.hpp:145
uint get_loc(Vec v, Vec bsize)
Definition: trackers.cpp:190
vector< IDPair >::iterator end()
Definition: trackers.hpp:161
void optimize_widths()
Reshape the grid to optimize number of Atom pairs.
Definition: trackers.cpp:168
void clear()
Clear the inner lists.
Definition: trackers.cpp:3
GridIterator(Grid &grid)
Definition: trackers.cpp:322
bool update_list(bool force=true)
Update the neighbor list based on current positions.
Definition: trackers.cpp:14
iterator begin()
Iterator over pairs.
Definition: trackers.cpp:219
virtual AtomID get_id(cuint n)=0
vector< IDPair > curpairs
Definition: trackers.hpp:124
vector< uint > neighbor_cells
Definition: trackers.hpp:298
SubGroup atoms
Definition: trackers.hpp:122
vector< IDPair >::iterator begin()
Definition: trackers.hpp:160
void ensure(AtomGroup &group)
Ensure that every Atom in input is in the overall list.
Definition: trackers.hpp:46
uint updatenum
Definition: trackers.hpp:127
bool ignorechanged
Definition: trackers.hpp:128
bool operator!=(const GridIterator &other)
Definition: trackers.hpp:317
void add_pair(AtomID a1, AtomID a2)
Add a pair to the list.
Definition: trackers.hpp:61
vector< set< AtomID > >::iterator cell1
Definition: trackers.hpp:295
AtomVec & vec()
Definition: trackers.hpp:143
The general interface for a "tracker", a class that needs to be called every timestep.
Definition: trackers.hpp:16
vector< uint >::iterator cellnum2
Definition: trackers.hpp:260
#define NDIM
Definition: vecrand.hpp:12
GridPairedIterator pair_iter
Definition: trackers.hpp:200
uint size() const
Number of atoms in the group.
Definition: box.hpp:471
uint widths[NDIM]
Number of box divisions per dimension.
Definition: trackers.hpp:192
GridPairedIterator(Grid &grid, AtomID a)
Definition: trackers.cpp:269
PairList ignorepairs
Definition: trackers.hpp:125
bool increment_cell1()
Definition: trackers.cpp:387
bool has_pair(AtomID a1, AtomID a2)
Check if a given pair is is the list.
Definition: trackers.hpp:53
The virtual interface for the shape of the space and its boundaries.
Definition: box.hpp:50
~NeighborList()
Definition: trackers.hpp:166
bool increment_atom2()
Definition: trackers.cpp:419
Eigen::Matrix< flt, NDIM, 1 > Vec
The basic physics vector.
Definition: vecrand.hpp:53
A fast algorithm for finding all pairs of neighboring atoms.
Definition: trackers.hpp:178
set< AtomID >::iterator begin(const AtomID a)
for iterating over neighbors
Definition: trackers.hpp:86
uint numcells(uint i)
Definition: trackers.hpp:245
flt time_to_edge(Atom &a)
Find the amount of time until an Atom leaves its current cell.
Definition: trackers.cpp:231
bool operator!=(const GridPairedIterator &other)
Definition: trackers.hpp:277
flt goalwidth
goalwidth is how many atoms per box (goal).
Definition: trackers.hpp:191
uint ignore_size() const
Number of pairs currently being ignored.
Definition: trackers.hpp:157
uint size() const
for iterating over neighbors
Definition: trackers.hpp:91
set< AtomID >::iterator end(const AtomID a)
for iterating over neighbors
Definition: trackers.hpp:88
bool operator==(const end_type other)
Definition: trackers.hpp:281
GridIterator iterator
Definition: trackers.hpp:199
bool operator==(const GridPairedIterator &other)
Definition: trackers.cpp:315
GridPairedIterator & operator++()
Definition: trackers.cpp:310
uint which()
Definition: trackers.hpp:144
vector< Vec > lastlocs
Definition: trackers.hpp:126