| 1 | /* | 
| 2 | * Copyright (c) 2013 The University of Notre Dame. All Rights Reserved. | 
| 3 | * | 
| 4 | * The University of Notre Dame grants you ("Licensee") a | 
| 5 | * non-exclusive, royalty free, license to use, modify and | 
| 6 | * redistribute this software in source and binary code form, provided | 
| 7 | * that the following conditions are met: | 
| 8 | * | 
| 9 | * 1. Redistributions of source code must retain the above copyright | 
| 10 | *    notice, this list of conditions and the following disclaimer. | 
| 11 | * | 
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | 
| 13 | *    notice, this list of conditions and the following disclaimer in the | 
| 14 | *    documentation and/or other materials provided with the | 
| 15 | *    distribution. | 
| 16 | * | 
| 17 | * This software is provided "AS IS," without a warranty of any | 
| 18 | * kind. All express or implied conditions, representations and | 
| 19 | * warranties, including any implied warranty of merchantability, | 
| 20 | * fitness for a particular purpose or non-infringement, are hereby | 
| 21 | * excluded.  The University of Notre Dame and its licensors shall not | 
| 22 | * be liable for any damages suffered by licensee as a result of | 
| 23 | * using, modifying or distributing the software or its | 
| 24 | * derivatives. In no event will the University of Notre Dame or its | 
| 25 | * licensors be liable for any lost revenue, profit or data, or for | 
| 26 | * direct, indirect, special, consequential, incidental or punitive | 
| 27 | * damages, however caused and regardless of the theory of liability, | 
| 28 | * arising out of the use of or inability to use software, even if the | 
| 29 | * University of Notre Dame has been advised of the possibility of | 
| 30 | * such damages. | 
| 31 | * | 
| 32 | * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your | 
| 33 | * research, please cite the appropriate papers when you publish your | 
| 34 | * work.  Good starting points are: | 
| 35 | * | 
| 36 | * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). | 
| 37 | * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). | 
| 38 | * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). | 
| 39 | * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 | * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). | 
| 41 | */ | 
| 42 |  | 
| 43 | #ifndef PRIMITIVES_SHORTRANGEINTERACTION_HPP | 
| 44 | #define PRIMITIVES_SHORTRANGEINTERACTION_HPP | 
| 45 |  | 
| 46 | #include <vector> | 
| 47 |  | 
| 48 | #include "visitors/BaseVisitor.hpp" | 
| 49 | #include "utils/PropertyMap.hpp" | 
| 50 | #include "brains/Snapshot.hpp" | 
| 51 | #include "brains/SnapshotManager.hpp" | 
| 52 |  | 
| 53 | namespace OpenMD{ | 
| 54 |  | 
| 55 | /** | 
| 56 | * @class ShortRangeInteraction | 
| 57 | * @brief | 
| 58 | * | 
| 59 | * A ShortRangeInteraction holds some bookeeping data for bonded | 
| 60 | * interactions (e.g. Bonds, Bends, Torsions, Inversions). | 
| 61 | * | 
| 62 | */ | 
| 63 | class ShortRangeInteraction{ | 
| 64 | public: | 
| 65 |  | 
| 66 | virtual ~ShortRangeInteraction(); | 
| 67 |  | 
| 68 | /** | 
| 69 | * Returns the global index of this ShortRangeInteraction. | 
| 70 | * @return  the global index of this ShortRangeInteraction | 
| 71 | */ | 
| 72 | int getGlobalIndex() { | 
| 73 | return globalIndex_; | 
| 74 | } | 
| 75 |  | 
| 76 | /** | 
| 77 | * Sets the global index of this ShortRangeInteraction. | 
| 78 | * @param index new global index to be set | 
| 79 | */ | 
| 80 | void setGlobalIndex(int index) { | 
| 81 | globalIndex_ = index; | 
| 82 | } | 
| 83 |  | 
| 84 | /** | 
| 85 | * Returns the local index of this ShortRangeInteraction | 
| 86 | * @return the local index of this ShortRangeInteraction | 
| 87 | */ | 
| 88 | int getLocalIndex() { | 
| 89 | return localIndex_; | 
| 90 | } | 
| 91 |  | 
| 92 | /** | 
| 93 | * Sets the local index of this ShortRangeInteraction | 
| 94 | * @param index new index to be set | 
| 95 | */ | 
| 96 | void setLocalIndex(int index) { | 
| 97 | localIndex_ = index; | 
| 98 | } | 
| 99 |  | 
| 100 |  | 
| 101 | /** | 
| 102 | * Sets the Snapshot Manager of this ShortRangeInteraction | 
| 103 | */ | 
| 104 | void setSnapshotManager(SnapshotManager* sman) { | 
| 105 | snapshotMan_ = sman; | 
| 106 | } | 
| 107 |  | 
| 108 |  | 
| 109 | /** Returns the name of this ShortRangeInteraction */ | 
| 110 | virtual std::string getName() = 0; | 
| 111 |  | 
| 112 | /** Sets the name of this ShortRangeInteraction*/ | 
| 113 | virtual void setName(const std::string& name) {} | 
| 114 |  | 
| 115 | /** | 
| 116 | * <p> | 
| 117 | * The purpose of the Visitor Pattern is to encapsulate an | 
| 118 | * operation that you want to perform on the elements of a data | 
| 119 | * structure. In this way, you can change the operation being | 
| 120 | * performed on a structure without the need of changing the | 
| 121 | * classes of the elements that you are operating on. Using a | 
| 122 | * Visitor pattern allows you to decouple the classes for the data | 
| 123 | * structure and the algorithms used upon them | 
| 124 | * </p> | 
| 125 | * @param v visitor | 
| 126 | */ | 
| 127 | virtual void accept(BaseVisitor* v) = 0; | 
| 128 |  | 
| 129 | /** | 
| 130 | * Returns the previous value of this ShortRangeInteraction | 
| 131 | * @return the value of this ShortRangeInteraction | 
| 132 | */ | 
| 133 | virtual RealType getPrevValue(); | 
| 134 |  | 
| 135 | /** | 
| 136 | * Returns the current value of this ShortRangeInteraction | 
| 137 | * @return the current value of this ShortRangeInteraction | 
| 138 | */ | 
| 139 | virtual RealType getValue(); | 
| 140 |  | 
| 141 | /** | 
| 142 | * Returns the value of this ShortRangeInteraction in specified snapshot | 
| 143 | * @return the value of this ShortRangeInteraction | 
| 144 | * @param snapshotNo | 
| 145 | */ | 
| 146 | virtual RealType getValue(int snapshotNo) = 0; | 
| 147 |  | 
| 148 | virtual std::vector<Atom*> getAtoms() { return atoms_; } | 
| 149 |  | 
| 150 | /** | 
| 151 | * Adds property into property map | 
| 152 | * @param genData GenericData to be added into PropertyMap | 
| 153 | */ | 
| 154 | void addProperty(GenericData* genData); | 
| 155 |  | 
| 156 | /** | 
| 157 | * Removes property from PropertyMap by name | 
| 158 | * @param propName the name of property to be removed | 
| 159 | */ | 
| 160 | void removeProperty(const std::string& propName); | 
| 161 |  | 
| 162 | /** | 
| 163 | * clear all of the properties | 
| 164 | */ | 
| 165 | void clearProperties(); | 
| 166 |  | 
| 167 | /** | 
| 168 | * Returns all names of properties | 
| 169 | * @return all names of properties | 
| 170 | */ | 
| 171 | std::vector<std::string> getPropertyNames(); | 
| 172 |  | 
| 173 | /** | 
| 174 | * Returns all of the properties in PropertyMap | 
| 175 | * @return all of the properties in PropertyMap | 
| 176 | */ | 
| 177 | std::vector<GenericData*> getProperties(); | 
| 178 |  | 
| 179 | /** | 
| 180 | * Returns property | 
| 181 | * @param propName name of property | 
| 182 | * @return a pointer point to property with propName. If no property named propName | 
| 183 | * exists, return NULL | 
| 184 | */ | 
| 185 | GenericData* getPropertyByName(const std::string& propName); | 
| 186 |  | 
| 187 | protected: | 
| 188 |  | 
| 189 | ShortRangeInteraction(); | 
| 190 | ShortRangeInteraction(const ShortRangeInteraction& sri); | 
| 191 | ShortRangeInteraction& operator=(const ShortRangeInteraction& sri); | 
| 192 |  | 
| 193 | SnapshotManager* snapshotMan_; | 
| 194 | std::vector<Atom*> atoms_; | 
| 195 |  | 
| 196 | int globalIndex_; | 
| 197 | int localIndex_; | 
| 198 |  | 
| 199 | private: | 
| 200 |  | 
| 201 | PropertyMap properties_; | 
| 202 | }; | 
| 203 |  | 
| 204 | }//end namespace OpenMD | 
| 205 | #endif //PRIMITIVES_STUNTDOUBLE_HPP |