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
1c7d6312
Commit
1c7d6312
authored
Nov 11, 2014
by
peastman
Browse files
Merge pull request #716 from peastman/master
CustomIntegrator throws an exception if variable names are ambiguous
parents
dbd7fd3a
ad5821ff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
openmmapi/src/CustomIntegrator.cpp
openmmapi/src/CustomIntegrator.cpp
+15
-3
No files found.
openmmapi/src/CustomIntegrator.cpp
View file @
1c7d6312
...
...
@@ -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) 2011-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2011-201
4
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -36,11 +36,11 @@
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/kernels.h"
#include <set>
#include <string>
using
namespace
OpenMM
;
using
std
::
string
;
using
std
::
vector
;
using
namespace
std
;
CustomIntegrator
::
CustomIntegrator
(
double
stepSize
)
:
globalsAreCurrent
(
true
),
forcesAreValid
(
false
)
{
setStepSize
(
stepSize
);
...
...
@@ -52,6 +52,18 @@ CustomIntegrator::CustomIntegrator(double stepSize) : globalsAreCurrent(true), f
void
CustomIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
throw
OpenMMException
(
"This Integrator is already bound to a context"
);
vector
<
std
::
string
>
variableList
;
set
<
std
::
string
>
variableSet
;
variableList
.
insert
(
variableList
.
end
(),
globalNames
.
begin
(),
globalNames
.
end
());
variableList
.
insert
(
variableList
.
end
(),
perDofNames
.
begin
(),
perDofNames
.
end
());
for
(
int
i
=
0
;
i
<
(
int
)
variableList
.
size
();
i
++
)
{
string
&
name
=
variableList
[
i
];
if
(
variableSet
.
find
(
name
)
!=
variableSet
.
end
())
throw
OpenMMException
(
"The Integrator defines two variables with the same name: "
+
name
);
variableSet
.
insert
(
name
);
if
(
contextRef
.
getParameters
().
find
(
name
)
!=
contextRef
.
getParameters
().
end
())
throw
OpenMMException
(
"The Integrator defines a variable with the same name as a Context parameter: "
+
name
);
}
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateCustomStepKernel
::
Name
(),
contextRef
);
...
...
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