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
a162c89e
Commit
a162c89e
authored
Sep 22, 2014
by
Robert McGibbon
Browse files
Add by-name getters to CustomIntegrator API
parent
fb95c56c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
openmmapi/include/openmm/CustomIntegrator.h
openmmapi/include/openmm/CustomIntegrator.h
+15
-0
openmmapi/src/CustomIntegrator.cpp
openmmapi/src/CustomIntegrator.cpp
+19
-0
No files found.
openmmapi/include/openmm/CustomIntegrator.h
View file @
a162c89e
...
...
@@ -302,6 +302,13 @@ public:
* @return the current value of the variable
*/
double
getGlobalVariable
(
int
index
)
const
;
/**
* Get the current value of a global variable, specified by name.
*
* @param name the name of the variable to get
* @return the current value of the parameter
*/
double
getGlobalVariableByName
(
const
std
::
string
&
name
);
/**
* Set the value of a global variable.
*
...
...
@@ -324,6 +331,14 @@ public:
* are stored into this
*/
void
getPerDofVariable
(
int
index
,
std
::
vector
<
Vec3
>&
values
)
const
;
/**
* Get the value of a per-DOF variable, specified by name.
*
* @param name the name of the variable to get
* @param values the values of the variable for all degrees of freedom
* are stored into this
*/
void
getPerDofVariableByName
(
const
std
::
string
&
name
,
std
::
vector
<
Vec3
>&
values
)
const
;
/**
* Set the value of a per-DOF variable.
*
...
...
openmmapi/src/CustomIntegrator.cpp
View file @
a162c89e
...
...
@@ -124,6 +124,15 @@ double CustomIntegrator::getGlobalVariable(int index) const {
return
globalValues
[
index
];
}
double
CustomIntegrator
::
getGlobalVariableByName
(
const
string
&
name
)
const
{
for
(
int
i
=
0
;
i
<
(
int
)
globalNames
.
size
();
i
++
)
if
(
name
==
globalNames
[
i
])
{
return
getGlobalVariable
(
i
);
}
}
throw
OpenMMException
(
"Illegal global variable name: "
+
name
);
}
void
CustomIntegrator
::
setGlobalVariable
(
int
index
,
double
value
)
{
ASSERT_VALID_INDEX
(
index
,
globalValues
);
if
(
owner
!=
NULL
&&
!
globalsAreCurrent
)
{
...
...
@@ -152,6 +161,16 @@ void CustomIntegrator::getPerDofVariable(int index, vector<Vec3>& values) const
kernel
.
getAs
<
const
IntegrateCustomStepKernel
>
().
getPerDofVariable
(
*
context
,
index
,
values
);
}
void
CustomIntegrator
::
getPerDofVariableByName
(
const
string
&
name
,
vector
<
Vec3
>&
values
)
const
{
for
(
int
i
=
0
;
i
<
(
int
)
perDofNames
.
size
();
i
++
)
if
(
name
==
perDofNames
[
i
])
{
getPerDofVariable
(
i
,
values
);
return
;
}
}
throw
OpenMMException
(
"Illegal per-DOF variable name: "
+
name
);
}
void
CustomIntegrator
::
setPerDofVariable
(
int
index
,
const
vector
<
Vec3
>&
values
)
{
ASSERT_VALID_INDEX
(
index
,
perDofValues
);
if
(
owner
!=
NULL
&&
values
.
size
()
!=
context
->
getSystem
().
getNumParticles
())
...
...
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