Changeset d40189 for src/Atom/AtomSet.hpp
- Timestamp:
- Apr 23, 2021, 8:31:23 PM (5 years ago)
- Branches:
- Candidate_v1.7.0, stable
- Children:
- 61cc0f
- Parents:
- cbbb6a
- git-author:
- Frederik Heber <frederik.heber@…> (04/28/19 22:01:20)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/23/21 20:31:23)
- File:
-
- 1 edited
-
src/Atom/AtomSet.hpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Atom/AtomSet.hpp
rcbbb6a rd40189 77 77 double totalMass() const; 78 78 double totalTemperatureAtStep(unsigned int step) const; 79 Vector totalForceAtStep(unsigned int step) const; 79 80 Vector totalMomentumAtStep(unsigned int step) const; 81 Vector totalAbsoluteMomentumAtStep(unsigned int step) const; 82 Vector totalAbsoluteForceAtStep(unsigned int step) const; 80 83 81 84 size_t getMaxTrajectorySize() const; … … 111 114 112 115 template<class T> 116 struct absValueSum { 117 absValueSum(T (AtomInfo::*_f)() const,T startValue) : 118 f(_f), 119 value(startValue) 120 {} 121 T operator+(const AtomInfo *atom){ 122 temp = (atom->*f)(); 123 for (int i=0;i<NDIM;++i) 124 temp[i] = fabs(temp[i]); 125 return value + temp; 126 } 127 T operator=(T _value){ 128 value = _value; 129 for (int i=0;i<NDIM;++i) 130 value[i] = fabs(value[i]); 131 return value; 132 } 133 T (AtomInfo::*f)() const; 134 T value; 135 T temp; 136 }; 137 138 template<class T> 113 139 struct valueMax { 114 140 valueMax(T (AtomInfo::*_f)() const,T startValue) : … … 145 171 T (AtomInfo::*f)(unsigned int) const; 146 172 T value; 173 }; 174 175 template<class T> 176 struct stepAbsValueSum { 177 stepAbsValueSum(unsigned int _step, T (AtomInfo::*_f)(unsigned int) const,T startValue) : 178 step(_step), 179 f(_f), 180 value(startValue) 181 {} 182 T operator+(const AtomInfo *atom){ 183 temp = (atom->*f)(step); 184 for (int i=0;i<NDIM;++i) 185 temp[i] = fabs(temp[i]); 186 return value + temp; 187 } 188 T operator=(T _value){ 189 value = _value; 190 for (int i=0;i<NDIM;++i) 191 value[i] = fabs(value[i]); 192 return value; 193 } 194 unsigned int step; 195 T (AtomInfo::*f)(unsigned int) const; 196 T value; 197 T temp; 147 198 }; 148 199 }; … … 208 259 class iterator_type, 209 260 class const_iterator_type> 261 inline Vector AtomSetMixin<container_type,iterator_type,const_iterator_type>::totalAbsoluteMomentumAtStep(unsigned int step) const{ 262 return accumulate(this->begin(),this->end(),stepAbsValueSum<Vector>(step,&AtomInfo::getMomentum,Vector())).value; 263 } 264 265 template <class container_type, 266 class iterator_type, 267 class const_iterator_type> 268 inline Vector AtomSetMixin<container_type,iterator_type,const_iterator_type>::totalForceAtStep(unsigned int step) const{ 269 return accumulate(this->begin(),this->end(),stepValueSum<Vector>(step,&AtomInfo::getAcceleration,Vector())).value; 270 } 271 272 template <class container_type, 273 class iterator_type, 274 class const_iterator_type> 275 inline Vector AtomSetMixin<container_type,iterator_type,const_iterator_type>::totalAbsoluteForceAtStep(unsigned int step) const{ 276 return accumulate(this->begin(),this->end(),stepAbsValueSum<Vector>(step,&AtomInfo::getAcceleration,Vector())).value; 277 } 278 279 template <class container_type, 280 class iterator_type, 281 class const_iterator_type> 210 282 inline void AtomSetMixin<container_type,iterator_type,const_iterator_type>::sortByIds(){ 211 283 std::sort(this->begin(), this->end(),
Note:
See TracChangeset
for help on using the changeset viewer.
