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 |
112 |
|
#define G_THERM_INT_LAMBDA 50 |
113 |
|
#define G_THERM_INT_K 51 |
114 |
|
#define G_FORCEFIELD_VARIANT 52 |
115 |
+ |
#define G_FORCEFIELD_FILENAME 53 |
116 |
+ |
#define G_THERM_INT_DIST_SPRING 54 |
117 |
+ |
#define G_THERM_INT_THETA_SPRING 55 |
118 |
+ |
#define G_THERM_INT_OMEGA_SPRING 56 |
119 |
+ |
#define G_SURFACETENSION 57 |
120 |
|
|
121 |
|
Globals::Globals(){ |
122 |
|
initalize(); |
124 |
|
|
125 |
|
Globals::~Globals(){ |
126 |
|
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 |
– |
|
127 |
|
if( components != NULL ){ |
128 |
|
for( i=0; i<n_components; i++ ) delete components[i]; |
129 |
|
delete[] components; |
133 |
|
void Globals::initalize(){ |
134 |
|
int i; |
135 |
|
|
96 |
– |
hash_size = 23; |
97 |
– |
hash_shift = 4; |
98 |
– |
|
136 |
|
components = NULL; |
137 |
|
|
138 |
< |
command_table = new LinkedCommand*[hash_size]; |
139 |
< |
for( i=0; i<hash_size; i++ ) command_table[i] = NULL; |
140 |
< |
|
141 |
< |
addHash( "forceField", G_FORCEFIELD ); |
142 |
< |
addHash( "nComponents", G_NCOMPONENTS ); |
143 |
< |
addHash( "targetTemp", G_TARGETTEMP ); |
144 |
< |
addHash( "ensemble", G_ENSEMBLE ); |
145 |
< |
|
146 |
< |
addHash( "dt", G_DT ); |
147 |
< |
addHash( "runTime", G_RUNTIME ); |
148 |
< |
|
149 |
< |
addHash( "initialConfig", G_INITIALCONFIG ); |
150 |
< |
addHash( "finalConfig", G_FINALCONFIG ); |
151 |
< |
addHash( "nMol", G_NMOL ); |
152 |
< |
addHash( "density", G_DENSITY ); |
153 |
< |
addHash( "box", G_BOX ); |
154 |
< |
addHash( "boxX", G_BOXX ); |
155 |
< |
addHash( "boxY", G_BOXY ); |
156 |
< |
addHash( "boxZ", G_BOXZ ); |
157 |
< |
addHash( "sampleTime", G_SAMPLETIME ); |
158 |
< |
addHash( "resetTime", G_RESETTIME ); |
159 |
< |
addHash( "statusTime", G_STATUSTIME ); |
160 |
< |
addHash( "cutoffRadius", G_RCUT ); |
161 |
< |
addHash( "switchingRadius", G_RSW ); |
162 |
< |
addHash( "dielectric", G_DIELECTRIC ); |
163 |
< |
addHash( "tempSet", G_TEMPSET ); |
164 |
< |
addHash( "thermalTime", G_THERMALTIME ); |
165 |
< |
addHash( "mixingRule", G_MIXINGRULE); |
166 |
< |
addHash( "usePeriodicBoundaryConditions", G_USEPBC); |
167 |
< |
addHash( "useReactionField", G_USERF ); |
168 |
< |
addHash( "targetPressure", G_TARGETPRESSURE); |
169 |
< |
addHash( "tauThermostat", G_TAUTHERMOSTAT); |
170 |
< |
addHash( "tauBarostat", G_TAUBAROSTAT); |
171 |
< |
addHash( "zconsTime", G_ZCONSTIME); |
172 |
< |
addHash( "nZconstraints", G_NZCONSTRAINTS); |
173 |
< |
addHash( "zconsTol", G_ZCONSTOL); |
174 |
< |
addHash( "zconsForcePolicy", G_ZCONSFORCEPOLICY); |
175 |
< |
addHash( "seed", G_SEED); |
176 |
< |
addHash( "useInitialTime", G_USEINITTIME); |
177 |
< |
addHash( "useInitialExtendedSystemState", G_USEINIT_XS_STATE); |
178 |
< |
addHash( "orthoBoxTolerance", G_ORTHOBOXTOLERANCE); |
179 |
< |
addHash( "minimizer", G_MINIMIZER); |
180 |
< |
addHash( "minimizerMaxIter", G_MIN_MAXITER); |
181 |
< |
addHash( "minimizerWriteFrq", G_MIN_WRITEFRQ); |
182 |
< |
addHash( "minimizerStepSize", G_MIN_STEPSIZE); |
183 |
< |
addHash( "minimizerFTol", G_MIN_FTOL); |
184 |
< |
addHash( "minimizerGTol", G_MIN_GTOL); |
185 |
< |
addHash( "minimizerLSTol", G_MIN_LSTOL); |
186 |
< |
addHash( "minimizerLSMaxIter", G_MIN_LSMAXITER); |
187 |
< |
addHash( "zconsGap", G_ZCONSGAP); |
188 |
< |
addHash( "zconsFixtime", G_ZCONSFIXTIME); |
189 |
< |
addHash( "zconsUsingSMD", G_ZCONSUSINGSMD); |
190 |
< |
addHash( "useSolidThermInt", G_USE_SOLID_THERM_INT); |
191 |
< |
addHash( "useLiquidThermInt", G_USE_LIQUID_THERM_INT); |
192 |
< |
addHash( "thermodynamicIntegrationLambda", G_THERM_INT_LAMBDA); |
193 |
< |
addHash( "thermodynamicIntegrationK", G_THERM_INT_K); |
194 |
< |
addHash( "forceFieldVariant", G_FORCEFIELD_VARIANT); |
138 |
> |
command_table.insert(CommandMapType::value_type("forceField", G_FORCEFIELD)); |
139 |
> |
command_table.insert(CommandMapType::value_type("nComponents", G_NCOMPONENTS)); |
140 |
> |
command_table.insert(CommandMapType::value_type("targetTemp", G_TARGETTEMP)); |
141 |
> |
command_table.insert(CommandMapType::value_type("ensemble", G_ENSEMBLE)); |
142 |
> |
command_table.insert(CommandMapType::value_type("dt", G_DT)); |
143 |
> |
command_table.insert(CommandMapType::value_type("runTime", G_RUNTIME)); |
144 |
> |
command_table.insert(CommandMapType::value_type("initialConfig", G_INITIALCONFIG)); |
145 |
> |
command_table.insert(CommandMapType::value_type("finalConfig", G_FINALCONFIG)); |
146 |
> |
command_table.insert(CommandMapType::value_type("nMol", G_NMOL)); |
147 |
> |
command_table.insert(CommandMapType::value_type("density", G_DENSITY)); |
148 |
> |
command_table.insert(CommandMapType::value_type("box", G_BOX)); |
149 |
> |
command_table.insert(CommandMapType::value_type("boxX", G_BOXX)); |
150 |
> |
command_table.insert(CommandMapType::value_type("boxY", G_BOXY)); |
151 |
> |
command_table.insert(CommandMapType::value_type("boxZ", G_BOXZ)); |
152 |
> |
command_table.insert(CommandMapType::value_type("sampleTime", G_SAMPLETIME)); |
153 |
> |
command_table.insert(CommandMapType::value_type("resetTime", G_RESETTIME)); |
154 |
> |
command_table.insert(CommandMapType::value_type("statusTime", G_STATUSTIME)); |
155 |
> |
command_table.insert(CommandMapType::value_type("cutoffRadius", G_RCUT)); |
156 |
> |
command_table.insert(CommandMapType::value_type("switchingRadius", G_RSW)); |
157 |
> |
command_table.insert(CommandMapType::value_type("dielectric", G_DIELECTRIC)); |
158 |
> |
command_table.insert(CommandMapType::value_type("tempSet", G_TEMPSET)); |
159 |
> |
command_table.insert(CommandMapType::value_type("thermalTime", G_THERMALTIME)); |
160 |
> |
command_table.insert(CommandMapType::value_type("mixingRule", G_MIXINGRULE)); |
161 |
> |
command_table.insert(CommandMapType::value_type("usePeriodicBoundaryConditions", G_USEPBC)); |
162 |
> |
command_table.insert(CommandMapType::value_type("useReactionField", G_USERF)); |
163 |
> |
command_table.insert(CommandMapType::value_type("targetPressure", G_TARGETPRESSURE)); |
164 |
> |
command_table.insert(CommandMapType::value_type("tauThermostat", G_TAUTHERMOSTAT)); |
165 |
> |
command_table.insert(CommandMapType::value_type("tauBarostat", G_TAUBAROSTAT)); |
166 |
> |
command_table.insert(CommandMapType::value_type("zconsTime", G_ZCONSTIME)); |
167 |
> |
command_table.insert(CommandMapType::value_type("nZconstraints", G_NZCONSTRAINTS)); |
168 |
> |
command_table.insert(CommandMapType::value_type("zconsTol", G_ZCONSTOL)); |
169 |
> |
command_table.insert(CommandMapType::value_type("zconsForcePolicy", G_ZCONSFORCEPOLICY)); |
170 |
> |
command_table.insert(CommandMapType::value_type("seed", G_SEED)); |
171 |
> |
command_table.insert(CommandMapType::value_type("useInitialTime", G_USEINITTIME)); |
172 |
> |
command_table.insert(CommandMapType::value_type("useInitialExtendedSystemState", G_USEINIT_XS_STATE)); |
173 |
> |
command_table.insert(CommandMapType::value_type("orthoBoxTolerance", G_ORTHOBOXTOLERANCE)); |
174 |
> |
command_table.insert(CommandMapType::value_type("minimizer", G_MINIMIZER)); |
175 |
> |
command_table.insert(CommandMapType::value_type("minimizerMaxIter", G_MIN_MAXITER)); |
176 |
> |
command_table.insert(CommandMapType::value_type("minimizerWriteFrq", G_MIN_WRITEFRQ)); |
177 |
> |
command_table.insert(CommandMapType::value_type("minimizerStepSize", G_MIN_STEPSIZE)); |
178 |
> |
command_table.insert(CommandMapType::value_type("minimizerFTol", G_MIN_FTOL)); |
179 |
> |
command_table.insert(CommandMapType::value_type("minimizerGTol", G_MIN_GTOL)); |
180 |
> |
command_table.insert(CommandMapType::value_type("minimizerLSTol", G_MIN_LSTOL)); |
181 |
> |
command_table.insert(CommandMapType::value_type("minimizerLSMaxIter", G_MIN_LSMAXITER)); |
182 |
> |
command_table.insert(CommandMapType::value_type("zconsGap", G_ZCONSGAP)); |
183 |
> |
command_table.insert(CommandMapType::value_type("zconsFixtime", G_ZCONSFIXTIME)); |
184 |
> |
command_table.insert(CommandMapType::value_type("zconsUsingSMD", G_ZCONSUSINGSMD)); |
185 |
> |
command_table.insert(CommandMapType::value_type("useSolidThermInt", G_USE_SOLID_THERM_INT)); |
186 |
> |
command_table.insert(CommandMapType::value_type("useLiquidThermInt", G_USE_LIQUID_THERM_INT)); |
187 |
> |
command_table.insert(CommandMapType::value_type("thermodynamicIntegrationLambda", G_THERM_INT_LAMBDA)); |
188 |
> |
command_table.insert(CommandMapType::value_type("thermodynamicIntegrationK", G_THERM_INT_K)); |
189 |
> |
command_table.insert(CommandMapType::value_type("forceFieldVariant", G_FORCEFIELD_VARIANT)); |
190 |
> |
command_table.insert(CommandMapType::value_type("forceFieldFileName", G_FORCEFIELD_FILENAME)); |
191 |
> |
command_table.insert(CommandMapType::value_type("thermIntDistSpringConst", G_THERM_INT_DIST_SPRING)); |
192 |
> |
command_table.insert(CommandMapType::value_type("thermIntThetaSpringConst", G_THERM_INT_THETA_SPRING)); |
193 |
> |
command_table.insert(CommandMapType::value_type("thermIntOmegaSpringConst", G_THERM_INT_OMEGA_SPRING)); |
194 |
> |
command_table.insert(CommandMapType::value_type("surfaceTension", G_SURFACETENSION)); |
195 |
|
|
196 |
+ |
|
197 |
|
strcpy( mixingRule,"standard"); //default mixing rules to standard. |
198 |
|
usePBC = 1; //default periodic boundry conditions to on |
199 |
|
useRF = 0; |
250 |
|
have_thermodynamic_integration_lambda = 0; |
251 |
|
have_thermodynamic_integration_k = 0; |
252 |
|
have_forcefield_variant = 0; |
253 |
< |
|
253 |
> |
have_forcefield_filename = 0; |
254 |
> |
have_dist_spring_constant = 0; |
255 |
> |
have_theta_spring_constant = 0; |
256 |
> |
have_omega_spring_constant = 0; |
257 |
> |
have_surface_tension = 0; |
258 |
|
} |
259 |
|
|
260 |
|
int Globals::newComponent( event* the_event ){ |
402 |
|
char err[300]; |
403 |
|
|
404 |
|
token = 0; |
405 |
< |
key = hash( lhs ); |
406 |
< |
if( command_table[key] != NULL ) token = command_table[key]->match( lhs ); |
405 |
> |
|
406 |
> |
CommandMapType::iterator iter; |
407 |
> |
std::string keyword(lhs); |
408 |
> |
iter = command_table.find(keyword); |
409 |
> |
if (iter != command_table.end()) { |
410 |
> |
token = iter->second; |
411 |
> |
} |
412 |
|
|
413 |
|
if( token ){ |
414 |
|
|
1252 |
|
switch( the_type ){ |
1253 |
|
|
1254 |
|
case STRING: |
1255 |
< |
strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval); |
1255 |
> |
strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval); |
1256 |
|
|
1257 |
< |
for(int i = 0; zconsForcePolicy[i] != '\0'; i++) |
1258 |
< |
{ |
1259 |
< |
zconsForcePolicy[i] = toupper(zconsForcePolicy[i]); |
1260 |
< |
} |
1257 |
> |
for(int i = 0; zconsForcePolicy[i] != '\0'; i++) |
1258 |
> |
{ |
1259 |
> |
zconsForcePolicy[i] = toupper(zconsForcePolicy[i]); |
1260 |
> |
} |
1261 |
|
have_zcons_force_policy = 1; |
1262 |
< |
return 1; |
1262 |
> |
return 1; |
1263 |
|
break; |
1264 |
|
|
1265 |
|
case DOUBLE: |
1436 |
|
|
1437 |
|
case STRING: |
1438 |
|
the_event->err_msg = |
1439 |
< |
strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not a double or int.\n" ); |
1439 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an int.\n" ); |
1440 |
|
return 1; |
1441 |
|
break; |
1442 |
|
|
1443 |
|
case DOUBLE: |
1444 |
< |
minimizer_writefrq= the_event->evt.asmt.rhs.dval; |
1445 |
< |
have_minimizer_writefrq = 1; |
1444 |
> |
the_event->err_msg = |
1445 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an int.\n" ); |
1446 |
|
return 1; |
1447 |
|
break; |
1448 |
|
|
1552 |
|
|
1553 |
|
case STRING: |
1554 |
|
the_event->err_msg = |
1555 |
< |
strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not a double or int.\n" ); |
1555 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" ); |
1556 |
|
return 1; |
1557 |
|
break; |
1558 |
|
|
1559 |
|
case DOUBLE: |
1560 |
< |
minimizer_ls_maxiteration = the_event->evt.asmt.rhs.dval; |
1561 |
< |
have_minimizer_ls_maxiteration = 1; |
1560 |
> |
the_event->err_msg = |
1561 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" ); |
1562 |
|
return 1; |
1563 |
|
break; |
1564 |
|
|
1610 |
|
switch( the_type ){ |
1611 |
|
|
1612 |
|
case STRING: |
1613 |
< |
the_event->err_msg = |
1613 |
> |
the_event->err_msg = |
1614 |
|
strdup( "Error in parsing meta-data file!\n\tseed is not a string.\n" ); |
1615 |
|
return 0; |
1616 |
< |
return 0; |
1616 |
> |
return 0; |
1617 |
|
break; |
1618 |
|
|
1619 |
|
case DOUBLE: |
1620 |
< |
have_seed = 1; |
1621 |
< |
seed = (int)the_event->evt.asmt.rhs.dval; |
1620 |
> |
have_seed = 1; |
1621 |
> |
seed = (int)the_event->evt.asmt.rhs.dval; |
1622 |
|
return 1; |
1623 |
|
break; |
1624 |
|
|
1625 |
|
case INT: |
1626 |
< |
have_seed = 1; |
1627 |
< |
seed = the_event->evt.asmt.rhs.ival ; |
1626 |
> |
have_seed = 1; |
1627 |
> |
seed = the_event->evt.asmt.rhs.ival ; |
1628 |
|
return 1; |
1629 |
|
break; |
1630 |
|
|
1728 |
|
return 0; |
1729 |
|
break; |
1730 |
|
} |
1731 |
< |
break; |
1731 |
> |
break; |
1732 |
> |
|
1733 |
|
case G_FORCEFIELD_VARIANT: |
1734 |
|
if( the_type == STRING ){ |
1735 |
|
strcpy( forcefield_variant, the_event->evt.asmt.rhs.sval ); |
1741 |
|
strdup( "Error in parsing meta-data file!\n\tforceFieldVariant was not a string assignment.\n" ); |
1742 |
|
return 0; |
1743 |
|
break; |
1744 |
+ |
// add more token cases here. |
1745 |
+ |
|
1746 |
+ |
case G_FORCEFIELD_FILENAME: |
1747 |
+ |
if( the_type == STRING ){ |
1748 |
+ |
strcpy( forcefield_filename, the_event->evt.asmt.rhs.sval ); |
1749 |
+ |
have_forcefield_filename = 1; |
1750 |
+ |
return 1; |
1751 |
+ |
} |
1752 |
+ |
|
1753 |
+ |
the_event->err_msg = |
1754 |
+ |
strdup( "Error in parsing meta-data file!\n\tforceFieldFileName was not a string assignment.\n" ); |
1755 |
+ |
return 0; |
1756 |
+ |
break; |
1757 |
+ |
|
1758 |
+ |
case G_THERM_INT_DIST_SPRING: |
1759 |
+ |
switch( the_type ){ |
1760 |
+ |
|
1761 |
+ |
case STRING: |
1762 |
+ |
the_event->err_msg = |
1763 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst is not a double or int.\n" ); |
1764 |
+ |
return 1; |
1765 |
+ |
break; |
1766 |
+ |
|
1767 |
+ |
case DOUBLE: |
1768 |
+ |
therm_int_dist_spring = the_event->evt.asmt.rhs.dval; |
1769 |
+ |
have_dist_spring_constant = 1; |
1770 |
+ |
return 1; |
1771 |
+ |
break; |
1772 |
+ |
|
1773 |
+ |
case INT: |
1774 |
+ |
therm_int_dist_spring = (double)the_event->evt.asmt.rhs.dval; |
1775 |
+ |
have_dist_spring_constant = 1; |
1776 |
+ |
return 1; |
1777 |
+ |
break; |
1778 |
+ |
|
1779 |
+ |
default: |
1780 |
+ |
the_event->err_msg = |
1781 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst unrecognized.\n" ); |
1782 |
+ |
return 0; |
1783 |
+ |
break; |
1784 |
+ |
} |
1785 |
+ |
break; |
1786 |
+ |
|
1787 |
+ |
case G_THERM_INT_THETA_SPRING: |
1788 |
+ |
switch( the_type ){ |
1789 |
+ |
|
1790 |
+ |
case STRING: |
1791 |
+ |
the_event->err_msg = |
1792 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst is not a double or int.\n" ); |
1793 |
+ |
return 1; |
1794 |
+ |
break; |
1795 |
+ |
|
1796 |
+ |
case DOUBLE: |
1797 |
+ |
therm_int_theta_spring = the_event->evt.asmt.rhs.dval; |
1798 |
+ |
have_theta_spring_constant = 1; |
1799 |
+ |
return 1; |
1800 |
+ |
break; |
1801 |
+ |
|
1802 |
+ |
case INT: |
1803 |
+ |
therm_int_theta_spring = (double)the_event->evt.asmt.rhs.dval; |
1804 |
+ |
have_theta_spring_constant = 1; |
1805 |
+ |
return 1; |
1806 |
+ |
break; |
1807 |
+ |
|
1808 |
+ |
default: |
1809 |
+ |
the_event->err_msg = |
1810 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst unrecognized.\n" ); |
1811 |
+ |
return 0; |
1812 |
+ |
break; |
1813 |
+ |
} |
1814 |
+ |
break; |
1815 |
+ |
|
1816 |
+ |
case G_THERM_INT_OMEGA_SPRING: |
1817 |
+ |
switch( the_type ){ |
1818 |
+ |
|
1819 |
+ |
case STRING: |
1820 |
+ |
the_event->err_msg = |
1821 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst is not a double or int.\n" ); |
1822 |
+ |
return 1; |
1823 |
+ |
break; |
1824 |
+ |
|
1825 |
+ |
case DOUBLE: |
1826 |
+ |
therm_int_omega_spring = the_event->evt.asmt.rhs.dval; |
1827 |
+ |
have_omega_spring_constant = 1; |
1828 |
+ |
return 1; |
1829 |
+ |
break; |
1830 |
+ |
|
1831 |
+ |
case INT: |
1832 |
+ |
therm_int_omega_spring = (double)the_event->evt.asmt.rhs.dval; |
1833 |
+ |
have_omega_spring_constant = 1; |
1834 |
+ |
return 1; |
1835 |
+ |
break; |
1836 |
+ |
|
1837 |
+ |
default: |
1838 |
+ |
the_event->err_msg = |
1839 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst unrecognized.\n" ); |
1840 |
+ |
return 0; |
1841 |
+ |
break; |
1842 |
+ |
} |
1843 |
+ |
break; |
1844 |
+ |
|
1845 |
+ |
case G_SURFACETENSION: |
1846 |
+ |
switch( the_type ){ |
1847 |
+ |
|
1848 |
+ |
case STRING: |
1849 |
+ |
the_event->err_msg = |
1850 |
+ |
strdup( "Error in parsing meta-data file!\n\tsurfaceTension is not a double or int.\n" ); |
1851 |
+ |
return 1; |
1852 |
+ |
break; |
1853 |
+ |
|
1854 |
+ |
case DOUBLE: |
1855 |
+ |
surface_tension= the_event->evt.asmt.rhs.dval; |
1856 |
+ |
have_surface_tension = 1; |
1857 |
+ |
return 1; |
1858 |
+ |
break; |
1859 |
+ |
|
1860 |
+ |
case INT: |
1861 |
+ |
surface_tension = (double)the_event->evt.asmt.rhs.dval; |
1862 |
+ |
have_surface_tension = 1; |
1863 |
+ |
return 1; |
1864 |
+ |
break; |
1865 |
+ |
|
1866 |
+ |
default: |
1867 |
+ |
the_event->err_msg = |
1868 |
+ |
strdup( "Error in parsing meta-data file!\n\tsurfaceTension unrecognized.\n" ); |
1869 |
+ |
return 0; |
1870 |
+ |
break; |
1871 |
+ |
} |
1872 |
+ |
break; |
1873 |
+ |
|
1874 |
+ |
|
1875 |
+ |
|
1876 |
|
// add more token cases here. |
1877 |
|
} |
1878 |
|
} |
1964 |
|
return 1; |
1965 |
|
} |
1966 |
|
|
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 |
– |
} |