~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to lib/atc/GhostManager.h

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2013-11-20 22:41:36 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20131120224136-tzx7leh606fqnckm
Tags: 0~20131119.git7162cf0-1
* [e65b919] Imported Upstream version 0~20131119.git7162cf0
* [f7bddd4] Fix some problems, introduced by upstream recently.
* [3616dfc] Use wrap-and-sort script.
* [7e92030] Ignore quilt dir

Show diffs side-by-side

added added

removed removed

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