Changeset 6145577 for src/Actions
- Timestamp:
- Apr 10, 2018, 6:43:12 AM (7 years ago)
- Branches:
- AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- c87d6e
- Parents:
- 8c6b68
- git-author:
- Frederik Heber <frederik.heber@…> (08/03/17 10:47:26)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/10/18 06:43:12)
- Location:
- src/Actions
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/ForceAnnealingAction.cpp
r8c6b68 r6145577 71 71 return Action::failure; 72 72 } 73 74 size_t CurrentStep = WorldTime::getInstance().getTime(); 75 if (CurrentStep == 0) { 76 ELOG(1, "WorldTime must be at least at step 1 already, use step-world-time if necessary."); 77 return Action::failure; 78 } 79 73 80 // first, we need to sort the mixin according to their ids (as selected atoms are sorted 74 81 // according to their arbitrary address in memory) … … 76 83 77 84 // create undo state for all selected atoms (undo info) 78 std::vector<AtomicInfo> UndoInfo; 79 UndoInfo.reserve(set.size()); 80 { 81 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 82 iter != World::getInstance().endAtomSelection(); 83 ++iter) 84 UndoInfo.push_back(AtomicInfo(*(iter->second))); 85 std::vector< std::vector<AtomicInfo> > UndoInfo(2); 86 for (int i=0;i<2;++i) { 87 UndoInfo[i].reserve(set.size()); 88 { 89 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 90 iter != World::getInstance().endAtomSelection(); 91 ++iter) 92 UndoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i)); 93 } 85 94 } 86 95 … … 93 102 params.MaxDistance.get(), 94 103 params.DampingFactor.get()); 95 size_t CurrentStep = WorldTime::getInstance().getTime();96 if (CurrentStep == 0) {97 ELOG(1, "WorldTime must be at least at step 1 already, use step-world-time if necessary.");98 return Action::failure;99 }100 104 101 105 // parse forces into last step (assuming we stepped on already) … … 113 117 STATUS("Successfully optimized structure by one step."); 114 118 115 std::vector<AtomicInfo> RedoInfo; 116 RedoInfo.reserve(set.size()); 117 { 118 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 119 iter != World::getInstance().endAtomSelection(); 120 ++iter) 121 RedoInfo.push_back(AtomicInfo(*(iter->second))); 119 std::vector< std::vector<AtomicInfo> > RedoInfo(2); 120 for (int i=0;i<2;++i) { 121 RedoInfo[i].reserve(set.size()); 122 { 123 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 124 iter != World::getInstance().endAtomSelection(); 125 ++iter) 126 RedoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i)); 127 } 122 128 } 129 123 130 MoleculeForceAnnealingState *UndoState = 124 131 new MoleculeForceAnnealingState(UndoInfo, RedoInfo, params); … … 130 137 MoleculeForceAnnealingState *state = 131 138 assert_cast<MoleculeForceAnnealingState*>(_state.get()); 139 const size_t CurrentStep = WorldTime::getInstance().getTime(); 132 140 133 141 // set stored old state 134 SetAtomsFromAtomicInfo(state->UndoInfo); 142 for (int i=0;i<2;++i) 143 SetAtomsFromAtomicInfo(state->UndoInfo[i], CurrentStep-i); 135 144 136 145 return ActionState::ptr(_state); … … 140 149 MoleculeForceAnnealingState *state = 141 150 assert_cast<MoleculeForceAnnealingState*>(_state.get()); 151 const size_t CurrentStep = WorldTime::getInstance().getTime(); 142 152 143 153 // set stored new state 144 SetAtomsFromAtomicInfo(state->RedoInfo); 154 for (int i=0;i<2;++i) 155 SetAtomsFromAtomicInfo(state->RedoInfo[i], CurrentStep-i); 145 156 146 157 return ActionState::ptr(_state); -
src/Actions/MoleculeAction/ForceAnnealingAction.def
r8c6b68 r6145577 32 32 (DummyValidator<bool>()) 33 33 34 #define statetypes (std::vector< AtomicInfo>)(std::vector<AtomicInfo>)34 #define statetypes (std::vector< std::vector<AtomicInfo> >)(std::vector< std::vector<AtomicInfo> >) 35 35 #define statereferences (UndoInfo)(RedoInfo) 36 36 -
src/Actions/UndoRedoHelpers.cpp
r8c6b68 r6145577 145 145 } 146 146 147 void MoleCuilder::SetAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms) 147 void MoleCuilder::SetAtomsFromAtomicInfo( 148 const std::vector<AtomicInfo> &_movedatoms, 149 const unsigned int _step) 148 150 { 149 151 BOOST_FOREACH( const AtomicInfo &_atominfo, _movedatoms) { … … 153 155 "MoleCuilder::SetAtomsFromAtomicInfo() - cannot find atom with id " 154 156 +toString(id)+" in the world."); 155 _atominfo.setAtom( *_atom );157 _atominfo.setAtom( *_atom, _step ); 156 158 } 157 159 } -
src/Actions/UndoRedoHelpers.hpp
r8c6b68 r6145577 19 19 #include "Atom/AtomicInfo.hpp" 20 20 #include "Bond/BondInfo.hpp" 21 #include "WorldTime.hpp" 21 22 22 23 namespace MoleCuilder { … … 61 62 * 62 63 * @param movedatoms vector of atomicInfo 64 * @param _step set state information for given world time 63 65 */ 64 void SetAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms); 66 void SetAtomsFromAtomicInfo( 67 const std::vector<AtomicInfo> &_movedatoms, 68 const unsigned int _step = WorldTime::getTime()); 65 69 66 70 /** Selects all atoms inside the given vector
Note:
See TracChangeset
for help on using the changeset viewer.