OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ParticleLayout.h
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 *
4 * The IPPL Framework
5 *
6 *
7 * Visit http://people.web.psi.ch/adelmann/ for more details
8 *
9 ***************************************************************************/
10
11#ifndef PARTICLE_LAYOUT_H
12#define PARTICLE_LAYOUT_H
13
14/*
15 * ParticleLayout - base class for all particle layout classes.
16 *
17 * This class is used as the generic base class for all classes
18 * which maintain the information on where all the particles are located
19 * on a parallel machine. It is responsible for performing particle
20 * swapping and load balancing, and for determining pair lists.
21 *
22 * If more general layout information is needed, such as the global -> local
23 * mapping for each particle, then derived classes must provide this info.
24 *
25 * When particles are created or destroyed, this class is also responsible
26 * for determining where particles are to be created, gathering this
27 * information, and recalculating the global indices of all the particles.
28 * For consistency, creation and destruction requests are cached, and then
29 * performed all in one step when the update routine is called.
30 *
31 * Derived classes must provide the following:
32 * 1) Specific version of update and loadBalance. These are not virtual,
33 * as this class is used as a template parameter (instead of being
34 * assigned to a base class pointer).
35 * 2) Internal storage to maintain their specific layout mechanism
36 * 3) the definition of a class pair_iterator, and a function
37 * void getPairlist(int, pair_iterator&, pair_iterator&) to get a
38 * begin/end iterator pair to access the local neighbor of the Nth
39 * local atom. This is not a virtual function, it is a requirement of
40 * the templated class for use in other parts of the code.
41 */
42
43// include files
45
46
47// forward declarations
48template<class T, unsigned Dim> class Vektor;
49
50
51// ParticleLayout class definition. Template parameters are the type
52// and dimension of the ParticlePos object used for the particles.
53template<class T, unsigned Dim>
55
56public:
57 // useful enumerations
58 enum { Dimension = Dim }; // dim of coord data
59 enum UpdateFlags { SWAP, BCONDS, NUMFLAGS, OPTDESTROY, ALL }; // update opts
60
61 // useful typedefs common to all layouts
62 typedef T Position_t;
63 typedef unsigned Index_t;
65
66 // in addition, all subclasses must provide a typedef or class definition
67 // for a type 'pair_iterator', which iterates over lists of 'pair_t' objs,
68 // and typedefs for the ParticlePos_t and ParticleIndex_t types.
69
70public:
71 // constructor and destructor: no arguments
74
75 // set the flags used to indicate what to do during the update
76 void setUpdateFlag(UpdateFlags f, bool val) {
77 if (f == ALL) {
78 UpdateOptions = (~0);
79 } else {
80 unsigned int mask = (1 << f);
81 UpdateOptions = (val ? (UpdateOptions|mask) : (UpdateOptions&(~mask)));
82 }
83 }
84
85 // get the flags used to indicate what to do during the update
86 bool getUpdateFlag(UpdateFlags f) const {
87 return (f==ALL ? (UpdateOptions==(~0u)) : ((UpdateOptions & (1u << f))!=0));
88 }
89
90 // get the boundary conditions container
92
93 // copy over the given boundary conditions
94 void setBConds(const ParticleBConds<T,Dim>& bc) { BoundConds = bc; }
95
96protected:
97 // apply the given boundary conditions to the given set of n particle
98 // positions. This modifies the position values based on the BC type.
99 //mwerks template<class PPT, class NDI>
100 //mwerks void apply_bconds(unsigned, PPT&, const ParticleBConds<T,Dim>&, const NDI&);
102 // Apply the given boundary conditions to the current particle positions.
103 // PPT is the type of particle position attribute container, and NDI is
104 // the type of index object (NDIndex or NDRegion)
105 template<class PPT, class NDI>
106 void apply_bconds(unsigned n, PPT& R,
107 const ParticleBConds<T,Dim>& bcs,
108 const NDI& nr) {
109
110 // apply boundary conditions to the positions
111 for (unsigned int i=0; i < n; ++i)
112 for (unsigned int j=0; j < Dim; j++)
113 R[i][j] = bcs.apply(R[i][j], j, nr);
114 }
115
116private:
117 // the list of boundary conditions for this set of particles
119
120 // flags indicating what should be updated
121 unsigned int UpdateOptions;
122};
123
125
126#endif // PARTICLE_LAYOUT_H
127
128/***************************************************************************
129 * $RCSfile: ParticleLayout.h,v $ $Author: adelmann $
130 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:29 $
131 * IPPL_VERSION_ID: $Id: ParticleLayout.h,v 1.1.1.1 2003/01/23 07:40:29 adelmann Exp $
132 ***************************************************************************/
const int nr
Definition: ClassicRandom.h:24
const unsigned Dim
Definition: Vektor.h:32
T apply(const T t, const unsigned d, const NDRegion< T, Dim > &nr) const
void apply_bconds(unsigned n, PPT &R, const ParticleBConds< T, Dim > &bcs, const NDI &nr)
void setUpdateFlag(UpdateFlags f, bool val)
ParticleBConds< T, Dim > & getBConds()
void setBConds(const ParticleBConds< T, Dim > &bc)
bool getUpdateFlag(UpdateFlags f) const
ParticleBConds< T, Dim > BoundConds
unsigned Index_t
Vektor< T, Dim > SingleParticlePos_t
unsigned int UpdateOptions