Changeset fc3aff for src/Actions
- Timestamp:
- Aug 20, 2014, 1:10:07 PM (11 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, Candidate_v1.7.0, Candidate_v1.7.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:
- 4c9101
- Parents:
- ee4f2d (diff), 3a33e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/Actions
- Files:
-
- 6 added
- 9 edited
-
ActionRegistry.cpp (modified) (4 diffs)
-
AtomAction/RemoveAction.def (modified) (1 diff)
-
FragmentationAction/FragmentationAutomationAction.cpp (modified) (3 diffs)
-
FragmentationAction/StructuralOptimizationAction.cpp (added)
-
FragmentationAction/StructuralOptimizationAction.def (added)
-
FragmentationAction/StructuralOptimizationAction.hpp (added)
-
GlobalListOfActions.hpp (modified) (3 diffs)
-
Makefile.am (modified) (6 diffs)
-
MoleculeAction/ForceAnnealingAction.cpp (added)
-
MoleculeAction/ForceAnnealingAction.def (added)
-
MoleculeAction/ForceAnnealingAction.hpp (added)
-
MoleculeAction/VerletIntegrationAction.cpp (modified) (5 diffs)
-
MoleculeAction/VerletIntegrationAction.def (modified) (2 diffs)
-
UndoRedoHelpers.cpp (modified) (8 diffs)
-
UndoRedoHelpers.hpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionRegistry.cpp
ree4f2d rfc3aff 73 73 clearOptionRegistry(); 74 74 75 // second clear each macro action that require presence of all primitive ones 75 // add all MakroActions: PLEASE adhere to the alphabetical ordering 76 { 77 MakroAction * presentAction = 78 dynamic_cast<MakroAction *>(getActionByName("molecular-dynamics")); 79 ASSERT( presentAction != NULL, 80 "ActionRegistry::fillRegistry() - makro action has not been registered."); 81 presentAction->unprepare(*this); 82 } 83 { 84 MakroAction * presentAction = 85 dynamic_cast<MakroAction *>(getActionByName("optimize-structure")); 86 ASSERT( presentAction != NULL, 87 "ActionRegistry::fillRegistry() - makro action has not been registered."); 88 presentAction->unprepare(*this); 89 } 76 90 { 77 91 MakroAction * presentAction = … … 81 95 presentAction->unprepare(*this); 82 96 } 83 #ifdef HAVE_JOBMARKET84 {85 MakroAction * presentAction =86 dynamic_cast<MakroAction *>(getActionByName("molecular-dynamics"));87 ASSERT( presentAction != NULL,88 "ActionRegistry::fillRegistry() - makro action has not been registered.");89 presentAction->unprepare(*this);90 }91 #endif92 97 93 98 //std::cout << "ActionRegistry::~ActionRegistry() called, instance is " << this << "." << std::endl; … … 121 126 presentAction->prepare(*this); 122 127 } 123 #ifdef HAVE_JOBMARKET124 128 { 125 129 MakroAction * presentAction = … … 129 133 presentAction->prepare(*this); 130 134 } 131 #endif 135 { 136 MakroAction * presentAction = 137 dynamic_cast<MakroAction *>(getActionByName("optimize-structure")); 138 ASSERT( presentAction != NULL, 139 "ActionRegistry::fillRegistry() - makro action has not been registered."); 140 presentAction->prepare(*this); 141 } 132 142 } 133 143 -
src/Actions/AtomAction/RemoveAction.def
ree4f2d rfc3aff 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 10 11 #include "Parameters/Validators/DummyValidator.hpp"12 9 13 10 // i.e. there is an integer with variable name Z that can be found in -
src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
ree4f2d rfc3aff 108 108 } 109 109 110 #ifdef HAVE_JOBMARKET111 110 static void updateSteps(Process &p, const size_t step, const size_t total) 112 111 { … … 114 113 p.setCurrStep(step); 115 114 } 116 #endif117 115 118 116 ActionState::ptr FragmentationFragmentationAutomationAction::performCall() { … … 178 176 ); 179 177 LOG(1, "INFO: Added " << NoJobs << " from FragmentJobsQueue."); 178 179 // prepare process 180 setMaxSteps(NumberJobs); 181 mpqccontroller.setUpdateHandler( 182 boost::bind(&updateSteps, boost::ref(*this), _1, _2) 183 ); 184 start(); 180 185 mpqccontroller.run(); 186 stop(); 181 187 182 188 // get back the results and place them in shortrangedata -
src/Actions/GlobalListOfActions.hpp
ree4f2d rfc3aff 18 18 19 19 // this is global list of actions valid for all cases 20 // PLEASE adhere to the alphabetical ordering of the list of Actions 21 // NOTE that Redo must remain at the front due to technical reasons 20 22 #define GLOBALLISTOFACTIONS_initial \ 21 23 (Redo) \ 22 (GraphUpdateMolecules) \ 23 (GraphCorrectBondDegree) \ 24 (GraphCreateAdjacency) \ 25 (GraphDepthFirstSearch) \ 26 (GraphDestroyAdjacency) \ 27 (GraphSubgraphDissection) \ 28 (MoleculeSaveTemperature) \ 29 (MoleculeCopy) \ 30 (MoleculeSuspendInWater) \ 31 (MoleculeFillWithMolecule) \ 32 (MoleculeRotateToPrincipalAxisSystem) \ 33 (MoleculeSaveAdjacency) \ 34 (MoleculeFillVoidWithMolecule) \ 35 (MoleculeVerletIntegration) \ 36 (MoleculeChangeName) \ 37 (MoleculeChangeBondAngle) \ 38 (MoleculeRotateAroundSelfByAngle) \ 39 (MoleculeSaveSelectedMolecules) \ 40 (MoleculeSaveBonds) \ 41 (MoleculeStretchBond) \ 42 (MoleculeLinearInterpolationofTrajectories) \ 43 (MoleculeLoad) \ 44 (MoleculeBondFile) \ 45 (TesselationNonConvexEnvelope) \ 46 (TesselationConvexEnvelope) \ 24 (AnalysisDipoleAngularCorrelation) \ 25 (AnalysisDipoleCorrelation) \ 26 (AnalysisMolecularVolume) \ 27 (AnalysisPairCorrelation) \ 28 (AnalysisPointCorrelation) \ 29 (AnalysisPrincipalAxisSystem) \ 30 (AnalysisSurfaceCorrelation) \ 31 (AtomAdd) \ 32 (AtomChangeElement) \ 33 (AtomRemove) \ 34 (AtomRotateAroundOriginByAngle) \ 35 (AtomSaveSelectedAtoms) \ 36 (AtomTranslate) \ 37 (BondAdd) \ 38 (BondRemove) \ 47 39 (CommandElementDb) \ 48 40 (CommandBondLengthTable) \ … … 56 48 (CommandVersion) \ 57 49 (CommandWarranty) \ 58 (ParserSetTremoloAtomdata) \ 50 (FillRegularGrid) \ 51 (FillSurface) \ 52 (FragmentationAnalyseFragmentationResults) \ 53 (FragmentationClearFragmentationResults) \ 54 (FragmentationFragmentation) \ 55 (FragmentationFragmentationAutomation) \ 56 (FragmentationMolecularDynamics) \ 57 (FragmentationParseFragmentJobs) \ 58 (FragmentationStoreSaturatedFragment) \ 59 (FragmentationStructuralOptimization) \ 60 (GraphUpdateMolecules) \ 61 (GraphCorrectBondDegree) \ 62 (GraphCreateAdjacency) \ 63 (GraphDepthFirstSearch) \ 64 (GraphDestroyAdjacency) \ 65 (GraphSubgraphDissection) \ 66 (MoleculeBondFile) \ 67 (MoleculeChangeName) \ 68 (MoleculeChangeBondAngle) \ 69 (MoleculeCopy) \ 70 (MoleculeFillWithMolecule) \ 71 (MoleculeFillVoidWithMolecule) \ 72 (MoleculeForceAnnealing) \ 73 (MoleculeLinearInterpolationofTrajectories) \ 74 (MoleculeLoad) \ 75 (MoleculeRotateAroundSelfByAngle) \ 76 (MoleculeRotateToPrincipalAxisSystem) \ 77 (MoleculeSaveAdjacency) \ 78 (MoleculeSaveBonds) \ 79 (MoleculeSaveSelectedMolecules) \ 80 (MoleculeSaveTemperature) \ 81 (MoleculeStretchBond) \ 82 (MoleculeSuspendInWater) \ 83 (MoleculeVerletIntegration) \ 84 (PotentialFitParticleCharges) \ 85 (PotentialParseHomologies) \ 86 (PotentialSaveHomologies) \ 59 87 (ParserParseTremoloPotentials) \ 60 88 (ParserSaveSelectedAtomsAsExtTypes) \ 61 89 (ParserSetParserParameters) \ 62 90 (ParserSetOutputFormats) \ 63 (AnalysisDipoleAngularCorrelation) \ 64 (AnalysisDipoleCorrelation) \ 65 (AnalysisPairCorrelation) \ 66 (AnalysisPointCorrelation) \ 67 (AnalysisSurfaceCorrelation) \ 68 (AnalysisMolecularVolume) \ 69 (AnalysisPrincipalAxisSystem) \ 91 (ParserSetTremoloAtomdata) \ 70 92 (Undo) \ 71 (AtomSaveSelectedAtoms) \72 (AtomRotateAroundOriginByAngle) \73 (AtomChangeElement) \74 (AtomRemove) \75 (AtomTranslate) \76 (AtomAdd) \77 (BondAdd) \78 (BondRemove) \79 (WorldCenterInBox) \80 (WorldRepeatBox) \81 (WorldChangeBox) \82 (WorldCenterOnEdge) \83 (WorldSetWorldTime) \84 (WorldSetBoundaryConditions) \85 (WorldOutput) \86 (WorldOutputAs) \87 (WorldSetDefaultName) \88 (WorldScaleBox) \89 (WorldAddEmptyBoundary) \90 (WorldBoundInBox) \91 (WorldInput) \92 (SelectionNotMoleculeOfAtom) \93 (SelectionNotAllMolecules) \94 (SelectionNotMoleculeById) \95 (SelectionMoleculeByOrder) \96 (SelectionMoleculeOfAtom) \97 (SelectionNotMoleculeByOrder) \98 (SelectionMoleculeByName) \99 (SelectionMoleculeById) \100 (SelectionAllMolecules) \101 (SelectionClearAllMolecules) \102 (SelectionInvertMolecules) \103 (SelectionMoleculeByFormula) \104 (SelectionNotMoleculeByFormula) \105 (SelectionNotMoleculeByName) \106 (SelectionNotAtomById) \107 (SelectionNotAtomByOrder) \108 93 (SelectionAllAtoms) \ 109 (SelectionClearAllAtoms) \110 (SelectionInvertAtoms) \111 (SelectionNotAllAtoms) \112 (SelectionNotAtomByElement) \113 94 (SelectionAllAtomsInsideVolume) \ 114 95 (SelectionAllAtomsOfMolecule) \ 115 (SelectionNotAllAtomsInsideVolume) \ 96 (SelectionAllMolecules) \ 97 (SelectionAllShapes) \ 116 98 (SelectionAtomByElement) \ 117 (SelectionNotAllAtomsOfMolecule) \118 99 (SelectionAtomById) \ 119 100 (SelectionAtomByOrder) \ 120 (SelectionAllShapes) \ 101 (SelectionClearAllAtoms) \ 102 (SelectionClearAllMolecules) \ 103 (SelectionInvertAtoms) \ 104 (SelectionInvertMolecules) \ 105 (SelectionMoleculeOfAtom) \ 106 (SelectionMoleculeByFormula) \ 107 (SelectionMoleculeById) \ 108 (SelectionMoleculeByName) \ 109 (SelectionMoleculeByOrder) \ 110 (SelectionNotAllAtoms) \ 111 (SelectionNotAllAtomsInsideVolume) \ 112 (SelectionNotAllAtomsOfMolecule) \ 113 (SelectionNotAllMolecules) \ 114 (SelectionNotAllShapes) \ 115 (SelectionNotAtomById) \ 116 (SelectionNotAtomByElement) \ 117 (SelectionNotAtomByOrder) \ 118 (SelectionNotMoleculeOfAtom) \ 119 (SelectionNotMoleculeByFormula) \ 120 (SelectionNotMoleculeById) \ 121 (SelectionNotMoleculeByName) \ 122 (SelectionNotMoleculeByOrder) \ 123 (SelectionNotShapeByName) \ 121 124 (SelectionShapeByName) \ 122 (SelectionNotAllShapes) \123 (SelectionNotShapeByName) \124 (FragmentationAnalyseFragmentationResults) \125 (FragmentationFragmentationAutomation) \126 (FragmentationClearFragmentationResults) \127 (FragmentationFragmentation) \128 (FragmentationMolecularDynamics) \129 (FragmentationParseFragmentJobs) \130 (FragmentationStoreSaturatedFragment) \131 (PotentialFitParticleCharges) \132 (PotentialParseHomologies) \133 (PotentialSaveHomologies) \134 (FillRegularGrid) \135 (FillSurface) \136 125 (ShapeCombineShapes) \ 137 126 (ShapeCreateShape) \ … … 139 128 (ShapeRotateShape) \ 140 129 (ShapeStretchShape) \ 141 (ShapeTranslateShape) 130 (ShapeTranslateShape) \ 131 (TesselationConvexEnvelope) \ 132 (TesselationNonConvexEnvelope) \ 133 (WorldAddEmptyBoundary) \ 134 (WorldBoundInBox) \ 135 (WorldCenterInBox) \ 136 (WorldCenterOnEdge) \ 137 (WorldChangeBox) \ 138 (WorldInput) \ 139 (WorldOutput) \ 140 (WorldOutputAs) \ 141 (WorldRepeatBox) \ 142 (WorldScaleBox) \ 143 (WorldSetBoundaryConditions) \ 144 (WorldSetDefaultName) \ 145 (WorldSetWorldTime) 142 146 143 147 // extend list of actions in case levmar is available -
src/Actions/Makefile.am
ree4f2d rfc3aff 231 231 Actions/FragmentationAction/MolecularDynamicsAction.cpp \ 232 232 Actions/FragmentationAction/ParseFragmentJobsAction.cpp \ 233 Actions/FragmentationAction/StoreSaturatedFragmentAction.cpp 233 Actions/FragmentationAction/StoreSaturatedFragmentAction.cpp \ 234 Actions/FragmentationAction/StructuralOptimizationAction.cpp 234 235 FRAGMENTATIONACTIONHEADER = \ 235 236 Actions/FragmentationAction/AnalyseFragmentationResultsAction.hpp \ … … 239 240 Actions/FragmentationAction/MolecularDynamicsAction.hpp \ 240 241 Actions/FragmentationAction/ParseFragmentJobsAction.hpp \ 241 Actions/FragmentationAction/StoreSaturatedFragmentAction.hpp 242 Actions/FragmentationAction/StoreSaturatedFragmentAction.hpp \ 243 Actions/FragmentationAction/StructuralOptimizationAction.hpp 242 244 FRAGMENTATIONACTIONDEFS = \ 243 245 Actions/FragmentationAction/AnalyseFragmentationResultsAction.def \ … … 247 249 Actions/FragmentationAction/MolecularDynamicsAction.def \ 248 250 Actions/FragmentationAction/ParseFragmentJobsAction.def \ 249 Actions/FragmentationAction/StoreSaturatedFragmentAction.def 251 Actions/FragmentationAction/StoreSaturatedFragmentAction.def \ 252 Actions/FragmentationAction/StructuralOptimizationAction.def 250 253 251 254 GRAPHACTIONSOURCE = \ … … 278 281 Actions/MoleculeAction/FillWithMoleculeAction.cpp \ 279 282 Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp \ 283 Actions/MoleculeAction/ForceAnnealingAction.cpp \ 280 284 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \ 281 285 Actions/MoleculeAction/LoadAction.cpp \ … … 296 300 Actions/MoleculeAction/FillWithMoleculeAction.hpp \ 297 301 Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp \ 302 Actions/MoleculeAction/ForceAnnealingAction.hpp \ 298 303 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \ 299 304 Actions/MoleculeAction/LoadAction.hpp \ … … 314 319 Actions/MoleculeAction/FillWithMoleculeAction.def \ 315 320 Actions/MoleculeAction/FillVoidWithMoleculeAction.def \ 321 Actions/MoleculeAction/ForceAnnealingAction.def \ 316 322 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.def \ 317 323 Actions/MoleculeAction/LoadAction.def \ -
src/Actions/MoleculeAction/VerletIntegrationAction.cpp
ree4f2d rfc3aff 3 3 * Description: creates and alters molecular systems 4 4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved. 5 * Copyright (C) 2013-2014 Frederik Heber. All rights reserved. 5 6 * 6 7 * … … 35 36 #include "CodePatterns/MemDebug.hpp" 36 37 38 #include "Actions/UndoRedoHelpers.hpp" 37 39 #include "Atom/atom.hpp" 40 #include "Atom/AtomicInfo.hpp" 38 41 #include "Atom/AtomSet.hpp" 39 42 #include "CodePatterns/Log.hpp" … … 53 56 using namespace MoleCuilder; 54 57 58 enum { 59 PositionIndex=0, 60 VelocityIndex=1, 61 ForceIndex=2, 62 MAXINDEX 63 } VectorIndexType; 64 55 65 // and construct the stuff 56 66 #include "VerletIntegrationAction.def" … … 58 68 /** =========== define the function ====================== */ 59 69 ActionState::ptr MoleculeVerletIntegrationAction::performCall() { 60 // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test61 70 AtomSetMixin<std::vector<atom *> > set(World::getInstance().getSelectedAtoms()); 71 if (set.empty()) { 72 LOG(0, "STATUS: No atoms selected."); 73 return Action::failure; 74 } 62 75 // we always operate relative to current time step 63 size_t CurrentStep = WorldTime::getInstance().getTime();76 const size_t CurrentStep = WorldTime::getInstance().getTime(); 64 77 VerletForceIntegration<std::vector<atom *> > Verlet(set, params.Deltat.get(), true); 65 78 // parse forces into next step … … 71 84 LOG(2, "File " << params.forcesfile.get() << " found and parsed."); 72 85 } 86 87 // create undo state for all selected atoms (undo info) 88 std::vector<AtomicInfo> UndoInfo; 89 UndoInfo.reserve(set.size()); 90 { 91 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 92 iter != World::getInstance().endAtomSelection(); 93 ++iter) 94 UndoInfo.push_back(AtomicInfo(*(iter->second))); 95 } 96 73 97 // perform velocity verlet update 74 LOG(1, "Verlet integrating."); 75 if (!Verlet(CurrentStep+1, 1, 0, params.FixedCenterOfMass.get())) 76 ELOG(1, "Velocity verlet failed."); 77 else 78 LOG(2, "DEBUG: Successfully performed updates on velocity and position."); 79 // increment to next time step 98 Verlet(CurrentStep+1, 1, 0, params.FixedCenterOfMass.get()); 99 LOG(0, "STATUS: Successfully performed updates on velocity and position."); 100 // increment to next time step: re-creates bond graph 80 101 World::getInstance().setTime(CurrentStep+1); 81 102 82 return Action::success; 103 // create undo state for all selected atoms (redo info): 104 // we need: 105 // -# forces from last step (possible parsing forces file, already in UndoInfo) 106 // -# velocities from last step (..UpdateU(), already in UndoInfo) 107 // -# current position (..UpdateX()) 108 std::vector<Vectors_t> UpdatedStep(MAXINDEX); 109 UpdatedStep[PositionIndex].reserve(set.size()); 110 UpdatedStep[VelocityIndex].reserve(set.size()); 111 UpdatedStep[ForceIndex].reserve(set.size()); 112 { 113 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 114 iter != World::getInstance().endAtomSelection(); 115 ++iter) { 116 UpdatedStep[PositionIndex].push_back(iter->second->getPositionAtStep(CurrentStep+1)); 117 UpdatedStep[VelocityIndex].push_back(iter->second->getAtomicVelocityAtStep(CurrentStep)); 118 UpdatedStep[ForceIndex].push_back(iter->second->getAtomicForceAtStep(CurrentStep)); 119 } 120 } 121 MoleculeVerletIntegrationState *UndoState = 122 new MoleculeVerletIntegrationState(UndoInfo, UpdatedStep, params); 123 124 return ActionState::ptr(UndoState); 83 125 } 84 126 85 127 ActionState::ptr MoleculeVerletIntegrationAction::performUndo(ActionState::ptr _state) { 86 // MoleculeVerletIntegrationState *state = assert_cast<MoleculeVerletIntegrationState*>(_state.get()); 128 MoleculeVerletIntegrationState *state = 129 assert_cast<MoleculeVerletIntegrationState*>(_state.get()); 87 130 88 // string newName = state->mol->getName(); 89 // state->mol->setName(state->lastName); 131 // go back one step 132 const size_t CurrentStep = WorldTime::getInstance().getTime(); 133 World::getInstance().setTime(CurrentStep-1); 90 134 91 STATUS("Undo of MoleculeVerletIntegrationAction not implemented."); 92 return Action::failure; 135 // remove current step for all modified atoms 136 removeLastStep(getIdsFromAtomicInfo(state->UndoInfo)); 137 138 // and set back the old step (forces have been changed) 139 SetAtomsFromAtomicInfo(state->UndoInfo); 140 141 return ActionState::ptr(_state); 93 142 } 94 143 95 144 ActionState::ptr MoleculeVerletIntegrationAction::performRedo(ActionState::ptr _state){ 96 STATUS("Rddo of MoleculeVerletIntegrationAction not implemented."); 97 return Action::failure; 145 MoleculeVerletIntegrationState *state = 146 assert_cast<MoleculeVerletIntegrationState*>(_state.get()); 147 148 // set forces and velocities 149 ResetAtomVelocity(state->UndoInfo, state->UpdatedStep[VelocityIndex]); 150 ResetAtomForce(state->UndoInfo, state->UpdatedStep[ForceIndex]); 151 152 // set stored new state 153 addNewStep(state->UndoInfo); 154 155 // add a new time step 156 size_t CurrentStep = WorldTime::getInstance().getTime(); 157 World::getInstance().setTime(CurrentStep+1); 158 159 // and set positions of the new step 160 ResetAtomPosition(state->UndoInfo, state->UpdatedStep[PositionIndex]); 161 162 return ActionState::ptr(_state); 98 163 } 99 164 -
src/Actions/MoleculeAction/VerletIntegrationAction.def
ree4f2d rfc3aff 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 class MoleculeListClass; 9 #include "LinearAlgebra/Vector.hpp" 10 #include <vector> 11 typedef std::vector<Vector> Vectors_t; 10 12 11 13 #include "Parameters/Validators/DummyValidator.hpp" … … 27 29 (DummyValidator< bool >()) 28 30 29 # undef statetypes30 # undef statereferences31 #define statetypes (std::vector<AtomicInfo>)(std::vector<Vectors_t>) 32 #define statereferences (UndoInfo)(UpdatedStep) 31 33 32 34 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Actions/UndoRedoHelpers.cpp
ree4f2d rfc3aff 3 3 * Description: creates and alters molecular systems 4 4 * Copyright (C) 2012 University of Bonn. All rights reserved. 5 * Copyright (C) 2013-2014 Frederik Heber. All rights reserved. 5 6 * 6 7 * … … 38 39 #include "UndoRedoHelpers.hpp" 39 40 41 #include <boost/bind.hpp> 40 42 #include <boost/foreach.hpp> 43 #include <boost/function.hpp> 41 44 42 45 #include "Atom/atom.hpp" … … 47 50 #include "CodePatterns/Log.hpp" 48 51 #include "World.hpp" 52 #include "WorldTime.hpp" 49 53 50 54 bool MoleCuilder::AddAtomsFromAtomicInfo(std::vector<AtomicInfo> &atoms) … … 103 107 } 104 108 105 void MoleCuilder::SetAtomsFromAtomicInfo( std::vector<AtomicInfo> &movedatoms)106 { 107 BOOST_FOREACH( const AtomicInfo &_atominfo, movedatoms) {109 void MoleCuilder::SetAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms) 110 { 111 BOOST_FOREACH( const AtomicInfo &_atominfo, _movedatoms) { 108 112 const atomId_t id = _atominfo.getId(); 109 113 atom * const _atom = World::getInstance().getAtom(AtomById(id)); … … 115 119 } 116 120 117 void MoleCuilder::SelectAtomsFromAtomicInfo( std::vector<AtomicInfo> &movedatoms)118 { 119 BOOST_FOREACH( const AtomicInfo &_atominfo, movedatoms) {121 void MoleCuilder::SelectAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms) 122 { 123 BOOST_FOREACH( const AtomicInfo &_atominfo, _movedatoms) { 120 124 const atomId_t id = _atominfo.getId(); 121 125 World::getInstance().selectAtom(id); … … 124 128 125 129 void MoleCuilder::ResetAtomPosition(const std::vector<AtomicInfo> &movedatoms, const std::vector<Vector> &MovedToVector) 130 { 131 boost::function<void(atom *, const Vector&)> setter = 132 boost::bind(&atom::setPosition, _1, _2); 133 ResetByFunction(movedatoms, MovedToVector, setter); 134 } 135 136 void MoleCuilder::ResetAtomVelocity(const std::vector<AtomicInfo> &movedatoms, const std::vector<Vector> &VelocityVector) 137 { 138 boost::function<void(atom *, const Vector&)> setter = 139 boost::bind(&atom::setAtomicVelocity, _1, _2); 140 ResetByFunction(movedatoms, VelocityVector, setter); 141 } 142 143 void MoleCuilder::ResetAtomForce(const std::vector<AtomicInfo> &movedatoms, const std::vector<Vector> &ForceVector) 144 { 145 boost::function<void(atom *, const Vector&)> setter = 146 boost::bind(&atom::setAtomicForce, _1, _2); 147 ResetByFunction(movedatoms, ForceVector, setter); 148 } 149 150 void MoleCuilder::ResetByFunction( 151 const std::vector<AtomicInfo> &movedatoms, 152 const std::vector<Vector> &MovedToVector, 153 boost::function<void(atom *, const Vector&)> &setter) 126 154 { 127 155 std::vector<Vector>::const_iterator positer = MovedToVector.begin(); … … 136 164 "FillSphericalSurfaceAction::performRedo() - cannot find atom with id " 137 165 +toString(id)+" in the world."); 138 _atom->setPosition(*positer );166 setter(_atom, *positer ); 139 167 ++positer; 140 168 } … … 152 180 } 153 181 } 182 183 void MoleCuilder::removeLastStep(const std::vector<atomId_t> &_atoms) 184 { 185 for (size_t i=0; i<_atoms.size(); ++i) { 186 atom * const _atom = World::getInstance().getAtom(AtomById(_atoms[i])); 187 _atom->removeSteps(); 188 } 189 } 190 191 void MoleCuilder::addNewStep(const std::vector<AtomicInfo> &_movedatoms) 192 { 193 for(size_t i=0; i< _movedatoms.size(); ++i) { 194 atom * const _atom = World::getInstance().getAtom(AtomById(_movedatoms[i].getId())); 195 _atom->UpdateSteps(); 196 } 197 } 198 199 void MoleCuilder::addNewStep(const std::vector<atomId_t> &_ids) 200 { 201 for(size_t i=0; i< _ids.size(); ++i) { 202 atom * const _atom = World::getInstance().getAtom(AtomById(_ids[i])); 203 _atom->UpdateSteps(); 204 } 205 } 206 207 std::vector<atomId_t> MoleCuilder::getIdsFromAtomicInfo(const std::vector<AtomicInfo> &movedatoms) 208 { 209 std::vector<atomId_t> ids(movedatoms.size(), (size_t)-1); 210 std::transform( 211 movedatoms.begin(), movedatoms.end(), 212 ids.begin(), 213 boost::bind(&AtomicInfo::getId, _1)); 214 return ids; 215 } -
src/Actions/UndoRedoHelpers.hpp
ree4f2d rfc3aff 55 55 * @param movedatoms vector of atomicInfo 56 56 */ 57 void SetAtomsFromAtomicInfo( std::vector<AtomicInfo> &movedatoms);57 void SetAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms); 58 58 59 59 /** Selects all atoms inside the given vector … … 61 61 * @param movedatoms vector of atomicInfo 62 62 */ 63 void SelectAtomsFromAtomicInfo(std::vector<AtomicInfo> &movedatoms); 63 void SelectAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms); 64 65 /** Helper function to allow setting arbitrary atom vectorial information via some 66 * \a setter function. 67 * 68 * @param movedatoms atoms whose info to change 69 * @param MovedToVector vector with old vectorial information 70 */ 71 void ResetByFunction( 72 const std::vector<AtomicInfo> &movedatoms, 73 const std::vector<Vector> &MovedToVector, 74 boost::function<void(atom *, const Vector&)> &setter); 64 75 65 76 /** Sets the atoms whose id is stored in given AtomicInfo in \a movedatoms … … 71 82 void ResetAtomPosition(const std::vector<AtomicInfo> &movedatoms, const std::vector<Vector> &MovedToVector); 72 83 84 /** Sets the atoms whose id is stored in given AtomicInfo in \a movedatoms 85 * to position in \a MovedToVector. 86 * 87 * @param movedatoms atoms whose position to change 88 * @param VelocityVector vector with old velocities 89 */ 90 void ResetAtomVelocity(const std::vector<AtomicInfo> &movedatoms, const std::vector<Vector> &VelocityVector); 91 92 /** Sets the atoms whose id is stored in given AtomicInfo in \a movedatoms 93 * to position in \a MovedToVector. 94 * 95 * @param movedatoms atoms whose position to change 96 * @param ForceVector vector with old forces 97 */ 98 void ResetAtomForce(const std::vector<AtomicInfo> &movedatoms, const std::vector<Vector> &ForceVector); 99 73 100 /** Remove all molecules identified by their ids given in \a ids. 74 101 * … … 76 103 */ 77 104 void RemoveMoleculesWithAtomsByIds(const std::vector<moleculeId_t> &ids); 105 106 /** Removes the last time step for all \a movedatoms 107 * 108 * @param movedatoms atoms whose last step in time to remove 109 */ 110 void removeLastStep(const std::vector<atomId_t> &movedatoms); 111 112 /** Adds another time step to all \a movedatoms. 113 * 114 * Note that the time step is initialized to zero. 115 * 116 * @param _ids atoms whose last step in time to remove 117 */ 118 void addNewStep(const std::vector<atomId_t> &_ids); 119 120 /** Adds another time step to all \a movedatoms. 121 * 122 * Note that the time step is initialized to zero. This gives you a chance 123 * to set the time step and call setAtomsFromAtomicInfo() yourself. 124 * 125 * @param _movedatoms atoms whose last step in time to remove 126 */ 127 void addNewStep(const std::vector<AtomicInfo> &_movedatoms); 128 129 /** Helper function to extract id information from vector of AtomicInfo. 130 * 131 * @param movedatoms atoms whose ids to extract 132 */ 133 std::vector<atomId_t> getIdsFromAtomicInfo(const std::vector<AtomicInfo> &movedatoms); 78 134 } 79 135
Note:
See TracChangeset
for help on using the changeset viewer.
