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

Eliminated box copy

There was an extra copy of the box in ActionAtomistic,
namely ActionAtomistic::box and ActionAtomistic::pbc.

This means that one should take care of both copies when changing it,
which is error prone.

I eliminated ActionAtomistic::box
parent 22c223b5
No related branches found
No related tags found
No related merge requests found
...@@ -113,6 +113,7 @@ void ActionAtomistic::calculateAtomicNumericalDerivatives( ActionWithValue* a, c ...@@ -113,6 +113,7 @@ void ActionAtomistic::calculateAtomicNumericalDerivatives( ActionWithValue* a, c
value[j*natoms+i][k]=a->getOutputQuantity(j); value[j*natoms+i][k]=a->getOutputQuantity(j);
} }
} }
Tensor box(pbc.getBox());
for(int i=0;i<3;i++) for(int k=0;k<3;k++){ for(int i=0;i<3;i++) for(int k=0;k<3;k++){
double arg0=box(i,k); double arg0=box(i,k);
for(int j=0;j<natoms;j++) positions[j]=pbc.realToScaled(positions[j]); for(int j=0;j<natoms;j++) positions[j]=pbc.realToScaled(positions[j]);
...@@ -203,7 +204,6 @@ void ActionAtomistic::parseAtomList(const std::string&key,const int num, std::ve ...@@ -203,7 +204,6 @@ void ActionAtomistic::parseAtomList(const std::string&key,const int num, std::ve
void ActionAtomistic::retrieveAtoms(){ void ActionAtomistic::retrieveAtoms(){
box=atoms.box;
pbc=atoms.pbc; pbc=atoms.pbc;
Colvar*cc=dynamic_cast<Colvar*>(this); Colvar*cc=dynamic_cast<Colvar*>(this);
if(cc && cc->checkIsEnergy()) energy=atoms.getEnergy(); if(cc && cc->checkIsEnergy()) energy=atoms.getEnergy();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Action.h" #include "Action.h"
#include "tools/Tensor.h" #include "tools/Tensor.h"
#include "Atoms.h" #include "Atoms.h"
#include "tools/Pbc.h"
#include <vector> #include <vector>
#include <set> #include <set>
...@@ -43,7 +44,6 @@ class ActionAtomistic : ...@@ -43,7 +44,6 @@ class ActionAtomistic :
std::set<AtomNumber> unique; std::set<AtomNumber> unique;
std::vector<Vector> positions; // positions of the needed atoms std::vector<Vector> positions; // positions of the needed atoms
double energy; double energy;
Tensor box;
Pbc& pbc; Pbc& pbc;
Tensor virial; Tensor virial;
std::vector<double> masses; std::vector<double> masses;
...@@ -216,7 +216,7 @@ const double & ActionAtomistic::getEnergy()const{ ...@@ -216,7 +216,7 @@ const double & ActionAtomistic::getEnergy()const{
inline inline
const Tensor & ActionAtomistic::getBox()const{ const Tensor & ActionAtomistic::getBox()const{
return box; return pbc.getBox();
} }
inline inline
......
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