Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make setTwist/twist take/return a const reference. #4719

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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