From 6492e55ffd89c92a316e6d9d7999765517d7c4e3 Mon Sep 17 00:00:00 2001 From: Gareth Aneurin Tribello Date: Thu, 1 Aug 2024 13:01:10 +0100 Subject: [PATCH] Ran astyle --- src/colvar/RMSDVector.cpp | 2 +- src/core/ActionWithMatrix.cpp | 16 ++++++------ src/core/ActionWithVector.cpp | 46 +++++++++++++++++------------------ src/matrixtools/Voronoi.cpp | 2 +- src/tools/MultiValue.cpp | 2 +- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/colvar/RMSDVector.cpp b/src/colvar/RMSDVector.cpp index 2c214bdd99..a7a38efb5b 100644 --- a/src/colvar/RMSDVector.cpp +++ b/src/colvar/RMSDVector.cpp @@ -269,7 +269,7 @@ void RMSDVector::gatherStoredValue( const unsigned& valindex, const unsigned& co const unsigned& bufstart, std::vector& buffer ) const { if( getConstPntrToComponent(valindex)->getRank()==1 ) { ActionWithVector::gatherStoredValue( valindex, code, myvals, bufstart, buffer ); return; } const std::vector& direction( myvals.getConstFirstAtomDerivativeVector()[1] ); - unsigned natoms = direction.size(); unsigned vindex = 3*code*natoms; Value* myval = const_cast( getConstPntrToComponent(valindex) ); + unsigned natoms = direction.size(); unsigned vindex = 3*code*natoms; Value* myval = const_cast( getConstPntrToComponent(valindex) ); for(unsigned i=0; iset(vindex + j*natoms + i, direction[i][j] ); } diff --git a/src/core/ActionWithMatrix.cpp b/src/core/ActionWithMatrix.cpp index a16ab86461..a3aaa05a86 100644 --- a/src/core/ActionWithMatrix.cpp +++ b/src/core/ActionWithMatrix.cpp @@ -116,9 +116,9 @@ void ActionWithMatrix::updateAllNeighbourLists() { void ActionWithMatrix::clearBookeepingBeforeTask( const unsigned& task_index ) const { // Reset the bookeeping elements for storage for(unsigned i=0; i( getConstPntrToComponent(i) ); unsigned ncols = myval->getNumberOfColumns(); - if( myval->getRank()!=2 || myval->hasDerivatives() || !myval->valueIsStored() || ncols>=myval->getShape()[1] ) continue; - myval->matrix_bookeeping[task_index*(1+ncols)]=0; + Value* myval = const_cast( getConstPntrToComponent(i) ); unsigned ncols = myval->getNumberOfColumns(); + if( myval->getRank()!=2 || myval->hasDerivatives() || !myval->valueIsStored() || ncols>=myval->getShape()[1] ) continue; + myval->matrix_bookeeping[task_index*(1+ncols)]=0; } if( matrix_to_do_after ) matrix_to_do_after->clearBookeepingBeforeTask( task_index ); } @@ -171,11 +171,11 @@ void ActionWithMatrix::runTask( const std::string& controller, const unsigned& c } double finalval = myvals.get( myval->getPositionInStream() ); if( fabs(finalval)>0 ) { - Value* myv = const_cast( myval ); - if( ncolsgetShape()[1] ) { - myv->set( current*ncols + myval->matrix_bookeeping[current*(1+ncols)], finalval ); - myv->matrix_bookeeping[current*(1+ncols)]++; myv->matrix_bookeeping[current*(1+ncols)+myval->matrix_bookeeping[current*(1+ncols)]] = col_stash_index; - } else myv->set( current*myval->getShape()[1] + col_stash_index, finalval ); + Value* myv = const_cast( myval ); + if( ncolsgetShape()[1] ) { + myv->set( current*ncols + myval->matrix_bookeeping[current*(1+ncols)], finalval ); + myv->matrix_bookeeping[current*(1+ncols)]++; myv->matrix_bookeeping[current*(1+ncols)+myval->matrix_bookeeping[current*(1+ncols)]] = col_stash_index; + } else myv->set( current*myval->getShape()[1] + col_stash_index, finalval ); } } } diff --git a/src/core/ActionWithVector.cpp b/src/core/ActionWithVector.cpp index 47942aff98..5cfe5e1d64 100644 --- a/src/core/ActionWithVector.cpp +++ b/src/core/ActionWithVector.cpp @@ -459,11 +459,11 @@ bool ActionWithVector::doNotCalculateDerivatives() const { void ActionWithVector::clearMatrixBookeeping() { for(unsigned i=0; istoredata ) continue; - if( myval->getRank()==2 && myval->getNumberOfColumns()getShape()[1] ) { - std::fill(myval->matrix_bookeeping.begin(), myval->matrix_bookeeping.end(), 0); - } - myval->set(0); + Value* myval = getPntrToComponent(i); if( !myval->storedata ) continue; + if( myval->getRank()==2 && myval->getNumberOfColumns()getShape()[1] ) { + std::fill(myval->matrix_bookeeping.begin(), myval->matrix_bookeeping.end(), 0); + } + myval->set(0); } } @@ -533,19 +533,19 @@ void ActionWithVector::runAllTasks() { } // MPI Gather everything - if( !serial ) { - if( buffer.size()>0 ) comm.Sum( buffer ); - gatherProcesses(); + if( !serial ) { + if( buffer.size()>0 ) comm.Sum( buffer ); + gatherProcesses(); } finishComputations( buffer ); forwardPass=false; } void ActionWithVector::gatherProcesses() { for(unsigned i=0; istoredata && !myval->hasDeriv ) { - comm.Sum( myval->data ); if( myval->getRank()==2 && myval->getNumberOfColumns()getShape()[1] ) comm.Sum( myval->matrix_bookeeping ); - } + Value* myval = getPntrToComponent(i); + if( myval->storedata && !myval->hasDeriv ) { + comm.Sum( myval->data ); if( myval->getRank()==2 && myval->getNumberOfColumns()getShape()[1] ) comm.Sum( myval->matrix_bookeeping ); + } } if( action_to_do_after ) action_to_do_after->gatherProcesses(); } @@ -595,9 +595,9 @@ void ActionWithVector::getNumberOfStreamedQuantities( const std::string& headstr } void ActionWithVector::getSizeOfBuffer( const unsigned& nactive_tasks, unsigned& bufsize ) { - for(int i=0; ibufstart=bufsize; - if( getPntrToComponent(i)->hasDerivatives() || getPntrToComponent(i)->getRank()==0 ) bufsize += getPntrToComponent(i)->data.size(); + for(int i=0; ibufstart=bufsize; + if( getPntrToComponent(i)->hasDerivatives() || getPntrToComponent(i)->getRank()==0 ) bufsize += getPntrToComponent(i)->data.size(); } if( action_to_do_after ) action_to_do_after->getSizeOfBuffer( nactive_tasks, bufsize ); } @@ -640,9 +640,9 @@ bool ActionWithVector::getNumberOfStoredValues( Value* startat, unsigned& nvals, void ActionWithVector::runTask( const unsigned& current, MultiValue& myvals ) const { myvals.setTaskIndex(current); myvals.vector_call=true; performTask( current, myvals ); for(unsigned i=0; igetRank()!=1 || myval->hasDerivatives() || !myval->valueIsStored() ) continue; - Value* myv = const_cast( myval ); myv->set( current, myvals.get( myval->getPositionInStream() ) ); + const Value* myval = getConstPntrToComponent(i); + if( myval->getRank()!=1 || myval->hasDerivatives() || !myval->valueIsStored() ) continue; + Value* myv = const_cast( myval ); myv->set( current, myvals.get( myval->getPositionInStream() ) ); } if( action_to_do_after ) action_to_do_after->runTask( current, myvals ); } @@ -672,7 +672,7 @@ void ActionWithVector::finishComputations( const std::vector& buf ) { // This gathers vectors and grids at the end of the calculation unsigned bufstart = getPntrToComponent(i)->bufstart; if( (getPntrToComponent(i)->getRank()>0 && getPntrToComponent(i)->hasDerivatives()) ) { - unsigned sz_v = getPntrToComponent(i)->data.size(); getPntrToComponent(i)->data.assign( getPntrToComponent(i)->data.size(), 0 ); + unsigned sz_v = getPntrToComponent(i)->data.size(); getPntrToComponent(i)->data.assign( getPntrToComponent(i)->data.size(), 0 ); for(unsigned j=0; jadd( j, buf[bufstart+j] ); @@ -722,10 +722,10 @@ bool ActionWithVector::checkForForces() { // Recover the number of derivatives we require (this should be equal to the number of forces) unsigned nderiv=0; getNumberOfStreamedDerivatives( nderiv, NULL ); if( !action_to_do_after && arg_deriv_starts.size()>0 ) { - nderiv = 0; - for(unsigned i=0; igetNumberOfStoredValues(); - } + nderiv = 0; + for(unsigned i=0; igetNumberOfStoredValues(); + } } if( forcesForApply.size()!=nderiv ) forcesForApply.resize( nderiv ); // Clear force buffer diff --git a/src/matrixtools/Voronoi.cpp b/src/matrixtools/Voronoi.cpp index 64083c2c96..b09f448540 100644 --- a/src/matrixtools/Voronoi.cpp +++ b/src/matrixtools/Voronoi.cpp @@ -80,7 +80,7 @@ void Voronoi::gatherStoredValue( const unsigned& valindex, const unsigned& code, if( value( getConstPntrToComponent(0) ); - myval->set( code*arg0->getShape()[1] + nv, 1 ); + myval->set( code*arg0->getShape()[1] + nv, 1 ); } } diff --git a/src/tools/MultiValue.cpp b/src/tools/MultiValue.cpp index 79ac6aa35a..b39a0e1948 100644 --- a/src/tools/MultiValue.cpp +++ b/src/tools/MultiValue.cpp @@ -49,7 +49,7 @@ void MultiValue::resize( const size_t& nvals, const size_t& nder, const size_t& if( values.size()==nvals && nderivatives==nder && matrix_row_nderivatives.size()==nmat && nmatrix_cols==maxcol ) return; values.resize(nvals); nderivatives=nder; derivatives.resize( nvals*nder ); hasderiv.resize(nvals*nder,false); nactive.resize(nvals); active_list.resize(nvals*nder); - nmatrix_cols=maxcol; matrix_force_stash.resize(nmat*nder,0); + nmatrix_cols=maxcol; matrix_force_stash.resize(nmat*nder,0); matrix_row_nderivatives.resize(nmat,0); matrix_row_derivative_indices.resize(nmat); atLeastOneSet=false; for(unsigned i=0; i