Skip to content
Snippets Groups Projects
Commit 2341446a authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Renamed getPosition(AtomNumber) to getGlobalPosition(AtomNumber)

See #357.

The whole code, including optional modules, correctly compiles
indicating that this function was used in a single place.

In case some foreign code uses getPosition(AtomNumber), after this
update the compilation will fail (and will not just produce incorrect results).
So I think this change can be merged safely.
parent 4a20a9cc
No related branches found
No related tags found
No related merge requests found
...@@ -77,8 +77,10 @@ public: ...@@ -77,8 +77,10 @@ public:
/// Get position of i-th atom (access by relative index) /// Get position of i-th atom (access by relative index)
const Vector & getPosition(int)const; const Vector & getPosition(int)const;
/// Get position of i-th atom (access by absolute AtomNumber). /// Get position of i-th atom (access by absolute AtomNumber).
/// With direct access to the global atom array /// With direct access to the global atom array.
const Vector & getPosition(AtomNumber)const; /// \warning Should be only used by actions that need to read the shared position array.
/// This array is insensitive to local changes such as makeWhole(), numerical derivatives, etc.
const Vector & getGlobalPosition(AtomNumber)const;
/// Get modifiable position of i-th atom (access by absolute AtomNumber). /// Get modifiable position of i-th atom (access by absolute AtomNumber).
/// Should be used by action that need to modify the stored atomic coordinates /// Should be used by action that need to modify the stored atomic coordinates
Vector & modifyPosition(AtomNumber); Vector & modifyPosition(AtomNumber);
...@@ -188,7 +190,7 @@ const Vector & ActionAtomistic::getPosition(int i)const { ...@@ -188,7 +190,7 @@ const Vector & ActionAtomistic::getPosition(int i)const {
} }
inline inline
const Vector & ActionAtomistic::getPosition(AtomNumber i)const { const Vector & ActionAtomistic::getGlobalPosition(AtomNumber i)const {
return atoms.positions[i.index()]; return atoms.positions[i.index()];
} }
......
...@@ -178,7 +178,7 @@ WholeMolecules::WholeMolecules(const ActionOptions&ao): ...@@ -178,7 +178,7 @@ WholeMolecules::WholeMolecules(const ActionOptions&ao):
void WholeMolecules::calculate() { void WholeMolecules::calculate() {
for(unsigned i=0; i<groups.size(); ++i) { for(unsigned i=0; i<groups.size(); ++i) {
for(unsigned j=0; j<groups[i].size()-1; ++j) { for(unsigned j=0; j<groups[i].size()-1; ++j) {
const Vector & first (getPosition(groups[i][j])); const Vector & first (getGlobalPosition(groups[i][j]));
Vector & second (modifyPosition(groups[i][j+1])); Vector & second (modifyPosition(groups[i][j+1]));
second=first+pbcDistance(first,second); second=first+pbcDistance(first,second);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment