From 6a237cf735559cdc58d6075c0e2f2aa1592a8e7a Mon Sep 17 00:00:00 2001 From: Daniele Rapetti <5535617+Iximiel@users.noreply.github.com> Date: Thu, 21 Dec 2023 10:17:34 +0100 Subject: [PATCH] inlined addForce --- src/core/ActionAtomistic.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/core/ActionAtomistic.cpp b/src/core/ActionAtomistic.cpp index 56f5bf25c8..83ab1d65dd 100644 --- a/src/core/ActionAtomistic.cpp +++ b/src/core/ActionAtomistic.cpp @@ -258,9 +258,16 @@ void ActionAtomistic::interpretAtomList(std::vector& strings, std:: } void ActionAtomistic::getValueIndices( const AtomNumber& i, std::size_t& valno, std::size_t& k ) const { - valno=0; k = i.index(); + //valno is the id of the id of the value + //is where the atom is in the value + //is really necessary to do this at every step? + valno=0; + k = i.index(); for(unsigned j=0; jgetNumberOfValues() ) { valno=j; break; } + if( kgetNumberOfValues() ){ + valno=j; + break; + } k = k - xpos[j]->getNumberOfValues(); } } @@ -284,14 +291,22 @@ void ActionAtomistic::retrieveAtoms() { } void ActionAtomistic::setForcesOnAtoms(const std::vector& forcesToApply, unsigned& ind) { - if( donotforce || (indexes.size()==0 && getName()!="FIXEDATOM") ) return; + if( donotforce || (indexes.size()==0 && getName()!="FIXEDATOM") ) + return; + std::size_t nn, kk; + for(unsigned i=0; iaddForce( kk, forcesToApply[ind++] ); + ypos[nn]->addForce( kk, forcesToApply[ind++] ); + zpos[nn]->addForce( kk, forcesToApply[ind++] ); } setForcesOnCell( forcesToApply, ind ); } @@ -356,6 +371,7 @@ Vector ActionAtomistic::getForce( const AtomNumber& i ) const { return f; } +// inline void ActionAtomistic::addForce( const AtomNumber& i, const Vector& f ) { std::size_t nn, kk; getValueIndices( i, nn, kk ); xpos[nn]->addForce( kk, f[0] );