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 655 by mmeineke, Tue Jul 29 16:32:06 2003 UTC vs.
Revision 689 by tim, Tue Aug 12 19:56:49 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 +  strcpy( initial_config, "./fooBar" );
135 +
136 + }
137 +
138   Globals::~Globals(){
139    int i;
140  
# Line 194 | Line 207 | int Globals::componentAssign( event* the_event ){
207    return 0;
208   }
209  
210 < int Globals::componentStartIndex( event* the_event ){
210 > int Globals::componentEnd( event* the_event ){
211  
212 <  current_component->startIndex( the_event->evt.si.array,
213 <                                 the_event->evt.si.n_elements );
212 >  the_event->err_msg = current_component->checkMe();
213 >  if( the_event->err_msg != NULL ) return 0;
214 >
215    return 1;
216   }
217  
218 < int Globals::componentEnd( event* the_event ){
218 > int Globals::newZconstraint( event* the_event ){
219 >  
220  
221 <  the_event->err_msg = current_component->checkMe();
221 >  int index = the_event->evt.blk_index;
222 >  char err[200];
223 >  current_zConstraint = new ZconStamp( index );
224 >  
225 >  have_zConstraints = 1;
226 >
227 >  if( have_n_zConstraints && index < n_zConstraints )
228 >    zConstraints[index] = current_zConstraint;
229 >  else{
230 >    if( have_n_zConstraints ){
231 >      sprintf( err, "Globals error, %d out of nZconstraints range",
232 >               index );
233 >      the_event->err_msg = strdup( err );
234 >      return 0;
235 >    }
236 >    else{
237 >      the_event->err_msg = strdup("Globals error, nZconstraints"
238 >                                  " not given before"
239 >                                  " first zConstraint declaration." );
240 >      return 0;
241 >    }
242 >  }  
243 >
244 >  return 1;
245 > }
246 >
247 >
248 >
249 > int Globals::zConstraintAssign( event* the_event ){
250 >
251 >  switch( the_event->evt.asmt.asmt_type ){
252 >    
253 >  case STRING:
254 >    return current_zConstraint->assignString( the_event->evt.asmt.lhs,
255 >                                              the_event->evt.asmt.rhs.sval,
256 >                                              &(the_event->err_msg));
257 >    break;
258 >    
259 >  case DOUBLE:
260 >    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
261 >                                              the_event->evt.asmt.rhs.dval,
262 >                                              &(the_event->err_msg));
263 >    break;
264 >    
265 >  case INT:
266 >    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
267 >                                           the_event->evt.asmt.rhs.ival,
268 >                                           &(the_event->err_msg));
269 >    break;
270 >    
271 >  default:
272 >    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
273 >                                 " assignment type" );
274 >    return 0;
275 >    break;
276 >  }
277 >  return 0;
278 > }
279 >
280 > int Globals::zConstraintEnd( event* the_event ){
281 >
282 >  the_event->err_msg = current_zConstraint->checkMe();
283    if( the_event->err_msg != NULL ) return 0;
284  
285    return 1;
# Line 258 | Line 334 | int Globals::globalAssign( event* the_event ){
334          return 1;
335        }
336        break;
337 +
338 +    case G_NZCONSTRAINTS:
339 +      if( the_type == STRING ){
340 +        the_event->err_msg =
341 +          strdup("Global error. nZconstraints is not a double or an int.\n" );
342 +        return 0;
343 +      }
344        
345 +      else if( the_type == DOUBLE ){
346 +        n_zConstraints = (int)the_event->evt.asmt.rhs.dval;
347 +        zConstraints = new ZconStamp*[n_zConstraints];
348 +        have_n_zConstraints = 1;
349 +        return 1;
350 +      }
351 +      
352 +      else{
353 +        n_zConstraints = the_event->evt.asmt.rhs.ival;
354 +        zConstraints = new ZconStamp*[n_zConstraints];
355 +        have_n_zConstraints = 1;
356 +        return 1;
357 +      }
358 +      break;
359 +      
360      case G_TARGETTEMP:
361        switch( the_type ){
362          
# Line 625 | Line 723 | int Globals::globalAssign( event* the_event ){
723        }
724        break;
725  
726 <   case G_THERMALTIME:
726 >    case G_THERMALTIME:
727        switch( the_type ){
728          
729        case STRING:
# Line 882 | Line 980 | int Globals::globalAssign( event* the_event ){
980          break;
981        }
982        break;
983 +      
984 +    case G_ZCONSTIME:
985 +      switch( the_type ){
986 +        
987 +      case STRING:
988 +        the_event->err_msg =
989 +          strdup( "Global error. zcons_time is not a double or int.\n" );
990 +        return 0;
991 +        break;
992 +        
993 +      case DOUBLE:
994 +        zcons_time = the_event->evt.asmt.rhs.dval;
995 +        have_zcons_time = 1;
996 +        return 1;
997 +        break;
998 +        
999 +      case INT:
1000 +        zcons_time = (double)the_event->evt.asmt.rhs.ival;
1001 +        have_zcons_time = 1;
1002 +        return 1;
1003 +        break;
1004 +        
1005 +      default:
1006 +        the_event->err_msg =
1007 +          strdup( "Global error. zcons_time unrecognized.\n" );
1008 +        return 0;
1009 +        break;
1010 +      }
1011 +      break;
1012  
1013 +    case G_ZCONSTOL:
1014 +      switch( the_type ){
1015 +        
1016 +      case STRING:
1017 +        the_event->err_msg =
1018 +          strdup( "Global error. zcons_tol is not a double or int.\n" );
1019 +        return 0;
1020 +        break;
1021 +        
1022 +      case DOUBLE:
1023 +        zcons_tol = the_event->evt.asmt.rhs.dval;
1024 +        have_zcons_tol = 1;
1025 +        return 1;
1026 +        break;
1027 +        
1028 +      case INT:
1029 +        zcons_tol = (double)the_event->evt.asmt.rhs.ival;
1030 +        have_zcons_tol = 1;
1031 +        return 1;
1032 +        break;
1033 +        
1034 +      default:
1035 +        the_event->err_msg =
1036 +          strdup( "Global error. zcons_ol unrecognized.\n" );
1037 +        return 0;
1038 +        break;
1039 +      }
1040 +      break;
1041 +  
1042  
1043        // add more token cases here.
1044  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines