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

Comparing branches/development/src/parallel/ForceMatrixDecomposition.cpp (file contents):
Revision 1723 by gezelter, Thu May 24 20:59:54 2012 UTC vs.
Revision 1756 by gezelter, Mon Jun 18 18:23:20 2012 UTC

# Line 461 | Line 461 | namespace OpenMD {
461      }
462    }
463  
464
464    groupCutoffs ForceMatrixDecomposition::getGroupCutoffs(int cg1, int cg2) {
465      int i, j;  
466   #ifdef IS_MPI
# Line 852 | Line 851 | namespace OpenMD {
851        pairwisePot[ii] = ploc2;
852      }
853  
855    for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) {
856      RealType ploc1 = embeddingPot[ii];
857      RealType ploc2 = 0.0;
858      MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM);
859      embeddingPot[ii] = ploc2;
860    }
861    
854      // Here be dragons.
855      MPI::Intracomm col = colComm.getComm();
856  
# Line 868 | Line 860 | namespace OpenMD {
860  
861  
862   #endif
863 +
864 +  }
865 +
866 +  /**
867 +   * Collects information obtained during the post-pair (and embedding
868 +   * functional) loops onto local data structures.
869 +   */
870 +  void ForceMatrixDecomposition::collectSelfData() {
871 +    snap_ = sman_->getCurrentSnapshot();
872 +    storageLayout_ = sman_->getStorageLayout();
873  
874 + #ifdef IS_MPI
875 +    for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) {
876 +      RealType ploc1 = embeddingPot[ii];
877 +      RealType ploc2 = 0.0;
878 +      MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM);
879 +      embeddingPot[ii] = ploc2;
880 +    }    
881 + #endif
882 +    
883    }
884 +
885 +
886  
887    int ForceMatrixDecomposition::getNAtomsInRow() {  
888   #ifdef IS_MPI
# Line 993 | Line 1006 | namespace OpenMD {
1006     * We need to exclude some overcounted interactions that result from
1007     * the parallel decomposition.
1008     */
1009 <  bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2) {
1010 <    int unique_id_1, unique_id_2;
1009 >  bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2, int cg1, int cg2) {
1010 >    int unique_id_1, unique_id_2, group1, group2;
1011          
1012   #ifdef IS_MPI
1013      // in MPI, we have to look up the unique IDs for each atom
1014      unique_id_1 = AtomRowToGlobal[atom1];
1015      unique_id_2 = AtomColToGlobal[atom2];
1016 +    group1 = cgRowToGlobal[cg1];
1017 +    group2 = cgColToGlobal[cg2];
1018   #else
1019      unique_id_1 = AtomLocalToGlobal[atom1];
1020      unique_id_2 = AtomLocalToGlobal[atom2];
1021 +    group1 = cgLocalToGlobal[cg1];
1022 +    group2 = cgLocalToGlobal[cg2];
1023   #endif  
1024  
1025      if (unique_id_1 == unique_id_2) return true;
# Line 1014 | Line 1031 | namespace OpenMD {
1031      } else {
1032        if ((unique_id_1 + unique_id_2) % 2 == 1) return true;
1033      }
1034 + #endif    
1035 +
1036 + #ifndef IS_MPI
1037 +    if (group1 == group2) {
1038 +      if (unique_id_1 < unique_id_2) return true;
1039 +    }
1040   #endif
1041      
1042      return false;
# Line 1116 | Line 1139 | namespace OpenMD {
1139  
1140   #else
1141      
1119
1120    // cerr << "atoms = " << atom1 << " " << atom2 << "\n";
1121    // cerr << "pos1 = " << snap_->atomData.position[atom1] << "\n";
1122    // cerr << "pos2 = " << snap_->atomData.position[atom2] << "\n";
1123
1142      idat.atypes = make_pair( atypesLocal[atom1], atypesLocal[atom2]);
1125    //idat.atypes = make_pair( ff_->getAtomType(idents[atom1]),
1126    //                         ff_->getAtomType(idents[atom2]) );
1143  
1144      if (storageLayout_ & DataStorage::dslAmat) {
1145        idat.A1 = &(snap_->atomData.aMat[atom1]);
# Line 1183 | Line 1199 | namespace OpenMD {
1199      atomColData.force[atom2] -= *(idat.f1);
1200  
1201      if (storageLayout_ & DataStorage::dslFlucQForce) {              
1202 <      atomRowData.flucQFrc[atom1] += *(idat.dVdFQ1);
1203 <      atomColData.flucQFrc[atom2] += *(idat.dVdFQ2);
1202 >      atomRowData.flucQFrc[atom1] -= *(idat.dVdFQ1);
1203 >      atomColData.flucQFrc[atom2] -= *(idat.dVdFQ2);
1204      }
1205  
1206      if (storageLayout_ & DataStorage::dslElectricField) {              
# Line 1208 | Line 1224 | namespace OpenMD {
1224      }
1225      
1226      if (storageLayout_ & DataStorage::dslFlucQForce) {              
1227 <      snap_->atomData.flucQFrc[atom1] += *(idat.dVdFQ1);
1227 >      snap_->atomData.flucQFrc[atom1] -= *(idat.dVdFQ1);
1228        snap_->atomData.flucQFrc[atom2] -= *(idat.dVdFQ2);
1229      }
1230  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines