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 2425 by chrisfen, Fri Nov 11 15:22:11 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");    
127 <  
126 >  DefineOptionalParameter(SwitchingFunctionType, "switchingFunctionType");
127    DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard");
128    DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true);
129    DefineOptionalParameterWithDefaultValue(UseInitalTime, "useInitialTime", false);
# 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(OutputForceVector, "outputForceVector", 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 331 | Line 341 | char* Globals::checkMe( void ){
341    CheckParameter(ForceField, isNotEmpty());
342    CheckParameter(NComponents,isPositive());
343    CheckParameter(TargetTemp, isPositive());
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")) );
347 <
344 >  CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) ||
345 >                 isEqualIgnoreCase(std::string("NVT")) ||
346 >                 isEqualIgnoreCase(std::string("NPTi")) ||
347 >                 isEqualIgnoreCase(std::string("NPTf")) ||
348 >                 isEqualIgnoreCase(std::string("NPTxyz")) );
349    CheckParameter(Dt, isPositive());
350    CheckParameter(RunTime, isPositive());
351    CheckParameter(InitialConfig, isNotEmpty());
# Line 360 | Line 371 | char* Globals::checkMe( void ){
371    CheckParameter(ZconsTol, isPositive());
372    //CheckParameter(ZconsForcePolicy,);
373    CheckParameter(Seed, isPositive());
374 <  CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) || isEqualIgnoreCase(std::string("CG")));
374 >  CheckParameter(Minimizer, isEqualIgnoreCase(std::string("SD")) ||
375 >                 isEqualIgnoreCase(std::string("CG")));
376    CheckParameter(MinimizerMaxIter, isPositive());
377    CheckParameter(MinimizerWriteFrq, isPositive());
378    CheckParameter(MinimizerStepSize, isPositive());
# Line 378 | Line 390 | char* Globals::checkMe( void ){
390    CheckParameter(ThermIntThetaSpringConst, isPositive());
391    CheckParameter(ThermIntOmegaSpringConst, isPositive());
392    CheckParameter(SurfaceTension, isPositive());
393 <  CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("UNDAMPED_WOLF")) || isEqualIgnoreCase(std::string("DAMPED_WOLF")) || isEqualIgnoreCase(std::string("REACTION_FIELD")) );
394 <  CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || isEqualIgnoreCase(std::string("MAX")) || isEqualIgnoreCase(std::string("TRADITIONAL")));
393 >  CheckParameter(ElectrostaticSummationMethod,
394 >                 isEqualIgnoreCase(std::string("NONE")) ||
395 >                 isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) ||
396 >                 isEqualIgnoreCase(std::string("SHIFTED_FORCE")) ||
397 >                 isEqualIgnoreCase(std::string("REACTION_FIELD")));
398 >  CheckParameter(ElectrostaticScreeningMethod,
399 >                 isEqualIgnoreCase(std::string("UNDAMPED")) ||
400 >                 isEqualIgnoreCase(std::string("DAMPED")));
401 >  CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) ||
402 >                 isEqualIgnoreCase(std::string("MAX")) ||
403 >                 isEqualIgnoreCase(std::string("TRADITIONAL")));
404 >  CheckParameter(SwitchingFunctionType,
405 >                 isEqualIgnoreCase(std::string("CUBIC")) ||
406 >                 isEqualIgnoreCase(std::string("FIFTH_ORDER_POLYNOMIAL")));
407    //CheckParameter(StatFileFormat,);    
408    //CheckParameter(MixingRule,);
409    CheckParameter(OrthoBoxTolerance, isPositive());  
410    CheckParameter(ThermIntDistSpringConst, isPositive());
411    CheckParameter(ThermIntThetaSpringConst, isPositive());
412    CheckParameter(ThermIntOmegaSpringConst, isPositive());
413 <  CheckParameter(DampingAlpha,isPositive());
413 >  CheckParameter(DampingAlpha,isNonNegative());
414    CheckParameter(SkinThickness, isPositive());
415    
416    //@todo memory leak

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines