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 659 by tim, Thu Jul 31 15:38:08 2003 UTC vs.
Revision 682 by tim, Tue Aug 12 17:51:33 2003 UTC

# Line 47 | Line 47
47   #define G_TAUTHERMOSTAT  26
48   #define G_TAUBAROSTAT    27
49   #define G_ZCONSTIME      28
50 < #define G_ZCONSMOLINDEX  29
50 > #define G_NZCONSTRAINTS  29
51 > #define G_ZCONSTOL 30
52  
52
53   Globals::Globals(){
54    
55    int i;
# Line 88 | Line 88 | Globals::Globals(){
88    addHash( "targetPressure",                       G_TARGETPRESSURE);
89    addHash( "tauThermostat",                        G_TAUTHERMOSTAT);
90    addHash( "tauBarostat",                          G_TAUBAROSTAT);
91 <  addHash( "zconsTime",     G_ZCONSTIME);
92 <  addHash( "zconsMolIndex", G_ZCONSMOLINDEX);
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 122 | 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 <  have_zcons_time = 0;
129 <  have_index_of_all_zcons_mols = 0;
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   Globals::~Globals(){
# Line 199 | Line 203 | int Globals::componentStartIndex( event* the_event ){
203    return 0;
204   }
205  
206 < int Globals::componentStartIndex( event* the_event ){
206 > int Globals::componentEnd( event* the_event ){
207  
208 <  current_component->startIndex( the_event->evt.si.array,
209 <                                 the_event->evt.si.n_elements );
208 >  the_event->err_msg = current_component->checkMe();
209 >  if( the_event->err_msg != NULL ) return 0;
210 >
211    return 1;
212   }
213  
214 < int Globals::componentEnd( event* the_event ){
214 > int Globals::newZconstraint( event* the_event ){
215 >  
216  
217 <  the_event->err_msg = current_component->checkMe();
217 >  int index = the_event->evt.blk_index;
218 >  char err[200];
219 >  current_zConstraint = new ZconStamp( index );
220 >  
221 >  have_zConstraints = 1;
222 >
223 >  if( have_n_zConstraints && index < n_zConstraints )
224 >    zConstraints[index] = current_zConstraint;
225 >  else{
226 >    if( have_n_zConstraints ){
227 >      sprintf( err, "Globals error, %d out of nZconstraints range",
228 >               index );
229 >      the_event->err_msg = strdup( err );
230 >      return 0;
231 >    }
232 >    else{
233 >      the_event->err_msg = strdup("Globals error, nZconstraints"
234 >                                  " not given before"
235 >                                  " first zConstraint declaration." );
236 >      return 0;
237 >    }
238 >  }  
239 >
240 >  return 1;
241 > }
242 >
243 >
244 >
245 > int Globals::zConstraintAssign( event* the_event ){
246 >
247 >  switch( the_event->evt.asmt.asmt_type ){
248 >    
249 >  case STRING:
250 >    return current_zConstraint->assignString( the_event->evt.asmt.lhs,
251 >                                            the_event->evt.asmt.rhs.sval,
252 >                                            &(the_event->err_msg));
253 >    break;
254 >    
255 >  case DOUBLE:
256 >    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
257 >                                            the_event->evt.asmt.rhs.dval,
258 >                                            &(the_event->err_msg));
259 >    break;
260 >    
261 >  case INT:
262 >    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
263 >                                         the_event->evt.asmt.rhs.ival,
264 >                                         &(the_event->err_msg));
265 >    break;
266 >    
267 >  default:
268 >    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
269 >                                 " assignment type" );
270 >    return 0;
271 >    break;
272 >  }
273 >  return 0;
274 > }
275 >
276 > int Globals::zConstraintEnd( event* the_event ){
277 >
278 >  the_event->err_msg = current_zConstraint->checkMe();
279    if( the_event->err_msg != NULL ) return 0;
280  
281    return 1;
# Line 263 | Line 330 | int Globals::globalAssign( event* the_event ){
330          return 1;
331        }
332        break;
333 +
334 +    case G_NZCONSTRAINTS:
335 +      if( the_type == STRING ){
336 +        the_event->err_msg =
337 +          strdup("Global error. nZconstraints is not a double or an int.\n" );
338 +        return 0;
339 +      }
340        
341 +      else if( the_type == DOUBLE ){
342 +        n_zConstraints = (int)the_event->evt.asmt.rhs.dval;
343 +        zConstraints = new ZconStamp*[n_zConstraints];
344 +        have_n_zConstraints = 1;
345 +        return 1;
346 +      }
347 +      
348 +      else{
349 +        n_zConstraints = the_event->evt.asmt.rhs.ival;
350 +        zConstraints = new ZconStamp*[n_zConstraints];
351 +        have_n_zConstraints = 1;
352 +        return 1;
353 +      }
354 +      break;
355 +      
356      case G_TARGETTEMP:
357        switch( the_type ){
358          
# Line 899 | Line 988 | int Globals::globalAssign( event* the_event ){
988          
989        case DOUBLE:
990          zcons_time = the_event->evt.asmt.rhs.dval;
991 +        have_zcons_time = 1;
992          return 1;
993          break;
994          
# Line 915 | Line 1005 | int Globals::globalAssign( event* the_event ){
1005          break;
1006        }
1007        break;
1008 <  
1009 <   case G_ZCONSMOLINDEX:
1008 >
1009 >   case G_ZCONSTOL:
1010        switch( the_type ){
1011          
1012        case STRING:
1013          the_event->err_msg =
1014 <          strdup( "Global error. zconsMolIndex is not a  int.\n" );
1014 >          strdup( "Global error. zcons_tol is not a double or int.\n" );
1015          return 0;
1016          break;
1017 <                
1017 >        
1018 >      case DOUBLE:
1019 >        zcons_tol = the_event->evt.asmt.rhs.dval;
1020 >        have_zcons_tol = 1;
1021 >        return 1;
1022 >        break;
1023 >        
1024        case INT:
1025 <        zconsMolIndex.push_back(the_event->evt.asmt.rhs.ival);
1026 <        have_index_of_all_zcons_mols = 1;
1027 <        return 1;
1025 >        zcons_tol = (double)the_event->evt.asmt.rhs.ival;
1026 >        have_zcons_tol = 1;
1027 >        return 1;
1028          break;
1029          
1030        default:
1031          the_event->err_msg =
1032 <          strdup( "Global error. zconsMolIndex unrecognized.\n" );
1032 >          strdup( "Global error. zcons_ol unrecognized.\n" );
1033          return 0;
1034          break;
1035        }
1036        break;
1037 +  
1038  
1039        // add more token cases here.
1040  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines