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 2372 by tim, Mon Oct 17 00:51:16 2005 UTC vs.
Revision 2420 by chrisfen, Tue Nov 8 13:32:27 2005 UTC

# Line 65 | Line 65
65    parameters_.insert(std::make_pair(std::string(KEYWORD),  &NAME));
66  
67   #define CheckParameter(NAME, CONSTRAINT)                              \
68 <  if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) std::cout <<"Error in parsing " << NAME.getKeyword() << " : "<< (CONSTRAINT).getConstraintDescription() << std::endl; }                
68 >  if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) { sprintf(painCave.errMsg,"Error in checking %s : should be %s\n",NAME.getKeyword().c_str(),(CONSTRAINT).getConstraintDescription().c_str()); painCave.isFatal = 1; painCave.severity = OOPSE_ERROR; simError();} }                
69  
70
70   Globals::Globals(){
71  
72    DefineParameter(ForceField, "forceField")
# Line 122 | Line 121 | Globals::Globals(){
121    DefineOptionalParameter(SurfaceTension, "surfaceTension");
122    DefineOptionalParameter(PrintPressureTensor, "printPressureTensor");
123    DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod");
124 +  DefineOptionalParameter(ElectrostaticScreeningMethod, "electrostaticScreeningMethod");
125    DefineOptionalParameter(CutoffPolicy, "cutoffPolicy");
126  DefineOptionalParameter(StatFileFormat, "statFileFormat");    
126    
127    DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard");
128    DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true);
# Line 135 | Line 134 | Globals::Globals(){
134    DefineOptionalParameterWithDefaultValue(ThermIntDistSpringConst, "thermIntDistSpringConst", 6.0);
135    DefineOptionalParameterWithDefaultValue(ThermIntThetaSpringConst, "thermIntThetaSpringConst", 7.5);
136    DefineOptionalParameterWithDefaultValue(ThermIntOmegaSpringConst, "thermIntOmegaSpringConst", 13.5);
137 <  DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5);
137 >  DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 0.2);
138    DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0);
139 +  DefineOptionalParameterWithDefaultValue(DumpForceVector, "dumpForceVector", 0);
140    DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0);
141 +  DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY");    
142 +
143    
144   }
145  
146   int Globals::globalAssign( event* the_event ){
147 <  
147 >  char errorMessage[65535];
148    int key;
149    interface_assign_type the_type =  the_event->evt.asmt.asmt_type;
150    char* lhs = the_event->evt.asmt.lhs;
# Line 150 | Line 152 | int Globals::globalAssign( event* the_event ){
152  
153    bool result = false;
154  
155 +  /**@todo fix memory leak */  
156    ParamMap::iterator i =parameters_.find(keyword);
157    if (i != parameters_.end()) {
158      if( the_type == STRING ){
159         result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval));
160         if (!result ) {
161 <            sprintf(the_event->err_msg, "Error in parsing %s: expect %s, but get %s.\n", keyword.c_str(), i->second->getParamType(), the_event->evt.asmt.rhs.sval);
161 >            sprintf(errorMessage, "Error in parsing %s: expect %s, but get a string \"%s\".\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.sval);
162 >            the_event->err_msg = strdup(errorMessage);
163         }
164      } else if( the_type == DOUBLE ){
165        result = i->second->setData(the_event->evt.asmt.rhs.dval);
166         if (!result )
167 <         sprintf(the_event->err_msg, "Error in parsing %s: expect %s, but get %f.\n", keyword.c_str(), i->second->getParamType(), the_event->evt.asmt.rhs.dval );
167 >         sprintf(errorMessage, "Error in parsing %s: expect %s, but get a double %f.\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.dval );
168 >       the_event->err_msg = strdup(errorMessage);
169      }      
170      else if (the_type == INT ){
171        result = i->second->setData(the_event->evt.asmt.rhs.ival);
172         if (!result )
173 <         sprintf(the_event->err_msg,  "Error in parsing %s: expect %s, but get %d.\n", keyword.c_str(), i->second->getParamType(), the_event->evt.asmt.rhs.ival );
173 >         sprintf(errorMessage,  "Error in parsing %s: expect %s, but get an int %d.\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.ival );
174 >       the_event->err_msg = strdup(errorMessage);
175        
176      } else {
177 <        sprintf(the_event->err_msg,  "%s is an unrecognized keyword\n", keyword.c_str() );
177 >        sprintf(errorMessage,  "Internal error of parser\n");
178 >        the_event->err_msg = strdup(errorMessage);
179      }
180 +  } else {
181 +    sprintf(errorMessage,  "%s is an unrecognized keyword\n", keyword.c_str() );
182 +    the_event->err_msg = strdup(errorMessage);
183    }
184  
185    if (keyword == "nComponents" && getNComponents() > 0) {
# Line 334 | Line 344 | char* Globals::checkMe( void ){
344    CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || isEqualIgnoreCase(std::string("NVT")) ||
345                                            isEqualIgnoreCase(std::string("NPTi")) || isEqualIgnoreCase(std::string("NPTf"))||
346                                            isEqualIgnoreCase(std::string("NPTxyz")) );
337
347    CheckParameter(Dt, isPositive());
348    CheckParameter(RunTime, isPositive());
349    CheckParameter(InitialConfig, isNotEmpty());
# Line 378 | Line 387 | char* Globals::checkMe( void ){
387    CheckParameter(ThermIntThetaSpringConst, isPositive());
388    CheckParameter(ThermIntOmegaSpringConst, isPositive());
389    CheckParameter(SurfaceTension, isPositive());
390 <  CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("UNDAMPED_WOLF")) || isEqualIgnoreCase(std::string("DAMPED_WOLF")) || isEqualIgnoreCase(std::string("REACTION_FIELD")) );
390 >  CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) || isEqualIgnoreCase(std::string("SHIFTED_FORCE"))  || isEqualIgnoreCase(std::string("REACTION_FIELD")));
391 >  CheckParameter(ElectrostaticScreeningMethod, isEqualIgnoreCase(std::string("UNDAMPED")) || isEqualIgnoreCase(std::string("DAMPED")));
392    CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || isEqualIgnoreCase(std::string("MAX")) || isEqualIgnoreCase(std::string("TRADITIONAL")));
393    //CheckParameter(StatFileFormat,);    
394    //CheckParameter(MixingRule,);
# Line 386 | Line 396 | char* Globals::checkMe( void ){
396    CheckParameter(ThermIntDistSpringConst, isPositive());
397    CheckParameter(ThermIntThetaSpringConst, isPositive());
398    CheckParameter(ThermIntOmegaSpringConst, isPositive());
399 <  CheckParameter(DampingAlpha,isPositive());
399 >  CheckParameter(DampingAlpha,isNonNegative());
400    CheckParameter(SkinThickness, isPositive());
401    
402    //@todo memory leak

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines