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 1113 by tim, Thu Apr 15 16:18:26 2004 UTC vs.
Revision 1221 by chrisfen, Wed Jun 2 14:56:18 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 +  useSolidThermInt = 0;
66 +  useLiquidThermInt = 0;
67  
68 +  haveCutoffGroups = false;
69 +
70    excludes = Exclude::Instance();
71  
72    myConfiguration = new SimState();
# Line 71 | Line 74 | SimInfo::SimInfo(){
74    has_minimizer = false;
75    the_minimizer =NULL;
76  
77 +  ngroup = 0;
78 +
79    wrapMeSimInfo( this );
80   }
81  
# Line 83 | Line 88 | SimInfo::~SimInfo(){
88    
89    for(i = properties.begin(); i != properties.end(); i++)
90      delete (*i).second;
91 <    
91 >  
92   }
93  
94   void SimInfo::setBox(double newBox[3]) {
# Line 186 | Line 191 | void SimInfo::calcHmatInv( void ) {
191  
192    if( oldOrtho != orthoRhombic ){
193      
194 <    if( orthoRhombic ){
194 >    if( orthoRhombic ) {
195        sprintf( painCave.errMsg,
196                 "OOPSE is switching from the default Non-Orthorhombic\n"
197                 "\tto the faster Orthorhombic periodic boundary computations.\n"
# Line 194 | Line 199 | void SimInfo::calcHmatInv( void ) {
199                 "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n"
200                 "\tvariable ( currently set to %G ) smaller.\n",
201                 orthoTolerance);
202 +      painCave.severity = OOPSE_INFO;
203        simError();
204      }
205      else {
# Line 205 | Line 211 | void SimInfo::calcHmatInv( void ) {
211                 "\tthe Orthorhombic computations, make the orthoBoxTolerance\n"
212                 "\tvariable ( currently set to %G ) larger.\n",
213                 orthoTolerance);
214 +      painCave.severity = OOPSE_WARNING;
215        simError();
216      }
217    }
# Line 326 | Line 333 | int SimInfo::getNDF(){
333    
334    for(int i = 0; i < integrableObjects.size(); i++){
335      ndf_local += 3;
336 <    if (integrableObjects[i]->isDirectional())
337 <      ndf_local += 3;
336 >    if (integrableObjects[i]->isDirectional()) {
337 >      if (integrableObjects[i]->isLinear())
338 >        ndf_local += 2;
339 >      else
340 >        ndf_local += 3;
341 >    }
342    }
343  
344    // n_constraints is local, so subtract them on each processor:
# Line 356 | Line 367 | int SimInfo::getNDFraw() {
367  
368    for(int i = 0; i < integrableObjects.size(); i++){
369      ndfRaw_local += 3;
370 <    if (integrableObjects[i]->isDirectional())
371 <      ndfRaw_local += 3;
370 >    if (integrableObjects[i]->isDirectional()) {
371 >       if (integrableObjects[i]->isLinear())
372 >        ndfRaw_local += 2;
373 >      else
374 >        ndfRaw_local += 3;
375 >    }
376    }
377      
378   #ifdef IS_MPI
# Line 431 | Line 446 | void SimInfo::refreshSim(){
446  
447    n_exclude = excludes->getSize();
448    excl = excludes->getFortranArray();
449 <
449 >  
450   #ifdef IS_MPI
451 <  n_global = mpiSim->getTotAtoms();
451 >  n_global = mpiSim->getNAtomsGlobal();
452   #else
453    n_global = n_atoms;
454   #endif
455 <
455 >  
456    isError = 0;
457 <
457 >  
458 >  getFortranGroupArrays(this, FglobalGroupMembership, mfact);
459 >  //it may not be a good idea to pass the address of first element in vector
460 >  //since c++ standard does not require vector to be stored continuously in meomory
461 >  //Most of the compilers will organize the memory of vector continuously
462    setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
463 <                  &nGlobalExcludes, globalExcludes, molMembershipArray,
464 <                  &isError );
446 <
447 <  if( isError ){
463 >                  &nGlobalExcludes, globalExcludes, molMembershipArray,
464 >                  &mfact[0], &ngroup, &FglobalGroupMembership[0], &isError);
465  
466 +  if( isError ){
467 +    
468      sprintf( painCave.errMsg,
469 <             "There was an error setting the simulation information in fortran.\n" );
469 >             "There was an error setting the simulation information in fortran.\n" );
470      painCave.isFatal = 1;
471 +    painCave.severity = OOPSE_ERROR;
472      simError();
473    }
474 <
474 >  
475   #ifdef IS_MPI
476    sprintf( checkPointMsg,
477             "succesfully sent the simulation information to fortran.\n");
478    MPIcheckPoint();
479   #endif // is_mpi
480 <
480 >  
481    this->ndf = this->getNDF();
482    this->ndfRaw = this->getNDFraw();
483    this->ndfTrans = this->getNDFtranslational();
484   }
485  
486   void SimInfo::setDefaultRcut( double theRcut ){
487 <
487 >  
488    haveRcut = 1;
489    rCut = theRcut;
490 <
471 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
472 <
473 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
474 < }
475 <
476 < void SimInfo::setDefaultEcr( double theEcr ){
477 <
478 <  haveEcr = 1;
479 <  ecr = theEcr;
490 >  rList = rCut + 1.0;
491    
492 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
482 <
483 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
492 >  notifyFortranCutOffs( &rCut, &rSw, &rList );
493   }
494  
495 < void SimInfo::setDefaultEcr( double theEcr, double theEst ){
495 > void SimInfo::setDefaultRcut( double theRcut, double theRsw ){
496  
497 <  est = theEst;
498 <  setDefaultEcr( theEcr );
497 >  rSw = theRsw;
498 >  setDefaultRcut( theRcut );
499   }
500  
501  
# Line 498 | Line 507 | void SimInfo::checkCutOffs( void ){
507      
508      if( rCut > maxCutoff ){
509        sprintf( painCave.errMsg,
510 <               "LJrcut is too large for the current periodic box.\n"
511 <               "\tCurrent Value of LJrcut = %G at time %G\n "
510 >               "cutoffRadius is too large for the current periodic box.\n"
511 >               "\tCurrent Value of cutoffRadius = %G at time %G\n "
512                 "\tThis is larger than half of at least one of the\n"
513                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
514 <               "\n, %G"
514 >               "\n"
515                 "\t[ %G %G %G ]\n"
516                 "\t[ %G %G %G ]\n"
517                 "\t[ %G %G %G ]\n",
518 <               rCut, currentTime, maxCutoff,
518 >               rCut, currentTime,
519                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
520                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
521                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
522 +      painCave.severity = OOPSE_ERROR;
523        painCave.isFatal = 1;
524        simError();
525 <    }
516 <    
517 <    if( haveEcr ){
518 <      if( ecr > maxCutoff ){
519 <        sprintf( painCave.errMsg,
520 <                 "electrostaticCutoffRadius is too large for the current\n"
521 <                 "\tperiodic box.\n\n"
522 <                 "\tCurrent Value of ECR = %G at time %G\n "
523 <                 "\tThis is larger than half of at least one of the\n"
524 <                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
525 <                 "\n"
526 <                 "\t[ %G %G %G ]\n"
527 <                 "\t[ %G %G %G ]\n"
528 <                 "\t[ %G %G %G ]\n",
529 <                 ecr, currentTime,
530 <                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
531 <                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
532 <                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
533 <        painCave.isFatal = 1;
534 <        simError();
535 <      }
536 <    }
525 >    }    
526    } else {
527      // initialize this stuff before using it, OK?
528      sprintf( painCave.errMsg,
529               "Trying to check cutoffs without a box.\n"
530               "\tOOPSE should have better programmers than that.\n" );
531 +    painCave.severity = OOPSE_ERROR;
532      painCave.isFatal = 1;
533      simError();      
534    }
# Line 581 | Line 571 | GenericData* SimInfo::getProperty(const string& propNa
571      return NULL;  
572   }
573  
584 vector<GenericData*> SimInfo::getProperties(){
574  
575 <  vector<GenericData*> result;
576 <  map<string, GenericData*>::iterator i;
575 > void SimInfo::getFortranGroupArrays(SimInfo* info,
576 >                                    vector<int>& FglobalGroupMembership,
577 >                                    vector<double>& mfact){
578    
579 <  for(i = properties.begin(); i != properties.end(); i++)
580 <    result.push_back((*i).second);
581 <    
582 <  return result;
579 >  Molecule* myMols;
580 >  Atom** myAtoms;
581 >  int numAtom;
582 >  double mtot;
583 >  int numMol;
584 >  int numCutoffGroups;
585 >  CutoffGroup* myCutoffGroup;
586 >  vector<CutoffGroup*>::iterator iterCutoff;
587 >  Atom* cutoffAtom;
588 >  vector<Atom*>::iterator iterAtom;
589 >  int atomIndex;
590 >  double totalMass;
591 >  
592 >  mfact.clear();
593 >  FglobalGroupMembership.clear();
594 >  
595 >
596 >  // Fix the silly fortran indexing problem
597 > #ifdef IS_MPI
598 >  numAtom = mpiSim->getNAtomsGlobal();
599 > #else
600 >  numAtom = n_atoms;
601 > #endif
602 >  for (int i = 0; i < numAtom; i++)
603 >    FglobalGroupMembership.push_back(globalGroupMembership[i] + 1);
604 >  
605 >
606 >  myMols = info->molecules;
607 >  numMol = info->n_mol;
608 >  for(int i  = 0; i < numMol; i++){
609 >    numCutoffGroups = myMols[i].getNCutoffGroups();
610 >    for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff);
611 >        myCutoffGroup != NULL;
612 >        myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){
613 >
614 >      totalMass = myCutoffGroup->getMass();
615 >      
616 >      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom);
617 >          cutoffAtom != NULL;
618 >          cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){
619 >        mfact.push_back(cutoffAtom->getMass()/totalMass);
620 >      }  
621 >    }
622 >  }
623 >
624   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines