1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
|
#ifndef GHOST_MANAGER_H
#define GHOST_MANAGER_H
// ATC headers
#include "MatrixLibrary.h"
#include "PerAtomQuantityLibrary.h"
#include "TimeIntegrator.h"
#include "ATC_TypeDefs.h"
namespace ATC {
// forward declarations
class ATC_Method;
class GhostModifier;
class LammpsInterface;
/**
* @class GhostManager
* @brief Manages methods for modifying ghost atoms
*/
class GhostManager {
public:
/** types of ghost boundary conditions in momentum */
enum BoundaryDynamicsType {
NO_BOUNDARY_DYNAMICS=0,
VERLET, // performs velocity-verlet
PRESCRIBED, // forces ghost locations to conform to interpolated finite element locations
DAMPED_HARMONIC, // turns ghost atoms into spring-mass-dashpot systems
DAMPED_LAYERS, // oer layer DAMPED_HARMONIC
COUPLED, // applies a spring-dashpot force to the ghosts
SWAP, // exchanges ghost and real atoms when they cross AtC boundaries
SWAP_VERLET // like above, but integrates the ghosts using velocity verlet
};
// constructor
GhostManager(ATC_Method * atc);
// destructor
virtual ~GhostManager();
/** parser/modifier */
virtual bool modify(int narg, char **arg);
/** create objects to implement requested numerical method */
virtual void construct_methods();
/** create and get necessary transfer operators */
virtual void construct_transfers();
/** pre time integration initialization of data */
virtual void initialize();
/** prior to lammps exchange */
virtual void pre_exchange();
/** Predictor phase, Verlet first step for velocity */
virtual void init_integrate_velocity(double dt);
/** Predictor phase, Verlet first step for position */
virtual void init_integrate_position(double dt);
/** set positions after integration */
virtual void post_init_integrate();
/** Corrector phase, Verlet second step for velocity */
virtual void final_integrate(double dt);
/** sets the boundary dynamics flag as desired */
void set_boundary_dynamics(BoundaryDynamicsType boundaryDynamics) {boundaryDynamics_ = boundaryDynamics;}
/** flag for reset */
bool need_reset() const {return needReset_;};
/** access to ATC method object */
ATC_Method * atc() {return atc_;};
protected:
/** pointer to routines that modify ghosts */
GhostModifier* ghostModifier_;
/** pointer to access ATC methods */
ATC_Method * atc_;
/** boundary dynamics method type */
BoundaryDynamicsType boundaryDynamics_;
/** flag for reset */
bool needReset_;
/** spring constant for some models */
std::vector<double> kappa_;
/** damping constant for some models */
std::vector<double> gamma_;
/** ratio between mass of ghost types and desired mass for some models */
std::vector<double> mu_;
private:
// DO NOT define this
GhostManager();
};
/**
* @class GhostModifier
* @brief Base class for objects which modify the ghost atoms, integrates ghost atoms using velocity-verlet if requested
*/
class GhostModifier {
public:
// constructor
GhostModifier(GhostManager * ghostManager);
// destructor
virtual ~GhostModifier();
/** create and get necessary transfer operators */
virtual void construct_transfers();
/** pre time integration initialization of data */
virtual void initialize(){};
/** Predictor phase, Verlet first step for velocity */
virtual void init_integrate_velocity(double dt);
/** Predictor phase, Verlet first step for position */
virtual void init_integrate_position(double dt);
/** set positions after integration */
virtual void post_init_integrate(){};
/** prior to lammps exchange */
virtual void pre_exchange(){};
/** Corrector phase, Verlet second step for velocity */
virtual void final_integrate(double dt);
/** sets the verlet integration flag as desired */
void set_integrate_atoms(bool integrateAtoms) {integrateAtoms_ = integrateAtoms;}
protected:
/** owning ghost manager */
GhostManager * ghostManager_;
/** object which integrates atoms */
AtomTimeIntegrator * atomTimeIntegrator_;
/** flag to perform velocity-verlet integration of ghosts */
bool integrateAtoms_;
private:
// DO NOT define this
GhostModifier();
};
/**
* @class GhostModifierPrescribed
* @brief sets ghost atom positions based on FE displacement
*/
class GhostModifierPrescribed : public GhostModifier {
public:
// constructor
GhostModifierPrescribed(GhostManager * ghostManager);
// destructor
virtual ~GhostModifierPrescribed(){};
/** create and get necessary transfer operators */
virtual void construct_transfers();
/** set positions after integration */
virtual void post_init_integrate();
protected:
/** positions of atoms */
PerAtomQuantity<double> * atomPositions_;
/** FE displacement at ghost locations */
PerAtomQuantity<double> * atomFeDisplacement_;
/** atom reference positions */
PerAtomQuantity<double> * atomRefPositions_;
private:
// DO NOT define this
GhostModifierPrescribed();
};
/**
* @class GhostModifierDampedHarmonic
* @brief Integrates ghost atoms using velocity-verlet with a damped harmonic force
*/
class GhostModifierDampedHarmonic : public GhostModifierPrescribed {
public:
// constructor
GhostModifierDampedHarmonic(GhostManager * ghostManager,
const std::vector<double> & kappa,
const std::vector<double> & gamma,
const std::vector<double> & mu);
// destructor
virtual ~GhostModifierDampedHarmonic(){};
/** create and get necessary transfer operators */
virtual void construct_transfers();
#if true
/** Predictor phase, Verlet first step for velocity */
virtual void init_integrate_velocity(double dt);
/** Predictor phase, Verlet first step for position */
virtual void init_integrate_position(double dt);
#endif
/** set positions after integration */
virtual void post_init_integrate(){};
/** Corrector phase, Verlet second step for velocity */
virtual void final_integrate(double dt);
protected:
/** velocities of atoms */
PerAtomQuantity<double> * atomVelocities_;
/** FE velocity at ghost locations */
PerAtomQuantity<double> * atomFeVelocity_;
/** atom forces */
PerAtomQuantity<double> * atomForces_;
/** effective spring constant for potential */
double k0_;
/** spring constant */
const std::vector<double> & kappa_;
/** damping constant */
const std::vector<double> & gamma_;
/** ratio between mass of ghost types and desired mass */
const std::vector<double> & mu_;
// workspace
DENS_MAT _forces_;
private:
// DO NOT define this
GhostModifierDampedHarmonic();
};
/**
* @class GhostModifierDampedHarmonicLayers
* @brief Integrates ghost atoms using velocity-verlet with a damped harmonic force based on which layer the atom resides in
*/
class GhostModifierDampedHarmonicLayers : public GhostModifierDampedHarmonic {
public:
// constructor
GhostModifierDampedHarmonicLayers(GhostManager * ghostManager,
const std::vector<double> & kappa,
const std::vector<double> & gamma,
const std::vector<double> & mu);
// destructor
virtual ~GhostModifierDampedHarmonicLayers(){};
/** create and get necessary transfer operators */
virtual void construct_transfers();
/** pre time integration initialization of data */
virtual void initialize();
/** Corrector phase, Verlet second step for velocity */
virtual void final_integrate(double dt);
protected:
// methods
/** compute distance of ghost atom to boundary */
void compute_distances();
/** sorting heuristics to identify layers */
int find_layers();
// data
/** distance from all ghost atoms to boundary, i.e. boundary face of containing element */
PerAtomQuantity<double> * ghostToBoundaryDistance_;
/** layer id for ghost atoms */
PerAtomQuantity<int> * layerId_;
private:
// DO NOT define this
GhostModifierDampedHarmonicLayers();
};
/**
* @class GhostIntegratorSwap
* @brief Integrates ghost atoms using velocity-verlet, and swaps atoms between ghost
* and internal depending on what element they are in
*/
class GhostIntegratorSwap : public GhostModifier {
public:
// constructor
GhostIntegratorSwap(GhostManager * ghostManager);
// destructor
virtual ~GhostIntegratorSwap(){};
/** create and get necessary transfer operators */
virtual void construct_transfers();
/** pre time integration initialization of data */
virtual void initialize();
/** prior to lammps exchange */
virtual void pre_exchange();
protected:
/** pointer to lammps interface */
LammpsInterface * lammpsInterface_;
/** internal element set */
const std::set<int> & elementSet_;
/** internal to element map */
PerAtomQuantity<int> * atomElement_;
/** ghost to element map */
PerAtomQuantity<int> * atomGhostElement_;
/** internal to atom map */
const Array<int> & internalToAtom_;
/** ghost to atom map */
const Array<int> & ghostToAtom_;
/** group bit for internal */
int groupbit_;
/** group bit for ghost */
int groupbitGhost_;
private:
// DO NOT define this
GhostIntegratorSwap();
};
};
#endif
|