ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/SimSetup.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 1212 by chrisfen, Tue Jun 1 17:15:43 2004 UTC vs.
Revision 1229 by gezelter, Thu Jun 3 20:02:25 2004 UTC

# Line 171 | Line 171 | void SimSetup::makeMolecules(void){
171    int i, j, k;
172    int exI, exJ, exK, exL, slI, slJ;
173    int tempI, tempJ, tempK, tempL;
174 <  int molI;
175 <  int stampID, atomOffset, rbOffset;
174 >  int molI, globalID;
175 >  int stampID, atomOffset, rbOffset, groupOffset;
176    molInit molInfo;
177    DirectionalAtom* dAtom;
178    RigidBody* myRB;
# Line 216 | Line 216 | void SimSetup::makeMolecules(void){
216    for (k = 0; k < nInfo; k++){
217      the_ff->setSimInfo(&(info[k]));
218  
219 + #ifdef IS_MPI
220 +    info[k].globalGroupMembership = new int[mpiSim->getNAtomsGlobal()];
221 +    for (i = 0; i < mpiSim->getNAtomsGlobal(); i++)
222 +      info[k].globalGroupMembership[i] = 0;
223 + #else
224 +    info[k].globalGroupMembership = new int[info[k].n_atoms];
225 +    for (i = 0; i < info[k].n_atoms; i++)
226 +      info[k].globalGroupMembership[i] = 0;
227 + #endif
228 +
229      atomOffset = 0;
230      groupOffset = 0;
231  
# Line 282 | Line 292 | void SimSetup::makeMolecules(void){
292  
293          molInfo.myAtoms[j]->setType(currentAtom->getType());
294   #ifdef IS_MPI
285
295          molInfo.myAtoms[j]->setGlobalIndex(globalAtomIndex[j + atomOffset]);
287
296   #endif // is_mpi
297        }
298  
# Line 506 | Line 514 | void SimSetup::makeMolecules(void){
514          nMembers = currentCutoffGroup->getNMembers();
515  
516          myCutoffGroup = new CutoffGroup();
517 <        myCutoffGroup->setGlobalIndex(globalGroupIndex[j + groupOffset]);
517 >        
518 > #ifdef IS_MPI
519 >        myCutoffGroup->setGlobalIndex(globalGroupIndex[groupOffset]);
520 > #else
521 >        myCutoffGroup->setGlobalIndex(groupOffset);
522 > #endif
523          
524          for (int cg = 0; cg < nMembers; cg++) {
525  
# Line 517 | Line 530 | void SimSetup::makeMolecules(void){
530            tempI = molI + atomOffset;
531  
532   #ifdef IS_MPI
533 <          globalID = info[k].atoms[tempI]->getGlobalIndex()
533 >          globalID = info[k].atoms[tempI]->getGlobalIndex();
534 >          info[k].globalGroupMembership[globalID] = globalGroupIndex[groupOffset];
535   #else
536            globalID = info[k].atoms[tempI]->getIndex();
537 < #endif
538 <
539 <          globalGroupMembership[globalID] = globalGroupIndex[j+groupOffset];
526 <
527 <          myCutoffGroup->addAtom(info[k].atoms[tempI]);          
528 <
537 >          info[k].globalGroupMembership[globalID] = groupOffset;
538 > #endif                    
539 >          myCutoffGroup->addAtom(info[k].atoms[tempI]);
540            cutoffAtomSet.insert(tempI);
541          }
542 <      
542 >        
543          molInfo.myCutoffGroups.push_back(myCutoffGroup);
544          groupOffset++;
545  
546        }//end for (j = 0; j < molInfo.nCutoffGroups; j++)
547 <
548 <      //creat a cutoff group for every atom  in current molecule which does not belong to cutoffgroup defined at mdl file
549 <
547 >      
548 >      
549 >      // create a cutoff group for every atom in current molecule which
550 >      // does not belong to cutoffgroup defined at mdl file
551 >      
552        for(j = 0; j < molInfo.nAtoms; j++){
553 <
553 >        
554          if(cutoffAtomSet.find(molInfo.myAtoms[j]->getIndex()) == cutoffAtomSet.end()){
555            myCutoffGroup = new CutoffGroup();
556            myCutoffGroup->addAtom(molInfo.myAtoms[j]);
557 <          myCutoffGroup->setGlobalIndex(globalGroupIndex[j + groupOffset]);
557 >          
558   #ifdef IS_MPI
559 <          globalID = info[k].atoms[atomOffset + j]->getGlobalIndex()
560 < #else
559 >          myCutoffGroup->setGlobalIndex(globalGroupIndex[groupOffset]);
560 >          globalID = info[k].atoms[atomOffset + j]->getGlobalIndex();
561 >          info[k].globalGroupMembership[globalID] = globalGroupIndex[groupOffset];
562 > #else
563 >          myCutoffGroup->setGlobalIndex(groupOffset);
564            globalID = info[k].atoms[atomOffset + j]->getIndex();
565 +          info[k].globalGroupMembership[globalID] = groupOffset;
566   #endif
550          globalGroupMembership[globalID] = globalGroupIndex[j+groupOffset];
567            molInfo.myCutoffGroups.push_back(myCutoffGroup);
568            groupOffset++;
569 <        }
554 <          
569 >        }          
570        }
571  
572        // After this is all set up, scan through the atoms to
# Line 641 | Line 656 | void SimSetup::makeMolecules(void){
656                                   theTorsions);
657  
658        info[k].molecules[i].initialize(molInfo);
659 <
660 <
659 >      
660 >      
661        atomOffset += molInfo.nAtoms;
662        delete[] theBonds;
663        delete[] theBends;
664        delete[] theTorsions;
665 <    }    
665 >    }
666 >
667 >
668 >
669 > #ifdef IS_MPI    
670 >    // Since the globalGroupMembership has been zero filled and we've only
671 >    // poked values into the atoms we know, we can do an Allreduce
672 >    // to get the full globalGroupMembership array (We think).
673 >    // This would be prettier if we could use MPI_IN_PLACE like the MPI-2
674 >    // docs said we could.
675 >
676 >    int* ggMjunk = new int[mpiSim->getNAtomsGlobal()];    
677 >
678 >    MPI_Allreduce(info[k].globalGroupMembership,
679 >                  ggMjunk,
680 >                  mpiSim->getNAtomsGlobal(),
681 >                  MPI_INT, MPI_SUM, MPI_COMM_WORLD);
682 >
683 >    for (i = 0; i < mpiSim->getNAtomsGlobal(); i++)
684 >      info[k].globalGroupMembership[i] = ggMjunk[i];
685 >
686 >    delete[] ggMjunk;
687 >    
688 > #endif
689 >
690 >
691 >
692    }
693  
694   #ifdef IS_MPI
# Line 1609 | Line 1650 | void SimSetup::mpiMolDivide(void){
1650  
1651    mpiSim->divideLabor();
1652    globalAtomIndex = mpiSim->getGlobalAtomIndex();
1653 +  globalGroupIndex = mpiSim->getGlobalGroupIndex();
1654    //globalMolIndex = mpiSim->getGlobalMolIndex();
1655  
1656    // set up the local variables

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines