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 574 by gezelter, Tue Jul 8 20:56:10 2003 UTC vs.
Revision 690 by mmeineke, Tue Aug 12 21:44:06 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines