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
780bbf8f
Commit
780bbf8f
authored
Apr 15, 2014
by
peastman
Browse files
Merge pull request #412 from peastman/master
Cleanup to the recent serialization code changes
parents
436d542d
7a6f4b2f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
46 deletions
+47
-46
serialization/src/CustomNonbondedForceProxy.cpp
serialization/src/CustomNonbondedForceProxy.cpp
+33
-31
serialization/src/NonbondedForceProxy.cpp
serialization/src/NonbondedForceProxy.cpp
+12
-14
serialization/tests/TestSerializeCustomNonbondedForce.cpp
serialization/tests/TestSerializeCustomNonbondedForce.cpp
+2
-1
No files found.
serialization/src/CustomNonbondedForceProxy.cpp
View file @
780bbf8f
...
...
@@ -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) 2010 Stanford University and the Authors.
*
* Portions copyright (c) 2010
-2014
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -102,7 +102,7 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
try
{
CustomNonbondedForce
*
force
=
new
CustomNonbondedForce
(
node
.
getStringProperty
(
"energy"
));
force
->
setNonbondedMethod
((
CustomNonbondedForce
::
NonbondedMethod
)
node
.
getIntProperty
(
"method"
));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoff"
,
1.0
));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoff"
));
force
->
setUseSwitchingFunction
(
node
.
getBoolProperty
(
"useSwitchingFunction"
,
false
));
force
->
setSwitchingDistance
(
node
.
getDoubleProperty
(
"switchingDistance"
,
-
1.0
));
force
->
setUseLongRangeCorrection
(
node
.
getBoolProperty
(
"useLongRangeCorrection"
,
false
));
...
...
@@ -149,8 +149,12 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
new
Continuous1DFunction
(
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)));
}
}
// Catch exceptions if InteractionGroups node is missing, in order to give backwards compatibility.
try
{
bool
hasInteractionGroups
=
false
;
// Older files will be missing this block.
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
().
size
();
i
++
)
{
if
(
node
.
getChildren
()[
i
].
getName
()
==
"InteractionGroups"
)
hasInteractionGroups
=
true
;
}
if
(
hasInteractionGroups
)
{
const
SerializationNode
&
interactionGroups
=
node
.
getChildNode
(
"InteractionGroups"
);
for
(
int
i
=
0
;
i
<
(
int
)
interactionGroups
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
interactionGroup
=
interactionGroups
.
getChildren
()[
i
];
...
...
@@ -166,8 +170,6 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
set2
.
insert
(
set2node
.
getChildren
()[
j
].
getIntProperty
(
"index"
));
force
->
addInteractionGroup
(
set1
,
set2
);
}
}
catch
(...)
{
// do nothing to allow backwards-compatibility
}
return
force
;
}
...
...
serialization/src/NonbondedForceProxy.cpp
View file @
780bbf8f
...
...
@@ -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) 2010 Stanford University and the Authors.
*
* Portions copyright (c) 2010
-2014
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -80,20 +80,18 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const {
NonbondedForce
*
force
=
new
NonbondedForce
();
try
{
force
->
setNonbondedMethod
((
NonbondedForce
::
NonbondedMethod
)
node
.
getIntProperty
(
"method"
));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoff"
,
1.0
));
force
->
setUseSwitchingFunction
(
node
.
getBoolProperty
(
"useSwitchingFunction"
,
false
));
force
->
setSwitchingDistance
(
node
.
getDoubleProperty
(
"switchingDistance"
,
-
1.0
));
force
->
setEwaldErrorTolerance
(
node
.
getDoubleProperty
(
"ewaldTolerance"
,
5e-4
));
force
->
setReactionFieldDielectric
(
node
.
getDoubleProperty
(
"rfDielectric"
,
78.3
));
force
->
setUseDispersionCorrection
(
node
.
getIntProperty
(
"dispersionCorrection"
,
true
));
double
alpha
;
int
nx
,
ny
,
nz
;
alpha
=
node
.
getDoubleProperty
(
"alpha"
,
0.0
);
nx
=
node
.
getIntProperty
(
"nx"
,
0
);
ny
=
node
.
getIntProperty
(
"ny"
,
0
);
nz
=
node
.
getIntProperty
(
"nz"
,
0
);
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoff"
));
force
->
setUseSwitchingFunction
(
node
.
getBoolProperty
(
"useSwitchingFunction"
,
false
));
force
->
setSwitchingDistance
(
node
.
getDoubleProperty
(
"switchingDistance"
,
-
1.0
));
force
->
setEwaldErrorTolerance
(
node
.
getDoubleProperty
(
"ewaldTolerance"
));
force
->
setReactionFieldDielectric
(
node
.
getDoubleProperty
(
"rfDielectric"
));
force
->
setUseDispersionCorrection
(
node
.
getIntProperty
(
"dispersionCorrection"
));
double
alpha
=
node
.
getDoubleProperty
(
"alpha"
,
0.0
);
int
nx
=
node
.
getIntProperty
(
"nx"
,
0
);
int
ny
=
node
.
getIntProperty
(
"ny"
,
0
);
int
nz
=
node
.
getIntProperty
(
"nz"
,
0
);
force
->
setPMEParameters
(
alpha
,
nx
,
ny
,
nz
);
force
->
setReciprocalSpaceForceGroup
(
node
.
getIntProperty
(
"recipForceGroup"
,
-
1
));
force
->
setReciprocalSpaceForceGroup
(
node
.
getIntProperty
(
"recipForceGroup"
,
-
1
));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
...
...
serialization/tests/TestSerializeCustomNonbondedForce.cpp
View file @
780bbf8f
...
...
@@ -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) 2010 Stanford University and the Authors.
*
* Portions copyright (c) 2010
-2014
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -66,6 +66,7 @@ void testSerialization() {
std
::
set
<
int
>
set1
,
set2
;
set1
.
insert
(
0
);
set2
.
insert
(
1
);
set2
.
insert
(
2
);
force
.
addInteractionGroup
(
set1
,
set2
);
// Serialize and then deserialize it.
...
...
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