From 975ccdd4a712d835bf9949d7ebacda3b581ef747 Mon Sep 17 00:00:00 2001 From: Gareth Aneurin Tribello Date: Mon, 27 Jan 2025 16:34:11 +0000 Subject: [PATCH] Fix of bug introduced after merge of master --- src/tools/LinkCells.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/tools/LinkCells.cpp b/src/tools/LinkCells.cpp index 99ca3f54de..107e7b3a53 100644 --- a/src/tools/LinkCells.cpp +++ b/src/tools/LinkCells.cpp @@ -50,21 +50,28 @@ void LinkCells::buildCellLists( const std::vector& pos, const std::vecto // Create an orthorhombic box around the atomic positions that encompasses every atomic position if there are no pbc auto box = pbc.getBox(); if(box(0,0)==0.0 && box(0,1)==0.0 && box(0,2)==0.0 && box(1,0)==0.0 && box(1,1)==0.0 && box(1,2)==0.0 && box(2,0)==0.0 && box(2,1)==0 && box(2,2)==0) { - Vector minp, maxp; minp = maxp = pos[0]; Tensor fake_box; fake_box.zero(); + Vector minp, maxp; + minp = maxp = pos[0]; for(unsigned k=0; k<3; ++k) { for(unsigned i=1; imaxp[k] ) maxp[k] = pos[i][k]; - if( pos[i][k]maxp[k] ) { + maxp[k] = pos[i][k]; + } + if( pos[i][k] epsilon) <<"Cell lists cannot be built when passing a box with null volume. Volume is "< LinkCells::findMyCell( const Vector& pos ) const { - std::array celn; Vector mypos = pos; - if( nopbc ) mypos = pos - origin; + std::array celn; + Vector mypos = pos; + if( nopbc ) { + mypos = pos - origin; + } Vector fpos=mypbc.realToScaled( pos ); for(unsigned j=0; j<3; ++j) { - if( nopbc ) celn[j] = std::floor( fpos[j] * ncells[j] ); - else celn[j] = std::floor( ( Tools::pbc(fpos[j]) + 0.5 ) * ncells[j] ); + if( nopbc ) { + celn[j] = std::floor( fpos[j] * ncells[j] ); + } else { + celn[j] = std::floor( ( Tools::pbc(fpos[j]) + 0.5 ) * ncells[j] ); + } plumed_assert( celn[j]>=0 && celn[j]