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 1167 by tim, Wed May 12 16:38:45 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 continuously in meomory
457 >  //Most of the compilers will organize the memory of vector continuously
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 >  double totalMass;
583 >  
584    mfact.clear();
585    groupList.clear();
586    groupStart.clear();
587    
588    //Be careful, fortran array begin at 1
589    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;
590  
591 <      for(int j=0; j < numAtom; j++)
592 <        mtot += myAtoms[j]->getMass();                
593 <      
594 <      for(int j=0; j < numAtom; j++){
595 <              
596 <        // We want the local Index:
599 <        groupList.push_back(myAtoms[j]->getIndex() + 1);
600 <        mfact.push_back(myAtoms[j]->getMass() / mtot);
591 >  myMols = info->molecules;
592 >  numMol = info->n_mol;
593 >  for(int i  = 0; i < numMol; i++){
594 >    numCutoffGroups = myMols[i].getNCutoffGroups();
595 >    for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff); myCutoffGroup != NULL;
596 >                                                  myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){
597  
598 <      }
598 >      totalMass = myCutoffGroup->getMass();
599        
600 +      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL;
601 +                                           cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){
602 +        mfact.push_back(cutoffAtom->getMass()/totalMass);
603 +        groupList.push_back(cutoffAtom->getIndex() + 1);
604 +      }  
605 +                              
606        groupStart.push_back(curIndex);
607 <      curIndex += numAtom;
608 <      
609 <    } //end for(int i =0 ; i < ngroup; i++)    
610 <  }
611 <  else{
610 <    //using atomic cutoff, every single atom is just a group
611 <    
612 < #ifdef IS_MPI
613 <    ngroup = mpiSim->getMyNlocal();
614 < #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)
607 >      curIndex += myCutoffGroup->getNumAtom();
608 >
609 >    }//end for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff))
610 >
611 >  }//end for(int i  = 0; i < numMol; i++)
612    
613 +  ngroup = groupStart.size();
614   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines