| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <string> | ||
| 4 | #include <yaml-cpp/yaml.h> | ||
| 5 | |||
| 6 | #include "types.hpp" | ||
| 7 | |||
| 8 | class System; | ||
| 9 | struct Particle; | ||
| 10 | |||
| 11 | class External { | ||
| 12 | public: | ||
| 13 | enum Props : int { | ||
| 14 | DOES_E = 1 << 0, | ||
| 15 | DOES_F = 1 << 1, | ||
| 16 | }; | ||
| 17 | int props = 0; | ||
| 18 | External(int props); | ||
| 19 | ✗ | virtual ~External() = default; | |
| 20 | bool doesE(); | ||
| 21 | bool doesF(); | ||
| 22 | |||
| 23 | virtual double operator()(Particle &p) = 0; | ||
| 24 | }; | ||
| 25 | |||
| 26 | class TestExternal : public External { | ||
| 27 | public: | ||
| 28 | TestExternal(System *s, const YAML::Node &c); | ||
| 29 | double operator()(Particle &p); | ||
| 30 | }; | ||
| 31 | |||
| 32 | class Const : public External { | ||
| 33 | public: | ||
| 34 | int d; | ||
| 35 | Real mag; | ||
| 36 | Const(System *s, const YAML::Node &c); | ||
| 37 | double operator()(Particle &p); | ||
| 38 | }; | ||
| 39 | |||
| 40 | class PiecewiseLinear : public External { | ||
| 41 | public: | ||
| 42 | int d; | ||
| 43 | Real pos1; | ||
| 44 | Real pos2; | ||
| 45 | Real posDeltaInv; | ||
| 46 | Real E1; | ||
| 47 | Real E2; | ||
| 48 | Real F; | ||
| 49 | PiecewiseLinear(System *s, const YAML::Node &c); | ||
| 50 | double operator()(Particle &p); | ||
| 51 | }; | ||
| 52 | |||
| 53 | class WallsHard : public External { | ||
| 54 | public: | ||
| 55 | Vec &L; | ||
| 56 | int d; | ||
| 57 | Real width; | ||
| 58 | WallsHard(System *s, const YAML::Node &c); | ||
| 59 | double operator()(Particle &p); | ||
| 60 | }; | ||
| 61 | |||
| 62 | class WallLJ : public External { | ||
| 63 | public: | ||
| 64 | Vec &L; | ||
| 65 | int d; | ||
| 66 | Real cutoff; | ||
| 67 | Vec pos; | ||
| 68 | WallLJ(System *s, const YAML::Node &c); | ||
| 69 | double operator()(Particle &p); | ||
| 70 | }; | ||
| 71 | |||
| 72 | class MovingInterface : public External { | ||
| 73 | public: | ||
| 74 | double &t; | ||
| 75 | int d; | ||
| 76 | Real B; | ||
| 77 | Real kappa; | ||
| 78 | Real v; | ||
| 79 | Real posStart; | ||
| 80 | MovingInterface(System *s, const YAML::Node &c); | ||
| 81 | double operator()(Particle &p); | ||
| 82 | }; | ||
| 83 | |||
| 84 | class FixedLJ : public External { | ||
| 85 | public: | ||
| 86 | Vec &L; | ||
| 87 | Vec pos; | ||
| 88 | Real cutoff; | ||
| 89 | FixedLJ(System *s, const YAML::Node &c); | ||
| 90 | double operator()(Particle &p); | ||
| 91 | }; | ||
| 92 | |||
| 93 | class FixedHard : public External { | ||
| 94 | public: | ||
| 95 | Vec &L; | ||
| 96 | Vec pos; | ||
| 97 | Real sigma; | ||
| 98 | FixedHard(System *s, const YAML::Node &c); | ||
| 99 | double operator()(Particle &p); | ||
| 100 | }; | ||
| 101 | |||
| 102 | class HarmonicTrapPlanar : public External { | ||
| 103 | public: | ||
| 104 | int d; | ||
| 105 | Real A; | ||
| 106 | Real pos; | ||
| 107 | HarmonicTrapPlanar(System *s, const YAML::Node &c); | ||
| 108 | double operator()(Particle &p); | ||
| 109 | }; | ||
| 110 | |||
| 111 | class Sine : public External { | ||
| 112 | public: | ||
| 113 | int dMod; | ||
| 114 | int dForce; | ||
| 115 | Real L; | ||
| 116 | Real A; | ||
| 117 | Real k; | ||
| 118 | Real phase; | ||
| 119 | Real Linv2pik; | ||
| 120 | Real ALby2pik; | ||
| 121 | Sine(System *s, const YAML::Node &c); | ||
| 122 | double operator()(Particle &p); | ||
| 123 | }; | ||
| 124 | |||
| 125 | class ExternalTable : public External { | ||
| 126 | public: | ||
| 127 | ArrayI bins; | ||
| 128 | ArrayI stride; | ||
| 129 | Vec dr; | ||
| 130 | std::vector<Vec> Fext; | ||
| 131 | |||
| 132 | ExternalTable(System *s, const YAML::Node &c); | ||
| 133 | double operator()(Particle &p); | ||
| 134 | int index(const Vec &r); | ||
| 135 | }; | ||
| 136 | |||
| 137 | 108 | class PairFunction { | |
| 138 | public: | ||
| 139 | ✗ | virtual ~PairFunction() = default; | |
| 140 | virtual double operator()(Particle &p1, Particle &p2) = 0; | ||
| 141 | }; | ||
| 142 | |||
| 143 | 108 | class TripleFunction { | |
| 144 | public: | ||
| 145 | ✗ | virtual ~TripleFunction() = default; | |
| 146 | virtual double operator()(Particle &p1, Particle &p2, Particle &p3) = 0; | ||
| 147 | }; | ||
| 148 | |||
| 149 | class Internal : public PairFunction, public TripleFunction { | ||
| 150 | public: | ||
| 151 | enum Props : int { | ||
| 152 | DOES_E = 1 << 0, | ||
| 153 | DOES_F = 1 << 1, | ||
| 154 | THREEBODY = 1 << 2, | ||
| 155 | NEEDS_GATHER = 1 << 3, | ||
| 156 | }; | ||
| 157 | int props = 0; | ||
| 158 | double range; | ||
| 159 | bool newton3; | ||
| 160 | bool gather = false; | ||
| 161 | Vec &L; | ||
| 162 | Internal(int props, double range, bool newton3, System *s); | ||
| 163 | ✗ | virtual ~Internal() = default; | |
| 164 | |||
| 165 | 108 | inline bool doesE() { return props & DOES_E; } | |
| 166 | 108 | inline bool doesF() { return props & DOES_F; } | |
| 167 |
5/6✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 678 times.
✓ Branch 4 taken 3694 times.
✓ Branch 5 taken 2977 times.
✓ Branch 6 taken 1969 times.
|
9402 | inline bool threebody() { return props & THREEBODY; } |
| 168 |
3/4✓ Branch 0 taken 631 times.
✓ Branch 1 taken 3741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4946 times.
|
9318 | inline bool needsGather() { return props & NEEDS_GATHER; } |
| 169 | |||
| 170 | 3741 | virtual void reset() {} | |
| 171 | |||
| 172 | ✗ | virtual double operator()(Particle &p) { return 0.; } | |
| 173 | virtual double operator()(Particle &p1, Particle &p2) = 0; | ||
| 174 | ✗ | virtual double operator()(Particle &p1, Particle &p2, Particle &p3) { return 0.; } | |
| 175 | }; | ||
| 176 | |||
| 177 | class TestInternal : public Internal { | ||
| 178 | public: | ||
| 179 | bool doThreebody; | ||
| 180 | double rangesq; | ||
| 181 | TestInternal(System *s, const YAML::Node &c, bool newton3); | ||
| 182 | double operator()(Particle &p1, Particle &p2); | ||
| 183 | double operator()(Particle &p1, Particle &p2, Particle &p3); | ||
| 184 | }; | ||
| 185 | |||
| 186 | class Ideal : public Internal { | ||
| 187 | public: | ||
| 188 | Ideal(System *s, const YAML::Node &c, bool newton3); | ||
| 189 | double operator()(Particle &p1, Particle &p2); | ||
| 190 | }; | ||
| 191 | |||
| 192 | class Hard : public Internal { | ||
| 193 | public: | ||
| 194 | Hard(System *s, const YAML::Node &c, bool newton3); | ||
| 195 | double operator()(Particle &p1, Particle &p2); | ||
| 196 | }; | ||
| 197 | |||
| 198 | class SquareShoulder : public Internal { | ||
| 199 | public: | ||
| 200 | double rangesq; | ||
| 201 | double epsilon; | ||
| 202 | SquareShoulder(System *s, const YAML::Node &c, bool newton3); | ||
| 203 | double operator()(Particle &p1, Particle &p2); | ||
| 204 | }; | ||
| 205 | |||
| 206 | class LJ : public Internal { | ||
| 207 | public: | ||
| 208 | double rangesq; | ||
| 209 | double Eshift; | ||
| 210 | LJ(System *s, const YAML::Node &c, bool newton3); | ||
| 211 | double operator()(Particle &p1, Particle &p2); | ||
| 212 | }; | ||
| 213 | |||
| 214 | class WCA : public Internal { | ||
| 215 | public: | ||
| 216 | double rangesq; | ||
| 217 | WCA(System *s, const YAML::Node &c, bool newton3); | ||
| 218 | double operator()(Particle &p1, Particle &p2); | ||
| 219 | }; | ||
| 220 | |||
| 221 | class Yukawa : public Internal { | ||
| 222 | public: | ||
| 223 | double kappa; | ||
| 224 | Yukawa(System *s, const YAML::Node &c, bool newton3); | ||
| 225 | double operator()(Particle &p1, Particle &p2); | ||
| 226 | }; | ||
| 227 | |||
| 228 | class Stockmayer : public Internal { | ||
| 229 | public: | ||
| 230 | double mu; | ||
| 231 | double musq; | ||
| 232 | double epsilon6; | ||
| 233 | Stockmayer(System *s, const YAML::Node &c, bool newton3); | ||
| 234 | double operator()(Particle &p1, Particle &p2); | ||
| 235 | }; | ||
| 236 | |||
| 237 | class GayBerne : public Internal { | ||
| 238 | public: | ||
| 239 | double rangesq; | ||
| 240 | double kappa; | ||
| 241 | double kappaprime; | ||
| 242 | double chi; | ||
| 243 | double chiprime; | ||
| 244 | GayBerne(System *s, const YAML::Node &c, bool newton3); | ||
| 245 | double operator()(Particle &p1, Particle &p2); | ||
| 246 | }; | ||
| 247 | |||
| 248 | class SW : public Internal { | ||
| 249 | public: | ||
| 250 | Real a; | ||
| 251 | Real A; | ||
| 252 | Real B; | ||
| 253 | Real lambda; | ||
| 254 | Real gamma; | ||
| 255 | Real costheta0; | ||
| 256 | Real asq; | ||
| 257 | SW(System *s, const YAML::Node &c, bool newton3); | ||
| 258 | double operator()(Particle &p1, Particle &p2); | ||
| 259 | double operator()(Particle &p1, Particle &p2, Particle &p3); | ||
| 260 | double threebody(Particle &p1, Particle &p2, Particle &p3, int update = 0); | ||
| 261 | }; | ||
| 262 | |||
| 263 | class SWOptimized : public Internal { | ||
| 264 | public: | ||
| 265 | std::vector<Particle> &particles; | ||
| 266 | std::vector<double> h; | ||
| 267 | std::vector<Vec> s; | ||
| 268 | std::vector<Eigen::Matrix<double, DIM, DIM>> T; | ||
| 269 | Real a; | ||
| 270 | Real A; | ||
| 271 | Real B; | ||
| 272 | Real lambda; | ||
| 273 | Real gamma; | ||
| 274 | Real costheta0; | ||
| 275 | Real asq; | ||
| 276 | SWOptimized(System *s, const YAML::Node &c, bool newton3); | ||
| 277 | void reset(); | ||
| 278 | double operator()(Particle &p); | ||
| 279 | double operator()(Particle &p1, Particle &p2); | ||
| 280 | double accumulationPhase(Particle &p1, Particle &p2); | ||
| 281 | double gatherPhase(Particle &p1, Particle &p2); | ||
| 282 | }; | ||
| 283 | |||
| 284 | class PotentialFactory { | ||
| 285 | public: | ||
| 286 | static std::map<std::string, External *(*)(System *s, const YAML::Node &c)> externalMap; | ||
| 287 | static std::map<std::string, Internal *(*)(System *s, const YAML::Node &c, bool newton3)> | ||
| 288 | internalMap; | ||
| 289 | static External *createExternal(System *s, const YAML::Node &externalConfig); | ||
| 290 | static std::vector<External *> createExternals(System *s, const YAML::Node &externalsConfig); | ||
| 291 | static Internal *createInternal(System *s, const YAML::Node &internalConfig, bool newton3); | ||
| 292 | }; | ||
| 293 |