QMCPACK
DistanceTable Class Referenceabstract

Abstract class to manage operations on pair data between two ParticleSets. More...

+ Inheritance diagram for DistanceTable:
+ Collaboration diagram for DistanceTable:

Public Types

using IndexType = QMCTraits::IndexType
 
using RealType = QMCTraits::RealType
 
using PosType = QMCTraits::PosType
 
using DistRow = Vector< RealType, aligned_allocator< RealType > >
 
using DisplRow = VectorSoaContainer< RealType, DIM >
 

Public Member Functions

 DistanceTable (const ParticleSet &source, const ParticleSet &target, DTModes modes)
 constructor using source and target ParticleSet More...
 
 DistanceTable (const DistanceTable &)=delete
 copy constructor. deleted More...
 
virtual ~DistanceTable ()=default
 virutal destructor More...
 
DTModes getModes () const
 get modes More...
 
void setModes (DTModes modes)
 set modes More...
 
const std::string & getName () const
 return the name of table More...
 
const ParticleSetget_origin () const
 returns the reference the origin particleset More...
 
size_t centers () const
 returns the number of centers More...
 
size_t targets () const
 returns the number of centers More...
 
size_t sources () const
 returns the number of source particles More...
 
virtual void evaluate (ParticleSet &P)=0
 evaluate the full Distance Table More...
 
