"platforms/vscode:/vscode.git/clone" did not exist on "e9c5ab17df46e87443f8046d8ce7c083c0be2773"
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: ...@@ -80,6 +80,12 @@ public:
return Vec3(lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2]); 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 // unary minus
Vec3 operator-() const { Vec3 operator-() const {
const Vec3& lhs = *this; const Vec3& lhs = *this;
...@@ -92,18 +98,35 @@ public: ...@@ -92,18 +98,35 @@ public:
return Vec3(lhs[0] - rhs[0], lhs[1] - rhs[1], lhs[2] - rhs[2]); 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 // scalar product
Vec3 operator*(double rhs) const { Vec3 operator*(double rhs) const {
const Vec3& lhs = *this; const Vec3& lhs = *this;
return Vec3(lhs[0]*rhs, lhs[1]*rhs, lhs[2]*rhs); 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 // dot product
double dot(const Vec3& rhs) const { double dot(const Vec3& rhs) const {
const Vec3& lhs = *this; const Vec3& lhs = *this;
return lhs[0]*rhs[0] + lhs[1]*rhs[1] + lhs[2]*rhs[2]; 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: private:
double data[3]; double data[3];
}; };
......
...@@ -175,6 +175,10 @@ public: ...@@ -175,6 +175,10 @@ public:
* ForceImpl in the system, allowing them to modify the values of state variables. * ForceImpl in the system, allowing them to modify the values of state variables.
*/ */
void updateContextState(); 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. * Get the platform-specific data stored in this context.
*/ */
......
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
double calcEnergy(ContextImpl& context); double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters(); std::map<std::string, double> getDefaultParameters();
std::vector<std::string> getKernelNames(); std::vector<std::string> getKernelNames();
std::vector<std::pair<int, int> > getBondedParticles(); std::vector<std::pair<int, int> > getBondedParticles() const;
private: private:
CustomBondForce& owner; CustomBondForce& owner;
Kernel kernel; Kernel kernel;
......
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
* Get pairs of particles connected by bonds by this force. This is used to determine which particles * Get pairs of particles connected by bonds by this force. This is used to determine which particles
* are part of the same molecule. * 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); return std::vector<std::pair<int, int> >(0);
} }
}; };
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
return std::map<std::string, double>(); // This force field doesn't define any parameters. return std::map<std::string, double>(); // This force field doesn't define any parameters.
} }
std::vector<std::string> getKernelNames(); std::vector<std::string> getKernelNames();
std::vector<std::pair<int, int> > getBondedParticles(); std::vector<std::pair<int, int> > getBondedParticles() const;
private: private:
HarmonicBondForce& owner; HarmonicBondForce& owner;
Kernel kernel; Kernel kernel;
......
...@@ -169,6 +169,10 @@ void ContextImpl::updateContextState() { ...@@ -169,6 +169,10 @@ void ContextImpl::updateContextState() {
forceImpls[i]->updateContextState(*this); forceImpls[i]->updateContextState(*this);
} }
const vector<ForceImpl*>& ContextImpl::getForceImpls() const {
return forceImpls;
}
void* ContextImpl::getPlatformData() { void* ContextImpl::getPlatformData() {
return platformData; return platformData;
} }
......
...@@ -103,7 +103,7 @@ map<string, double> CustomBondForceImpl::getDefaultParameters() { ...@@ -103,7 +103,7 @@ map<string, double> CustomBondForceImpl::getDefaultParameters() {
return parameters; return parameters;
} }
vector<pair<int, int> > CustomBondForceImpl::getBondedParticles() { vector<pair<int, int> > CustomBondForceImpl::getBondedParticles() const {
int numBonds = owner.getNumBonds(); int numBonds = owner.getNumBonds();
vector<pair<int, int> > bonds(numBonds); vector<pair<int, int> > bonds(numBonds);
for (int i = 0; i < numBonds; i++) { for (int i = 0; i < numBonds; i++) {
......
...@@ -63,7 +63,7 @@ std::vector<std::string> HarmonicBondForceImpl::getKernelNames() { ...@@ -63,7 +63,7 @@ std::vector<std::string> HarmonicBondForceImpl::getKernelNames() {
return names; return names;
} }
vector<pair<int, int> > HarmonicBondForceImpl::getBondedParticles() { vector<pair<int, int> > HarmonicBondForceImpl::getBondedParticles() const {
int numBonds = owner.getNumBonds(); int numBonds = owner.getNumBonds();
vector<pair<int, int> > bonds(numBonds); vector<pair<int, int> > bonds(numBonds);
for (int i = 0; i < numBonds; i++) { 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