--- trunk/src/utils/LocalIndexManager.hpp 2005/04/15 22:04:00 507 +++ trunk/src/utils/LocalIndexManager.hpp 2013/12/05 18:19:26 1953 @@ -6,19 +6,10 @@ * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,6 +28,16 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ /** @@ -54,7 +55,7 @@ #include #include -namespace oopse { +namespace OpenMD { /** * @class IndexListContainer @@ -64,34 +65,31 @@ namespace oopse { class IndexListContainer{ public: static const int MAX_INTEGER = 2147483647; - typedef std::list >::iterator IndexListContainerIterator; + typedef std::list >::iterator IndexListContainerIterator; - IndexListContainer(int minIndex = 0, int maxIndex = MAX_INTEGER) :minIndex_(minIndex), maxIndex_(maxIndex) { - - indexContainer_.push_back(std::make_pair(minIndex, maxIndex)); - } + indexContainer_.push_back(std::make_pair(minIndex, maxIndex)); + } - int pop() { - + int pop() { if (indexContainer_.empty()) { std::cerr << "" << std::endl; } - IndexListContainerIterator i = indexContainer_.begin(); int result; result = indexContainer_.front().first; if (indexContainer_.front().first == indexContainer_.front().second) { indexContainer_.pop_front(); - } else if (indexContainer_.front().first < indexContainer_.front().second) { + } else if (indexContainer_.front().first < + indexContainer_.front().second) { ++indexContainer_.front().first; } else { std::cerr << "" << std::endl; } - + return result; } @@ -100,7 +98,7 @@ namespace oopse { * */ void insert(int index) { - IndexListContainerIterator insertPos = internalInsert(index, index); + IndexListContainerIterator insertPos = internalInsert(index, index); merge(insertPos); } @@ -110,7 +108,8 @@ namespace oopse { * @param endIndex */ void insert(int beginIndex, int endIndex) { - IndexListContainerIterator insertPos = internalInsert(beginIndex, endIndex); + IndexListContainerIterator insertPos = internalInsert(beginIndex, + endIndex); merge(insertPos); } @@ -128,7 +127,6 @@ namespace oopse { std::unique(indices.begin(), indices.end()); std::vector::iterator i; - IndexListContainerIterator insertPos; int beginIndex; beginIndex = indices[0]; @@ -139,8 +137,6 @@ namespace oopse { beginIndex = *i; } } - - } std::vector getIndicesBefore(int index) { @@ -164,20 +160,15 @@ namespace oopse { indexContainer_.erase(indexContainer_.begin(), i); break; } else { - for (int j = (*i).first; j < index; ++j) { result.push_back(j); - } - + } (*i).first = index; indexContainer_.erase(indexContainer_.begin(), i); break; } - } - return result; - } int getMaxIndex() { @@ -196,10 +187,7 @@ namespace oopse { if (endIndex > maxIndex_) { std::cerr << "" << std::endl; } - - - IndexListContainerIterator j; - + IndexListContainerIterator i = indexContainer_.begin(); for (; i != indexContainer_.end(); ++i) { if ((*i).first > endIndex) { @@ -294,12 +282,117 @@ namespace oopse { void releaseRigidBodyIndex(std::vector indices) { rigidBodyIndexContainer_.insert(indices); } - + + int getNextCutoffGroupIndex() { + return cutoffGroupIndexContainer_.pop(); + } + + std::vector getCutoffGroupIndicesBefore(int index) { + return cutoffGroupIndexContainer_.getIndicesBefore(index); + } + + void releaseCutoffGroupIndex(int index) { + cutoffGroupIndexContainer_.insert(index); + } + + void releaseCutoffGroupIndex(int beginIndex, int endIndex) { + cutoffGroupIndexContainer_.insert(beginIndex, endIndex); + } + + void releaseCutoffGroupIndex(std::vector indices) { + cutoffGroupIndexContainer_.insert(indices); + } + + int getNextBondIndex() { + return bondIndexContainer_.pop(); + } + + std::vector getBondIndicesBefore(int index) { + return bondIndexContainer_.getIndicesBefore(index); + } + + void releaseBondIndex(int index) { + bondIndexContainer_.insert(index); + } + + void releaseBondIndex(int beginIndex, int endIndex) { + bondIndexContainer_.insert(beginIndex, endIndex); + } + + void releaseBondIndex(std::vector indices) { + bondIndexContainer_.insert(indices); + } + + int getNextBendIndex() { + return bendIndexContainer_.pop(); + } + + std::vector getBendIndicesBefore(int index) { + return bendIndexContainer_.getIndicesBefore(index); + } + + void releaseBendIndex(int index) { + bendIndexContainer_.insert(index); + } + + void releaseBendIndex(int beginIndex, int endIndex) { + bendIndexContainer_.insert(beginIndex, endIndex); + } + + void releaseBendIndex(std::vector indices) { + bendIndexContainer_.insert(indices); + } + + int getNextTorsionIndex() { + return torsionIndexContainer_.pop(); + } + + std::vector getTorsionIndicesBefore(int index) { + return torsionIndexContainer_.getIndicesBefore(index); + } + + void releaseTorsionIndex(int index) { + torsionIndexContainer_.insert(index); + } + + void releaseTorsionIndex(int beginIndex, int endIndex) { + torsionIndexContainer_.insert(beginIndex, endIndex); + } + + void releaseTorsionIndex(std::vector indices) { + torsionIndexContainer_.insert(indices); + } + + int getNextInversionIndex() { + return inversionIndexContainer_.pop(); + } + + std::vector getInversionIndicesBefore(int index) { + return inversionIndexContainer_.getIndicesBefore(index); + } + + void releaseInversionIndex(int index) { + inversionIndexContainer_.insert(index); + } + + void releaseInversionIndex(int beginIndex, int endIndex) { + inversionIndexContainer_.insert(beginIndex, endIndex); + } + + void releaseInversionIndex(std::vector indices) { + inversionIndexContainer_.insert(indices); + } + private: IndexListContainer atomIndexContainer_; IndexListContainer rigidBodyIndexContainer_; + IndexListContainer cutoffGroupIndexContainer_; + IndexListContainer bondIndexContainer_; + IndexListContainer bendIndexContainer_; + IndexListContainer torsionIndexContainer_; + IndexListContainer inversionIndexContainer_; }; -} //end namespace oopse +} //end namespace OpenMD #endif //UTILS_LOCALINDEXMANAGER_HPP