virtual void mw_evaluate (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 
virtual void mw_recompute (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< bool > &recompute) const
 recompute multi walker internal data, recompute More...
 
virtual void move (const ParticleSet &P, const PosType &rnew, const IndexType iat, bool prepare_old=true)=0
 evaluate the temporary pair relations when a move is proposed More...
 
virtual void mw_move (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list, const std::vector< PosType > &rnew_list, const IndexType iat, bool prepare_old=true) const
 walker batched version of move. More...
 
virtual void update (IndexType jat)=0
 update the distance table by the pair relations from the temporal position. More...
 
virtual void updatePartial (IndexType jat, bool from_temp)
 fill partially the distance table by the pair relations from the temporary or old particle position. More...
 
virtual void mw_updatePartial (const RefVectorWithLeader< DistanceTable > &dt_list, IndexType jat, const std::vector< bool > &from_temp)
 walker batched version of updatePartial. More...
 
virtual void finalizePbyP (const ParticleSet &P)
 finalize distance table calculation after particle-by-particle moves if update() doesn't make the table up-to-date during p-by-p moves finalizePbyP takes action to bring the table up-to-date More...
 
virtual void mw_finalizePbyP (const RefVectorWithLeader< DistanceTable > &dt_list, const RefVectorWithLeader< ParticleSet > &p_list) const
 walker batched version of finalizePbyP If not DTModes::NEED_TEMP_DATA_ON_HOST, host distance table data is not updated at all during p-by-p Thus, a recompute is necessary to update the whole host distance table for consumers like the Coulomb potential. More...
 
virtual int get_first_neighbor (IndexType iat, RealType &r, PosType &dr, bool newpos) const =0
 find the first nearest neighbor More...
 
void print (std::ostream &os)
 
virtual void createResource (ResourceCollection &collection) const
 initialize a shared resource and hand it to a collection More...
 
virtual void acquireResource (ResourceCollection &collection, const RefVectorWithLeader< DistanceTable > &dt_list) const
 acquire a shared resource from a collection More...
 
virtual void releaseResource (ResourceCollection &collection, const RefVectorWithLeader< DistanceTable > &dt_list) const
 return a shared resource to a collection More...
 

Static Public Attributes

static constexpr unsigned DIM = OHMMS_DIM
 

Protected Attributes

const ParticleSetorigin_
 
const size_t num_sources_
 
const size_t num_targets_
 
const std::string name_
 name of the table More...
 
DTModes modes_
 operation modes defined by DTModes More...
 

Detailed Description

Abstract class to manage operations on pair data between two ParticleSets.

Each DistanceTable object is defined by Source and Target of ParticleSet types. This base class doesn't contain storage. It is intended for update/compute invoked by ParticleSet. Derived AA/AB classes handle the actual storage and data access.

Definition at line 38 of file DistanceTable.h.

Member Typedef Documentation

◆ DisplRow

Definition at line 47 of file DistanceTable.h.

◆ DistRow

Definition at line 46 of file DistanceTable.h.

◆ IndexType

Definition at line 43 of file DistanceTable.h.

◆ PosType

Definition at line 45 of file DistanceTable.h.

◆ RealType

Definition at line 44 of file DistanceTable.h.

Constructor & Destructor Documentation

◆ DistanceTable() [1/2]

DistanceTable ( const ParticleSet source,
const ParticleSet target,
DTModes  modes 
)
inline

constructor using source and target ParticleSet

Definition at line 64 of file DistanceTable.h.

65  : origin_(source),
66  num_sources_(source.getTotalNum()),
67  num_targets_(target.getTotalNum()),
68  name_(source.getName() + "_" + target.getName()),
69  modes_(modes)
70  {}
const std::string name_
name of the table
Definition: DistanceTable.h:57
const ParticleSet & origin_
Definition: DistanceTable.h:51
DTModes modes_
operation modes defined by DTModes
Definition: DistanceTable.h:60

◆ DistanceTable() [2/2]

DistanceTable ( const DistanceTable )
delete

copy constructor. deleted

◆ ~DistanceTable()

virtual ~DistanceTable ( )
virtualdefault

virutal destructor

Member Function Documentation

◆ acquireResource()

virtual void acquireResource ( ResourceCollection collection,
const RefVectorWithLeader< DistanceTable > &  dt_list 
) const
inlinevirtual

acquire a shared resource from a collection

Reimplemented in SoaDistanceTableABOMPTarget< T, D, SC >, and SoaDistanceTableAAOMPTarget< T, D, SC >.

Definition at line 214 of file DistanceTable.h.

215  {}

◆ centers()

size_t centers ( ) const
inline

returns the number of centers

Definition at line 91 of file DistanceTable.h.

References ParticleSet::getTotalNum(), and DistanceTable::origin_.

91 { return origin_.getTotalNum(); }
size_t getTotalNum() const
Definition: ParticleSet.h:493
const ParticleSet & origin_
Definition: DistanceTable.h:51

◆ createResource()

virtual void createResource ( ResourceCollection collection) const
inlinevirtual

initialize a shared resource and hand it to a collection

Reimplemented in SoaDistanceTableABOMPTarget< T, D, SC >, and SoaDistanceTableAAOMPTarget< T, D, SC >.

Definition at line 211 of file DistanceTable.h.

211 {}

◆ evaluate()

virtual void evaluate ( ParticleSet P)
pure virtual

evaluate the full Distance Table

Parameters
Pthe target particle set

Implemented in SoaDistanceTableABOMPTarget< T, D, SC >, SoaDistanceTableAAOMPTarget< T, D, SC >, SoaDistanceTableAA< T, D, SC >, and SoaDistanceTableAB< T, D, SC >.

Referenced by DistanceTable::mw_evaluate().

◆ finalizePbyP()

virtual void finalizePbyP ( const ParticleSet P)
inlinevirtual

finalize distance table calculation after particle-by-particle moves if update() doesn't make the table up-to-date during p-by-p moves finalizePbyP takes action to bring the table up-to-date

Definition at line 182 of file DistanceTable.h.

Referenced by DistanceTable::mw_finalizePbyP().

182 {}

◆ get_first_neighbor()

virtual int get_first_neighbor ( IndexType  iat,
RealType r,
PosType dr,
bool  newpos 
) const
pure virtual

find the first nearest neighbor

Parameters
iatsource particle id
rdistance
drdisplacement
newposif true, use the data in temp_r_ and temp_dr_ for the proposed move. if false, use the data in distance_[iat] and displacements_[iat]
Returns
the id of the nearest particle, -1 not found

Implemented in SoaDistanceTableAB< T, D, SC >.

Referenced by HybridRepCenterOrbitals< SPLINEBASE::DataType >::evaluate_v(), HybridRepCenterOrbitals< SPLINEBASE::DataType >::evaluate_vgh(), and HybridRepCenterOrbitals< SPLINEBASE::DataType >::evaluate_vgl().

◆ get_origin()

const ParticleSet& get_origin ( ) const
inline

returns the reference the origin particleset

Definition at line 88 of file DistanceTable.h.

References DistanceTable::origin_.

88 { return origin_; }
const ParticleSet & origin_
Definition: DistanceTable.h:51

◆ getModes()

DTModes getModes ( ) const
inline

get modes

Definition at line 79 of file DistanceTable.h.

References DistanceTable::modes_.

79 { return modes_; }
DTModes modes_
operation modes defined by DTModes
Definition: DistanceTable.h:60

◆ getName()

const std::string& getName ( ) const
inline

return the name of table

Definition at line 85 of file DistanceTable.h.

References DistanceTable::name_.

85 { return name_; }
const std::string name_
name of the table
Definition: DistanceTable.h:57

◆ move()

virtual void move ( const ParticleSet P,
const PosType rnew,
const IndexType  iat,
bool  prepare_old = true 
)
pure virtual

evaluate the temporary pair relations when a move is proposed

Parameters
Pthe target particle set
rnewproposed new position
iatthe particle to be moved
prepare_oldif true, prepare (temporary) old distances and displacements for using getOldDists and getOldDispls functions in acceptMove.

Note: some distance table consumers (WaveFunctionComponent) have optimized code paths which require prepare_old = true for accepting a move. Drivers/Hamiltonians know whether moves will be accepted or not and manage this flag when calling ParticleSet::makeMoveXXX functions.

Implemented in SoaDistanceTableABOMPTarget< T, D, SC >, SoaDistanceTableAAOMPTarget< T, D, SC >, SoaDistanceTableAA< T, D, SC >, and SoaDistanceTableAB< T, D, SC >.

Referenced by DistanceTable::mw_move().

◆ mw_evaluate()

virtual void mw_evaluate ( const RefVectorWithLeader< DistanceTable > &  dt_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
) const
inlinevirtual

Reimplemented in SoaDistanceTableABOMPTarget< T, D, SC >.

Definition at line 103 of file DistanceTable.h.

References DistanceTable::evaluate().

Referenced by SoaDistanceTableAAOMPTarget< T, D, SC >::mw_finalizePbyP().

105  {
106  for (int iw = 0; iw < dt_list.size(); iw++)
107  dt_list[iw].evaluate(p_list[iw]);
108  }
virtual void evaluate(ParticleSet &P)=0
evaluate the full Distance Table

◆ mw_finalizePbyP()

virtual void mw_finalizePbyP ( const RefVectorWithLeader< DistanceTable > &  dt_list,
const RefVectorWithLeader< ParticleSet > &  p_list 
) const
inlinevirtual

walker batched version of finalizePbyP If not DTModes::NEED_TEMP_DATA_ON_HOST, host distance table data is not updated at all during p-by-p Thus, a recompute is necessary to update the whole host distance table for consumers like the Coulomb potential.

Reimplemented in SoaDistanceTableAAOMPTarget< T, D, SC >.

Definition at line 188 of file DistanceTable.h.

References DistanceTable::finalizePbyP().

190  {
191  for (int iw = 0; iw < dt_list.size(); iw++)
192  dt_list[iw].finalizePbyP(p_list[iw]);
193  }
virtual void finalizePbyP(const ParticleSet &P)
finalize distance table calculation after particle-by-particle moves if update() doesn&#39;t make the tab...

◆ mw_move()

virtual void mw_move ( const RefVectorWithLeader< DistanceTable > &  dt_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< PosType > &  rnew_list,
const IndexType  iat,
bool  prepare_old = true 
) const
inlinevirtual

walker batched version of move.

this function may be implemented asynchronously. Additional synchroniziation for collecting results should be handled by the caller. If DTModes::NEED_TEMP_DATA_ON_HOST, host data will be updated. If no consumer requests data on the host, the transfer is skipped.

Reimplemented in SoaDistanceTableAAOMPTarget< T, D, SC >.

Definition at line 140 of file DistanceTable.h.

References DistanceTable::move().

145  {
146  for (int iw = 0; iw < dt_list.size(); iw++)
147  dt_list[iw].move(p_list[iw], rnew_list[iw], iat, prepare_old);
148  }
virtual void move(const ParticleSet &P, const PosType &rnew, const IndexType iat, bool prepare_old=true)=0
evaluate the temporary pair relations when a move is proposed

◆ mw_recompute()

virtual void mw_recompute ( const RefVectorWithLeader< DistanceTable > &  dt_list,
const RefVectorWithLeader< ParticleSet > &  p_list,
const std::vector< bool > &  recompute 
) const
inlinevirtual

recompute multi walker internal data, recompute

Parameters
dt_listthe distance table batch
p_listthe target particle set batch
recomputeif true, must recompute. Otherwise, implementation dependent.

Reimplemented in SoaDistanceTableABOMPTarget< T, D, SC >.

Definition at line 115 of file DistanceTable.h.

118  {
119  for (int iw = 0; iw < dt_list.size(); iw++)
120  if (recompute[iw])
121  dt_list[iw].evaluate(p_list[iw]);
122  }

◆ mw_updatePartial()

virtual void mw_updatePartial ( const RefVectorWithLeader< DistanceTable > &  dt_list,
IndexType  jat,
const std::vector< bool > &  from_temp 
)
inlinevirtual

walker batched version of updatePartial.

If not DTModes::NEED_TEMP_DATA_ON_HOST, host data is not up-to-date and host distance table will not be updated.

Reimplemented in SoaDistanceTableAAOMPTarget< T, D, SC >.

Definition at line 170 of file DistanceTable.h.

References DistanceTable::updatePartial().

173  {
174  for (int iw = 0; iw < dt_list.size(); iw++)
175  dt_list[iw].updatePartial(jat, from_temp[iw]);
176  }
virtual void updatePartial(IndexType jat, bool from_temp)
fill partially the distance table by the pair relations from the temporary or old particle position...

◆ print()

void print ( std::ostream &  os)
inline

Definition at line 205 of file DistanceTable.h.

206  {
207  throw std::runtime_error("DistanceTable::print is not supported");
208  }

◆ releaseResource()

virtual void releaseResource ( ResourceCollection collection,
const RefVectorWithLeader< DistanceTable > &  dt_list 
) const
inlinevirtual

return a shared resource to a collection

Reimplemented in SoaDistanceTableABOMPTarget< T, D, SC >, and SoaDistanceTableAAOMPTarget< T, D, SC >.

Definition at line 218 of file DistanceTable.h.

219  {}

◆ setModes()

void setModes ( DTModes  modes)
inline

set modes

Definition at line 82 of file DistanceTable.h.

References DistanceTable::modes_.

82 { modes_ = modes; }
DTModes modes_
operation modes defined by DTModes
Definition: DistanceTable.h:60

◆ sources()

size_t sources ( ) const
inline

returns the number of source particles

Definition at line 97 of file DistanceTable.h.

References DistanceTable::num_sources_.

Referenced by Backflow_eI< FT >::evaluatePbyP().

97 { return num_sources_; }

◆ targets()

size_t targets ( ) const
inline

◆ update()

virtual void update ( IndexType  jat)
pure virtual

update the distance table by the pair relations from the temporal position.

Used when a move is accepted in regular mode

Parameters
iatthe particle with an accepted move

Implemented in SoaDistanceTableAAOMPTarget< T, D, SC >, SoaDistanceTableABOMPTarget< T, D, SC >, SoaDistanceTableAA< T, D, SC >, and SoaDistanceTableAB< T, D, SC >.

Referenced by DistanceTable::updatePartial().

◆ updatePartial()

virtual void updatePartial ( IndexType  jat,
bool  from_temp 
)
inlinevirtual

fill partially the distance table by the pair relations from the temporary or old particle position.

Used in forward mode when a move is reject

Parameters
iatthe particle with an accepted move
from_tempif true, copy from temp. if false, copy from old

Reimplemented in SoaDistanceTableAAOMPTarget< T, D, SC >, and SoaDistanceTableAA< T, D, SC >.

Definition at line 161 of file DistanceTable.h.

References DistanceTable::update().

Referenced by DistanceTable::mw_updatePartial().

162  {
163  if (from_temp)
164  update(jat);
165  }
virtual void update(IndexType jat)=0
update the distance table by the pair relations from the temporal position.

Member Data Documentation

◆ DIM

constexpr unsigned DIM = OHMMS_DIM
static

Definition at line 41 of file DistanceTable.h.

◆ modes_

◆ name_

◆ num_sources_

◆ num_targets_

◆ origin_


The documentation for this class was generated from the following file: