ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/Globals.cpp
(Generate patch)

Comparing trunk/OOPSE/libBASS/Globals.cpp (file contents):
Revision 579 by gezelter, Wed Jul 9 13:56:27 2003 UTC vs.
Revision 693 by tim, Wed Aug 13 19:21:53 2003 UTC

# Line 46 | Line 46
46   #define G_TARGETPRESSURE 25
47   #define G_TAUTHERMOSTAT  26
48   #define G_TAUBAROSTAT    27
49 + #define G_ZCONSTIME      28
50 + #define G_NZCONSTRAINTS  29
51 + #define G_ZCONSTOL 30
52  
50
53   Globals::Globals(){
54    
55    int i;
# Line 86 | Line 88 | Globals::Globals(){
88    addHash( "targetPressure",                       G_TARGETPRESSURE);
89    addHash( "tauThermostat",                        G_TAUTHERMOSTAT);
90    addHash( "tauBarostat",                          G_TAUBAROSTAT);
91 <  
91 >  addHash( "zconsTime",                            G_ZCONSTIME);
92 >  addHash( "nZconstraints",                        G_NZCONSTRAINTS);
93 >  addHash( "zconsTol",                               G_ZCONSTOL);
94 >        
95    // define some default values
96  
97    strcpy( mixingRule,"standard");  //default mixing rules to standard.
# Line 119 | Line 124 | Globals::Globals(){
124    have_target_pressure =0;
125    have_q_mass =         0;
126    have_tau_thermostat = 0;
127 <  have_tau_barostat =   0;
128 < }
127 >  have_tau_barostat   = 0;
128 >  have_zcons_time     = 0;
129 >  have_n_zConstraints = 0;
130 >  have_zConstraints   = 0;
131 >  have_zcons_tol = 0;
132  
133 + }
134 +
135   Globals::~Globals(){
136    int i;
137  
# Line 194 | Line 204 | int Globals::componentStartIndex( event* the_event ){
204    return 0;
205   }
206  
207 < int Globals::componentStartIndex( event* the_event ){
207 > int Globals::componentEnd( event* the_event ){
208  
209 <  current_component->startIndex( the_event->evt.si.array,
210 <                                 the_event->evt.si.n_elements );
209 >  the_event->err_msg = current_component->checkMe();
210 >  if( the_event->err_msg != NULL ) return 0;
211 >
212    return 1;
213   }
214  
215 < int Globals::componentEnd( event* the_event ){
215 > int Globals::newZconstraint( event* the_event ){
216 >  
217  
218 <  the_event->err_msg = current_component->checkMe();
218 >  int index = the_event->evt.blk_index;
219 >  char err[200];
220 >  current_zConstraint = new ZconStamp( index );
221 >  
222 >  have_zConstraints = 1;
223 >
224 >  if( have_n_zConstraints && index < n_zConstraints )
225 >    zConstraints[index] = current_zConstraint;
226 >  else{
227 >    if( have_n_zConstraints ){
228 >      sprintf( err, "Globals error, %d out of nZconstraints range",
229 >               index );
230 >      the_event->err_msg = strdup( err );
231 >      return 0;
232 >    }
233 >    else{
234 >      the_event->err_msg = strdup("Globals error, nZconstraints"
235 >                                  " not given before"
236 >                                  " first zConstraint declaration." );
237 >      return 0;
238 >    }
239 >  }  
240 >
241 >  return 1;
242 > }
243 >
244 >
245 >
246 > int Globals::zConstraintAssign( event* the_event ){
247 >
248 >  switch( the_event->evt.asmt.asmt_type ){
249 >    
250 >  case STRING:
251 >    return current_zConstraint->assignString( the_event->evt.asmt.lhs,
252 >                                              the_event->evt.asmt.rhs.sval,
253 >                                              &(the_event->err_msg));
254 >    break;
255 >    
256 >  case DOUBLE:
257 >    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
258 >                                              the_event->evt.asmt.rhs.dval,
259 >                                              &(the_event->err_msg));
260 >    break;
261 >    
262 >  case INT:
263 >    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
264 >                                           the_event->evt.asmt.rhs.ival,
265 >                                           &(the_event->err_msg));
266 >    break;
267 >    
268 >  default:
269 >    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
270 >                                 " assignment type" );
271 >    return 0;
272 >    break;
273 >  }
274 >  return 0;
275 > }
276 >
277 > int Globals::zConstraintEnd( event* the_event ){
278 >
279 >  the_event->err_msg = current_zConstraint->checkMe();
280    if( the_event->err_msg != NULL ) return 0;
281  
282    return 1;
# Line 258 | Line 331 | int Globals::globalAssign( event* the_event ){
331          return 1;
332        }
333        break;
334 +
335 +    case G_NZCONSTRAINTS:
336 +      if( the_type == STRING ){
337 +        the_event->err_msg =
338 +          strdup("Global error. nZconstraints is not a double or an int.\n" );
339 +        return 0;
340 +      }
341        
342 +      else if( the_type == DOUBLE ){
343 +        n_zConstraints = (int)the_event->evt.asmt.rhs.dval;
344 +        zConstraints = new ZconStamp*[n_zConstraints];
345 +        have_n_zConstraints = 1;
346 +        return 1;
347 +      }
348 +      
349 +      else{
350 +        n_zConstraints = the_event->evt.asmt.rhs.ival;
351 +        zConstraints = new ZconStamp*[n_zConstraints];
352 +        have_n_zConstraints = 1;
353 +        return 1;
354 +      }
355 +      break;
356 +      
357      case G_TARGETTEMP:
358        switch( the_type ){
359          
# Line 625 | Line 720 | int Globals::globalAssign( event* the_event ){
720        }
721        break;
722  
723 <   case G_THERMALTIME:
723 >    case G_THERMALTIME:
724        switch( the_type ){
725          
726        case STRING:
# Line 882 | Line 977 | int Globals::globalAssign( event* the_event ){
977          break;
978        }
979        break;
980 +      
981 +    case G_ZCONSTIME:
982 +      switch( the_type ){
983 +        
984 +      case STRING:
985 +        the_event->err_msg =
986 +          strdup( "Global error. zcons_time is not a double or int.\n" );
987 +        return 0;
988 +        break;
989 +        
990 +      case DOUBLE:
991 +        zcons_time = the_event->evt.asmt.rhs.dval;
992 +        have_zcons_time = 1;
993 +        return 1;
994 +        break;
995 +        
996 +      case INT:
997 +        zcons_time = (double)the_event->evt.asmt.rhs.ival;
998 +        have_zcons_time = 1;
999 +        return 1;
1000 +        break;
1001 +        
1002 +      default:
1003 +        the_event->err_msg =
1004 +          strdup( "Global error. zcons_time unrecognized.\n" );
1005 +        return 0;
1006 +        break;
1007 +      }
1008 +      break;
1009  
1010 +    case G_ZCONSTOL:
1011 +      switch( the_type ){
1012 +        
1013 +      case STRING:
1014 +        the_event->err_msg =
1015 +          strdup( "Global error. zcons_tol is not a double or int.\n" );
1016 +        return 0;
1017 +        break;
1018 +        
1019 +      case DOUBLE:
1020 +        zcons_tol = the_event->evt.asmt.rhs.dval;
1021 +        have_zcons_tol = 1;
1022 +        return 1;
1023 +        break;
1024 +        
1025 +      case INT:
1026 +        zcons_tol = (double)the_event->evt.asmt.rhs.ival;
1027 +        have_zcons_tol = 1;
1028 +        return 1;
1029 +        break;
1030 +        
1031 +      default:
1032 +        the_event->err_msg =
1033 +          strdup( "Global error. zcons_ol unrecognized.\n" );
1034 +        return 0;
1035 +        break;
1036 +      }
1037 +      break;
1038 +  
1039 +
1040 +      // add more token cases here.
1041 +
1042      }
1043    }
1044    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines