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 569 by mmeineke, Tue Jul 1 21:33:45 2003 UTC vs.
Revision 660 by tim, Thu Jul 31 19:59:34 2003 UTC

# Line 2 | Line 2
2   #include <cstring>
3   #include <cmath>
4  
5 + #include <iostream>
6 + using namespace std;
7  
8   #include "SimInfo.hpp"
9   #define __C
# Line 14 | Line 16 | SimInfo* currentInfo;
16   #include "mpiSimulation.hpp"
17   #endif
18  
19 + inline double roundMe( double x ){
20 +  return ( x >= 0 ) ? floor( x + 0.5 ) : ceil( x - 0.5 );
21 + }
22 +          
23 +
24   SimInfo* currentInfo;
25  
26   SimInfo::SimInfo(){
# Line 26 | Line 33 | SimInfo::SimInfo(){
33    the_integrator = NULL;
34    setTemp = 0;
35    thermalTime = 0.0;
36 +  currentTime = 0.0;
37    rCut = 0.0;
38 +  ecr = 0.0;
39 +  est = 0.0;
40 +  oldEcr = 0.0;
41 +  oldRcut = 0.0;
42  
43 +  haveOrigRcut = 0;
44 +  haveOrigEcr = 0;
45 +  boxIsInit = 0;
46 +  
47 +  
48 +
49    usePBC = 0;
50    useLJ = 0;
51    useSticky = 0;
# Line 39 | Line 57 | void SimInfo::setBox(double newBox[3]) {
57    wrapMeSimInfo( this );
58   }
59  
60 < void SimInfo::setBox(double newBox[3]) {
60 > SimInfo::~SimInfo(){
61  
62 <  double smallestBoxL, maxCutoff;
63 <  int status;
64 <  int i;
62 >  map<string, GenericData*>::iterator i;
63 >  
64 >  for(i = properties.begin(); i != properties.end(); i++)
65 >    delete (*i).second;
66  
67 <  for(i=0; i<9; i++) Hmat[i] = 0.0;;
67 >  
68 > }
69  
70 <  Hmat[0] = newBox[0];
71 <  Hmat[4] = newBox[1];
72 <  Hmat[8] = newBox[2];
70 > void SimInfo::setBox(double newBox[3]) {
71 >  
72 >  int i, j;
73 >  double tempMat[3][3];
74  
75 <  calcHmatI();
76 <  calcBoxL();
75 >  for(i=0; i<3; i++)
76 >    for (j=0; j<3; j++) tempMat[i][j] = 0.0;;
77  
78 <  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
78 >  tempMat[0][0] = newBox[0];
79 >  tempMat[1][1] = newBox[1];
80 >  tempMat[2][2] = newBox[2];
81  
82 <  smallestBoxL = boxLx;
60 <  if (boxLy < smallestBoxL) smallestBoxL = boxLy;
61 <  if (boxLz < smallestBoxL) smallestBoxL = boxLz;
82 >  setBoxM( tempMat );
83  
84 <  maxCutoff = smallestBoxL / 2.0;
84 > }
85  
86 <  if (rList > maxCutoff) {
87 <    sprintf( painCave.errMsg,
88 <             "New Box size is forcing neighborlist radius down to %lf\n",
89 <             maxCutoff );
90 <    painCave.isFatal = 0;
91 <    simError();
86 > void SimInfo::setBoxM( double theBox[3][3] ){
87 >  
88 >  int i, j, status;
89 >  double smallestBoxL, maxCutoff;
90 >  double FortranHmat[9]; // to preserve compatibility with Fortran the
91 >                         // ordering in the array is as follows:
92 >                         // [ 0 3 6 ]
93 >                         // [ 1 4 7 ]
94 >                         // [ 2 5 8 ]
95 >  double FortranHmatInv[9]; // the inverted Hmat (for Fortran);
96  
97 <    rList = maxCutoff;
97 >  
98 >  if( !boxIsInit ) boxIsInit = 1;
99  
100 <    sprintf( painCave.errMsg,
101 <             "New Box size is forcing cutoff radius down to %lf\n",
102 <             maxCutoff - 1.0 );
103 <    painCave.isFatal = 0;
104 <    simError();
100 >  for(i=0; i < 3; i++)
101 >    for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j];
102 >  
103 >  calcBoxL();
104 >  calcHmatInv();
105  
106 <    rCut = rList - 1.0;
107 <
108 <    // list radius changed so we have to refresh the simulation structure.
109 <    refreshSim();
106 >  for(i=0; i < 3; i++) {
107 >    for (j=0; j < 3; j++) {
108 >      FortranHmat[3*j + i] = Hmat[i][j];
109 >      FortranHmatInv[3*j + i] = HmatInv[i][j];
110 >    }
111    }
112  
113 <  if (rCut > maxCutoff) {
114 <    sprintf( painCave.errMsg,
115 <             "New Box size is forcing cutoff radius down to %lf\n",
116 <             maxCutoff );
90 <    painCave.isFatal = 0;
91 <    simError();
113 >  setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic);
114 >
115 > }
116 >
117  
118 <    status = 0;
119 <    LJ_new_rcut(&rCut, &status);
120 <    if (status != 0) {
121 <      sprintf( painCave.errMsg,
122 <               "Error in recomputing LJ shifts based on new rcut\n");
98 <      painCave.isFatal = 1;
99 <      simError();
100 <    }
101 <  }
118 > void SimInfo::getBoxM (double theBox[3][3]) {
119 >
120 >  int i, j;
121 >  for(i=0; i<3; i++)
122 >    for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j];
123   }
124  
104 void SimInfo::setBoxM( double theBox[9] ){
105  
106  int i, status;
107  double smallestBoxL, maxCutoff;
125  
126 <  for(i=0; i<9; i++) Hmat[i] = theBox[i];
127 <  calcHmatI();
128 <  calcBoxL();
126 > void SimInfo::scaleBox(double scale) {
127 >  double theBox[3][3];
128 >  int i, j;
129  
130 <  setFortranBoxSize(Hmat, HmatI, &orthoRhombic);
114 <
115 <  smallestBoxL = boxLx;
116 <  if (boxLy < smallestBoxL) smallestBoxL = boxLy;
117 <  if (boxLz < smallestBoxL) smallestBoxL = boxLz;
130 >  // cerr << "Scaling box by " << scale << "\n";
131  
132 <  maxCutoff = smallestBoxL / 2.0;
132 >  for(i=0; i<3; i++)
133 >    for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale;
134  
135 <  if (rList > maxCutoff) {
122 <    sprintf( painCave.errMsg,
123 <             "New Box size is forcing neighborlist radius down to %lf\n",
124 <             maxCutoff );
125 <    painCave.isFatal = 0;
126 <    simError();
135 >  setBoxM(theBox);
136  
137 <    rList = maxCutoff;
137 > }
138  
139 <    sprintf( painCave.errMsg,
140 <             "New Box size is forcing cutoff radius down to %lf\n",
141 <             maxCutoff - 1.0 );
142 <    painCave.isFatal = 0;
143 <    simError();
139 > void SimInfo::calcHmatInv( void ) {
140 >  
141 >  int i,j;
142 >  double smallDiag;
143 >  double tol;
144 >  double sanity[3][3];
145  
146 <    rCut = rList - 1.0;
146 >  invertMat3( Hmat, HmatInv );
147  
148 <    // list radius changed so we have to refresh the simulation structure.
139 <    refreshSim();
140 <  }
148 >  // Check the inverse to make sure it is sane:
149  
150 <  if (rCut > maxCutoff) {
151 <    sprintf( painCave.errMsg,
152 <             "New Box size is forcing cutoff radius down to %lf\n",
153 <             maxCutoff );
154 <    painCave.isFatal = 0;
155 <    simError();
150 >  matMul3( Hmat, HmatInv, sanity );
151 >    
152 >  // check to see if Hmat is orthorhombic
153 >  
154 >  smallDiag = Hmat[0][0];
155 >  if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1];
156 >  if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2];
157 >  tol = smallDiag * 1E-6;
158  
159 <    status = 0;
160 <    LJ_new_rcut(&rCut, &status);
161 <    if (status != 0) {
162 <      sprintf( painCave.errMsg,
163 <               "Error in recomputing LJ shifts based on new rcut\n");
164 <      painCave.isFatal = 1;
165 <      simError();
159 >  orthoRhombic = 1;
160 >  
161 >  for (i = 0; i < 3; i++ ) {
162 >    for (j = 0 ; j < 3; j++) {
163 >      if (i != j) {
164 >        if (orthoRhombic) {
165 >          if (Hmat[i][j] >= tol) orthoRhombic = 0;
166 >        }        
167 >      }
168      }
169    }
170   }
159
171  
172 < void SimInfo::getBox(double theBox[9]) {
162 <
163 <  int i;
164 <  for(i=0; i<9; i++) theBox[i] = Hmat[i];
165 < }
166 <
167 <
168 < void SimInfo::calcHmatI( void ) {
169 <
170 <  double C[3][3];
171 <  double detHmat;
172 > double SimInfo::matDet3(double a[3][3]) {
173    int i, j, k;
174 <  double smallDiag;
174 <  double tol;
175 <  double sanity[3][3];
174 >  double determinant;
175  
176 <  // calculate the adjunct of Hmat;
176 >  determinant = 0.0;
177  
178 <  C[0][0] =  ( Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]);
179 <  C[1][0] = -( Hmat[1]*Hmat[8]) + (Hmat[7]*Hmat[2]);
180 <  C[2][0] =  ( Hmat[1]*Hmat[5]) - (Hmat[4]*Hmat[2]);
178 >  for(i = 0; i < 3; i++) {
179 >    j = (i+1)%3;
180 >    k = (i+2)%3;
181  
182 <  C[0][1] = -( Hmat[3]*Hmat[8]) + (Hmat[6]*Hmat[5]);
183 <  C[1][1] =  ( Hmat[0]*Hmat[8]) - (Hmat[6]*Hmat[2]);
185 <  C[2][1] = -( Hmat[0]*Hmat[5]) + (Hmat[3]*Hmat[2]);
182 >    determinant += a[0][i] * (a[1][j]*a[2][k] - a[1][k]*a[2][j]);
183 >  }
184  
185 <  C[0][2] =  ( Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]);
186 <  C[1][2] = -( Hmat[0]*Hmat[7]) + (Hmat[6]*Hmat[1]);
189 <  C[2][2] =  ( Hmat[0]*Hmat[4]) - (Hmat[3]*Hmat[1]);
185 >  return determinant;
186 > }
187  
188 <  // calcutlate the determinant of Hmat
188 > void SimInfo::invertMat3(double a[3][3], double b[3][3]) {
189    
190 <  detHmat = 0.0;
191 <  for(i=0; i<3; i++) detHmat += Hmat[i] * C[i][0];
190 >  int  i, j, k, l, m, n;
191 >  double determinant;
192  
193 <  
197 <  // H^-1 = C^T / det(H)
198 <  
199 <  i=0;
200 <  for(j=0; j<3; j++){
201 <    for(k=0; k<3; k++){
193 >  determinant = matDet3( a );
194  
195 <      HmatI[i] = C[j][k] / detHmat;
196 <      i++;
197 <    }
195 >  if (determinant == 0.0) {
196 >    sprintf( painCave.errMsg,
197 >             "Can't invert a matrix with a zero determinant!\n");
198 >    painCave.isFatal = 1;
199 >    simError();
200    }
201  
202 <  // sanity check
203 <
204 <  for(i=0; i<3; i++){
205 <    for(j=0; j<3; j++){
202 >  for (i=0; i < 3; i++) {
203 >    j = (i+1)%3;
204 >    k = (i+2)%3;
205 >    for(l = 0; l < 3; l++) {
206 >      m = (l+1)%3;
207 >      n = (l+2)%3;
208        
209 <      sanity[i][j] = 0.0;
214 <      for(k=0; k<3; k++){
215 <        sanity[i][j] += Hmat[3*k+i] * HmatI[3*j+k];
216 <      }
209 >      b[l][i] = (a[j][m]*a[k][n] - a[j][n]*a[k][m]) / determinant;
210      }
211    }
212 + }
213  
214 <  cerr << "sanity => \n"
215 <       << sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n"
222 <       << sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n"
223 <       << sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2]
224 <       << "\n";
225 <    
214 > void SimInfo::matMul3(double a[3][3], double b[3][3], double c[3][3]) {
215 >  double r00, r01, r02, r10, r11, r12, r20, r21, r22;
216  
217 <  // check to see if Hmat is orthorhombic
217 >  r00 = a[0][0]*b[0][0] + a[0][1]*b[1][0] + a[0][2]*b[2][0];
218 >  r01 = a[0][0]*b[0][1] + a[0][1]*b[1][1] + a[0][2]*b[2][1];
219 >  r02 = a[0][0]*b[0][2] + a[0][1]*b[1][2] + a[0][2]*b[2][2];
220    
221 <  smallDiag = Hmat[0];
222 <  if(smallDiag > Hmat[4]) smallDiag = Hmat[4];
223 <  if(smallDiag > Hmat[8]) smallDiag = Hmat[8];
224 <  tol = smallDiag * 1E-6;
221 >  r10 = a[1][0]*b[0][0] + a[1][1]*b[1][0] + a[1][2]*b[2][0];
222 >  r11 = a[1][0]*b[0][1] + a[1][1]*b[1][1] + a[1][2]*b[2][1];
223 >  r12 = a[1][0]*b[0][2] + a[1][1]*b[1][2] + a[1][2]*b[2][2];
224 >  
225 >  r20 = a[2][0]*b[0][0] + a[2][1]*b[1][0] + a[2][2]*b[2][0];
226 >  r21 = a[2][0]*b[0][1] + a[2][1]*b[1][1] + a[2][2]*b[2][1];
227 >  r22 = a[2][0]*b[0][2] + a[2][1]*b[1][2] + a[2][2]*b[2][2];
228 >  
229 >  c[0][0] = r00; c[0][1] = r01; c[0][2] = r02;
230 >  c[1][0] = r10; c[1][1] = r11; c[1][2] = r12;
231 >  c[2][0] = r20; c[2][1] = r21; c[2][2] = r22;
232 > }
233  
234 <  orthoRhombic = 1;
235 <  for(i=0; (i<9) && orthoRhombic; i++){
236 <    
237 <    if( (i%4) ){ // ignore the diagonals (0, 4, and 8)
238 <      orthoRhombic = (Hmat[i] <= tol);
234 > void SimInfo::matVecMul3(double m[3][3], double inVec[3], double outVec[3]) {
235 >  double a0, a1, a2;
236 >
237 >  a0 = inVec[0];  a1 = inVec[1];  a2 = inVec[2];
238 >
239 >  outVec[0] = m[0][0]*a0 + m[0][1]*a1 + m[0][2]*a2;
240 >  outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2;
241 >  outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2;
242 > }
243 >
244 > void SimInfo::transposeMat3(double in[3][3], double out[3][3]) {
245 >  double temp[3][3];
246 >  int i, j;
247 >
248 >  for (i = 0; i < 3; i++) {
249 >    for (j = 0; j < 3; j++) {
250 >      temp[j][i] = in[i][j];
251      }
252    }
253 <    
253 >  for (i = 0; i < 3; i++) {
254 >    for (j = 0; j < 3; j++) {
255 >      out[i][j] = temp[i][j];
256 >    }
257 >  }
258   }
259 +  
260 + void SimInfo::printMat3(double A[3][3] ){
261  
262 +  std::cerr
263 +            << "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n"
264 +            << "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n"
265 +            << "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n";
266 + }
267 +
268 + void SimInfo::printMat9(double A[9] ){
269 +
270 +  std::cerr
271 +            << "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n"
272 +            << "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n"
273 +            << "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n";
274 + }
275 +
276   void SimInfo::calcBoxL( void ){
277  
278    double dx, dy, dz, dsq;
279    int i;
280  
281 <  // boxVol = h1 (dot) h2 (cross) h3
281 >  // boxVol = Determinant of Hmat
282  
283 <  boxVol = Hmat[0] * ( (Hmat[4]*Hmat[8]) - (Hmat[7]*Hmat[5]) )
252 <         + Hmat[1] * ( (Hmat[5]*Hmat[6]) - (Hmat[8]*Hmat[3]) )
253 <         + Hmat[2] * ( (Hmat[3]*Hmat[7]) - (Hmat[6]*Hmat[4]) );
283 >  boxVol = matDet3( Hmat );
284  
255
285    // boxLx
286    
287 <  dx = Hmat[0]; dy = Hmat[1]; dz = Hmat[2];
287 >  dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0];
288    dsq = dx*dx + dy*dy + dz*dz;
289 <  boxLx = sqrt( dsq );
289 >  boxL[0] = sqrt( dsq );
290 >  maxCutoff = 0.5 * boxL[0];
291  
292    // boxLy
293    
294 <  dx = Hmat[3]; dy = Hmat[4]; dz = Hmat[5];
294 >  dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1];
295    dsq = dx*dx + dy*dy + dz*dz;
296 <  boxLy = sqrt( dsq );
296 >  boxL[1] = sqrt( dsq );
297 >  if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
298  
299    // boxLz
300    
301 <  dx = Hmat[6]; dy = Hmat[7]; dz = Hmat[8];
301 >  dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2];
302    dsq = dx*dx + dy*dy + dz*dz;
303 <  boxLz = sqrt( dsq );
304 <  
303 >  boxL[2] = sqrt( dsq );
304 >  if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
305 >
306   }
307  
308  
# Line 281 | Line 313 | void SimInfo::wrapVector( double thePos[3] ){
313  
314    if( !orthoRhombic ){
315      // calc the scaled coordinates.
316 +  
317 +
318 +    matVecMul3(HmatInv, thePos, scaled);
319      
320      for(i=0; i<3; i++)
321 <      scaled[i] =
287 <        thePos[0]*HmatI[i] + thePos[1]*HmatI[i+3] + thePos[3]*HmatI[i+6];
321 >      scaled[i] -= roundMe(scaled[i]);
322      
289    // wrap the scaled coordinates
290    
291    for(i=0; i<3; i++)
292      scaled[i] -= round(scaled[i]);
293    
323      // calc the wrapped real coordinates from the wrapped scaled coordinates
324      
325 <    for(i=0; i<3; i++)
326 <      thePos[i] =
298 <        scaled[0]*Hmat[i] + scaled[1]*Hmat[i+3] + scaled[3]*Hmat[i+6];
325 >    matVecMul3(Hmat, scaled, thePos);
326 >
327    }
328    else{
329      // calc the scaled coordinates.
330      
331      for(i=0; i<3; i++)
332 <      scaled[i] = thePos[i]*HmatI[i*4];
332 >      scaled[i] = thePos[i]*HmatInv[i][i];
333      
334      // wrap the scaled coordinates
335      
336      for(i=0; i<3; i++)
337 <      scaled[i] -= round(scaled[i]);
337 >      scaled[i] -= roundMe(scaled[i]);
338      
339      // calc the wrapped real coordinates from the wrapped scaled coordinates
340      
341      for(i=0; i<3; i++)
342 <      thePos[i] = scaled[i]*Hmat[i*4];
342 >      thePos[i] = scaled[i]*Hmat[i][i];
343    }
344      
317    
345   }
346  
347  
# Line 355 | Line 382 | void SimInfo::refreshSim(){
382    int isError;
383    int n_global;
384    int* excl;
385 <  
359 <  fInfo.rrf = 0.0;
360 <  fInfo.rt = 0.0;
385 >
386    fInfo.dielect = 0.0;
387  
363  fInfo.box[0] = box_x;
364  fInfo.box[1] = box_y;
365  fInfo.box[2] = box_z;
366
367  fInfo.rlist = rList;
368  fInfo.rcut = rCut;
369
388    if( useDipole ){
371    fInfo.rrf = ecr;
372    fInfo.rt = ecr - est;
389      if( useReactionField )fInfo.dielect = dielectric;
390    }
391  
# Line 415 | Line 431 | void SimInfo::refreshSim(){
431  
432    this->ndf = this->getNDF();
433    this->ndfRaw = this->getNDFraw();
434 +
435 + }
436 +
437 +
438 + void SimInfo::setRcut( double theRcut ){
439 +
440 +  if( !haveOrigRcut ){
441 +    haveOrigRcut = 1;
442 +    origRcut = theRcut;
443 +  }
444 +
445 +  rCut = theRcut;
446 +  checkCutOffs();
447 + }
448 +
449 + void SimInfo::setEcr( double theEcr ){
450 +
451 +  if( !haveOrigEcr ){
452 +    haveOrigEcr = 1;
453 +    origEcr = theEcr;
454 +  }
455 +
456 +  ecr = theEcr;
457 +  checkCutOffs();
458 + }
459  
460 + void SimInfo::setEcr( double theEcr, double theEst ){
461 +
462 +  est = theEst;
463 +  setEcr( theEcr );
464   }
465  
466 +
467 + void SimInfo::checkCutOffs( void ){
468 +
469 +  int cutChanged = 0;
470 +
471 +  if( boxIsInit ){
472 +    
473 +    //we need to check cutOffs against the box
474 +    
475 +    if( maxCutoff > rCut ){
476 +      if( rCut < origRcut ){
477 +        rCut = origRcut;
478 +        if (rCut > maxCutoff) rCut = maxCutoff;
479 +        
480 +        sprintf( painCave.errMsg,
481 +                 "New Box size is setting the long range cutoff radius "
482 +                 "to %lf\n",
483 +                 rCut );
484 +        painCave.isFatal = 0;
485 +        simError();
486 +      }
487 +    }
488 +
489 +    if( maxCutoff > ecr ){
490 +      if( ecr < origEcr ){
491 +        rCut = origEcr;
492 +        if (ecr > maxCutoff) ecr = maxCutoff;
493 +        
494 +        sprintf( painCave.errMsg,
495 +                 "New Box size is setting the electrostaticCutoffRadius "
496 +                 "to %lf\n",
497 +                 ecr );
498 +        painCave.isFatal = 0;
499 +        simError();
500 +      }
501 +    }
502 +
503 +
504 +    if (rCut > maxCutoff) {
505 +      sprintf( painCave.errMsg,
506 +               "New Box size is setting the long range cutoff radius "
507 +               "to %lf\n",
508 +               maxCutoff );
509 +      painCave.isFatal = 0;
510 +      simError();
511 +      rCut = maxCutoff;
512 +    }
513 +
514 +    if( ecr > maxCutoff){
515 +      sprintf( painCave.errMsg,
516 +               "New Box size is setting the electrostaticCutoffRadius "
517 +               "to %lf\n",
518 +               maxCutoff  );
519 +      painCave.isFatal = 0;
520 +      simError();      
521 +      ecr = maxCutoff;
522 +    }
523 +
524 +    
525 +  }
526 +  
527 +
528 +  if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1;
529 +
530 +  // rlist is the 1.0 plus max( rcut, ecr )
531 +  
532 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
533 +
534 +  if( cutChanged ){
535 +    
536 +    notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
537 +  }
538 +
539 +  oldEcr = ecr;
540 +  oldRcut = rCut;
541 + }
542 +
543 + void SimInfo::addProperty(GenericData* prop){
544 +
545 +  map<string, GenericData*>::iterator result;
546 +  result = properties.find(prop->getID());
547 +  
548 +  //we can't simply use  properties[prop->getID()] = prop,
549 +  //it will cause memory leak if we already contain a propery which has the same name of prop
550 +  
551 +  if(result != properties.end()){
552 +    
553 +    delete (*result).second;
554 +    (*result).second = prop;
555 +      
556 +  }
557 +  else{
558 +
559 +    properties[prop->getID()] = prop;
560 +
561 +  }
562 +    
563 + }
564 +
565 + GenericData* SimInfo::getProperty(const string& propName){
566 +
567 +  map<string, GenericData*>::iterator result;
568 +  
569 +  //string lowerCaseName = ();
570 +  
571 +  result = properties.find(propName);
572 +  
573 +  if(result != properties.end())
574 +    return (*result).second;  
575 +  else  
576 +    return NULL;  
577 + }
578 +
579 + vector<GenericData*> SimInfo::getProperties(){
580 +
581 +  vector<GenericData*> result;
582 +  map<string, GenericData*>::iterator i;
583 +  
584 +  for(i = properties.begin(); i != properties.end(); i++)
585 +    result.push_back((*i).second);
586 +    
587 +  return result;
588 + }
589 +
590 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines