diff --git a/src/adjmat/AdjacencyMatrixBase.cpp b/src/adjmat/AdjacencyMatrixBase.cpp index f04cdc294c..5850029cc2 100644 --- a/src/adjmat/AdjacencyMatrixBase.cpp +++ b/src/adjmat/AdjacencyMatrixBase.cpp @@ -215,52 +215,81 @@ unsigned AdjacencyMatrixBase::retrieveNeighbours( const unsigned& current, std:: void AdjacencyMatrixBase::setupForTask( const unsigned& current, std::vector & indices, MultiValue& myvals ) const { // Now retrieve bookeeping arrays - if( indices.size()!=(1+ablocks.size()+threeblocks.size()) ) indices.resize( 1+ablocks.size()+threeblocks.size() ); + if( indices.size()!=(1+ablocks.size()+threeblocks.size()) ) { + indices.resize( 1+ablocks.size()+threeblocks.size() ); + } // Now get the positions - const Value* myval = getConstPntrToComponent(0); - unsigned natoms=retrieveNeighbours( current, indices ); myvals.setSplitIndex( natoms ); + // const Value* myval = getConstPntrToComponent(0); + unsigned natoms=retrieveNeighbours( current, indices ); + myvals.setSplitIndex( natoms ); + //placing this on the stack + Vector currentAtom = ActionAtomistic::getPosition(current); // Now retrieve everything for the third atoms if( threeblocks.size()>0 ) { - unsigned ncells_required=0; std::vector cells_required( threecells.getNumberOfCells() ); - threecells.addRequiredCells( threecells.findMyCell( ActionAtomistic::getPosition(current) ), ncells_required, cells_required ); + unsigned ncells_required=0; + std::vector cells_required( threecells.getNumberOfCells() ); + threecells.addRequiredCells( threecells.findMyCell( currentAtom ), ncells_required, cells_required ); threecells.retrieveAtomsInCells( ncells_required, cells_required, natoms, indices ); } myvals.setNumberOfIndices( natoms ); // Apply periodic boundary conditions to atom positions - std::vector > & t_atoms( myvals.getFirstAtomDerivativeVector() ); if( t_atoms.size()!=1 ) t_atoms.resize(1); - if( t_atoms[0].size() > & t_atoms( myvals.getFirstAtomDerivativeVector() ); + //since I am usig this as a temp variable, just have to care if size is 0, + if( t_atoms.size()==0 ) + t_atoms.resize(1); + if( t_atoms[0].size() & atoms( myvals.getAtomVector() ); - if( atoms.size() & indices( myvals.getIndices() ); for(unsigned i=myvals.getSplitIndex(); i& matrix_indices( myvals.getMatrixRowDerivativeIndices() ); - matrix_indices[nmat_ind+0]=3*index2+0; matrix_indices[nmat_ind+1]=3*index2+1; matrix_indices[nmat_ind+2]=3*index2+2; + unsigned nmat_ind = myvals.getNumberOfMatrixRowDerivatives(); + std::vector& matrix_indices( myvals.getMatrixRowDerivativeIndices() ); + matrix_indices[nmat_ind+0]=3*index2+0; + matrix_indices[nmat_ind+1]=3*index2+1; + matrix_indices[nmat_ind+2]=3*index2+2; myvals.setNumberOfMatrixRowDerivatives( nmat_ind+3 ); } @@ -269,36 +298,71 @@ void AdjacencyMatrixBase::performTask( const std::string& controller, const unsi Vector atom = myvals.getAtomVector()[index2]; myvals.setValue( 1, atom[0] ); myvals.setValue( 2, atom[1] ); myvals.setValue( 3, atom[2] ); if( !doNotCalculateDerivatives() ) { - myvals.addDerivative( 1, 3*index1+0, -1 ); myvals.addDerivative( 1, 3*index2+0, +1 ); - myvals.addDerivative( 1, 3*index1+1, 0 ); myvals.addDerivative( 1, 3*index2+1, 0 ); - myvals.addDerivative( 1, 3*index1+2, 0 ); myvals.addDerivative( 1, 3*index2+2, 0 ); - myvals.addDerivative( 2, 3*index1+0, 0 ); myvals.addDerivative( 2, 3*index2+0, 0 ); - myvals.addDerivative( 2, 3*index1+1, -1 ); myvals.addDerivative( 2, 3*index2+1, +1 ); - myvals.addDerivative( 2, 3*index1+2, 0 ); myvals.addDerivative( 2, 3*index2+2, 0 ); - myvals.addDerivative( 3, 3*index1+0, 0 ); myvals.addDerivative( 3, 3*index2+0, 0 ); - myvals.addDerivative( 3, 3*index1+1, 0 ); myvals.addDerivative( 3, 3*index2+1, 0 ); - myvals.addDerivative( 3, 3*index1+2, -1 ); myvals.addDerivative( 3, 3*index2+2, +1 ); + myvals.addDerivative( 1, 3*index1+0, -1 ); + myvals.addDerivative( 1, 3*index2+0, +1 ); + myvals.addDerivative( 1, 3*index1+1, 0 ); + myvals.addDerivative( 1, 3*index2+1, 0 ); + myvals.addDerivative( 1, 3*index1+2, 0 ); + myvals.addDerivative( 1, 3*index2+2, 0 ); + myvals.addDerivative( 2, 3*index1+0, 0 ); + myvals.addDerivative( 2, 3*index2+0, 0 ); + myvals.addDerivative( 2, 3*index1+1, -1 ); + myvals.addDerivative( 2, 3*index2+1, +1 ); + myvals.addDerivative( 2, 3*index1+2, 0 ); + myvals.addDerivative( 2, 3*index2+2, 0 ); + myvals.addDerivative( 3, 3*index1+0, 0 ); + myvals.addDerivative( 3, 3*index2+0, 0 ); + myvals.addDerivative( 3, 3*index1+1, 0 ); + myvals.addDerivative( 3, 3*index2+1, 0 ); + myvals.addDerivative( 3, 3*index1+2, -1 ); + myvals.addDerivative( 3, 3*index2+2, +1 ); for(unsigned k=0; k<3; ++k) { // Update dynamic lists for central atom - myvals.updateIndex( 1, 3*index1+k ); myvals.updateIndex( 2, 3*index1+k ); myvals.updateIndex( 3, 3*index1+k ); + myvals.updateIndex( 1, 3*index1+k ); + myvals.updateIndex( 2, 3*index1+k ); + myvals.updateIndex( 3, 3*index1+k ); // Update dynamic lists for bonded atom - myvals.updateIndex( 1, 3*index2+k ); myvals.updateIndex( 2, 3*index2+k ); myvals.updateIndex( 3, 3*index2+k ); + myvals.updateIndex( 1, 3*index2+k ); + myvals.updateIndex( 2, 3*index2+k ); + myvals.updateIndex( 3, 3*index2+k ); } // Add derivatives of virial unsigned base = 3*getNumberOfAtoms(); // Virial for x - myvals.addDerivative( 1, base+0, -atom[0] ); myvals.addDerivative( 1, base+3, -atom[1] ); myvals.addDerivative( 1, base+6, -atom[2] ); - myvals.addDerivative( 1, base+1, 0 ); myvals.addDerivative( 1, base+4, 0 ); myvals.addDerivative( 1, base+7, 0 ); - myvals.addDerivative( 1, base+2, 0 ); myvals.addDerivative( 1, base+5, 0 ); myvals.addDerivative( 1, base+8, 0 ); + myvals.addDerivative( 1, base+0, -atom[0] ); + myvals.addDerivative( 1, base+3, -atom[1] ); + myvals.addDerivative( 1, base+6, -atom[2] ); + myvals.addDerivative( 1, base+1, 0 ); + myvals.addDerivative( 1, base+4, 0 ); + myvals.addDerivative( 1, base+7, 0 ); + myvals.addDerivative( 1, base+2, 0 ); + myvals.addDerivative( 1, base+5, 0 ); + myvals.addDerivative( 1, base+8, 0 ); // Virial for y - myvals.addDerivative( 2, base+0, 0 ); myvals.addDerivative( 2, base+3, 0 ); myvals.addDerivative( 2, base+6, 0 ); - myvals.addDerivative( 2, base+1, -atom[0] ); myvals.addDerivative( 2, base+4, -atom[1] ); myvals.addDerivative( 2, base+7, -atom[2] ); - myvals.addDerivative( 2, base+2, 0 ); myvals.addDerivative( 2, base+5, 0 ); myvals.addDerivative( 2, base+8, 0 ); + myvals.addDerivative( 2, base+0, 0 ); + myvals.addDerivative( 2, base+3, 0 ); + myvals.addDerivative( 2, base+6, 0 ); + myvals.addDerivative( 2, base+1, -atom[0] ); + myvals.addDerivative( 2, base+4, -atom[1] ); + myvals.addDerivative( 2, base+7, -atom[2] ); + myvals.addDerivative( 2, base+2, 0 ); + myvals.addDerivative( 2, base+5, 0 ); + myvals.addDerivative( 2, base+8, 0 ); // Virial for z - myvals.addDerivative( 3, base+0, 0 ); myvals.addDerivative( 3, base+3, 0 ); myvals.addDerivative( 3, base+6, 0 ); - myvals.addDerivative( 3, base+1, 0 ); myvals.addDerivative( 3, base+4, 0 ); myvals.addDerivative( 3, base+7, 0 ); - myvals.addDerivative( 3, base+2, -atom[0] ); myvals.addDerivative( 3, base+5, -atom[1] ); myvals.addDerivative( 3, base+8, -atom[2] ); - for(unsigned k=0; k<9; ++k) { myvals.updateIndex( 1, base+k ); myvals.updateIndex( 2, base+k ); myvals.updateIndex( 3, base+k ); } + myvals.addDerivative( 3, base+0, 0 ); + myvals.addDerivative( 3, base+3, 0 ); + myvals.addDerivative( 3, base+6, 0 ); + myvals.addDerivative( 3, base+1, 0 ); + myvals.addDerivative( 3, base+4, 0 ); + myvals.addDerivative( 3, base+7, 0 ); + myvals.addDerivative( 3, base+2, -atom[0] ); + myvals.addDerivative( 3, base+5, -atom[1] ); + myvals.addDerivative( 3, base+8, -atom[2] ); + for(unsigned k=0; k<9; ++k) { + myvals.updateIndex( 1, base+k ); + myvals.updateIndex( 2, base+k ); + myvals.updateIndex( 3, base+k ); + } } } }