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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines