ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new-templateless/OOPSE/libmdtools/SimInfo.cpp
(Generate patch)

Comparing:
trunk/OOPSE/libmdtools/SimInfo.cpp (file contents), Revision 787 by mmeineke, Thu Sep 25 19:27:15 2003 UTC vs.
branches/new-templateless/OOPSE/libmdtools/SimInfo.cpp (file contents), Revision 850 by mmeineke, Mon Nov 3 22:07:17 2003 UTC

# Line 1 | Line 1
1 < #include <cstdlib>
2 < #include <cstring>
3 < #include <cmath>
1 > #include <stdlib.h>
2 > #include <string.h>
3 > #include <math.h>
4  
5   #include <iostream>
6   using namespace std;
# Line 61 | Line 61 | SimInfo::SimInfo(){
61  
62    myConfiguration = new SimState();
63  
64 +  properties = new GenericData();
65 +
66    wrapMeSimInfo( this );
67   }
68  
# Line 68 | Line 70 | SimInfo::~SimInfo(){
70   SimInfo::~SimInfo(){
71  
72    delete myConfiguration;
73 <
72 <  map<string, GenericData*>::iterator i;
73 <  
74 <  for(i = properties.begin(); i != properties.end(); i++)
75 <    delete (*i).second;
76 <    
73 >  delete properties;    
74   }
75  
76   void SimInfo::setBox(double newBox[3]) {
# Line 408 | Line 405 | int SimInfo::getNDF(){
405  
406  
407   int SimInfo::getNDF(){
408 <  int ndf_local, ndf;
408 >  int ndf_local;
409    
410    ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints;
411  
# Line 424 | Line 421 | int SimInfo::getNDFraw() {
421   }
422  
423   int SimInfo::getNDFraw() {
424 <  int ndfRaw_local, ndfRaw;
424 >  int ndfRaw_local;
425  
426    // Raw degrees of freedom that we have to set
427    ndfRaw_local = 3 * n_atoms + 3 * n_oriented;
# Line 439 | Line 436 | int SimInfo::getNDFtranslational() {
436   }
437  
438   int SimInfo::getNDFtranslational() {
439 <  int ndfTrans_local, ndfTrans;
439 >  int ndfTrans_local;
440  
441    ndfTrans_local = 3 * n_atoms - n_constraints;
442  
# Line 515 | Line 512 | void SimInfo::setRcut( double theRcut ){
512  
513   void SimInfo::setRcut( double theRcut ){
514  
518  if( !haveOrigRcut ){
519    haveOrigRcut = 1;
520    origRcut = theRcut;
521  }
522
515    rCut = theRcut;
516    checkCutOffs();
517   }
518  
519 < void SimInfo::setEcr( double theEcr ){
519 > void SimInfo::setDefaultRcut( double theRcut ){
520 >
521 >  haveOrigRcut = 1;
522 >  origRcut = theRcut;
523 >  rCut = theRcut;
524  
525 <  if( !haveOrigEcr ){
530 <    haveOrigEcr = 1;
531 <    origEcr = theEcr;
532 <  }
525 >  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
526  
527 +  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
528 + }
529 +
530 + void SimInfo::setEcr( double theEcr ){
531 +
532    ecr = theEcr;
533    checkCutOffs();
534   }
535  
536 + void SimInfo::setDefaultEcr( double theEcr ){
537 +
538 +  haveOrigEcr = 1;
539 +  origEcr = theEcr;
540 +  
541 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
542 +
543 +  ecr = theEcr;
544 +
545 +  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
546 + }
547 +
548   void SimInfo::setEcr( double theEcr, double theEst ){
549  
550    est = theEst;
551    setEcr( theEcr );
552   }
553  
554 + void SimInfo::setDefaultEcr( double theEcr, double theEst ){
555  
556 +  est = theEst;
557 +  setDefaultEcr( theEcr );
558 + }
559 +
560 +
561   void SimInfo::checkCutOffs( void ){
562  
563    int cutChanged = 0;
# Line 608 | Line 624 | void SimInfo::checkCutOffs( void ){
624      ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
625      
626      if( cutChanged ){
611      
627        notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
628      }
629      
# Line 625 | Line 640 | void SimInfo::checkCutOffs( void ){
640    
641   }
642  
643 < void SimInfo::addProperty(GenericData* prop){
643 > GenericData* SimInfo::getProperty(char* propName){
644  
645 <  map<string, GenericData*>::iterator result;
631 <  result = properties.find(prop->getID());
632 <  
633 <  //we can't simply use  properties[prop->getID()] = prop,
634 <  //it will cause memory leak if we already contain a propery which has the same name of prop
635 <  
636 <  if(result != properties.end()){
637 <    
638 <    delete (*result).second;
639 <    (*result).second = prop;
640 <      
641 <  }
642 <  else{
643 <
644 <    properties[prop->getID()] = prop;
645 <
646 <  }
647 <    
645 >  return properties->find( propName );
646   }
647  
650 GenericData* SimInfo::getProperty(const string& propName){
651
652  map<string, GenericData*>::iterator result;
653  
654  //string lowerCaseName = ();
655  
656  result = properties.find(propName);
657  
658  if(result != properties.end())
659    return (*result).second;  
660  else  
661    return NULL;  
662 }
663
664 vector<GenericData*> SimInfo::getProperties(){
665
666  vector<GenericData*> result;
667  map<string, GenericData*>::iterator i;
668  
669  for(i = properties.begin(); i != properties.end(); i++)
670    result.push_back((*i).second);
671    
672  return result;
673 }
674
648   double SimInfo::matTrace3(double m[3][3]){
649    double trace;
650    trace = m[0][0] + m[1][1] + m[2][2];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines