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 1198 by tim, Thu May 27 00:48:12 2004 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines