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

Comparing trunk/OOPSE-2.0/src/io/Globals.cpp (file contents):
Revision 1490 by gezelter, Fri Sep 24 04:16:43 2004 UTC vs.
Revision 2308 by chuckv, Fri Sep 16 23:04:47 2005 UTC

# Line 1 | Line 1
1 + /*
2 + * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + *
4 + * The University of Notre Dame grants you ("Licensee") a
5 + * non-exclusive, royalty free, license to use, modify and
6 + * redistribute this software in source and binary code form, provided
7 + * that the following conditions are met:
8 + *
9 + * 1. Acknowledgement of the program authors must be made in any
10 + *    publication of scientific results based in part on use of the
11 + *    program.  An acceptable form of acknowledgement is citation of
12 + *    the article in which the program was described (Matthew
13 + *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 + *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 + *    Parallel Simulation Engine for Molecular Dynamics,"
16 + *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 + *
18 + * 2. Redistributions of source code must retain the above copyright
19 + *    notice, this list of conditions and the following disclaimer.
20 + *
21 + * 3. Redistributions in binary form must reproduce the above copyright
22 + *    notice, this list of conditions and the following disclaimer in the
23 + *    documentation and/or other materials provided with the
24 + *    distribution.
25 + *
26 + * This software is provided "AS IS," without a warranty of any
27 + * kind. All express or implied conditions, representations and
28 + * warranties, including any implied warranty of merchantability,
29 + * fitness for a particular purpose or non-infringement, are hereby
30 + * excluded.  The University of Notre Dame and its licensors shall not
31 + * be liable for any damages suffered by licensee as a result of
32 + * using, modifying or distributing the software or its
33 + * derivatives. In no event will the University of Notre Dame or its
34 + * licensors be liable for any lost revenue, profit or data, or for
35 + * direct, indirect, special, consequential, incidental or punitive
36 + * damages, however caused and regardless of the theory of liability,
37 + * arising out of the use of or inability to use software, even if the
38 + * University of Notre Dame has been advised of the possibility of
39 + * such damages.
40 + */
41 +
42   #include <stdlib.h>
43   #include <stdio.h>
44   #include <string.h>
45  
46 < #include "Globals.hpp"
47 < #include "simError.h"
46 > #include "io/Globals.hpp"
47 > #include "utils/simError.h"
48   #ifdef IS_MPI
49 < #include "mpiBASS.h"
49 > #include "io/mpiBASS.h"
50   #endif // is_mpi
51  
52   /*
53   * The following section lists all of the defined tokens for the
54 < * gloabal assignment statements. All are prefixed with a G_ to avoid
54 > * global assignment statements. All are prefixed with a G_ to avoid
55   * stepping on any previously defined enumerations.
56   *
57   * NOTE: tokens start at 1, 0 is a resrved token number
# Line 42 | Line 83
83   #define G_THERMALTIME       21
84   #define G_USEPBC            22
85   #define G_MIXINGRULE        23
86 < #define G_USERF             24
87 < #define G_TARGETPRESSURE    25
88 < #define G_TAUTHERMOSTAT     26
89 < #define G_TAUBAROSTAT       27
90 < #define G_ZCONSTIME         28
91 < #define G_NZCONSTRAINTS     29
92 < #define G_ZCONSTOL          30
93 < #define G_ZCONSFORCEPOLICY  31
94 < #define G_SEED              32
95 < #define G_RESETTIME         33
96 < #define G_USEINITTIME       34
97 < #define G_USEINIT_XS_STATE  35
98 < #define G_ORTHOBOXTOLERANCE 36
99 < #define G_MINIMIZER         37
100 < #define G_MIN_MAXITER       38
101 < #define G_MIN_WRITEFRQ      39
102 < #define G_MIN_STEPSIZE      40
103 < #define G_MIN_FTOL          41
104 < #define G_MIN_GTOL          42
105 < #define G_MIN_LSTOL         43
106 < #define G_MIN_LSMAXITER     44
107 < #define G_ZCONSGAP          45
108 < #define G_ZCONSFIXTIME      46
109 < #define G_ZCONSUSINGSMD     47
110 < #define G_USE_SOLID_THERM_INT     48
111 < #define G_USE_LIQUID_THERM_INT    49
112 < #define G_THERM_INT_LAMBDA  50
113 < #define G_THERM_INT_K       51
114 < #define G_FORCEFIELD_VARIANT 52
86 > #define G_TARGETPRESSURE    24
87 > #define G_TAUTHERMOSTAT     25
88 > #define G_TAUBAROSTAT       26
89 > #define G_ZCONSTIME         27
90 > #define G_NZCONSTRAINTS     28
91 > #define G_ZCONSTOL          29
92 > #define G_ZCONSFORCEPOLICY  30
93 > #define G_SEED              31
94 > #define G_RESETTIME         32
95 > #define G_USEINITTIME       33
96 > #define G_USEINIT_XS_STATE  34
97 > #define G_ORTHOBOXTOLERANCE 35
98 > #define G_MINIMIZER         36
99 > #define G_MIN_MAXITER       37
100 > #define G_MIN_WRITEFRQ      38
101 > #define G_MIN_STEPSIZE      39
102 > #define G_MIN_FTOL          40
103 > #define G_MIN_GTOL          41
104 > #define G_MIN_LSTOL         42
105 > #define G_MIN_LSMAXITER     43
106 > #define G_ZCONSGAP          44
107 > #define G_ZCONSFIXTIME      45
108 > #define G_ZCONSUSINGSMD     46
109 > #define G_USE_SOLID_THERM_INT    47
110 > #define G_USE_LIQUID_THERM_INT   48
111 > #define G_THERM_INT_LAMBDA  49
112 > #define G_THERM_INT_K       50
113 > #define G_FORCEFIELD_VARIANT     51
114 > #define G_FORCEFIELD_FILENAME    52
115 > #define G_THERM_INT_DIST_SPRING  53
116 > #define G_THERM_INT_THETA_SPRING 54
117 > #define G_THERM_INT_OMEGA_SPRING 55
118 > #define G_SURFACETENSION    56
119 > #define G_PRINTPRESSURETENSOR    57
120 > #define G_ELECTRO_SUM_METHOD     58
121 > #define G_DAMPING_ALPHA     59
122 > #define G_CUTOFFPOLICY      60
123 > #define G_COMPRESSDUMPFILE  61
124  
125   Globals::Globals(){
126    initalize();
# Line 78 | Line 128 | Globals::~Globals(){
128  
129   Globals::~Globals(){
130    int i;
81
82  for( i=0; i<hash_size; i++ ){
83    if( command_table[i] != NULL ) delete command_table[i];
84  }
85  delete[] command_table;
86
131    if( components != NULL ){
132      for( i=0; i<n_components; i++ ) delete components[i];
133      delete[] components;
# Line 93 | Line 137 | void Globals::initalize(){
137   void Globals::initalize(){
138    int i;
139    
96  hash_size = 23;
97  hash_shift = 4;
98  
140    components = NULL;
141    
142 <  command_table = new LinkedCommand*[hash_size];
143 <  for( i=0; i<hash_size; i++ ) command_table[i] = NULL;
144 <  
145 <  addHash( "forceField",    G_FORCEFIELD );
146 <  addHash( "nComponents",   G_NCOMPONENTS );
147 <  addHash( "targetTemp",    G_TARGETTEMP );
148 <  addHash( "ensemble",      G_ENSEMBLE );
149 <  
150 <  addHash( "dt",            G_DT );
151 <  addHash( "runTime",       G_RUNTIME );
152 <  
153 <  addHash( "initialConfig", G_INITIALCONFIG );
154 <  addHash( "finalConfig",   G_FINALCONFIG );
155 <  addHash( "nMol",          G_NMOL );
156 <  addHash( "density",       G_DENSITY );
157 <  addHash( "box",           G_BOX );
158 <  addHash( "boxX",          G_BOXX );
159 <  addHash( "boxY",          G_BOXY );
160 <  addHash( "boxZ",          G_BOXZ );
161 <  addHash( "sampleTime",    G_SAMPLETIME );
162 <  addHash( "resetTime",     G_RESETTIME );
163 <  addHash( "statusTime",    G_STATUSTIME );
164 <  addHash( "cutoffRadius",  G_RCUT );
165 <  addHash( "switchingRadius",  G_RSW );
166 <  addHash( "dielectric",    G_DIELECTRIC );
167 <  addHash( "tempSet",       G_TEMPSET );
168 <  addHash( "thermalTime",   G_THERMALTIME );
169 <  addHash( "mixingRule",    G_MIXINGRULE);
170 <  addHash( "usePeriodicBoundaryConditions",        G_USEPBC);
171 <  addHash( "useReactionField",                     G_USERF );
172 <  addHash( "targetPressure",                       G_TARGETPRESSURE);
173 <  addHash( "tauThermostat",                        G_TAUTHERMOSTAT);
174 <  addHash( "tauBarostat",                          G_TAUBAROSTAT);
175 <  addHash( "zconsTime",                            G_ZCONSTIME);
176 <  addHash( "nZconstraints",                        G_NZCONSTRAINTS);
177 <  addHash( "zconsTol",                             G_ZCONSTOL);
178 <  addHash( "zconsForcePolicy",                     G_ZCONSFORCEPOLICY);
179 <  addHash( "seed",                                 G_SEED);
180 <  addHash( "useInitialTime",                       G_USEINITTIME);
181 <  addHash( "useInitialExtendedSystemState",        G_USEINIT_XS_STATE);
182 <  addHash( "orthoBoxTolerance",                    G_ORTHOBOXTOLERANCE);
183 <  addHash( "minimizer",                            G_MINIMIZER);
184 <  addHash( "minimizerMaxIter",                     G_MIN_MAXITER);
185 <  addHash( "minimizerWriteFrq",                    G_MIN_WRITEFRQ);
186 <  addHash( "minimizerStepSize",                    G_MIN_STEPSIZE);
187 <  addHash( "minimizerFTol",                        G_MIN_FTOL);
188 <  addHash( "minimizerGTol",                        G_MIN_GTOL);
189 <  addHash( "minimizerLSTol",                       G_MIN_LSTOL);
190 <  addHash( "minimizerLSMaxIter",                   G_MIN_LSMAXITER);
191 <  addHash( "zconsGap",                             G_ZCONSGAP);
192 <  addHash( "zconsFixtime",                         G_ZCONSFIXTIME);
193 <  addHash( "zconsUsingSMD",                        G_ZCONSUSINGSMD);
194 <  addHash( "useSolidThermInt",                     G_USE_SOLID_THERM_INT);
195 <  addHash( "useLiquidThermInt",                    G_USE_LIQUID_THERM_INT);
196 <  addHash( "thermodynamicIntegrationLambda",       G_THERM_INT_LAMBDA);
197 <  addHash( "thermodynamicIntegrationK",            G_THERM_INT_K);
198 <  addHash( "forceFieldVariant",                    G_FORCEFIELD_VARIANT);
142 >  command_table.insert(CommandMapType::value_type("forceField", G_FORCEFIELD));
143 >  command_table.insert(CommandMapType::value_type("nComponents", G_NCOMPONENTS));
144 >  command_table.insert(CommandMapType::value_type("targetTemp", G_TARGETTEMP));
145 >  command_table.insert(CommandMapType::value_type("ensemble", G_ENSEMBLE));
146 >  command_table.insert(CommandMapType::value_type("dt", G_DT));
147 >  command_table.insert(CommandMapType::value_type("runTime", G_RUNTIME));
148 >  command_table.insert(CommandMapType::value_type("initialConfig", G_INITIALCONFIG));
149 >  command_table.insert(CommandMapType::value_type("finalConfig", G_FINALCONFIG));
150 >  command_table.insert(CommandMapType::value_type("nMol", G_NMOL));
151 >  command_table.insert(CommandMapType::value_type("density", G_DENSITY));
152 >  command_table.insert(CommandMapType::value_type("box", G_BOX));
153 >  command_table.insert(CommandMapType::value_type("boxX", G_BOXX));
154 >  command_table.insert(CommandMapType::value_type("boxY", G_BOXY));
155 >  command_table.insert(CommandMapType::value_type("boxZ", G_BOXZ));
156 >  command_table.insert(CommandMapType::value_type("sampleTime", G_SAMPLETIME));
157 >  command_table.insert(CommandMapType::value_type("resetTime", G_RESETTIME));
158 >  command_table.insert(CommandMapType::value_type("statusTime", G_STATUSTIME));
159 >  command_table.insert(CommandMapType::value_type("cutoffRadius", G_RCUT));
160 >  command_table.insert(CommandMapType::value_type("switchingRadius", G_RSW));
161 >  command_table.insert(CommandMapType::value_type("dielectric", G_DIELECTRIC));
162 >  command_table.insert(CommandMapType::value_type("tempSet", G_TEMPSET));
163 >  command_table.insert(CommandMapType::value_type("thermalTime", G_THERMALTIME));
164 >  command_table.insert(CommandMapType::value_type("mixingRule", G_MIXINGRULE));
165 >  command_table.insert(CommandMapType::value_type("usePeriodicBoundaryConditions", G_USEPBC));
166 >  command_table.insert(CommandMapType::value_type("targetPressure", G_TARGETPRESSURE));
167 >  command_table.insert(CommandMapType::value_type("tauThermostat", G_TAUTHERMOSTAT));
168 >  command_table.insert(CommandMapType::value_type("tauBarostat", G_TAUBAROSTAT));
169 >  command_table.insert(CommandMapType::value_type("zconsTime", G_ZCONSTIME));
170 >  command_table.insert(CommandMapType::value_type("nZconstraints", G_NZCONSTRAINTS));
171 >  command_table.insert(CommandMapType::value_type("zconsTol", G_ZCONSTOL));
172 >  command_table.insert(CommandMapType::value_type("zconsForcePolicy", G_ZCONSFORCEPOLICY));
173 >  command_table.insert(CommandMapType::value_type("seed", G_SEED));
174 >  command_table.insert(CommandMapType::value_type("useInitialTime", G_USEINITTIME));
175 >  command_table.insert(CommandMapType::value_type("useInitialExtendedSystemState", G_USEINIT_XS_STATE));
176 >  command_table.insert(CommandMapType::value_type("orthoBoxTolerance", G_ORTHOBOXTOLERANCE));
177 >  command_table.insert(CommandMapType::value_type("minimizer", G_MINIMIZER));
178 >  command_table.insert(CommandMapType::value_type("minimizerMaxIter", G_MIN_MAXITER));
179 >  command_table.insert(CommandMapType::value_type("minimizerWriteFrq", G_MIN_WRITEFRQ));
180 >  command_table.insert(CommandMapType::value_type("minimizerStepSize", G_MIN_STEPSIZE));
181 >  command_table.insert(CommandMapType::value_type("minimizerFTol", G_MIN_FTOL));
182 >  command_table.insert(CommandMapType::value_type("minimizerGTol", G_MIN_GTOL));
183 >  command_table.insert(CommandMapType::value_type("minimizerLSTol", G_MIN_LSTOL));
184 >  command_table.insert(CommandMapType::value_type("minimizerLSMaxIter", G_MIN_LSMAXITER));
185 >  command_table.insert(CommandMapType::value_type("zconsGap", G_ZCONSGAP));
186 >  command_table.insert(CommandMapType::value_type("zconsFixtime", G_ZCONSFIXTIME));
187 >  command_table.insert(CommandMapType::value_type("zconsUsingSMD", G_ZCONSUSINGSMD));
188 >  command_table.insert(CommandMapType::value_type("useSolidThermInt", G_USE_SOLID_THERM_INT));
189 >  command_table.insert(CommandMapType::value_type("useLiquidThermInt", G_USE_LIQUID_THERM_INT));
190 >  command_table.insert(CommandMapType::value_type("thermodynamicIntegrationLambda", G_THERM_INT_LAMBDA));
191 >  command_table.insert(CommandMapType::value_type("thermodynamicIntegrationK", G_THERM_INT_K));
192 >  command_table.insert(CommandMapType::value_type("forceFieldVariant", G_FORCEFIELD_VARIANT));
193 >  command_table.insert(CommandMapType::value_type("forceFieldFileName", G_FORCEFIELD_FILENAME));
194 >  command_table.insert(CommandMapType::value_type("thermIntDistSpringConst", G_THERM_INT_DIST_SPRING));
195 >  command_table.insert(CommandMapType::value_type("thermIntThetaSpringConst", G_THERM_INT_THETA_SPRING));
196 >  command_table.insert(CommandMapType::value_type("thermIntOmegaSpringConst", G_THERM_INT_OMEGA_SPRING));
197 >  command_table.insert(CommandMapType::value_type("surfaceTension", G_SURFACETENSION));
198 >  command_table.insert(CommandMapType::value_type("printPressureTensor", G_PRINTPRESSURETENSOR));
199 >  command_table.insert(CommandMapType::value_type("electrostaticSummationMethod", G_ELECTRO_SUM_METHOD));
200 >  command_table.insert(CommandMapType::value_type("dampingAlpha", G_DAMPING_ALPHA));
201 >  command_table.insert(CommandMapType::value_type("cutoffPolicy", G_CUTOFFPOLICY));
202 >  command_table.insert(CommandMapType::value_type("compressDumpFile", G_COMPRESSDUMPFILE));
203  
204    strcpy( mixingRule,"standard");  //default mixing rules to standard.
205    usePBC = 1; //default  periodic boundry conditions to on
161  useRF  = 0;
206    useInitTime = 0; // default to pull init time from the init file
207    useInitXSstate = 0; // default to pull the extended state from the init file
208    orthoBoxTolerance = 1E-6;
209    useSolidThermInt = 0; // default solid-state thermodynamic integration to off
210    useLiquidThermInt = 0; // default liquid thermodynamic integration to off
211 +  dampingAlpha = 1.5; // default damping parameter in Wolf Electrostatics
212 +  compressDumpFile = 0; // default compressDumpFile set to off
213  
214    have_force_field =  0;
215    have_n_components = 0;
# Line 212 | Line 258 | void Globals::initalize(){
258    have_thermodynamic_integration_lambda = 0;
259    have_thermodynamic_integration_k = 0;
260    have_forcefield_variant = 0;
261 <
261 >  have_forcefield_filename = 0;
262 >  have_dist_spring_constant =  0;
263 >  have_theta_spring_constant = 0;
264 >  have_omega_spring_constant = 0;
265 >  have_surface_tension = 0;
266 >  have_print_pressure_tensor = 0;
267 >  have_electro_sum_method = 0;
268 >  have_damping_alpha = 0;
269 >  have_cutoff_policy = 0;
270 >  have_compress_dumpfile = 0;
271   }
272  
273   int Globals::newComponent( event* the_event ){
# Line 360 | Line 415 | int Globals::globalAssign( event* the_event ){
415    char err[300];
416    
417    token = 0;
418 <  key = hash( lhs );
419 <  if( command_table[key] != NULL ) token = command_table[key]->match( lhs );
418 >
419 >  CommandMapType::iterator iter;
420 >  std::string keyword(lhs);
421 >  iter = command_table.find(keyword);
422 >  if (iter != command_table.end()) {
423 >    token = iter->second;
424 >  }
425    
426    if( token ){
427      
# Line 1038 | Line 1098 | int Globals::globalAssign( event* the_event ){
1098        return 0;
1099        break;
1100  
1041    case G_USERF:
1042      if( the_type == STRING ){
1043        
1044        if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) useRF = 1;
1045        else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) useRF = 0;
1046        else{
1047          the_event->err_msg =
1048            strdup( "Error in parsing meta-data file!\n\tuseReactionField was not \"true\" or \"false\".\n" );
1049          return 0;
1050        }
1051        return 1;
1052      }
1053      
1054      the_event->err_msg =
1055        strdup( "Error in parsing meta-data file!\n\tuseReactionField was not \"true\" or \"false\".\n" );
1056      return 0;
1057      break;
1058
1101      case G_TARGETPRESSURE:
1102        switch( the_type ){
1103          
# Line 1205 | Line 1247 | int Globals::globalAssign( event* the_event ){
1247        switch( the_type ){
1248          
1249        case STRING:
1250 <   strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval);
1250 >        strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval);
1251  
1252 <   for(int i = 0; zconsForcePolicy[i] != '\0'; i++)
1253 <        {
1254 <      zconsForcePolicy[i] = toupper(zconsForcePolicy[i]);
1255 <   }
1252 >        for(int i = 0; zconsForcePolicy[i] != '\0'; i++)
1253 >          {
1254 >            zconsForcePolicy[i] = toupper(zconsForcePolicy[i]);
1255 >          }
1256          have_zcons_force_policy = 1;
1257 <   return 1;
1257 >        return 1;
1258          break;
1259          
1260        case DOUBLE:
# Line 1389 | Line 1431 | int Globals::globalAssign( event* the_event ){
1431  
1432        case STRING:
1433          the_event->err_msg =
1434 <          strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not a double or int.\n" );
1434 >          strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an int.\n" );
1435          return 1;
1436          break;
1437          
1438        case DOUBLE:
1439 <        minimizer_writefrq= the_event->evt.asmt.rhs.dval;
1440 <        have_minimizer_writefrq = 1;
1439 >        the_event->err_msg =
1440 >          strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an  int.\n" );
1441          return 1;
1442          break;
1443          
# Line 1505 | Line 1547 | int Globals::globalAssign( event* the_event ){
1547  
1548        case STRING:
1549          the_event->err_msg =
1550 <          strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not a double or int.\n" );
1550 >          strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" );
1551          return 1;
1552          break;
1553          
1554        case DOUBLE:
1555 <        minimizer_ls_maxiteration = the_event->evt.asmt.rhs.dval;
1556 <        have_minimizer_ls_maxiteration = 1;
1555 >        the_event->err_msg =
1556 >          strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" );
1557          return 1;
1558          break;
1559          
# Line 1563 | Line 1605 | int Globals::globalAssign( event* the_event ){
1605        switch( the_type ){
1606          
1607        case STRING:
1608 <   the_event->err_msg =
1608 >        the_event->err_msg =
1609            strdup( "Error in parsing meta-data file!\n\tseed is not a string.\n" );
1610          return 0;
1611 <   return 0;
1611 >        return 0;
1612          break;
1613          
1614        case DOUBLE:
1615 <   have_seed = 1;
1616 <   seed = (int)the_event->evt.asmt.rhs.dval;
1615 >        have_seed = 1;
1616 >        seed = (int)the_event->evt.asmt.rhs.dval;
1617          return 1;
1618          break;
1619          
1620        case INT:
1621 <   have_seed = 1;
1622 <   seed =  the_event->evt.asmt.rhs.ival ;
1621 >        have_seed = 1;
1622 >        seed =  the_event->evt.asmt.rhs.ival ;
1623          return 1;
1624          break;
1625          
# Line 1681 | Line 1723 | int Globals::globalAssign( event* the_event ){
1723          return 0;
1724          break;
1725        }
1726 <      break;      
1726 >      break;  
1727 >  
1728      case G_FORCEFIELD_VARIANT:
1729        if( the_type == STRING ){
1730          strcpy( forcefield_variant, the_event->evt.asmt.rhs.sval );
# Line 1694 | Line 1737 | int Globals::globalAssign( event* the_event ){
1737        return 0;
1738        break;      
1739        // add more token cases here.      
1740 +
1741 +    case G_FORCEFIELD_FILENAME:
1742 +      if( the_type == STRING ){
1743 +        strcpy( forcefield_filename, the_event->evt.asmt.rhs.sval );
1744 +        have_forcefield_filename = 1;
1745 +        return 1;
1746 +      }
1747 +      
1748 +      the_event->err_msg =
1749 +        strdup( "Error in parsing meta-data file!\n\tforceFieldFileName was not a string assignment.\n" );
1750 +      return 0;
1751 +      break;      
1752 +
1753 +    case G_THERM_INT_DIST_SPRING:
1754 +      switch( the_type ){
1755 +        
1756 +      case STRING:
1757 +        the_event->err_msg =
1758 +          strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst is not a double or int.\n" );
1759 +        return 1;
1760 +        break;
1761 +        
1762 +      case DOUBLE:
1763 +        therm_int_dist_spring = the_event->evt.asmt.rhs.dval;
1764 +        have_dist_spring_constant = 1;
1765 +        return 1;
1766 +        break;
1767 +        
1768 +      case INT:
1769 +        therm_int_dist_spring = (double)the_event->evt.asmt.rhs.dval;
1770 +        have_dist_spring_constant = 1;
1771 +        return 1;
1772 +        break;
1773 +        
1774 +      default:
1775 +        the_event->err_msg =
1776 +          strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst unrecognized.\n" );
1777 +        return 0;
1778 +        break;
1779 +      }
1780 +      break;  
1781 +
1782 +    case G_THERM_INT_THETA_SPRING:
1783 +      switch( the_type ){
1784 +        
1785 +      case STRING:
1786 +        the_event->err_msg =
1787 +          strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst is not a double or int.\n" );
1788 +        return 1;
1789 +        break;
1790 +        
1791 +      case DOUBLE:
1792 +        therm_int_theta_spring = the_event->evt.asmt.rhs.dval;
1793 +        have_theta_spring_constant = 1;
1794 +        return 1;
1795 +        break;
1796 +        
1797 +      case INT:
1798 +        therm_int_theta_spring = (double)the_event->evt.asmt.rhs.dval;
1799 +        have_theta_spring_constant = 1;
1800 +        return 1;
1801 +        break;
1802 +        
1803 +      default:
1804 +        the_event->err_msg =
1805 +          strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst unrecognized.\n" );
1806 +        return 0;
1807 +        break;
1808 +      }
1809 +      break;
1810 +
1811 +    case G_THERM_INT_OMEGA_SPRING:
1812 +      switch( the_type ){
1813 +        
1814 +      case STRING:
1815 +        the_event->err_msg =
1816 +          strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst is not a double or int.\n" );
1817 +        return 1;
1818 +        break;
1819 +        
1820 +      case DOUBLE:
1821 +        therm_int_omega_spring = the_event->evt.asmt.rhs.dval;
1822 +        have_omega_spring_constant = 1;
1823 +        return 1;
1824 +        break;
1825 +        
1826 +      case INT:
1827 +        therm_int_omega_spring = (double)the_event->evt.asmt.rhs.dval;
1828 +        have_omega_spring_constant = 1;
1829 +        return 1;
1830 +        break;
1831 +        
1832 +      default:
1833 +        the_event->err_msg =
1834 +          strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst unrecognized.\n" );
1835 +        return 0;
1836 +        break;
1837 +      }
1838 +      break;  
1839 +
1840 +    case G_SURFACETENSION:
1841 +        switch( the_type ){
1842 +      
1843 +        case STRING:
1844 +          the_event->err_msg =
1845 +            strdup( "Error in parsing meta-data file!\n\tsurfaceTension is not a double or int.\n" );
1846 +          return 1;
1847 +          break;
1848 +          
1849 +        case DOUBLE:
1850 +          surface_tension= the_event->evt.asmt.rhs.dval;
1851 +          have_surface_tension = 1;
1852 +          return 1;
1853 +          break;
1854 +          
1855 +        case INT:
1856 +          surface_tension = (double)the_event->evt.asmt.rhs.dval;
1857 +          have_surface_tension = 1;
1858 +          return 1;
1859 +          break;
1860 +          
1861 +        default:
1862 +          the_event->err_msg =
1863 +            strdup( "Error in parsing meta-data file!\n\tsurfaceTension unrecognized.\n" );
1864 +          return 0;
1865 +          break;
1866 +        }
1867 +        break;
1868 +
1869 +    case G_PRINTPRESSURETENSOR:
1870 +      if( the_type == STRING ){
1871 +        
1872 +        if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) {
1873 +            have_print_pressure_tensor= 1;
1874 +            print_pressure_tensor = 1;
1875 +        } else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) {
1876 +            have_print_pressure_tensor= 1;
1877 +            print_pressure_tensor = 0;
1878 +        } else{
1879 +          the_event->err_msg =
1880 +            strdup( "Error in parsing meta-data file!\n\tprintPressureTensor was not \"true\" or \"false\".\n" );
1881 +          return 0;
1882 +        }
1883 +        return 1;
1884 +          }
1885 +          
1886 +          the_event->err_msg =
1887 +        strdup( "Error in parsing meta-data file!\n\tprintPressureTensor was not \"true\" or \"false\".\n" );
1888 +          return 0;
1889 +          break;
1890 +
1891 +    case G_COMPRESSDUMPFILE:
1892 +       if( the_type == STRING ){
1893 +          
1894 +          if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) {
1895 +             have_compress_dumpfile = 1;
1896 +             compressDumpFile = 1;
1897 +          } else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) {
1898 +             have_compress_dumpfile= 1;
1899 +             compressDumpFile = 0;
1900 +          } else{
1901 +             the_event->err_msg =
1902 +             strdup( "Error in parsing meta-data file!\n\tcompressDumpFile was not \"true\" or \"false\".\n" );
1903 +             return 0;
1904 +          }
1905 +          return 1;
1906 +       }
1907 +      
1908 +       the_event->err_msg =
1909 +       strdup( "Error in parsing meta-data file!\n\tcompressDumpFile was not \"true\" or \"false\".\n" );
1910 +       return 0;
1911 +       break;
1912 +      
1913 +      
1914 +    case G_ELECTRO_SUM_METHOD:
1915 +      switch( the_type ){
1916 +        
1917 +      case STRING:
1918 +        strcpy(electrostaticSummationMethod, the_event->evt.asmt.rhs.sval);
1919 +
1920 +        for(int i = 0; electrostaticSummationMethod[i] != '\0'; i++)
1921 +          {
1922 +            electrostaticSummationMethod[i] = toupper(electrostaticSummationMethod[i]);
1923 +          }
1924 +        have_electro_sum_method = 1;
1925 +        return 1;
1926 +        break;
1927 +        
1928 +      case DOUBLE:
1929 +        the_event->err_msg =
1930 +          strdup( "Error in parsing meta-data file!\n\telectrostaticSummationMethod should be a string!\n" );
1931 +        return 0;
1932 +        break;
1933 +        
1934 +      case INT:
1935 +        the_event->err_msg =
1936 +          strdup( "Error in parsing meta-data file!\n\telectrostaticSummationMethod should be a string!\n" );
1937 +        return 0;
1938 +        break;
1939 +        
1940 +      default:
1941 +        the_event->err_msg =
1942 +          strdup( "Error in parsing meta-data file!\n\telectrostaticSummationMethod unrecognized.\n" );
1943 +        return 0;
1944 +        break;
1945 +      }
1946 +      break;
1947 +
1948 +    case G_DAMPING_ALPHA:
1949 +      switch( the_type ){
1950 +        
1951 +      case STRING:
1952 +        the_event->err_msg =
1953 +          strdup( "Error in parsing meta-data file!\n\tdampingAlpha is not a double or int.\n" );
1954 +        return 1;
1955 +        break;
1956 +        
1957 +      case DOUBLE:
1958 +        dampingAlpha = the_event->evt.asmt.rhs.dval;
1959 +        have_damping_alpha = 1;
1960 +        return 1;
1961 +        break;
1962 +        
1963 +      case INT:
1964 +        dampingAlpha = (double)the_event->evt.asmt.rhs.dval;
1965 +        have_damping_alpha = 1;
1966 +        return 1;
1967 +        break;
1968 +        
1969 +      default:
1970 +        the_event->err_msg =
1971 +          strdup( "Error in parsing meta-data file!\n\tdampingAlpha unrecognized.\n" );
1972 +        return 0;
1973 +        break;
1974 +      }
1975 +      break;  
1976 +
1977 +    case G_CUTOFFPOLICY:
1978 +      switch( the_type ){
1979 +        
1980 +      case STRING:
1981 +        strcpy(cutoffPolicy, the_event->evt.asmt.rhs.sval);
1982 +
1983 +        for(int i = 0; cutoffPolicy[i] != '\0'; i++)
1984 +          {
1985 +            cutoffPolicy[i] = toupper(cutoffPolicy[i]);
1986 +          }
1987 +        have_cutoff_policy = 1;
1988 +        return 1;
1989 +        break;
1990 +        
1991 +      case DOUBLE:
1992 +        the_event->err_msg =
1993 +          strdup( "Error in parsing meta-data file!\n\tcutoffPolicy should be a string!\n" );
1994 +        return 0;
1995 +        break;
1996 +        
1997 +      case INT:
1998 +        the_event->err_msg =
1999 +          strdup( "Error in parsing meta-data file!\n\tcutoffPolicy should be a string!\n" );
2000 +        return 0;
2001 +        break;
2002 +        
2003 +      default:
2004 +        the_event->err_msg =
2005 +          strdup( "Error in parsing meta-data file!\n\tcutoffPolicy unrecognized.\n" );
2006 +        return 0;
2007 +        break;
2008 +      }
2009 +      break;
2010 +
2011 +      
2012 +      // add more token cases here.      
2013      }
2014    }
2015    
# Line 1784 | Line 2100 | int Globals::hash( char* text ){
2100    return 1;
2101   }
2102  
1787 int Globals::hash( char* text ){
1788
1789  register unsigned short int i = 0; // loop counter
1790  int key = 0; // the hash key
1791  
1792  while( text[i] != '\0' ){
1793    
1794    key = ( ( key << hash_shift ) + text[i] ) % hash_size;
1795    
1796    i++;
1797  }
1798  
1799  if( key < 0 ){
1800
1801    // if the key is less than zero, we've had an overflow error
1802
1803    sprintf( painCave.errMsg,
1804             "There has been an overflow error in the Globals' hash key.");
1805    painCave.isFatal = 1;
1806    simError();
1807 #ifdef IS_MPI
1808    if( painCave.isEventLoop ){
1809      if( worldRank == 0 ) mpiInterfaceExit();
1810    }
1811 #endif //is_mpi
1812  }
1813  
1814  return key;
1815 }
1816
1817 void Globals::addHash( char* text, int token ){
1818
1819  int key;
1820  LinkedCommand* the_element;
1821
1822  the_element = new LinkedCommand;
1823  the_element->setValues( text, token );
1824
1825  key = hash( text );
1826
1827  the_element->setNext( command_table[key] );
1828  command_table[key] = the_element;
1829 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines