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 1144 by tim, Sat May 1 18:52:38 2004 UTC vs.
Revision 1150 by gezelter, Fri May 7 21:35:05 2004 UTC

# Line 448 | Line 448 | void SimInfo::refreshSim(){
448   #else
449    n_global = n_atoms;
450   #endif
451 <
451 >  
452    isError = 0;
453 <
454 < getFortranGroupArray(this, mfact, ngroup, groupList, groupStart);
455 <
453 >  
454 >  getFortranGroupArray(this, mfact, ngroup, groupList, groupStart);
455 >  
456    setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
457 <                                    &nGlobalExcludes, globalExcludes, molMembershipArray,
458 <                                    &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError );
459 <
460 <  if( isError ){
461 <
457 >                  &nGlobalExcludes, globalExcludes, molMembershipArray,
458 >                  &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError);
459 >  
460 >  if( isError ){
461 >    
462      sprintf( painCave.errMsg,
463 <             "There was an error setting the simulation information in fortran.\n" );
463 >             "There was an error setting the simulation information in fortran.\n" );
464      painCave.isFatal = 1;
465      simError();
466    }
467 <
467 >  
468   #ifdef IS_MPI
469    sprintf( checkPointMsg,
470             "succesfully sent the simulation information to fortran.\n");
471    MPIcheckPoint();
472   #endif // is_mpi
473 <
473 >  
474    this->ndf = this->getNDF();
475    this->ndfRaw = this->getNDFraw();
476    this->ndfTrans = this->getNDFtranslational();
477   }
478  
479   void SimInfo::setDefaultRcut( double theRcut ){
480 <
480 >  
481    haveRcut = 1;
482    rCut = theRcut;
483 <
483 >  
484    ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
485 <
485 >  
486    notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
487   }
488  
# Line 596 | Line 596 | void getFortranGroupArray(SimInfo* info, vector<double
596  
597  
598   void getFortranGroupArray(SimInfo* info, vector<double>& mfact, int& ngroup,
599 <                                                          vector<int>& groupList, vector<int>& groupStart){
599 >                          vector<int>& groupList, vector<int>& groupStart){
600    Molecule* mol;
601 +  Atom** myAtoms;
602    int numAtom;
603    int curIndex;
604 +  double mtot;
605  
606    mfact.clear();
607    groupList.clear();
608    groupStart.clear();
609 <
609 >  
610    //Be careful, fortran array begin at 1
611    curIndex = 1;
612 <    
612 >  
613    if(info->useMolecularCutoffs){
614 <    //if using molecular cutoff
614 >    
615 > #ifdef IS_MPI
616 >    ngroup = mpiSim->getMyNMol();
617 > #else
618      ngroup = info->n_mol;
619 <
619 > #endif
620 >    
621      for(int i = 0; i < ngroup; i ++){
622        mol = &(info->molecules[i]);
623        numAtom = mol->getNAtoms();
624 +      myAtoms = mol->getMyAtoms();
625 +      mtot = 0.0;
626 +
627 +      for(int j=0; j < numAtom; j++)
628 +        mtot += myAtoms[j]->getMass();                
629        
630 <      for(int j=0; j < numAtom; j++){
631 < #ifdef IS_MPI
632 <        groupList.push_back((info->atoms[i])->getGlobalIndex() + 1);
633 < #else
634 <        groupList.push_back((info->atoms[i])->getIndex() + 1);
635 < #endif
636 <      }//for(int j=0; j < numAtom; j++)
637 <            
630 >      for(int j=0; j < numAtom; j++){
631 >              
632 >        // We want the local Index:
633 >        groupList.push_back(myAtoms[j]->getIndex() + 1);
634 >        mfact.push_back(myAtoms[j]->getMass() / mtot);
635 >
636 >      }
637 >      
638        groupStart.push_back(curIndex);
639        curIndex += numAtom;
640        
641 <    }//end for(int i =0 ; i < ngroup; i++)    
641 >    } //end for(int i =0 ; i < ngroup; i++)    
642    }
643    else{
644      //using atomic cutoff, every single atom is just a group
645 <    ngroup = info->n_atoms;
635 <    for(int i =0 ; i < ngroup; i++){
636 <      groupStart.push_back(curIndex++);
637 <
645 >    
646   #ifdef IS_MPI
647 <      groupList.push_back((info->atoms[i])->getGlobalIndex() + 1);
647 >    ngroup = mpiSim->getMyNlocal();
648   #else
649 <      groupList.push_back((info->atoms[i])->getIndex() + 1);
649 >    ngroup = info->n_atoms;
650   #endif
651 <
651 >    
652 >    for(int i =0 ; i < ngroup; i++){
653 >      groupStart.push_back(curIndex++);      
654 >      groupList.push_back((info->atoms[i])->getIndex() + 1);
655 >      mfact.push_back(1.0);
656 >      
657      }//end for(int i =0 ; i < ngroup; i++)
658 <
658 >    
659    }//end if (info->useMolecularCutoffs)
660 <
660 >  
661   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines