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 1203 by gezelter, Thu May 27 18:59:17 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  
# Line 442 | Line 445 | void SimInfo::refreshSim(){
445    excl = excludes->getFortranArray();
446    
447   #ifdef IS_MPI
448 <  n_global = mpiSim->getTotAtoms();
448 >  n_global = mpiSim->getNAtomsGlobal();
449   #else
450    n_global = n_atoms;
451   #endif
# 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;
591 <  
592 <  if(info->useMolecularCutoffs){
593 <    
594 < #ifdef IS_MPI
595 <    ngroup = mpiSim->getMyNMol();
596 < #else
597 <    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;
592 <
593 <      for(int j=0; j < numAtom; j++)
594 <        mtot += myAtoms[j]->getMass();                
595 <      
596 <      for(int j=0; j < numAtom; j++){
597 <              
598 <        // We want the local Index:
599 <        groupList.push_back(myAtoms[j]->getIndex() + 1);
600 <        mfact.push_back(myAtoms[j]->getMass() / mtot);
591 >
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 <      groupStart.push_back(curIndex);
602 <      curIndex += numAtom;
603 <      
604 <    } //end for(int i =0 ; i < ngroup; i++)    
605 <  }
609 <  else{
610 <    //using atomic cutoff, every single atom is just a group
611 <    
612 < #ifdef IS_MPI
613 <    ngroup = mpiSim->getMyNlocal();
601 >      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL;
602 >                                           cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){
603 >        mfact.push_back(cutoffAtom->getMass()/totalMass);
604 > #ifdef IS_MPI        
605 >        groupList.push_back(cutoffAtom->getGlobalIndex() + 1);
606   #else
607 <    ngroup = info->n_atoms;
607 >        groupList.push_back(cutoffAtom->getIndex() + 1);
608   #endif
609 <    
610 <    for(int i =0 ; i < ngroup; i++){
611 <      groupStart.push_back(curIndex++);      
612 <      groupList.push_back((info->atoms[i])->getIndex() + 1);
613 <      mfact.push_back(1.0);
614 <      
615 <    }//end for(int i =0 ; i < ngroup; i++)
616 <    
617 <  }//end if (info->useMolecularCutoffs)
618 <  
609 >      }  
610 >                              
611 >      groupStart.push_back(curIndex);
612 >      curIndex += myCutoffGroup->getNumAtom();
613 >
614 >    }//end for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff))
615 >
616 >  }//end for(int i  = 0; i < numMol; i++)
617 >
618 >
619 >  //The last cutoff group need more element to indicate the end of the cutoff
620 >  ngroup = groupStart.size();
621   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines