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

Comparing trunk/OOPSE/libmdtools/SimInfo.cpp (file contents):
Revision 1154 by gezelter, Tue May 11 16:00:22 2004 UTC vs.
Revision 1157 by tim, Tue May 11 20:33:41 2004 UTC

# Line 62 | Line 62 | SimInfo::SimInfo(){
62    useReactionField = 0;
63    useGB = 0;
64    useEAM = 0;
65 +  
66 +  haveCutoffGroups = false;
67  
68    excludes = Exclude::Instance();
69  
# Line 450 | Line 452 | void SimInfo::refreshSim(){
452    isError = 0;
453    
454    getFortranGroupArray(this, mfact, ngroup, groupList, groupStart);
455 <  
455 >  //it may not be a good idea to pass the address of first element in vector
456 >  //since c++ standard does not require vector to be stored continously in meomory
457 >  //Most of the compilers will organize the memory of vector continously
458    setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
459                    &nGlobalExcludes, globalExcludes, molMembershipArray,
460                    &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError);
# Line 563 | Line 567 | void getFortranGroupArray(SimInfo* info, vector<double
567  
568   void getFortranGroupArray(SimInfo* info, vector<double>& mfact, int& ngroup,
569                            vector<int>& groupList, vector<int>& groupStart){
570 <  Molecule* mol;
570 >  Molecule* myMols;
571    Atom** myAtoms;
572    int numAtom;
573    int curIndex;
574    double mtot;
575 <
575 >  int numMol;
576 >  int numCutoffGroups;
577 >  CutoffGroup* myCutoffGroup;
578 >  vector<CutoffGroup*>::iterator iterCutoff;
579 >  Atom* cutoffAtom;
580 >  vector<Atom*>::iterator iterAtom;
581 >  int atomIndex;
582 >  
583    mfact.clear();
584    groupList.clear();
585    groupStart.clear();
586    
587    //Be careful, fortran array begin at 1
588    curIndex = 1;
589 <  
590 <  if(info->useMolecularCutoffs){
591 <    
592 < #ifdef IS_MPI
593 <    ngroup = mpiSim->getMyNMol();
594 < #else
595 <    ngroup = info->n_mol;
585 < #endif
589 >
590 >  myMols = info->molecules;
591 >  numMol = info->n_mol;
592 >  for(int i  = 0; i < numMol; i++){
593 >    numAtom = myMols[i].getNAtoms();
594 >    myAtoms = myMols[i].getMyAtoms();
595 >
596      
597 <    for(int i = 0; i < ngroup; i ++){
588 <      mol = &(info->molecules[i]);
589 <      numAtom = mol->getNAtoms();
590 <      myAtoms = mol->getMyAtoms();
591 <      mtot = 0.0;
597 >    for(int j = 0; j < numAtom; j++){
598  
599 <      for(int j=0; j < numAtom; j++)
600 <        mtot += myAtoms[j]->getMass();                
601 <      
602 <      for(int j=0; j < numAtom; j++){
603 <              
604 <        // We want the local Index:
599 <        groupList.push_back(myAtoms[j]->getIndex() + 1);
600 <        mfact.push_back(myAtoms[j]->getMass() / mtot);
599 >    
600 > #ifdef IS_MPI      
601 >      atomIndex = myAtoms[j]->getGlobalIndex();
602 > #else
603 >      atomIndex = myAtoms[j]->getIndex();
604 > #endif
605  
606 +      if(myMols[i].belongToCutoffGroup(atomIndex))
607 +        continue;
608 +      else{
609 +        mfact.push_back(myAtoms[j]->getMass());
610 +        groupList.push_back(myAtoms[j]->getIndex() + 1);
611 +        groupStart.push_back(curIndex++);  
612        }
613 +    }
614        
615 <      groupStart.push_back(curIndex);
616 <      curIndex += numAtom;
615 >    numCutoffGroups = myMols[i].getNCutoffGroups();
616 >    for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff); myCutoffGroup != NULL;
617 >                                                  myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){
618        
619 <    } //end for(int i =0 ; i < ngroup; i++)    
620 <  }
621 <  else{
622 <    //using atomic cutoff, every single atom is just a group
619 >      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL;
620 >                                           cutoffAtom = myCutoffGroup->beginAtom(iterAtom)){
621 >        groupList.push_back(cutoffAtom->getIndex() + 1);
622 >      }  
623 >                              
624 >      groupStart.push_back(curIndex);
625 >      curIndex += myCutoffGroup->getNumAtom();
626 >    }
627      
628 < #ifdef IS_MPI
629 <    ngroup = mpiSim->getMyNlocal();
630 < #else
615 <    ngroup = info->n_atoms;
616 < #endif
617 <    
618 <    for(int i =0 ; i < ngroup; i++){
619 <      groupStart.push_back(curIndex++);      
620 <      groupList.push_back((info->atoms[i])->getIndex() + 1);
621 <      mfact.push_back(1.0);
622 <      
623 <    }//end for(int i =0 ; i < ngroup; i++)
624 <    
625 <  }//end if (info->useMolecularCutoffs)
626 <  
628 >  }
629 >
630 >  ngroup = groupStart.size();
631   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines