OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ParticleCashedLayout.h
Go to the documentation of this file.
1//
2// Class ParticleCashedLayout
3// Please note: for the time being this class is *not* used! But since it
4// might be used in future projects, we keep this file.
5//
6// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7// All rights reserved
8//
9// This file is part of OPAL.
10//
11// OPAL is free software: you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation, either version 3 of the License, or
14// (at your option) any later version.
15//
16// You should have received a copy of the GNU General Public License
17// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18//
19
20#ifndef PARTICLE_CASHED_LAYOUT_H
21#define PARTICLE_CASHED_LAYOUT_H
22
23/*
24 * ParticleCashedLayout - particle layout based on spatial decomposition,
25 * with particle interaction (nearest-neighbor with cutoff)
26 *
27 * This is a specialized version of ParticleLayout, which places particles
28 * on processors based on their spatial location relative to a fixed grid.
29 * In particular, this can maintain particles on processors based on a
30 * specified FieldLayout or RegionLayout, so that particles are always on
31 * the same node as the node containing the Field region to which they are
32 * local. This may also be used if there is no associated Field at all,
33 * in which case a grid is selected based on an even distribution of
34 * particles among processors.
35 */
36
37// include files
41#include "Region/RegionLayout.h"
42
43#include <vector>
44#include <iostream>
45
46// forward declarations
47class UserList;
48template <unsigned Dim> class FieldLayout;
49template <unsigned Dim, class T> class UniformCartesian;
50template <class T, unsigned Dim, class Mesh> class ParticleCashedLayout;
51template <class T, unsigned Dim, class Mesh>
52std::ostream& operator<<(std::ostream&, const ParticleCashedLayout<T,Dim,Mesh>&);
53
54
55// ParticleCashedLayout class definition. Template parameters are the type
56// and dimension of the ParticlePos object used for the particles. The
57// dimension of the position must match the dimension of the FieldLayout
58// object used in this particle layout, if any.
59// Optional template parameter for the mesh type
60template < class T, unsigned Dim, class Mesh=UniformCartesian<Dim,T> >
61class ParticleCashedLayout : public ParticleSpatialLayout<T, Dim, Mesh> {
62
63public:
64
68
69 // type of attributes this layout should use for position, ID, and rad
73
74public:
75 // constructor: The Field layout to which we match our particle's
76 // locations.
78
79 // constructor: this one also takes a Mesh
81
82 // a similar constructor, but this one takes a RegionLayout.
84
85 // a default constructor ... in this case, no layout will
86 // be assumed by this class. A layout may be given later via the
87 // 'setLayout' method, either as a FieldLayout or as a RegionLayout.
89
90 // destructor
92
93 //
94 // Particle swapping/update routines
95 //
96
97 // Update the location and indices of all atoms in the given IpplParticleBase
98 // object. This handles swapping particles among processors if
99 // needed, and handles create and destroy requests. When complete,
100 // all nodes have correct layout information.
102 const ParticleAttrib<char>* canSwap=0);
103
104
105 // Retrieve a Forward-style iterator for the beginning and end of the
106 // Nth (local) particle's nearest-neighbor pairlist.
107 // If this is the first call of this
108 // method after update(), this must make sure up-to-date info on particles
109 // from neighboring nodes is available.
111
112 // specify the interaction radius ... two versions, one which gives a
113 // single value for all atoms
114 void setInteractionRadius(const T& r) {
115 InterRadius = r;
116 return;
117 }
118
119 // Return the maximum interaction radius of the entire system. This is
120 // the value from the most recent call to update()
122
123 // Return the interaction radius of atom i.
124 T getInteractionRadius(unsigned /*i*/) {
125 return InterRadius;
126 }
127
128 // directly set NeedGhostSwap flag to indicate whether this is needed
129 // useful when a ParticleAttrib other than position R is modified and
130 // we do not need to call update().
131 void setNeedGhostSwap(bool cond=true) {
132 NeedGhostSwap = cond;
133 }
134
135 //
136 // virtual functions for FieldLayoutUser's (and other UserList users)
137 //
138
139 // Repartition onto a new layout
140 virtual void Repartition(UserList *);
141
142private:
143 // information needed to compute which ghost particles to send/receive
148
149 // interaction radius data. If the attribute pointer is null, use the
150 // scalar value instead.
151 // also, the maximum interaction radius for the local particles, and for all
152 // the particles
154
155 // perform common constructor tasks
156 void setup();
157
158 // recalculate where we need to send ghost particles for building
159 // nearest-neighbor interaction lists
161
162 // recalculate where we need to send ghost particles for building
163 // nearest-neighbor interaction lists
164 // special version which accounts for periodic boundary conditions
165 void rebuild_interaction_data(const bool periodicBC[2*Dim]);
166
167 // copy particles to other nodes for pairlist computation. The arguments
168 // are the current number of local particles, and the IpplParticleBase object.
169 // This will also calculate the pairlists if necessary.
170 void swap_ghost_particles(unsigned,
172
173 // copy particles to other nodes for pairlist computation. The arguments
174 // are the current number of local particles, and the IpplParticleBase object.
175 // This will also calculate the pairlists if necessary.
176 // special version to take account of periodic boundaries
177 void swap_ghost_particles(unsigned,
179 const bool periodicBC[2*Dim]);
180
181 // change the value of the maximum local interaction radius
183
184 // Return the maximum interaction radius of the local particles.
186};
187
189
190#endif
const unsigned Dim
std::ostream & operator<<(std::ostream &, const ParticleCashedLayout< T, Dim, Mesh > &)
Definition: Mesh.h:35
void getCashedParticles(IpplParticleBase< ParticleCashedLayout< T, Dim, Mesh > > &)
void swap_ghost_particles(unsigned, IpplParticleBase< ParticleCashedLayout< T, Dim, Mesh > > &)
ParticleLayout< T, Dim >::Index_t Index_t
void update(IpplParticleBase< ParticleCashedLayout< T, Dim, Mesh > > &p, const ParticleAttrib< char > *canSwap=0)
void setInteractionRadius(const T &r)
virtual void Repartition(UserList *)
ParticleInteractAttrib< T > ParticleInterRadius_t
ParticleInteractAttrib< Index_t > ParticleIndex_t
ParticleLayout< T, Dim >::SingleParticlePos_t SingleParticlePos_t
ParticleInteractAttrib< SingleParticlePos_t > ParticlePos_t
void setNeedGhostSwap(bool cond=true)
void setMaxInteractionRadius(T maxval)
unsigned Index_t