"platforms/cuda/src/kernels/nonbonded.cu" did not exist on "e28ce5581864d87aecdcdca6d5b299d0f3382e6e"
Commit 0307a0db authored by Yutong Zhao's avatar Yutong Zhao
Browse files

Context constructor now uses const System&, guaranteeing that System won't be modified.

parent 19757775
...@@ -216,7 +216,7 @@ void CustomHbondForce::setFunctionParameters(int index, const std::string& name, ...@@ -216,7 +216,7 @@ void CustomHbondForce::setFunctionParameters(int index, const std::string& name,
functions[index].max = max; functions[index].max = max;
} }
ForceImpl* CustomHbondForce::createImpl() { ForceImpl* CustomHbondForce::createImpl() const {
return new CustomHbondForceImpl(*this); return new CustomHbondForceImpl(*this);
} }
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
} }
}; };
CustomHbondForceImpl::CustomHbondForceImpl(CustomHbondForce& owner) : owner(owner) { CustomHbondForceImpl::CustomHbondForceImpl(const CustomHbondForce& owner) : owner(owner) {
} }
CustomHbondForceImpl::~CustomHbondForceImpl() { CustomHbondForceImpl::~CustomHbondForceImpl() {
...@@ -82,7 +82,7 @@ void CustomHbondForceImpl::initialize(ContextImpl& context) { ...@@ -82,7 +82,7 @@ void CustomHbondForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of parameters and exclusions. // Check for errors in the specification of parameters and exclusions.
System& system = context.getSystem(); const System& system = context.getSystem();
vector<set<int> > exclusions(owner.getNumDonors()); vector<set<int> > exclusions(owner.getNumDonors());
vector<double> parameters; vector<double> parameters;
int numDonorParameters = owner.getNumPerDonorParameters(); int numDonorParameters = owner.getNumPerDonorParameters();
......
...@@ -174,7 +174,7 @@ void CustomNonbondedForce::setFunctionParameters(int index, const std::string& n ...@@ -174,7 +174,7 @@ void CustomNonbondedForce::setFunctionParameters(int index, const std::string& n
functions[index].max = max; functions[index].max = max;
} }
ForceImpl* CustomNonbondedForce::createImpl() { ForceImpl* CustomNonbondedForce::createImpl() const {
return new CustomNonbondedForceImpl(*this); return new CustomNonbondedForceImpl(*this);
} }
......
...@@ -43,7 +43,7 @@ using std::set; ...@@ -43,7 +43,7 @@ using std::set;
using std::string; using std::string;
using std::stringstream; using std::stringstream;
CustomNonbondedForceImpl::CustomNonbondedForceImpl(CustomNonbondedForce& owner) : owner(owner) { CustomNonbondedForceImpl::CustomNonbondedForceImpl(const CustomNonbondedForce& owner) : owner(owner) {
} }
CustomNonbondedForceImpl::~CustomNonbondedForceImpl() { CustomNonbondedForceImpl::~CustomNonbondedForceImpl() {
...@@ -54,7 +54,7 @@ void CustomNonbondedForceImpl::initialize(ContextImpl& context) { ...@@ -54,7 +54,7 @@ void CustomNonbondedForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of parameters and exclusions. // Check for errors in the specification of parameters and exclusions.
System& system = context.getSystem(); const System& system = context.getSystem();
if (owner.getNumParticles() != system.getNumParticles()) if (owner.getNumParticles() != system.getNumParticles())
throw OpenMMException("CustomNonbondedForce must have exactly as many particles as the System it belongs to."); throw OpenMMException("CustomNonbondedForce must have exactly as many particles as the System it belongs to.");
vector<set<int> > exclusions(owner.getNumParticles()); vector<set<int> > exclusions(owner.getNumParticles());
......
...@@ -118,7 +118,7 @@ void CustomTorsionForce::setTorsionParameters(int index, int particle1, int part ...@@ -118,7 +118,7 @@ void CustomTorsionForce::setTorsionParameters(int index, int particle1, int part
torsions[index].particle4 = particle4; torsions[index].particle4 = particle4;
} }
ForceImpl* CustomTorsionForce::createImpl() { ForceImpl* CustomTorsionForce::createImpl() const {
return new CustomTorsionForceImpl(*this); return new CustomTorsionForceImpl(*this);
} }
......
...@@ -43,7 +43,7 @@ using std::set; ...@@ -43,7 +43,7 @@ using std::set;
using std::string; using std::string;
using std::stringstream; using std::stringstream;
CustomTorsionForceImpl::CustomTorsionForceImpl(CustomTorsionForce& owner) : owner(owner) { CustomTorsionForceImpl::CustomTorsionForceImpl(const CustomTorsionForce& owner) : owner(owner) {
} }
CustomTorsionForceImpl::~CustomTorsionForceImpl() { CustomTorsionForceImpl::~CustomTorsionForceImpl() {
...@@ -54,7 +54,7 @@ void CustomTorsionForceImpl::initialize(ContextImpl& context) { ...@@ -54,7 +54,7 @@ void CustomTorsionForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of bonds. // Check for errors in the specification of bonds.
System& system = context.getSystem(); const System& system = context.getSystem();
vector<double> parameters; vector<double> parameters;
int numParameters = owner.getNumPerTorsionParameters(); int numParameters = owner.getNumPerTorsionParameters();
for (int i = 0; i < owner.getNumTorsions(); i++) { for (int i = 0; i < owner.getNumTorsions(); i++) {
......
...@@ -75,7 +75,7 @@ void GBSAOBCForce::setCutoffDistance(double distance) { ...@@ -75,7 +75,7 @@ void GBSAOBCForce::setCutoffDistance(double distance) {
cutoffDistance = distance; cutoffDistance = distance;
} }
ForceImpl* GBSAOBCForce::createImpl() { ForceImpl* GBSAOBCForce::createImpl() const {
return new GBSAOBCForceImpl(*this); return new GBSAOBCForceImpl(*this);
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
using namespace OpenMM; using namespace OpenMM;
using std::vector; using std::vector;
GBSAOBCForceImpl::GBSAOBCForceImpl(GBSAOBCForce& owner) : owner(owner) { GBSAOBCForceImpl::GBSAOBCForceImpl(const GBSAOBCForce& owner) : owner(owner) {
} }
void GBSAOBCForceImpl::initialize(ContextImpl& context) { void GBSAOBCForceImpl::initialize(ContextImpl& context) {
......
...@@ -124,6 +124,6 @@ void GBVIForce::getBondParameters(int index, int& bondIndex1, int& bondIndex2, d ...@@ -124,6 +124,6 @@ void GBVIForce::getBondParameters(int index, int& bondIndex1, int& bondIndex2, d
bondLength = bonds[index].bondLength; bondLength = bonds[index].bondLength;
} }
ForceImpl* GBVIForce::createImpl() { ForceImpl* GBVIForce::createImpl() const {
return new GBVIForceImpl(*this); return new GBVIForceImpl(*this);
} }
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
using namespace OpenMM; using namespace OpenMM;
using std::vector; using std::vector;
GBVIForceImpl::GBVIForceImpl(GBVIForce& owner) : owner(owner) { GBVIForceImpl::GBVIForceImpl(const GBVIForce& owner) : owner(owner) {
} }
void GBVIForceImpl::initialize(ContextImpl& context) { void GBVIForceImpl::initialize(ContextImpl& context) {
...@@ -49,7 +49,7 @@ void GBVIForceImpl::initialize(ContextImpl& context) { ...@@ -49,7 +49,7 @@ void GBVIForceImpl::initialize(ContextImpl& context) {
if (owner.getNumParticles() != context.getSystem().getNumParticles()) if (owner.getNumParticles() != context.getSystem().getNumParticles())
throw OpenMMException("GBVIForce must have exactly as many particles as the System it belongs to."); throw OpenMMException("GBVIForce must have exactly as many particles as the System it belongs to.");
System& system = context.getSystem(); const System& system = context.getSystem();
int numberOfParticles = owner.getNumParticles(); int numberOfParticles = owner.getNumParticles();
int numberOfBonds = owner.getNumBonds(); int numberOfBonds = owner.getNumBonds();
...@@ -109,13 +109,14 @@ void GBVIForceImpl::initialize(ContextImpl& context) { ...@@ -109,13 +109,14 @@ void GBVIForceImpl::initialize(ContextImpl& context) {
kernel.getAs<CalcGBVIForceKernel>().initialize(context.getSystem(), owner, scaledRadii); kernel.getAs<CalcGBVIForceKernel>().initialize(context.getSystem(), owner, scaledRadii);
} }
/*
int GBVIForceImpl::getBondsFromForces(ContextImpl& context) { int GBVIForceImpl::getBondsFromForces(ContextImpl& context) {
// load 1-2 atom pairs along w/ bond distance using HarmonicBondForce & constraints // load 1-2 atom pairs along w/ bond distance using HarmonicBondForce & constraints
System& system = context.getSystem(); const System& system = context.getSystem();
for (int i = 0; i < system.getNumForces(); i++) { for (int i = 0; i < system.getNumForces(); i++) {
if (dynamic_cast<HarmonicBondForce*>(&system.getForce(i)) != NULL) { if (dynamic_cast<const HarmonicBondForce*>(&system.getForce(i)) != NULL) {
const HarmonicBondForce& force = dynamic_cast<const HarmonicBondForce&>(system.getForce(i)); const HarmonicBondForce& force = dynamic_cast<const HarmonicBondForce&>(system.getForce(i));
for (int j = 0; j < force.getNumBonds(); ++j) { for (int j = 0; j < force.getNumBonds(); ++j) {
int particle1, particle2; int particle1, particle2;
...@@ -142,6 +143,7 @@ int GBVIForceImpl::getBondsFromForces(ContextImpl& context) { ...@@ -142,6 +143,7 @@ int GBVIForceImpl::getBondsFromForces(ContextImpl& context) {
return 0; return 0;
} }
*/
#define GBVIDebug 0 #define GBVIDebug 0
......
...@@ -63,7 +63,7 @@ void HarmonicAngleForce::setAngleParameters(int index, int particle1, int partic ...@@ -63,7 +63,7 @@ void HarmonicAngleForce::setAngleParameters(int index, int particle1, int partic
angles[index].k = k; angles[index].k = k;
} }
ForceImpl* HarmonicAngleForce::createImpl() { ForceImpl* HarmonicAngleForce::createImpl() const {
return new HarmonicAngleForceImpl(*this); return new HarmonicAngleForceImpl(*this);
} }
......
...@@ -38,7 +38,7 @@ using std::pair; ...@@ -38,7 +38,7 @@ using std::pair;
using std::vector; using std::vector;
using std::set; using std::set;
HarmonicAngleForceImpl::HarmonicAngleForceImpl(HarmonicAngleForce& owner) : owner(owner) { HarmonicAngleForceImpl::HarmonicAngleForceImpl(const HarmonicAngleForce& owner) : owner(owner) {
} }
HarmonicAngleForceImpl::~HarmonicAngleForceImpl() { HarmonicAngleForceImpl::~HarmonicAngleForceImpl() {
......
...@@ -61,7 +61,7 @@ void HarmonicBondForce::setBondParameters(int index, int particle1, int particle ...@@ -61,7 +61,7 @@ void HarmonicBondForce::setBondParameters(int index, int particle1, int particle
bonds[index].k = k; bonds[index].k = k;
} }
ForceImpl* HarmonicBondForce::createImpl() { ForceImpl* HarmonicBondForce::createImpl() const {
return new HarmonicBondForceImpl(*this); return new HarmonicBondForceImpl(*this);
} }
......
...@@ -38,7 +38,7 @@ using std::pair; ...@@ -38,7 +38,7 @@ using std::pair;
using std::vector; using std::vector;
using std::set; using std::set;
HarmonicBondForceImpl::HarmonicBondForceImpl(HarmonicBondForce& owner) : owner(owner) { HarmonicBondForceImpl::HarmonicBondForceImpl(const HarmonicBondForce& owner) : owner(owner) {
} }
HarmonicBondForceImpl::~HarmonicBondForceImpl() { HarmonicBondForceImpl::~HarmonicBondForceImpl() {
......
...@@ -102,7 +102,7 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf ...@@ -102,7 +102,7 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf
} }
void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxIterations) { void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxIterations) {
System& system = context.getSystem(); const System& system = context.getSystem();
int numParticles = system.getNumParticles(); int numParticles = system.getNumParticles();
lbfgsfloatval_t *x = lbfgs_malloc(numParticles*3); lbfgsfloatval_t *x = lbfgs_malloc(numParticles*3);
if (x == NULL) if (x == NULL)
......
...@@ -40,6 +40,6 @@ MonteCarloBarostat::MonteCarloBarostat(double defaultPressure, double temperatur ...@@ -40,6 +40,6 @@ MonteCarloBarostat::MonteCarloBarostat(double defaultPressure, double temperatur
setRandomNumberSeed((int) time(NULL)); setRandomNumberSeed((int) time(NULL));
} }
ForceImpl* MonteCarloBarostat::createImpl() { ForceImpl* MonteCarloBarostat::createImpl() const {
return new MonteCarloBarostatImpl(*this); return new MonteCarloBarostatImpl(*this);
} }
...@@ -45,7 +45,7 @@ const float AVOGADRO = 6.0221367e23f; ...@@ -45,7 +45,7 @@ const float AVOGADRO = 6.0221367e23f;
const float RGAS = BOLTZMANN*AVOGADRO; // (J/(mol K)) const float RGAS = BOLTZMANN*AVOGADRO; // (J/(mol K))
const float BOLTZ = RGAS/1000; // (kJ/(mol K)) const float BOLTZ = RGAS/1000; // (kJ/(mol K))
MonteCarloBarostatImpl::MonteCarloBarostatImpl(MonteCarloBarostat& owner) : owner(owner), step(0) { MonteCarloBarostatImpl::MonteCarloBarostatImpl(const MonteCarloBarostat& owner) : owner(owner), step(0) {
} }
void MonteCarloBarostatImpl::initialize(ContextImpl& context) { void MonteCarloBarostatImpl::initialize(ContextImpl& context) {
......
...@@ -145,7 +145,7 @@ void NonbondedForce::setExceptionParameters(int index, int particle1, int partic ...@@ -145,7 +145,7 @@ void NonbondedForce::setExceptionParameters(int index, int particle1, int partic
exceptions[index].epsilon = epsilon; exceptions[index].epsilon = epsilon;
} }
ForceImpl* NonbondedForce::createImpl() { ForceImpl* NonbondedForce::createImpl() const {
return new NonbondedForceImpl(*this); return new NonbondedForceImpl(*this);
} }
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
NonbondedForceImpl::NonbondedForceImpl(NonbondedForce& owner) : owner(owner) { NonbondedForceImpl::NonbondedForceImpl(const NonbondedForce& owner) : owner(owner) {
} }
NonbondedForceImpl::~NonbondedForceImpl() { NonbondedForceImpl::~NonbondedForceImpl() {
...@@ -54,7 +54,7 @@ void NonbondedForceImpl::initialize(ContextImpl& context) { ...@@ -54,7 +54,7 @@ void NonbondedForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of exceptions. // Check for errors in the specification of exceptions.
System& system = context.getSystem(); const System& system = context.getSystem();
if (owner.getNumParticles() != system.getNumParticles()) if (owner.getNumParticles() != system.getNumParticles())
throw OpenMMException("NonbondedForce must have exactly as many particles as the System it belongs to."); throw OpenMMException("NonbondedForce must have exactly as many particles as the System it belongs to.");
vector<set<int> > exceptions(owner.getNumParticles()); vector<set<int> > exceptions(owner.getNumParticles());
......
...@@ -67,7 +67,7 @@ void PeriodicTorsionForce::setTorsionParameters(int index, int particle1, int pa ...@@ -67,7 +67,7 @@ void PeriodicTorsionForce::setTorsionParameters(int index, int particle1, int pa
periodicTorsions[index].k = k; periodicTorsions[index].k = k;
} }
ForceImpl* PeriodicTorsionForce::createImpl() { ForceImpl* PeriodicTorsionForce::createImpl() const {
return new PeriodicTorsionForceImpl(*this); return new PeriodicTorsionForceImpl(*this);
} }
......
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