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 781 by tim, Mon Sep 22 23:07:57 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 94 | Line 91 | void SimInfo::setBoxM( double theBox[3][3] ){
91  
92   void SimInfo::setBoxM( double theBox[3][3] ){
93    
94 <  int i, j, status;
98 <  double smallestBoxL, maxCutoff;
94 >  int i, j;
95    double FortranHmat[9]; // to preserve compatibility with Fortran the
96                           // ordering in the array is as follows:
97                           // [ 0 3 6 ]
# Line 302 | Line 298 | void SimInfo::calcBoxL( void ){
298   void SimInfo::calcBoxL( void ){
299  
300    double dx, dy, dz, dsq;
305  int i;
301  
302    // boxVol = Determinant of Hmat
303  
# Line 372 | Line 367 | void SimInfo::wrapVector( double thePos[3] ){
367  
368   void SimInfo::wrapVector( double thePos[3] ){
369  
370 <  int i, j, k;
370 >  int i;
371    double scaled[3];
372  
373    if( !orthoRhombic ){
# Line 410 | 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 426 | 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 441 | 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 517 | Line 512 | void SimInfo::setRcut( double theRcut ){
512  
513   void SimInfo::setRcut( double theRcut ){
514  
520  if( !haveOrigRcut ){
521    haveOrigRcut = 1;
522    origRcut = theRcut;
523  }
524
515    rCut = theRcut;
516    checkCutOffs();
517   }
518  
519 < void SimInfo::setEcr( double theEcr ){
519 > void SimInfo::setDefaultRcut( double theRcut ){
520  
521 <  if( !haveOrigEcr ){
522 <    haveOrigEcr = 1;
523 <    origEcr = theEcr;
534 <  }
521 >  haveOrigRcut = 1;
522 >  origRcut = theRcut;
523 >  rCut = theRcut;
524  
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 610 | Line 624 | void SimInfo::checkCutOffs( void ){
624      ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
625      
626      if( cutChanged ){
613      
627        notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
628      }
629      
# Line 627 | 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;
633 <  result = properties.find(prop->getID());
634 <  
635 <  //we can't simply use  properties[prop->getID()] = prop,
636 <  //it will cause memory leak if we already contain a propery which has the same name of prop
637 <  
638 <  if(result != properties.end()){
639 <    
640 <    delete (*result).second;
641 <    (*result).second = prop;
642 <      
643 <  }
644 <  else{
645 <
646 <    properties[prop->getID()] = prop;
647 <
648 <  }
649 <    
645 >  return properties->find( propName );
646   }
647  
652 GenericData* SimInfo::getProperty(const string& propName){
653
654  map<string, GenericData*>::iterator result;
655  
656  //string lowerCaseName = ();
657  
658  result = properties.find(propName);
659  
660  if(result != properties.end())
661    return (*result).second;  
662  else  
663    return NULL;  
664 }
665
666 vector<GenericData*> SimInfo::getProperties(){
667
668  vector<GenericData*> result;
669  map<string, GenericData*>::iterator i;
670  
671  for(i = properties.begin(); i != properties.end(); i++)
672    result.push_back((*i).second);
673    
674  return result;
675 }
676
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