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 1097 by gezelter, Mon Apr 12 20:32:20 2004 UTC vs.
Revision 1187 by chrisfen, Sat May 22 18:16: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 +  useThermInt = 0;
66 +
67 +  haveCutoffGroups = false;
68  
69    excludes = Exclude::Instance();
70  
# Line 71 | Line 73 | SimInfo::SimInfo(){
73    has_minimizer = false;
74    the_minimizer =NULL;
75  
76 +  ngroup = 0;
77 +
78    wrapMeSimInfo( this );
79   }
80  
# Line 83 | Line 87 | SimInfo::~SimInfo(){
87    
88    for(i = properties.begin(); i != properties.end(); i++)
89      delete (*i).second;
90 <    
90 >  
91   }
92  
93   void SimInfo::setBox(double newBox[3]) {
# Line 322 | Line 326 | int SimInfo::getNDF(){
326   int SimInfo::getNDF(){
327    int ndf_local;
328  
329 +  ndf_local = 0;
330 +  
331    for(int i = 0; i < integrableObjects.size(); i++){
332      ndf_local += 3;
333 <    if (integrableObjects[i]->isDirectional())
334 <      ndf_local += 3;
333 >    if (integrableObjects[i]->isDirectional()) {
334 >      if (integrableObjects[i]->isLinear())
335 >        ndf_local += 2;
336 >      else
337 >        ndf_local += 3;
338 >    }
339    }
340  
341    // n_constraints is local, so subtract them on each processor:
# Line 350 | Line 360 | int SimInfo::getNDFraw() {
360    int ndfRaw_local;
361  
362    // Raw degrees of freedom that we have to set
363 +  ndfRaw_local = 0;
364  
365    for(int i = 0; i < integrableObjects.size(); i++){
366      ndfRaw_local += 3;
367 <    if (integrableObjects[i]->isDirectional())
368 <      ndfRaw_local += 3;
367 >    if (integrableObjects[i]->isDirectional()) {
368 >       if (integrableObjects[i]->isLinear())
369 >        ndfRaw_local += 2;
370 >      else
371 >        ndfRaw_local += 3;
372 >    }
373    }
374      
375   #ifdef IS_MPI
# Line 383 | Line 398 | int SimInfo::getNDFtranslational() {
398    return ndfTrans;
399   }
400  
401 + int SimInfo::getTotIntegrableObjects() {
402 +  int nObjs_local;
403 +  int nObjs;
404 +
405 +  nObjs_local =  integrableObjects.size();
406 +
407 +
408 + #ifdef IS_MPI
409 +  MPI_Allreduce(&nObjs_local,&nObjs,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
410 + #else
411 +  nObjs = nObjs_local;
412 + #endif
413 +
414 +
415 +  return nObjs;
416 + }
417 +
418   void SimInfo::refreshSim(){
419  
420    simtype fInfo;
# Line 411 | Line 443 | void SimInfo::refreshSim(){
443  
444    n_exclude = excludes->getSize();
445    excl = excludes->getFortranArray();
446 <
446 >  
447   #ifdef IS_MPI
448    n_global = mpiSim->getTotAtoms();
449   #else
450    n_global = n_atoms;
451   #endif
452 <
452 >  
453    isError = 0;
454 <
454 >  
455 >  getFortranGroupArray(this, mfact, ngroup, groupList, groupStart);
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 <                  &isError );
462 <
460 >                  &nGlobalExcludes, globalExcludes, molMembershipArray,
461 >                  &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError);
462 >  
463    if( isError ){
464 <
464 >    
465      sprintf( painCave.errMsg,
466 <             "There was an error setting the simulation information in fortran.\n" );
466 >             "There was an error setting the simulation information in fortran.\n" );
467      painCave.isFatal = 1;
468      simError();
469    }
470 <
470 >  
471   #ifdef IS_MPI
472    sprintf( checkPointMsg,
473             "succesfully sent the simulation information to fortran.\n");
474    MPIcheckPoint();
475   #endif // is_mpi
476 <
476 >  
477    this->ndf = this->getNDF();
478    this->ndfRaw = this->getNDFraw();
479    this->ndfTrans = this->getNDFtranslational();
480   }
481  
482   void SimInfo::setDefaultRcut( double theRcut ){
483 <
483 >  
484    haveRcut = 1;
485    rCut = theRcut;
486 <
451 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
452 <
453 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
454 < }
455 <
456 < void SimInfo::setDefaultEcr( double theEcr ){
457 <
458 <  haveEcr = 1;
459 <  ecr = theEcr;
486 >  rList = rCut + 1.0;
487    
488 <  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
462 <
463 <  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
488 >  notifyFortranCutOffs( &rCut, &rSw, &rList );
489   }
490  
491 < void SimInfo::setDefaultEcr( double theEcr, double theEst ){
491 > void SimInfo::setDefaultRcut( double theRcut, double theRsw ){
492  
493 <  est = theEst;
494 <  setDefaultEcr( theEcr );
493 >  rSw = theRsw;
494 >  setDefaultRcut( theRcut );
495   }
496  
497  
# Line 478 | Line 503 | void SimInfo::checkCutOffs( void ){
503      
504      if( rCut > maxCutoff ){
505        sprintf( painCave.errMsg,
506 <               "LJrcut is too large for the current periodic box.\n"
507 <               "\tCurrent Value of LJrcut = %G at time %G\n "
506 >               "cutoffRadius is too large for the current periodic box.\n"
507 >               "\tCurrent Value of cutoffRadius = %G at time %G\n "
508                 "\tThis is larger than half of at least one of the\n"
509                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
510 <               "\n, %G"
510 >               "\n"
511                 "\t[ %G %G %G ]\n"
512                 "\t[ %G %G %G ]\n"
513                 "\t[ %G %G %G ]\n",
514 <               rCut, currentTime, maxCutoff,
514 >               rCut, currentTime,
515                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
516                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
517                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
518        painCave.isFatal = 1;
519        simError();
520 <    }
496 <    
497 <    if( haveEcr ){
498 <      if( ecr > maxCutoff ){
499 <        sprintf( painCave.errMsg,
500 <                 "electrostaticCutoffRadius is too large for the current\n"
501 <                 "\tperiodic box.\n\n"
502 <                 "\tCurrent Value of ECR = %G at time %G\n "
503 <                 "\tThis is larger than half of at least one of the\n"
504 <                 "\tperiodic box vectors.  Right now, the Box matrix is:\n"
505 <                 "\n"
506 <                 "\t[ %G %G %G ]\n"
507 <                 "\t[ %G %G %G ]\n"
508 <                 "\t[ %G %G %G ]\n",
509 <                 ecr, currentTime,
510 <                 Hmat[0][0], Hmat[0][1], Hmat[0][2],
511 <                 Hmat[1][0], Hmat[1][1], Hmat[1][2],
512 <                 Hmat[2][0], Hmat[2][1], Hmat[2][2]);
513 <        painCave.isFatal = 1;
514 <        simError();
515 <      }
516 <    }
520 >    }    
521    } else {
522      // initialize this stuff before using it, OK?
523      sprintf( painCave.errMsg,
# Line 561 | Line 565 | GenericData* SimInfo::getProperty(const string& propNa
565      return NULL;  
566   }
567  
564 vector<GenericData*> SimInfo::getProperties(){
568  
569 <  vector<GenericData*> result;
570 <  map<string, GenericData*>::iterator i;
569 > void getFortranGroupArray(SimInfo* info, vector<double>& mfact, int& ngroup,
570 >                          vector<int>& groupList, vector<int>& groupStart){
571 >  Molecule* myMols;
572 >  Atom** myAtoms;
573 >  int numAtom;
574 >  int curIndex;
575 >  double mtot;
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 <  for(i = properties.begin(); i != properties.end(); i++)
586 <    result.push_back((*i).second);
587 <    
588 <  return result;
585 >  mfact.clear();
586 >  groupList.clear();
587 >  groupStart.clear();
588 >  
589 >  //Be careful, fortran array begin at 1
590 >  curIndex = 1;
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 >      totalMass = myCutoffGroup->getMass();
600 >      
601 >      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); cutoffAtom != NULL;
602 >                                           cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){
603 >        mfact.push_back(cutoffAtom->getMass()/totalMass);
604 >        groupList.push_back(cutoffAtom->getIndex() + 1);
605 >      }  
606 >                              
607 >      groupStart.push_back(curIndex);
608 >      curIndex += myCutoffGroup->getNumAtom();
609 >
610 >    }//end for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff))
611 >
612 >  }//end for(int i  = 0; i < numMol; i++)
613 >  
614 >  ngroup = groupStart.size();
615   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines