Skip to content
Snippets Groups Projects
Commit eafefd26 authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Fixed potential bug in Atoms

If you had your atoms distributed among the domains such that one
node had on all the Atoms there could be a problem in running plumed.
This change fixes this problem.  Also deleted rogue check in
AdjacencyMatrixAction
parent 33850404
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ Atoms::Atoms(PlumedMain&plumed):
forcesHaveBeenSet(0),
virialHasBeenSet(false),
massAndChargeOK(false),
shuffledAtoms(false),
shuffledAtoms(0),
plumed(plumed),
naturalUnits(false),
timestep(0.0),
......@@ -141,7 +141,7 @@ void Atoms::share(){
shareAll();
return;
}
if(dd && shuffledAtoms){
if(dd && shuffledAtoms>0){
for(unsigned i=0;i<actions.size();i++) if(actions[i]->isActive()) {
unique.insert(actions[i]->getUnique().begin(),actions[i]->getUnique().end());
}
......@@ -151,7 +151,7 @@ void Atoms::share(){
void Atoms::shareAll(){
std::set<AtomNumber> unique;
if(dd && shuffledAtoms)
if(dd && shuffledAtoms>0)
for(int i=0;i<natoms;i++) unique.insert(AtomNumber::index(i));
share(unique);
}
......@@ -167,7 +167,7 @@ void Atoms::share(const std::set<AtomNumber>& unique){
mdatoms->getCharges(gatindex,charges);
mdatoms->getMasses(gatindex,masses);
}
if(dd && shuffledAtoms){
if(dd && shuffledAtoms>0){
if(dd.async){
for(unsigned i=0;i<dd.mpi_request_positions.size();i++) dd.mpi_request_positions[i].wait();
for(unsigned i=0;i<dd.mpi_request_index.size();i++) dd.mpi_request_index[i].wait();
......@@ -237,7 +237,7 @@ void Atoms::wait(){
if(collectEnergy) energy=md_energy;
if(dd && shuffledAtoms){
if(dd && shuffledAtoms>0){
// receive toBeReceived
Communicator::Status status;
if(dd.async){
......@@ -322,21 +322,24 @@ void Atoms::setAtomsGatindex(int*g){
for(unsigned i=0;i<gatindex.size();i++) gatindex[i]=g[i];
for(unsigned i=0;i<dd.g2l.size();i++) dd.g2l[i]=-1;
if( gatindex.size()==natoms ){
shuffledAtoms=false;
shuffledAtoms=0;
for(unsigned i=0;i<gatindex.size();i++){
if( gatindex[i]!=i ){ shuffledAtoms=true; break; }
if( gatindex[i]!=i ){ shuffledAtoms=1; break; }
}
} else {
shuffledAtoms=true;
shuffledAtoms=1;
}
if(dd){
dd.Sum(shuffledAtoms);
for(unsigned i=0;i<gatindex.size();i++) dd.g2l[gatindex[i]]=i;
}
if(dd) for(unsigned i=0;i<gatindex.size();i++) dd.g2l[gatindex[i]]=i;
}
void Atoms::setAtomsContiguous(int start){
for(unsigned i=0;i<gatindex.size();i++) gatindex[i]=start+i;
for(unsigned i=0;i<dd.g2l.size();i++) dd.g2l[i]=-1;
if(dd) for(unsigned i=0;i<gatindex.size();i++) dd.g2l[gatindex[i]]=i;
if(gatindex.size()<natoms) shuffledAtoms=true;
if(gatindex.size()<natoms) shuffledAtoms=1;
}
void Atoms::setRealPrecision(int p){
......
......@@ -70,7 +70,7 @@ class Atoms
unsigned forcesHaveBeenSet;
bool virialHasBeenSet;
bool massAndChargeOK;
bool shuffledAtoms;
unsigned shuffledAtoms;
std::map<std::string,std::vector<AtomNumber> > groups;
......
......@@ -60,7 +60,6 @@ tmpdf(1)
}
for(unsigned j=i;j<nfunc;++j){
plumed_assert( j*(i+1)<0.5*(nfunc*nfunc+nfunc) );
std::string sw, errors; parseNumbered("SWITCH",ibase+j+1,sw);
if(sw.length()==0){
std::string num; Tools::convert(ibase+j+1,num);
......
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