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 1579 by gezelter, Thu Jun 9 20:26:29 2011 UTC vs.
Revision 1583 by gezelter, Thu Jun 16 22:00:08 2011 UTC

# Line 61 | Line 61 | namespace OpenMD {
61      nGroups_ = info_->getNLocalCutoffGroups();
62      cerr << "in dId, nGroups = " << nGroups_ << "\n";
63      // gather the information for atomtype IDs (atids):
64 <    identsLocal = info_->getIdentArray();
64 >    idents = info_->getIdentArray();
65      AtomLocalToGlobal = info_->getGlobalAtomIndices();
66      cgLocalToGlobal = info_->getGlobalGroupIndices();
67      vector<int> globalGroupMembership = info_->getGlobalGroupMembership();
68 <    vector<RealType> massFactorsLocal = info_->getMassFactors();
68 >    massFactors = info_->getMassFactors();
69      PairList excludes = info_->getExcludedInteractions();
70      PairList oneTwo = info_->getOneTwoInteractions();
71      PairList oneThree = info_->getOneThreeInteractions();
# Line 108 | Line 108 | namespace OpenMD {
108      identsRow.resize(nAtomsInRow_);
109      identsCol.resize(nAtomsInCol_);
110      
111 <    AtomCommIntRow->gather(identsLocal, identsRow);
112 <    AtomCommIntColumn->gather(identsLocal, identsCol);
111 >    AtomCommIntRow->gather(idents, identsRow);
112 >    AtomCommIntColumn->gather(idents, identsCol);
113      
114      AtomCommIntRow->gather(AtomLocalToGlobal, AtomRowToGlobal);
115      AtomCommIntColumn->gather(AtomLocalToGlobal, AtomColToGlobal);
# Line 117 | Line 117 | namespace OpenMD {
117      cgCommIntRow->gather(cgLocalToGlobal, cgRowToGlobal);
118      cgCommIntColumn->gather(cgLocalToGlobal, cgColToGlobal);
119  
120 <    AtomCommRealRow->gather(massFactorsLocal, massFactorsRow);
121 <    AtomCommRealColumn->gather(massFactorsLocal, massFactorsCol);
120 >    AtomCommRealRow->gather(massFactors, massFactorsRow);
121 >    AtomCommRealColumn->gather(massFactors, massFactorsCol);
122  
123      groupListRow_.clear();
124      groupListRow_.resize(nGroupsInRow_);
# Line 232 | Line 232 | namespace OpenMD {
232      set<AtomType*> atypes = info_->getSimulatedAtomTypes();
233      vector<RealType> atypeCutoff;
234      atypeCutoff.resize( atypes.size() );
235 <
235 >      
236      for (set<AtomType*>::iterator at = atypes.begin();
237           at != atypes.end(); ++at){
238      rc = interactionMan_->getSuggestedCutoffRadius(*at);
238        atid = (*at)->getIdent();
239 <      atypeCutoff[atid] = rc;
239 >
240 >      if (userChoseCutoff_)
241 >        atypeCutoff[atid] = userCutoff_;
242 >      else
243 >        atypeCutoff[atid] = interactionMan_->getSuggestedCutoffRadius(*at);
244      }
245  
246      vector<RealType> gTypeCutoffs;
# Line 309 | Line 312 | namespace OpenMD {
312        for (vector<int>::iterator ia = atomList.begin();
313             ia != atomList.end(); ++ia) {            
314          int atom1 = (*ia);
315 <        atid = identsLocal[atom1];
315 >        atid = idents[atom1];
316          if (atypeCutoff[atid] > groupCutoff[cg1]) {
317            groupCutoff[cg1] = atypeCutoff[atid];
318          }
# Line 378 | Line 381 | namespace OpenMD {
381            if (abs(gTypeCutoffMap[key].first - userCutoff_) > 0.0001) {
382              sprintf(painCave.errMsg,
383                      "ForceMatrixDecomposition::createGtypeCutoffMap "
384 <                    "user-specified rCut does not match computed group Cutoff\n");
384 >                    "user-specified rCut (%lf) does not match computed group Cutoff\n", userCutoff_);
385              painCave.severity = OPENMD_ERROR;
386              painCave.isFatal = 1;
387              simError();            
# Line 410 | Line 413 | namespace OpenMD {
413    }
414  
415    void ForceMatrixDecomposition::zeroWorkArrays() {
416 +    pairwisePot = 0.0;
417 +    embeddingPot = 0.0;
418  
414    for (int j = 0; j < N_INTERACTION_FAMILIES; j++) {
415      longRangePot_[j] = 0.0;
416    }
417
419   #ifdef IS_MPI
420      if (storageLayout_ & DataStorage::dslForce) {
421        fill(atomRowData.force.begin(), atomRowData.force.end(), V3Zero);
# Line 430 | Line 431 | namespace OpenMD {
431           Vector<RealType, N_INTERACTION_FAMILIES> (0.0));
432  
433      fill(pot_col.begin(), pot_col.end(),
434 <         Vector<RealType, N_INTERACTION_FAMILIES> (0.0));
434 <    
435 <    pot_local = Vector<RealType, N_INTERACTION_FAMILIES>(0.0);
434 >         Vector<RealType, N_INTERACTION_FAMILIES> (0.0));  
435  
436      if (storageLayout_ & DataStorage::dslParticlePot) {    
437        fill(atomRowData.particlePot.begin(), atomRowData.particlePot.end(), 0.0);
# Line 606 | Line 605 | namespace OpenMD {
605      AtomCommPotRow->scatter(pot_row, pot_temp);
606  
607      for (int ii = 0;  ii < pot_temp.size(); ii++ )
608 <      pot_local += pot_temp[ii];
608 >      pairwisePot += pot_temp[ii];
609      
610      fill(pot_temp.begin(), pot_temp.end(),
611           Vector<RealType, N_INTERACTION_FAMILIES> (0.0));
612        
613      AtomCommPotColumn->scatter(pot_col, pot_temp);    
615    
616    for (int ii = 0;  ii < pot_temp.size(); ii++ )
617      pot_local += pot_temp[ii];
614      
615 +    for (int ii = 0;  ii < pot_temp.size(); ii++ )
616 +      pairwisePot += pot_temp[ii];    
617   #endif
618 +
619    }
620  
621    int ForceMatrixDecomposition::getNAtomsInRow() {  
# Line 691 | Line 690 | namespace OpenMD {
690   #ifdef IS_MPI
691      return massFactorsRow[atom1];
692   #else
693 <    return massFactorsLocal[atom1];
693 >    return massFactors[atom1];
694   #endif
695    }
696  
# Line 699 | Line 698 | namespace OpenMD {
698   #ifdef IS_MPI
699      return massFactorsCol[atom2];
700   #else
701 <    return massFactorsLocal[atom2];
701 >    return massFactors[atom2];
702   #endif
703  
704    }
# Line 754 | Line 753 | namespace OpenMD {
753      for (vector<int>::iterator i = skipsForAtom[atom1].begin();
754           i != skipsForAtom[atom1].end(); ++i) {
755        if ( (*i) == unique_id_2 ) return true;
756 <    }    
756 >    }
757  
758 +    return false;
759    }
760  
761  
# Line 776 | Line 776 | namespace OpenMD {
776    }
777  
778      // filling interaction blocks with pointers
779 <  InteractionData ForceMatrixDecomposition::fillInteractionData(int atom1, int atom2) {    
780 <    InteractionData idat;
781 <
779 >  void ForceMatrixDecomposition::fillInteractionData(InteractionData &idat,
780 >                                                     int atom1, int atom2) {    
781   #ifdef IS_MPI
782      
783      idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]),
784                               ff_->getAtomType(identsCol[atom2]) );
786
785      
786      if (storageLayout_ & DataStorage::dslAmat) {
787        idat.A1 = &(atomRowData.aMat[atom1]);
# Line 822 | Line 820 | namespace OpenMD {
820  
821   #else
822  
823 <    idat.atypes = make_pair( ff_->getAtomType(identsLocal[atom1]),
824 <                             ff_->getAtomType(identsLocal[atom2]) );
823 >    idat.atypes = make_pair( ff_->getAtomType(idents[atom1]),
824 >                             ff_->getAtomType(idents[atom2]) );
825  
826      if (storageLayout_ & DataStorage::dslAmat) {
827        idat.A1 = &(snap_->atomData.aMat[atom1]);
# Line 840 | Line 838 | namespace OpenMD {
838        idat.t2 = &(snap_->atomData.torque[atom2]);
839      }
840  
841 <    if (storageLayout_ & DataStorage::dslDensity) {
841 >    if (storageLayout_ & DataStorage::dslDensity) {    
842        idat.rho1 = &(snap_->atomData.density[atom1]);
843        idat.rho2 = &(snap_->atomData.density[atom2]);
844      }
# Line 861 | Line 859 | namespace OpenMD {
859      }
860  
861   #endif
864    return idat;
862    }
863  
864    
865 <  void ForceMatrixDecomposition::unpackInteractionData(InteractionData idat, int atom1, int atom2) {    
865 >  void ForceMatrixDecomposition::unpackInteractionData(InteractionData &idat, int atom1, int atom2) {    
866   #ifdef IS_MPI
867      pot_row[atom1] += 0.5 *  *(idat.pot);
868      pot_col[atom2] += 0.5 *  *(idat.pot);
# Line 873 | Line 870 | namespace OpenMD {
870      atomRowData.force[atom1] += *(idat.f1);
871      atomColData.force[atom2] -= *(idat.f1);
872   #else
873 <    longRangePot_ += *(idat.pot);
874 <    
873 >    pairwisePot += *(idat.pot);
874 >
875      snap_->atomData.force[atom1] += *(idat.f1);
876      snap_->atomData.force[atom2] -= *(idat.f1);
877   #endif
# Line 882 | Line 879 | namespace OpenMD {
879    }
880  
881  
882 <  InteractionData ForceMatrixDecomposition::fillSkipData(int atom1, int atom2){
883 <
884 <    InteractionData idat;
882 >  void ForceMatrixDecomposition::fillSkipData(InteractionData &idat,
883 >                                              int atom1, int atom2) {
884 >    // Still Missing:: skippedCharge fill must be added to DataStorage
885   #ifdef IS_MPI
886      idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]),
887                               ff_->getAtomType(identsCol[atom2]) );
# Line 898 | Line 895 | namespace OpenMD {
895        idat.t2 = &(atomColData.torque[atom2]);
896      }
897   #else
898 <    idat.atypes = make_pair( ff_->getAtomType(identsLocal[atom1]),
899 <                             ff_->getAtomType(identsLocal[atom2]) );
898 >    idat.atypes = make_pair( ff_->getAtomType(idents[atom1]),
899 >                             ff_->getAtomType(idents[atom2]) );
900  
901      if (storageLayout_ & DataStorage::dslElectroFrame) {
902        idat.eFrame1 = &(snap_->atomData.electroFrame[atom1]);
# Line 912 | Line 909 | namespace OpenMD {
909   #endif    
910    }
911  
912 +
913 +  void ForceMatrixDecomposition::unpackSkipData(InteractionData &idat, int atom1, int atom2) {    
914 + #ifdef IS_MPI
915 +    pot_row[atom1] += 0.5 *  *(idat.pot);
916 +    pot_col[atom2] += 0.5 *  *(idat.pot);
917 + #else
918 +    pairwisePot += *(idat.pot);  
919 + #endif
920 +
921 +  }
922 +
923 +
924    /*
925     * buildNeighborList
926     *
# Line 957 | Line 966 | namespace OpenMD {
966   #ifdef IS_MPI
967      for (int i = 0; i < nGroupsInRow_; i++) {
968        rs = cgRowData.position[i];
969 +
970        // scaled positions relative to the box vectors
971        scaled = invHmat * rs;
972 +
973        // wrap the vector back into the unit box by subtracting integer box
974        // numbers
975 <      for (int j = 0; j < 3; j++)
975 >      for (int j = 0; j < 3; j++) {
976          scaled[j] -= roundMe(scaled[j]);
977 +        scaled[j] += 0.5;
978 +      }
979      
980        // find xyz-indices of cell that cutoffGroup is in.
981        whichCell.x() = nCells_.x() * scaled.x();
# Line 971 | Line 984 | namespace OpenMD {
984  
985        // find single index of this cell:
986        cellIndex = Vlinear(whichCell, nCells_);
987 +
988        // add this cutoff group to the list of groups in this cell;
989        cellListRow_[cellIndex].push_back(i);
990      }
991  
992      for (int i = 0; i < nGroupsInCol_; i++) {
993        rs = cgColData.position[i];
994 +
995        // scaled positions relative to the box vectors
996        scaled = invHmat * rs;
997 +
998        // wrap the vector back into the unit box by subtracting integer box
999        // numbers
1000 <      for (int j = 0; j < 3; j++)
1000 >      for (int j = 0; j < 3; j++) {
1001          scaled[j] -= roundMe(scaled[j]);
1002 +        scaled[j] += 0.5;
1003 +      }
1004  
1005        // find xyz-indices of cell that cutoffGroup is in.
1006        whichCell.x() = nCells_.x() * scaled.x();
# Line 991 | Line 1009 | namespace OpenMD {
1009  
1010        // find single index of this cell:
1011        cellIndex = Vlinear(whichCell, nCells_);
1012 +
1013        // add this cutoff group to the list of groups in this cell;
1014        cellListCol_[cellIndex].push_back(i);
1015      }
1016   #else
1017      for (int i = 0; i < nGroups_; i++) {
1018        rs = snap_->cgData.position[i];
1019 +
1020        // scaled positions relative to the box vectors
1021        scaled = invHmat * rs;
1022 +
1023        // wrap the vector back into the unit box by subtracting integer box
1024        // numbers
1025 <      for (int j = 0; j < 3; j++)
1025 >      for (int j = 0; j < 3; j++) {
1026          scaled[j] -= roundMe(scaled[j]);
1027 +        scaled[j] += 0.5;
1028 +      }
1029  
1030        // find xyz-indices of cell that cutoffGroup is in.
1031        whichCell.x() = nCells_.x() * scaled.x();
# Line 1010 | Line 1033 | namespace OpenMD {
1033        whichCell.z() = nCells_.z() * scaled.z();
1034  
1035        // find single index of this cell:
1036 <      cellIndex = Vlinear(whichCell, nCells_);
1036 >      cellIndex = Vlinear(whichCell, nCells_);      
1037 >
1038        // add this cutoff group to the list of groups in this cell;
1039        cellList_[cellIndex].push_back(i);
1040      }
# Line 1068 | Line 1092 | namespace OpenMD {
1092                }
1093              }
1094   #else
1095 +
1096              for (vector<int>::iterator j1 = cellList_[m1].begin();
1097                   j1 != cellList_[m1].end(); ++j1) {
1098                for (vector<int>::iterator j2 = cellList_[m2].begin();
1099                     j2 != cellList_[m2].end(); ++j2) {
1100 <                              
1100 >
1101                  // Always do this if we're in different cells or if
1102                  // we're in the same cell and the global index of the
1103                  // j2 cutoff group is less than the j1 cutoff group
# Line 1092 | Line 1117 | namespace OpenMD {
1117          }
1118        }
1119      }
1120 <
1120 >    
1121      // save the local cutoff group positions for the check that is
1122      // done on each loop:
1123      saved_CG_positions_.clear();
1124      for (int i = 0; i < nGroups_; i++)
1125        saved_CG_positions_.push_back(snap_->cgData.position[i]);
1126 <
1126 >  
1127      return neighborList;
1128    }
1129   } //end namespace OpenMD

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines