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> |
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 |
+ |
#define G_PRINTPREESURETENSOR 58 |
121 |
+ |
#define G_USE_UNDAMPED_WOLF 59 |
122 |
+ |
#define G_USE_DAMPED_WOLF 60 |
123 |
+ |
#define G_CUTOFFPOLICY 61 |
124 |
|
|
125 |
|
Globals::Globals(){ |
126 |
|
initalize(); |
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; |
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("useReactionField", G_USERF)); |
167 |
> |
command_table.insert(CommandMapType::value_type("targetPressure", G_TARGETPRESSURE)); |
168 |
> |
command_table.insert(CommandMapType::value_type("tauThermostat", G_TAUTHERMOSTAT)); |
169 |
> |
command_table.insert(CommandMapType::value_type("tauBarostat", G_TAUBAROSTAT)); |
170 |
> |
command_table.insert(CommandMapType::value_type("zconsTime", G_ZCONSTIME)); |
171 |
> |
command_table.insert(CommandMapType::value_type("nZconstraints", G_NZCONSTRAINTS)); |
172 |
> |
command_table.insert(CommandMapType::value_type("zconsTol", G_ZCONSTOL)); |
173 |
> |
command_table.insert(CommandMapType::value_type("zconsForcePolicy", G_ZCONSFORCEPOLICY)); |
174 |
> |
command_table.insert(CommandMapType::value_type("seed", G_SEED)); |
175 |
> |
command_table.insert(CommandMapType::value_type("useInitialTime", G_USEINITTIME)); |
176 |
> |
command_table.insert(CommandMapType::value_type("useInitialExtendedSystemState", G_USEINIT_XS_STATE)); |
177 |
> |
command_table.insert(CommandMapType::value_type("orthoBoxTolerance", G_ORTHOBOXTOLERANCE)); |
178 |
> |
command_table.insert(CommandMapType::value_type("minimizer", G_MINIMIZER)); |
179 |
> |
command_table.insert(CommandMapType::value_type("minimizerMaxIter", G_MIN_MAXITER)); |
180 |
> |
command_table.insert(CommandMapType::value_type("minimizerWriteFrq", G_MIN_WRITEFRQ)); |
181 |
> |
command_table.insert(CommandMapType::value_type("minimizerStepSize", G_MIN_STEPSIZE)); |
182 |
> |
command_table.insert(CommandMapType::value_type("minimizerFTol", G_MIN_FTOL)); |
183 |
> |
command_table.insert(CommandMapType::value_type("minimizerGTol", G_MIN_GTOL)); |
184 |
> |
command_table.insert(CommandMapType::value_type("minimizerLSTol", G_MIN_LSTOL)); |
185 |
> |
command_table.insert(CommandMapType::value_type("minimizerLSMaxIter", G_MIN_LSMAXITER)); |
186 |
> |
command_table.insert(CommandMapType::value_type("zconsGap", G_ZCONSGAP)); |
187 |
> |
command_table.insert(CommandMapType::value_type("zconsFixtime", G_ZCONSFIXTIME)); |
188 |
> |
command_table.insert(CommandMapType::value_type("zconsUsingSMD", G_ZCONSUSINGSMD)); |
189 |
> |
command_table.insert(CommandMapType::value_type("useSolidThermInt", G_USE_SOLID_THERM_INT)); |
190 |
> |
command_table.insert(CommandMapType::value_type("useLiquidThermInt", G_USE_LIQUID_THERM_INT)); |
191 |
> |
command_table.insert(CommandMapType::value_type("thermodynamicIntegrationLambda", G_THERM_INT_LAMBDA)); |
192 |
> |
command_table.insert(CommandMapType::value_type("thermodynamicIntegrationK", G_THERM_INT_K)); |
193 |
> |
command_table.insert(CommandMapType::value_type("forceFieldVariant", G_FORCEFIELD_VARIANT)); |
194 |
> |
command_table.insert(CommandMapType::value_type("forceFieldFileName", G_FORCEFIELD_FILENAME)); |
195 |
> |
command_table.insert(CommandMapType::value_type("thermIntDistSpringConst", G_THERM_INT_DIST_SPRING)); |
196 |
> |
command_table.insert(CommandMapType::value_type("thermIntThetaSpringConst", G_THERM_INT_THETA_SPRING)); |
197 |
> |
command_table.insert(CommandMapType::value_type("thermIntOmegaSpringConst", G_THERM_INT_OMEGA_SPRING)); |
198 |
> |
command_table.insert(CommandMapType::value_type("surfaceTension", G_SURFACETENSION)); |
199 |
> |
command_table.insert(CommandMapType::value_type("printPressureTensor", G_PRINTPREESURETENSOR)); |
200 |
> |
command_table.insert(CommandMapType::value_type("useUndampedWolf", G_USE_UNDAMPED_WOLF)); |
201 |
> |
command_table.insert(CommandMapType::value_type("useDampedWolf", G_USE_DAMPED_WOLF)); |
202 |
> |
command_table.insert(CommandMapType::value_type("cutoffPolicy", G_CUTOFFPOLICY)); |
203 |
|
|
204 |
|
strcpy( mixingRule,"standard"); //default mixing rules to standard. |
205 |
|
usePBC = 1; //default periodic boundry conditions to on |
257 |
|
have_thermodynamic_integration_lambda = 0; |
258 |
|
have_thermodynamic_integration_k = 0; |
259 |
|
have_forcefield_variant = 0; |
260 |
< |
|
260 |
> |
have_forcefield_filename = 0; |
261 |
> |
have_dist_spring_constant = 0; |
262 |
> |
have_theta_spring_constant = 0; |
263 |
> |
have_omega_spring_constant = 0; |
264 |
> |
have_surface_tension = 0; |
265 |
> |
have_print_pressure_tensor = 0; |
266 |
> |
have_cutoff_policy = 0; |
267 |
|
} |
268 |
|
|
269 |
|
int Globals::newComponent( event* the_event ){ |
411 |
|
char err[300]; |
412 |
|
|
413 |
|
token = 0; |
414 |
< |
key = hash( lhs ); |
415 |
< |
if( command_table[key] != NULL ) token = command_table[key]->match( lhs ); |
414 |
> |
|
415 |
> |
CommandMapType::iterator iter; |
416 |
> |
std::string keyword(lhs); |
417 |
> |
iter = command_table.find(keyword); |
418 |
> |
if (iter != command_table.end()) { |
419 |
> |
token = iter->second; |
420 |
> |
} |
421 |
|
|
422 |
|
if( token ){ |
423 |
|
|
1261 |
|
switch( the_type ){ |
1262 |
|
|
1263 |
|
case STRING: |
1264 |
< |
strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval); |
1265 |
< |
|
1266 |
< |
for(int i = 0; zconsForcePolicy[i] != '\0'; i++) |
1267 |
< |
{ |
1268 |
< |
zconsForcePolicy[i] = toupper(zconsForcePolicy[i]); |
1269 |
< |
} |
1264 |
> |
strcpy(zconsForcePolicy, the_event->evt.asmt.rhs.sval); |
1265 |
> |
|
1266 |
> |
for(int i = 0; zconsForcePolicy[i] != '\0'; i++) |
1267 |
> |
{ |
1268 |
> |
zconsForcePolicy[i] = toupper(zconsForcePolicy[i]); |
1269 |
> |
} |
1270 |
|
have_zcons_force_policy = 1; |
1271 |
< |
return 1; |
1271 |
> |
return 1; |
1272 |
|
break; |
1273 |
|
|
1274 |
|
case DOUBLE: |
1445 |
|
|
1446 |
|
case STRING: |
1447 |
|
the_event->err_msg = |
1448 |
< |
strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not a double or int.\n" ); |
1448 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an int.\n" ); |
1449 |
|
return 1; |
1450 |
|
break; |
1451 |
|
|
1452 |
|
case DOUBLE: |
1453 |
< |
minimizer_writefrq= the_event->evt.asmt.rhs.dval; |
1454 |
< |
have_minimizer_writefrq = 1; |
1453 |
> |
the_event->err_msg = |
1454 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_writefrq is not an int.\n" ); |
1455 |
|
return 1; |
1456 |
|
break; |
1457 |
|
|
1561 |
|
|
1562 |
|
case STRING: |
1563 |
|
the_event->err_msg = |
1564 |
< |
strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not a double or int.\n" ); |
1564 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" ); |
1565 |
|
return 1; |
1566 |
|
break; |
1567 |
|
|
1568 |
|
case DOUBLE: |
1569 |
< |
minimizer_ls_maxiteration = the_event->evt.asmt.rhs.dval; |
1570 |
< |
have_minimizer_ls_maxiteration = 1; |
1569 |
> |
the_event->err_msg = |
1570 |
> |
strdup( "Error in parsing meta-data file!\n\tminimizer_ls_maxiteration is not an int.\n" ); |
1571 |
|
return 1; |
1572 |
|
break; |
1573 |
|
|
1619 |
|
switch( the_type ){ |
1620 |
|
|
1621 |
|
case STRING: |
1622 |
< |
the_event->err_msg = |
1622 |
> |
the_event->err_msg = |
1623 |
|
strdup( "Error in parsing meta-data file!\n\tseed is not a string.\n" ); |
1624 |
|
return 0; |
1625 |
< |
return 0; |
1625 |
> |
return 0; |
1626 |
|
break; |
1627 |
|
|
1628 |
|
case DOUBLE: |
1629 |
< |
have_seed = 1; |
1630 |
< |
seed = (int)the_event->evt.asmt.rhs.dval; |
1629 |
> |
have_seed = 1; |
1630 |
> |
seed = (int)the_event->evt.asmt.rhs.dval; |
1631 |
|
return 1; |
1632 |
|
break; |
1633 |
|
|
1634 |
|
case INT: |
1635 |
< |
have_seed = 1; |
1636 |
< |
seed = the_event->evt.asmt.rhs.ival ; |
1635 |
> |
have_seed = 1; |
1636 |
> |
seed = the_event->evt.asmt.rhs.ival ; |
1637 |
|
return 1; |
1638 |
|
break; |
1639 |
|
|
1737 |
|
return 0; |
1738 |
|
break; |
1739 |
|
} |
1740 |
< |
break; |
1740 |
> |
break; |
1741 |
> |
|
1742 |
|
case G_FORCEFIELD_VARIANT: |
1743 |
|
if( the_type == STRING ){ |
1744 |
|
strcpy( forcefield_variant, the_event->evt.asmt.rhs.sval ); |
1751 |
|
return 0; |
1752 |
|
break; |
1753 |
|
// add more token cases here. |
1754 |
+ |
|
1755 |
+ |
case G_FORCEFIELD_FILENAME: |
1756 |
+ |
if( the_type == STRING ){ |
1757 |
+ |
strcpy( forcefield_filename, the_event->evt.asmt.rhs.sval ); |
1758 |
+ |
have_forcefield_filename = 1; |
1759 |
+ |
return 1; |
1760 |
+ |
} |
1761 |
+ |
|
1762 |
+ |
the_event->err_msg = |
1763 |
+ |
strdup( "Error in parsing meta-data file!\n\tforceFieldFileName was not a string assignment.\n" ); |
1764 |
+ |
return 0; |
1765 |
+ |
break; |
1766 |
+ |
|
1767 |
+ |
case G_THERM_INT_DIST_SPRING: |
1768 |
+ |
switch( the_type ){ |
1769 |
+ |
|
1770 |
+ |
case STRING: |
1771 |
+ |
the_event->err_msg = |
1772 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst is not a double or int.\n" ); |
1773 |
+ |
return 1; |
1774 |
+ |
break; |
1775 |
+ |
|
1776 |
+ |
case DOUBLE: |
1777 |
+ |
therm_int_dist_spring = the_event->evt.asmt.rhs.dval; |
1778 |
+ |
have_dist_spring_constant = 1; |
1779 |
+ |
return 1; |
1780 |
+ |
break; |
1781 |
+ |
|
1782 |
+ |
case INT: |
1783 |
+ |
therm_int_dist_spring = (double)the_event->evt.asmt.rhs.dval; |
1784 |
+ |
have_dist_spring_constant = 1; |
1785 |
+ |
return 1; |
1786 |
+ |
break; |
1787 |
+ |
|
1788 |
+ |
default: |
1789 |
+ |
the_event->err_msg = |
1790 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntDistSpringConst unrecognized.\n" ); |
1791 |
+ |
return 0; |
1792 |
+ |
break; |
1793 |
+ |
} |
1794 |
+ |
break; |
1795 |
+ |
|
1796 |
+ |
case G_THERM_INT_THETA_SPRING: |
1797 |
+ |
switch( the_type ){ |
1798 |
+ |
|
1799 |
+ |
case STRING: |
1800 |
+ |
the_event->err_msg = |
1801 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst is not a double or int.\n" ); |
1802 |
+ |
return 1; |
1803 |
+ |
break; |
1804 |
+ |
|
1805 |
+ |
case DOUBLE: |
1806 |
+ |
therm_int_theta_spring = the_event->evt.asmt.rhs.dval; |
1807 |
+ |
have_theta_spring_constant = 1; |
1808 |
+ |
return 1; |
1809 |
+ |
break; |
1810 |
+ |
|
1811 |
+ |
case INT: |
1812 |
+ |
therm_int_theta_spring = (double)the_event->evt.asmt.rhs.dval; |
1813 |
+ |
have_theta_spring_constant = 1; |
1814 |
+ |
return 1; |
1815 |
+ |
break; |
1816 |
+ |
|
1817 |
+ |
default: |
1818 |
+ |
the_event->err_msg = |
1819 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntThetaSpringConst unrecognized.\n" ); |
1820 |
+ |
return 0; |
1821 |
+ |
break; |
1822 |
+ |
} |
1823 |
+ |
break; |
1824 |
+ |
|
1825 |
+ |
case G_THERM_INT_OMEGA_SPRING: |
1826 |
+ |
switch( the_type ){ |
1827 |
+ |
|
1828 |
+ |
case STRING: |
1829 |
+ |
the_event->err_msg = |
1830 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst is not a double or int.\n" ); |
1831 |
+ |
return 1; |
1832 |
+ |
break; |
1833 |
+ |
|
1834 |
+ |
case DOUBLE: |
1835 |
+ |
therm_int_omega_spring = the_event->evt.asmt.rhs.dval; |
1836 |
+ |
have_omega_spring_constant = 1; |
1837 |
+ |
return 1; |
1838 |
+ |
break; |
1839 |
+ |
|
1840 |
+ |
case INT: |
1841 |
+ |
therm_int_omega_spring = (double)the_event->evt.asmt.rhs.dval; |
1842 |
+ |
have_omega_spring_constant = 1; |
1843 |
+ |
return 1; |
1844 |
+ |
break; |
1845 |
+ |
|
1846 |
+ |
default: |
1847 |
+ |
the_event->err_msg = |
1848 |
+ |
strdup( "Error in parsing meta-data file!\n\tthermIntOmegaSpringConst unrecognized.\n" ); |
1849 |
+ |
return 0; |
1850 |
+ |
break; |
1851 |
+ |
} |
1852 |
+ |
break; |
1853 |
+ |
|
1854 |
+ |
case G_SURFACETENSION: |
1855 |
+ |
switch( the_type ){ |
1856 |
+ |
|
1857 |
+ |
case STRING: |
1858 |
+ |
the_event->err_msg = |
1859 |
+ |
strdup( "Error in parsing meta-data file!\n\tsurfaceTension is not a double or int.\n" ); |
1860 |
+ |
return 1; |
1861 |
+ |
break; |
1862 |
+ |
|
1863 |
+ |
case DOUBLE: |
1864 |
+ |
surface_tension= the_event->evt.asmt.rhs.dval; |
1865 |
+ |
have_surface_tension = 1; |
1866 |
+ |
return 1; |
1867 |
+ |
break; |
1868 |
+ |
|
1869 |
+ |
case INT: |
1870 |
+ |
surface_tension = (double)the_event->evt.asmt.rhs.dval; |
1871 |
+ |
have_surface_tension = 1; |
1872 |
+ |
return 1; |
1873 |
+ |
break; |
1874 |
+ |
|
1875 |
+ |
default: |
1876 |
+ |
the_event->err_msg = |
1877 |
+ |
strdup( "Error in parsing meta-data file!\n\tsurfaceTension unrecognized.\n" ); |
1878 |
+ |
return 0; |
1879 |
+ |
break; |
1880 |
+ |
} |
1881 |
+ |
break; |
1882 |
+ |
|
1883 |
+ |
case G_PRINTPREESURETENSOR: |
1884 |
+ |
if( the_type == STRING ){ |
1885 |
+ |
|
1886 |
+ |
if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) { |
1887 |
+ |
have_print_pressure_tensor= 1; |
1888 |
+ |
print_pressure_tensor = 1; |
1889 |
+ |
} else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) { |
1890 |
+ |
have_print_pressure_tensor= 1; |
1891 |
+ |
print_pressure_tensor = 0; |
1892 |
+ |
} else{ |
1893 |
+ |
the_event->err_msg = |
1894 |
+ |
strdup( "Error in parsing meta-data file!\n\tprintPressureTensor was not \"true\" or \"false\".\n" ); |
1895 |
+ |
return 0; |
1896 |
+ |
} |
1897 |
+ |
return 1; |
1898 |
+ |
} |
1899 |
+ |
|
1900 |
+ |
the_event->err_msg = |
1901 |
+ |
strdup( "Error in parsing meta-data file!\n\tprintPressureTensor was not \"true\" or \"false\".\n" ); |
1902 |
+ |
return 0; |
1903 |
+ |
break; |
1904 |
+ |
|
1905 |
+ |
case G_USE_UNDAMPED_WOLF: |
1906 |
+ |
if( the_type == STRING ){ |
1907 |
+ |
|
1908 |
+ |
if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) useUndampedWolf = 1; |
1909 |
+ |
else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) useUndampedWolf = 0; |
1910 |
+ |
else{ |
1911 |
+ |
the_event->err_msg = |
1912 |
+ |
strdup( "Error in parsing meta-data file!\n\tuseUndampedWolf was not \"true\" or \"false\".\n" ); |
1913 |
+ |
return 0; |
1914 |
+ |
} |
1915 |
+ |
return 1; |
1916 |
+ |
} |
1917 |
+ |
|
1918 |
+ |
the_event->err_msg = |
1919 |
+ |
strdup( "Error in parsing meta-data file!\n\tuseUndampedWolf was not \"true\" or \"false\".\n" ); |
1920 |
+ |
return 0; |
1921 |
+ |
break; |
1922 |
+ |
|
1923 |
+ |
case G_USE_DAMPED_WOLF: |
1924 |
+ |
if( the_type == STRING ){ |
1925 |
+ |
|
1926 |
+ |
if( !strcasecmp( "true", the_event->evt.asmt.rhs.sval )) useDampedWolf = 1; |
1927 |
+ |
else if( !strcasecmp( "false", the_event->evt.asmt.rhs.sval )) useDampedWolf = 0; |
1928 |
+ |
else{ |
1929 |
+ |
the_event->err_msg = |
1930 |
+ |
strdup( "Error in parsing meta-data file!\n\tuseDampedWolf was not \"true\" or \"false\".\n" ); |
1931 |
+ |
return 0; |
1932 |
+ |
} |
1933 |
+ |
return 1; |
1934 |
+ |
} |
1935 |
+ |
|
1936 |
+ |
the_event->err_msg = |
1937 |
+ |
strdup( "Error in parsing meta-data file!\n\tuseDampedWolf was not \"true\" or \"false\".\n" ); |
1938 |
+ |
return 0; |
1939 |
+ |
break; |
1940 |
+ |
|
1941 |
+ |
case G_CUTOFFPOLICY: |
1942 |
+ |
switch( the_type ){ |
1943 |
+ |
|
1944 |
+ |
case STRING: |
1945 |
+ |
strcpy(cutoffPolicy, the_event->evt.asmt.rhs.sval); |
1946 |
+ |
|
1947 |
+ |
for(int i = 0; cutoffPolicy[i] != '\0'; i++) |
1948 |
+ |
{ |
1949 |
+ |
cutoffPolicy[i] = toupper(cutoffPolicy[i]); |
1950 |
+ |
} |
1951 |
+ |
have_cutoff_policy = 1; |
1952 |
+ |
return 1; |
1953 |
+ |
break; |
1954 |
+ |
|
1955 |
+ |
case DOUBLE: |
1956 |
+ |
the_event->err_msg = |
1957 |
+ |
strdup( "Error in parsing meta-data file!\n\tcutoffPolicy should be a string!\n" ); |
1958 |
+ |
return 0; |
1959 |
+ |
break; |
1960 |
+ |
|
1961 |
+ |
case INT: |
1962 |
+ |
the_event->err_msg = |
1963 |
+ |
strdup( "Error in parsing meta-data file!\n\tcutoffPolicy should be a string!\n" ); |
1964 |
+ |
return 0; |
1965 |
+ |
break; |
1966 |
+ |
|
1967 |
+ |
default: |
1968 |
+ |
the_event->err_msg = |
1969 |
+ |
strdup( "Error in parsing meta-data file!\n\tcutoffPolicy unrecognized.\n" ); |
1970 |
+ |
return 0; |
1971 |
+ |
break; |
1972 |
+ |
} |
1973 |
+ |
break; |
1974 |
+ |
|
1975 |
+ |
|
1976 |
+ |
// add more token cases here. |
1977 |
|
} |
1978 |
|
} |
1979 |
|
|
2064 |
|
return 1; |
2065 |
|
} |
2066 |
|
|
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 |
– |
} |