ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/devel_omp/src/parallel/ForceMatrixDecomposition.cpp
(Generate patch)

Comparing:
branches/development/src/parallel/ForceMatrixDecomposition.cpp (file contents), Revision 1592 by gezelter, Tue Jul 12 20:33:14 2011 UTC vs.
branches/devel_omp/src/parallel/ForceMatrixDecomposition.cpp (file contents), Revision 1595 by chuckv, Tue Jul 19 18:50:04 2011 UTC

# Line 47 | Line 47 | namespace OpenMD {
47   using namespace std;
48   namespace OpenMD {
49  
50 +  ForceMatrixDecomposition::ForceMatrixDecomposition(SimInfo* info, InteractionManager* iMan) : ForceDecomposition(info, iMan) {
51 +
52 +    // In a parallel computation, row and colum scans must visit all
53 +    // surrounding cells (not just the 14 upper triangular blocks that
54 +    // are used when the processor can see all pairs)
55 + #ifdef IS_MPI
56 +    cellOffsets_.push_back( Vector3i(-1, 0, 0) );
57 +    cellOffsets_.push_back( Vector3i(-1,-1, 0) );
58 +    cellOffsets_.push_back( Vector3i( 0,-1, 0) );
59 +    cellOffsets_.push_back( Vector3i( 1,-1, 0) );
60 +    cellOffsets_.push_back( Vector3i( 0, 0,-1) );
61 +    cellOffsets_.push_back( Vector3i(-1, 0, 1) );
62 +    cellOffsets_.push_back( Vector3i(-1,-1,-1) );
63 +    cellOffsets_.push_back( Vector3i( 0,-1,-1) );
64 +    cellOffsets_.push_back( Vector3i( 1,-1,-1) );
65 +    cellOffsets_.push_back( Vector3i( 1, 0,-1) );
66 +    cellOffsets_.push_back( Vector3i( 1, 1,-1) );
67 +    cellOffsets_.push_back( Vector3i( 0, 1,-1) );
68 +    cellOffsets_.push_back( Vector3i(-1, 1,-1) );
69 + #endif    
70 +  }
71 +
72 +
73    /**
74     * distributeInitialData is essentially a copy of the older fortran
75     * SimulationSetup
76     */
54  
77    void ForceMatrixDecomposition::distributeInitialData() {
78      snap_ = sman_->getCurrentSnapshot();
79      storageLayout_ = sman_->getStorageLayout();
# Line 74 | Line 96 | namespace OpenMD {
96  
97   #ifdef IS_MPI
98  
99 <    AtomCommIntRow = new Communicator<Row,int>(nLocal_);
100 <    AtomCommRealRow = new Communicator<Row,RealType>(nLocal_);
79 <    AtomCommVectorRow = new Communicator<Row,Vector3d>(nLocal_);
80 <    AtomCommMatrixRow = new Communicator<Row,Mat3x3d>(nLocal_);
81 <    AtomCommPotRow = new Communicator<Row,potVec>(nLocal_);
99 >    MPI::Intracomm row = rowComm.getComm();
100 >    MPI::Intracomm col = colComm.getComm();
101  
102 <    AtomCommIntColumn = new Communicator<Column,int>(nLocal_);
103 <    AtomCommRealColumn = new Communicator<Column,RealType>(nLocal_);
104 <    AtomCommVectorColumn = new Communicator<Column,Vector3d>(nLocal_);
105 <    AtomCommMatrixColumn = new Communicator<Column,Mat3x3d>(nLocal_);
106 <    AtomCommPotColumn = new Communicator<Column,potVec>(nLocal_);
102 >    AtomPlanIntRow = new Plan<int>(row, nLocal_);
103 >    AtomPlanRealRow = new Plan<RealType>(row, nLocal_);
104 >    AtomPlanVectorRow = new Plan<Vector3d>(row, nLocal_);
105 >    AtomPlanMatrixRow = new Plan<Mat3x3d>(row, nLocal_);
106 >    AtomPlanPotRow = new Plan<potVec>(row, nLocal_);
107  
108 <    cgCommIntRow = new Communicator<Row,int>(nGroups_);
109 <    cgCommVectorRow = new Communicator<Row,Vector3d>(nGroups_);
110 <    cgCommIntColumn = new Communicator<Column,int>(nGroups_);
111 <    cgCommVectorColumn = new Communicator<Column,Vector3d>(nGroups_);
108 >    AtomPlanIntColumn = new Plan<int>(col, nLocal_);
109 >    AtomPlanRealColumn = new Plan<RealType>(col, nLocal_);
110 >    AtomPlanVectorColumn = new Plan<Vector3d>(col, nLocal_);
111 >    AtomPlanMatrixColumn = new Plan<Mat3x3d>(col, nLocal_);
112 >    AtomPlanPotColumn = new Plan<potVec>(col, nLocal_);
113  
114 <    nAtomsInRow_ = AtomCommIntRow->getSize();
115 <    nAtomsInCol_ = AtomCommIntColumn->getSize();
116 <    nGroupsInRow_ = cgCommIntRow->getSize();
117 <    nGroupsInCol_ = cgCommIntColumn->getSize();
114 >    cgPlanIntRow = new Plan<int>(row, nGroups_);
115 >    cgPlanVectorRow = new Plan<Vector3d>(row, nGroups_);
116 >    cgPlanIntColumn = new Plan<int>(col, nGroups_);
117 >    cgPlanVectorColumn = new Plan<Vector3d>(col, nGroups_);
118  
119 +    nAtomsInRow_ = AtomPlanIntRow->getSize();
120 +    nAtomsInCol_ = AtomPlanIntColumn->getSize();
121 +    nGroupsInRow_ = cgPlanIntRow->getSize();
122 +    nGroupsInCol_ = cgPlanIntColumn->getSize();
123 +
124      // Modify the data storage objects with the correct layouts and sizes:
125      atomRowData.resize(nAtomsInRow_);
126      atomRowData.setStorageLayout(storageLayout_);
# Line 109 | Line 134 | namespace OpenMD {
134      identsRow.resize(nAtomsInRow_);
135      identsCol.resize(nAtomsInCol_);
136      
137 <    AtomCommIntRow->gather(idents, identsRow);
138 <    AtomCommIntColumn->gather(idents, identsCol);
137 >    AtomPlanIntRow->gather(idents, identsRow);
138 >    AtomPlanIntColumn->gather(idents, identsCol);
139      
140      // allocate memory for the parallel objects
141      atypesRow.resize(nAtomsInRow_);
# Line 126 | Line 151 | namespace OpenMD {
151  
152      AtomRowToGlobal.resize(nAtomsInRow_);
153      AtomColToGlobal.resize(nAtomsInCol_);
154 <    AtomCommIntRow->gather(AtomLocalToGlobal, AtomRowToGlobal);
155 <    AtomCommIntColumn->gather(AtomLocalToGlobal, AtomColToGlobal);
156 <    
154 >    AtomPlanIntRow->gather(AtomLocalToGlobal, AtomRowToGlobal);
155 >    AtomPlanIntColumn->gather(AtomLocalToGlobal, AtomColToGlobal);
156 >
157 >    cerr << "Atoms in Local:\n";
158 >    for (int i = 0; i < AtomLocalToGlobal.size(); i++) {
159 >      cerr << "i =\t" << i << "\t localAt =\t" << AtomLocalToGlobal[i] << "\n";
160 >    }
161 >    cerr << "Atoms in Row:\n";
162 >    for (int i = 0; i < AtomRowToGlobal.size(); i++) {
163 >      cerr << "i =\t" << i << "\t rowAt =\t" << AtomRowToGlobal[i] << "\n";
164 >    }
165 >    cerr << "Atoms in Col:\n";
166 >    for (int i = 0; i < AtomColToGlobal.size(); i++) {
167 >      cerr << "i =\t" << i << "\t colAt =\t" << AtomColToGlobal[i] << "\n";
168 >    }
169 >
170      cgRowToGlobal.resize(nGroupsInRow_);
171      cgColToGlobal.resize(nGroupsInCol_);
172 <    cgCommIntRow->gather(cgLocalToGlobal, cgRowToGlobal);
173 <    cgCommIntColumn->gather(cgLocalToGlobal, cgColToGlobal);
172 >    cgPlanIntRow->gather(cgLocalToGlobal, cgRowToGlobal);
173 >    cgPlanIntColumn->gather(cgLocalToGlobal, cgColToGlobal);
174 >
175 >    cerr << "Gruops in Local:\n";
176 >    for (int i = 0; i < cgLocalToGlobal.size(); i++) {
177 >      cerr << "i =\t" << i << "\t localCG =\t" << cgLocalToGlobal[i] << "\n";
178 >    }
179 >    cerr << "Groups in Row:\n";
180 >    for (int i = 0; i < cgRowToGlobal.size(); i++) {
181 >      cerr << "i =\t" << i << "\t rowCG =\t" << cgRowToGlobal[i] << "\n";
182 >    }
183 >    cerr << "Groups in Col:\n";
184 >    for (int i = 0; i < cgColToGlobal.size(); i++) {
185 >      cerr << "i =\t" << i << "\t colCG =\t" << cgColToGlobal[i] << "\n";
186 >    }
187  
188 +
189      massFactorsRow.resize(nAtomsInRow_);
190      massFactorsCol.resize(nAtomsInCol_);
191 <    AtomCommRealRow->gather(massFactors, massFactorsRow);
192 <    AtomCommRealColumn->gather(massFactors, massFactorsCol);
191 >    AtomPlanRealRow->gather(massFactors, massFactorsRow);
192 >    AtomPlanRealColumn->gather(massFactors, massFactorsCol);
193  
194      groupListRow_.clear();
195      groupListRow_.resize(nGroupsInRow_);
# Line 517 | Line 569 | namespace OpenMD {
569   #ifdef IS_MPI
570      
571      // gather up the atomic positions
572 <    AtomCommVectorRow->gather(snap_->atomData.position,
572 >    AtomPlanVectorRow->gather(snap_->atomData.position,
573                                atomRowData.position);
574 <    AtomCommVectorColumn->gather(snap_->atomData.position,
574 >    AtomPlanVectorColumn->gather(snap_->atomData.position,
575                                   atomColData.position);
576      
577      // gather up the cutoff group positions
578 <    cgCommVectorRow->gather(snap_->cgData.position,
578 >
579 >    cerr  << "before gather\n";
580 >    for (int i = 0; i < snap_->cgData.position.size(); i++) {
581 >      cerr << "cgpos = " << snap_->cgData.position[i] << "\n";
582 >    }
583 >
584 >    cgPlanVectorRow->gather(snap_->cgData.position,
585                              cgRowData.position);
586 <    cgCommVectorColumn->gather(snap_->cgData.position,
586 >
587 >    cerr  << "after gather\n";
588 >    for (int i = 0; i < cgRowData.position.size(); i++) {
589 >      cerr << "cgRpos = " << cgRowData.position[i] << "\n";
590 >    }
591 >
592 >    cgPlanVectorColumn->gather(snap_->cgData.position,
593                                 cgColData.position);
594 +    for (int i = 0; i < cgColData.position.size(); i++) {
595 +      cerr << "cgCpos = " << cgColData.position[i] << "\n";
596 +    }
597 +
598      
599      // if needed, gather the atomic rotation matrices
600      if (storageLayout_ & DataStorage::dslAmat) {
601 <      AtomCommMatrixRow->gather(snap_->atomData.aMat,
601 >      AtomPlanMatrixRow->gather(snap_->atomData.aMat,
602                                  atomRowData.aMat);
603 <      AtomCommMatrixColumn->gather(snap_->atomData.aMat,
603 >      AtomPlanMatrixColumn->gather(snap_->atomData.aMat,
604                                     atomColData.aMat);
605      }
606      
607      // if needed, gather the atomic eletrostatic frames
608      if (storageLayout_ & DataStorage::dslElectroFrame) {
609 <      AtomCommMatrixRow->gather(snap_->atomData.electroFrame,
609 >      AtomPlanMatrixRow->gather(snap_->atomData.electroFrame,
610                                  atomRowData.electroFrame);
611 <      AtomCommMatrixColumn->gather(snap_->atomData.electroFrame,
611 >      AtomPlanMatrixColumn->gather(snap_->atomData.electroFrame,
612                                     atomColData.electroFrame);
613      }
614  
# Line 557 | Line 625 | namespace OpenMD {
625      
626      if (storageLayout_ & DataStorage::dslDensity) {
627        
628 <      AtomCommRealRow->scatter(atomRowData.density,
628 >      AtomPlanRealRow->scatter(atomRowData.density,
629                                 snap_->atomData.density);
630        
631        int n = snap_->atomData.density.size();
632        vector<RealType> rho_tmp(n, 0.0);
633 <      AtomCommRealColumn->scatter(atomColData.density, rho_tmp);
633 >      AtomPlanRealColumn->scatter(atomColData.density, rho_tmp);
634        for (int i = 0; i < n; i++)
635          snap_->atomData.density[i] += rho_tmp[i];
636      }
# Line 578 | Line 646 | namespace OpenMD {
646      storageLayout_ = sman_->getStorageLayout();
647   #ifdef IS_MPI
648      if (storageLayout_ & DataStorage::dslFunctional) {
649 <      AtomCommRealRow->gather(snap_->atomData.functional,
649 >      AtomPlanRealRow->gather(snap_->atomData.functional,
650                                atomRowData.functional);
651 <      AtomCommRealColumn->gather(snap_->atomData.functional,
651 >      AtomPlanRealColumn->gather(snap_->atomData.functional,
652                                   atomColData.functional);
653      }
654      
655      if (storageLayout_ & DataStorage::dslFunctionalDerivative) {
656 <      AtomCommRealRow->gather(snap_->atomData.functionalDerivative,
656 >      AtomPlanRealRow->gather(snap_->atomData.functionalDerivative,
657                                atomRowData.functionalDerivative);
658 <      AtomCommRealColumn->gather(snap_->atomData.functionalDerivative,
658 >      AtomPlanRealColumn->gather(snap_->atomData.functionalDerivative,
659                                   atomColData.functionalDerivative);
660      }
661   #endif
# Line 601 | Line 669 | namespace OpenMD {
669      int n = snap_->atomData.force.size();
670      vector<Vector3d> frc_tmp(n, V3Zero);
671      
672 <    AtomCommVectorRow->scatter(atomRowData.force, frc_tmp);
672 >    AtomPlanVectorRow->scatter(atomRowData.force, frc_tmp);
673      for (int i = 0; i < n; i++) {
674        snap_->atomData.force[i] += frc_tmp[i];
675        frc_tmp[i] = 0.0;
676      }
677      
678 <    AtomCommVectorColumn->scatter(atomColData.force, frc_tmp);
679 <    for (int i = 0; i < n; i++)
678 >    AtomPlanVectorColumn->scatter(atomColData.force, frc_tmp);
679 >    for (int i = 0; i < n; i++) {
680        snap_->atomData.force[i] += frc_tmp[i];
681 +    }
682          
683      if (storageLayout_ & DataStorage::dslTorque) {
684  
685        int nt = snap_->atomData.torque.size();
686        vector<Vector3d> trq_tmp(nt, V3Zero);
687  
688 <      AtomCommVectorRow->scatter(atomRowData.torque, trq_tmp);
688 >      AtomPlanVectorRow->scatter(atomRowData.torque, trq_tmp);
689        for (int i = 0; i < nt; i++) {
690          snap_->atomData.torque[i] += trq_tmp[i];
691          trq_tmp[i] = 0.0;
692        }
693        
694 <      AtomCommVectorColumn->scatter(atomColData.torque, trq_tmp);
694 >      AtomPlanVectorColumn->scatter(atomColData.torque, trq_tmp);
695        for (int i = 0; i < nt; i++)
696          snap_->atomData.torque[i] += trq_tmp[i];
697      }
# Line 632 | Line 701 | namespace OpenMD {
701        int ns = snap_->atomData.skippedCharge.size();
702        vector<RealType> skch_tmp(ns, 0.0);
703  
704 <      AtomCommRealRow->scatter(atomRowData.skippedCharge, skch_tmp);
704 >      AtomPlanRealRow->scatter(atomRowData.skippedCharge, skch_tmp);
705        for (int i = 0; i < ns; i++) {
706          snap_->atomData.skippedCharge[i] += skch_tmp[i];
707          skch_tmp[i] = 0.0;
708        }
709        
710 <      AtomCommRealColumn->scatter(atomColData.skippedCharge, skch_tmp);
710 >      AtomPlanRealColumn->scatter(atomColData.skippedCharge, skch_tmp);
711        for (int i = 0; i < ns; i++)
712          snap_->atomData.skippedCharge[i] += skch_tmp[i];
713      }
# Line 650 | Line 719 | namespace OpenMD {
719  
720      // scatter/gather pot_row into the members of my column
721            
722 <    AtomCommPotRow->scatter(pot_row, pot_temp);
722 >    AtomPlanPotRow->scatter(pot_row, pot_temp);
723  
724      for (int ii = 0;  ii < pot_temp.size(); ii++ )
725        pairwisePot += pot_temp[ii];
# Line 658 | Line 727 | namespace OpenMD {
727      fill(pot_temp.begin(), pot_temp.end(),
728           Vector<RealType, N_INTERACTION_FAMILIES> (0.0));
729        
730 <    AtomCommPotColumn->scatter(pot_col, pot_temp);    
730 >    AtomPlanPotColumn->scatter(pot_col, pot_temp);    
731      
732      for (int ii = 0;  ii < pot_temp.size(); ii++ )
733        pairwisePot += pot_temp[ii];    
734   #endif
735  
736 +    cerr << "pairwisePot = " <<  pairwisePot << "\n";
737    }
738  
739    int ForceMatrixDecomposition::getNAtomsInRow() {  
# Line 698 | Line 768 | namespace OpenMD {
768      
769   #ifdef IS_MPI
770      d = cgColData.position[cg2] - cgRowData.position[cg1];
771 +    cerr << "cg1 = " << cg1 << "\tcg1p = " << cgRowData.position[cg1] << "\n";
772 +    cerr << "cg2 = " << cg2 << "\tcg2p = " << cgColData.position[cg2] << "\n";
773   #else
774      d = snap_->cgData.position[cg2] - snap_->cgData.position[cg1];
775 +    cerr << "cg1 = " << cg1 << "\tcg1p = " << snap_->cgData.position[cg1] << "\n";
776 +    cerr << "cg2 = " << cg2 << "\tcg2p = " << snap_->cgData.position[cg2] << "\n";
777   #endif
778      
779      snap_->wrapVector(d);
# Line 774 | Line 848 | namespace OpenMD {
848     */
849    bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2) {
850      int unique_id_1, unique_id_2;
851 +    
852  
853 +    cerr << "sap with atom1, atom2 =\t" << atom1 << "\t" << atom2 << "\n";
854   #ifdef IS_MPI
855      // in MPI, we have to look up the unique IDs for each atom
856      unique_id_1 = AtomRowToGlobal[atom1];
857      unique_id_2 = AtomColToGlobal[atom2];
858  
859 +    cerr << "sap with uid1, uid2 =\t" << unique_id_1 << "\t" << unique_id_2 << "\n";
860      // this situation should only arise in MPI simulations
861      if (unique_id_1 == unique_id_2) return true;
862      
# Line 804 | Line 881 | namespace OpenMD {
881     */
882    bool ForceMatrixDecomposition::excludeAtomPair(int atom1, int atom2) {
883      int unique_id_2;
807    
884   #ifdef IS_MPI
885      // in MPI, we have to look up the unique IDs for the row atom.
886      unique_id_2 = AtomColToGlobal[atom2];
# Line 954 | Line 1030 | namespace OpenMD {
1030      
1031    }
1032  
1033 + vector<vector<int> > ForceMatrixDecomposition::buildLayerBasedNeighborList() {
1034 +        printf("buildLayerBasedNeighborList; nGroups:%d\n", nGroups_);
1035 +        // Na = nGroups_
1036 +        /* cell occupancy counter */
1037 +        vector<int> k_c;
1038 +        /* c_i - has cell containing atom i (size Na) */
1039 +        vector<int> c;
1040 +        /* l_i - layer containing atom i (size Na) */
1041 +        vector<int> l;
1042 +
1043 + //      cellList_.clear();
1044 +
1045 +        RealType rList_ = (largestRcut_ + skinThickness_);
1046 +        Snapshot* snap_ = sman_->getCurrentSnapshot();
1047 +        Mat3x3d Hmat = snap_->getHmat();
1048 +        Vector3d Hx = Hmat.getColumn(0);
1049 +        Vector3d Hy = Hmat.getColumn(1);
1050 +        Vector3d Hz = Hmat.getColumn(2);
1051 +
1052 +        nCells_.x() = (int) (Hx.length()) / rList_;
1053 +        nCells_.y() = (int) (Hy.length()) / rList_;
1054 +        nCells_.z() = (int) (Hz.length()) / rList_;
1055 +
1056 +        Mat3x3d invHmat = snap_->getInvHmat();
1057 +        Vector3d rs, scaled, dr;
1058 +        Vector3i whichCell;
1059 +        int cellIndex;
1060 +        int nCtot = nCells_.x() * nCells_.y() * nCells_.z();
1061 +
1062 + //      cellList_.resize(nCtot);
1063 +        k_c = vector<int>(nCtot, 0);
1064 +
1065 +        for (int i = 0; i < nGroups_; i++)
1066 +        {
1067 +                rs = snap_->cgData.position[i];
1068 +
1069 +                // scaled positions relative to the box vectors
1070 +                scaled = invHmat * rs;
1071 +
1072 +                // wrap the vector back into the unit box by subtracting integer box
1073 +                // numbers
1074 +                for (int j = 0; j < 3; j++)
1075 +                {
1076 +                        scaled[j] -= roundMe(scaled[j]);
1077 +                        scaled[j] += 0.5;
1078 +                }
1079 +
1080 +                // find xyz-indices of cell that cutoffGroup is in.
1081 +                whichCell.x() = nCells_.x() * scaled.x();
1082 +                whichCell.y() = nCells_.y() * scaled.y();
1083 +                whichCell.z() = nCells_.z() * scaled.z();
1084 +
1085 +                // find single index of this cell:
1086 +                cellIndex = Vlinear(whichCell, nCells_);
1087 +
1088 +                c.push_back(cellIndex);
1089 +
1090 + //              // add this cutoff group to the list of groups in this cell;
1091 + //              cellList_[cellIndex].push_back(i);
1092 +        }
1093 +
1094 +        int k_c_curr;
1095 +        int k_c_max = 0;
1096 +        /* the cell-layer occupancy matrix */
1097 +        vector<vector<int> > H_c_l = vector<vector<int> >(nCtot);
1098 +
1099 +        for(int i = 0; i < nGroups_; ++i)
1100 +        {
1101 +                k_c_curr = ++k_c[c[i]];
1102 +                l.push_back(k_c_curr);
1103 +
1104 +                /* determines the number of layers in use */
1105 +                if(k_c_max < k_c_curr)
1106 +                {
1107 +                        k_c_max = k_c_curr;
1108 +                }
1109 +
1110 +                H_c_l[c[i]].push_back(/*l[*/i/*]*/);
1111 +        }
1112 +
1113 +        int m;
1114 +        /* the neighbor matrix */
1115 +        vector<vector<int> >neighborMatW = vector<vector<int> >(nGroups_);
1116 +
1117 + //      vector<pair<int, int> > neighborList;
1118 +        groupCutoffs cuts;
1119 +
1120 +        /* loops over objects(atoms, rigidBodies, cutoffGroups, etc.) */
1121 +        for(int i = 0; i < nGroups_; ++i)
1122 +        {
1123 +                m = 0;
1124 +                /* c' */
1125 +                int c1 = c[i];
1126 +                Vector3i c1v = idxToV(c1, nCells_);
1127 +
1128 +                /* loops over the neighboring cells c'' */
1129 +                for (vector<Vector3i>::iterator os = cellOffsets_.begin(); os != cellOffsets_.end(); ++os)
1130 +                {
1131 +                        Vector3i c2v = c1v + (*os);
1132 +
1133 +                        if (c2v.x() >= nCells_.x())
1134 +                        {
1135 +                                c2v.x() = 0;
1136 +                        } else if (c2v.x() < 0)
1137 +                        {
1138 +                                c2v.x() = nCells_.x() - 1;
1139 +                        }
1140 +
1141 +                        if (c2v.y() >= nCells_.y())
1142 +                        {
1143 +                                c2v.y() = 0;
1144 +                        } else if (c2v.y() < 0)
1145 +                        {
1146 +                                c2v.y() = nCells_.y() - 1;
1147 +                        }
1148 +
1149 +                        if (c2v.z() >= nCells_.z())
1150 +                        {
1151 +                                c2v.z() = 0;
1152 +                        } else if (c2v.z() < 0)
1153 +                        {
1154 +                                c2v.z() = nCells_.z() - 1;
1155 +                        }
1156 +
1157 +                        int c2 = Vlinear(c2v, nCells_);
1158 +                        /* loops over layers l to access the neighbor atoms */
1159 +                        for (vector<int>::iterator j = H_c_l[c2].begin(); j != H_c_l[c2].end(); ++j)
1160 +                        {
1161 + //                              if i'' = 0 then break // doesn't apply to vector implementation of matrix
1162 + //                              if(i != *j)
1163 +                                if (c2 != c1 || (*j) < (i))
1164 +                                {
1165 +                                        dr = snap_->cgData.position[(*j)] - snap_->cgData.position[(i)];
1166 +                                        snap_->wrapVector(dr);
1167 +                                        cuts = getGroupCutoffs((i), (*j));
1168 +                                        if (dr.lengthSquare() < cuts.third)
1169 +                                        {
1170 +                                                ++m;
1171 +                                                /* transposed version of Rapaport W mat, to occupy successive memory locations on CPU */
1172 +                                                neighborMatW[i].push_back(*j);
1173 + //                                              neighborList.push_back(make_pair((i), (*j)));
1174 +                                        }
1175 +                                }
1176 +                        }
1177 +                }
1178 +        }
1179 +
1180 +        // save the local cutoff group positions for the check that is
1181 +        // done on each loop:
1182 +        saved_CG_positions_.clear();
1183 +        for (int i = 0; i < nGroups_; i++)
1184 +                saved_CG_positions_.push_back(snap_->cgData.position[i]);
1185 +
1186 +        return neighborMatW;
1187 + }
1188 +
1189    /*
1190     * buildNeighborList
1191     *
# Line 1031 | Line 1263 | namespace OpenMD {
1263          // add this cutoff group to the list of groups in this cell;
1264          cellListRow_[cellIndex].push_back(i);
1265        }
1034      
1266        for (int i = 0; i < nGroupsInCol_; i++) {
1267          rs = cgColData.position[i];
1268          
# Line 1076 | Line 1307 | namespace OpenMD {
1307          whichCell.z() = nCells_.z() * scaled.z();
1308          
1309          // find single index of this cell:
1310 <        cellIndex = Vlinear(whichCell, nCells_);      
1310 >        cellIndex = Vlinear(whichCell, nCells_);
1311          
1312          // add this cutoff group to the list of groups in this cell;
1313          cellList_[cellIndex].push_back(i);
# Line 1120 | Line 1351 | namespace OpenMD {
1351                  for (vector<int>::iterator j2 = cellListCol_[m2].begin();
1352                       j2 != cellListCol_[m2].end(); ++j2) {
1353                    
1354 <                  // Always do this if we're in different cells or if
1355 <                  // we're in the same cell and the global index of the
1356 <                  // j2 cutoff group is less than the j1 cutoff group
1357 <                  
1358 <                  if (m2 != m1 || cgColToGlobal[(*j2)] < cgRowToGlobal[(*j1)]) {
1359 <                    dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)];
1360 <                    snap_->wrapVector(dr);
1361 <                    cuts = getGroupCutoffs( (*j1), (*j2) );
1131 <                    if (dr.lengthSquare() < cuts.third) {
1132 <                      neighborList.push_back(make_pair((*j1), (*j2)));
1133 <                    }
1134 <                  }
1354 >                  // In parallel, we need to visit *all* pairs of row &
1355 >                  // column indicies and will truncate later on.
1356 >                  dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)];
1357 >                  snap_->wrapVector(dr);
1358 >                  cuts = getGroupCutoffs( (*j1), (*j2) );
1359 >                  if (dr.lengthSquare() < cuts.third) {
1360 >                    neighborList.push_back(make_pair((*j1), (*j2)));
1361 >                  }                  
1362                  }
1363                }
1364   #else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines