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
0307a0db
Commit
0307a0db
authored
Apr 15, 2013
by
Yutong Zhao
Browse files
Context constructor now uses const System&, guaranteeing that System won't be modified.
parent
19757775
Changes
138
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
33 additions
and
38 deletions
+33
-38
openmmapi/include/openmm/internal/PeriodicTorsionForceImpl.h
openmmapi/include/openmm/internal/PeriodicTorsionForceImpl.h
+3
-3
openmmapi/include/openmm/internal/RBTorsionForceImpl.h
openmmapi/include/openmm/internal/RBTorsionForceImpl.h
+3
-3
openmmapi/src/AndersenThermostat.cpp
openmmapi/src/AndersenThermostat.cpp
+1
-1
openmmapi/src/AndersenThermostatImpl.cpp
openmmapi/src/AndersenThermostatImpl.cpp
+1
-1
openmmapi/src/CMAPTorsionForce.cpp
openmmapi/src/CMAPTorsionForce.cpp
+1
-1
openmmapi/src/CMAPTorsionForceImpl.cpp
openmmapi/src/CMAPTorsionForceImpl.cpp
+1
-1
openmmapi/src/CMMotionRemover.cpp
openmmapi/src/CMMotionRemover.cpp
+1
-1
openmmapi/src/CMMotionRemoverImpl.cpp
openmmapi/src/CMMotionRemoverImpl.cpp
+1
-1
openmmapi/src/Context.cpp
openmmapi/src/Context.cpp
+5
-9
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+1
-1
openmmapi/src/CustomAngleForce.cpp
openmmapi/src/CustomAngleForce.cpp
+1
-1
openmmapi/src/CustomAngleForceImpl.cpp
openmmapi/src/CustomAngleForceImpl.cpp
+2
-3
openmmapi/src/CustomBondForce.cpp
openmmapi/src/CustomBondForce.cpp
+1
-1
openmmapi/src/CustomBondForceImpl.cpp
openmmapi/src/CustomBondForceImpl.cpp
+2
-2
openmmapi/src/CustomCompoundBondForce.cpp
openmmapi/src/CustomCompoundBondForce.cpp
+1
-1
openmmapi/src/CustomCompoundBondForceImpl.cpp
openmmapi/src/CustomCompoundBondForceImpl.cpp
+2
-2
openmmapi/src/CustomExternalForce.cpp
openmmapi/src/CustomExternalForce.cpp
+1
-1
openmmapi/src/CustomExternalForceImpl.cpp
openmmapi/src/CustomExternalForceImpl.cpp
+2
-2
openmmapi/src/CustomGBForce.cpp
openmmapi/src/CustomGBForce.cpp
+1
-1
openmmapi/src/CustomGBForceImpl.cpp
openmmapi/src/CustomGBForceImpl.cpp
+2
-2
No files found.
openmmapi/include/openmm/internal/PeriodicTorsionForceImpl.h
View file @
0307a0db
...
...
@@ -47,10 +47,10 @@ namespace OpenMM {
class
PeriodicTorsionForceImpl
:
public
ForceImpl
{
public:
PeriodicTorsionForceImpl
(
PeriodicTorsionForce
&
owner
);
PeriodicTorsionForceImpl
(
const
PeriodicTorsionForce
&
owner
);
~
PeriodicTorsionForceImpl
();
void
initialize
(
ContextImpl
&
context
);
PeriodicTorsionForce
&
getOwner
()
{
const
PeriodicTorsionForce
&
getOwner
()
const
{
return
owner
;
}
void
updateContextState
(
ContextImpl
&
context
)
{
...
...
@@ -63,7 +63,7 @@ public:
std
::
vector
<
std
::
string
>
getKernelNames
();
void
updateParametersInContext
(
ContextImpl
&
context
);
private:
PeriodicTorsionForce
&
owner
;
const
PeriodicTorsionForce
&
owner
;
Kernel
kernel
;
};
...
...
openmmapi/include/openmm/internal/RBTorsionForceImpl.h
View file @
0307a0db
...
...
@@ -47,10 +47,10 @@ namespace OpenMM {
class
RBTorsionForceImpl
:
public
ForceImpl
{
public:
RBTorsionForceImpl
(
RBTorsionForce
&
owner
);
RBTorsionForceImpl
(
const
RBTorsionForce
&
owner
);
~
RBTorsionForceImpl
();
void
initialize
(
ContextImpl
&
context
);
RBTorsionForce
&
getOwner
()
{
const
RBTorsionForce
&
getOwner
()
const
{
return
owner
;
}
void
updateContextState
(
ContextImpl
&
context
)
{
...
...
@@ -63,7 +63,7 @@ public:
std
::
vector
<
std
::
string
>
getKernelNames
();
void
updateParametersInContext
(
ContextImpl
&
context
);
private:
RBTorsionForce
&
owner
;
const
RBTorsionForce
&
owner
;
Kernel
kernel
;
};
...
...
openmmapi/src/AndersenThermostat.cpp
View file @
0307a0db
...
...
@@ -40,6 +40,6 @@ AndersenThermostat::AndersenThermostat(double defaultTemperature, double default
setRandomNumberSeed
((
int
)
time
(
NULL
));
}
ForceImpl
*
AndersenThermostat
::
createImpl
()
{
ForceImpl
*
AndersenThermostat
::
createImpl
()
const
{
return
new
AndersenThermostatImpl
(
*
this
);
}
openmmapi/src/AndersenThermostatImpl.cpp
View file @
0307a0db
...
...
@@ -39,7 +39,7 @@
using
namespace
OpenMM
;
using
std
::
vector
;
AndersenThermostatImpl
::
AndersenThermostatImpl
(
AndersenThermostat
&
owner
)
:
owner
(
owner
)
{
AndersenThermostatImpl
::
AndersenThermostatImpl
(
const
AndersenThermostat
&
owner
)
:
owner
(
owner
)
{
}
void
AndersenThermostatImpl
::
initialize
(
ContextImpl
&
context
)
{
...
...
openmmapi/src/CMAPTorsionForce.cpp
View file @
0307a0db
...
...
@@ -92,7 +92,7 @@ void CMAPTorsionForce::setTorsionParameters(int index, int map, int a1, int a2,
torsions
[
index
].
b4
=
b4
;
}
ForceImpl
*
CMAPTorsionForce
::
createImpl
()
{
ForceImpl
*
CMAPTorsionForce
::
createImpl
()
const
{
return
new
CMAPTorsionForceImpl
(
*
this
);
}
openmmapi/src/CMAPTorsionForceImpl.cpp
View file @
0307a0db
...
...
@@ -41,7 +41,7 @@
using
namespace
OpenMM
;
using
namespace
std
;
CMAPTorsionForceImpl
::
CMAPTorsionForceImpl
(
CMAPTorsionForce
&
owner
)
:
owner
(
owner
)
{
CMAPTorsionForceImpl
::
CMAPTorsionForceImpl
(
const
CMAPTorsionForce
&
owner
)
:
owner
(
owner
)
{
}
CMAPTorsionForceImpl
::~
CMAPTorsionForceImpl
()
{
...
...
openmmapi/src/CMMotionRemover.cpp
View file @
0307a0db
...
...
@@ -37,6 +37,6 @@ using namespace OpenMM;
CMMotionRemover
::
CMMotionRemover
(
int
frequency
)
:
frequency
(
frequency
)
{
}
ForceImpl
*
CMMotionRemover
::
createImpl
()
{
ForceImpl
*
CMMotionRemover
::
createImpl
()
const
{
return
new
CMMotionRemoverImpl
(
*
this
);
}
openmmapi/src/CMMotionRemoverImpl.cpp
View file @
0307a0db
...
...
@@ -39,7 +39,7 @@
using
namespace
OpenMM
;
using
std
::
vector
;
CMMotionRemoverImpl
::
CMMotionRemoverImpl
(
CMMotionRemover
&
owner
)
:
owner
(
owner
)
{
CMMotionRemoverImpl
::
CMMotionRemoverImpl
(
const
CMMotionRemover
&
owner
)
:
owner
(
owner
)
{
}
void
CMMotionRemoverImpl
::
initialize
(
ContextImpl
&
context
)
{
...
...
openmmapi/src/Context.cpp
View file @
0307a0db
...
...
@@ -40,15 +40,15 @@
using
namespace
OpenMM
;
using
namespace
std
;
Context
::
Context
(
System
&
system
,
Integrator
&
integrator
)
:
properties
(
map
<
string
,
string
>
())
{
Context
::
Context
(
const
System
&
system
,
Integrator
&
integrator
)
:
properties
(
map
<
string
,
string
>
())
{
impl
=
new
ContextImpl
(
*
this
,
system
,
integrator
,
0
,
properties
);
}
Context
::
Context
(
System
&
system
,
Integrator
&
integrator
,
Platform
&
platform
)
:
properties
(
map
<
string
,
string
>
())
{
Context
::
Context
(
const
System
&
system
,
Integrator
&
integrator
,
Platform
&
platform
)
:
properties
(
map
<
string
,
string
>
())
{
impl
=
new
ContextImpl
(
*
this
,
system
,
integrator
,
&
platform
,
properties
);
}
Context
::
Context
(
System
&
system
,
Integrator
&
integrator
,
Platform
&
platform
,
const
map
<
string
,
string
>&
properties
)
:
properties
(
properties
)
{
Context
::
Context
(
const
System
&
system
,
Integrator
&
integrator
,
Platform
&
platform
,
const
map
<
string
,
string
>&
properties
)
:
properties
(
properties
)
{
impl
=
new
ContextImpl
(
*
this
,
system
,
integrator
,
&
platform
,
properties
);
}
...
...
@@ -61,10 +61,6 @@ const System& Context::getSystem() const {
}
System
&
Context
::
getSystem
()
{
return
impl
->
getSystem
();
}
const
Integrator
&
Context
::
getIntegrator
()
const
{
return
impl
->
getIntegrator
();
}
...
...
@@ -204,7 +200,7 @@ void Context::setVelocities(const vector<Vec3>& velocities) {
}
void
Context
::
setVelocitiesToTemperature
(
double
temperature
,
int
randomSeed
)
{
System
&
system
=
impl
->
getSystem
();
const
System
&
system
=
impl
->
getSystem
();
// Generate the list of Gaussian random numbers.
...
...
@@ -263,7 +259,7 @@ void Context::computeVirtualSites() {
}
void
Context
::
reinitialize
()
{
System
&
system
=
impl
->
getSystem
();
const
System
&
system
=
impl
->
getSystem
();
Integrator
&
integrator
=
impl
->
getIntegrator
();
Platform
&
platform
=
impl
->
getPlatform
();
integrator
.
cleanup
();
...
...
openmmapi/src/ContextImpl.cpp
View file @
0307a0db
...
...
@@ -47,7 +47,7 @@
using
namespace
OpenMM
;
using
namespace
std
;
ContextImpl
::
ContextImpl
(
Context
&
owner
,
System
&
system
,
Integrator
&
integrator
,
Platform
*
platform
,
const
map
<
string
,
string
>&
properties
)
:
ContextImpl
::
ContextImpl
(
Context
&
owner
,
const
System
&
system
,
Integrator
&
integrator
,
Platform
*
platform
,
const
map
<
string
,
string
>&
properties
)
:
owner
(
owner
),
system
(
system
),
integrator
(
integrator
),
hasInitializedForces
(
false
),
hasSetPositions
(
false
),
integratorIsDeleted
(
false
),
lastForceGroups
(
-
1
),
platform
(
platform
),
platformData
(
NULL
)
{
if
(
system
.
getNumParticles
()
==
0
)
...
...
openmmapi/src/CustomAngleForce.cpp
View file @
0307a0db
...
...
@@ -116,7 +116,7 @@ void CustomAngleForce::setAngleParameters(int index, int particle1, int particle
angles
[
index
].
particle3
=
particle3
;
}
ForceImpl
*
CustomAngleForce
::
createImpl
()
{
ForceImpl
*
CustomAngleForce
::
createImpl
()
const
{
return
new
CustomAngleForceImpl
(
*
this
);
}
...
...
openmmapi/src/CustomAngleForceImpl.cpp
View file @
0307a0db
...
...
@@ -43,7 +43,7 @@ using std::set;
using
std
::
string
;
using
std
::
stringstream
;
CustomAngleForceImpl
::
CustomAngleForceImpl
(
CustomAngleForce
&
owner
)
:
owner
(
owner
)
{
CustomAngleForceImpl
::
CustomAngleForceImpl
(
const
CustomAngleForce
&
owner
)
:
owner
(
owner
)
{
}
CustomAngleForceImpl
::~
CustomAngleForceImpl
()
{
...
...
@@ -53,8 +53,7 @@ void CustomAngleForceImpl::initialize(ContextImpl& context) {
kernel
=
context
.
getPlatform
().
createKernel
(
CalcCustomAngleForceKernel
::
Name
(),
context
);
// Check for errors in the specification of bonds.
System
&
system
=
context
.
getSystem
();
const
System
&
system
=
context
.
getSystem
();
vector
<
double
>
parameters
;
int
numParameters
=
owner
.
getNumPerAngleParameters
();
for
(
int
i
=
0
;
i
<
owner
.
getNumAngles
();
i
++
)
{
...
...
openmmapi/src/CustomBondForce.cpp
View file @
0307a0db
...
...
@@ -114,7 +114,7 @@ void CustomBondForce::setBondParameters(int index, int particle1, int particle2,
bonds
[
index
].
particle2
=
particle2
;
}
ForceImpl
*
CustomBondForce
::
createImpl
()
{
ForceImpl
*
CustomBondForce
::
createImpl
()
const
{
return
new
CustomBondForceImpl
(
*
this
);
}
...
...
openmmapi/src/CustomBondForceImpl.cpp
View file @
0307a0db
...
...
@@ -43,7 +43,7 @@ using std::set;
using
std
::
string
;
using
std
::
stringstream
;
CustomBondForceImpl
::
CustomBondForceImpl
(
CustomBondForce
&
owner
)
:
owner
(
owner
)
{
CustomBondForceImpl
::
CustomBondForceImpl
(
const
CustomBondForce
&
owner
)
:
owner
(
owner
)
{
}
CustomBondForceImpl
::~
CustomBondForceImpl
()
{
...
...
@@ -54,7 +54,7 @@ void CustomBondForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of bonds.
System
&
system
=
context
.
getSystem
();
const
System
&
system
=
context
.
getSystem
();
vector
<
double
>
parameters
;
int
numParameters
=
owner
.
getNumPerBondParameters
();
for
(
int
i
=
0
;
i
<
owner
.
getNumBonds
();
i
++
)
{
...
...
openmmapi/src/CustomCompoundBondForce.cpp
View file @
0307a0db
...
...
@@ -149,7 +149,7 @@ void CustomCompoundBondForce::setFunctionParameters(int index, const std::string
functions
[
index
].
max
=
max
;
}
ForceImpl
*
CustomCompoundBondForce
::
createImpl
()
{
ForceImpl
*
CustomCompoundBondForce
::
createImpl
()
const
{
return
new
CustomCompoundBondForceImpl
(
*
this
);
}
...
...
openmmapi/src/CustomCompoundBondForceImpl.cpp
View file @
0307a0db
...
...
@@ -71,7 +71,7 @@ public:
}
};
CustomCompoundBondForceImpl
::
CustomCompoundBondForceImpl
(
CustomCompoundBondForce
&
owner
)
:
owner
(
owner
)
{
CustomCompoundBondForceImpl
::
CustomCompoundBondForceImpl
(
const
CustomCompoundBondForce
&
owner
)
:
owner
(
owner
)
{
}
CustomCompoundBondForceImpl
::~
CustomCompoundBondForceImpl
()
{
...
...
@@ -82,7 +82,7 @@ void CustomCompoundBondForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of parameters and exclusions.
System
&
system
=
context
.
getSystem
();
const
System
&
system
=
context
.
getSystem
();
vector
<
int
>
particles
;
vector
<
double
>
parameters
;
int
numBondParameters
=
owner
.
getNumPerBondParameters
();
...
...
openmmapi/src/CustomExternalForce.cpp
View file @
0307a0db
...
...
@@ -112,7 +112,7 @@ void CustomExternalForce::setParticleParameters(int index, int particle, const v
particles
[
index
].
particle
=
particle
;
}
ForceImpl
*
CustomExternalForce
::
createImpl
()
{
ForceImpl
*
CustomExternalForce
::
createImpl
()
const
{
return
new
CustomExternalForceImpl
(
*
this
);
}
...
...
openmmapi/src/CustomExternalForceImpl.cpp
View file @
0307a0db
...
...
@@ -43,7 +43,7 @@ using std::set;
using
std
::
string
;
using
std
::
stringstream
;
CustomExternalForceImpl
::
CustomExternalForceImpl
(
CustomExternalForce
&
owner
)
:
owner
(
owner
)
{
CustomExternalForceImpl
::
CustomExternalForceImpl
(
const
CustomExternalForce
&
owner
)
:
owner
(
owner
)
{
}
CustomExternalForceImpl
::~
CustomExternalForceImpl
()
{
...
...
@@ -54,7 +54,7 @@ void CustomExternalForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of bonds.
System
&
system
=
context
.
getSystem
();
const
System
&
system
=
context
.
getSystem
();
vector
<
double
>
parameters
;
int
numParameters
=
owner
.
getNumPerParticleParameters
();
for
(
int
i
=
0
;
i
<
owner
.
getNumParticles
();
i
++
)
{
...
...
openmmapi/src/CustomGBForce.cpp
View file @
0307a0db
...
...
@@ -202,7 +202,7 @@ void CustomGBForce::setFunctionParameters(int index, const std::string& name, co
functions
[
index
].
max
=
max
;
}
ForceImpl
*
CustomGBForce
::
createImpl
()
{
ForceImpl
*
CustomGBForce
::
createImpl
()
const
{
return
new
CustomGBForceImpl
(
*
this
);
}
...
...
openmmapi/src/CustomGBForceImpl.cpp
View file @
0307a0db
...
...
@@ -43,7 +43,7 @@ using std::set;
using
std
::
string
;
using
std
::
stringstream
;
CustomGBForceImpl
::
CustomGBForceImpl
(
CustomGBForce
&
owner
)
:
owner
(
owner
)
{
CustomGBForceImpl
::
CustomGBForceImpl
(
const
CustomGBForce
&
owner
)
:
owner
(
owner
)
{
}
CustomGBForceImpl
::~
CustomGBForceImpl
()
{
...
...
@@ -54,7 +54,7 @@ void CustomGBForceImpl::initialize(ContextImpl& context) {
// Check for errors in the specification of parameters and exclusions.
System
&
system
=
context
.
getSystem
();
const
System
&
system
=
context
.
getSystem
();
if
(
owner
.
getNumParticles
()
!=
system
.
getNumParticles
())
throw
OpenMMException
(
"CustomGBForce must have exactly as many particles as the System it belongs to."
);
vector
<
set
<
int
>
>
exclusions
(
owner
.
getNumParticles
());
...
...
Prev
1
2
3
4
5
6
7
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