Unverified Commit fc21fd19 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Compile correctly under newer C++ standards (#5296)

parent c6f9fab2
......@@ -54,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cmath>
#include <cstdlib>
#include <stdexcept>
#include <exception>
#include <memory>
#include <vector>
#include <complex>
......
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2025 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman, Evan Pretti *
* Contributors: *
* *
......@@ -116,15 +116,11 @@ public:
/**
* Get the number of particles for which force field parameters have been defined.
*/
int getNumParticles() const {
return particles.size();
}
int getNumParticles() const;
/**
* Get the number of special interactions that should be calculated differently from other interactions.
*/
int getNumExceptions() const {
return exceptions.size();
}
int getNumExceptions() const;
/**
* Get the cutoff distance (in nm) being used for nonbonded interactions.
*
......@@ -362,9 +358,7 @@ public:
/**
* Get the number of electrodes that have been added.
*/
int getNumElectrodes() const {
return electrodes.size();
}
int getNumElectrodes() const;
/**
* Add a new electrode from a set of particles. The specified particles
* will have their charges solved for such that they are held at the
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2025 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman, Evan Pretti *
* Contributors: *
* *
......@@ -47,6 +47,18 @@ ConstantPotentialForce::ConstantPotentialForce() : constantPotentialMethod(CG),
nx(0), ny(0), nz(0), numContexts(0) {
}
int ConstantPotentialForce::getNumParticles() const {
return particles.size();
}
int ConstantPotentialForce::getNumExceptions() const {
return exceptions.size();
}
int ConstantPotentialForce::getNumElectrodes() const {
return electrodes.size();
}
double ConstantPotentialForce::getCutoffDistance() const {
return cutoffDistance;
}
......
......@@ -44,9 +44,7 @@ namespace OpenMM {
class CommonIntegrateCustomStepKernel : public IntegrateCustomStepKernel {
public:
enum GlobalTargetType {DT, VARIABLE, PARAMETER};
CommonIntegrateCustomStepKernel(std::string name, const Platform& platform, ComputeContext& cc) : IntegrateCustomStepKernel(name, platform), cc(cc),
hasInitializedKernels(false), deviceGlobalsAreCurrent(false), needsEnergyParamDerivs(false) {
}
CommonIntegrateCustomStepKernel(std::string name, const Platform& platform, ComputeContext& cc);
/**
* Initialize the kernel.
*
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2025 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -113,6 +113,10 @@ private:
string param;
};
CommonIntegrateCustomStepKernel::CommonIntegrateCustomStepKernel(std::string name, const Platform& platform, ComputeContext& cc) : IntegrateCustomStepKernel(name, platform), cc(cc),
hasInitializedKernels(false), deviceGlobalsAreCurrent(false), needsEnergyParamDerivs(false) {
}
void CommonIntegrateCustomStepKernel::initialize(const System& system, const CustomIntegrator& integrator) {
cc.initializeContexts();
ContextSelector selector(cc);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
......@@ -59,9 +59,7 @@ public:
/**
* Get the number of particles in the system.
*/
int getNumParticles() const {
return particles.size();
}
int getNumParticles() const;
/**
* Add the parameters for a particle. This should be called once for each particle
......
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
......@@ -105,9 +105,7 @@ public:
/**
* Get the number of particles in the potential function
*/
int getNumMultipoles() const {
return multipoles.size();
}
int getNumMultipoles() const;
/**
* Get the method used for handling long-range nonbonded interactions.
......
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
......@@ -59,16 +59,12 @@ public:
/**
* Get the number of torsion-torsion terms in the potential function
*/
int getNumTorsionTorsions(void) const {
return torsionTorsions.size();
}
int getNumTorsionTorsions(void) const;
/**
* Get the number of torsion-torsion grids
*/
int getNumTorsionTorsionGrids(void) const {
return torsionTorsionGrids.size();
}
int getNumTorsionTorsionGrids(void) const;
/**
* Add a torsion-torsion term to the force field.
......
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
......@@ -143,23 +143,17 @@ public:
/**
* Get the number of particles
*/
int getNumParticles() const {
return parameters.size();
}
int getNumParticles() const;
/**
* Get the number of particle types.
*/
int getNumParticleTypes() const {
return types.size();
}
int getNumParticleTypes() const;
/**
* Get the number of type pairs.
*/
int getNumTypePairs() const {
return pairs.size();
}
int getNumTypePairs() const;
/**
* Set the force field parameters for a vdw particle.
......
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
......@@ -57,9 +57,7 @@ public:
/**
* Get the number of particles
*/
int getNumParticles() const {
return parameters.size();
}
int getNumParticles() const;
/**
* Set the force field parameters for a WCA dispersion particle.
......
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2019 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs *
* Contributors: *
* *
......@@ -79,15 +79,11 @@ public:
/**
* Get the number of particles in the potential function.
*/
int getNumParticles() const {
return particles.size();
}
int getNumParticles() const;
/**
* Get the number of exceptions.
*/
int getNumExceptions() const {
return exceptions.size();
}
int getNumExceptions() const;
/**
* Get the method used for handling long-range nonbonded interactions.
*/
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -40,6 +40,10 @@ AmoebaGeneralizedKirkwoodForce::AmoebaGeneralizedKirkwoodForce() :
surfaceAreaFactor = -6.0* 3.1415926535*0.0216*1000.0*0.4184;
}
int AmoebaGeneralizedKirkwoodForce::getNumParticles() const {
return particles.size();
}
int AmoebaGeneralizedKirkwoodForce::addParticle(double charge, double radius, double scalingFactor) {
particles.push_back(ParticleInfo(charge, radius, scalingFactor, radius, 0.0));
return particles.size()-1;
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: *
* Contributors: *
* *
......@@ -46,6 +46,10 @@ AmoebaMultipoleForce::AmoebaMultipoleForce() : nonbondedMethod(NoCutoff), polari
extrapolationCoefficients.push_back(0.474);
}
int AmoebaMultipoleForce::getNumMultipoles() const {
return multipoles.size();
}
AmoebaMultipoleForce::NonbondedMethod AmoebaMultipoleForce::getNonbondedMethod() const {
return nonbondedMethod;
}
......
......@@ -39,6 +39,13 @@ using namespace std;
AmoebaTorsionTorsionForce::AmoebaTorsionTorsionForce() : usePeriodic(false) {
}
int AmoebaTorsionTorsionForce::getNumTorsionTorsions(void) const {
return torsionTorsions.size();
}
int AmoebaTorsionTorsionForce::getNumTorsionTorsionGrids(void) const {
return torsionTorsionGrids.size();
}
int AmoebaTorsionTorsionForce::addTorsionTorsion(int particle1, int particle2, int particle3,
int particle4, int particle5, int chiralCheckAtomIndex,
int gridIndex) {
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: *
* Contributors: *
* *
......@@ -42,6 +42,18 @@ AmoebaVdwForce::AmoebaVdwForce() : nonbondedMethod(NoCutoff), potentialFunction(
useTypes(false), alchemicalMethod(None), n(5), alpha(0.7) {
}
int AmoebaVdwForce::getNumParticles() const {
return parameters.size();
}
int AmoebaVdwForce::getNumParticleTypes() const {
return types.size();
}
int AmoebaVdwForce::getNumTypePairs() const {
return pairs.size();
}
int AmoebaVdwForce::addParticle(int parentIndex, double sigma, double epsilon, double reductionFactor, bool isAlchemical, double scaleFactor) {
if (useTypes)
throw OpenMMException("AmoebaVdwForce: must use the same version of addParticle() for all particles");
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: *
* Contributors: *
* *
......@@ -54,6 +54,10 @@ AmoebaWcaDispersionForce::AmoebaWcaDispersionForce() {
shctd = 0.82;
}
int AmoebaWcaDispersionForce::getNumParticles() const {
return parameters.size();
}
int AmoebaWcaDispersionForce::addParticle(double radius, double epsilon) {
parameters.push_back(WcaDispersionInfo(radius, epsilon));
return parameters.size()-1;
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2008-2019 Stanford University and the Authors. *
* Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -42,6 +42,14 @@ HippoNonbondedForce::HippoNonbondedForce() : nonbondedMethod(NoCutoff), cutoffDi
extrapolationCoefficients = {0.042, 0.635, 0.414};
}
int HippoNonbondedForce::getNumParticles() const {
return particles.size();
}
int HippoNonbondedForce::getNumExceptions() const {
return exceptions.size();
}
HippoNonbondedForce::NonbondedMethod HippoNonbondedForce::getNonbondedMethod() const {
return nonbondedMethod;
}
......
......@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2013-2024 Stanford University and the Authors. *
* Portions copyright (c) 2013-2026 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -59,15 +59,11 @@ public:
/**
* Get the number of particles for which force field parameters have been defined.
*/
int getNumParticles() const {
return particles.size();
}
int getNumParticles() const;
/**
* Get the number of special interactions that should be calculated differently from other interactions.
*/
int getNumScreenedPairs() const {
return screenedPairs.size();
}
int getNumScreenedPairs() const;
/**
* Add a Drude particle to which forces should be applied.
*
......
......@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. *
* *
* Portions copyright (c) 2013-2024 Stanford University and the Authors. *
* Portions copyright (c) 2013-2026 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -39,6 +39,14 @@ using namespace std;
DrudeForce::DrudeForce() : usePeriodic(false) {
}
int DrudeForce::getNumParticles() const {
return particles.size();
}
int DrudeForce::getNumScreenedPairs() const {
return screenedPairs.size();
}
int DrudeForce::addParticle(int particle, int particle1, int particle2, int particle3, int particle4, double charge, double polarizability, double aniso12, double aniso34) {
if (polarizability <= 0)
throw OpenMMException("Polarizability must be positive");
......
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