QMCPACK
DynamicCoordinates.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2020 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 /** @file DynamicCoordinates.h
14  */
15 #ifndef QMCPLUSPLUS_DYNAMICCOORDINATES_H
16 #define QMCPLUSPLUS_DYNAMICCOORDINATES_H
17 
18 #include <memory>
19 #include "Configuration.h"
22 
23 namespace qmcplusplus
24 {
25 class ResourceCollection;
26 
27 /** enumerator for DynamicCoordinates kinds
28  */
30 {
31  DC_POS, // SoA positions
32  DC_POS_OFFLOAD, // SoA positions with OpenMP offload
33 };
34 
35 /** quantum variables of all the particles
36  */
38 {
39 public:
44 
46 
47  DynamicCoordinates(const DynamicCoordinates&) = default;
49 
51 
52  virtual ~DynamicCoordinates() = default;
53 
54  virtual std::unique_ptr<DynamicCoordinates> makeClone() = 0;
55 
56  /** resize internal storages based on the number of particles
57  * @param n the number of particles
58  */
59  virtual void resize(size_t n) = 0;
60  /// return the number of particles
61  virtual size_t size() const = 0;
62 
63  /// overwrite the positions of all the particles.
64  virtual void setAllParticlePos(const ParticlePos& R) = 0;
65  /// overwrite the position of one the particle.
66  virtual void setOneParticlePos(const PosType& pos, size_t iat) = 0;
67  /** copy the active positions of particles with a uniform id in all the walkers to a single internal buffer.
68  * @param coords_list a batch of DynamicCoordinates
69  * @param iat paricle id, uniform across coords_list
70  * @param new_positions proposed positions
71  */
73  size_t iat,
74  const std::vector<PosType>& new_positions) const
75  {
76  assert(this == &coords_list.getLeader());
77  }
78 
79  /** overwrite the positions of particles with a uniform id in all the walkers upon acceptance.
80  * @param coords_list a batch of DynamicCoordinates
81  * @param iat paricle id, uniform across coords_list
82  * @param new_positions proposed positions
83  * @param isAccepted accept/reject info
84  */
85  virtual void mw_acceptParticlePos(const RefVectorWithLeader<DynamicCoordinates>& coords_list,
86  size_t iat,
87  const std::vector<PosType>& new_positions,
88  const std::vector<bool>& isAccepted) const = 0;
89 
90  /// all particle position accessor
91  virtual const PosVectorSoa& getAllParticlePos() const = 0;
92  /// one particle position accessor
93  virtual PosType getOneParticlePos(size_t iat) const = 0;
94 
95  /// secure internal data consistency after p-by-p moves
96  virtual void donePbyP() {}
97 
98  /// initialize a shared resource and hand it to a collection
99  virtual void createResource(ResourceCollection& collection) const {}
100 
101  /// acquire a shared resource from a collection
102  virtual void acquireResource(ResourceCollection& collection,
103  const RefVectorWithLeader<DynamicCoordinates>& coords_list) const
104  {}
105 
106  /// return a shared resource to a collection
107  virtual void releaseResource(ResourceCollection& collection,
108  const RefVectorWithLeader<DynamicCoordinates>& coords_list) const
109  {}
110 
111 protected:
112  /// type of dynamic coordinates
114 };
115 } // namespace qmcplusplus
116 #endif
virtual void createResource(ResourceCollection &collection) const
initialize a shared resource and hand it to a collection
DynamicCoordinateKind
enumerator for DynamicCoordinates kinds
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
virtual void setOneParticlePos(const PosType &pos, size_t iat)=0
overwrite the position of one the particle.
QTBase::RealType RealType
Definition: Configuration.h:58
PtclOnLatticeTraits::ParticlePos ParticlePos
virtual void mw_copyActivePos(const RefVectorWithLeader< DynamicCoordinates > &coords_list, size_t iat, const std::vector< PosType > &new_positions) const
copy the active positions of particles with a uniform id in all the walkers to a single internal buff...
virtual const PosVectorSoa & getAllParticlePos() const =0
all particle position accessor
quantum variables of all the particles
virtual void donePbyP()
secure internal data consistency after p-by-p moves
Soa Container for D-dim vectors.
virtual void acquireResource(ResourceCollection &collection, const RefVectorWithLeader< DynamicCoordinates > &coords_list) const
acquire a shared resource from a collection
SoA adaptor class for Vector<TinyVector<T,D> >
virtual std::unique_ptr< DynamicCoordinates > makeClone()=0
virtual void setAllParticlePos(const ParticlePos &R)=0
overwrite the positions of all the particles.
Attaches a unit to a Vector for IO.
virtual ~DynamicCoordinates()=default
virtual void resize(size_t n)=0
resize internal storages based on the number of particles
DynamicCoordinateKind getKind() const
DynamicCoordinates & operator=(const DynamicCoordinates &)=delete
virtual size_t size() const =0
return the number of particles
QTBase::PosType PosType
Definition: Configuration.h:61
const DynamicCoordinateKind variable_kind_
type of dynamic coordinates
DynamicCoordinates(const DynamicCoordinateKind kind_in)
virtual void releaseResource(ResourceCollection &collection, const RefVectorWithLeader< DynamicCoordinates > &coords_list) const
return a shared resource to a collection
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
VectorSoaContainer< RealType, QMCTraits::DIM > PosVectorSoa
virtual PosType getOneParticlePos(size_t iat) const =0
one particle position accessor
virtual void mw_acceptParticlePos(const RefVectorWithLeader< DynamicCoordinates > &coords_list, size_t iat, const std::vector< PosType > &new_positions, const std::vector< bool > &isAccepted) const =0
overwrite the positions of particles with a uniform id in all the walkers upon acceptance.