Changeset e5c0a1
- Timestamp:
- Aug 6, 2010, 2:01:13 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 822f01
- Parents:
- 2a76b0
- Location:
- src
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/PairCorrelationAction.cpp
r2a76b0 re5c0a1 76 76 ofstream output; 77 77 ofstream binoutput; 78 std::vector< element *> elements;78 std::vector<const element *> elements; 79 79 string type; 80 80 Vector Point; -
src/Actions/AnalysisAction/PointCorrelationAction.cpp
r2a76b0 re5c0a1 77 77 ofstream output; 78 78 ofstream binoutput; 79 std::vector< element *> elements;79 std::vector<const element *> elements; 80 80 string type; 81 81 Vector Point; … … 97 97 cout << "Point to correlate to is " << Point << endl; 98 98 CorrelationToPointMap *correlationmap = NULL; 99 for(std::vector< element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)99 for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter) 100 100 cout << "element is " << (*iter)->getSymbol() << endl; 101 101 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules(); -
src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp
r2a76b0 re5c0a1 78 78 ofstream output; 79 79 ofstream binoutput; 80 std::vector< element *> elements;80 std::vector<const element *> elements; 81 81 string type; 82 82 Vector Point; -
src/Actions/AtomAction/AddAction.cpp
r2a76b0 re5c0a1 52 52 53 53 Action::state_ptr AtomAddAction::performCall() { 54 element * elemental = NULL;54 const element * elemental = NULL; 55 55 Vector position; 56 56 -
src/Actions/AtomAction/ChangeElementAction.cpp
r2a76b0 re5c0a1 50 50 Action::state_ptr AtomChangeElementAction::performCall() { 51 51 atom *first = NULL; 52 element *elemental = NULL;52 const element *elemental = NULL; 53 53 54 54 ValueStorage::getInstance().queryCurrentValue(NAME, elemental); -
src/Actions/MapOfActions.cpp
r2a76b0 re5c0a1 292 292 293 293 // value types for the actions 294 TypeMap["add-atom"] = &typeid( element);294 TypeMap["add-atom"] = &typeid(const element); 295 295 TypeMap["bond-file"] = &typeid(std::string); 296 296 TypeMap["bond-table"] = &typeid(std::string); … … 298 298 TypeMap["center-in-box"] = &typeid(BoxValue); 299 299 TypeMap["change-box"] = &typeid(BoxValue); 300 TypeMap["change-element"] = &typeid( element);300 TypeMap["change-element"] = &typeid(const element); 301 301 TypeMap["change-molname"] = &typeid(std::string); 302 302 TypeMap["convex-envelope"] = &typeid(void); … … 342 342 TypeMap["distances"] = &typeid(VectorValue); 343 343 TypeMap["DoRotate"] = &typeid(bool); 344 TypeMap["element"] = &typeid( element);345 TypeMap["elements"] = &typeid(std::vector< element *>);344 TypeMap["element"] = &typeid(const element); 345 TypeMap["elements"] = &typeid(std::vector<const element *>); 346 346 TypeMap["end-step"] = &typeid(int); 347 347 TypeMap["id-mapping"] = &typeid(bool); … … 380 380 TypeEnumMap[&typeid(atom)] = Atom; 381 381 TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms; 382 TypeEnumMap[&typeid( element)] = Element;383 TypeEnumMap[&typeid(std::vector< element *>)] = ListOfElements;382 TypeEnumMap[&typeid(const element)] = Element; 383 TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements; 384 384 385 385 // default values for any action that needs one (always string!) … … 558 558 } 559 559 560 void MapOfActions::queryCurrentValue(const char * name, c lasselement * &_T) {560 void MapOfActions::queryCurrentValue(const char * name, const element * &_T) { 561 561 int Z = -1; 562 if (typeid( element ) == *TypeMap[name]) {562 if (typeid(const element ) == *TypeMap[name]) { 563 563 if (CurrentValue.find(name) == CurrentValue.end()) 564 564 throw MissingValueException(__FILE__, __LINE__); … … 642 642 } 643 643 644 void MapOfActions::queryCurrentValue(const char * name, std::vector< element *>&_T)644 void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T) 645 645 { 646 646 int Z = -1; 647 element *elemental = NULL;648 if (typeid( std::vector< element *> ) == *TypeMap[name]) {647 const element *elemental = NULL; 648 if (typeid( std::vector<const element *> ) == *TypeMap[name]) { 649 649 if (CurrentValue.find(name) == CurrentValue.end()) 650 650 throw MissingValueException(__FILE__, __LINE__); … … 694 694 } 695 695 696 void MapOfActions::setCurrentValue(const char * name, c lasselement * &_T)697 { 698 if (typeid( element ) == *TypeMap[name]) {696 void MapOfActions::setCurrentValue(const char * name, const element * &_T) 697 { 698 if (typeid(const element ) == *TypeMap[name]) { 699 699 std::ostringstream stream; 700 700 stream << _T->Z; … … 754 754 } 755 755 756 void MapOfActions::setCurrentValue(const char * name, std::vector< element *>&_T)757 { 758 if (typeid( std::vector< element *> ) == *TypeMap[name]) {756 void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T) 757 { 758 if (typeid( std::vector<const element *> ) == *TypeMap[name]) { 759 759 std::ostringstream stream; 760 for (std::vector< element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {760 for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 761 761 stream << (*iter)->Z << " "; 762 762 } -
src/Actions/MapOfActions.hpp
r2a76b0 re5c0a1 163 163 164 164 void queryCurrentValue(const char * name, class atom * &_T); 165 void queryCurrentValue(const char * name, c lasselement * &_T);165 void queryCurrentValue(const char * name, const element * &_T); 166 166 void queryCurrentValue(const char * name, class molecule * &_T); 167 167 void queryCurrentValue(const char * name, class Box &_T); 168 168 void queryCurrentValue(const char * name, class Vector &_T); 169 169 void queryCurrentValue(const char * name, std::vector<atom *>&_T); 170 void queryCurrentValue(const char * name, std::vector< element *>&_T);170 void queryCurrentValue(const char * name, std::vector<const element *>&_T); 171 171 void queryCurrentValue(const char * name, std::vector<molecule *>&_T); 172 172 template<typename T> void queryCurrentValue(const char * name, T &_T) … … 197 197 198 198 void setCurrentValue(const char * name, class atom * &_T); 199 void setCurrentValue(const char * name, c lasselement * &_T);199 void setCurrentValue(const char * name, const element * &_T); 200 200 void setCurrentValue(const char * name, class molecule * &_T); 201 201 void setCurrentValue(const char * name, class Box &_T); 202 202 void setCurrentValue(const char * name, class Vector &_T); 203 203 void setCurrentValue(const char * name, std::vector<atom *>&_T); 204 void setCurrentValue(const char * name, std::vector< element *>&_T);204 void setCurrentValue(const char * name, std::vector<const element *>&_T); 205 205 void setCurrentValue(const char * name, std::vector<molecule *>&_T); 206 206 template<class T> void setCurrentValue(const char * name, T &_T) -
src/Formula.cpp
r2a76b0 re5c0a1 146 146 147 147 bool Formula::hasElement(const string &shorthand) const{ 148 element * element = World::getInstance().getPeriode()->FindElement(shorthand);148 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 149 149 return hasElement(element); 150 150 } … … 167 167 168 168 void Formula::operator+=(const string &shorthand){ 169 element * element = World::getInstance().getPeriode()->FindElement(shorthand);169 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 170 170 operator+=(element); 171 171 } … … 198 198 199 199 void Formula::operator-=(const string &shorthand){ 200 element * element = World::getInstance().getPeriode()->FindElement(shorthand);200 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 201 201 operator-=(element); 202 202 } … … 220 220 221 221 void Formula::addElements(const string &shorthand,unsigned int count){ 222 element * element = World::getInstance().getPeriode()->FindElement(shorthand);222 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 223 223 addElements(element,count); 224 224 } … … 252 252 253 253 const unsigned int Formula::operator[](string shorthand) const{ 254 element * element = World::getInstance().getPeriode()->FindElement(shorthand);254 const element * element = World::getInstance().getPeriode()->FindElement(shorthand); 255 255 return operator[](element); 256 256 } … … 380 380 result_type 381 381 Formula::_iterator<result_type>::operator*(){ 382 element *element = World::getInstance().getPeriode()->FindElement(pos+1);382 const element *element = World::getInstance().getPeriode()->FindElement(pos+1); 383 383 ASSERT(element,"Element with position of iterator not found"); 384 384 return make_pair(element,(*set)[pos]); … … 390 390 // no one can keep this value around, so a static is ok to avoid temporaries 391 391 static value_type value=make_pair(reinterpret_cast<element*>(0),0); // no default constructor for std::pair 392 element *element = World::getInstance().getPeriode()->FindElement(pos+1);392 const element *element = World::getInstance().getPeriode()->FindElement(pos+1); 393 393 ASSERT(element,"Element with position of iterator not found"); 394 394 value = make_pair(element,(*set)[pos]); -
src/UIElements/Dialog.hpp
r2a76b0 re5c0a1 255 255 virtual void setResult(); 256 256 protected: 257 element * tmp;257 const element * tmp; 258 258 }; 259 259 … … 265 265 virtual void setResult(); 266 266 protected: 267 element *temp;268 std::vector< element *> tmp;267 const element *temp; 268 std::vector<const element *> tmp; 269 269 }; 270 270 -
src/UIElements/QT4/QTDialog.cpp
r2a76b0 re5c0a1 818 818 } 819 819 820 ElementQTQueryPipe::ElementQTQueryPipe( element **_content, QTDialog *_dialog, QComboBox *_theBox) :820 ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) : 821 821 content(_content), 822 822 dialog(_dialog), … … 834 834 } 835 835 836 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector< element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :836 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 837 837 content(_content), 838 838 dialog(_dialog), … … 846 846 QVariant data = theBox->itemData(newIndex); 847 847 int idx = data.toInt(); 848 element *elemental = World::getInstance().getPeriode()->FindElement(idx);848 const element *elemental = World::getInstance().getPeriode()->FindElement(idx); 849 849 if(elemental) 850 850 (*content).push_back(elemental); -
src/UIElements/QT4/QTDialog.hpp
r2a76b0 re5c0a1 451 451 Q_OBJECT 452 452 public: 453 ElementQTQueryPipe( element **_content, QTDialog *_dialog, QComboBox *_theBox);453 ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox); 454 454 virtual ~ElementQTQueryPipe(); 455 455 … … 458 458 459 459 private: 460 element **content;460 const element **content; 461 461 QTDialog *dialog; 462 462 QComboBox *theBox; … … 466 466 Q_OBJECT 467 467 public: 468 ElementsQTQueryPipe(std::vector< element *>*_content, QTDialog *_dialog, QComboBox *_theBox);468 ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox); 469 469 virtual ~ElementsQTQueryPipe(); 470 470 … … 473 473 474 474 private: 475 std::vector< element *>*content;475 std::vector<const element *>*content; 476 476 QTDialog *dialog; 477 477 QComboBox *theBox; -
src/UIElements/TextUI/TextDialog.cpp
r2a76b0 re5c0a1 566 566 bool badInput=false; 567 567 bool aborted = false; 568 element * temp = NULL;568 const element * temp = NULL; 569 569 do{ 570 570 badInput = false; -
src/analysis_correlation.cpp
r2a76b0 re5c0a1 32 32 * \return Map of doubles with values the pair of the two atoms. 33 33 */ 34 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements)34 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements) 35 35 { 36 36 Info FunctionInfo(__func__); … … 47 47 48 48 // create all possible pairs of elements 49 set <pair< element *,element *> > PairsOfElements;49 set <pair<const element *,const element *> > PairsOfElements; 50 50 if (elements.size() >= 2) { 51 for (vector< element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)52 for (vector< element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)51 for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) 52 for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) 53 53 if (type1 != type2) { 54 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );54 PairsOfElements.insert( make_pair(*type1,*type2) ); 55 55 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl); 56 56 } 57 57 } else if (elements.size() == 1) { // one to all are valid 58 element *elemental = *elements.begin();59 PairsOfElements.insert( pair< element *, element*>(elemental,(element *)NULL) );60 PairsOfElements.insert( pair< element *, element*>((element *)NULL,elemental) );58 const element *elemental = *elements.begin(); 59 PairsOfElements.insert( pair<const element *,const element*>(elemental,0) ); 60 PairsOfElements.insert( pair<const element *,const element*>(0,elemental) ); 61 61 } else { // all elements valid 62 62 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); … … 73 73 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 74 74 if ((*iter)->getId() < (*runner)->getId()){ 75 for (set <pair< element *,element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)75 for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 76 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 77 77 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node); … … 94 94 * \return Map of doubles with values the pair of the two atoms. 95 95 */ 96 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const int ranges[NDIM] )96 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] ) 97 97 { 98 98 Info FunctionInfo(__func__); … … 114 114 115 115 // create all possible pairs of elements 116 set <pair< element *,element *> > PairsOfElements;116 set <pair<const element *,const element *> > PairsOfElements; 117 117 if (elements.size() >= 2) { 118 for (vector< element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)119 for (vector< element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)118 for (vector<const element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1) 119 for (vector<const element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2) 120 120 if (type1 != type2) { 121 PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );121 PairsOfElements.insert( make_pair(*type1,*type2) ); 122 122 DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << *(*type1) << " and " << *(*type2) << "." << endl); 123 123 } 124 124 } else if (elements.size() == 1) { // one to all are valid 125 element *elemental = *elements.begin();126 PairsOfElements.insert( pair< element *, element*>(elemental,(element *)NULL) );127 PairsOfElements.insert( pair< element *, element*>((element *)NULL,elemental) );125 const element *elemental = *elements.begin(); 126 PairsOfElements.insert( pair<const element *,const element*>(elemental,0) ); 127 PairsOfElements.insert( pair<const element *,const element*>(0,elemental) ); 128 128 } else { // all elements valid 129 129 PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) ); … … 148 148 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 149 149 if ((*iter)->getId() < (*runner)->getId()){ 150 for (set <pair< element *,element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)150 for (set <pair<const element *,const element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 151 151 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 152 152 periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3 … … 177 177 * \return Map of dobules with values as pairs of atom and the vector 178 178 */ 179 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point )179 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point ) 180 180 { 181 181 Info FunctionInfo(__func__); … … 195 195 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 196 196 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 197 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)197 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 198 198 if ((*type == NULL) || ((*iter)->type == *type)) { 199 199 distance = domain.periodicDistance(*(*iter)->node,*point); … … 214 214 * \return Map of dobules with values as pairs of atom and the vector 215 215 */ 216 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point, const int ranges[NDIM] )216 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] ) 217 217 { 218 218 Info FunctionInfo(__func__); … … 236 236 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 237 237 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 238 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)238 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 239 239 if ((*type == NULL) || ((*iter)->type == *type)) { 240 240 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 … … 262 262 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 263 263 */ 264 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )264 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ) 265 265 { 266 266 Info FunctionInfo(__func__); … … 283 283 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 284 284 DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl); 285 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)285 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 286 286 if ((*type == NULL) || ((*iter)->type == *type)) { 287 287 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); … … 308 308 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 309 309 */ 310 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )310 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 311 311 { 312 312 Info FunctionInfo(__func__); … … 334 334 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 335 335 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 336 for (vector< element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)336 for (vector<const element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 337 337 if ((*type == NULL) || ((*iter)->type == *type)) { 338 338 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 -
src/analysis_correlation.hpp
r2a76b0 re5c0a1 46 46 /********************************************** declarations *******************************/ 47 47 48 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements);49 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point );50 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );51 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const int ranges[NDIM] );52 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Vector *point, const int ranges[NDIM] );53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector< element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );48 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements); 49 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point ); 50 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ); 51 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const int ranges[NDIM] ); 52 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Vector *point, const int ranges[NDIM] ); 53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<const element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 54 54 int GetBin ( const double value, const double BinWidth, const double BinStart ); 55 55 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); -
src/periodentafel.cpp
r2a76b0 re5c0a1 34 34 { 35 35 stringstream input(elementsDB,ios_base::in); 36 bool status = LoadElementsDatabase( &input);36 bool status = LoadElementsDatabase(input); 37 37 ASSERT(status, "General element initialization failed"); 38 38 } … … 72 72 * \return iterator to added element 73 73 */ 74 periodentafel::iterator periodentafel::AddElement(element * constpointer)74 periodentafel::iterator periodentafel::AddElement(element * pointer) 75 75 { 76 76 atomicNumber_t Z = pointer->getNumber(); … … 85 85 * \param *pointer element to be removed 86 86 */ 87 size_t periodentafel::RemoveElement( element * constpointer)87 size_t periodentafel::RemoveElement(const element * pointer) 88 88 { 89 89 return RemoveElement(pointer->getNumber()); … … 113 113 * \return pointer to element or NULL if not found 114 114 */ 115 element * constperiodentafel::FindElement(atomicNumber_t Z) const115 const element * periodentafel::FindElement(atomicNumber_t Z) const 116 116 { 117 117 const_iterator res = elements.find(Z); … … 124 124 * \return pointer to element 125 125 */ 126 element * constperiodentafel::FindElement(const string &shorthand) const126 const element * periodentafel::FindElement(const string &shorthand) const 127 127 { 128 128 element *res = 0; … … 139 139 * \return desired element or NULL 140 140 */ 141 element * constperiodentafel::AskElement() const142 { 143 element * walker = NULL;141 const element * periodentafel::AskElement() const 142 { 143 const element * walker = NULL; 144 144 int Z; 145 145 do { … … 154 154 * \return pointer to either present or newly created element 155 155 */ 156 element * constperiodentafel::EnterElement()156 const element * periodentafel::EnterElement() 157 157 { 158 158 atomicNumber_t Z = 0; 159 159 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl); 160 160 cin >> Z; 161 element * constres = FindElement(Z);161 const element *res = FindElement(Z); 162 162 if (!res) { 163 163 // TODO: make this using the constructor … … 179 179 180 180 /******************** Access to iterators ****************************/ 181 periodentafel::const_iterator periodentafel::begin() {181 periodentafel::const_iterator periodentafel::begin() const{ 182 182 return elements.begin(); 183 183 } 184 184 185 periodentafel::const_iterator periodentafel::end() {185 periodentafel::const_iterator periodentafel::end() const{ 186 186 return elements.end(); 187 187 } 188 188 189 periodentafel::reverse_iterator periodentafel::rbegin() {189 periodentafel::reverse_iterator periodentafel::rbegin() const{ 190 190 return reverse_iterator(elements.end()); 191 191 } 192 192 193 periodentafel::reverse_iterator periodentafel::rend() {193 periodentafel::reverse_iterator periodentafel::rend() const{ 194 194 return reverse_iterator(elements.begin()); 195 195 } … … 227 227 if (!input.fail()) 228 228 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl); 229 status = status && LoadElementsDatabase( &input);229 status = status && LoadElementsDatabase(input); 230 230 input.close(); 231 231 input.clear(); … … 286 286 * \return true - parsing successful, false - something went wrong 287 287 */ 288 bool periodentafel::LoadElementsDatabase(istream *input)288 bool periodentafel::LoadElementsDatabase(istream &input) 289 289 { 290 290 bool status = true; 291 int counter = 0; 292 pair< std::map<atomicNumber_t,element*>::iterator, bool > InserterTest; 293 if (!(*input).fail()) { 294 (*input).getline(header1, MAXSTRINGSIZE); 295 (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines 291 string header1tmp,header2tmp; 292 // first parse into a map, so we can revert to old status in case something goes wront 293 map<atomicNumber_t,element*> parsedElements; 294 if (!input.fail()) { 295 getline(input,header1tmp); 296 getline(input,header2tmp); // skip first two header lines 297 cout << "First header: " << header1tmp << endl; 298 cout << "Second header: " << header2tmp << endl; 296 299 DoLog(0) && (Log() << Verbose(0) << "Parsed elements:"); 297 while (! (*input).eof()) {300 while (!input.eof()) { 298 301 element *neues = new element; 299 (*input)>> neues->getName();;300 //(*input) >> ws; 301 (*input)>> neues->getSymbol();302 //(*input) >> ws; 303 (*input)>> neues->period;304 //(*input) >> ws; 305 (*input)>> neues->group;306 //(*input) >> ws; 307 (*input)>> neues->block;308 //(*input) >> ws; 309 (*input)>> neues->Z;310 //(*input) >> ws; 311 (*input)>> neues->mass;312 //(*input) >> ws; 313 (*input)>> neues->CovalentRadius;314 //(*input) >> ws; 315 (*input)>> neues->VanDerWaalsRadius;316 //(*input) >> ws; 317 (*input)>> ws;302 input >> neues->getName();; 303 //(*input) >> ws; 304 input >> neues->getSymbol(); 305 //(*input) >> ws; 306 input >> neues->period; 307 //(*input) >> ws; 308 input >> neues->group; 309 //(*input) >> ws; 310 input >> neues->block; 311 //(*input) >> ws; 312 input >> neues->Z; 313 //(*input) >> ws; 314 input >> neues->mass; 315 //(*input) >> ws; 316 input >> neues->CovalentRadius; 317 //(*input) >> ws; 318 input >> neues->VanDerWaalsRadius; 319 //(*input) >> ws; 320 input >> ws; 318 321 //neues->Output((ofstream *)&cout); 319 322 if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) { 320 if (elements.count(neues->getNumber())) {// if element already present, remove and delete old one (i.e. replace it) 321 //cout << neues->symbol << " is present already." << endl; 322 element * const Elemental = FindElement(neues->getNumber()); 323 ASSERT(Elemental != NULL, "element should be present but is not??"); 324 *Elemental = *neues; 325 delete(neues); 326 neues = Elemental; 327 } else { 328 InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues)); 329 ASSERT(InserterTest.second, "Could not insert new element into periodentafel on LoadElementsDatabase()."); 330 } 323 parsedElements[neues->Z] = neues; 331 324 DoLog(0) && (Log() << Verbose(0) << " " << *neues); 332 counter++;333 325 } else { 334 326 DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl); … … 336 328 delete(neues); 337 329 } 330 // when the input is in failed state, we most likely just read garbage 331 if(input.fail()) { 332 DoeLog(2) && (eLog() << Verbose(2) << "Error parsing elements db." << endl); 333 status = false; 334 break; 335 } 338 336 } 339 337 DoLog(0) && (Log() << Verbose(0) << endl); … … 343 341 } 344 342 345 if ( counter == 0)343 if (!parsedElements.size()) 346 344 status = false; 345 346 if(status){ 347 for(map<atomicNumber_t,element*>::iterator iter=parsedElements.begin(); 348 iter!=parsedElements.end(); 349 ++iter){ 350 if (elements.count(iter->first)) { 351 // if element already present, replace the old one 352 // pointer to old element might still be in use, so we have to replace into the old element 353 *(elements[iter->first])=*iter->second; 354 } 355 else { 356 // no such element in periodentafel... we can just insert 357 elements[iter->first] = iter->second; 358 } 359 } 360 // all went well.. we now copy the header 361 strncpy(header1,header1tmp.c_str(),MAXSTRINGSIZE); 362 header1[MAXSTRINGSIZE-1]=0; 363 strncpy(header2,header2tmp.c_str(),MAXSTRINGSIZE); 364 header2[MAXSTRINGSIZE-1]=0; 365 } 347 366 348 367 return status; -
src/periodentafel.hpp
r2a76b0 re5c0a1 43 43 ~periodentafel(); 44 44 45 iterator AddElement(element * constpointer);46 size_t RemoveElement( element * constpointer);45 iterator AddElement(element * pointer); 46 size_t RemoveElement(const element * pointer); 47 47 size_t RemoveElement(atomicNumber_t); 48 48 void CleanupPeriodtable(); 49 element * constFindElement(atomicNumber_t) const;50 element * constFindElement(const std::string &shorthand) const;51 element * constAskElement() const;52 element * constEnterElement();49 const element * FindElement(atomicNumber_t) const; 50 const element * FindElement(const std::string &shorthand) const; 51 const element * AskElement() const; 52 const element * EnterElement(); 53 53 54 const_iterator begin() ;55 const_iterator end() ;56 reverse_iterator rbegin() ;57 reverse_iterator rend() ;54 const_iterator begin() const; 55 const_iterator end() const; 56 reverse_iterator rbegin() const; 57 reverse_iterator rend() const; 58 58 bool Output(std::ostream * const output) const; 59 59 bool LoadPeriodentafel(const char * const path); … … 62 62 private: 63 63 64 bool LoadElementsDatabase(std::istream *input);64 bool LoadElementsDatabase(std::istream &input); 65 65 bool LoadValenceDatabase(std::istream *input); 66 66 bool LoadOrbitalsDatabase(std::istream *input); -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r2a76b0 re5c0a1 46 46 47 47 // construct element list 48 std::vector< element *> elements;48 std::vector<const element *> elements; 49 49 hydrogen = World::getInstance().getPeriode()->FindElement(1); 50 50 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
r2a76b0 re5c0a1 37 37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 element *hydrogen;39 const element *hydrogen; 40 40 41 41 CorrelationToPointMap *pointmap; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r2a76b0 re5c0a1 45 45 std::vector<molecule *> allMolecules; 46 46 molecule *TestSurfaceMolecule; 47 element *hydrogen;48 element *carbon;49 std::vector< element *> elements;47 const element *hydrogen; 48 const element *carbon; 49 std::vector<const element *> elements; 50 50 51 51 CorrelationToSurfaceMap *surfacemap; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r2a76b0 re5c0a1 49 49 50 50 // construct element list 51 std::vector< element *> elements;51 std::vector<const element *> elements; 52 52 hydrogen = World::getInstance().getPeriode()->FindElement(1); 53 53 CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found"); -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
r2a76b0 re5c0a1 37 37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 element *hydrogen;39 const element *hydrogen; 40 40 41 41 PairCorrelationMap *correlationmap; -
src/unittests/periodentafelTest.cpp
r2a76b0 re5c0a1 11 11 #include <cppunit/extensions/TestFactoryRegistry.h> 12 12 #include <cppunit/ui/text/TestRunner.h> 13 14 #include <sstream> 15 #include <iostream> 13 16 14 17 #include "Helpers/Assert.hpp" … … 67 70 { 68 71 // reload all databases 69 CPPUNIT_ASSERT(tafel->LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)) && "General element initialization failed"); 72 stringstream elementsDBstream(elementsDB,ios_base::in); 73 CPPUNIT_ASSERT(tafel->LoadElementsDatabase(elementsDBstream) && "General element initialization failed"); 70 74 CPPUNIT_ASSERT(tafel->LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)) && "Valence entry of element initialization failed"); 71 75 CPPUNIT_ASSERT(tafel->LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)) && "Orbitals entry of element initialization failed"); -
src/unittests/periodentafelTest.hpp
r2a76b0 re5c0a1 31 31 private: 32 32 33 element *hydrogen;34 element *carbon;33 const element *hydrogen; 34 const element *carbon; 35 35 periodentafel *tafel; 36 36
Note:
See TracChangeset
for help on using the changeset viewer.