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
67fc6658
Commit
67fc6658
authored
Oct 05, 2016
by
peastman
Committed by
GitHub
Oct 05, 2016
Browse files
Merge pull request #1608 from kyleabeauchamp/intser
Add support for customIntegrator serialization and test
parents
c2166480
171f3a26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
serialization/src/CustomIntegratorProxy.cpp
serialization/src/CustomIntegratorProxy.cpp
+7
-1
serialization/tests/TestSerializeIntegrator.cpp
serialization/tests/TestSerializeIntegrator.cpp
+12
-4
No files found.
serialization/src/CustomIntegratorProxy.cpp
View file @
67fc6658
...
...
@@ -107,6 +107,12 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const {
integrator
->
addConstrainVelocities
();
}
else
if
(
computationType
==
CustomIntegrator
::
UpdateContextState
)
{
integrator
->
addUpdateContextState
();
}
else
if
(
computationType
==
CustomIntegrator
::
IfBlockStart
)
{
integrator
->
beginIfBlock
(
cit
->
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
WhileBlockStart
)
{
integrator
->
beginWhileBlock
(
cit
->
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
BlockEnd
)
{
integrator
->
endBlock
();
}
else
{
throw
(
OpenMMException
(
"Custom Integrator Deserialization: Unknown computation type"
));
}
...
...
@@ -115,4 +121,4 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const {
integrator
->
setRandomNumberSeed
(
node
.
getIntProperty
(
"randomSeed"
));
integrator
->
setConstraintTolerance
(
node
.
getDoubleProperty
(
"constraintTolerance"
));
return
integrator
;
}
\ No newline at end of file
}
serialization/tests/TestSerializeIntegrator.cpp
View file @
67fc6658
...
...
@@ -137,12 +137,20 @@ void testSerializeCustomIntegrator() {
intg
->
addGlobalVariable
(
"oute"
,
0
);
intg
->
addGlobalVariable
(
"oute1"
,
0
);
intg
->
addGlobalVariable
(
"oute2"
,
0
);
intg
->
addGlobalVariable
(
"oute3_conditional_v1"
,
0
);
// HACK: need addGlobals to be alphabetical to work around bug
intg
->
addGlobalVariable
(
"oute3_conditional_v2"
,
0
);
intg
->
addComputePerDof
(
"outf"
,
"f"
);
intg
->
addComputePerDof
(
"outf1"
,
"f1"
);
intg
->
addComputePerDof
(
"outf2"
,
"f2"
);
intg
->
addComputeGlobal
(
"oute"
,
"energy"
);
intg
->
addComputeGlobal
(
"oute1"
,
"energy1"
);
intg
->
addComputeGlobal
(
"oute2"
,
"energy2"
);
intg
->
beginIfBlock
(
"1 > 0"
);
intg
->
addComputeGlobal
(
"oute3_conditional_v1"
,
"energy"
);
intg
->
endBlock
();
intg
->
beginWhileBlock
(
"0 > 1"
);
intg
->
addComputeGlobal
(
"oute3_conditional_v2"
,
"energy"
);
intg
->
endBlock
();
intg
->
addUpdateContextState
();
intg
->
addConstrainVelocities
();
intg
->
addComputeSum
(
"summand2"
,
"v*v+f*f"
);
...
...
@@ -216,13 +224,13 @@ int main() {
testSerializeVerletIntegrator
();
testSerializeVariableLangevinIntegrator
();
testSerializeVariableVerletIntegrator
();
testSerializeLangevinIntegrator
();
testSerializeLangevinIntegrator
();
testSerializeCompoundIntegrator
();
}
catch
(
const
exception
&
e
)
{
return
1
;
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
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