Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
b4044e73
Commit
b4044e73
authored
May 14, 2012
by
Peter Eastman
Browse files
Created templatized interface for Kernel, which made a lot of code that invokes kernels cleaner.
parent
fcdba25c
Changes
44
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
80 additions
and
66 deletions
+80
-66
olla/include/openmm/Kernel.h
olla/include/openmm/Kernel.h
+15
-1
openmmapi/src/AndersenThermostatImpl.cpp
openmmapi/src/AndersenThermostatImpl.cpp
+2
-2
openmmapi/src/BrownianIntegrator.cpp
openmmapi/src/BrownianIntegrator.cpp
+2
-2
openmmapi/src/CMAPTorsionForceImpl.cpp
openmmapi/src/CMAPTorsionForceImpl.cpp
+2
-2
openmmapi/src/CMMotionRemoverImpl.cpp
openmmapi/src/CMMotionRemoverImpl.cpp
+2
-2
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+22
-22
openmmapi/src/CustomAngleForceImpl.cpp
openmmapi/src/CustomAngleForceImpl.cpp
+2
-2
openmmapi/src/CustomBondForceImpl.cpp
openmmapi/src/CustomBondForceImpl.cpp
+2
-2
openmmapi/src/CustomCompoundBondForceImpl.cpp
openmmapi/src/CustomCompoundBondForceImpl.cpp
+2
-2
openmmapi/src/CustomExternalForceImpl.cpp
openmmapi/src/CustomExternalForceImpl.cpp
+2
-2
openmmapi/src/CustomGBForceImpl.cpp
openmmapi/src/CustomGBForceImpl.cpp
+2
-2
openmmapi/src/CustomHbondForceImpl.cpp
openmmapi/src/CustomHbondForceImpl.cpp
+2
-2
openmmapi/src/CustomIntegrator.cpp
openmmapi/src/CustomIntegrator.cpp
+9
-9
openmmapi/src/CustomNonbondedForceImpl.cpp
openmmapi/src/CustomNonbondedForceImpl.cpp
+2
-2
openmmapi/src/CustomTorsionForceImpl.cpp
openmmapi/src/CustomTorsionForceImpl.cpp
+2
-2
openmmapi/src/GBSAOBCForceImpl.cpp
openmmapi/src/GBSAOBCForceImpl.cpp
+2
-2
openmmapi/src/GBVIForceImpl.cpp
openmmapi/src/GBVIForceImpl.cpp
+2
-2
openmmapi/src/HarmonicAngleForceImpl.cpp
openmmapi/src/HarmonicAngleForceImpl.cpp
+2
-2
openmmapi/src/HarmonicBondForceImpl.cpp
openmmapi/src/HarmonicBondForceImpl.cpp
+2
-2
openmmapi/src/LangevinIntegrator.cpp
openmmapi/src/LangevinIntegrator.cpp
+2
-2
No files found.
olla/include/openmm/Kernel.h
View file @
b4044e73
...
...
@@ -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 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2012
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -79,6 +79,20 @@ public:
* Get the object which implements this Kernel.
*/
KernelImpl
&
getImpl
();
/**
* Get a reference to the object which implements this Kernel, casting it to the specified type.
*/
template
<
class
T
>
const
T
&
getAs
()
const
{
return
dynamic_cast
<
T
&>
(
*
impl
);
}
/**
* Get a reference to the object which implements this Kernel, casting it to the specified type.
*/
template
<
class
T
>
T
&
getAs
()
{
return
dynamic_cast
<
T
&>
(
*
impl
);
}
private:
KernelImpl
*
impl
;
};
...
...
openmmapi/src/AndersenThermostatImpl.cpp
View file @
b4044e73
...
...
@@ -44,11 +44,11 @@ AndersenThermostatImpl::AndersenThermostatImpl(AndersenThermostat& owner) : owne
void
AndersenThermostatImpl
::
initialize
(
ContextImpl
&
context
)
{
kernel
=
context
.
getPlatform
().
createKernel
(
ApplyAndersenThermostatKernel
::
Name
(),
context
);
dynamic_cast
<
ApplyAndersenThermostatKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
ApplyAndersenThermostatKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
void
AndersenThermostatImpl
::
updateContextState
(
ContextImpl
&
context
)
{
dynamic_cast
<
ApplyAndersenThermostatKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
);
kernel
.
getAs
<
ApplyAndersenThermostatKernel
>
().
execute
(
context
);
}
std
::
map
<
std
::
string
,
double
>
AndersenThermostatImpl
::
getDefaultParameters
()
{
...
...
openmmapi/src/BrownianIntegrator.cpp
View file @
b4044e73
...
...
@@ -55,7 +55,7 @@ void BrownianIntegrator::initialize(ContextImpl& contextRef) {
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateBrownianStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateBrownianStepKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
contextRef
.
getSystem
(),
*
this
);
kernel
.
getAs
<
IntegrateBrownianStepKernel
>
().
initialize
(
contextRef
.
getSystem
(),
*
this
);
}
vector
<
string
>
BrownianIntegrator
::
getKernelNames
()
{
...
...
@@ -68,6 +68,6 @@ void BrownianIntegrator::step(int steps) {
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
dynamic_cast
<
IntegrateBrownianStepKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
*
context
,
*
this
);
kernel
.
getAs
<
IntegrateBrownianStepKernel
>
().
execute
(
*
context
,
*
this
);
}
}
openmmapi/src/CMAPTorsionForceImpl.cpp
View file @
b4044e73
...
...
@@ -49,12 +49,12 @@ CMAPTorsionForceImpl::~CMAPTorsionForceImpl() {
void
CMAPTorsionForceImpl
::
initialize
(
ContextImpl
&
context
)
{
kernel
=
context
.
getPlatform
().
createKernel
(
CalcCMAPTorsionForceKernel
::
Name
(),
context
);
dynamic_cast
<
CalcCMAPTorsionForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCMAPTorsionForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CMAPTorsionForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCMAPTorsionForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCMAPTorsionForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CMMotionRemoverImpl.cpp
View file @
b4044e73
...
...
@@ -45,11 +45,11 @@ CMMotionRemoverImpl::CMMotionRemoverImpl(CMMotionRemover& owner) : owner(owner)
void
CMMotionRemoverImpl
::
initialize
(
ContextImpl
&
context
)
{
kernel
=
context
.
getPlatform
().
createKernel
(
RemoveCMMotionKernel
::
Name
(),
context
);
const
System
&
system
=
context
.
getSystem
();
dynamic_cast
<
RemoveCMMotionKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
system
,
owner
);
kernel
.
getAs
<
RemoveCMMotionKernel
>
().
initialize
(
system
,
owner
);
}
void
CMMotionRemoverImpl
::
updateContextState
(
ContextImpl
&
context
)
{
dynamic_cast
<
RemoveCMMotionKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
);
kernel
.
getAs
<
RemoveCMMotionKernel
>
().
execute
(
context
);
}
std
::
vector
<
std
::
string
>
CMMotionRemoverImpl
::
getKernelNames
()
{
...
...
openmmapi/src/ContextImpl.cpp
View file @
b4044e73
...
...
@@ -97,22 +97,22 @@ ContextImpl::ContextImpl(Context& owner, System& system, Integrator& integrator,
platform
->
contextCreated
(
*
this
,
properties
);
initializeForcesKernel
=
platform
->
createKernel
(
CalcForcesAndEnergyKernel
::
Name
(),
*
this
);
dynamic_cast
<
CalcForcesAndEnergyKernel
&
>
(
initializeForcesKernel
.
getImpl
()
).
initialize
(
system
);
initializeForcesKernel
.
getAs
<
CalcForcesAndEnergyKernel
>
().
initialize
(
system
);
kineticEnergyKernel
=
platform
->
createKernel
(
CalcKineticEnergyKernel
::
Name
(),
*
this
);
dynamic_cast
<
CalcK
ineticEnergyKernel
&>
(
k
ineticEnergyKernel
.
getImpl
()
).
initialize
(
system
);
k
ineticEnergyKernel
.
getAs
<
CalcK
ineticEnergyKernel
>
(
).
initialize
(
system
);
updateStateDataKernel
=
platform
->
createKernel
(
UpdateStateDataKernel
::
Name
(),
*
this
);
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
initialize
(
system
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
initialize
(
system
);
applyConstraintsKernel
=
platform
->
createKernel
(
ApplyConstraintsKernel
::
Name
(),
*
this
);
dynamic_cast
<
A
pplyConstraintsKernel
&>
(
a
pplyConstraintsKernel
.
getImpl
()
).
initialize
(
system
);
a
pplyConstraintsKernel
.
getAs
<
A
pplyConstraintsKernel
>
(
).
initialize
(
system
);
virtualSitesKernel
=
platform
->
createKernel
(
VirtualSitesKernel
::
Name
(),
*
this
);
dynamic_cast
<
V
irtualSitesKernel
&>
(
v
irtualSitesKernel
.
getImpl
()
).
initialize
(
system
);
v
irtualSitesKernel
.
getAs
<
V
irtualSitesKernel
>
(
).
initialize
(
system
);
Vec3
periodicBoxVectors
[
3
];
system
.
getDefaultPeriodicBoxVectors
(
periodicBoxVectors
[
0
],
periodicBoxVectors
[
1
],
periodicBoxVectors
[
2
]);
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
setPeriodicBoxVectors
(
*
this
,
periodicBoxVectors
[
0
],
periodicBoxVectors
[
1
],
periodicBoxVectors
[
2
]);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
setPeriodicBoxVectors
(
*
this
,
periodicBoxVectors
[
0
],
periodicBoxVectors
[
1
],
periodicBoxVectors
[
2
]);
for
(
size_t
i
=
0
;
i
<
forceImpls
.
size
();
++
i
)
forceImpls
[
i
]
->
initialize
(
*
this
);
integrator
.
initialize
(
*
this
);
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
setVelocities
(
*
this
,
vector
<
Vec3
>
(
system
.
getNumParticles
()));
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
setVelocities
(
*
this
,
vector
<
Vec3
>
(
system
.
getNumParticles
()));
}
ContextImpl
::~
ContextImpl
()
{
...
...
@@ -122,33 +122,33 @@ ContextImpl::~ContextImpl() {
}
double
ContextImpl
::
getTime
()
const
{
return
dynamic_cast
<
const
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
getTime
(
*
this
);
return
u
pdateStateDataKernel
.
getAs
<
const
U
pdateStateDataKernel
>
(
).
getTime
(
*
this
);
}
void
ContextImpl
::
setTime
(
double
t
)
{
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
setTime
(
*
this
,
t
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
setTime
(
*
this
,
t
);
}
void
ContextImpl
::
getPositions
(
std
::
vector
<
Vec3
>&
positions
)
{
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
getPositions
(
*
this
,
positions
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
getPositions
(
*
this
,
positions
);
}
void
ContextImpl
::
setPositions
(
const
std
::
vector
<
Vec3
>&
positions
)
{
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
setPositions
(
*
this
,
positions
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
setPositions
(
*
this
,
positions
);
integrator
.
stateChanged
(
State
::
Positions
);
}
void
ContextImpl
::
getVelocities
(
std
::
vector
<
Vec3
>&
velocities
)
{
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
getVelocities
(
*
this
,
velocities
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
getVelocities
(
*
this
,
velocities
);
}
void
ContextImpl
::
setVelocities
(
const
std
::
vector
<
Vec3
>&
velocities
)
{
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
setVelocities
(
*
this
,
velocities
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
setVelocities
(
*
this
,
velocities
);
integrator
.
stateChanged
(
State
::
Velocities
);
}
void
ContextImpl
::
getForces
(
std
::
vector
<
Vec3
>&
forces
)
{
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
getForces
(
*
this
,
forces
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
getForces
(
*
this
,
forces
);
}
const
std
::
map
<
std
::
string
,
double
>&
ContextImpl
::
getParameters
()
const
{
...
...
@@ -169,7 +169,7 @@ void ContextImpl::setParameter(std::string name, double value) {
}
void
ContextImpl
::
getPeriodicBoxVectors
(
Vec3
&
a
,
Vec3
&
b
,
Vec3
&
c
)
{
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
getPeriodicBoxVectors
(
*
this
,
a
,
b
,
c
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
getPeriodicBoxVectors
(
*
this
,
a
,
b
,
c
);
}
void
ContextImpl
::
setPeriodicBoxVectors
(
const
Vec3
&
a
,
const
Vec3
&
b
,
const
Vec3
&
c
)
{
...
...
@@ -179,20 +179,20 @@ void ContextImpl::setPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3
throw
OpenMMException
(
"Second periodic box vector must be parallel to y."
);
if
(
c
[
0
]
!=
0.0
||
c
[
1
]
!=
0.0
)
throw
OpenMMException
(
"Third periodic box vector must be parallel to z."
);
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
setPeriodicBoxVectors
(
*
this
,
a
,
b
,
c
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
setPeriodicBoxVectors
(
*
this
,
a
,
b
,
c
);
}
void
ContextImpl
::
applyConstraints
(
double
tol
)
{
dynamic_cast
<
A
pplyConstraintsKernel
&>
(
a
pplyConstraintsKernel
.
getImpl
()
).
apply
(
*
this
,
tol
);
a
pplyConstraintsKernel
.
getAs
<
A
pplyConstraintsKernel
>
(
).
apply
(
*
this
,
tol
);
}
void
ContextImpl
::
computeVirtualSites
()
{
dynamic_cast
<
V
irtualSitesKernel
&>
(
v
irtualSitesKernel
.
getImpl
()
).
computePositions
(
*
this
);
v
irtualSitesKernel
.
getAs
<
V
irtualSitesKernel
>
(
).
computePositions
(
*
this
);
}
double
ContextImpl
::
calcForcesAndEnergy
(
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
lastForceGroups
=
groups
;
CalcForcesAndEnergyKernel
&
kernel
=
dynamic_cast
<
CalcForcesAndEnergyKernel
&
>
(
initializeForcesKernel
.
getImpl
()
);
CalcForcesAndEnergyKernel
&
kernel
=
initializeForcesKernel
.
getAs
<
CalcForcesAndEnergyKernel
>
();
double
energy
=
0.0
;
kernel
.
beginComputation
(
*
this
,
includeForces
,
includeEnergy
,
groups
);
for
(
int
i
=
0
;
i
<
(
int
)
forceImpls
.
size
();
++
i
)
...
...
@@ -206,7 +206,7 @@ int ContextImpl::getLastForceGroups() const {
}
double
ContextImpl
::
calcKineticEnergy
()
{
return
dynamic_cast
<
CalcK
ineticEnergyKernel
&>
(
k
ineticEnergyKernel
.
getImpl
()
).
execute
(
*
this
);
return
k
ineticEnergyKernel
.
getAs
<
CalcK
ineticEnergyKernel
>
(
).
execute
(
*
this
);
}
void
ContextImpl
::
updateContextState
()
{
...
...
@@ -312,7 +312,7 @@ void ContextImpl::createCheckpoint(ostream& stream) {
writeString
(
stream
,
iter
->
first
);
stream
.
write
((
char
*
)
&
iter
->
second
,
sizeof
(
double
));
}
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
createCheckpoint
(
*
this
,
stream
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
createCheckpoint
(
*
this
,
stream
);
stream
.
flush
();
}
...
...
@@ -332,5 +332,5 @@ void ContextImpl::loadCheckpoint(istream& stream) {
stream
.
read
((
char
*
)
&
value
,
sizeof
(
double
));
parameters
[
name
]
=
value
;
}
dynamic_cast
<
U
pdateStateDataKernel
&>
(
u
pdateStateDataKernel
.
getImpl
()
).
loadCheckpoint
(
*
this
,
stream
);
u
pdateStateDataKernel
.
getAs
<
U
pdateStateDataKernel
>
(
).
loadCheckpoint
(
*
this
,
stream
);
}
openmmapi/src/CustomAngleForceImpl.cpp
View file @
b4044e73
...
...
@@ -85,12 +85,12 @@ void CustomAngleForceImpl::initialize(ContextImpl& context) {
throw
OpenMMException
(
msg
.
str
());
}
}
dynamic_cast
<
CalcCustomAngleForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomAngleForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomAngleForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomAngleForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomAngleForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CustomBondForceImpl.cpp
View file @
b4044e73
...
...
@@ -79,12 +79,12 @@ void CustomBondForceImpl::initialize(ContextImpl& context) {
throw
OpenMMException
(
msg
.
str
());
}
}
dynamic_cast
<
CalcCustomBondForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomBondForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomBondForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomBondForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomBondForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CustomCompoundBondForceImpl.cpp
View file @
b4044e73
...
...
@@ -102,12 +102,12 @@ void CustomCompoundBondForceImpl::initialize(ContextImpl& context) {
throw
OpenMMException
(
msg
.
str
());
}
}
dynamic_cast
<
CalcCustomCompoundBondForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomCompoundBondForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomCompoundBondForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomCompoundBondForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomCompoundBondForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CustomExternalForceImpl.cpp
View file @
b4044e73
...
...
@@ -73,12 +73,12 @@ void CustomExternalForceImpl::initialize(ContextImpl& context) {
throw
OpenMMException
(
msg
.
str
());
}
}
dynamic_cast
<
CalcCustomExternalForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomExternalForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomExternalForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomExternalForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomExternalForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CustomGBForceImpl.cpp
View file @
b4044e73
...
...
@@ -102,12 +102,12 @@ void CustomGBForceImpl::initialize(ContextImpl& context) {
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
throw
OpenMMException
(
"CustomGBForce: The cutoff distance cannot be greater than half the periodic box size."
);
}
dynamic_cast
<
CalcCustomGBForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomGBForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomGBForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomGBForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomGBForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CustomHbondForceImpl.cpp
View file @
b4044e73
...
...
@@ -175,12 +175,12 @@ void CustomHbondForceImpl::initialize(ContextImpl& context) {
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
throw
OpenMMException
(
"CustomHbondForce: The cutoff distance cannot be greater than half the periodic box size."
);
}
dynamic_cast
<
CalcCustomHbondForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomHbondForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomHbondForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomHbondForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomHbondForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CustomIntegrator.cpp
View file @
b4044e73
...
...
@@ -54,12 +54,12 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateCustomStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
contextRef
.
getSystem
(),
*
this
);
dynamic_cast
<
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
setGlobalVariables
(
contextRef
,
globalValues
);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
initialize
(
contextRef
.
getSystem
(),
*
this
);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
setGlobalVariables
(
contextRef
,
globalValues
);
for
(
int
i
=
0
;
i
<
(
int
)
perDofValues
.
size
();
i
++
)
{
if
(
perDofValues
[
i
].
size
()
==
1
)
perDofValues
[
i
].
resize
(
context
->
getSystem
().
getNumParticles
(),
perDofValues
[
i
][
0
]);
dynamic_cast
<
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
setPerDofVariable
(
contextRef
,
i
,
perDofValues
[
i
]);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
setPerDofVariable
(
contextRef
,
i
,
perDofValues
[
i
]);
}
}
...
...
@@ -76,7 +76,7 @@ vector<string> CustomIntegrator::getKernelNames() {
void
CustomIntegrator
::
step
(
int
steps
)
{
globalsAreCurrent
=
false
;
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
dynamic_cast
<
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
*
context
,
*
this
,
forcesAreValid
);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
execute
(
*
context
,
*
this
,
forcesAreValid
);
}
}
...
...
@@ -109,7 +109,7 @@ const string& CustomIntegrator::getPerDofVariableName(int index) const {
double
CustomIntegrator
::
getGlobalVariable
(
int
index
)
const
{
ASSERT_VALID_INDEX
(
index
,
globalValues
);
if
(
owner
!=
NULL
&&
!
globalsAreCurrent
)
{
dynamic_cast
<
const
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
getGlobalVariables
(
*
context
,
globalValues
);
kernel
.
getAs
<
const
IntegrateCustomStepKernel
>
().
getGlobalVariables
(
*
context
,
globalValues
);
globalsAreCurrent
=
true
;
}
return
globalValues
[
index
];
...
...
@@ -118,12 +118,12 @@ double CustomIntegrator::getGlobalVariable(int index) const {
void
CustomIntegrator
::
setGlobalVariable
(
int
index
,
double
value
)
{
ASSERT_VALID_INDEX
(
index
,
globalValues
);
if
(
owner
!=
NULL
&&
!
globalsAreCurrent
)
{
dynamic_cast
<
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
getGlobalVariables
(
*
context
,
globalValues
);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
getGlobalVariables
(
*
context
,
globalValues
);
globalsAreCurrent
=
true
;
}
globalValues
[
index
]
=
value
;
if
(
owner
!=
NULL
)
dynamic_cast
<
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
setGlobalVariables
(
*
context
,
globalValues
);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
setGlobalVariables
(
*
context
,
globalValues
);
}
void
CustomIntegrator
::
setGlobalVariableByName
(
const
string
&
name
,
double
value
)
{
...
...
@@ -140,7 +140,7 @@ void CustomIntegrator::getPerDofVariable(int index, vector<Vec3>& values) const
if
(
owner
==
NULL
)
values
=
perDofValues
[
index
];
else
dynamic_cast
<
const
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
getPerDofVariable
(
*
context
,
index
,
values
);
kernel
.
getAs
<
const
IntegrateCustomStepKernel
>
().
getPerDofVariable
(
*
context
,
index
,
values
);
}
void
CustomIntegrator
::
setPerDofVariable
(
int
index
,
const
vector
<
Vec3
>&
values
)
{
...
...
@@ -150,7 +150,7 @@ void CustomIntegrator::setPerDofVariable(int index, const vector<Vec3>& values)
if
(
owner
==
NULL
)
perDofValues
[
index
]
=
values
;
else
dynamic_cast
<
IntegrateCustomStepKernel
&
>
(
kernel
.
getImpl
()
).
setPerDofVariable
(
*
context
,
index
,
values
);
kernel
.
getAs
<
IntegrateCustomStepKernel
>
().
setPerDofVariable
(
*
context
,
index
,
values
);
}
void
CustomIntegrator
::
setPerDofVariableByName
(
const
string
&
name
,
const
vector
<
Vec3
>&
value
)
{
...
...
openmmapi/src/CustomNonbondedForceImpl.cpp
View file @
b4044e73
...
...
@@ -102,12 +102,12 @@ void CustomNonbondedForceImpl::initialize(ContextImpl& context) {
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
throw
OpenMMException
(
"CustomNonbondedForce: The cutoff distance cannot be greater than half the periodic box size."
);
}
dynamic_cast
<
CalcCustomNonbondedForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomNonbondedForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomNonbondedForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomNonbondedForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomNonbondedForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/CustomTorsionForceImpl.cpp
View file @
b4044e73
...
...
@@ -91,12 +91,12 @@ void CustomTorsionForceImpl::initialize(ContextImpl& context) {
throw
OpenMMException
(
msg
.
str
());
}
}
dynamic_cast
<
CalcCustomTorsionForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcCustomTorsionForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
CustomTorsionForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcCustomTorsionForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcCustomTorsionForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/GBSAOBCForceImpl.cpp
View file @
b4044e73
...
...
@@ -52,12 +52,12 @@ void GBSAOBCForceImpl::initialize(ContextImpl& context) {
if
(
cutoff
>
0.5
*
boxVectors
[
0
][
0
]
||
cutoff
>
0.5
*
boxVectors
[
1
][
1
]
||
cutoff
>
0.5
*
boxVectors
[
2
][
2
])
throw
OpenMMException
(
"GBSAOBCForce: The cutoff distance cannot be greater than half the periodic box size."
);
}
dynamic_cast
<
CalcGBSAOBCForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcGBSAOBCForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
GBSAOBCForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcGBSAOBCForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcGBSAOBCForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/GBVIForceImpl.cpp
View file @
b4044e73
...
...
@@ -106,7 +106,7 @@ void GBVIForceImpl::initialize(ContextImpl& context) {
scaledRadii
.
resize
(
numberOfParticles
);
findScaledRadii
(
numberOfParticles
,
bondIndices
,
bondLengths
,
scaledRadii
);
dynamic_cast
<
CalcGBVIForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
,
scaledRadii
);
kernel
.
getAs
<
CalcGBVIForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
,
scaledRadii
);
}
int
GBVIForceImpl
::
getBondsFromForces
(
ContextImpl
&
context
)
{
...
...
@@ -241,7 +241,7 @@ void GBVIForceImpl::findScaledRadii( int numberOfParticles, const std::vector<st
double
GBVIForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcGBVIForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcGBVIForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/HarmonicAngleForceImpl.cpp
View file @
b4044e73
...
...
@@ -46,12 +46,12 @@ HarmonicAngleForceImpl::~HarmonicAngleForceImpl() {
void
HarmonicAngleForceImpl
::
initialize
(
ContextImpl
&
context
)
{
kernel
=
context
.
getPlatform
().
createKernel
(
CalcHarmonicAngleForceKernel
::
Name
(),
context
);
dynamic_cast
<
CalcHarmonicAngleForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcHarmonicAngleForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
HarmonicAngleForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcHarmonicAngleForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcHarmonicAngleForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/HarmonicBondForceImpl.cpp
View file @
b4044e73
...
...
@@ -46,12 +46,12 @@ HarmonicBondForceImpl::~HarmonicBondForceImpl() {
void
HarmonicBondForceImpl
::
initialize
(
ContextImpl
&
context
)
{
kernel
=
context
.
getPlatform
().
createKernel
(
CalcHarmonicBondForceKernel
::
Name
(),
context
);
dynamic_cast
<
CalcHarmonicBondForceKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
CalcHarmonicBondForceKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
}
double
HarmonicBondForceImpl
::
calcForcesAndEnergy
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
)
{
if
((
groups
&
(
1
<<
owner
.
getForceGroup
()))
!=
0
)
return
dynamic_cast
<
CalcHarmonicBondForceKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
context
,
includeForces
,
includeEnergy
);
return
kernel
.
getAs
<
CalcHarmonicBondForceKernel
>
().
execute
(
context
,
includeForces
,
includeEnergy
);
return
0.0
;
}
...
...
openmmapi/src/LangevinIntegrator.cpp
View file @
b4044e73
...
...
@@ -55,7 +55,7 @@ void LangevinIntegrator::initialize(ContextImpl& contextRef) {
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateLangevinStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateLangevinStepKernel
&
>
(
kernel
.
getImpl
()
).
initialize
(
contextRef
.
getSystem
(),
*
this
);
kernel
.
getAs
<
IntegrateLangevinStepKernel
>
().
initialize
(
contextRef
.
getSystem
(),
*
this
);
}
vector
<
string
>
LangevinIntegrator
::
getKernelNames
()
{
...
...
@@ -68,6 +68,6 @@ void LangevinIntegrator::step(int steps) {
for
(
int
i
=
0
;
i
<
steps
;
++
i
)
{
context
->
updateContextState
();
context
->
calcForcesAndEnergy
(
true
,
false
);
dynamic_cast
<
IntegrateLangevinStepKernel
&
>
(
kernel
.
getImpl
()
).
execute
(
*
context
,
*
this
);
kernel
.
getAs
<
IntegrateLangevinStepKernel
>
().
execute
(
*
context
,
*
this
);
}
}
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment