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 675 by mmeineke, Mon Aug 11 19:38:44 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  
52  
53   Globals::Globals(){
# 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 >
94    // define some default values
95  
96    strcpy( mixingRule,"standard");  //default mixing rules to standard.
# Line 122 | Line 123 | Globals::Globals(){
123    have_target_pressure =0;
124    have_q_mass =         0;
125    have_tau_thermostat = 0;
126 <  have_tau_barostat =   0;
127 <  have_zcons_time = 0;
128 <  have_index_of_all_zcons_mols = 0;
126 >  have_tau_barostat   = 0;
127 >  have_zcon_time     = 0;
128 >  have_n_zConstraints = 0;
129 >  have_zConstraints   = 0;
130   }
131  
132   Globals::~Globals(){
# Line 199 | Line 201 | int Globals::componentStartIndex( event* the_event ){
201    return 0;
202   }
203  
204 < int Globals::componentStartIndex( event* the_event ){
204 > int Globals::componentEnd( event* the_event ){
205  
206 <  current_component->startIndex( the_event->evt.si.array,
207 <                                 the_event->evt.si.n_elements );
206 >  the_event->err_msg = current_component->checkMe();
207 >  if( the_event->err_msg != NULL ) return 0;
208 >
209    return 1;
210   }
211  
212 < int Globals::componentEnd( event* the_event ){
212 > int Globals::newZconstraint( event* the_event ){
213 >  
214  
215 <  the_event->err_msg = current_component->checkMe();
215 >  int index = the_event->evt.blk_index;
216 >  char err[200];
217 >  current_zConstraint = new ZconStamp( index );
218 >  
219 >  have_zConstraints = 1;
220 >
221 >  if( have_n_zConstraints && index < n_zConstraints )
222 >    zConstraints[index] = current_zConstraint;
223 >  else{
224 >    if( have_n_zConstraints ){
225 >      sprintf( err, "Globals error, %d out of nZconstraints range",
226 >               index );
227 >      the_event->err_msg = strdup( err );
228 >      return 0;
229 >    }
230 >    else{
231 >      the_event->err_msg = strdup("Globals error, nZconstraints"
232 >                                  " not given before"
233 >                                  " first zConstraint declaration." );
234 >      return 0;
235 >    }
236 >  }  
237 >
238 >  return 1;
239 > }
240 >
241 >
242 >
243 > int Globals::zConstraintAssign( event* the_event ){
244 >
245 >  switch( the_event->evt.asmt.asmt_type ){
246 >    
247 >  case STRING:
248 >    return current_zConstraint->assignString( the_event->evt.asmt.lhs,
249 >                                            the_event->evt.asmt.rhs.sval,
250 >                                            &(the_event->err_msg));
251 >    break;
252 >    
253 >  case DOUBLE:
254 >    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
255 >                                            the_event->evt.asmt.rhs.dval,
256 >                                            &(the_event->err_msg));
257 >    break;
258 >    
259 >  case INT:
260 >    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
261 >                                         the_event->evt.asmt.rhs.ival,
262 >                                         &(the_event->err_msg));
263 >    break;
264 >    
265 >  default:
266 >    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
267 >                                 " assignment type" );
268 >    return 0;
269 >    break;
270 >  }
271 >  return 0;
272 > }
273 >
274 > int Globals::zConstraintEnd( event* the_event ){
275 >
276 >  the_event->err_msg = current_zConstraint->checkMe();
277    if( the_event->err_msg != NULL ) return 0;
278  
279    return 1;
# Line 260 | Line 325 | int Globals::globalAssign( event* the_event ){
325          n_components = the_event->evt.asmt.rhs.ival;
326          components = new Component*[n_components];
327          have_n_components = 1;
328 +        return 1;
329 +      }
330 +      break;
331 +
332 +    case G_NZCONSTRAINTS:
333 +      if( the_type == STRING ){
334 +        the_event->err_msg =
335 +          strdup("Global error. nZconstraints is not a double or an int.\n" );
336 +        return 0;
337 +      }
338 +      
339 +      else if( the_type == DOUBLE ){
340 +        n_zConstraints = (int)the_event->evt.asmt.rhs.dval;
341 +        zConstraints = new ZconStamp*[n_zConstraints];
342 +        have_n_zConstraints = 1;
343 +        return 1;
344 +      }
345 +      
346 +      else{
347 +        n_zConstraints = the_event->evt.asmt.rhs.ival;
348 +        zConstraints = new ZconStamp*[n_zConstraints];
349 +        have_n_zConstraints = 1;
350          return 1;
351        }
352        break;
# Line 904 | Line 991 | int Globals::globalAssign( event* the_event ){
991          
992        case INT:
993          zcons_time = (double)the_event->evt.asmt.rhs.ival;
994 <        have_zcons_time = 1;
994 >        have_zcon_time = 1;
995          return 1;
996          break;
997          
# Line 916 | Line 1003 | int Globals::globalAssign( event* the_event ){
1003        }
1004        break;
1005    
919   case G_ZCONSMOLINDEX:
920      switch( the_type ){
921        
922      case STRING:
923        the_event->err_msg =
924          strdup( "Global error. zconsMolIndex is not a  int.\n" );
925        return 0;
926        break;
927                
928      case INT:
929        zconsMolIndex.push_back(the_event->evt.asmt.rhs.ival);
930        have_index_of_all_zcons_mols = 1;
931        return 1;
932        break;
933        
934      default:
935        the_event->err_msg =
936          strdup( "Global error. zconsMolIndex unrecognized.\n" );
937        return 0;
938        break;
939      }
940      break;
1006  
1007        // add more token cases here.
1008  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines