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 1212 by chrisfen, Tue Jun 1 17:15:43 2004 UTC

# Line 42 | Line 42 | SimInfo::SimInfo(){
42    thermalTime = 0.0;
43    currentTime = 0.0;
44    rCut = 0.0;
45 <  ecr = 0.0;
46 <  est = 0.0;
45 >  rSw = 0.0;
46  
47    haveRcut = 0;
48 <  haveEcr = 0;
48 >  haveRsw = 0;
49    boxIsInit = 0;
50    
51    resetTime = 1e99;
# Line 63 | Line 62 | SimInfo::SimInfo(){
62    useReactionField = 0;
63    useGB = 0;
64    useEAM = 0;
65 <  useMolecularCutoffs = 0;
65 >  useSolidThermInt = 0;
66 >  useLiquidThermInt = 0;
67 >
68 >  haveCutoffGroups = false;
69  
70    excludes = Exclude::Instance();
71  
# Line 444 | Line 446 | void SimInfo::refreshSim(){
446    excl = excludes->getFortranArray();
447    
448   #ifdef IS_MPI
449 <  n_global = mpiSim->getTotAtoms();
449 >  n_global = mpiSim->getNAtomsGlobal();
450   #else
451    n_global = n_atoms;
452   #endif
453 <
453 >  
454    isError = 0;
455 <
456 < getFortranGroupArray(this, mfact, ngroup, groupList, groupStart);
457 <
458 <  setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
459 <                                    &nGlobalExcludes, globalExcludes, molMembershipArray,
460 <                                    &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError );
461 <
462 <  if( isError ){
463 <
455 >  
456 >  getFortranGroupArray(this, mfact, ngroup, groupList, groupStart);
457 >  //it may not be a good idea to pass the address of first element in vector
458 >  //since c++ standard does not require vector to be stored continuously in meomory
459 >  //Most of the compilers will organize the memory of vector continuously
460 >  setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
461 >                  &nGlobalExcludes, globalExcludes, molMembershipArray,
462 >                  &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError);
463 >  
464 >  if( isError ){
465 >    
466      sprintf( painCave.errMsg,
467 <             "There was an error setting the simulation information in fortran.\n" );
467 >             "There was an error setting the simulation information in fortran.\n" );
468      painCave.isFatal = 1;
469      simError();
470    }
471 <
471 >  
472   #ifdef IS_MPI
473    sprintf( checkPointMsg,
474             "succesfully sent the simulation information to fortran.\n");
475    MPIcheckPoint();
476   #endif // is_mpi
477 <
477 >  
478    this->ndf = this->getNDF();
479    this->ndfRaw = this->getNDFraw();
480    this->ndfTrans = this->getNDFtranslational();
481   }
482  
483   void SimInfo::setDefaultRcut( double theRcut ){
484 <
484 >  
485    haveRcut = 1;
486    rCut = theRcut;
487 <
488 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
489 <
486 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
487 >  rList = rCut + 1.0;
488 >  
489 >  notifyFortranCutOffs( &rCut, &rSw, &rList );
490   }
491  
492 < void SimInfo::setDefaultEcr( double theEcr ){
492 > void SimInfo::setDefaultRcut( double theRcut, double theRsw ){
493  
494 <  haveEcr = 1;
495 <  ecr = theEcr;
493 <  
494 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
495 <
496 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
494 >  rSw = theRsw;
495 >  setDefaultRcut( theRcut );
496   }
497  
499 void SimInfo::setDefaultEcr( double theEcr, double theEst ){
498  
501  est = theEst;
502  setDefaultEcr( theEcr );
503 }
504
505
499   void SimInfo::checkCutOffs( void ){
500    
501    if( boxIsInit ){
# Line 511 | Line 504 | void SimInfo::checkCutOffs( void ){
504      
505      if( rCut > maxCutoff ){
506        sprintf( painCave.errMsg,
507 <               "LJrcut is too large for the current periodic box.\n"
508 <               "\tCurrent Value of LJrcut = %G at time %G\n "
507 >               "cutoffRadius is too large for the current periodic box.\n"
508 >               "\tCurrent Value of cutoffRadius = %G at time %G\n "
509                 "\tThis is larger than half of at least one of the\n"
510                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
511                 "\n"
# Line 525 | Line 518 | void SimInfo::checkCutOffs( void ){
518                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
519        painCave.isFatal = 1;
520        simError();
521 <    }
529 <    
530 <    if( haveEcr ){
531 <      if( ecr > maxCutoff ){
532 <        sprintf( painCave.errMsg,
533 <                 "electrostaticCutoffRadius is too large for the current\n"
534 <                 "\tperiodic box.\n\n"
535 <                 "\tCurrent Value of ECR = %G at time %G\n "
536 <                 "\tThis is larger than half of at least one of the\n"
537 <                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
538 <                 "\n"
539 <                 "\t[ %G %G %G ]\n"
540 <                 "\t[ %G %G %G ]\n"
541 <                 "\t[ %G %G %G ]\n",
542 <                 ecr, currentTime,
543 <                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
544 <                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
545 <                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
546 <        painCave.isFatal = 1;
547 <        simError();
548 <      }
549 <    }
521 >    }    
522    } else {
523      // initialize this stuff before using it, OK?
524      sprintf( painCave.errMsg,
# Line 596 | Line 568 | void getFortranGroupArray(SimInfo* info, vector<double
568  
569  
570   void getFortranGroupArray(SimInfo* info, vector<double>& mfact, int& ngroup,
571 <                                                          vector<int>& groupList, vector<int>& groupStart){
572 <  Molecule* mol;
571 >                          vector<int>& groupList, vector<int>& groupStart){
572 >  Molecule* myMols;
573 >  Atom** myAtoms;
574    int numAtom;
575    int curIndex;
576 <
576 >  double mtot;
577 >  int numMol;
578 >  int numCutoffGroups;
579 >  CutoffGroup* myCutoffGroup;
580 >  vector<CutoffGroup*>::iterator iterCutoff;
581 >  Atom* cutoffAtom;
582 >  vector<Atom*>::iterator iterAtom;
583 >  int atomIndex;
584 >  double totalMass;
585 >  
586    mfact.clear();
587    groupList.clear();
588    groupStart.clear();
589 <
589 >  
590    //Be careful, fortran array begin at 1
591    curIndex = 1;
610    
611  if(info->useMolecularCutoffs){
612    //if using molecular cutoff
613    ngroup = info->n_mol;
592  
593 <    for(int i = 0; i < ngroup; i ++){
594 <      mol = &(info->molecules[i]);
595 <      numAtom = mol->getNAtoms();
593 >  myMols = info->molecules;
594 >  numMol = info->n_mol;
595 >  for(int i  = 0; i < numMol; i++){
596 >    numCutoffGroups = myMols[i].getNCutoffGroups();
597 >    for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff); myCutoffGroup != NULL;
598 >                                                  myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){
599 >
600 >      totalMass = myCutoffGroup->getMass();
601        
602 <      for(int j=0; j < numAtom; j++){
603 < #ifdef IS_MPI
604 <        groupList.push_back((info->atoms[i])->getGlobalIndex() + 1);
602 >      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL;
603 >                                           cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){
604 >        mfact.push_back(cutoffAtom->getMass()/totalMass);
605 > #ifdef IS_MPI        
606 >        groupList.push_back(cutoffAtom->getGlobalIndex() + 1);
607   #else
608 <        groupList.push_back((info->atoms[i])->getIndex() + 1);
608 >        groupList.push_back(cutoffAtom->getIndex() + 1);
609   #endif
610 <      }//for(int j=0; j < numAtom; j++)
611 <            
610 >      }  
611 >                              
612        groupStart.push_back(curIndex);
613 <      curIndex += numAtom;
629 <      
630 <    }//end for(int i =0 ; i < ngroup; i++)    
631 <  }
632 <  else{
633 <    //using atomic cutoff, every single atom is just a group
634 <    ngroup = info->n_atoms;
635 <    for(int i =0 ; i < ngroup; i++){
636 <      groupStart.push_back(curIndex++);
613 >      curIndex += myCutoffGroup->getNumAtom();
614  
615 < #ifdef IS_MPI
639 <      groupList.push_back((info->atoms[i])->getGlobalIndex() + 1);
640 < #else
641 <      groupList.push_back((info->atoms[i])->getIndex() + 1);
642 < #endif
615 >    }//end for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff))
616  
617 <    }//end for(int i =0 ; i < ngroup; i++)
617 >  }//end for(int i  = 0; i < numMol; i++)
618  
646  }//end if (info->useMolecularCutoffs)
619  
620 +  //The last cutoff group need more element to indicate the end of the cutoff
621 +  ngroup = groupStart.size();
622   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines