Skip to content

Commit

Permalink
Merge pull request #4719 from quantumsteve/faster_setTwist
Browse files Browse the repository at this point in the history
Make setTwist/twist take/return a const reference.
  • Loading branch information
prckent authored Aug 31, 2023
2 parents 7b9d286 + 0a56494 commit 155b0f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Particle/ParticleSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ class ParticleSet : public QMCTraits, public OhmmsElementBase, public PtclOnLatt
///return the address of the i-th properties
inline const FullPrecRealType* restrict getPropertyBase(int i) const { return Properties[i]; }

inline void setTwist(SingleParticlePos& t) { myTwist = t; }
inline SingleParticlePos getTwist() const { return myTwist; }
inline void setTwist(const SingleParticlePos& t) { myTwist = t; }
inline const SingleParticlePos& getTwist() const { return myTwist; }

/** Initialize particles around another ParticleSet
* Used to initialize an electron ParticleSet by an ion ParticleSet
Expand Down
5 changes: 3 additions & 2 deletions src/QMCWaveFunctions/TrialWaveFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@ class TrialWaveFunction

void evaluateRatiosAlltoOne(ParticleSet& P, std::vector<ValueType>& ratios);

void setTwist(std::vector<RealType> t) { myTwist = t; }
const std::vector<RealType> twist() { return myTwist; }
void setTwist(const std::vector<RealType>& t) { myTwist = t; }
void setTwist(std::vector<RealType>&& t) { myTwist = std::move(t); }
const std::vector<RealType>& twist() const { return myTwist; }

inline void setMassTerm(ParticleSet& P)
{
Expand Down
9 changes: 4 additions & 5 deletions src/QMCWaveFunctions/WaveFunctionFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ std::unique_ptr<TrialWaveFunction> WaveFunctionFactory::buildTWF(xmlNodePtr cur,
attribs.add(hdfName, "name");
if (hdfName == "twistAngle")
{
std::vector<ParticleSet::RealType> tsts(3, 0);
putContent(tsts, kcur);
targetPsi->setTwist(tsts);
std::vector<ParticleSet::RealType> twists(3, 0);
putContent(twists, kcur);
targetPsi->setTwist(std::move(twists));
foundtwist = true;
}
}
Expand All @@ -102,8 +102,7 @@ std::unique_ptr<TrialWaveFunction> WaveFunctionFactory::buildTWF(xmlNodePtr cur,
if (!foundtwist)
{
//default twist is [0 0 0]
std::vector<ParticleSet::RealType> tsts(3, 0);
targetPsi->setTwist(tsts);
targetPsi->setTwist(std::vector<ParticleSet::RealType>(3, 0));
}
}
else if (cname == WaveFunctionComponentBuilder::jastrow_tag)
Expand Down

0 comments on commit 155b0f1

Please sign in to comment.