1 /* ---------------------------------------------------------------------- 2 This is the 3 4 ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗████████╗███████╗ 5 ██║ ██║██╔════╝ ██╔════╝ ██╔════╝ ██║ ██║╚══██╔══╝██╔════╝ 6 ██║ ██║██║ ███╗██║ ███╗██║ ███╗███████║ ██║ ███████╗ 7 ██║ ██║██║ ██║██║ ██║██║ ██║██╔══██║ ██║ ╚════██║ 8 ███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║ ██║ ██║ ███████║ 9 ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝® 10 11 DEM simulation engine, released by 12 DCS Computing Gmbh, Linz, Austria 13 http://www.dcs-computing.com, office@dcs-computing.com 14 15 LIGGGHTS® is part of CFDEM®project: 16 http://www.liggghts.com | http://www.cfdem.com 17 18 Core developer and main author: 19 Christoph Kloss, christoph.kloss@dcs-computing.com 20 21 LIGGGHTS® is open-source, distributed under the terms of the GNU Public 22 License, version 2 or later. It is distributed in the hope that it will 23 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 24 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have 25 received a copy of the GNU General Public License along with LIGGGHTS®. 26 If not, see http://www.gnu.org/licenses . See also top-level README 27 and LICENSE files. 28 29 LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH, 30 the producer of the LIGGGHTS® software and the CFDEM®coupling software 31 See http://www.cfdem.com/terms-trademark-policy for details. 32 33 ------------------------------------------------------------------------- 34 Contributing author and copyright for this file: 35 (if not contributing author is listed, this file has been contributed 36 by the core developer) 37 38 Christoph Kloss (DCS Computing GmbH, Linz) 39 Christoph Kloss (JKU Linz) 40 Philippe Seil (JKU Linz) 41 42 Copyright 2012- DCS Computing GmbH, Linz 43 Copyright 2009-2012 JKU Linz 44 ------------------------------------------------------------------------- */ 45 46 #ifndef LMP_CUSTOM_VALUE_TRACKER_H 47 #define LMP_CUSTOM_VALUE_TRACKER_H 48 49 #include "associative_pointer_array.h" 50 #include "container.h" 51 #include "abstract_mesh.h" 52 #include <string> 53 #include <list> 54 #include <vector> 55 56 namespace LAMMPS_NS 57 { 58 59 /* ---------------------------------------------------------------------- */ 60 61 class CustomValueTracker : protected Pointers 62 { 63 public: 64 CustomValueTracker(LAMMPS *lmp); 65 CustomValueTracker(LAMMPS *lmp,AbstractMesh *_owner); 66 ~CustomValueTracker(); 67 68 // per-element properties 69 70 template<typename T> 71 T* addElementProperty(const char *_id, 72 const char* _comm, 73 const char* _ref, 74 const char *_restart, 75 int _scalePower = 1, 76 int _init_len = 0, 77 const char *_statistics = 0, 78 const double _weighting_factor = 1, 79 ScalarContainer<double> * const scale = NULL, 80 ScalarContainer<double> * const scaleAvg = NULL, 81 const bool _enable_favre = false); 82 83 template<typename T> 84 T* getElementProperty(const char *_id); 85 86 template<typename T> 87 T* getElementProperty(int _i); 88 89 inline ContainerBase* getElementPropertyBase(const char *_id); 90 inline ContainerBase* getElementPropertyBase(int i); 91 92 inline int getElementPropertyIndex(const char *_id); 93 94 template<typename T, typename U> 95 void setElementProperty(const char *_id, U def); 96 97 void removeElementProperty(const char *_id); 98 nElementProperties()99 inline int nElementProperties() 100 { return elementProperties_.size(); } 101 void check_element_property_consistency(int _len); 102 103 // global (e.g. mesh) properties 104 105 template<typename T> 106 T* addGlobalProperty(const char *_id, const char* _comm, const char* _ref, const char *_restart, int _scalePower = 1); 107 108 template<typename T> 109 T* getGlobalProperty(const char *_id); 110 111 template<typename T, typename U> 112 void setGlobalProperty(const char *_id, U def); 113 114 void removeGlobalProperty(const char *_id); 115 116 // operation with 117 // per-element properties 118 119 inline void copyElement(int from, int to); 120 inline void addUninitializedElement(); 121 inline void addZeroElement(); 122 inline void deleteAllElements(); 123 inline void deleteRestart(bool scale,bool translate,bool rotate); 124 inline void deleteElement(int i); 125 inline void deleteForwardElement(int i,bool scale,bool translate,bool rotate); 126 inline void deleteRestartElement(int i,bool scale,bool translate,bool rotate); 127 inline void deleteRestartGlobal(bool scale,bool translate,bool rotate); 128 void clearReverse(bool scale,bool translate,bool rotate); 129 130 void storeOrig(); 131 void resetToOrig(); 132 133 bool calcStatistics(); 134 135 template<typename T> 136 T* getAvgElementProperty(const char *_id); 137 138 template<typename T> 139 T* getMeanSquareElementProperty(const char *_id); 140 141 template<typename T> 142 T* getAvgAvgElementProperty(const char *_id); 143 144 template<typename T> 145 T* getAvgMeanSquareElementProperty(const char *_id); 146 147 void setWeightingFactor(double _weighting_factor); 148 149 inline void storeGlobalPropOrig(const char *_id); 150 inline void resetGlobalPropToOrig(const char *_id); 151 152 inline void moveElement(const int i, const double * const delta); 153 void move(const double * const vecTotal, const double * const vecIncremental); 154 void move(const double * const vecIncremental); 155 void rotate(const double * const totalQ, const double * const dQ); 156 void rotate(const double * const dQ); 157 void scale(double factor); 158 159 // buffer operations 160 161 inline int allElemBufSize(int operation,bool scale,bool translate,bool rotate) const; 162 inline int pushAllElemToBuffer(double *buf, int operation,bool scale,bool translate, bool rotate); 163 inline int popAllElemFromBuffer(double *buf, int operation,bool scale,bool translate, bool rotate); 164 165 inline int elemListBufSize(int n,int operation,bool scale,bool translate,bool rotate); 166 inline int pushElemListToBuffer(int n, int *list, int *wraplist, double *buf, int operation, std::list<std::string> * properties, double *dlo, double *dhi,bool scale,bool translate, bool rotate); 167 inline int popElemListFromBuffer(int first, int n, double *buf, int operation, std::list<std::string> * properties, bool scale,bool translate, bool rotate); 168 inline int pushElemListToBufferReverse(int first, int n, double *buf, int operation, std::list<std::string> * properties, bool scale,bool translate, bool rotate); 169 inline int popElemListFromBufferReverse(int n, int *list, double *buf, int operation, std::list<std::string> * properties, bool scale,bool translate, bool rotate); 170 171 inline int elemBufSize(int operation, std::list<std::string> * properties, bool scale,bool translate,bool rotate); 172 inline int pushElemToBuffer(int i, double *buf, int operation,bool scale,bool translate, bool rotate); 173 inline int popElemFromBuffer(double *buf, int operation,bool scale,bool translate, bool rotate); 174 175 inline int globalPropsBufSize(int operation,bool scale,bool translate,bool rotate); 176 inline int pushGlobalPropsToBuffer(double *buf, int operation,bool scale,bool translate, bool rotate); 177 inline int popGlobalPropsFromBuffer(double *buf, int operation,bool scale,bool translate, bool rotate); 178 179 private: 180 181 class AbstractMesh *ownerMesh_; 182 183 int capacityElement_; 184 class AssociativePointerArray<ContainerBase> elementProperties_; 185 class AssociativePointerArray<ContainerBase> globalProperties_; 186 class AssociativePointerArray<ContainerBase> globalProperties_orig_; 187 }; 188 189 // ************************************* 190 #include "custom_value_tracker_I.h" 191 // ************************************* 192 193 } /* LAMMPS_NS */ 194 #endif 195