Commit 95aa79b7 authored by Peter Eastman's avatar Peter Eastman
Browse files

Minor API additions needed for the Normal Mode Langevin plugin

parent 00eec5ea
......@@ -80,6 +80,12 @@ public:
return Vec3(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2]);
}
Vec3 operator+=(const Vec3& rhs) {
data[0] += rhs[0];
data[1] += rhs[1];
data[2] += rhs[2];
}
// unary minus
Vec3 operator-() const {
const Vec3& lhs = *this;
......@@ -92,17 +98,34 @@ public:
return Vec3(lhs[0] - rhs[0], lhs[1] - rhs[1], lhs[2] - rhs[2]);
}
Vec3 operator-=(const Vec3& rhs) {
data[0] -= rhs[0];
data[1] -= rhs[1];
data[2] -= rhs[2];
}
// scalar product
Vec3 operator*(double rhs) const {
const Vec3& lhs = *this;
return Vec3(lhs[0]*rhs, lhs[1]*rhs, lhs[2]*rhs);
}
Vec3 operator*=(double rhs) {
data[0] *= rhs;
data[1] *= rhs;
data[2] *= rhs;
}
// dot product
double dot(const Vec3& rhs) const {
const Vec3& lhs = *this;
return lhs[0]*rhs[0] + lhs[1]*rhs[1] + lhs[2]*rhs[2];
}
// cross product
Vec3 cross(const Vec3& rhs) const {
return Vec3(data[1]*rhs[2]-data[2]*rhs[1], data[2]*rhs[0]-data[0]*rhs[2], data[0]*rhs[1]-data[1]*rhs[0]);
}
private:
double data[3];
......
......@@ -175,6 +175,10 @@ public:
* ForceImpl in the system, allowing them to modify the values of state variables.
*/
void updateContextState();
/**
* Get the list of ForceImpls belonging to this ContextImpl.
*/
const std::vector<ForceImpl*>& getForceImpls() const;
/**
* Get the platform-specific data stored in this context.
*/
......
......@@ -60,7 +60,7 @@ public:
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters();
std::vector<std::string> getKernelNames();
std::vector<std::pair<int, int> > getBondedParticles();
std::vector<std::pair<int, int> > getBondedParticles() const;
private:
CustomBondForce& owner;
Kernel kernel;
......
......@@ -105,7 +105,7 @@ public:
* Get pairs of particles connected by bonds by this force. This is used to determine which particles
* are part of the same molecule.
*/
std::vector<std::pair<int, int> > getBondedParticles() {
virtual std::vector<std::pair<int, int> > getBondedParticles() const {
return std::vector<std::pair<int, int> >(0);
}
};
......
......@@ -62,7 +62,7 @@ public:
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
std::vector<std::string> getKernelNames();
std::vector<std::pair<int, int> > getBondedParticles();
std::vector<std::pair<int, int> > getBondedParticles() const;
private:
HarmonicBondForce& owner;
Kernel kernel;
......
......@@ -169,6 +169,10 @@ void ContextImpl::updateContextState() {
forceImpls[i]->updateContextState(*this);
}
const vector<ForceImpl*>& ContextImpl::getForceImpls() const {
return forceImpls;
}
void* ContextImpl::getPlatformData() {
return platformData;
}
......
......@@ -103,7 +103,7 @@ map<string, double> CustomBondForceImpl::getDefaultParameters() {
return parameters;
}
vector<pair<int, int> > CustomBondForceImpl::getBondedParticles() {
vector<pair<int, int> > CustomBondForceImpl::getBondedParticles() const {
int numBonds = owner.getNumBonds();
vector<pair<int, int> > bonds(numBonds);
for (int i = 0; i < numBonds; i++) {
......
......@@ -63,7 +63,7 @@ std::vector<std::string> HarmonicBondForceImpl::getKernelNames() {
return names;
}
vector<pair<int, int> > HarmonicBondForceImpl::getBondedParticles() {
vector<pair<int, int> > HarmonicBondForceImpl::getBondedParticles() const {
int numBonds = owner.getNumBonds();
vector<pair<int, int> > bonds(numBonds);
for (int i = 0; i < numBonds; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment