"platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp" did not exist on "64493da66474b3874c798d21d81b23fd5560134c"
Commit 9f37b18b authored by peastman's avatar peastman
Browse files

Code cleanup to reference and CPU platforms

parent f9106ddb
......@@ -152,7 +152,7 @@ class ReferenceCustomHbondIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, double** donorParameters, double** acceptorParameters,
void calculatePairIxn(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& donorParameters, std::vector<std::vector<double> >& acceptorParameters,
std::vector<std::set<int> >& exclusions, const std::map<std::string, double>& globalParameters,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const;
......
/* Portions copyright (c) 2009-2014 Stanford University and Simbios.
/* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
......@@ -59,8 +59,8 @@ class ReferenceCustomManyParticleIxn {
std::vector<DihedralTermInfo> dihedralTerms;
void loopOverInteractions(std::vector<int>& particles, int loopIndex, std::vector<OpenMM::Vec3>& atomCoordinates,
double** particleParameters, std::map<std::string, double>& variables, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy) const;
std::vector<std::vector<double> >& particleParameters, std::map<std::string, double>& variables,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const;
/**---------------------------------------------------------------------------------------
......@@ -76,8 +76,8 @@ class ReferenceCustomManyParticleIxn {
--------------------------------------------------------------------------------------- */
void calculateOneIxn(const std::vector<int>& particles, std::vector<OpenMM::Vec3>& atomCoordinates,
double** particleParameters, std::map<std::string, double>& variables, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy) const;
std::vector<std::vector<double> >& particleParameters, std::map<std::string, double>& variables,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const;
void computeDelta(int atom1, int atom2, double* delta, std::vector<OpenMM::Vec3>& atomCoordinates) const;
......@@ -136,7 +136,7 @@ class ReferenceCustomManyParticleIxn {
--------------------------------------------------------------------------------------- */
void calculateIxn(std::vector<OpenMM::Vec3>& atomCoordinates, double** particleParameters,
void calculateIxn(std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<std::vector<double> >& particleParameters,
const std::map<std::string, double>& globalParameters,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy) const;
};
......
/* Portions copyright (c) 2009-2016 Stanford University and Simbios.
/* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
......@@ -61,15 +61,13 @@ class ReferenceCustomNonbondedIxn {
@param atom1 the index of the first atom
@param atom2 the index of the second atom
@param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][parameterIndex]
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void calculateOneIxn(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<OpenMM::Vec3>& forces,
double* energyByAtom, double* totalEnergy, double* energyParamDerivs);
double* totalEnergy, double* energyParamDerivs);
public:
......@@ -144,19 +142,16 @@ class ReferenceCustomNonbondedIxn {
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param globalParameters the values of global parameters
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void calculatePairIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<std::set<int> >& exclusions,
double* fixedParameters, const std::map<std::string, double>& globalParameters,
std::vector<OpenMM::Vec3>& forces, double* energyByAtom, double* totalEnergy,
double* energyParamDerivs);
std::vector<std::vector<double> >& atomParameters, std::vector<std::set<int> >& exclusions,
const std::map<std::string, double>& globalParameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs);
// ---------------------------------------------------------------------------------------
......
......@@ -84,8 +84,8 @@ class ReferenceCustomTorsionIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces,
void calculateBondIxn(std::vector<int>& atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs);
......
......@@ -77,8 +77,8 @@ class ReferenceHarmonicBondIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces,
void calculateBondIxn(std::vector<int>& atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs);
};
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Portions copyright (c) 2008-2018 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -259,7 +259,6 @@ class ReferenceCalcHarmonicBondForceKernel : public CalcHarmonicBondForceKernel
public:
ReferenceCalcHarmonicBondForceKernel(std::string name, const Platform& platform) : CalcHarmonicBondForceKernel(name, platform) {
}
~ReferenceCalcHarmonicBondForceKernel();
/**
* Initialize the kernel.
*
......@@ -285,8 +284,8 @@ public:
void copyParametersToContext(ContextImpl& context, const HarmonicBondForce& force);
private:
int numBonds;
int **bondIndexArray;
double **bondParamArray;
std::vector<std::vector<int> >bondIndexArray;
std::vector<std::vector<double> >bondParamArray;
bool usePeriodic;
};
......@@ -297,7 +296,6 @@ class ReferenceCalcCustomBondForceKernel : public CalcCustomBondForceKernel {
public:
ReferenceCalcCustomBondForceKernel(std::string name, const Platform& platform) : CalcCustomBondForceKernel(name, platform) {
}
~ReferenceCalcCustomBondForceKernel();
/**
* Initialize the kernel.
*
......@@ -323,8 +321,8 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomBondForce& force);
private:
int numBonds;
int **bondIndexArray;
double **bondParamArray;
std::vector<std::vector<int> >bondIndexArray;
std::vector<std::vector<double> >bondParamArray;
Lepton::CompiledExpression energyExpression, forceExpression;
std::vector<Lepton::CompiledExpression> energyParamDerivExpressions;
std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames;
......@@ -338,7 +336,6 @@ class ReferenceCalcHarmonicAngleForceKernel : public CalcHarmonicAngleForceKerne
public:
ReferenceCalcHarmonicAngleForceKernel(std::string name, const Platform& platform) : CalcHarmonicAngleForceKernel(name, platform) {
}
~ReferenceCalcHarmonicAngleForceKernel();
/**
* Initialize the kernel.
*
......@@ -364,8 +361,8 @@ public:
void copyParametersToContext(ContextImpl& context, const HarmonicAngleForce& force);
private:
int numAngles;
int **angleIndexArray;
double **angleParamArray;
std::vector<std::vector<int> >angleIndexArray;
std::vector<std::vector<double> >angleParamArray;
bool usePeriodic;
};
......@@ -376,7 +373,6 @@ class ReferenceCalcCustomAngleForceKernel : public CalcCustomAngleForceKernel {
public:
ReferenceCalcCustomAngleForceKernel(std::string name, const Platform& platform) : CalcCustomAngleForceKernel(name, platform) {
}
~ReferenceCalcCustomAngleForceKernel();
/**
* Initialize the kernel.
*
......@@ -402,8 +398,8 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomAngleForce& force);
private:
int numAngles;
int **angleIndexArray;
double **angleParamArray;
std::vector<std::vector<int> >angleIndexArray;
std::vector<std::vector<double> >angleParamArray;
Lepton::CompiledExpression energyExpression, forceExpression;
std::vector<Lepton::CompiledExpression> energyParamDerivExpressions;
std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames;
......@@ -417,7 +413,6 @@ class ReferenceCalcPeriodicTorsionForceKernel : public CalcPeriodicTorsionForceK
public:
ReferenceCalcPeriodicTorsionForceKernel(std::string name, const Platform& platform) : CalcPeriodicTorsionForceKernel(name, platform) {
}
~ReferenceCalcPeriodicTorsionForceKernel();
/**
* Initialize the kernel.
*
......@@ -443,8 +438,8 @@ public:
void copyParametersToContext(ContextImpl& context, const PeriodicTorsionForce& force);
private:
int numTorsions;
int **torsionIndexArray;
double **torsionParamArray;
std::vector<std::vector<int> >torsionIndexArray;
std::vector<std::vector<double> >torsionParamArray;
bool usePeriodic;
};
......@@ -455,7 +450,6 @@ class ReferenceCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
public:
ReferenceCalcRBTorsionForceKernel(std::string name, const Platform& platform) : CalcRBTorsionForceKernel(name, platform) {
}
~ReferenceCalcRBTorsionForceKernel();
/**
* Initialize the kernel.
*
......@@ -481,8 +475,8 @@ public:
void copyParametersToContext(ContextImpl& context, const RBTorsionForce& force);
private:
int numTorsions;
int **torsionIndexArray;
double **torsionParamArray;
std::vector<std::vector<int> >torsionIndexArray;
std::vector<std::vector<double> >torsionParamArray;
bool usePeriodic;
};
......@@ -530,7 +524,6 @@ class ReferenceCalcCustomTorsionForceKernel : public CalcCustomTorsionForceKerne
public:
ReferenceCalcCustomTorsionForceKernel(std::string name, const Platform& platform) : CalcCustomTorsionForceKernel(name, platform) {
}
~ReferenceCalcCustomTorsionForceKernel();
/**
* Initialize the kernel.
*
......@@ -556,8 +549,8 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomTorsionForce& force);
private:
int numTorsions;
int **torsionIndexArray;
double **torsionParamArray;
std::vector<std::vector<int> >torsionIndexArray;
std::vector<std::vector<double> >torsionParamArray;
Lepton::CompiledExpression energyExpression, forceExpression;
std::vector<Lepton::CompiledExpression> energyParamDerivExpressions;
std::vector<std::string> parameterNames, globalParameterNames, energyParamDerivNames;
......@@ -616,8 +609,8 @@ public:
void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
private:
int numParticles, num14;
int **bonded14IndexArray;
double **particleParamArray, **bonded14ParamArray;
std::vector<std::vector<int> >bonded14IndexArray;
std::vector<std::vector<double> > particleParamArray, bonded14ParamArray;
double nonbondedCutoff, switchingDistance, rfDielectric, ewaldAlpha, ewaldDispersionAlpha, dispersionCoefficient;
int kmax[3], gridSize[3], dispersionGridSize[3];
bool useSwitchingFunction;
......@@ -659,7 +652,7 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomNonbondedForce& force);
private:
int numParticles;
double **particleParamArray;
std::vector<std::vector<double> > particleParamArray;
double nonbondedCutoff, switchingDistance, periodicBoxSize[3], longRangeCoefficient;
bool useSwitchingFunction, hasInitializedLongRangeCorrection;
CustomNonbondedForce* forceCopy;
......@@ -745,7 +738,7 @@ public:
private:
int numParticles;
bool isPeriodic;
double **particleParamArray;
std::vector<std::vector<double> > particleParamArray;
double nonbondedCutoff;
std::vector<std::set<int> > exclusions;
std::vector<std::string> particleParameterNames, globalParameterNames, energyParamDerivNames, valueNames;
......@@ -770,7 +763,6 @@ class ReferenceCalcCustomExternalForceKernel : public CalcCustomExternalForceKer
public:
ReferenceCalcCustomExternalForceKernel(std::string name, const Platform& platform) : CalcCustomExternalForceKernel(name, platform) {
}
~ReferenceCalcCustomExternalForceKernel();
/**
* Initialize the kernel.
*
......@@ -798,7 +790,7 @@ private:
class PeriodicDistanceFunction;
int numParticles;
std::vector<int> particles;
double **particleParamArray;
std::vector<std::vector<double> > particleParamArray;
Lepton::CompiledExpression energyExpression, forceExpressionX, forceExpressionY, forceExpressionZ;
std::vector<std::string> parameterNames, globalParameterNames;
Vec3* boxVectors;
......@@ -848,7 +840,7 @@ public:
private:
int numDonors, numAcceptors, numParticles;
bool isPeriodic;
double **donorParamArray, **acceptorParamArray;
std::vector<std::vector<double> > donorParamArray, acceptorParamArray;
double nonbondedCutoff;
ReferenceCustomHbondIxn* ixn;
std::vector<std::set<int> > exclusions;
......@@ -888,7 +880,7 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomCentroidBondForce& force);
private:
int numBonds, numParticles;
double **bondParamArray;
std::vector<std::vector<double> > bondParamArray;
ReferenceCustomCentroidBondIxn* ixn;
std::vector<std::string> globalParameterNames, energyParamDerivNames;
bool usePeriodic;
......@@ -927,7 +919,7 @@ public:
void copyParametersToContext(ContextImpl& context, const CustomCompoundBondForce& force);
private:
int numBonds;
double **bondParamArray;
std::vector<std::vector<double> > bondParamArray;
ReferenceCustomCompoundBondIxn* ixn;
std::vector<std::string> globalParameterNames, energyParamDerivNames;
bool usePeriodic;
......@@ -967,7 +959,7 @@ public:
private:
int numParticles;
double cutoffDistance;
double **particleParamArray;
std::vector<std::vector<double> > particleParamArray;
ReferenceCustomManyParticleIxn* ixn;
std::vector<std::string> globalParameterNames;
NonbondedMethod nonbondedMethod;
......
......@@ -62,8 +62,8 @@ class OPENMM_EXPORT ReferenceLJCoulomb14 : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces,
void calculateBondIxn(std::vector<int>& atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs);
};
......
/* Portions copyright (c) 2006-2013 Stanford University and Simbios.
/* Portions copyright (c) 2006-2018 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
......@@ -62,14 +62,13 @@ class ReferenceLJCoulombIxn {
@param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void calculateOneIxn(int atom1, int atom2, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<OpenMM::Vec3>& forces,
double* energyByAtom, double* totalEnergy) const;
std::vector<std::vector<double> >& atomParameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy) const;
public:
......@@ -169,9 +168,7 @@ class ReferenceLJCoulombIxn {
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@param includeDirect true if direct space interactions should be included
@param includeReciprocal true if reciprocal space interactions should be included
......@@ -179,9 +176,8 @@ class ReferenceLJCoulombIxn {
--------------------------------------------------------------------------------------- */
void calculatePairIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<std::set<int> >& exclusions,
double* fixedParameters, std::vector<OpenMM::Vec3>& forces,
double* energyByAtom, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
std::vector<std::vector<double> >& atomParameters, std::vector<std::set<int> >& exclusions,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
private:
/**---------------------------------------------------------------------------------------
......@@ -193,9 +189,7 @@ private:
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@param includeDirect true if direct space interactions should be included
@param includeReciprocal true if reciprocal space interactions should be included
......@@ -203,9 +197,8 @@ private:
--------------------------------------------------------------------------------------- */
void calculateEwaldIxn(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
double** atomParameters, std::vector<std::set<int> >& exclusions,
double* fixedParameters, std::vector<OpenMM::Vec3>& forces,
double* energyByAtom, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
std::vector<std::vector<double> >& atomParameters, std::vector<std::set<int> >& exclusions,
std::vector<OpenMM::Vec3>& forces, double* totalEnergy, bool includeDirect, bool includeReciprocal) const;
};
} // namespace OpenMM
......
......@@ -78,8 +78,8 @@ class OPENMM_EXPORT ReferenceProperDihedralBond : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces,
void calculateBondIxn(std::vector<int>& atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs);
};
......
......@@ -76,8 +76,8 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
void calculateBondIxn(int* atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
double* parameters, std::vector<OpenMM::Vec3>& forces,
void calculateBondIxn(std::vector<int>& atomIndices, std::vector<OpenMM::Vec3>& atomCoordinates,
std::vector<double>& parameters, std::vector<OpenMM::Vec3>& forces,
double* totalEnergy, double* energyParamDerivs);
};
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Portions copyright (c) 2008-2018 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -89,36 +89,6 @@
using namespace OpenMM;
using namespace std;
static int** allocateIntArray(int length, int width) {
int** array = new int*[length];
for (int i = 0; i < length; ++i)
array[i] = new int[width];
return array;
}
static double** allocateRealArray(int length, int width) {
double** array = new double*[length];
for (int i = 0; i < length; ++i)
array[i] = new double[width];
return array;
}
static void disposeIntArray(int** array, int size) {
if (array) {
for (int i = 0; i < size; ++i)
delete[] array[i];
delete[] array;
}
}
static void disposeRealArray(double** array, int size) {
if (array) {
for (int i = 0; i < size; ++i)
delete[] array[i];
delete[] array;
}
}
static vector<Vec3>& extractPositions(ContextImpl& context) {
ReferencePlatform::PlatformData* data = reinterpret_cast<ReferencePlatform::PlatformData*>(context.getPlatformData());
return *((vector<Vec3>*) data->positions);
......@@ -366,15 +336,10 @@ void ReferenceVirtualSitesKernel::computePositions(ContextImpl& context) {
ReferenceVirtualSites::computePositions(context.getSystem(), positions);
}
ReferenceCalcHarmonicBondForceKernel::~ReferenceCalcHarmonicBondForceKernel() {
disposeIntArray(bondIndexArray, numBonds);
disposeRealArray(bondParamArray, numBonds);
}
void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, const HarmonicBondForce& force) {
numBonds = force.getNumBonds();
bondIndexArray = allocateIntArray(numBonds, 2);
bondParamArray = allocateRealArray(numBonds, 2);
bondIndexArray.resize(numBonds, vector<int>(2));
bondParamArray.resize(numBonds, vector<double>(2));
for (int i = 0; i < numBonds; ++i) {
int particle1, particle2;
double length, k;
......@@ -418,11 +383,6 @@ void ReferenceCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl&
}
}
ReferenceCalcCustomBondForceKernel::~ReferenceCalcCustomBondForceKernel() {
disposeIntArray(bondIndexArray, numBonds);
disposeRealArray(bondParamArray, numBonds);
}
void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const CustomBondForce& force) {
numBonds = force.getNumBonds();
int numParameters = force.getNumPerBondParameters();
......@@ -430,8 +390,8 @@ void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const
// Build the arrays.
bondIndexArray = allocateIntArray(numBonds, 2);
bondParamArray = allocateRealArray(numBonds, numParameters);
bondIndexArray.resize(numBonds, vector<int>(2));
bondParamArray.resize(numBonds, vector<double>(numParameters));
vector<double> params;
for (int i = 0; i < numBonds; ++i) {
int particle1, particle2;
......@@ -500,15 +460,10 @@ void ReferenceCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& co
}
}
ReferenceCalcHarmonicAngleForceKernel::~ReferenceCalcHarmonicAngleForceKernel() {
disposeIntArray(angleIndexArray, numAngles);
disposeRealArray(angleParamArray, numAngles);
}
void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, const HarmonicAngleForce& force) {
numAngles = force.getNumAngles();
angleIndexArray = allocateIntArray(numAngles, 3);
angleParamArray = allocateRealArray(numAngles, 2);
angleIndexArray.resize(numAngles, vector<int>(3));
angleParamArray.resize(numAngles, vector<double>(2));
for (int i = 0; i < numAngles; ++i) {
int particle1, particle2, particle3;
double angle, k;
......@@ -551,11 +506,6 @@ void ReferenceCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl&
}
}
ReferenceCalcCustomAngleForceKernel::~ReferenceCalcCustomAngleForceKernel() {
disposeIntArray(angleIndexArray, numAngles);
disposeRealArray(angleParamArray, numAngles);
}
void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const CustomAngleForce& force) {
numAngles = force.getNumAngles();
int numParameters = force.getNumPerAngleParameters();
......@@ -563,8 +513,8 @@ void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const
// Build the arrays.
angleIndexArray = allocateIntArray(numAngles, 3);
angleParamArray = allocateRealArray(numAngles, numParameters);
angleIndexArray.resize(numAngles, vector<int>(3));
angleParamArray.resize(numAngles, vector<double>(numParameters));
vector<double> params;
for (int i = 0; i < numAngles; ++i) {
int particle1, particle2, particle3;
......@@ -634,15 +584,10 @@ void ReferenceCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& c
}
}
ReferenceCalcPeriodicTorsionForceKernel::~ReferenceCalcPeriodicTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, const PeriodicTorsionForce& force) {
numTorsions = force.getNumTorsions();
torsionIndexArray = allocateIntArray(numTorsions, 4);
torsionParamArray = allocateRealArray(numTorsions, 3);
torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray.resize(numTorsions, vector<double>(3));
for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4, periodicity;
double phase, k;
......@@ -688,15 +633,10 @@ void ReferenceCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImp
}
}
ReferenceCalcRBTorsionForceKernel::~ReferenceCalcRBTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const RBTorsionForce& force) {
numTorsions = force.getNumTorsions();
torsionIndexArray = allocateIntArray(numTorsions, 4);
torsionParamArray = allocateRealArray(numTorsions, 6);
torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray.resize(numTorsions, vector<double>(6));
for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4;
double c0, c1, c2, c3, c4, c5;
......@@ -820,11 +760,6 @@ void ReferenceCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& c
}
}
ReferenceCalcCustomTorsionForceKernel::~ReferenceCalcCustomTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions);
}
void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, const CustomTorsionForce& force) {
numTorsions = force.getNumTorsions();
int numParameters = force.getNumPerTorsionParameters();
......@@ -832,8 +767,8 @@ void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, con
// Build the arrays.
torsionIndexArray = allocateIntArray(numTorsions, 4);
torsionParamArray = allocateRealArray(numTorsions, numParameters);
torsionIndexArray.resize(numTorsions, vector<int>(4));
torsionParamArray.resize(numTorsions, vector<double>(numParameters));
vector<double> params;
for (int i = 0; i < numTorsions; ++i) {
int particle1, particle2, particle3, particle4;
......@@ -905,9 +840,6 @@ void ReferenceCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl&
}
ReferenceCalcNonbondedForceKernel::~ReferenceCalcNonbondedForceKernel() {
disposeRealArray(particleParamArray, numParticles);
disposeIntArray(bonded14IndexArray, num14);
disposeRealArray(bonded14ParamArray, num14);
if (neighborList != NULL)
delete neighborList;
}
......@@ -932,9 +864,9 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
// Build the arrays.
num14 = nb14s.size();
bonded14IndexArray = allocateIntArray(num14, 2);
bonded14ParamArray = allocateRealArray(num14, 3);
particleParamArray = allocateRealArray(numParticles, 3);
bonded14IndexArray.resize(num14, vector<int>(2));
bonded14ParamArray.resize(num14, vector<double>(3));
particleParamArray.resize(numParticles, vector<double>(3));
for (int i = 0; i < numParticles; ++i) {
double charge, radius, depth;
force.getParticleParameters(i, charge, radius, depth);
......@@ -1019,7 +951,7 @@ double ReferenceCalcNonbondedForceKernel::execute(ContextImpl& context, bool inc
}
if (useSwitchingFunction)
clj.setUseSwitchingFunction(switchingDistance);
clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, 0, forceData, 0, includeEnergy ? &energy : NULL, includeDirect, includeReciprocal);
clj.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, forceData, includeEnergy ? &energy : NULL, includeDirect, includeReciprocal);
if (includeDirect) {
ReferenceBondForce refBondForce;
ReferenceLJCoulomb14 nonbonded14;
......@@ -1092,7 +1024,6 @@ void ReferenceCalcNonbondedForceKernel::getLJPMEParameters(double& alpha, int& n
}
ReferenceCalcCustomNonbondedForceKernel::~ReferenceCalcCustomNonbondedForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (neighborList != NULL)
delete neighborList;
if (forceCopy != NULL)
......@@ -1115,13 +1046,9 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, c
// Build the arrays.
int numParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numParameters);
for (int i = 0; i < numParticles; ++i) {
vector<double> parameters;
force.getParticleParameters(i, parameters);
for (int j = 0; j < numParameters; j++)
particleParamArray[i][j] = parameters[j];
}
particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i)
force.getParticleParameters(i, particleParamArray[i]);
nonbondedMethod = CalcCustomNonbondedForceKernel::NonbondedMethod(force.getNonbondedMethod());
nonbondedCutoff = force.getCutoffDistance();
if (nonbondedMethod == NoCutoff) {
......@@ -1219,7 +1146,7 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo
if (useSwitchingFunction)
ixn.setUseSwitchingFunction(switchingDistance);
vector<double> energyParamDerivValues(energyParamDerivNames.size()+1, 0.0);
ixn.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, 0, globalParamValues, forceData, 0, includeEnergy ? &energy : NULL, &energyParamDerivValues[0]);
ixn.calculatePairIxn(numParticles, posData, particleParamArray, exclusions, globalParamValues, forceData, includeEnergy ? &energy : NULL, &energyParamDerivValues[0]);
map<string, double>& energyParamDerivs = extractEnergyParameterDerivatives(context);
for (int i = 0; i < energyParamDerivNames.size(); i++)
energyParamDerivs[energyParamDerivNames[i]] += energyParamDerivValues[i];
......@@ -1323,7 +1250,6 @@ void ReferenceCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& conte
}
ReferenceCalcCustomGBForceKernel::~ReferenceCalcCustomGBForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (neighborList != NULL)
delete neighborList;
}
......@@ -1356,13 +1282,9 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu
// Build the arrays.
int numPerParticleParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numPerParticleParameters);
for (int i = 0; i < numParticles; ++i) {
vector<double> parameters;
force.getParticleParameters(i, parameters);
for (int j = 0; j < numPerParticleParameters; j++)
particleParamArray[i][j] = parameters[j];
}
particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i)
force.getParticleParameters(i, particleParamArray[i]);
for (int i = 0; i < numPerParticleParameters; i++)
particleParameterNames.push_back(force.getPerParticleParameterName(i));
for (int i = 0; i < force.getNumGlobalParameters(); i++)
......@@ -1548,10 +1470,6 @@ Lepton::CustomFunction* ReferenceCalcCustomExternalForceKernel::PeriodicDistance
return new PeriodicDistanceFunction(boxVectorHandle);
}
ReferenceCalcCustomExternalForceKernel::~ReferenceCalcCustomExternalForceKernel() {
disposeRealArray(particleParamArray, numParticles);
}
void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, const CustomExternalForce& force) {
numParticles = force.getNumParticles();
int numParameters = force.getNumPerParticleParameters();
......@@ -1559,13 +1477,9 @@ void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, co
// Build the arrays.
particles.resize(numParticles);
particleParamArray = allocateRealArray(numParticles, numParameters);
vector<double> params;
for (int i = 0; i < numParticles; ++i) {
force.getParticleParameters(i, particles[i], params);
for (int j = 0; j < numParameters; j++)
particleParamArray[i][j] = params[j];
}
particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i)
force.getParticleParameters(i, particles[i], particleParamArray[i]);
// Parse the expression used to calculate the force.
......@@ -1624,8 +1538,6 @@ void ReferenceCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl
}
ReferenceCalcCustomHbondForceKernel::~ReferenceCalcCustomHbondForceKernel() {
disposeRealArray(donorParamArray, numDonors);
disposeRealArray(acceptorParamArray, numAcceptors);
if (ixn != NULL)
delete ixn;
}
......@@ -1648,29 +1560,23 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const
vector<vector<int> > donorParticles(numDonors);
int numDonorParameters = force.getNumPerDonorParameters();
donorParamArray = allocateRealArray(numDonors, numDonorParameters);
donorParamArray.resize(numDonors);
for (int i = 0; i < numDonors; ++i) {
vector<double> parameters;
int d1, d2, d3;
force.getDonorParameters(i, d1, d2, d3, parameters);
force.getDonorParameters(i, d1, d2, d3, donorParamArray[i]);
donorParticles[i].push_back(d1);
donorParticles[i].push_back(d2);
donorParticles[i].push_back(d3);
for (int j = 0; j < numDonorParameters; j++)
donorParamArray[i][j] = parameters[j];
}
vector<vector<int> > acceptorParticles(numAcceptors);
int numAcceptorParameters = force.getNumPerAcceptorParameters();
acceptorParamArray = allocateRealArray(numAcceptors, numAcceptorParameters);
acceptorParamArray.resize(numAcceptors);
for (int i = 0; i < numAcceptors; ++i) {
vector<double> parameters;
int a1, a2, a3;
force.getAcceptorParameters(i, a1, a2, a3, parameters);
force.getAcceptorParameters(i, a1, a2, a3, acceptorParamArray[i]);
acceptorParticles[i].push_back(a1);
acceptorParticles[i].push_back(a2);
acceptorParticles[i].push_back(a3);
for (int j = 0; j < numAcceptorParameters; j++)
acceptorParamArray[i][j] = parameters[j];
}
NonbondedMethod nonbondedMethod = CalcCustomHbondForceKernel::NonbondedMethod(force.getNonbondedMethod());
nonbondedCutoff = force.getCutoffDistance();
......@@ -1751,7 +1657,6 @@ void ReferenceCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& c
}
ReferenceCalcCustomCentroidBondForceKernel::~ReferenceCalcCustomCentroidBondForceKernel() {
disposeRealArray(bondParamArray, numBonds);
if (ixn != NULL)
delete ixn;
}
......@@ -1771,13 +1676,9 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system
numBonds = force.getNumBonds();
vector<vector<int> > bondGroups(numBonds);
int numBondParameters = force.getNumPerBondParameters();
bondParamArray = allocateRealArray(numBonds, numBondParameters);
for (int i = 0; i < numBonds; ++i) {
vector<double> parameters;
force.getBondParameters(i, bondGroups[i], parameters);
for (int j = 0; j < numBondParameters; j++)
bondParamArray[i][j] = parameters[j];
}
bondParamArray.resize(numBonds);
for (int i = 0; i < numBonds; ++i)
force.getBondParameters(i, bondGroups[i], bondParamArray[i]);
// Create custom functions for the tabulated functions.
......@@ -1848,7 +1749,6 @@ void ReferenceCalcCustomCentroidBondForceKernel::copyParametersToContext(Context
}
ReferenceCalcCustomCompoundBondForceKernel::~ReferenceCalcCustomCompoundBondForceKernel() {
disposeRealArray(bondParamArray, numBonds);
if (ixn != NULL)
delete ixn;
}
......@@ -1861,13 +1761,9 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system
numBonds = force.getNumBonds();
vector<vector<int> > bondParticles(numBonds);
int numBondParameters = force.getNumPerBondParameters();
bondParamArray = allocateRealArray(numBonds, numBondParameters);
for (int i = 0; i < numBonds; ++i) {
vector<double> parameters;
force.getBondParameters(i, bondParticles[i], parameters);
for (int j = 0; j < numBondParameters; j++)
bondParamArray[i][j] = parameters[j];
}
bondParamArray.resize(numBonds);
for (int i = 0; i < numBonds; ++i)
force.getBondParameters(i, bondParticles[i], bondParamArray[i]);
// Create custom functions for the tabulated functions.
......@@ -1938,7 +1834,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context
}
ReferenceCalcCustomManyParticleForceKernel::~ReferenceCalcCustomManyParticleForceKernel() {
disposeRealArray(particleParamArray, numParticles);
if (ixn != NULL)
delete ixn;
}
......@@ -1949,13 +1844,10 @@ void ReferenceCalcCustomManyParticleForceKernel::initialize(const System& system
numParticles = system.getNumParticles();
int numParticleParameters = force.getNumPerParticleParameters();
particleParamArray = allocateRealArray(numParticles, numParticleParameters);
particleParamArray.resize(numParticles);
for (int i = 0; i < numParticles; ++i) {
vector<double> parameters;
int type;
force.getParticleParameters(i, parameters, type);
for (int j = 0; j < numParticleParameters; j++)
particleParamArray[i][j] = parameters[j];
force.getParticleParameters(i, particleParamArray[i], type);
}
for (int i = 0; i < force.getNumGlobalParameters(); i++)
globalParameterNames.push_back(force.getGlobalParameterName(i));
......
......@@ -69,7 +69,7 @@ void ReferenceAngleBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double* angleParameters,
void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, vector<double>& angleParameters,
double* dEdR, double* energyTerm) const {
double angle;
......@@ -101,9 +101,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double*
--------------------------------------------------------------------------------------- */
void ReferenceAngleBondIxn::calculateBondIxn(int* atomIndices,
void ReferenceAngleBondIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates,
double* parameters,
vector<double>& parameters,
vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) {
......
......@@ -64,9 +64,9 @@ ReferenceBondForce::~ReferenceBondForce() {
--------------------------------------------------------------------------------------- */
void ReferenceBondForce::calculateForce(int numberOfBonds, int** atomIndices,
void ReferenceBondForce::calculateForce(int numberOfBonds, vector<vector<int> >& atomIndices,
vector<Vec3>& atomCoordinates,
double** parameters,
vector<vector<double> >& parameters,
vector<Vec3>& forces,
double *totalEnergy,
ReferenceBondIxn& referenceBondIxn) {
......
......@@ -62,8 +62,8 @@ ReferenceBondIxn::~ReferenceBondIxn() {
--------------------------------------------------------------------------------------- */
void ReferenceBondIxn::calculateBondIxn(int* atomIndices, vector<Vec3>& atomCoordinates,
double* parameters, vector<Vec3>& forces,
void ReferenceBondIxn::calculateBondIxn(vector<int>& atomIndices, vector<Vec3>& atomCoordinates,
vector<double>& parameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) {
}
......
......@@ -206,6 +206,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<Vec3>& atomCoord
--------------------------------------------------------------------------------------- */
void ReferenceCMAPTorsionIxn::calculateBondIxn(int* atomIndices, vector<Vec3>& atomCoordinates,
double* parameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) {
void ReferenceCMAPTorsionIxn::calculateBondIxn(vector<int>& atomIndices, vector<Vec3>& atomCoordinates,
vector<double>& parameters, vector<Vec3>& forces, double* totalEnergy, double* energyParamDerivs) {
}
......@@ -81,9 +81,9 @@ void ReferenceCustomAngleIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void ReferenceCustomAngleIxn::calculateBondIxn(int* atomIndices,
void ReferenceCustomAngleIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates,
double* parameters,
vector<double>& parameters,
vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) {
double deltaR[2][ReferenceForce::LastDeltaRIndex];
......
......@@ -82,9 +82,9 @@ void ReferenceCustomBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void ReferenceCustomBondIxn::calculateBondIxn(int* atomIndices,
void ReferenceCustomBondIxn::calculateBondIxn(vector<int>& atomIndices,
vector<Vec3>& atomCoordinates,
double* parameters,
vector<double>& parameters,
vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) {
double deltaR[ReferenceForce::LastDeltaRIndex];
......
/* Portions copyright (c) 2009-2016 Stanford University and Simbios.
/* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
......@@ -93,7 +93,7 @@ void ReferenceCustomCentroidBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
boxVectors[2] = vectors[2];
}
void ReferenceCustomCentroidBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, double** bondParameters,
void ReferenceCustomCentroidBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& bondParameters,
const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) {
......
......@@ -116,7 +116,7 @@ void ReferenceCustomCompoundBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, double** bondParameters,
void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<Vec3>& atomCoordinates, vector<vector<double> >& bondParameters,
const map<string, double>& globalParameters, vector<Vec3>& forces,
double* totalEnergy, double* energyParamDerivs) {
for (auto& param : globalParameters)
......
/* Portions copyright (c) 2009-2013 Stanford University and Simbios.
/* Portions copyright (c) 2009-2018 Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
......@@ -94,7 +94,7 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn() {
void ReferenceCustomExternalIxn::calculateForce(int atomIndex,
vector<Vec3>& atomCoordinates,
double* parameters,
vector<double>& parameters,
vector<Vec3>& forces,
double* energy) const {
......
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