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
ad5821ff
Commit
ad5821ff
authored
Nov 11, 2014
by
peastman
Browse files
CustomIntegrator throws an exception if variable names are ambiguous
parent
d5666536
Changes
1
Hide 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 @
ad5821ff
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* 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 *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -36,11 +36,11 @@
...
@@ -36,11 +36,11 @@
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <set>
#include <string>
#include <string>
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
std
::
string
;
using
namespace
std
;
using
std
::
vector
;
CustomIntegrator
::
CustomIntegrator
(
double
stepSize
)
:
globalsAreCurrent
(
true
),
forcesAreValid
(
false
)
{
CustomIntegrator
::
CustomIntegrator
(
double
stepSize
)
:
globalsAreCurrent
(
true
),
forcesAreValid
(
false
)
{
setStepSize
(
stepSize
);
setStepSize
(
stepSize
);
...
@@ -52,6 +52,18 @@ CustomIntegrator::CustomIntegrator(double stepSize) : globalsAreCurrent(true), f
...
@@ -52,6 +52,18 @@ CustomIntegrator::CustomIntegrator(double stepSize) : globalsAreCurrent(true), f
void
CustomIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
void
CustomIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
throw
OpenMMException
(
"This Integrator is already bound to a context"
);
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
;
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateCustomStepKernel
::
Name
(),
contextRef
);
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