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 1713 by gezelter, Sat May 19 14:21:02 2012 UTC vs.
Revision 1755 by gezelter, Thu Jun 14 01:58:35 2012 UTC

# Line 95 | Line 95 | namespace OpenMD {
95      storageLayout_ = sman_->getStorageLayout();
96      ff_ = info_->getForceField();
97      nLocal_ = snap_->getNumberOfAtoms();
98 <    
98 >  
99      nGroups_ = info_->getNLocalCutoffGroups();
100      // gather the information for atomtype IDs (atids):
101      idents = info_->getIdentArray();
# Line 109 | Line 109 | namespace OpenMD {
109      PairList* oneTwo = info_->getOneTwoInteractions();
110      PairList* oneThree = info_->getOneThreeInteractions();
111      PairList* oneFour = info_->getOneFourInteractions();
112 <
112 >    
113 >    if (needVelocities_)
114 >      snap_->cgData.setStorageLayout(DataStorage::dslPosition |
115 >                                     DataStorage::dslVelocity);
116 >    else
117 >      snap_->cgData.setStorageLayout(DataStorage::dslPosition);
118 >    
119   #ifdef IS_MPI
120  
121      MPI::Intracomm row = rowComm.getComm();
# Line 145 | Line 151 | namespace OpenMD {
151      cgRowData.resize(nGroupsInRow_);
152      cgRowData.setStorageLayout(DataStorage::dslPosition);
153      cgColData.resize(nGroupsInCol_);
154 <    cgColData.setStorageLayout(DataStorage::dslPosition);
155 <        
154 >    if (needVelocities_)
155 >      // we only need column velocities if we need them.
156 >      cgColData.setStorageLayout(DataStorage::dslPosition |
157 >                                 DataStorage::dslVelocity);
158 >    else    
159 >      cgColData.setStorageLayout(DataStorage::dslPosition);
160 >      
161      identsRow.resize(nAtomsInRow_);
162      identsCol.resize(nAtomsInCol_);
163      
# Line 523 | Line 534 | namespace OpenMD {
534             atomRowData.skippedCharge.end(), 0.0);
535        fill(atomColData.skippedCharge.begin(),
536             atomColData.skippedCharge.end(), 0.0);
537 +    }
538 +
539 +    if (storageLayout_ & DataStorage::dslFlucQForce) {      
540 +      fill(atomRowData.flucQFrc.begin(),
541 +           atomRowData.flucQFrc.end(), 0.0);
542 +      fill(atomColData.flucQFrc.begin(),
543 +           atomColData.flucQFrc.end(), 0.0);
544      }
545  
546      if (storageLayout_ & DataStorage::dslElectricField) {    
# Line 531 | Line 549 | namespace OpenMD {
549        fill(atomColData.electricField.begin(),
550             atomColData.electricField.end(), V3Zero);
551      }
552 +
553      if (storageLayout_ & DataStorage::dslFlucQForce) {    
554        fill(atomRowData.flucQFrc.begin(), atomRowData.flucQFrc.end(),
555             0.0);
# Line 592 | Line 611 | namespace OpenMD {
611      cgPlanVectorColumn->gather(snap_->cgData.position,
612                                 cgColData.position);
613  
614 +
615 +
616 +    if (needVelocities_) {
617 +      // gather up the atomic velocities
618 +      AtomPlanVectorColumn->gather(snap_->atomData.velocity,
619 +                                   atomColData.velocity);
620 +      
621 +      cgPlanVectorColumn->gather(snap_->cgData.velocity,
622 +                                 cgColData.velocity);
623 +    }
624 +
625      
626      // if needed, gather the atomic rotation matrices
627      if (storageLayout_ & DataStorage::dslAmat) {
# Line 758 | Line 788 | namespace OpenMD {
788  
789      for (int ii = 0;  ii < pot_temp.size(); ii++ )
790        pairwisePot += pot_temp[ii];
791 <    
791 >        
792 >    if (storageLayout_ & DataStorage::dslParticlePot) {
793 >      // This is the pairwise contribution to the particle pot.  The
794 >      // embedding contribution is added in each of the low level
795 >      // non-bonded routines.  In single processor, this is done in
796 >      // unpackInteractionData, not in collectData.
797 >      for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) {
798 >        for (int i = 0; i < nLocal_; i++) {
799 >          // factor of two is because the total potential terms are divided
800 >          // by 2 in parallel due to row/ column scatter      
801 >          snap_->atomData.particlePot[i] += 2.0 * pot_temp[i](ii);
802 >        }
803 >      }
804 >    }
805 >
806      fill(pot_temp.begin(), pot_temp.end(),
807           Vector<RealType, N_INTERACTION_FAMILIES> (0.0));
808        
# Line 766 | Line 810 | namespace OpenMD {
810      
811      for (int ii = 0;  ii < pot_temp.size(); ii++ )
812        pairwisePot += pot_temp[ii];    
813 +
814 +    if (storageLayout_ & DataStorage::dslParticlePot) {
815 +      // This is the pairwise contribution to the particle pot.  The
816 +      // embedding contribution is added in each of the low level
817 +      // non-bonded routines.  In single processor, this is done in
818 +      // unpackInteractionData, not in collectData.
819 +      for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) {
820 +        for (int i = 0; i < nLocal_; i++) {
821 +          // factor of two is because the total potential terms are divided
822 +          // by 2 in parallel due to row/ column scatter      
823 +          snap_->atomData.particlePot[i] += 2.0 * pot_temp[i](ii);
824 +        }
825 +      }
826 +    }
827      
828 +    if (storageLayout_ & DataStorage::dslParticlePot) {
829 +      int npp = snap_->atomData.particlePot.size();
830 +      vector<RealType> ppot_temp(npp, 0.0);
831 +
832 +      // This is the direct or embedding contribution to the particle
833 +      // pot.
834 +      
835 +      AtomPlanRealRow->scatter(atomRowData.particlePot, ppot_temp);
836 +      for (int i = 0; i < npp; i++) {
837 +        snap_->atomData.particlePot[i] += ppot_temp[i];
838 +      }
839 +
840 +      fill(ppot_temp.begin(), ppot_temp.end(), 0.0);
841 +      
842 +      AtomPlanRealColumn->scatter(atomColData.particlePot, ppot_temp);
843 +      for (int i = 0; i < npp; i++) {
844 +        snap_->atomData.particlePot[i] += ppot_temp[i];
845 +      }
846 +    }
847 +
848      for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) {
849        RealType ploc1 = pairwisePot[ii];
850        RealType ploc2 = 0.0;
# Line 780 | Line 858 | namespace OpenMD {
858        MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM);
859        embeddingPot[ii] = ploc2;
860      }
861 +    
862 +    // Here be dragons.
863 +    MPI::Intracomm col = colComm.getComm();
864  
865 +    col.Allreduce(MPI::IN_PLACE,
866 +                  &snap_->frameData.conductiveHeatFlux[0], 3,
867 +                  MPI::REALTYPE, MPI::SUM);
868 +
869 +
870   #endif
871  
872    }
# Line 823 | Line 909 | namespace OpenMD {
909      
910      snap_->wrapVector(d);
911      return d;    
912 +  }
913 +
914 +  Vector3d ForceMatrixDecomposition::getGroupVelocityColumn(int cg2){
915 + #ifdef IS_MPI
916 +    return cgColData.velocity[cg2];
917 + #else
918 +    return snap_->cgData.velocity[cg2];
919 + #endif
920    }
921  
922 +  Vector3d ForceMatrixDecomposition::getAtomVelocityColumn(int atom2){
923 + #ifdef IS_MPI
924 +    return atomColData.velocity[atom2];
925 + #else
926 +    return snap_->atomData.velocity[atom2];
927 + #endif
928 +  }
929  
930 +
931    Vector3d ForceMatrixDecomposition::getAtomToGroupVectorRow(int atom1, int cg1){
932  
933      Vector3d d;
# Line 1007 | Line 1109 | namespace OpenMD {
1109        idat.skippedCharge2 = &(atomColData.skippedCharge[atom2]);
1110      }
1111  
1112 +    if (storageLayout_ & DataStorage::dslFlucQPosition) {              
1113 +      idat.flucQ1 = &(atomRowData.flucQPos[atom1]);
1114 +      idat.flucQ2 = &(atomColData.flucQPos[atom2]);
1115 +    }
1116 +
1117   #else
1118      
1012
1013    // cerr << "atoms = " << atom1 << " " << atom2 << "\n";
1014    // cerr << "pos1 = " << snap_->atomData.position[atom1] << "\n";
1015    // cerr << "pos2 = " << snap_->atomData.position[atom2] << "\n";
1016
1119      idat.atypes = make_pair( atypesLocal[atom1], atypesLocal[atom2]);
1018    //idat.atypes = make_pair( ff_->getAtomType(idents[atom1]),
1019    //                         ff_->getAtomType(idents[atom2]) );
1120  
1121      if (storageLayout_ & DataStorage::dslAmat) {
1122        idat.A1 = &(snap_->atomData.aMat[atom1]);
# Line 1057 | Line 1157 | namespace OpenMD {
1157        idat.skippedCharge1 = &(snap_->atomData.skippedCharge[atom1]);
1158        idat.skippedCharge2 = &(snap_->atomData.skippedCharge[atom2]);
1159      }
1160 +
1161 +    if (storageLayout_ & DataStorage::dslFlucQPosition) {              
1162 +      idat.flucQ1 = &(snap_->atomData.flucQPos[atom1]);
1163 +      idat.flucQ2 = &(snap_->atomData.flucQPos[atom2]);
1164 +    }
1165 +
1166   #endif
1167    }
1168  
# Line 1069 | Line 1175 | namespace OpenMD {
1175      atomRowData.force[atom1] += *(idat.f1);
1176      atomColData.force[atom2] -= *(idat.f1);
1177  
1178 <    // should particle pot be done here also?
1178 >    if (storageLayout_ & DataStorage::dslFlucQForce) {              
1179 >      atomRowData.flucQFrc[atom1] -= *(idat.dVdFQ1);
1180 >      atomColData.flucQFrc[atom2] -= *(idat.dVdFQ2);
1181 >    }
1182 >
1183 >    if (storageLayout_ & DataStorage::dslElectricField) {              
1184 >      atomRowData.electricField[atom1] += *(idat.eField1);
1185 >      atomColData.electricField[atom2] += *(idat.eField2);
1186 >    }
1187 >
1188   #else
1189      pairwisePot += *(idat.pot);
1190  
# Line 1077 | Line 1192 | namespace OpenMD {
1192      snap_->atomData.force[atom2] -= *(idat.f1);
1193  
1194      if (idat.doParticlePot) {
1195 +      // This is the pairwise contribution to the particle pot.  The
1196 +      // embedding contribution is added in each of the low level
1197 +      // non-bonded routines.  In parallel, this calculation is done
1198 +      // in collectData, not in unpackInteractionData.
1199        snap_->atomData.particlePot[atom1] += *(idat.vpair) * *(idat.sw);
1200 <      snap_->atomData.particlePot[atom2] -= *(idat.vpair) * *(idat.sw);
1200 >      snap_->atomData.particlePot[atom2] += *(idat.vpair) * *(idat.sw);
1201      }
1202 <      
1202 >    
1203 >    if (storageLayout_ & DataStorage::dslFlucQForce) {              
1204 >      snap_->atomData.flucQFrc[atom1] -= *(idat.dVdFQ1);
1205 >      snap_->atomData.flucQFrc[atom2] -= *(idat.dVdFQ2);
1206 >    }
1207 >
1208 >    if (storageLayout_ & DataStorage::dslElectricField) {              
1209 >      snap_->atomData.electricField[atom1] += *(idat.eField1);
1210 >      snap_->atomData.electricField[atom2] += *(idat.eField2);
1211 >    }
1212 >
1213   #endif
1214      
1215    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines